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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java (-6 / +29 lines)
Lines 940-951 Link Here
940
        "    -g:none            no debug info\n" + 
940
        "    -g:none            no debug info\n" + 
941
        "    -preserveAllLocals preserve unused local vars for debug purpose\n" + 
941
        "    -preserveAllLocals preserve unused local vars for debug purpose\n" + 
942
        " \n" + 
942
        " \n" + 
943
        " Ignored options:\n" + 
943
        " Annotation processing options:\n" + 
944
        "    -J<option>         pass option to virtual machine (ignored)\n" + 
944
        "   These options are meaningful only in a 1.6 environment.\n" + 
945
        "    -X<option>         specify non-standard option (ignored\n" + 
945
        "    -Akey[=value]        annotation processors options that are made to\n" + 
946
        "                       except for -Xemacs)\n" + 
946
        "                         annotation processors. key are identifiers separated\n" + 
947
        "    -X                 print non-standard options and exit (ignored)\n" + 
947
        "                         by ..\n" + 
948
        "    -O                 optimize for execution time (ignored)\n" + 
948
        "    -processorpath <directories and zip/jar files separated by ;>\n" + 
949
        "                         specify locations where to find annotation processors\n" + 
950
        "                         If this option is not used, the classpath will be\n" + 
951
        "                         searched for processors.\n" + 
952
        "    -processor <class1[,class2,...]>\n" + 
953
        "                         Qualified names of the annotation processors to run.\n" + 
954
        "                         This bypasses the default annotation discovery process\n" + 
955
        "    -proc:only           run annotation processors, but do not compile\n" + 
956
        "    -proc:none           perform compilation but do not run annotation\n" + 
957
        "                         processors\n" + 
958
        "    -s <dir>             specify a directory where to put the generated source\n" + 
959
        "                         files\n" + 
960
        "    -XprintProcessorInfo print information about which annotations and which\n" + 
961
        "                         elements a processor is asked to process\n" + 
962
        "    -XprintRounds        print information about annotation processing rounds.\n" + 
949
        " \n" + 
963
        " \n" + 
950
        " Advanced options:\n" + 
964
        " Advanced options:\n" + 
951
        "    @<file>            read command line arguments from file\n" + 
965
        "    @<file>            read command line arguments from file\n" + 
Lines 970-975 Link Here
970
        "    -? -help           print this help message\n" + 
984
        "    -? -help           print this help message\n" + 
971
        "    -v -version        print compiler version\n" + 
985
        "    -v -version        print compiler version\n" + 
972
        "    -showversion       print compiler version and continue\n" + 
986
        "    -showversion       print compiler version and continue\n" + 
987
        " \n" + 
988
        " Ignored options:\n" + 
989
        "    -J<option>         pass option to virtual machine (ignored)\n" + 
990
        "    -X<option>         specify non-standard option (ignored\n" + 
991
        "                       except for listed -X options)\n" + 
992
        "    -X                 print non-standard options and exit (ignored)\n" + 
993
        "    -O                 optimize for execution time (ignored)\n" + 
973
        "\n";
994
        "\n";
974
	String expandedExpectedOutput = 
995
	String expandedExpectedOutput = 
