what happened to sun.* packages

后端 未结 2 589
孤独总比滥情好
孤独总比滥情好 2021-01-29 07:46

I don\'t find any references in JDK 7 documentation regarding sun.* packages. Is it deprecated. But then what are the substitutes?

For eg: sun.reflect

相关标签:
2条回答
  • 2021-01-29 08:06

    You have to use the java.lang.reflect package for reflection purposes.

    See: http://docs.oracle.com/javase/8/docs/api/java/lang/reflect/package-summary.html

    0 讨论(0)
  • 2021-01-29 08:08

    The sun.reflect packages are not deprecated. They are for internal use by the JDK only. Oracle (formerly Sun) does not document the internal packages and does not guarantee that they will exist on all Java platform implementations (any vendor can make a Java platform implementation) nor that they will be the same in all versions of the standard Oracle Java platform implementation.

    Oracle explains this on their website:

    The sun.* packages are not part of the supported, public interface.

    A Java program that directly calls into sun.* packages is not guaranteed to work on all Java-compatible platforms. In fact, such a program is not guaranteed to work even in future versions on the same platform.

    0 讨论(0)
提交回复
热议问题