pihentagy
pihentagy

Reputation: 6285

Is it safe to use a class inside the package sun.misc?

For example should I use sun.misc.IOUtils?

Upvotes: 4

Views: 859

Answers (3)

Vineet Reynolds
Vineet Reynolds

Reputation: 76709

No, while this might appear to be fine when running on Oracle/Sun JVMs, it is certainly not the case with JVMs developed by IBM or HP, or any other organization (GNU perhaps, and probably even Apple) that does not provide these classes.

You would realize this only when you have to deploy and run on other environments.

Upvotes: 2

planetjones
planetjones

Reputation: 12633

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.

More info here.

Upvotes: 5

genobis
genobis

Reputation: 1101

No, it's not. It's an internal API and there is no guarantee that it will stay unchanged. Use external libraries.

Upvotes: 7

Related Questions