975
		MessageFormat.format(expectedOutput, new String[] {
996
		MessageFormat.format(expectedOutput, new String[] {
Lines 1137-1142 Link Here
1137
			"		<option key=\"org.eclipse.jdt.core.compiler.debug.localVariable\" value=\"do not generate\"/>\n" + 
1158
			"		<option key=\"org.eclipse.jdt.core.compiler.debug.localVariable\" value=\"do not generate\"/>\n" + 
1138
			"		<option key=\"org.eclipse.jdt.core.compiler.debug.sourceFile\" value=\"generate\"/>\n" + 
1159
			"		<option key=\"org.eclipse.jdt.core.compiler.debug.sourceFile\" value=\"generate\"/>\n" + 
1139
			"		<option key=\"org.eclipse.jdt.core.compiler.doc.comment.support\" value=\"disabled\"/>\n" + 
1160
			"		<option key=\"org.eclipse.jdt.core.compiler.doc.comment.support\" value=\"disabled\"/>\n" + 
1161
			"		<option key=\"org.eclipse.jdt.core.compiler.generateClassFiles\" value=\"enabled\"/>\n" + 
1140
			"		<option key=\"org.eclipse.jdt.core.compiler.maxProblemPerUnit\" value=\"100\"/>\n" + 
1162
			"		<option key=\"org.eclipse.jdt.core.compiler.maxProblemPerUnit\" value=\"100\"/>\n" + 
1141
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.annotationSuperInterface\" value=\"warning\"/>\n" + 
1163
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.annotationSuperInterface\" value=\"warning\"/>\n" + 
1142
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.assertIdentifier\" value=\"warning\"/>\n" + 
1164
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.assertIdentifier\" value=\"warning\"/>\n" + 
Lines 1203-1208 Link Here
1203
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete\" value=\"disabled\"/>\n" + 
1225
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete\" value=\"disabled\"/>\n" + 
1204
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.unusedPrivateMember\" value=\"warning\"/>\n" + 
1226
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.unusedPrivateMember\" value=\"warning\"/>\n" + 
1205
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast\" value=\"warning\"/>\n" + 
1227
			"		<option key=\"org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast\" value=\"warning\"/>\n" + 
1228
			"		<option key=\"org.eclipse.jdt.core.compiler.processAnnotations\" value=\"enabled\"/>\n" + 
1206
			"		<option key=\"org.eclipse.jdt.core.compiler.source\" value=\"1.5\"/>\n" + 
1229
			"		<option key=\"org.eclipse.jdt.core.compiler.source\" value=\"1.5\"/>\n" + 
1207
			"		<option key=\"org.eclipse.jdt.core.compiler.taskCaseSensitive\" value=\"enabled\"/>\n" + 
1230
			"		<option key=\"org.eclipse.jdt.core.compiler.taskCaseSensitive\" value=\"enabled\"/>\n" + 
1208
			"		<option key=\"org.eclipse.jdt.core.compiler.taskPriorities\" value=\"\"/>\n" + 
1231
			"		<option key=\"org.eclipse.jdt.core.compiler.taskPriorities\" value=\"\"/>\n" + 
(-)batch/org/eclipse/jdt/internal/compiler/batch/messages.properties (-8 / +29 lines)
Lines 63-69 Link Here
63
configure.noClasspath = no classpath defined, using default directory instead
63
configure.noClasspath = no classpath defined, using default directory instead
64
configure.incorrectClasspath = incorrect classpath: {0}
64
configure.incorrectClasspath = incorrect classpath: {0}
65
configure.invalidexpansionargumentname = expansion argument file {0} does not exist or cannot be read
65
configure.invalidexpansionargumentname = expansion argument file {0} does not exist or cannot be read
66
configure.cannotOpenLog = cannot open .log file
66
configure.cannotOpenLog = cannot open .log file: {0}
67
configure.unexpectedCustomEncoding = unexpected custom encoding specification: {0}[{1}]
67
configure.unexpectedCustomEncoding = unexpected custom encoding specification: {0}[{1}]
68
configure.unsupportedEncoding = unsupported encoding format: {0}
68
configure.unsupportedEncoding = unsupported encoding format: {0}
69
configure.duplicateDefaultEncoding = duplicate default encoding format specification: {0}
69
configure.duplicateDefaultEncoding = duplicate default encoding format specification: {0}
Lines 160-171 Link Here
160
\    -g:none            no debug info\n\
160
\    -g:none            no debug info\n\
161
\    -preserveAllLocals preserve unused local vars for debug purpose\n\
161
\    -preserveAllLocals preserve unused local vars for debug purpose\n\
162
\ \n\
162
\ \n\
163
\ Ignored options:\n\
163
\ Annotation processing options:\n\
164
\    -J<option>         pass option to virtual machine (ignored)\n\
164
\   These options are meaningful only in a 1.6 environment.\n\
165
\    -X<option>         specify non-standard option (ignored\n\
165
\    -Akey[=value]        annotation processors options that are made to\n\
166
\                       except for -Xemacs)\n\
166
\                         annotation processors. key are identifiers separated\n\
167
\    -X                 print non-standard options and exit (ignored)\n\
167
\                         by '.'.\n\
168
\    -O                 optimize for execution time (ignored)\n\
168
\    -processorpath <directories and zip/jar files separated by {0}>\n\
169
\                         specify locations where to find annotation processors\n\
170
\                         If this option is not used, the classpath will be\n\
171
\                         searched for processors.\n\
172
\    -processor <class1[,class2,...]>\n\
173
\                         Qualified names of the annotation processors to run.\n\
174
\                         This bypasses the default annotation discovery process\n\
175
\    -proc:only           run annotation processors, but do not compile\n\
176
\    -proc:none           perform compilation but do not run annotation\n\
177
\                         processors\n\
178
\    -s <dir>             specify a directory where to put the generated source\n\
179
\                         files\n\
180
\    -XprintProcessorInfo print information about which annotations and which\n\
181
\                         elements a processor is asked to process\n\
182
\    -XprintRounds        print information about annotation processing rounds.\n\
169
\ \n\
183
\ \n\
170
\ Advanced options:\n\
184
\ Advanced options:\n\
171
\    @<file>            read command line arguments from file\n\
185
\    @<file>            read command line arguments from file\n\
Lines 189-195 Link Here
189
\ \n\
203
\ \n\
190
\    -? -help           print this help message\n\
204
\    -? -help           print this help message\n\
191
\    -v -version        print compiler version\n\
205
\    -v -version        print compiler version\n\
192
\    -showversion       print compiler version and continue\n
206
\    -showversion       print compiler version and continue\n\
207
\ \n\
208
\ Ignored options:\n\
209
\    -J<option>         pass option to virtual machine (ignored)\n\
210
\    -X<option>         specify non-standard option (ignored\n\
211
\                       except for listed -X options)\n\
212
\    -X                 print non-standard options and exit (ignored)\n\
213
\    -O                 optimize for execution time (ignored)\n
193
misc.usage.warn = {1} {2}\n\
214
misc.usage.warn = {1} {2}\n\
194
{3}\n\
215
{3}\n\
195
\ \n\
216
\ \n\
(-)batch/org/eclipse/jdt/internal/compiler/batch/Main.java (-4 / +85 lines)
Lines 44-49 Link Here
44
import org.eclipse.jdt.core.compiler.CharOperation;
44
import org.eclipse.jdt.core.compiler.CharOperation;
45
import org.eclipse.jdt.core.compiler.InvalidInputException;
45
import org.eclipse.jdt.core.compiler.InvalidInputException;
46
import org.eclipse.jdt.core.compiler.IProblem;
46
import org.eclipse.jdt.core.compiler.IProblem;
47
import org.eclipse.jdt.internal.compiler.AbstractAnnotationProcessorManager;
47
import org.eclipse.jdt.internal.compiler.ClassFile;
48
import org.eclipse.jdt.internal.compiler.ClassFile;
48
import org.eclipse.jdt.internal.compiler.CompilationResult;
49
import org.eclipse.jdt.internal.compiler.CompilationResult;
49
import org.eclipse.jdt.internal.compiler.Compiler;
50
import org.eclipse.jdt.internal.compiler.Compiler;
Lines 940-946 Link Here
940
					this.log.println("# " + dateFormat.format(date));//$NON-NLS-1$
941
					this.log.println("# " + dateFormat.format(date));//$NON-NLS-1$
941
				}
942
				}
942
			} catch (FileNotFoundException e) {
943
			} catch (FileNotFoundException e) {
943
				throw new InvalidInputException(this.main.bind("configure.cannotOpenLog")); //$NON-NLS-1$
944
				throw new InvalidInputException(this.main.bind("configure.cannotOpenLog", logFileName)); //$NON-NLS-1$
944
			}
945
			}
