Running Sun's javac on Classpath

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



To begin with, building Javac results in a .class file with a > 1.5
version ID.  That's easy to fix if you alter the makefile to change
the version ID:

--- /tmp/compiler/Makefile      2006-11-12 02:14:13.000000000 +0000
+++ ./Makefile  2006-11-20 17:08:06.000000000 +0000
@@ -147,7 +147,7 @@
        $(JAVAC) -d $(BUILD_BOOTCLASSES) -source $(COMPILER_SOURCE_LEVEL) -g:source,lines @$(BUILD_JAVAC_SRCFILES)
        $(MKDIR) -p $(BUILD_CLASSES)
        $(JAVA) -cp $(BUILD_BOOTCLASSES):$(SRC_CLASSES) com.sun.tools.javac.Main \
-               -d $(BUILD_CLASSES) -g:source,lines @$(BUILD_JAVAC_SRCFILES)
+               -d $(BUILD_CLASSES) -source $(COMPILER_SOURCE_LEVEL) -target $(COMPILER_SOURCE_LEVEL) -g:source,lines @$(BUILD_JAVAC_SRCFILES)
        ( $(ECHO) "Main-Class: com.sun.tools.javac.Main" ; \
          $(ECHO) "Built-By: $$USER" ; \
          $(ECHO) "Built-At: `date`" ) > $(BUILD)/javac.MF

Then you have something that will run on a 1.5 runtime.

Unfortunately, with Classpath you soon come across another problem:

--------------------------------------------------------------------------------
java.lang.ExceptionInInitializerError
   at java.lang.Class.initializeClass(natClass.cc:754)
   at com.sun.tools.javac.main.JavaCompiler.initProcessAnnotations(JavaCompiler.java:891)
   at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:741)
   at com.sun.tools.javac.main.Main.compile(Main.java:370)
   at com.sun.tools.javac.main.Main.compile(Main.java:296)
   at com.sun.tools.javac.main.Main.compile(Main.java:287)
   at com.sun.tools.javac.Main.compile(Main.java:86)
   at com.sun.tools.javac.Main.main(Main.java:71)
Caused by: java.util.regex.PatternSyntaxException: At position 7 in regular expression pattern:
At position 0 in regular expression pattern:
unsupported name all
	(\P{all})+
	       ^
   at java.util.regex.Pattern.<init>(Pattern.java:113)
   at java.util.regex.Pattern.compile(Pattern.java:152)
   at com.sun.tools.javac.processing.JavacProcessingEnvironment.<clinit>(JavacProcessingEnvironment.java:1218)
   at java.lang.Class.initializeClass(natClass.cc:746)
   ...7 more
Caused by: gnu.java.util.regex.REException: At position 7 in regular expression pattern:
At position 0 in regular expression pattern:
unsupported name all
   at gnu.java.util.regex.RE.getRETokenNamedProperty(RE.java:1490)
   at gnu.java.util.regex.RE.initialize(RE.java:1060)
   at gnu.java.util.regex.RE.<init>(RE.java:323)
   at gnu.java.util.regex.RE.initialize(RE.java:716)
   at gnu.java.util.regex.RE.<init>(RE.java:323)
   at java.util.regex.Pattern.<init>(Pattern.java:108)
   ...10 more
Caused by: gnu.java.util.regex.REException: At position 0 in regular expression pattern:
unsupported name all
   at gnu.java.util.regex.RETokenNamedProperty.getHandler(RETokenNamedProperty.java:263)
   at gnu.java.util.regex.RETokenNamedProperty.<init>(RETokenNamedProperty.java:97)
   at gnu.java.util.regex.RE.getRETokenNamedProperty(RE.java:1486)
   ...15 more
--------------------------------------------------------------------------------

which is caused by this line:

    private static final Pattern noMatches  = Pattern.compile("(\\P{all})+");

"all" doesn't seem to be a well-defined regular-expression construct.
http://java.sun.com/j2se/1.5.0/docs/api/java/util/regex/Pattern.html
doesn't mention it, but I guess it's something like:


Index: regex/RETokenNamedProperty.java
===================================================================
*** regex/RETokenNamedProperty.java	(revision 118943)
--- regex/RETokenNamedProperty.java	(working copy)
*************** final class RETokenNamedProperty extends
*** 170,175 ****
--- 170,179 ----
            name.equals("Space") ) {
           return new POSIXHandler(name);
        }
+ 
+       if (name.equals("all"))
+ 	return new AllHandler();
+ 
        if (name.startsWith("In")) {
  	  try {
  	      name = name.substring(2);
*************** final class RETokenNamedProperty extends
*** 312,315 ****
--- 316,325 ----
        }
    }
  
+   private static class AllHandler extends Handler {
+     public boolean includes(char c) 
+     {
+       return true;
+     }
+   }
  }

Once we're past that, all goes well until

java.lang.NoClassDefFoundError: sun.misc.Service
   at com.sun.tools.javac.processing.JavacProcessingEnvironment.initProcessorIterator(JavacProcessingEnvironment.java:209)
   at com.sun.tools.javac.processing.JavacProcessingEnvironment.<init>(JavacProcessingEnvironment.java:159)
   at com.sun.tools.javac.main.JavaCompiler.initProcessAnnotations(JavaCompiler.java:891)
   at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:741)
   at com.sun.tools.javac.main.Main.compile(Main.java:370)
   at com.sun.tools.javac.main.Main.compile(Main.java:296)
   at com.sun.tools.javac.main.Main.compile(Main.java:287)
   at com.sun.tools.javac.Main.compile(Main.java:86)
   at com.sun.tools.javac.Main.main(Main.java:71)

which is caused by

                        Iterator<Processor> it =
                            Service.providers(Processor.class, processorCL);

As I understand it, sun.misc.Service has now been promoted to
java.util.Service, but I can't anywhere find a specification for this
class.

The only private APIs used in the compiler are:

sun/tools/javac/model/AnnotationProxyMaker.java:import sun.reflect.annotation.*;
sun/tools/javac/processing/JavacProcessingEnvironment.java:import sun.misc.Service;
sun/tools/javac/processing/JavacProcessingEnvironment.java:import sun.misc.ServiceConfigurationError;

So, I imagine it shouldn't be terribly hard to remove these dependencies.

Andrew.


[Index of Archives]     [Linux Kernel]     [Linux Cryptography]     [Fedora]     [Fedora Directory]     [Red Hat Development]

  Powered by Linux