View | Details | Raw Unified | Return to bug 88364 | Differences between
and this patch

Collapse All | Expand All

(-)batch/org/eclipse/jdt/internal/compiler/batch/Main.java (-17 / +191 lines)
Lines 941-946 Link Here
941
		"org.eclipse.jdt.internal.compiler.batch.messages"; 	//$NON-NLS-1$
941
		"org.eclipse.jdt.internal.compiler.batch.messages"; 	//$NON-NLS-1$
942
942
943
	public String[] classpaths;
943
	public String[] classpaths;
944
	public int[] classpathModes;
944
	public String destinationPath;
945
	public String destinationPath;
945
	public String[] encodings;
946
	public String[] encodings;
946
	public Logger logger;
947
	public Logger logger;
Lines 1199-1209 Link Here
1199
		final int InsideDefaultEncoding = 64;
1200
		final int InsideDefaultEncoding = 64;
1200
		final int InsideBootClasspath = 128;
1201
		final int InsideBootClasspath = 128;
1201
		final int InsideMaxProblems = 256;
1202
		final int InsideMaxProblems = 256;
1203
		final int InsideExtDirs = 512;
1204
		final int InsideSourcepath = 1024;
1202
		final int Default = 0;
1205
		final int Default = 0;
1203
		String[] bootclasspaths = null;
1206
		String[] bootclasspaths = null;
1207
		String[] extdirs = null;
1208
		String[] extlibs = null;
1209
		String[] sourcepaths = null;
1204
		int DEFAULT_SIZE_CLASSPATH = 4;
1210
		int DEFAULT_SIZE_CLASSPATH = 4;
1205
		int pathCount = 0;
1211
		int pathCount = 0;
1206
		int bootclasspathCount = 0;
1212
		int bootclasspathCount = 0;
1213
		int extdirsCount = 0;
1214
		int extlibsCount = 0;
1215
		int sourcepathCount = 0;
1207
		int index = -1, filesCount = 0, argCount = argv.length;
1216
		int index = -1, filesCount = 0, argCount = argv.length;
1208
		int mode = Default;
1217
		int mode = Default;
1209
		this.repetitions = 0;
1218
		this.repetitions = 0;
Lines 1405-1410 Link Here
1405
				mode = InsideBootClasspath;
1414
				mode = InsideBootClasspath;
1406
				continue;
1415
				continue;
1407
			}
1416
			}
1417
			if (currentArg.equals("-sourcepath")) {//$NON-NLS-1$
1418
				if (sourcepathCount > 0)
1419
					throw new InvalidInputException(
1420
						Main.bind("configure.duplicateSourcepath", currentArg)); //$NON-NLS-1$
1421
				sourcepaths = new String[DEFAULT_SIZE_CLASSPATH];
1422
				mode = InsideSourcepath;
1423
				continue;
1424
			}
1408
			if (currentArg.equals("-progress")) { //$NON-NLS-1$
1425
			if (currentArg.equals("-progress")) { //$NON-NLS-1$
1409
				mode = Default;
1426
				mode = Default;
1410
				this.showProgress = true;
1427
				this.showProgress = true;
Lines 1444-1449 Link Here
1444
				this.systemExitWhenFinished = false;
1461
				this.systemExitWhenFinished = false;
1445
				continue;
1462
				continue;
1446
			}
1463
			}
1464
			if (currentArg.startsWith("-X")) { //$NON-NLS-1$
1465
				mode = Default;
1466
				continue;
1467
			}
1468
			if (currentArg.startsWith("-J")) { //$NON-NLS-1$
1469
				mode = Default;
1470
				continue;
1471
			}
1472
			if (currentArg.equals("-O")) { //$NON-NLS-1$
1473
				mode = Default;
1474
				continue;
1475
			}
1447
			if (currentArg.equals("-verbose")) { //$NON-NLS-1$
1476
			if (currentArg.equals("-verbose")) { //$NON-NLS-1$
1448
				mode = Default;
1477
				mode = Default;
1449
				this.verbose = true;
1478
				this.verbose = true;
Lines 1454-1459 Link Here
1454
				this.produceRefInfo = true;
1483
				this.produceRefInfo = true;
1455
				continue;
1484
				continue;
1456
			}
1485
			}