945
		}
946
		}
946
947
Lines 1151-1156 Link Here
1151
1152
1152
public boolean verbose = false;
1153
public boolean verbose = false;
1153
1154
1155
private String[] expandedCommandLine;
1156
1157
private PrintWriter err;
1158
1154
public Main(PrintWriter outWriter, PrintWriter errWriter, boolean systemExitWhenFinished) {
1159
public Main(PrintWriter outWriter, PrintWriter errWriter, boolean systemExitWhenFinished) {
1155
	this(outWriter, errWriter, systemExitWhenFinished, null);
1160
	this(outWriter, errWriter, systemExitWhenFinished, null);
1156
}
1161
}
Lines 1918-1923 Link Here
1918
	final int INSIDE_SOURCE_PATH_start = 13;
1923
	final int INSIDE_SOURCE_PATH_start = 13;
1919
	final int INSIDE_ENDORSED_DIRS = 15;
1924
	final int INSIDE_ENDORSED_DIRS = 15;
1920
	final int INSIDE_SOURCE_DIRECTORY_DESTINATION_PATH = 16;
1925
	final int INSIDE_SOURCE_DIRECTORY_DESTINATION_PATH = 16;
1926
	final int INSIDE_PROCESSOR_PATH_start = 17;
1927
	final int INSIDE_PROCESSOR_start = 18;
