Java 6 and SwingUtilities2

The application has a component that uses com.sun.java.swing.SwingUtilities2. Now I understand that this class should not be used, but it is a component in the system that uses it.

Therefore, since it is no longer available in Java 6, I get a NoClassDefFoundError. How can I get around this problem without the need to update the component, since I still do not know if this option exists.

+5
source share
4 answers

If you have no other choice, then you should find out what exactly this class uses from SwingUtilities2, and then make a proxy for this function in your own SwingUtilities2. Then you can paste it into your own com.sun.java.swing package, which will overlap with the original one, and if the same classloader that loads your component also knows about SwingUtilities2, then it will see another and your application will work.

Depending on what the component is and what it used from SwingUtilities2, it can be much more complicated than updating it or even rewriting it.

+5
source

Da-doom! That is why you should pay attention to these annoying warnings warning you not to rely on the internals of the JVM!

+1

, , , .

SwingUtilities2 -, . , , .

+1

(- ) - Java 6. sun.swing.SU2 com.sun... SU2 jar (, java6fix.jar) . , - jvm bootclasspath. com.sun..SU2 sun.swing.SU2. , Java6, , . , ((Boolean)c.getClientProperty(AA_TEXT_PROPERTY_KEY));, you can put your own client property for this component to prevent NPE. When you take this path, you can simply create your own com.sun ... SU2.AA_TEXT_PROPERTY_KEY and call c.setClientProperty (AA_TEXT_PROPERTY_KEY, true) for this component. Also try disabling anti-aliasing on the component, if possible.

+1
source

All Articles