1486
			if (currentArg.equals("-extdirs")) {//$NON-NLS-1$
1487
				if (extdirsCount > 0)
1488
					throw new InvalidInputException(
1489
						Main.bind("configure.duplicateExtDirs", currentArg)); //$NON-NLS-1$
1490
				extdirs = new String[DEFAULT_SIZE_CLASSPATH];
1491
				mode = InsideExtDirs;
1492
				continue;
1493
			}
1457
			if (currentArg.equals("-inlineJSR")) { //$NON-NLS-1$
1494
			if (currentArg.equals("-inlineJSR")) { //$NON-NLS-1$
1458
			    mode = Default;
1495
			    mode = Default;
1459
				this.options.put(
1496
				this.options.put(
Lines 1837-1842 Link Here
1837
				useEnableJavadoc = true;
1874
				useEnableJavadoc = true;
1838
				continue;
1875
				continue;
1839
			}
1876
			}
1877
			if (mode == InsideExtDirs) {
1878
				StringTokenizer tokenizer = new StringTokenizer(currentArg, File.pathSeparator);
1879
				while (tokenizer.hasMoreTokens()) {
1880
					int length;
1881
					if ((length = extdirs.length) <= extdirsCount) {
1882
						System.arraycopy(
1883
							extdirs,
1884
							0,
1885
							(extdirs = new String[length * 2]),
1886
							0,
1887
							length);
1888
					}
1889
					extdirs[extdirsCount++] = tokenizer.nextToken();
1890
				}
1891
				mode = Default;
1892
				continue;
1893
			}
1840
			if (mode == TargetSetting) {
1894
			if (mode == TargetSetting) {
1841
				if (didSpecifyTarget) {
1895
				if (didSpecifyTarget) {
1842
					throw new InvalidInputException(
1896
					throw new InvalidInputException(
Lines 1970-1975 Link Here
1970
				mode = Default;
2024
				mode = Default;
1971
				continue;
2025
				continue;
1972
			}			
2026
			}			
2027
			if (mode == InsideSourcepath) {
2028
				StringTokenizer tokenizer = new StringTokenizer(currentArg, File.pathSeparator);
2029
				while (tokenizer.hasMoreTokens()) {
2030
					int length;
2031
					if ((length = sourcepaths.length) <= sourcepathCount) {
2032
						System.arraycopy(
2033
							sourcepaths,
2034
							0,
2035
							(sourcepaths = new String[length * 2]),
2036
							0,
2037
							length);
2038
					}
2039
					sourcepaths[sourcepathCount++] = tokenizer.nextToken();
2040
				}
2041
				mode = Default;
2042
				continue;
2043
			}
1973
			//default is input directory
2044
			//default is input directory
1974
			currentArg = currentArg.replace('/', File.separatorChar);
2045
			currentArg = currentArg.replace('/', File.separatorChar);
1975
			if (currentArg.endsWith(File.separator))
2046
			if (currentArg.endsWith(File.separator))
Lines 2058-2063 Link Here
2058
			this.classpaths[pathCount++] = System.getProperty("user.dir");//$NON-NLS-1$
2129
			this.classpaths[pathCount++] = System.getProperty("user.dir");//$NON-NLS-1$
2059
		}
2130
		}
2060
		
2131
		
2132
		if (extdirsCount == 0) {
2133
			String extdirsStr = System.getProperty("java.ext.dirs"); //$NON-NLS-1$
2134
2135
			extdirs = new String[DEFAULT_SIZE_CLASSPATH];
2136
			StringTokenizer tokenizer = new StringTokenizer(extdirsStr, File.pathSeparator);
2137
			while (tokenizer.hasMoreTokens()) {
2138
				int length;
2139
				if ((length = extdirs.length) <= extdirsCount) {
2140
					System.arraycopy(
2141
						extdirs,
2142
						0,
2143
						(extdirs = new String[length * 2]),
2144
						0,
2145
						length);
2146
				}
2147
				extdirs[extdirsCount++] = tokenizer.nextToken();
2148
			}
2149
		}
2150
		
2151
		/*
2152
		 * At this point extdirs contains all the extension
2153
		 * directories parsed out into individual strings, and
2154
		 * extdirsCount stores the total number of extensions
2155
		 * directories.
2156
		 */
2157
2158
		if (extdirsCount != 0 && extlibsCount == 0) {
2159
			File[][] systemLibrariesJars = getLibrariesFiles(extdirs, extdirsCount);
2160
			if (systemLibrariesJars != null) {
2161
				int length = getLength(systemLibrariesJars);
2162
				extlibs = new String[length];
2163
				for (int i = 0, max = systemLibrariesJars.length; i < max; i++) {
2164
					File[] current = systemLibrariesJars[i];
2165
					if (current != null) {
2166
						for (int j = 0, max2 = current.length; j < max2; j++) {
2167
							extlibs[extlibsCount++] = current[j].getAbsolutePath();
2168
						}
2169
					}
2170
				}
2171
			}
2172
		}
2173
		
2174
		/*
2175
		 * At this point extlibs contains all the extension libraries
2176
		 * parsed out into individual strings, and extlibsCount stores
2177
		 * the total number of extensions libraries.
2178
		 */
2179
		
2061
		if (bootclasspathCount == 0) {
2180
		if (bootclasspathCount == 0) {
2062
			/* no bootclasspath specified
2181
			/* no bootclasspath specified
2063
			 * we can try to retrieve the default librairies of the VM used to run
2182
			 * we can try to retrieve the default librairies of the VM used to run
Lines 2080-2086 Link Here
2080
					try {
2199
					try {
2081
						javaHomeFile = new File(javaHomeFile.getCanonicalPath());
2200
						javaHomeFile = new File(javaHomeFile.getCanonicalPath());
2082
						// add all jars in the lib subdirectory
2201
						// add all jars in the lib subdirectory
2083
						File[] directoriesToCheck = new File[] { new File(javaHomeFile, "lib"), new File(javaHomeFile, "lib/ext")};//$NON-NLS-1$//$NON-NLS-2$
2202
						File[] directoriesToCheck = new File[] { new File(javaHomeFile, "lib") };//$NON-NLS-1$
2084
						File[][] systemLibrariesJars = getLibrariesFiles(directoriesToCheck);
2203
						File[][] systemLibrariesJars = getLibrariesFiles(directoriesToCheck);
2085
						if (systemLibrariesJars != null) {
2204
						if (systemLibrariesJars != null) {
2086
							int length = getLength(systemLibrariesJars);
2205
							int length = getLength(systemLibrariesJars);
Lines 2100-2125 Link Here
2100
		 	 	}
2219
		 	 	}
2101
		 	 }
2220
		 	 }
2102
		}
2221
		}
2103
2222
		
2223
		/*
2224
		 * At this point bootclasspaths contains all the bootclasspath
2225
		 * entries and bootclasspathCount contains the total number of
2226
		 * bootclasspath entries.
2227
		 */
2228
		
2104
		if (this.classpaths == null) {
2229
		if (this.classpaths == null) {
2105
			this.classpaths = new String[0];
2230
			this.classpaths = new String[0];
2106
		}
2231
		}
2107
		/* 
2232
		/* 
2108
		 * We put the bootclasspath at the beginning of the classpath entries
2233
		 * We put the bootclasspath at the beginning of the classpath
2234
		 * entries, followed by the extension libraries, followed by
2235
		 * the sourcepath followed by the classpath.  All classpath
2236
		 * entries are searched for both sources and binaries except
2237
		 * the sourcepath entries which are searched for sources only.
2109
		 */
2238
		 */
2110
		String[] newclasspaths = null;
2239
		String[] newclasspaths = null;
2111
		if ((pathCount + bootclasspathCount) != this.classpaths.length) {
2240
		int newlength = bootclasspathCount + extlibsCount + sourcepathCount + pathCount;
2112
			newclasspaths = new String[pathCount + bootclasspathCount];
2241
		if (newlength != this.classpaths.length) {
2242
			newclasspaths = new String[newlength];
2243
			classpathModes = new int[newlength];
2113
		} else {
2244
		} else {
2114
			newclasspaths = this.classpaths;
2245
			newclasspaths = this.classpaths;
2246
			classpathModes = new int[this.classpaths.length];
2115
		}
2247
		}
2248
2249
		// initialize all entries to be searched for sources and binaries
2250
		for (int i = 0; i < classpathModes.length; i++)
2251
			classpathModes[i] = (ClasspathDirectory.SOURCE | ClasspathDirectory.BINARY);
2252
2253
		// copy classpath
2116
		System.arraycopy(
2254
		System.arraycopy(
2117
			this.classpaths,
2255
			this.classpaths,
2118
			0,
2256
			0,
2119
			newclasspaths,
2257
			newclasspaths,
2120
			bootclasspathCount,
2258
			bootclasspathCount + extlibsCount + sourcepathCount,
2121
			pathCount);
2259
			pathCount);
2122
2260
		
2261
		// copy sourcepath
2262
		if (sourcepathCount != 0) {
2263
			System.arraycopy(
2264
				sourcepaths,
2265
				0,
2266
				newclasspaths,
2267
				bootclasspathCount + extlibsCount,
2268
				sourcepathCount);
2269
			for (int i = bootclasspathCount + extlibsCount; i < bootclasspathCount + extlibsCount + sourcepathCount; i++)
2270
				classpathModes[i] = ClasspathDirectory.SOURCE;
2271
		}
2272
		
2273
		// copy extlibs
2274
		if (extlibsCount != 0) {
2275
			System.arraycopy(
2276
				 extlibs,
2277
				 0,
2278
				 newclasspaths,
2279
				 bootclasspathCount,
2280
				 extlibsCount);
2281
		}
2282
		
2283
		// copy bootclasspath
2123
		if (bootclasspathCount != 0) {
2284
		if (bootclasspathCount != 0) {
2124
			System.arraycopy(
2285
			System.arraycopy(
2125
				bootclasspaths,
2286
				bootclasspaths,
Lines 2315-2330 Link Here
2315
		return units;
2476
		return units;
2316
	}
2477
	}
2317
	
2478
	
2318
	private File[][] getLibrariesFiles(File[] files) {
2479
	private FilenameFilter filter = new FilenameFilter() {
2319
		FilenameFilter filter = new FilenameFilter() {
2480
		public boolean accept(File dir, String name) {
2320
			public boolean accept(File dir, String name) {
2481
			String lowerCaseName = name.toLowerCase();
2321
				String lowerCaseName = name.toLowerCase();
2482
			if (lowerCaseName.endsWith(SUFFIX_STRING_jar) || lowerCaseName.endsWith(SUFFIX_STRING_zip)) {
2322
				if (lowerCaseName.endsWith(SUFFIX_STRING_jar) || lowerCaseName.endsWith(SUFFIX_STRING_zip)) {
2483
				return true;
2323
					return true;
2324
				}
2325
				return false;
2326
			}
2484
			}
2327
		};
2485
			return false;
2486
		}
2487
	};
2488
	
2489
	private File[][] getLibrariesFiles(File[] files) {
2328
		final int filesLength = files.length;
2490
		final int filesLength = files.length;
2329
		File[][] result = new File[filesLength][];
2491
		File[][] result = new File[filesLength][];
2330
		for (int i = 0; i < filesLength; i++) {
2492
		for (int i = 0; i < filesLength; i++) {
Lines 2336-2341 Link Here
2336
		return result;
2498
		return result;
2337
	}
2499
	}
2338
	
2500
	
2501
	private File[][] getLibrariesFiles(String[] files, int numFiles) {
2502
		final int filesLength = numFiles;
2503
		File[][] result = new File[filesLength][];
2504
		for (int i = 0; i < filesLength; i++) {
2505
			File currentFile = new File(files[i]);
2506
			if (currentFile.exists() && currentFile.isDirectory()) {
2507
				result[i] = currentFile.listFiles(filter);
2508
			}
2509
		}
2510
		return result;
2511
	}
2512
	
2339
	private int getLength(File[][] libraries) {
2513
	private int getLength(File[][] libraries) {
2340
		int sum = 0;
2514
		int sum = 0;
2341
		if (libraries != null) {
2515
		if (libraries != null) {
Lines 2368-2374 Link Here
2368
		String defaultEncoding = (String) this.options.get(CompilerOptions.OPTION_Encoding);
2542
		String defaultEncoding = (String) this.options.get(CompilerOptions.OPTION_Encoding);
2369
		if ("".equals(defaultEncoding)) //$NON-NLS-1$
2543
		if ("".equals(defaultEncoding)) //$NON-NLS-1$
2370
			defaultEncoding = null; //$NON-NLS-1$	
2544
			defaultEncoding = null; //$NON-NLS-1$	
2371
		return new FileSystem(this.classpaths, this.filenames, defaultEncoding);
2545
		return new FileSystem(this.classpaths, this.filenames, defaultEncoding, this.classpathModes);
2372
	}
2546
	}
2373
	/*
2547
	/*
2374
	 *  Low-level API performing the actual compilation
2548
	 *  Low-level API performing the actual compilation
(-)batch/org/eclipse/jdt/internal/compiler/batch/messages.properties (+10 lines)
Lines 49-54 Link Here
49
configure.source = source level should be comprised in between ''1.3'' and ''1.5'' (or ''5'' or ''5.0''): {0}
49
configure.source = source level should be comprised in between ''1.3'' and ''1.5'' (or ''5'' or ''5.0''): {0}
50
configure.duplicateOutputPath = duplicate output path specification: {0}
50
configure.duplicateOutputPath = duplicate output path specification: {0}
51
configure.duplicateBootClasspath = duplicate bootclasspath specification: {0}
51
configure.duplicateBootClasspath = duplicate bootclasspath specification: {0}
52
configure.duplicateExtDirs = duplicate extdirs specification: {0}
53
configure.duplicateSourcepath = duplicate sourcepath specification: {0}
52
configure.invalidDebugOption = invalid debug option: {0}
54
configure.invalidDebugOption = invalid debug option: {0}
53
configure.invalidWarningConfiguration = invalid warning configuration: {0}
55
configure.invalidWarningConfiguration = invalid warning configuration: {0}
54
configure.invalidWarning = invalid warning: {0}
56
configure.invalidWarning = invalid warning: {0}
Lines 93-100 Link Here
93
\ Classpath options:\n\
95
\ Classpath options:\n\
94
\    -cp -classpath <directories and zip/jar files separated by {0}>\n\
96
\    -cp -classpath <directories and zip/jar files separated by {0}>\n\
95
\                       specify location for application classes and sources\n\
97
\                       specify location for application classes and sources\n\
98
\    -sourcepath <directories separated by {0}>\n\
99
\                       specify location for application sources\n\
96
\    -bootclasspath <directories and zip/jar files separated by {0}>\n\
100
\    -bootclasspath <directories and zip/jar files separated by {0}>\n\
97
\                       specify location for system classes\n\
101
\                       specify location for system classes\n\
102
\    -extdirs <directories separated by {0}>\n\
103
\                       specify location for extension zip/jar files\n\
98
\    -d <dir>           destination directory (if omitted, no directory is created)\n\
104
\    -d <dir>           destination directory (if omitted, no directory is created)\n\
99
\    -d none            generate no .class files\n\
105
\    -d none            generate no .class files\n\
100
\    -encoding <enc>    specify custom encoding for all sources. Each file/directory can override it\n\
106
\    -encoding <enc>    specify custom encoding for all sources. Each file/directory can override it\n\
Lines 179-184 Link Here
179
\    -repeat <n>        repeat compilation process <n> times for perf analysis\n\
185
\    -repeat <n>        repeat compilation process <n> times for perf analysis\n\
180
\    -inlineJSR         inline JSR bytecode (implicit if target >= 1.5)\n\
186
\    -inlineJSR         inline JSR bytecode (implicit if target >= 1.5)\n\
181
\    -enableJavadoc     consider references in javadoc\n\
187
\    -enableJavadoc     consider references in javadoc\n\
188
\    -J<option>         pass option to virtual machine (ignored)\n\
189
\    -X<option>         specify non-standard option (ignored)\n\
190
\    -X                 print non-standard options and exit (ignored)\n\
191
\    -O                 optimize for execution time (ignored)\n\
182
\ \n\
192
\ \n\
183
\    -? -help           print this help message\n\
193
\    -? -help           print this help message\n\
184
\    -v -version        print compiler version\n\
194
\    -v -version        print compiler version\n\

Return to bug 88364