1928
	final int INSIDE_S_start = 19;
1921
1929
1922
	final int DEFAULT = 0;
1930
	final int DEFAULT = 0;
1923
	ArrayList bootclasspaths = new ArrayList(DEFAULT_SIZE_CLASSPATH);
1931
	ArrayList bootclasspaths = new ArrayList(DEFAULT_SIZE_CLASSPATH);
Lines 1996-2001 Link Here
1996
		}
2004
		}
1997
	}
2005
	}
1998
	argCount = newCommandLineArgs.length;
2006
	argCount = newCommandLineArgs.length;
2007
	this.expandedCommandLine = newCommandLineArgs;
1999
	while (++index < argCount) {
2008
	while (++index < argCount) {
2000
2009
2001
		if (customEncoding != null) {
2010
		if (customEncoding != null) {
Lines 2422-2427 Link Here
2422
					this.logger.setEmacs();
2431
					this.logger.setEmacs();
2423
					continue;
2432
					continue;
2424
				}
2433
				}
2434
				// annotation processing
2435
				if (currentArg.startsWith("-A")) { //$NON-NLS-1$
2436
					mode = DEFAULT;
2437
					continue;
2438
				}
2439
				if (currentArg.equals("-processorpath")) { //$NON-NLS-1$
2440
					mode = INSIDE_PROCESSOR_PATH_start;
2441
					continue;
2442
				}
2443
				if (currentArg.equals("-processor")) { //$NON-NLS-1$
2444
					mode = INSIDE_PROCESSOR_start;
2445
					continue;
2446
				}
2447
				if (currentArg.equals("-proc:only")) { //$NON-NLS-1$
2448
					this.options.put(
2449
						CompilerOptions.OPTION_GenerateClassFiles,
2450
						CompilerOptions.DISABLED);
2451
					mode = DEFAULT;
2452
					continue;
2453
				}
2454
				if (currentArg.equals("-proc:none")) { //$NON-NLS-1$
2455
					this.options.put(
2456
						CompilerOptions.OPTION_Process_Annotations,
2457
						CompilerOptions.DISABLED);
2458
					mode = DEFAULT;
2459
					continue;
2460
				}
2461
				if (currentArg.equals("-s")) { //$NON-NLS-1$
2462
					mode = INSIDE_S_start;
2463
					continue;
2464
				}
2465
				if (currentArg.equals("-XprintProcessorInfo") //$NON-NLS-1$
2466
						|| currentArg.equals("-XprintRounds")) { //$NON-NLS-1$ 
2467
					mode = DEFAULT;
2468
					continue;
2469
				}
2425
				// tolerated javac options - quietly filtered out
2470
				// tolerated javac options - quietly filtered out
2426
				if (currentArg.startsWith("-X")) { //$NON-NLS-1$
2471
				if (currentArg.startsWith("-X")) { //$NON-NLS-1$
2427
					mode = DEFAULT;
2472
					mode = DEFAULT;
Lines 2576-2582 Link Here
2576
						this.bind("configure.incorrectDestinationPathEntry", //$NON-NLS-1$ 
2621
						this.bind("configure.incorrectDestinationPathEntry", //$NON-NLS-1$ 
2577
							"[-d " + currentArg)); //$NON-NLS-1$
2622
							"[-d " + currentArg)); //$NON-NLS-1$
2578
				}
2623
				}
2579
				// continue; fall through on purpose
2624
				break;
2625
			case INSIDE_PROCESSOR_PATH_start :
2626
				// nothing to do here. This is consumed again by the AnnotationProcessorManager
2627
				mode = DEFAULT;
2628
				continue;
2629
			case INSIDE_PROCESSOR_start :
2630
				// nothing to do here. This is consumed again by the AnnotationProcessorManager
2631
				mode = DEFAULT;
