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 19 May 2005 20:39:46 -0000 @@ -941,6 +941,7 @@ "org.eclipse.jdt.internal.compiler.batch.messages"; //$NON-NLS-1$ public String[] classpaths; + public int[] classpathModes; public String destinationPath; public String[] encodings; public Logger logger; @@ -1199,11 +1200,19 @@ final int InsideDefaultEncoding = 64; final int InsideBootClasspath = 128; final int InsideMaxProblems = 256; + final int InsideExtDirs = 512; + final int InsideSourcepath = 1024; final int Default = 0; String[] bootclasspaths = null; + String[] extdirs = null; + String[] extlibs = null; + String[] sourcepaths = null; int DEFAULT_SIZE_CLASSPATH = 4; int pathCount = 0; int bootclasspathCount = 0; + int extdirsCount = 0; + int extlibsCount = 0; + int sourcepathCount = 0; int index = -1, filesCount = 0, argCount = argv.length; int mode = Default; this.repetitions = 0; @@ -1405,6 +1414,14 @@ mode = InsideBootClasspath; continue; } + if (currentArg.equals("-sourcepath")) {//$NON-NLS-1$ + if (sourcepathCount > 0) + throw new InvalidInputException( + Main.bind("configure.duplicateSourcepath", currentArg)); //$NON-NLS-1$ + sourcepaths = new String[DEFAULT_SIZE_CLASSPATH]; + mode = InsideSourcepath; + continue; + } if (currentArg.equals("-progress")) { //$NON-NLS-1$ mode = Default; this.showProgress = true; @@ -1444,6 +1461,18 @@ this.systemExitWhenFinished = false; continue; } + if (currentArg.startsWith("-X")) { //$NON-NLS-1$ + mode = Default; + continue; + } + if (currentArg.startsWith("-J")) { //$NON-NLS-1$ + mode = Default; + continue; + } + if (currentArg.equals("-O")) { //$NON-NLS-1$ + mode = Default; + continue; + } if (currentArg.equals("-verbose")) { //$NON-NLS-1$ mode = Default; this.verbose = true; @@ -1454,6 +1483,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 +1874,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( @@ -1970,6 +2024,23 @@ mode = Default; continue; } + if (mode == InsideSourcepath) { + StringTokenizer tokenizer = new StringTokenizer(currentArg, File.pathSeparator); + while (tokenizer.hasMoreTokens()) { + int length; + if ((length = sourcepaths.length) <= sourcepathCount) { + System.arraycopy( + sourcepaths, + 0, + (sourcepaths = new String[length * 2]), + 0, + length); + } + sourcepaths[sourcepathCount++] = tokenizer.nextToken(); + } + mode = Default; + continue; + } //default is input directory currentArg = currentArg.replace('/', File.separatorChar); if (currentArg.endsWith(File.separator)) @@ -2058,6 +2129,54 @@ 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 +2199,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); @@ -2100,26 +2219,68 @@ } } } - + + /* + * 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]; } /* - * We put the bootclasspath at the beginning of the classpath entries + * We put the bootclasspath at the beginning of the classpath + * entries, followed by the extension libraries, followed by + * the sourcepath followed by the classpath. All classpath + * entries are searched for both sources and binaries except + * the sourcepath entries which are searched for sources only. */ String[] newclasspaths = null; - if ((pathCount + bootclasspathCount) != this.classpaths.length) { - newclasspaths = new String[pathCount + bootclasspathCount]; + int newlength = bootclasspathCount + extlibsCount + sourcepathCount + pathCount; + if (newlength != this.classpaths.length) { + newclasspaths = new String[newlength]; + classpathModes = new int[newlength]; } else { newclasspaths = this.classpaths; + classpathModes = new int[this.classpaths.length]; } + + // initialize all entries to be searched for sources and binaries + for (int i = 0; i < classpathModes.length; i++) + classpathModes[i] = (ClasspathDirectory.SOURCE | ClasspathDirectory.BINARY); + + // copy classpath System.arraycopy( this.classpaths, 0, newclasspaths, - bootclasspathCount, + bootclasspathCount + extlibsCount + sourcepathCount, pathCount); - + + // copy sourcepath + if (sourcepathCount != 0) { + System.arraycopy( + sourcepaths, + 0, + newclasspaths, + bootclasspathCount + extlibsCount, + sourcepathCount); + for (int i = bootclasspathCount + extlibsCount; i < bootclasspathCount + extlibsCount + sourcepathCount; i++) + classpathModes[i] = ClasspathDirectory.SOURCE; + } + + // copy extlibs + if (extlibsCount != 0) { + System.arraycopy( + extlibs, + 0, + newclasspaths, + bootclasspathCount, + extlibsCount); + } + + // copy bootclasspath if (bootclasspathCount != 0) { System.arraycopy( bootclasspaths, @@ -2315,16 +2476,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 +2498,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) { @@ -2368,7 +2542,7 @@ String defaultEncoding = (String) this.options.get(CompilerOptions.OPTION_Encoding); if ("".equals(defaultEncoding)) //$NON-NLS-1$ defaultEncoding = null; //$NON-NLS-1$ - return new FileSystem(this.classpaths, this.filenames, defaultEncoding); + return new FileSystem(this.classpaths, this.filenames, defaultEncoding, this.classpathModes); } /* * Low-level API performing the actual compilation 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.421 diff -u -r1.421 messages.properties --- batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 14 May 2005 14:39:07 -0000 1.421 +++ batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 19 May 2005 20:39:46 -0000 @@ -49,6 +49,8 @@ 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.duplicateSourcepath = duplicate sourcepath specification: {0} configure.invalidDebugOption = invalid debug option: {0} configure.invalidWarningConfiguration = invalid warning configuration: {0} configure.invalidWarning = invalid warning: {0} @@ -93,8 +95,12 @@ \ Classpath options:\n\ \ -cp -classpath \n\ \ specify location for application classes and sources\n\ +\ -sourcepath \n\ +\ specify location for application 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\ @@ -179,6 +185,10 @@ \ -repeat repeat compilation process times for perf analysis\n\ \ -inlineJSR inline JSR bytecode (implicit if target >= 1.5)\n\ \ -enableJavadoc consider references in javadoc\n\ +\ -J