Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 310330 | Differences between
and this patch

Collapse All | Expand All

(-)antadapter/org/eclipse/jdt/core/JDTCompilerAdapter.java (-96 / +97 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 107-169 Link Here
107
		 */
107
		 */
108
		cmd.createArgument().setValue("-noExit"); //$NON-NLS-1$
108
		cmd.createArgument().setValue("-noExit"); //$NON-NLS-1$
109
109
110
        if (this.bootclasspath != null) {
110
		if (this.bootclasspath != null) {
111
			cmd.createArgument().setValue("-bootclasspath"); //$NON-NLS-1$
111
			cmd.createArgument().setValue("-bootclasspath"); //$NON-NLS-1$
112
        	if (this.bootclasspath.size() != 0) {
112
			if (this.bootclasspath.size() != 0) {
113
    			/*
113
				/*
114
    			 * Set the bootclasspath for the Eclipse compiler.
114
				 * Set the bootclasspath for the Eclipse compiler.
115
    			 */
115
				 */
116
    			cmd.createArgument().setPath(this.bootclasspath);
116
				cmd.createArgument().setPath(this.bootclasspath);
117
        	} else {
117
			} else {
118
    			cmd.createArgument().setValue(Util.EMPTY_STRING);
118
				cmd.createArgument().setValue(Util.EMPTY_STRING);
119
        	}
119
			}
120
        }
120
		}
121
121
122
        Path classpath = new Path(this.project);
122
		Path classpath = new Path(this.project);
123
123
124
       /*
124
		/*
125
         * Eclipse compiler doesn't support -extdirs.
125
		 * Eclipse compiler doesn't support -extdirs.
126
         * It is emulated using the classpath. We add extdirs entries after the
126
		 * It is emulated using the classpath. We add extdirs entries after the
127
         * bootclasspath.
127
		 * bootclasspath.
128
         */
128
		 */
129
        if (this.extdirs != null) {
129
		if (this.extdirs != null) {
130
			cmd.createArgument().setValue("-extdirs"); //$NON-NLS-1$
130
			cmd.createArgument().setValue("-extdirs"); //$NON-NLS-1$
131
			cmd.createArgument().setPath(this.extdirs);
131
			cmd.createArgument().setPath(this.extdirs);
132
        }
132
		}
133
133
134
		/*
134
		/*
135
		 * The java runtime is already handled, so we simply want to retrieve the
135
		 * The java runtime is already handled, so we simply want to retrieve the
136
		 * ant runtime and the compile classpath.
136
		 * ant runtime and the compile classpath.
137
		 */
137
		 */
138
        classpath.append(getCompileClasspath());
138
		classpath.append(getCompileClasspath());
139
140
		// For -sourcepath, use the "sourcepath" value if present.
141
		// Otherwise default to the "srcdir" value.
142
		Path sourcepath = null;
139
143
140
        // For -sourcepath, use the "sourcepath" value if present.
144
		// retrieve the method getSourcepath() using reflect
141
        // Otherwise default to the "srcdir" value.
145
		// This is done to improve the compatibility to ant 1.5
142
        Path sourcepath = null;
146
		Method getSourcepathMethod = null;
143
147
		try {
144
        // retrieve the method getSourcepath() using reflect
148
			getSourcepathMethod = javacClass.getMethod("getSourcepath", null); //$NON-NLS-1$
145
        // This is done to improve the compatibility to ant 1.5
149
		} catch(NoSuchMethodException e) {
146
        Method getSourcepathMethod = null;
150
			// if not found, then we cannot use this method (ant 1.5)
147
        try {
151
		}
148
	        getSourcepathMethod = javacClass.getMethod("getSourcepath", null); //$NON-NLS-1$
152
		Path compileSourcePath = null;
149
        } catch(NoSuchMethodException e) {
153
		if (getSourcepathMethod != null) {
150
        	// if not found, then we cannot use this method (ant 1.5)
154
			try {
151
        }
152
        Path compileSourcePath = null;
153
        if (getSourcepathMethod != null) {
154
	 		try {
155
				compileSourcePath = (Path) getSourcepathMethod.invoke(this.attributes, null);
155
				compileSourcePath = (Path) getSourcepathMethod.invoke(this.attributes, null);
156
			} catch (IllegalAccessException e) {
156
			} catch (IllegalAccessException e) {
157
				// should never happen
157
				// should never happen
158
			} catch (InvocationTargetException e) {
158
			} catch (InvocationTargetException e) {
159
				// should never happen
159
				// should never happen
160
			}
160
			}
161
        }
161
		}
162
        if (compileSourcePath != null) {
162
		if (compileSourcePath != null) {
163
            sourcepath = compileSourcePath;
163
			sourcepath = compileSourcePath;
164
        } else {
164
		} else {
165
            sourcepath = this.src;
165
			sourcepath = this.src;
166
        }
166
		}
167
		classpath.append(sourcepath);
167
		classpath.append(sourcepath);
168
		/*
168
		/*
169
		 * Set the classpath for the Eclipse compiler.
169
		 * Set the classpath for the Eclipse compiler.
Lines 171-208 Link Here
171
		cmd.createArgument().setValue("-classpath"); //$NON-NLS-1$
171
		cmd.createArgument().setValue("-classpath"); //$NON-NLS-1$
172
		createClasspathArgument(cmd, classpath);
172
		createClasspathArgument(cmd, classpath);
173
173
174
        final String javaVersion = JavaEnvUtils.getJavaVersion();
174
		final String javaVersion = JavaEnvUtils.getJavaVersion();
175
		String memoryParameterPrefix = javaVersion.equals(JavaEnvUtils.JAVA_1_1) ? "-J-" : "-J-X";//$NON-NLS-1$//$NON-NLS-2$
175
		String memoryParameterPrefix = javaVersion.equals(JavaEnvUtils.JAVA_1_1) ? "-J-" : "-J-X";//$NON-NLS-1$//$NON-NLS-2$
176
        if (this.memoryInitialSize != null) {
176
		if (this.memoryInitialSize != null) {
177
            if (!this.attributes.isForkedJavac()) {
177
			if (!this.attributes.isForkedJavac()) {
178
                this.attributes.log(AntAdapterMessages.getString("ant.jdtadapter.info.ignoringMemoryInitialSize"), Project.MSG_WARN); //$NON-NLS-1$
178
				this.attributes.log(AntAdapterMessages.getString("ant.jdtadapter.info.ignoringMemoryInitialSize"), Project.MSG_WARN); //$NON-NLS-1$
179
            } else {
179
			} else {
180
                cmd.createArgument().setValue(memoryParameterPrefix
180
				cmd.createArgument().setValue(memoryParameterPrefix
181
                                              + "ms" + this.memoryInitialSize); //$NON-NLS-1$
181
						+ "ms" + this.memoryInitialSize); //$NON-NLS-1$
182
            }
182
			}
183
        }
183
		}
184
184
185
        if (this.memoryMaximumSize != null) {
185
		if (this.memoryMaximumSize != null) {
186
            if (!this.attributes.isForkedJavac()) {
186
			if (!this.attributes.isForkedJavac()) {
187
                this.attributes.log(AntAdapterMessages.getString("ant.jdtadapter.info.ignoringMemoryMaximumSize"), Project.MSG_WARN); //$NON-NLS-1$
187
				this.attributes.log(AntAdapterMessages.getString("ant.jdtadapter.info.ignoringMemoryMaximumSize"), Project.MSG_WARN); //$NON-NLS-1$
188
            } else {
188
			} else {
189
                cmd.createArgument().setValue(memoryParameterPrefix
189
				cmd.createArgument().setValue(memoryParameterPrefix
190
                                              + "mx" + this.memoryMaximumSize); //$NON-NLS-1$
190
						+ "mx" + this.memoryMaximumSize); //$NON-NLS-1$
191
            }
191
			}
192
        }
192
		}
193
193
194
        if (this.debug) {
194
		if (this.debug) {
195
	       // retrieve the method getSourcepath() using reflect
195
			// retrieve the method getSourcepath() using reflect
196
	        // This is done to improve the compatibility to ant 1.5
196
			// This is done to improve the compatibility to ant 1.5
197
	        Method getDebugLevelMethod = null;
197
			Method getDebugLevelMethod = null;
198
	        try {
198
			try {
199
		        getDebugLevelMethod = javacClass.getMethod("getDebugLevel", null); //$NON-NLS-1$
199
				getDebugLevelMethod = javacClass.getMethod("getDebugLevel", null); //$NON-NLS-1$
200
	        } catch(NoSuchMethodException e) {
200
			} catch(NoSuchMethodException e) {
201
	        	// if not found, then we cannot use this method (ant 1.5)
201
				// if not found, then we cannot use this method (ant 1.5)
202
	        	// debug level is only available with ant 1.5.x
202
				// debug level is only available with ant 1.5.x
203
	        }
203
			}
204
     	    String debugLevel = null;
204
			String debugLevel = null;
205
	        if (getDebugLevelMethod != null) {
205
			if (getDebugLevelMethod != null) {
206
				try {
206
				try {
207
					debugLevel = (String) getDebugLevelMethod.invoke(this.attributes, null);
207
					debugLevel = (String) getDebugLevelMethod.invoke(this.attributes, null);
208
				} catch (IllegalAccessException e) {
208
				} catch (IllegalAccessException e) {
Lines 210-216 Link Here
210
				} catch (InvocationTargetException e) {
210
				} catch (InvocationTargetException e) {
211
					// should never happen
211
					// should never happen
212
				}
212
				}
213
        	}
213
			}
214
			if (debugLevel != null) {
214
			if (debugLevel != null) {
215
				this.customDefaultOptions.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.DO_NOT_GENERATE);
215
				this.customDefaultOptions.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.DO_NOT_GENERATE);
216
				this.customDefaultOptions.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.DO_NOT_GENERATE);
216
				this.customDefaultOptions.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.DO_NOT_GENERATE);
Lines 230-247 Link Here
230
				this.customDefaultOptions.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE);
230
				this.customDefaultOptions.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.GENERATE);
231
				this.customDefaultOptions.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE);
231
				this.customDefaultOptions.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.GENERATE);
232
				this.customDefaultOptions.put(CompilerOptions.OPTION_SourceFileAttribute , CompilerOptions.GENERATE);
232
				this.customDefaultOptions.put(CompilerOptions.OPTION_SourceFileAttribute , CompilerOptions.GENERATE);
233
            }
233
			}
234
        } else {
234
		} else {
235
			this.customDefaultOptions.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.DO_NOT_GENERATE);
235
			this.customDefaultOptions.put(CompilerOptions.OPTION_LocalVariableAttribute, CompilerOptions.DO_NOT_GENERATE);
236
			this.customDefaultOptions.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.DO_NOT_GENERATE);
236
			this.customDefaultOptions.put(CompilerOptions.OPTION_LineNumberAttribute, CompilerOptions.DO_NOT_GENERATE);
237
			this.customDefaultOptions.put(CompilerOptions.OPTION_SourceFileAttribute , CompilerOptions.DO_NOT_GENERATE);
237
			this.customDefaultOptions.put(CompilerOptions.OPTION_SourceFileAttribute , CompilerOptions.DO_NOT_GENERATE);
238
        }
238
		}
239
239
240
		/*
240
		/*
241
		 * Handle the nowarn option. If none, then we generate all warnings.
241
		 * Handle the nowarn option. If none, then we generate all warnings.
242
		 */
242
		 */
243
		if (this.attributes.getNowarn()) {
243
		if (this.attributes.getNowarn()) {
244
	        // disable all warnings
244
			// disable all warnings
245
			Object[] entries = this.customDefaultOptions.entrySet().toArray();
245
			Object[] entries = this.customDefaultOptions.entrySet().toArray();
246
			for (int i = 0, max = entries.length; i < max; i++) {
246
			for (int i = 0, max = entries.length; i < max; i++) {
247
				Map.Entry entry = (Map.Entry) entries[i];
247
				Map.Entry entry = (Map.Entry) entries[i];
Lines 269-275 Link Here
269
			this.customDefaultOptions.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, CompilerOptions.DISABLED);
269
			this.customDefaultOptions.put(CompilerOptions.OPTION_ReportDeprecationWhenOverridingDeprecatedMethod, CompilerOptions.DISABLED);
270
		}
270
		}
271
271
272
	   	/*
272
		/*
273
		 * destDir option.
273
		 * destDir option.
274
		 */
274
		 */
275
		if (this.destDir != null) {
275
		if (this.destDir != null) {
Lines 302-321 Link Here
302
		 * source option
302
		 * source option
303
		 */
303
		 */
304
		String source = this.attributes.getSource();
304
		String source = this.attributes.getSource();
305
        if (source != null) {
305
		if (source != null) {
306
			this.customDefaultOptions.put(CompilerOptions.OPTION_Source, source);
306
			this.customDefaultOptions.put(CompilerOptions.OPTION_Source, source);
307
        }
307
		}
308
309
		/*
310
		 * encoding option
311
		 */
312
        if (this.encoding != null) {
313
            cmd.createArgument().setValue("-encoding"); //$NON-NLS-1$
314
            cmd.createArgument().setValue(this.encoding);
315
        }
316
308
317
		if (compilerArgs != null) {
309
		if (compilerArgs != null) {
318
	        /*
310
			/*
319
			 * Add extra argument on the command line
311
			 * Add extra argument on the command line
320
			 */
312
			 */
321
			final int length = compilerArgs.length;
313
			final int length = compilerArgs.length;
Lines 325-341 Link Here
325
					if (this.logFileName == null && "-log".equals(arg) && ((i + 1) < max)) { //$NON-NLS-1$
317
					if (this.logFileName == null && "-log".equals(arg) && ((i + 1) < max)) { //$NON-NLS-1$
326
						this.logFileName = compilerArgs[i + 1];
318
						this.logFileName = compilerArgs[i + 1];
327
					}
319
					}
328
			        cmd.createArgument().setValue(arg);
320
					cmd.createArgument().setValue(arg);
329
				}
321
				}
330
			}
322
			}
331
	   	}
323
		}