2632
				continue;
2633
			case INSIDE_S_start :
2634
				// nothing to do here. This is consumed again by the AnnotationProcessorManager
2635
				mode = DEFAULT;
2636
				continue;			
2580
		}
2637
		}
2581
2638
2582
		// default is input directory, if no custom destination path exists
2639
		// default is input directory, if no custom destination path exists
Lines 2678-2690 Link Here
2678
		this.timesCounter = 0;
2735
		this.timesCounter = 0;
2679
	}
2736
	}
2680
	
2737
	
2681
	if (filesCount != 0)
2738
	if (filesCount != 0) {
2682
		System.arraycopy(
2739
		System.arraycopy(
2683
			this.filenames,
2740
			this.filenames,
2684
			0,
2741
			0,
2685
			(this.filenames = new String[filesCount]),
2742
			(this.filenames = new String[filesCount]),
2686
			0,
2743
			0,
2687
			filesCount);
2744
			filesCount);
2745
	}
2688
2746
2689
	setPaths(bootclasspaths,
2747
	setPaths(bootclasspaths,
2690
			sourcepathClasspathArg,
2748
			sourcepathClasspathArg,
Lines 2857-2862 Link Here
2857
		Map customDefaultOptions) {
2915
		Map customDefaultOptions) {
2858
	this.logger = new Logger(this, outWriter, errWriter);
2916
	this.logger = new Logger(this, outWriter, errWriter);
2859
	this.out = outWriter;
2917
	this.out = outWriter;
2918
	this.err = errWriter;
2860
	this.systemExitWhenFinished = systemExit;
2919
	this.systemExitWhenFinished = systemExit;
2861
	this.options = new CompilerOptions().getMap();
2920
	this.options = new CompilerOptions().getMap();
2862
	if (customDefaultOptions != null) {
2921
	if (customDefaultOptions != null) {
Lines 2952-2957 Link Here
2952
			getProblemFactory(),
3011
			getProblemFactory(),
2953
			this.out);
3012
			this.out);
2954
3013
3014
	if (this.compilerOptions.complianceLevel >= ClassFileConstants.JDK1_6
3015
			&& this.compilerOptions.processAnnotations) {
3016
		initializeAnnotationProcessorManager();
3017
	}
3018
2955
	// set the non-externally configurable options.
3019
	// set the non-externally configurable options.
2956
	this.compilerOptions.verbose = this.verbose;
3020
	this.compilerOptions.verbose = this.verbose;
2957
	this.compilerOptions.produceReferenceInfo = this.produceRefInfo;
3021
	this.compilerOptions.produceReferenceInfo = this.produceRefInfo;
Lines 2967-2973 Link Here
2967
	// cleanup
3031
	// cleanup
2968
	environment.cleanup();
3032
	environment.cleanup();
2969
}
3033
}
2970
3034
protected void initializeAnnotationProcessorManager() {
3035
	try {
3036
		Class c = Class.forName("org.eclipse.jdt.internal.compiler.apt.dispatch.AnnotationProcessorManager"); //$NON-NLS-1$
3037
		AbstractAnnotationProcessorManager annotationManager = (AbstractAnnotationProcessorManager) c.newInstance();
3038
		annotationManager.configure(this, this.expandedCommandLine);
3039
		annotationManager.setErr(this.err);
3040
		annotationManager.setOut(this.out);
3041
		this.batchCompiler.annotationProcessorManager = annotationManager;
3042
	} catch (ClassNotFoundException e) {
3043
		// ignore
3044
	} catch (InstantiationException e) {
3045
		// should not happen
3046
		throw new org.eclipse.jdt.internal.compiler.problem.AbortCompilation();
3047
	} catch (IllegalAccessException e) {
3048
		// should not happen
3049
		throw new org.eclipse.jdt.internal.compiler.problem.AbortCompilation();
3050
	}
3051
}
2971
public void printUsage() {
3052
public void printUsage() {
2972
	printUsage("misc.usage"); //$NON-NLS-1$
3053
	printUsage("misc.usage"); //$NON-NLS-1$
2973
}
3054
}
(-)compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java (+24 lines)
Lines 108-113 Link Here
108
	public static final String OPTION_ReportParameterAssignment =  "org.eclipse.jdt.core.compiler.problem.parameterAssignment"; //$NON-NLS-1$
