Unable to reference sun.*

Brendon McLean java.net at twistedprotein.com
Sat May 10 05:24:49 PDT 2008


I've been developing an application on the Mac, but the target  
audience will be cross platform.  I've just discovered that the  
application doesn't compile on either Windows or Linux on Java 6.  The  
compiler is complaining that one of the sun.* package I'm importing  
doesn't exist.  I'm very well aware that linking to these packages is  
strongly discouraged, but I was wondering whether perhaps it is now  
enforced?  I have the following file:
import sun.reflect.misc.MethodUtil;

public class Test {
     public static void main(String[] args) throws  
NoSuchMethodException {
         MethodUtil.getMethod(Test.class, "main", new Class[] 
This file will:
* Compile on all platforms under Java 5
* Compile on all platforms when compiled in IntelliJ IDEA
* Compile on Java 6 using javac on the Mac.
* Fail to compile on Linux and Windows using Java 6 javac.

The package is located in classes.jar on the Mac and in rt.jar on all  
other platforms.  In other words, this class should compile without  
any classpath argument.  Also of interest, is that referencing classes  
in the com.sun.* packages will work but generate a warning.  I can  
only conclude that there is something about the Java 6 compiler that  
is actively preventing me from linking to sun.* packages.

Is this true?  Or have I missed something so obvious I'm going to have  
to give up programming and pursue farming?

Brendon McLean.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20080510/e1182612/attachment.html 

More information about the compiler-dev mailing list