0

I'm actually developing a Java applet to access an HSM in order to sign data.

So I'm using a lot of Sun packages (PKCS11 wrapper and sunPKCS11 provider).

I saw that link : http://www.oracle.com/technetwork/java/faq-sun-packages-142232.html that tells us it is discouraged to use sun packages.

But I want to make sure why. I'm actually compiling my code in Java 1.6 x86 JDK.

Is it possible that end-users won't be able to use my application when updating their version of Java ? Or will the problem appear only if I change my JDK to compile my code ? Or is it both situations ?

Thanks in advance for your clarifications.

Thordax
  • 1,673
  • 4
  • 28
  • 54

2 Answers2

6

It's stated pretty clearly in the documentation your linked :

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.

So end-users might not be able to use your app if they're not using the same JDK as you.

And yes, in the future you might have problems too with a newer version of your JDK.

Buhake Sindi
  • 87,898
  • 29
  • 167
  • 228
alain.janinm
  • 19,951
  • 10
  • 65
  • 112
3

The main problem is that those packages/classes might not exist in other JDKs or versions of the same JDK. You might get problems compiling your code on another JDK but it's mainly the users which you should think about: if their runtime lacks the classes that are needed they eventually try to run some code that isn't available and depending on how you structured your application the result might range from functionality simply being unavailable to a crash of the application.

Note that this might also be the case if you're hosting the application, i.e. when it is a web application. We ran into the same problem with some of the imaging classes which prevented us from upgrading the Java version on our servers without having to change the application as well.

Thomas
  • 87,414
  • 12
  • 119
  • 157
  • That's the almost perfect answer: I would add a reference to the sun classes not being part of the specification / standard API. You should only use classes that are in the javadocs. – Gimby Oct 23 '14 at 08:14