108
	public static final String OPTION_ReportParameterAssignment =  "org.eclipse.jdt.core.compiler.problem.parameterAssignment"; //$NON-NLS-1$
109
	public static final String OPTION_ReportFallthroughCase =  "org.eclipse.jdt.core.compiler.problem.fallthroughCase"; //$NON-NLS-1$
109
	public static final String OPTION_ReportFallthroughCase =  "org.eclipse.jdt.core.compiler.problem.fallthroughCase"; //$NON-NLS-1$
110
	public static final String OPTION_ReportOverridingMethodWithoutSuperInvocation =  "org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation"; //$NON-NLS-1$
110
	public static final String OPTION_ReportOverridingMethodWithoutSuperInvocation =  "org.eclipse.jdt.core.compiler.problem.overridingMethodWithoutSuperInvocation"; //$NON-NLS-1$
111
	public static final String OPTION_GenerateClassFiles = "org.eclipse.jdt.core.compiler.generateClassFiles"; //$NON-NLS-1$
112
	public static final String OPTION_Process_Annotations = "org.eclipse.jdt.core.compiler.processAnnotations"; //$NON-NLS-1$
111
	
113
	
112
	// Backward compatibility
114
	// Backward compatibility
113
	public static final String OPTION_ReportInvalidAnnotation = "org.eclipse.jdt.core.compiler.problem.invalidAnnotation"; //$NON-NLS-1$
115
	public static final String OPTION_ReportInvalidAnnotation = "org.eclipse.jdt.core.compiler.problem.invalidAnnotation"; //$NON-NLS-1$
Lines 303-308 Link Here
303
	// store annotations
305
	// store annotations
304
	public boolean storeAnnotations = false;
306
	public boolean storeAnnotations = false;
305
	
307
	
308
	// annotation processing
309
	public boolean generateClassFiles = true;
310
	public boolean processAnnotations = true;
311
	
306
	/** 
312
	/** 
307
	 * Initializing the compiler options with defaults
313
	 * Initializing the compiler options with defaults
308
	 */
314
	 */
Lines 412-417 Link Here
412
		optionsMap.put(OPTION_ReportParameterAssignment, getSeverityString(ParameterAssignment));
418
		optionsMap.put(OPTION_ReportParameterAssignment, getSeverityString(ParameterAssignment));
413
		optionsMap.put(OPTION_ReportFallthroughCase, getSeverityString(FallthroughCase));
419
		optionsMap.put(OPTION_ReportFallthroughCase, getSeverityString(FallthroughCase));
414
		optionsMap.put(OPTION_ReportOverridingMethodWithoutSuperInvocation, getSeverityString(OverridingMethodWithoutSuperInvocation));
420
		optionsMap.put(OPTION_ReportOverridingMethodWithoutSuperInvocation, getSeverityString(OverridingMethodWithoutSuperInvocation));
421
		optionsMap.put(OPTION_GenerateClassFiles, this.generateClassFiles ? ENABLED : DISABLED); 
422
		optionsMap.put(OPTION_Process_Annotations, this.processAnnotations ? ENABLED : DISABLED); 
415
		return optionsMap;		
423
		return optionsMap;		
416
	}
424
	}
417
	
425
	
Lines 740-745 Link Here
740
				this.reportMissingJavadocCommentsOverriding = false;
748
				this.reportMissingJavadocCommentsOverriding = false;
741
			}
749
			}
742
		}
750
		}
751
		if ((optionValue = optionsMap.get(OPTION_GenerateClassFiles)) != null) {
752
			if (ENABLED.equals(optionValue)) {
753
				this.generateClassFiles = true;
754
			} else if (DISABLED.equals(optionValue)) {
755
				this.generateClassFiles = false;
756
			}
757
		}
758
		if ((optionValue = optionsMap.get(OPTION_Process_Annotations)) != null) {
759
			if (ENABLED.equals(optionValue)) {
760
				this.processAnnotations = true;
761
			} else if (DISABLED.equals(optionValue)) {
762
				this.processAnnotations = false;
763
			}
764
		}
743
	}
765
	}
