Why is sun.misc discouraged for use?

2019-07-13 11:33发布

I've been using the BASE64Encoder and BASE64Decoder in sun.misc; I'm using Eclipse and had to turn to warnings since the access is restricted to it by default.

The classes works perfectly, but during my work with this I've read plenty of places that one should not use sun.misc at all but no one states a proper reason.

Should I stay away from sun.misc and why?

1条回答
我只想做你的唯一
2楼-- · 2019-07-13 11:39

There is no promise to continue support for these classes; they may be removed from the JDK without warning at any release.

Also, not all JDKs have these classes, so your code may not run on all platforms, which goes against the intention of java's "compile once, run anywhere" philosophy.

查看更多
登录 后发表回答