Index: batch/org/eclipse/jdt/internal/compiler/batch/Main.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/Main.java,v retrieving revision 1.196 diff -u -r1.196 Main.java --- batch/org/eclipse/jdt/internal/compiler/batch/Main.java 16 May 2005 20:48:06 -0000 1.196 +++ batch/org/eclipse/jdt/internal/compiler/batch/Main.java 17 May 2005 20:33:09 -0000 @@ -1199,11 +1199,16 @@ final int InsideDefaultEncoding = 64; final int InsideBootClasspath = 128; final int InsideMaxProblems = 256; + final int InsideExtDirs = 512; final int Default = 0; String[] bootclasspaths = null; + String[] extdirs = null; + String[] extlibs = null; int DEFAULT_SIZE_CLASSPATH = 4; int pathCount = 0; int bootclasspathCount = 0; + int extdirsCount = 0; + int extlibsCount = 0; int index = -1, filesCount = 0, argCount = argv.length; int mode = Default; this.repetitions = 0; @@ -1454,6 +1459,14 @@ this.produceRefInfo = true; continue; } + if (currentArg.equals("-extdirs")) {//$NON-NLS-1$ + if (extdirsCount > 0) + throw new InvalidInputException( + Main.bind("configure.duplicateExtDirs", currentArg)); //$NON-NLS-1$ + extdirs = new String[DEFAULT_SIZE_CLASSPATH]; + mode = InsideExtDirs; + continue; + } if (currentArg.equals("-inlineJSR")) { //$NON-NLS-1$ mode = Default; this.options.put( @@ -1837,6 +1850,23 @@ useEnableJavadoc = true; continue; } + if (mode == InsideExtDirs) { + StringTokenizer tokenizer = new StringTokenizer(currentArg, File.pathSeparator); + while (tokenizer.hasMoreTokens()) { + int length; + if ((length = extdirs.length) <= extdirsCount) { + System.arraycopy( + extdirs, + 0, + (extdirs = new String[length * 2]), + 0, + length); + } + extdirs[extdirsCount++] = tokenizer.nextToken(); + } + mode = Default; + continue; + } if (mode == TargetSetting) { if (didSpecifyTarget) { throw new InvalidInputException( @@ -2058,6 +2088,51 @@ this.classpaths[pathCount++] = System.getProperty("user.dir");//$NON-NLS-1$ } + if (extdirsCount == 0) { + String extdirsStr = System.getProperty("java.ext.dirs"); //$NON-NLS-1$ + + extdirs = new String[DEFAULT_SIZE_CLASSPATH]; + StringTokenizer tokenizer = new StringTokenizer(extdirsStr, File.pathSeparator); + while (tokenizer.hasMoreTokens()) { + int length; + if ((length = extdirs.length) <= extdirsCount) { + System.arraycopy( + extdirs, + 0, + (extdirs = new String[length * 2]), + 0, + length); + } + extdirs[extdirsCount++] = tokenizer.nextToken(); + } + } + + // at this point extdirs contains all the extension + // directories parsed out into individual strings, and + // extdirsCount stores the total number of extensions + // directories. + + if (extdirsCount != 0 && extlibsCount == 0) { + File[][] systemLibrariesJars = getLibrariesFiles(extdirs, extdirsCount); + if (systemLibrariesJars != null) { + int length = getLength(systemLibrariesJars); + extlibs = new String[length]; + for (int i = 0, max = systemLibrariesJars.length; i < max; i++) { + File[] current = systemLibrariesJars[i]; + if (current != null) { + for (int j = 0, max2 = current.length; j < max2; j++) { + extlibs[extlibsCount++] = current[j].getAbsolutePath(); + } + } + } + } + } + + // at this point extlibs contains all the extension + // libraries parsed out into individual strings, and + // extlibsCount stores the total number of extensions + // libraries. + if (bootclasspathCount == 0) { /* no bootclasspath specified * we can try to retrieve the default librairies of the VM used to run @@ -2080,7 +2155,7 @@ try { javaHomeFile = new File(javaHomeFile.getCanonicalPath()); // add all jars in the lib subdirectory - File[] directoriesToCheck = new File[] { new File(javaHomeFile, "lib"), new File(javaHomeFile, "lib/ext")};//$NON-NLS-1$//$NON-NLS-2$ + File[] directoriesToCheck = new File[] { new File(javaHomeFile, "lib") };//$NON-NLS-1$ File[][] systemLibrariesJars = getLibrariesFiles(directoriesToCheck); if (systemLibrariesJars != null) { int length = getLength(systemLibrariesJars); @@ -2101,6 +2176,10 @@ } } + // at this point bootclasspaths contains all the + // bootclasspath entries and bootclasspathCount + // contains the total number of bootclasspath entries. + if (this.classpaths == null) { this.classpaths = new String[0]; } @@ -2108,8 +2187,8 @@ * We put the bootclasspath at the beginning of the classpath entries */ String[] newclasspaths = null; - if ((pathCount + bootclasspathCount) != this.classpaths.length) { - newclasspaths = new String[pathCount + bootclasspathCount]; + if ((pathCount + bootclasspathCount + extlibsCount) != this.classpaths.length) { + newclasspaths = new String[pathCount + bootclasspathCount + extlibsCount]; } else { newclasspaths = this.classpaths; } @@ -2117,7 +2196,7 @@ this.classpaths, 0, newclasspaths, - bootclasspathCount, + bootclasspathCount + extlibsCount, pathCount); if (bootclasspathCount != 0) { @@ -2128,6 +2207,14 @@ 0, bootclasspathCount); } + if (extlibsCount != 0) { + System.arraycopy( + extlibs, + 0, + newclasspaths, + bootclasspathCount, + extlibsCount); + } this.classpaths = newclasspaths; for (int i = 0, max = this.classpaths.length; i < max; i++) { File file = new File(this.classpaths[i]); @@ -2315,16 +2402,17 @@ return units; } - private File[][] getLibrariesFiles(File[] files) { - FilenameFilter filter = new FilenameFilter() { - public boolean accept(File dir, String name) { - String lowerCaseName = name.toLowerCase(); - if (lowerCaseName.endsWith(SUFFIX_STRING_jar) || lowerCaseName.endsWith(SUFFIX_STRING_zip)) { - return true; - } - return false; + private FilenameFilter filter = new FilenameFilter() { + public boolean accept(File dir, String name) { + String lowerCaseName = name.toLowerCase(); + if (lowerCaseName.endsWith(SUFFIX_STRING_jar) || lowerCaseName.endsWith(SUFFIX_STRING_zip)) { + return true; } - }; + return false; + } + }; + + private File[][] getLibrariesFiles(File[] files) { final int filesLength = files.length; File[][] result = new File[filesLength][]; for (int i = 0; i < filesLength; i++) { @@ -2336,6 +2424,18 @@ return result; } + private File[][] getLibrariesFiles(String[] files, int numFiles) { + final int filesLength = numFiles; + File[][] result = new File[filesLength][]; + for (int i = 0; i < filesLength; i++) { + File currentFile = new File(files[i]); + if (currentFile.exists() && currentFile.isDirectory()) { + result[i] = currentFile.listFiles(filter); + } + } + return result; + } + private int getLength(File[][] libraries) { int sum = 0; if (libraries != null) { Index: batch/org/eclipse/jdt/internal/compiler/batch/messages.properties =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties,v retrieving revision 1.419 diff -u -r1.419 messages.properties --- batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 9 May 2005 17:05:44 -0000 1.419 +++ batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 17 May 2005 20:33:09 -0000 @@ -49,6 +49,7 @@ configure.source = source level should be comprised in between ''1.3'' and ''1.5'' (or ''5'' or ''5.0''): {0} configure.duplicateOutputPath = duplicate output path specification: {0} configure.duplicateBootClasspath = duplicate bootclasspath specification: {0} +configure.duplicateExtDirs = duplicate extdirs specification: {0} configure.invalidDebugOption = invalid debug option: {0} configure.invalidWarningConfiguration = invalid warning configuration: {0} configure.invalidWarning = invalid warning: {0} @@ -95,6 +96,8 @@ \ specify location for application classes and sources\n\ \ -bootclasspath \n\ \ specify location for system classes\n\ +\ -extdirs \n\ +\ specify location for extension zip/jar files\n\ \ -d destination directory (if omitted, no directory is created)\n\ \ -d none generate no .class files\n\ \ -encoding specify custom encoding for all sources. Each file/directory can override it\n\