744
766
745
	public String toString() {
767
	public String toString() {
Lines 819-824 Link Here
819
		buf.append("\n\t- unused label: ").append(getSeverityString(UnusedLabel)); //$NON-NLS-1$
841
		buf.append("\n\t- unused label: ").append(getSeverityString(UnusedLabel)); //$NON-NLS-1$
820
		buf.append("\n\t- treat optional error as fatal: ").append(this.treatOptionalErrorAsFatal ? ENABLED : DISABLED); //$NON-NLS-1$
842
		buf.append("\n\t- treat optional error as fatal: ").append(this.treatOptionalErrorAsFatal ? ENABLED : DISABLED); //$NON-NLS-1$
821
		buf.append("\n\t- parameter assignment: ").append(getSeverityString(ParameterAssignment)); //$NON-NLS-1$
843
		buf.append("\n\t- parameter assignment: ").append(getSeverityString(ParameterAssignment)); //$NON-NLS-1$
844
		buf.append("\n\t- generate class files: ").append(this.generateClassFiles ? ENABLED : DISABLED); //$NON-NLS-1$
845
		buf.append("\n\t- process annotations: ").append(this.processAnnotations ? ENABLED : DISABLED); //$NON-NLS-1$
822
		return buf.toString();
846
		return buf.toString();
823
	}
847
	}
824
848
(-)compiler/org/eclipse/jdt/internal/compiler/Compiler.java (-29 / +60 lines)
Lines 40-45 Link Here
40
	// ONCE STABILIZED, THESE SHOULD RETURN TO A FINAL FIELD
40
	// ONCE STABILIZED, THESE SHOULD RETURN TO A FINAL FIELD
41
	public static boolean DEBUG = false;
41
	public static boolean DEBUG = false;
42
	public int parseThreshold = -1;
42
	public int parseThreshold = -1;
43
	
44
	public AbstractAnnotationProcessorManager annotationProcessorManager;
45
43
	// number of initial units parsed at once (-1: none)
46
	// number of initial units parsed at once (-1: none)
44
47
45
	/*
48
	/*
Lines 354-387 Link Here
354
			CompilationUnitDeclaration parsedUnit;
357
			CompilationUnitDeclaration parsedUnit;
355
			CompilationResult unitResult =
358
			CompilationResult unitResult =
356
				new CompilationResult(sourceUnits[i], i, maxUnits, this.options.maxProblemsPerUnit);
359
				new CompilationResult(sourceUnits[i], i, maxUnits, this.options.maxProblemsPerUnit);
357
			try {
360
			if (options.verbose) {
358
				if (options.verbose) {
361
				this.out.println(
359
					this.out.println(
362
					Messages.bind(Messages.compilation_request,
360
						Messages.bind(Messages.compilation_request,
363
					new String[] {
361
						new String[] {
364
						String.valueOf(i + 1),
362
							String.valueOf(i + 1),
365
						String.valueOf(maxUnits),
363
							String.valueOf(maxUnits),
366
						new String(sourceUnits[i].getFileName())
364
							new String(sourceUnits[i].getFileName())
367
					}));
365
						}));
368
			}
366
				}
369
			// diet parsing for large collection of units
367
				// diet parsing for large collection of units
370
			if (totalUnits < parseThreshold) {
368
				if (totalUnits < parseThreshold) {
371
				parsedUnit = parser.parse(sourceUnits[i], unitResult);
369
					parsedUnit = parser.parse(sourceUnits[i], unitResult);
372
			} else {
370
				} else {
373
				parsedUnit = parser.dietParse(sourceUnits[i], unitResult);
371
					parsedUnit = parser.dietParse(sourceUnits[i], unitResult);
374
			}
372
				}
375
			ImportReference currentPackage = parsedUnit.currentPackage;
373
				// initial type binding creation
376
			if (currentPackage != null) {
374
				lookupEnvironment.buildTypeBindings(parsedUnit, null /*no access restriction*/);
377
				unitResult.recordPackageName(currentPackage.tokens);
375
				this.addCompilationUnit(sourceUnits[i], parsedUnit);
376
				ImportReference currentPackage = parsedUnit.currentPackage;
377
				if (currentPackage != null) {
378
					unitResult.recordPackageName(currentPackage.tokens);
379
				}
380
				//} catch (AbortCompilationUnit e) {
381
				//	requestor.acceptResult(unitResult.tagAsAccepted());
382
			} finally {
383
				sourceUnits[i] = null; // no longer hold onto the unit
384
			}
