[Java Spec Report] javac -source 1.5 @ mac

"Pat LaVarre" <[email protected]> Sat, 06 Mar 2004 23:30:45 -0000
Newsgroups gmane.comp.java.spec-report
Message-ID <[email protected]>
// In short:

We cannot easily grant the natural wish to try javac -source 1.5 in Mac OS X.  Although the 
javac, "written once", runs as a .class compiled from .java, those .class files actually vary 
slightly by system, and do not "run anywhere".

True or false or irredeemably wrong-headed?

// At length:

Lately a friend dreamed that I might could try javac -source 1.5 much, even though lately 
I've been spending more free time on Mac OS X rather than on Linux or Windows.

We tried a number of techniques that more plainly didn't work, but then eventually tried 
copying the com.sun.tools.javac.Main.class of Linux lib/tools.jar over to the Mac.

Some time later I began to guess that the class name com.sun.tools.javac.Main is handled 
specially by Mac java e.g. by being found in a bootclasspath I don't know how to override.

Accordingly, I inflated my lib/tools.jar from the Linux beta 1.5.0.  I copied my javac/
Main.class to become javac/Pain.class and began binary-editing that .class file.  I 
decremented the major:minor version and I changed from "Main" to "Pain".  Then I saw:

$ ls -l tools.jar 
-rw-r--r--  1 pat  pat  6002223  6 Mar 15:08 tools.jar
$ 
$ cmp -l com/sun/tools/javac/Main.class com/sun/tools/javac/Pain.class
     8  61  60
    78 115 120
   145 115 120
   177 115 120
$ 
$ java -cp . com.sun.tools.javac.Pain -target 1.5 empty.java
Exception in thread "main" java.lang.VerifyError: (class: com/sun/tools/javac/Pain, 
method: <clinit> signature: ()V) Illegal type in constant pool
$ 
$ java -Xverify:none -cp . com.sun.tools.javac.Pain -target 1.5 empty.java
Bus error
$ 

I suppose I won't quit until after I more carefully disassemble my Pain.class, but meanwhile 
...

I guess essentially this exercise serves to remind me, ...

People developing compilers for a runtime naturally face a chicken-and-egg trouble in 
trying to advance the runtime and the compiler together.

Sun has chosen to give away only matched pairs, rather than to try and make the new 
compiler work with the old runtime.

Although the javac, "written once", runs as a .class compiled from .java, those .class files 
actually vary slightly by system, and do not "run anywhere".

Pat LaVarre




------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/5cFolB/TM
---------------------------------------------------------------------~->

To unsubscribe from this mailing list, send an email to:
[email protected]
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/java-spec-report/

<*> To unsubscribe from this group, send an email to:
     [email protected]

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/