332
     	/*
324
		/*
325
		 * encoding option. javac task encoding property must be the last encoding on the command
326
		 * line as compiler arg might also specify an encoding.
327
		 */
328
		if (this.encoding != null) {
329
			cmd.createArgument().setValue("-encoding"); //$NON-NLS-1$
330
			cmd.createArgument().setValue(this.encoding);
331
		}
332
333
		/*
333
		 * Eclipse compiler doesn't have a -sourcepath option. This is
334
		 * Eclipse compiler doesn't have a -sourcepath option. This is
334
		 * handled through the javac task that collects all source files in
335
		 * handled through the javac task that collects all source files in
335
		 * srcdir option.
336
		 * srcdir option.
336
		 */
337
		 */
337
        logAndAddFilesToCompile(cmd);
338
		logAndAddFilesToCompile(cmd);
338
        return cmd;
339
		return cmd;
339
	}
340
	}
340
341
341
	/**
342
	/**
(-)batch/org/eclipse/jdt/internal/compiler/batch/Main.java (-5 / +41 lines)
Lines 38-43 Link Here
38
import java.util.Comparator;
38
import java.util.Comparator;
39
import java.util.Date;
39
import java.util.Date;
40
import java.util.HashMap;
40
import java.util.HashMap;
41
import java.util.HashSet;
41
import java.util.Iterator;
42
import java.util.Iterator;
42
import java.util.List;
43
import java.util.List;
43
import java.util.Locale;
44
import java.util.Locale;
Lines 1736-1742 Link Here
1736
	String usageSection = null;
1737
	String usageSection = null;
1737
	boolean printVersionRequired = false;
1738
	boolean printVersionRequired = false;
1738
1739
1739
	boolean didSpecifyDefaultEncoding = false;
1740
	boolean didSpecifyDeprecation = false;
1740
	boolean didSpecifyDeprecation = false;
1741
	boolean didSpecifyCompliance = false;
1741
	boolean didSpecifyCompliance = false;
1742
	boolean didSpecifyDisabledAnnotationProcessing = false;
1742
	boolean didSpecifyDisabledAnnotationProcessing = false;
Lines 1745-1750 Link Here
1745
	String customDestinationPath = null;
1745
	String customDestinationPath = null;
1746
	String currentSourceDirectory = null;
1746
	String currentSourceDirectory = null;
1747
	String currentArg = Util.EMPTY_STRING;
1747
	String currentArg = Util.EMPTY_STRING;
1748
	
1749
	Set specifiedEncodings = null;
1748
1750
1749
	// expand the command line if necessary
1751
	// expand the command line if necessary
1750
	boolean needExpansion = false;
1752
	boolean needExpansion = false;
Lines 2456-2464 Link Here
2456
				mode = DEFAULT;
2458
				mode = DEFAULT;
2457
				continue;
2459
				continue;
2458
			case INSIDE_DEFAULT_ENCODING :
2460
			case INSIDE_DEFAULT_ENCODING :
2459
				if (didSpecifyDefaultEncoding) {
2461
				if (specifiedEncodings != null) {
2460
					throw new IllegalArgumentException(
2462
					// check already defined encoding
2461
						this.bind("configure.duplicateDefaultEncoding", currentArg)); //$NON-NLS-1$
2463
					if (!specifiedEncodings.contains(currentArg)) {
2464
						if (specifiedEncodings.size() > 1) {
2465
							this.logger.logPendingError(
2466
									this.bind("configure.differentencodings", //$NON-NLS-1$
2467
									currentArg,
2468
									getAllEncodings(specifiedEncodings)));
2469
						} else {
2470
							this.logger.logPendingError(
2471
									this.bind("configure.differentencoding", //$NON-NLS-1$
2472
									currentArg,
2473
									getAllEncodings(specifiedEncodings)));
2474
						}
2475
					}
2476
				} else {
2477
					specifiedEncodings = new HashSet();
2462
				}
2478
				}
2463
				try { // ensure encoding is supported
2479
				try { // ensure encoding is supported
2464
					new InputStreamReader(new ByteArrayInputStream(new byte[0]), currentArg);
2480
					new InputStreamReader(new ByteArrayInputStream(new byte[0]), currentArg);
Lines 2466-2473 Link Here
2466
					throw new IllegalArgumentException(
2482
					throw new IllegalArgumentException(
2467
						this.bind("configure.unsupportedEncoding", currentArg)); //$NON-NLS-1$
2483
						this.bind("configure.unsupportedEncoding", currentArg)); //$NON-NLS-1$
2468
				}
2484
				}
2485
				specifiedEncodings.add(currentArg);
2469
				this.options.put(CompilerOptions.OPTION_Encoding, currentArg);
2486
				this.options.put(CompilerOptions.OPTION_Encoding, currentArg);
2470
				didSpecifyDefaultEncoding = true;
2471
				mode = DEFAULT;
2487
				mode = DEFAULT;
2472
				continue;
2488
				continue;
2473
			case INSIDE_DESTINATION_PATH :
2489
			case INSIDE_DESTINATION_PATH :
Lines 2724-2729 Link Here
2724
			endorsedDirClasspaths,
2740
			endorsedDirClasspaths,
2725
			customEncoding);
2741
			customEncoding);
2726
2742
2743
	if (specifiedEncodings != null && specifiedEncodings.size() > 1) {
2744
		this.logger.logPendingError(this.bind("configure.multipleencodings", //$NON-NLS-1$
2745
				(String) this.options.get(CompilerOptions.OPTION_Encoding),
2746
				getAllEncodings(specifiedEncodings)));
2747
	}
2727
	if (this.pendingErrors != null) {
2748
	if (this.pendingErrors != null) {
2728
		for (Iterator iterator = this.pendingErrors.iterator(); iterator.hasNext(); ) {
2749
		for (Iterator iterator = this.pendingErrors.iterator(); iterator.hasNext(); ) {
2729
			String message = (String) iterator.next();
2750
			String message = (String) iterator.next();
Lines 2732-2737 Link Here
2732
		this.pendingErrors = null;
2753
		this.pendingErrors = null;
2733
	}
2754
	}
2734
}
2755
}
2756
private static String getAllEncodings(Set encodings) {
2757
	int size = encodings.size();
2758
	String[] allEncodings = new String[size];
2759
	encodings.toArray(allEncodings);
2760
	Arrays.sort(allEncodings);
2761
	StringBuffer buffer = new StringBuffer();
2762
	for (int i = 0; i < size; i++) {
2763
		if (i > 0) {
2764
			buffer.append(", "); //$NON-NLS-1$
2765
		}
2766
		buffer.append(allEncodings[i]);
2767
	}
2768
	return String.valueOf(buffer);
2769
}
2770
2735
private void initializeWarnings(String propertiesFile) {
2771
private void initializeWarnings(String propertiesFile) {
2736
	File file = new File(propertiesFile);
2772
	File file = new File(propertiesFile);
2737
	if (!file.exists()) {
2773
	if (!file.exists()) {
(-)batch/org/eclipse/jdt/internal/compiler/batch/messages.properties (+3 lines)
Lines 97-102 Link Here
97
configure.multipleClasspathSections = multiple Class-Path headers in manifest of jar file: {0}
97
configure.multipleClasspathSections = multiple Class-Path headers in manifest of jar file: {0}
98
configure.missingwarningspropertiesfile=properties file {0} does not exist
98
configure.missingwarningspropertiesfile=properties file {0} does not exist
99
configure.ioexceptionwarningspropertiesfile=An IOException occurred while reading the properties file {0}
99
configure.ioexceptionwarningspropertiesfile=An IOException occurred while reading the properties file {0}
100
configure.multipleencodings=Multiple encoding specified: {1}. The default encoding has been set to {0}
101
configure.differentencodings=Found encoding {0}. Different encodings were specified: {1}
102
configure.differentencoding=Found encoding {0}. A different encoding was specified: {1}
100
103
101
### requestor
104
### requestor
102
requestor.error = {0}. ERROR in {1}
105
requestor.error = {0}. ERROR in {1}

Return to bug 310330