378
			}
379
			// initial type binding creation
380
			lookupEnvironment.buildTypeBindings(parsedUnit, null /*no access restriction*/);
381
			this.addCompilationUnit(sourceUnits[i], parsedUnit);
382
			//} catch (AbortCompilationUnit e) {
383
			//	requestor.acceptResult(unitResult.tagAsAccepted());
385
		}
384
		}
386
		// binding resolution
385
		// binding resolution
387
		lookupEnvironment.completeTypeBindings();
386
		lookupEnvironment.completeTypeBindings();
Lines 394-407 Link Here
394
	 */
393
	 */
395
	public void compile(ICompilationUnit[] sourceUnits) {
394
	public void compile(ICompilationUnit[] sourceUnits) {
396
		CompilationUnitDeclaration unit = null;
395
		CompilationUnitDeclaration unit = null;
397
		int i = 0;
398
		try {
396
		try {
399
			// build and record parsed units
397
			// build and record parsed units
400
398
401
			beginToCompile(sourceUnits);
399
			beginToCompile(sourceUnits);
402
400
401
			if (this.annotationProcessorManager != null) {
402
				processAnnotations(sourceUnits);
403
				if (!options.generateClassFiles) {
404
					return;
405
				}
406
			}
403
			// process all units (some more could be injected in the loop by the lookup environment)
407
			// process all units (some more could be injected in the loop by the lookup environment)
404
			for (; i < this.totalUnits; i++) {
408
			for (int i = 0; i < this.totalUnits; i++) {
405
				unit = unitsToProcess[i];
409
				unit = unitsToProcess[i];
406
				try {
410
				try {
407
					if (options.verbose)
411
					if (options.verbose)
Lines 450-455 Link Here
450
		}
454
		}
451
	}
455
	}
452
456
457
	protected void processAnnotations(ICompilationUnit[] sourceUnits) {
458
		int newUnitSize = 0;
459
		do {
460
			this.annotationProcessorManager.processAnnotations(unitsToProcess, false);
461
    		List newUnits = this.annotationProcessorManager.getNewUnits();
462
    		newUnitSize = newUnits.size();
463
    		ICompilationUnit[] newSourceUnits = sourceUnits;
464
    		if (newUnitSize != 0) {
465
    			// we reset the compiler in order to restart with the new units
466
    			this.reset();
467
    			int sourceUnitsLength = sourceUnits.length;
468
    			newSourceUnits = new ICompilationUnit[sourceUnitsLength + newUnitSize];
469
    			newUnits.toArray(newSourceUnits);
470
    			System.arraycopy(sourceUnits, 0, newSourceUnits, newUnitSize, sourceUnitsLength);
471
    			beginToCompile(newSourceUnits);
472
    			this.annotationProcessorManager.reset();
473
    		}
474
		} while (newUnitSize != 0);
475
		// one more loop to create possible resources
476
		// this loop cannot create any java source files
477
		this.annotationProcessorManager.processAnnotations(unitsToProcess, true);
478
		List newUnits = this.annotationProcessorManager.getNewUnits();
479
		if (newUnits.size() != 0) {
480
			// TODO report error
481
		}
482
	}
483
453
	/*
484
	/*
454
	 * Compiler crash recovery in case of unexpected runtime exceptions
485
	 * Compiler crash recovery in case of unexpected runtime exceptions
455
	 */
486
	 */
(-)compiler/org/eclipse/jdt/internal/compiler/AbstractAnnotationProcessorManager.java (+23 lines)
Added Link Here
1
package org.eclipse.jdt.internal.compiler;
2
3
import java.io.PrintWriter;
4
import java.util.List;
5
6
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
7
import org.eclipse.jdt.internal.compiler.batch.Main;
8
9
public abstract class AbstractAnnotationProcessorManager {
10
	public abstract void configure(Main batchCompiler, String[] options);
11
	
12
	public abstract void setOut(PrintWriter out);
13
	
14
	public abstract void setErr(PrintWriter err);
15
16
	public abstract List getNewUnits();
17
	
18
	public abstract void reset();
19
	
20
	public abstract void processAnnotations(CompilationUnitDeclaration[] units, boolean isLastRound);
21
	
22
	public abstract void setProcessors(Object[] processors);
23
}

Return to bug 160773