Hey Tom, java-gcj-compat's javac currently ignores the extensions directory (as we've both discovered). The Eclipse compiler doesn't have an extensions directory option either, so we have to expand it manually. This is similar to what Eclipse's JDTCompilerAdapter class does for ant. AG
2005-03-06 Anthony Green <green@xxxxxxxxxx> * com/sun/tools/javac/Main.java (compile): Append the extensions directory to the bootclasspath. (expandExtDirs): New method. Index: com/sun/tools/javac/Main.java =================================================================== RCS file: /cvs/rhug/java-gcj-compat/com/sun/tools/javac/Main.java,v retrieving revision 1.4 diff -c -r1.4 Main.java *** com/sun/tools/javac/Main.java 2 Mar 2005 15:49:28 -0000 1.4 --- com/sun/tools/javac/Main.java 6 Mar 2005 08:52:02 -0000 *************** *** 88,93 **** --- 88,114 ---- ecjMethod = klass.getMethod ("compile", new Class[] {String[].class}); } + // Expand a extensions directory list into a classpath. + private String expandExtDirs (String extdirs) + { + StringBuffer paths = new StringBuffer(""); + String[] dirs = extdirs.split (File.pathSeparator); + for (int i = 0; i < dirs.length; i++) + { + File dir = new File (dirs[i]); + if (dir.isDirectory ()) + { + File[] files = dir.listFiles (); + for (int j = 0; j < files.length; j++) + { + paths.append (File.pathSeparator); + paths.append (files[j].getAbsolutePath()); + } + } + } + return paths.toString (); + } + public int compile (String[] args) throws Exception { // FIXME: Remove arguments supported by javac but not by ecj. We *************** *** 101,106 **** --- 122,131 ---- // We must set the bootclasspath if this isn't already done for us. boolean hasBootclasspath = false; + // We add the extensions directory to the end of the bootclasspath. + // Default to the running JVM's extensions directory. + String extdirs = System.getProperty ("java.ext.dirs"); + for (int i = 0; i < args.length; i++) { if (args[i].equals ("-bootclasspath")) *************** *** 111,116 **** --- 136,148 ---- { classpathIndex = i+1; } + if (args[i].equals ("-extdirs")) + { + extdirs = args[i+1]; + args[i] = "-REMOVETHISARGUMENT"; + args[i + 1] = "-REMOVETHISARGUMENT"; + removeCount += 2; + } else if (args[i].equals ("-sourcepath")) { sourcepath = args[i+1]; *************** *** 127,133 **** // Append the sourcepath to the classpath. if (sourcepath != null && classpathIndex != -1) ! args[classpathIndex] += ":" + sourcepath; String[] strippedArgs = new String[args.length - removeCount + (hasBootclasspath ? 0 : 2)]; --- 159,165 ---- // Append the sourcepath to the classpath. if (sourcepath != null && classpathIndex != -1) ! args[classpathIndex] += File.pathSeparator + sourcepath; String[] strippedArgs = new String[args.length - removeCount + (hasBootclasspath ? 0 : 2)]; *************** *** 135,148 **** for (int i = 0; i < args.length; i++) { if (!args[i].equals ("-REMOVETHISARGUMENT")) ! strippedArgs[k++] = args[i]; } if (! hasBootclasspath) { strippedArgs[k++] = "-bootclasspath"; ! strippedArgs[k++] = System.getProperty ("sun.boot.class.path"); } ! Object ecjInstance = ecjConstructor.newInstance (new Object[] { new PrintWriter (System.out), new PrintWriter (System.err), --- 167,189 ---- for (int i = 0; i < args.length; i++) { if (!args[i].equals ("-REMOVETHISARGUMENT")) ! { ! if (!args[i].equals ("-bootclasspath")) ! strippedArgs[k++] = args[i]; ! else ! { ! strippedArgs[k++] = args[i++]; ! strippedArgs[k++] = args[i] + File.pathSeparator + expandExtDirs (extdirs); ! } ! } } if (! hasBootclasspath) { strippedArgs[k++] = "-bootclasspath"; ! strippedArgs[k++] = System.getProperty ("sun.boot.class.path") ! + File.pathSeparator + expandExtDirs (extdirs); } ! Object ecjInstance = ecjConstructor.newInstance (new Object[] { new PrintWriter (System.out), new PrintWriter (System.err),