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

Collapse All | Expand All

(-)buildnotes_jdt-core.html (+4 lines)
Lines 46-51 Link Here
46
<br>Project org.eclipse.jdt.core v_812
46
<br>Project org.eclipse.jdt.core v_812
47
(<a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.core/?only_with_tag=v_812">cvs</a>).
47
(<a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.core/?only_with_tag=v_812">cvs</a>).
48
<h2>What's new in this drop</h2>
48
<h2>What's new in this drop</h2>
49
<ul>
50
<li>Added new API <code>org.eclipse.jdt.core.JavaCore#VERSION_CLDC1_1</code> in order to support the cldc1.1 target inside the IDE.
51
</li>
52
</ul>
49
53
50
<h3>Problem Reports Fixed</h3>
54
<h3>Problem Reports Fixed</h3>
51
<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=203061">203061</a>
55
<a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=203061">203061</a>
(-)compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java (-7 / +21 lines)
Lines 206-212 Link Here
206
}
206
}
207
public void addDefinitelyAssignedVariables(Scope scope, int initStateIndex) {
207
public void addDefinitelyAssignedVariables(Scope scope, int initStateIndex) {
208
	// Required to fix 1PR0XVS: LFRE:WINNT - Compiler: variable table for method appears incorrect
208
	// Required to fix 1PR0XVS: LFRE:WINNT - Compiler: variable table for method appears incorrect
209
	if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS | ClassFileConstants.ATTR_STACK_MAP)) == 0)
209
	if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS
210
			| ClassFileConstants.ATTR_STACK_MAP_TABLE
211
			| ClassFileConstants.ATTR_STACK_MAP)) == 0)
210
		return;
212
		return;
211
	for (int i = 0; i < visibleLocalsCount; i++) {
213
	for (int i = 0; i < visibleLocalsCount; i++) {
212
		LocalVariableBinding localBinding = visibleLocals[i];
214
		LocalVariableBinding localBinding = visibleLocals[i];
Lines 235-241 Link Here
235
	labels[countLabels++] = aLabel;
237
	labels[countLabels++] = aLabel;
236
}
238
}
237
public void addVisibleLocalVariable(LocalVariableBinding localBinding) {
239
public void addVisibleLocalVariable(LocalVariableBinding localBinding) {
238
	if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS | ClassFileConstants.ATTR_STACK_MAP)) == 0)
240
	if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS
241
			| ClassFileConstants.ATTR_STACK_MAP_TABLE
242
			| ClassFileConstants.ATTR_STACK_MAP)) == 0)
239
		return;
243
		return;
240
244
241
	if (visibleLocalsCount >= visibleLocals.length)
245
	if (visibleLocalsCount >= visibleLocals.length)
Lines 1025-1031 Link Here
1025
public void exitUserScope(BlockScope currentScope) {
1029
public void exitUserScope(BlockScope currentScope) {
1026
	// mark all the scope's locals as losing their definite assignment
1030
	// mark all the scope's locals as losing their definite assignment
1027
1031
1028
	if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS | ClassFileConstants.ATTR_STACK_MAP)) == 0)
1032
	if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS
1033
			| ClassFileConstants.ATTR_STACK_MAP_TABLE
1034
			| ClassFileConstants.ATTR_STACK_MAP)) == 0)
1029
		return;
1035
		return;
1030
	int index = this.visibleLocalsCount - 1;
1036
	int index = this.visibleLocalsCount - 1;
1031
	while (index >= 0) {
1037
	while (index >= 0) {
Lines 1045-1051 Link Here
1045
}
1051
}
1046
public void exitUserScope(BlockScope currentScope, LocalVariableBinding binding) {
1052
public void exitUserScope(BlockScope currentScope, LocalVariableBinding binding) {
1047
	// mark all the scope's locals as losing their definite assignment
1053
	// mark all the scope's locals as losing their definite assignment
1048
	if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS | ClassFileConstants.ATTR_STACK_MAP)) == 0)
1054
	if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS
1055
			| ClassFileConstants.ATTR_STACK_MAP_TABLE
1056
			| ClassFileConstants.ATTR_STACK_MAP)) == 0)
1049
		return;
1057
		return;
1050
	int index = this.visibleLocalsCount - 1;
1058
	int index = this.visibleLocalsCount - 1;
1051
	while (index >= 0) {
1059
	while (index >= 0) {
Lines 5740-5746 Link Here
5740
			fieldBinding.type);
5748
			fieldBinding.type);
5741
}
5749
}
5742
public void record(LocalVariableBinding local) {
5750
public void record(LocalVariableBinding local) {
5743
	if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS | ClassFileConstants.ATTR_STACK_MAP)) == 0)
5751
	if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS
5752
			| ClassFileConstants.ATTR_STACK_MAP_TABLE
5753
			| ClassFileConstants.ATTR_STACK_MAP)) == 0)
5744
		return;
5754
		return;
5745
	if (allLocalsCounter == locals.length) {
5755
	if (allLocalsCounter == locals.length) {
5746
		// resize the collection
5756
		// resize the collection
Lines 6105-6111 Link Here
6105
public void removeNotDefinitelyAssignedVariables(Scope scope, int initStateIndex) {
6115
public void removeNotDefinitelyAssignedVariables(Scope scope, int initStateIndex) {
6106
	// given some flow info, make sure we did not loose some variables initialization
6116
	// given some flow info, make sure we did not loose some variables initialization
6107
	// if this happens, then we must update their pc entries to reflect it in debug attributes
6117
	// if this happens, then we must update their pc entries to reflect it in debug attributes
6108
	if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS | ClassFileConstants.ATTR_STACK_MAP)) == 0)
6118
	if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS
6119
			| ClassFileConstants.ATTR_STACK_MAP_TABLE
6120
			| ClassFileConstants.ATTR_STACK_MAP)) == 0)
6109
		return;
6121
		return;
6110
	for (int i = 0; i < visibleLocalsCount; i++) {
6122
	for (int i = 0; i < visibleLocalsCount; i++) {
6111
		LocalVariableBinding localBinding = visibleLocals[i];
6123
		LocalVariableBinding localBinding = visibleLocals[i];
Lines 6585-6591 Link Here
6585
		this.lastEntryPC = pos;
6597
		this.lastEntryPC = pos;
6586
	}
6598
	}
6587
	// need to update the initialization endPC in case of generation of local variable attributes.
6599
	// need to update the initialization endPC in case of generation of local variable attributes.
6588
	if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS | ClassFileConstants.ATTR_STACK_MAP)) != 0) {
6600
	if ((this.generateAttributes & (ClassFileConstants.ATTR_VARS
6601
			| ClassFileConstants.ATTR_STACK_MAP_TABLE
6602
			| ClassFileConstants.ATTR_STACK_MAP)) != 0) {
6589
		for (int i = 0, max = this.locals.length; i < max; i++) {
6603
		for (int i = 0, max = this.locals.length; i < max; i++) {
6590
			LocalVariableBinding local = this.locals[i];
6604
			LocalVariableBinding local = this.locals[i];
6591
			if (local != null && local.declaringScope == scope && local.initializationCount > 0) {
6605
			if (local != null && local.declaringScope == scope && local.initializationCount > 0) {
(-)compiler/org/eclipse/jdt/internal/compiler/codegen/BranchLabel.java (-1 / +1 lines)
Lines 205-211 Link Here
205
					this.codeStream.lastEntryPC = this.position;
205
					this.codeStream.lastEntryPC = this.position;
206
				}
206
				}
207
				// end of new code
207
				// end of new code
208
				if ((this.codeStream.generateAttributes & (ClassFileConstants.ATTR_VARS | ClassFileConstants.ATTR_STACK_MAP)) != 0) {
208
				if ((this.codeStream.generateAttributes & (ClassFileConstants.ATTR_VARS | ClassFileConstants.ATTR_STACK_MAP_TABLE | ClassFileConstants.ATTR_STACK_MAP)) != 0) {
209
					LocalVariableBinding locals[] = this.codeStream.locals;
209
					LocalVariableBinding locals[] = this.codeStream.locals;
210
					for (int i = 0, max = locals.length; i < max; i++) {
210
					for (int i = 0, max = locals.length; i < max; i++) {
211
						LocalVariableBinding local = locals[i];
211
						LocalVariableBinding local = locals[i];
(-)compiler/org/eclipse/jdt/internal/compiler/codegen/AttributeNamesConstants.java (+1 lines)
Lines 31-34 Link Here
31
	final char[] StackMapTableName = "StackMapTable".toCharArray(); //$NON-NLS-1$
31
	final char[] StackMapTableName = "StackMapTable".toCharArray(); //$NON-NLS-1$
32
	final char[] InconsistentHierarchy = "InconsistentHierarchy".toCharArray(); //$NON-NLS-1$
32
	final char[] InconsistentHierarchy = "InconsistentHierarchy".toCharArray(); //$NON-NLS-1$
33
	final char[] VarargsName = "Varargs".toCharArray(); //$NON-NLS-1$
33
	final char[] VarargsName = "Varargs".toCharArray(); //$NON-NLS-1$
34
	final char[] StackMapName = "StackMap".toCharArray(); //$NON-NLS-1$
34
}
35
}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java (-1 / +1 lines)
Lines 274-280 Link Here
274
		int count = isEnum ? 2 : 0; // reserve 2 slots for special enum methods: #values() and #valueOf(String)
274
		int count = isEnum ? 2 : 0; // reserve 2 slots for special enum methods: #values() and #valueOf(String)
275
		MethodBinding[] methodBindings = new MethodBinding[(clinitIndex == -1 ? size : size - 1) + count];
275
		MethodBinding[] methodBindings = new MethodBinding[(clinitIndex == -1 ? size : size - 1) + count];
276
		// create special methods for enums
276
		// create special methods for enums
277
	    SourceTypeBinding sourceType = referenceContext.binding;
277
		SourceTypeBinding sourceType = referenceContext.binding;
278
		if (isEnum) {
278
		if (isEnum) {
279
			methodBindings[0] = sourceType.addSyntheticEnumMethod(TypeConstants.VALUES); // add <EnumType>[] values() 
279
			methodBindings[0] = sourceType.addSyntheticEnumMethod(TypeConstants.VALUES); // add <EnumType>[] values() 
280
			methodBindings[1] = sourceType.addSyntheticEnumMethod(TypeConstants.VALUEOF); // add <EnumType> valueOf() 
280
			methodBindings[1] = sourceType.addSyntheticEnumMethod(TypeConstants.VALUEOF); // add <EnumType> valueOf() 
(-)model/org/eclipse/jdt/internal/core/util/Disassembler.java (-9 / +1 lines)
Lines 1261-1285 Link Here
1261
		writeNewLine(buffer, lineSeparator, tabNumber + 3);
1261
		writeNewLine(buffer, lineSeparator, tabNumber + 3);
1262
		int numberOfEntries = attribute.getNumberOfEntries();
1262
		int numberOfEntries = attribute.getNumberOfEntries();
1263
		final IStackMapFrame[] stackMapFrames = attribute.getStackMapFrame();
1263
		final IStackMapFrame[] stackMapFrames = attribute.getStackMapFrame();
1264
		int absolutePC = -1;
1265
		for (int j = 0; j < numberOfEntries; j++) {
1264
		for (int j = 0; j < numberOfEntries; j++) {
1266
			if (j > 0) {
1265
			if (j > 0) {
1267
				writeNewLine(buffer, lineSeparator, tabNumber + 3);
1266
				writeNewLine(buffer, lineSeparator, tabNumber + 3);
1268
			}
1267
			}
1269
			final IStackMapFrame frame = stackMapFrames[j];
1268
			final IStackMapFrame frame = stackMapFrames[j];
1270
			// disassemble each frame
1269
			// disassemble each frame
1271
			int offsetDelta = frame.getOffsetDelta();
1272
			if (absolutePC == -1) {
1273
				absolutePC = offsetDelta;
1274
			} else {
1275
				absolutePC += (offsetDelta + 1);
1276
			}
1277
			// FULL_FRAME
1278
			buffer.append(
1270
			buffer.append(
1279
					Messages.bind(
1271
					Messages.bind(
1280
						Messages.disassembler_frame_full_frame,
1272
						Messages.disassembler_frame_full_frame,
1281
						new String[] {
1273
						new String[] {
1282
							Integer.toString(absolutePC),
1274
							Integer.toString(frame.getOffsetDelta()),
1283
							Integer.toString(frame.getNumberOfLocals()),
1275
							Integer.toString(frame.getNumberOfLocals()),
1284
							disassemble(frame.getLocals(), mode),
1276
							disassemble(frame.getLocals(), mode),
1285
							Integer.toString(frame.getNumberOfStackItems()),
1277
							Integer.toString(frame.getNumberOfStackItems()),
(-)model/org/eclipse/jdt/core/JavaCore.java (-1 / +8 lines)
Lines 1045-1050 Link Here
1045
	/**
1045
	/**
1046
	 * Possible  configurable option value.
1046
	 * Possible  configurable option value.
1047
	 * @see #getDefaultOptions()
1047
	 * @see #getDefaultOptions()
1048
	 * @since 3.4
1049
	 */
1050
	public static final String VERSION_CLDC1_1 = "cldc1.1"; //$NON-NLS-1$
1051
	/**
1052
	 * Possible  configurable option value.
1053
	 * @see #getDefaultOptions()
1048
	 * @since 2.0
1054
	 * @since 2.0
1049
	 */
1055
	 */
1050
	public static final String ABORT = "abort"; //$NON-NLS-1$
1056
	public static final String ABORT = "abort"; //$NON-NLS-1$
Lines 1921-1928 Link Here
1921
	 *    Note that "1.4" target requires to toggle compliance mode to "1.4", "1.5" target requires
1927
	 *    Note that "1.4" target requires to toggle compliance mode to "1.4", "1.5" target requires
1922
	 *    to toggle compliance mode to "1.5", "1.6" target requires to toggle compliance mode to "1.6" and
1928
	 *    to toggle compliance mode to "1.5", "1.6" target requires to toggle compliance mode to "1.6" and
1923
	 *    "1.7" target requires to toggle compliance mode to "1.7".
1929
	 *    "1.7" target requires to toggle compliance mode to "1.7".
1930
	 *    "cldc1.1" requires the source version to be "1.3" and the compliance version to be "1.4" or lower.
1924
	 *     - option id:         "org.eclipse.jdt.core.compiler.codegen.targetPlatform"
1931
	 *     - option id:         "org.eclipse.jdt.core.compiler.codegen.targetPlatform"
1925
	 *     - possible values:   { "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7" }
1932
	 *     - possible values:   { "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "cldc1.1" }
1926
	 *     - default:           "1.2"
1933
	 *     - default:           "1.2"
1927
	 *
1934
	 *
1928
	 * COMPILER / Generating Local Variable Debug Attribute
1935
	 * COMPILER / Generating Local Variable Debug Attribute
(-)compiler/org/eclipse/jdt/internal/compiler/classfmt/ClassFileConstants.java (-10 / +18 lines)
Lines 81-89 Link Here
81
	
81
	
82
	int MINOR_VERSION_0 = 0;
82
	int MINOR_VERSION_0 = 0;
83
	int MINOR_VERSION_1 = 1;
83
	int MINOR_VERSION_1 = 1;
84
	int MINOR_VERSION_2 = 2;	
84
	int MINOR_VERSION_2 = 2;
85
	int MINOR_VERSION_3 = 3;	
85
	int MINOR_VERSION_3 = 3;
86
	
86
	int MINOR_VERSION_4 = 4;
87
87
	// JDK 1.1 -> 1.7, comparable value allowing to check both major/minor version at once 1.4.1 > 1.4.0
88
	// JDK 1.1 -> 1.7, comparable value allowing to check both major/minor version at once 1.4.1 > 1.4.0
88
	// 16 unsigned bits for major, then 16 bits for minor
89
	// 16 unsigned bits for major, then 16 bits for minor
89
	long JDK1_1 = ((long)ClassFileConstants.MAJOR_VERSION_1_1 << 16) + ClassFileConstants.MINOR_VERSION_3; // 1.1. is 45.3
90
	long JDK1_1 = ((long)ClassFileConstants.MAJOR_VERSION_1_1 << 16) + ClassFileConstants.MINOR_VERSION_3; // 1.1. is 45.3
Lines 93-103 Link Here
93
	long JDK1_5 = ((long)ClassFileConstants.MAJOR_VERSION_1_5 << 16) + ClassFileConstants.MINOR_VERSION_0;	
94
	long JDK1_5 = ((long)ClassFileConstants.MAJOR_VERSION_1_5 << 16) + ClassFileConstants.MINOR_VERSION_0;	
94
	long JDK1_6 = ((long)ClassFileConstants.MAJOR_VERSION_1_6 << 16) + ClassFileConstants.MINOR_VERSION_0;	
95
	long JDK1_6 = ((long)ClassFileConstants.MAJOR_VERSION_1_6 << 16) + ClassFileConstants.MINOR_VERSION_0;	
95
	long JDK1_7 = ((long)ClassFileConstants.MAJOR_VERSION_1_7 << 16) + ClassFileConstants.MINOR_VERSION_0;	
96
	long JDK1_7 = ((long)ClassFileConstants.MAJOR_VERSION_1_7 << 16) + ClassFileConstants.MINOR_VERSION_0;	
96
	
97
98
	/*
99
	 * cldc1.1 is 45.3, but we modify it to be different from JDK1_1.
100
	 * In the code gen, we will generate the same target value as JDK1_1
101
	 */ 
102
	long CLDC_1_1 = ((long)ClassFileConstants.MAJOR_VERSION_1_1 << 16) + ClassFileConstants.MINOR_VERSION_4;
103
97
	// jdk level used to denote future releases: optional behavior is not enabled for now, but may become so. In order to enable these,
104
	// jdk level used to denote future releases: optional behavior is not enabled for now, but may become so. In order to enable these,
98
	// search for references to this constant, and change it to one of the official JDT constants above.
105
	// search for references to this constant, and change it to one of the official JDT constants above.
99
	long JDK_DEFERRED = Long.MAX_VALUE;
106
	long JDK_DEFERRED = Long.MAX_VALUE;
100
	
107
101
	int INT_ARRAY = 10;
108
	int INT_ARRAY = 10;
102
	int BYTE_ARRAY = 8;
109
	int BYTE_ARRAY = 8;
103
	int BOOLEAN_ARRAY = 4;
110
	int BOOLEAN_ARRAY = 4;
Lines 106-115 Link Here
106
	int LONG_ARRAY = 11;
113
	int LONG_ARRAY = 11;
107
	int FLOAT_ARRAY = 6;
114
	int FLOAT_ARRAY = 6;
108
	int DOUBLE_ARRAY = 7;
115
	int DOUBLE_ARRAY = 7;
109
	
116
110
	// Debug attributes
117
	// Debug attributes
111
	int ATTR_SOURCE = 1; // SourceFileAttribute
118
	int ATTR_SOURCE = 0x1; // SourceFileAttribute
112
	int ATTR_LINES = 2; // LineNumberAttribute
119
	int ATTR_LINES = 0x2; // LineNumberAttribute
113
	int ATTR_VARS = 4; // LocalVariableTableAttribute
120
	int ATTR_VARS = 0x4; // LocalVariableTableAttribute
114
	int ATTR_STACK_MAP = 8; // Stack map table attribute
121
	int ATTR_STACK_MAP_TABLE = 0x8; // Stack map table attribute
122
	int ATTR_STACK_MAP = 0x10; // Stack map attribute: cldc
115
}
123
}
(-)batch/org/eclipse/jdt/internal/compiler/batch/Main.java (-2 / +12 lines)
Lines 2636-2642 Link Here
2636
					this.options.put(
2636
					this.options.put(
2637
							CompilerOptions.OPTION_InlineJsr,
2637
							CompilerOptions.OPTION_InlineJsr,
2638
							CompilerOptions.ENABLED);
2638
							CompilerOptions.ENABLED);
2639
				    continue;
2639
					continue;
2640
				}
2640
				}
2641
				if (currentArg.startsWith("-g")) { //$NON-NLS-1$
2641
				if (currentArg.startsWith("-g")) { //$NON-NLS-1$
2642
					mode = DEFAULT;
2642
					mode = DEFAULT;
Lines 2848-2854 Link Here
2848
					this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7);
2848
					this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_1_7);
2849
				} else if (currentArg.equals("jsr14")) { //$NON-NLS-1$
2849
				} else if (currentArg.equals("jsr14")) { //$NON-NLS-1$
2850
					this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_JSR14);
2850
					this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_JSR14);
2851
				} else {
2851
				} else if (currentArg.equals("cldc1.1")) { //$NON-NLS-1$
2852
					this.options.put(CompilerOptions.OPTION_TargetPlatform, CompilerOptions.VERSION_CLDC1_1);
2853
					this.options.put(CompilerOptions.OPTION_InlineJsr, CompilerOptions.ENABLED);
2854
				}else {
2852
					throw new InvalidInputException(this.bind("configure.targetJDK", currentArg)); //$NON-NLS-1$
2855
					throw new InvalidInputException(this.bind("configure.targetJDK", currentArg)); //$NON-NLS-1$
2853
				}
2856
				}
2854
				mode = DEFAULT;
2857
				mode = DEFAULT;
Lines 3976-3981 Link Here
3976
			if (CompilerOptions.versionToJdkLevel(sourceVersion) < ClassFileConstants.JDK1_5) {
3979
			if (CompilerOptions.versionToJdkLevel(sourceVersion) < ClassFileConstants.JDK1_5) {
3977
				throw new InvalidInputException(this.bind("configure.incompatibleTargetForGenericSource", (String) targetVersion, (String) sourceVersion)); //$NON-NLS-1$
3980
				throw new InvalidInputException(this.bind("configure.incompatibleTargetForGenericSource", (String) targetVersion, (String) sourceVersion)); //$NON-NLS-1$
3978
			}
3981
			}
3982
		} else if (CompilerOptions.VERSION_CLDC1_1.equals(targetVersion)) {
3983
			if (this.didSpecifySource && CompilerOptions.versionToJdkLevel(sourceVersion) >= ClassFileConstants.JDK1_4) {
3984
				throw new InvalidInputException(this.bind("configure.incompatibleSourceForCldcTarget", (String) targetVersion, (String) sourceVersion)); //$NON-NLS-1$
3985
			}
3986
			if (CompilerOptions.versionToJdkLevel(compliance) >= ClassFileConstants.JDK1_5) {
3987
				throw new InvalidInputException(this.bind("configure.incompatibleComplianceForCldcTarget", (String) targetVersion, (String) sourceVersion)); //$NON-NLS-1$
3988
			}
3979
		} else {
3989
		} else {
3980
			// target must be 1.7 if source is 1.7
3990
			// target must be 1.7 if source is 1.7
3981
			if (CompilerOptions.versionToJdkLevel(sourceVersion) >= ClassFileConstants.JDK1_7
3991
			if (CompilerOptions.versionToJdkLevel(sourceVersion) >= ClassFileConstants.JDK1_7
(-)batch/org/eclipse/jdt/internal/compiler/batch/messages.properties (-1 / +5 lines)
Lines 52-58 Link Here
52
configure.invalidWarningConfiguration = invalid warning configuration: {0}
52
configure.invalidWarningConfiguration = invalid warning configuration: {0}
53
configure.invalidWarning = invalid warning: {0}
53
configure.invalidWarning = invalid warning: {0}
54
configure.invalidWarningOption = invalid warning option: {0}
54
configure.invalidWarningOption = invalid warning option: {0}
55
configure.targetJDK = target level should be comprised in between ''1.1'' and ''1.7'' (or ''5'', ''5.0'', ..., ''7'' or ''7.0''): {0}
55
configure.targetJDK = target level should be comprised in between ''1.1'' and ''1.7'' (or ''5'', ''5.0'', ..., ''7'' or ''7.0'') or cldc1.1: {0}
56
configure.incompatibleTargetForSource = Target level ''{0}'' is incompatible with source level ''{1}''. A target level ''{1}'' or better is required
56
configure.incompatibleTargetForSource = Target level ''{0}'' is incompatible with source level ''{1}''. A target level ''{1}'' or better is required
57
configure.incompatibleTargetForGenericSource = Target level ''{0}'' is incompatible with source level ''{1}''. A source level ''1.5'' or better is required
57
configure.incompatibleTargetForGenericSource = Target level ''{0}'' is incompatible with source level ''{1}''. A source level ''1.5'' or better is required
58
configure.incompatibleComplianceForSource = Compliance level ''{0}'' is incompatible with source level ''{1}''. A compliance level ''{1}'' or better is required
58
configure.incompatibleComplianceForSource = Compliance level ''{0}'' is incompatible with source level ''{1}''. A compliance level ''{1}'' or better is required
Lines 80-85 Link Here
80
configure.duplicateDestinationPathEntry = duplicate destination path entry in {0} option
80
configure.duplicateDestinationPathEntry = duplicate destination path entry in {0} option
81
configure.invalidClassName = invalid class name: {0}
81
configure.invalidClassName = invalid class name: {0}
82
configure.incorrectVMVersionforAPT = Annotation processing got disabled, since it requires a 1.6 compliant JVM
82
configure.incorrectVMVersionforAPT = Annotation processing got disabled, since it requires a 1.6 compliant JVM
83
configure.incompatibleSourceForCldcTarget=Target level ''{0}'' is incompatible with source level ''{1}''. A source level ''1.3'' or lower is required
84
configure.incompatibleComplianceForCldcTarget=Target level ''{0}'' is incompatible with compliance level ''{1}''. A compliance level ''1.4''or lower is required
83
85
84
### requestor
86
### requestor
85
requestor.error = {0}. ERROR in {1}
87
requestor.error = {0}. ERROR in {1}
Lines 150-155 Link Here
150
\    -1.7 -7 -7.0       use 1.7 compliance (-source 1.7 -target 1.7)\n\
152
\    -1.7 -7 -7.0       use 1.7 compliance (-source 1.7 -target 1.7)\n\
151
\    -source <version>  set source level: 1.3 to 1.7 (or 5, 5.0, etc)\n\
153
\    -source <version>  set source level: 1.3 to 1.7 (or 5, 5.0, etc)\n\
152
\    -target <version>  set classfile target: 1.1 to 1.7 (or 5, 5.0, etc)\n\
154
\    -target <version>  set classfile target: 1.1 to 1.7 (or 5, 5.0, etc)\n\
155
\                       cldc1.1 can also be used to generate the StackMap\n\
156
\                       attribute\n\
153
\ \n\
157
\ \n\
154
\ Warning options:\n\
158
\ Warning options:\n\
155
\    -deprecation     + deprecation outside deprecated code (equivalent to\n\
159
\    -deprecation     + deprecation outside deprecated code (equivalent to\n\
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetClassFile.java (+4 lines)
Lines 113-119 Link Here
113
	this.creatingProblemType = creatingProblemType;
113
	this.creatingProblemType = creatingProblemType;
114
	if (this.targetJDK >= ClassFileConstants.JDK1_6) {
114
	if (this.targetJDK >= ClassFileConstants.JDK1_6) {
115
		this.codeStream = new StackMapFrameCodeStream(this);
115
		this.codeStream = new StackMapFrameCodeStream(this);
116
		this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP_TABLE;
117
	} else if (this.targetJDK == ClassFileConstants.CLDC_1_1) {
118
		this.targetJDK = ClassFileConstants.JDK1_1; // put back 45.3
116
		this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP;
119
		this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP;
120
		this.codeStream = new StackMapFrameCodeStream(this);
117
	} else {
121
	} else {
118
		this.codeStream = new CodeStream(this);
122
		this.codeStream = new CodeStream(this);
119
	}
123
	}
(-)compiler/org/eclipse/jdt/internal/compiler/impl/CompilerOptions.java (+4 lines)
Lines 132-137 Link Here
132
	public static final String VERSION_1_3 = "1.3"; //$NON-NLS-1$
132
	public static final String VERSION_1_3 = "1.3"; //$NON-NLS-1$
133
	public static final String VERSION_1_4 = "1.4"; //$NON-NLS-1$
133
	public static final String VERSION_1_4 = "1.4"; //$NON-NLS-1$
134
	public static final String VERSION_JSR14 = "jsr14"; //$NON-NLS-1$
134
	public static final String VERSION_JSR14 = "jsr14"; //$NON-NLS-1$
135
	public static final String VERSION_CLDC1_1 = "cldc1.1"; //$NON-NLS-1$
135
	public static final String VERSION_1_5 = "1.5"; //$NON-NLS-1$
136
	public static final String VERSION_1_5 = "1.5"; //$NON-NLS-1$
136
	public static final String VERSION_1_6 = "1.6"; //$NON-NLS-1$
137
	public static final String VERSION_1_6 = "1.6"; //$NON-NLS-1$
137
	public static final String VERSION_1_7 = "1.7"; //$NON-NLS-1$
138
	public static final String VERSION_1_7 = "1.7"; //$NON-NLS-1$
Lines 1063-1068 Link Here
1063
			if (VERSION_JSR14.equals(versionID)) {
1064
			if (VERSION_JSR14.equals(versionID)) {
1064
				return ClassFileConstants.JDK1_4;
1065
				return ClassFileConstants.JDK1_4;
1065
			}
1066
			}
1067
			if (VERSION_CLDC1_1.equals(versionID)) {
1068
				return ClassFileConstants.CLDC_1_1;
1069
			}
1066
		}
1070
		}
1067
		return 0; // unknown
1071
		return 0; // unknown
1068
	}
1072
	}
(-)compiler/org/eclipse/jdt/internal/compiler/ClassFile.java (-7 / +1022 lines)
Lines 412-417 Link Here
412
		this.produceAttributes = options.produceDebugAttributes;
412
		this.produceAttributes = options.produceDebugAttributes;
413
		this.referenceBinding = typeBinding;
413
		this.referenceBinding = typeBinding;
414
		if (this.targetJDK >= ClassFileConstants.JDK1_6) {
414
		if (this.targetJDK >= ClassFileConstants.JDK1_6) {
415
			this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP_TABLE;
416
			this.codeStream = new StackMapFrameCodeStream(this);
417
		} else if (this.targetJDK == ClassFileConstants.CLDC_1_1) {
418
			this.targetJDK = ClassFileConstants.JDK1_1; // put back 45.3
415
			this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP;
419
			this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP;
416
			this.codeStream = new StackMapFrameCodeStream(this);
420
			this.codeStream = new StackMapFrameCodeStream(this);
417
		} else {
421
		} else {
Lines 1484-1490 Link Here
1484
		this.contents[codeAttributeOffset + 12] = (byte) (code_length >> 8);
1488
		this.contents[codeAttributeOffset + 12] = (byte) (code_length >> 8);
1485
		this.contents[codeAttributeOffset + 13] = (byte) code_length;
1489
		this.contents[codeAttributeOffset + 13] = (byte) code_length;
1486
1490
1487
		boolean addStackMaps = (this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0;
1491
		boolean addStackMaps = (this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP_TABLE) != 0;
1488
		// write the exception table
1492
		// write the exception table
1489
		ExceptionLabel[] exceptionLabels = codeStream.exceptionLabels;
1493
		ExceptionLabel[] exceptionLabels = codeStream.exceptionLabels;
1490
		int exceptionHandlersCount = 0; // each label holds one handler per range (start/end contiguous)
1494
		int exceptionHandlersCount = 0; // each label holds one handler per range (start/end contiguous)
Lines 2111-2116 Link Here
2111
			}
2115
			}
2112
		}
2116
		}
2113
2117
2118
		if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) {
2119
			StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream;
2120
			stackMapFrameCodeStream.removeFramePosition(code_length);
2121
			if (stackMapFrameCodeStream.hasFramePositions()) {
2122
				ArrayList frames = new ArrayList();
2123
				traverse(this.codeStream.methodDeclaration.binding, max_locals, this.contents, codeAttributeOffset + 14, code_length, frames, false);
2124
				int numberOfFrames = frames.size();
2125
				if (numberOfFrames > 1) {
2126
					int stackMapTableAttributeOffset = localContentsOffset;
2127
					// add the stack map table attribute
2128
					if (localContentsOffset + 8 >= this.contents.length) {
2129
						resizeContents(8);
2130
					}
2131
					int stackMapAttributeNameIndex =
2132
						constantPool.literalIndex(AttributeNamesConstants.StackMapName);
2133
					this.contents[localContentsOffset++] = (byte) (stackMapAttributeNameIndex >> 8);
2134
					this.contents[localContentsOffset++] = (byte) stackMapAttributeNameIndex;
2135
2136
					int stackMapAttributeLengthOffset = localContentsOffset;
2137
					// generate the attribute
2138
					localContentsOffset += 4;
2139
					if (localContentsOffset + 4 >= this.contents.length) {
2140
						resizeContents(4);
2141
					}
2142
					int numberOfFramesOffset = localContentsOffset;
2143
					localContentsOffset += 2;
2144
					if (localContentsOffset + 2 >= this.contents.length) {
2145
						resizeContents(2);
2146
					}
2147
					StackMapFrame currentFrame = (StackMapFrame) frames.get(0);
2148
					for (int j = 1; j < numberOfFrames; j++) {
2149
						// select next frame
2150
						currentFrame = (StackMapFrame) frames.get(j);
2151
						// generate current frame
2152
						// need to find differences between the current frame and the previous frame
2153
						int frameOffset = currentFrame.pc;
2154
						// FULL_FRAME
2155
						if (localContentsOffset + 5 >= this.contents.length) {
2156
							resizeContents(5);
2157
						}
2158
						this.contents[localContentsOffset++] = (byte) (frameOffset >> 8);
2159
						this.contents[localContentsOffset++] = (byte) frameOffset;
2160
						int numberOfLocalOffset = localContentsOffset;
2161
						localContentsOffset += 2; // leave two spots for number of locals
2162
						int numberOfLocalEntries = 0;
2163
						int numberOfLocals = currentFrame.getNumberOfLocals();
2164
						int numberOfEntries = 0;
2165
						int localsLength = currentFrame.locals == null ? 0 : currentFrame.locals.length;
2166
						for (int i = 0; i < localsLength && numberOfLocalEntries < numberOfLocals; i++) {
2167
							if (localContentsOffset + 3 >= this.contents.length) {
2168
								resizeContents(3);
2169
							}
2170
							VerificationTypeInfo info = currentFrame.locals[i];
2171
							if (info == null) {
2172
								this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_TOP;
2173
							} else {
2174
								switch(info.id()) {
2175
									case T_boolean :
2176
									case T_byte :
2177
									case T_char :
2178
									case T_int :
2179
									case T_short :
2180
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_INTEGER;
2181
										break;
2182
									case T_float :
2183
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_FLOAT;
2184
										break;
2185
									case T_long :
2186
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_LONG;
2187
										i++;
2188
										break;
2189
									case T_double :
2190
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_DOUBLE;
2191
										i++;
2192
										break;
2193
									case T_null :
2194
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_NULL;
2195
										break;
2196
									default:
2197
										this.contents[localContentsOffset++] = (byte) info.tag;
2198
									switch (info.tag) {
2199
										case VerificationTypeInfo.ITEM_UNINITIALIZED :
2200
											int offset = info.offset;
2201
											this.contents[localContentsOffset++] = (byte) (offset >> 8);
2202
											this.contents[localContentsOffset++] = (byte) offset;
2203
											break;
2204
										case VerificationTypeInfo.ITEM_OBJECT :
2205
											int indexForType = constantPool.literalIndexForType(info.constantPoolName());
2206
											this.contents[localContentsOffset++] = (byte) (indexForType >> 8);
2207
											this.contents[localContentsOffset++] = (byte) indexForType;
2208
									}
2209
								}
2210
								numberOfLocalEntries++;
2211
							}
2212
							numberOfEntries++;
2213
						}
2214
						if (localContentsOffset + 4 >= this.contents.length) {
2215
							resizeContents(4);
2216
						}
2217
						this.contents[numberOfLocalOffset++] = (byte) (numberOfEntries >> 8);
2218
						this.contents[numberOfLocalOffset] = (byte) numberOfEntries;
2219
						int numberOfStackItems = currentFrame.numberOfStackItems;
2220
						this.contents[localContentsOffset++] = (byte) (numberOfStackItems >> 8);
2221
						this.contents[localContentsOffset++] = (byte) numberOfStackItems;
2222
						for (int i = 0; i < numberOfStackItems; i++) {
2223
							if (localContentsOffset + 3 >= this.contents.length) {
2224
								resizeContents(3);
2225
							}
2226
							VerificationTypeInfo info = currentFrame.stackItems[i];
2227
							if (info == null) {
2228
								this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_TOP;
2229
							} else {
2230
								switch(info.id()) {
2231
									case T_boolean :
2232
									case T_byte :
2233
									case T_char :
2234
									case T_int :
2235
									case T_short :
2236
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_INTEGER;
2237
										break;
2238
									case T_float :
2239
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_FLOAT;
2240
										break;
2241
									case T_long :
2242
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_LONG;
2243
										break;
2244
									case T_double :
2245
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_DOUBLE;
2246
										break;
2247
									case T_null :
2248
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_NULL;
2249
										break;
2250
									default:
2251
										this.contents[localContentsOffset++] = (byte) info.tag;
2252
									switch (info.tag) {
2253
										case VerificationTypeInfo.ITEM_UNINITIALIZED :
2254
											int offset = info.offset;
2255
											this.contents[localContentsOffset++] = (byte) (offset >> 8);
2256
											this.contents[localContentsOffset++] = (byte) offset;
2257
											break;
2258
										case VerificationTypeInfo.ITEM_OBJECT :
2259
											int indexForType = constantPool.literalIndexForType(info.constantPoolName());
2260
											this.contents[localContentsOffset++] = (byte) (indexForType >> 8);
2261
											this.contents[localContentsOffset++] = (byte) indexForType;
2262
									}
2263
								}
2264
							}
2265
						}
2266
					}
2267
2268
					numberOfFrames--;
2269
					if (numberOfFrames != 0) {
2270
						this.contents[numberOfFramesOffset++] = (byte) (numberOfFrames >> 8);
2271
						this.contents[numberOfFramesOffset] = (byte) numberOfFrames;
2272
2273
						int attributeLength = localContentsOffset - stackMapAttributeLengthOffset - 4;
2274
						this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 24);
2275
						this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 16);
2276
						this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 8);
2277
						this.contents[stackMapAttributeLengthOffset] = (byte) attributeLength;
2278
						attributeNumber++;
2279
					} else {
2280
						localContentsOffset = stackMapTableAttributeOffset;
2281
					}
2282
				}
2283
			}
2284
		}
2285
2114
		this.contents[codeAttributeAttributeOffset++] = (byte) (attributeNumber >> 8);
2286
		this.contents[codeAttributeAttributeOffset++] = (byte) (attributeNumber >> 8);
2115
		this.contents[codeAttributeAttributeOffset] = (byte) attributeNumber;
2287
		this.contents[codeAttributeAttributeOffset] = (byte) attributeNumber;
2116
2288
Lines 2162-2168 Link Here
2162
		this.contents[codeAttributeOffset + 12] = (byte) (code_length >> 8);
2334
		this.contents[codeAttributeOffset + 12] = (byte) (code_length >> 8);
2163
		this.contents[codeAttributeOffset + 13] = (byte) code_length;
2335
		this.contents[codeAttributeOffset + 13] = (byte) code_length;
2164
2336
2165
		boolean addStackMaps = (this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0;
2337
		boolean addStackMaps = (this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP_TABLE) != 0;
2166
		// write the exception table
2338
		// write the exception table
2167
		ExceptionLabel[] exceptionLabels = codeStream.exceptionLabels;
2339
		ExceptionLabel[] exceptionLabels = codeStream.exceptionLabels;
2168
		int exceptionHandlersCount = 0; // each label holds one handler per range (start/end contiguous)
2340
		int exceptionHandlersCount = 0; // each label holds one handler per range (start/end contiguous)
Lines 2403-2409 Link Here
2403
			}
2575
			}
2404
		}
2576
		}
2405
2577
2406
		if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) {
2578
		if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP_TABLE) != 0) {
2407
			StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream;
2579
			StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream;
2408
			stackMapFrameCodeStream.removeFramePosition(code_length);
2580
			stackMapFrameCodeStream.removeFramePosition(code_length);
2409
			if (stackMapFrameCodeStream.hasFramePositions()) {
2581
			if (stackMapFrameCodeStream.hasFramePositions()) {
Lines 2752-2757 Link Here
2752
			}
2924
			}
2753
		}
2925
		}
2754
2926
2927
		if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) {
2928
			StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream;
2929
			stackMapFrameCodeStream.removeFramePosition(code_length);
2930
			if (stackMapFrameCodeStream.hasFramePositions()) {
2931
				ArrayList frames = new ArrayList();
2932
				traverse(this.codeStream.methodDeclaration.binding, max_locals, this.contents, codeAttributeOffset + 14, code_length, frames, false);
2933
				int numberOfFrames = frames.size();
2934
				if (numberOfFrames > 1) {
2935
					int stackMapTableAttributeOffset = localContentsOffset;
2936
					// add the stack map table attribute
2937
					if (localContentsOffset + 8 >= this.contents.length) {
2938
						resizeContents(8);
2939
					}
2940
					int stackMapAttributeNameIndex =
2941
						constantPool.literalIndex(AttributeNamesConstants.StackMapName);
2942
					this.contents[localContentsOffset++] = (byte) (stackMapAttributeNameIndex >> 8);
2943
					this.contents[localContentsOffset++] = (byte) stackMapAttributeNameIndex;
2944
2945
					int stackMapAttributeLengthOffset = localContentsOffset;
2946
					// generate the attribute
2947
					localContentsOffset += 4;
2948
					if (localContentsOffset + 4 >= this.contents.length) {
2949
						resizeContents(4);
2950
					}
2951
					int numberOfFramesOffset = localContentsOffset;
2952
					localContentsOffset += 2;
2953
					if (localContentsOffset + 2 >= this.contents.length) {
2954
						resizeContents(2);
2955
					}
2956
					StackMapFrame currentFrame = (StackMapFrame) frames.get(0);
2957
					for (int j = 1; j < numberOfFrames; j++) {
2958
						// select next frame
2959
						currentFrame = (StackMapFrame) frames.get(j);
2960
						// generate current frame
2961
						// need to find differences between the current frame and the previous frame
2962
						int frameOffset = currentFrame.pc;
2963
						// FULL_FRAME
2964
						if (localContentsOffset + 5 >= this.contents.length) {
2965
							resizeContents(5);
2966
						}
2967
						this.contents[localContentsOffset++] = (byte) (frameOffset >> 8);
2968
						this.contents[localContentsOffset++] = (byte) frameOffset;
2969
						int numberOfLocalOffset = localContentsOffset;
2970
						localContentsOffset += 2; // leave two spots for number of locals
2971
						int numberOfLocalEntries = 0;
2972
						int numberOfLocals = currentFrame.getNumberOfLocals();
2973
						int numberOfEntries = 0;
2974
						int localsLength = currentFrame.locals == null ? 0 : currentFrame.locals.length;
2975
						for (int i = 0; i < localsLength && numberOfLocalEntries < numberOfLocals; i++) {
2976
							if (localContentsOffset + 3 >= this.contents.length) {
2977
								resizeContents(3);
2978
							}
2979
							VerificationTypeInfo info = currentFrame.locals[i];
2980
							if (info == null) {
2981
								this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_TOP;
2982
							} else {
2983
								switch(info.id()) {
2984
									case T_boolean :
2985
									case T_byte :
2986
									case T_char :
2987
									case T_int :
2988
									case T_short :
2989
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_INTEGER;
2990
										break;
2991
									case T_float :
2992
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_FLOAT;
2993
										break;
2994
									case T_long :
2995
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_LONG;
2996
										i++;
2997
										break;
2998
									case T_double :
2999
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_DOUBLE;
3000
										i++;
3001
										break;
3002
									case T_null :
3003
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_NULL;
3004
										break;
3005
									default:
3006
										this.contents[localContentsOffset++] = (byte) info.tag;
3007
									switch (info.tag) {
3008
										case VerificationTypeInfo.ITEM_UNINITIALIZED :
3009
											int offset = info.offset;
3010
											this.contents[localContentsOffset++] = (byte) (offset >> 8);
3011
											this.contents[localContentsOffset++] = (byte) offset;
3012
											break;
3013
										case VerificationTypeInfo.ITEM_OBJECT :
3014
											int indexForType = constantPool.literalIndexForType(info.constantPoolName());
3015
											this.contents[localContentsOffset++] = (byte) (indexForType >> 8);
3016
											this.contents[localContentsOffset++] = (byte) indexForType;
3017
									}
3018
								}
3019
								numberOfLocalEntries++;
3020
							}
3021
							numberOfEntries++;
3022
						}
3023
						if (localContentsOffset + 4 >= this.contents.length) {
3024
							resizeContents(4);
3025
						}
3026
						this.contents[numberOfLocalOffset++] = (byte) (numberOfEntries >> 8);
3027
						this.contents[numberOfLocalOffset] = (byte) numberOfEntries;
3028
						int numberOfStackItems = currentFrame.numberOfStackItems;
3029
						this.contents[localContentsOffset++] = (byte) (numberOfStackItems >> 8);
3030
						this.contents[localContentsOffset++] = (byte) numberOfStackItems;
3031
						for (int i = 0; i < numberOfStackItems; i++) {
3032
							if (localContentsOffset + 3 >= this.contents.length) {
3033
								resizeContents(3);
3034
							}
3035
							VerificationTypeInfo info = currentFrame.stackItems[i];
3036
							if (info == null) {
3037
								this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_TOP;
3038
							} else {
3039
								switch(info.id()) {
3040
									case T_boolean :
3041
									case T_byte :
3042
									case T_char :
3043
									case T_int :
3044
									case T_short :
3045
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_INTEGER;
3046
										break;
3047
									case T_float :
3048
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_FLOAT;
3049
										break;
3050
									case T_long :
3051
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_LONG;
3052
										break;
3053
									case T_double :
3054
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_DOUBLE;
3055
										break;
3056
									case T_null :
3057
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_NULL;
3058
										break;
3059
									default:
3060
										this.contents[localContentsOffset++] = (byte) info.tag;
3061
									switch (info.tag) {
3062
										case VerificationTypeInfo.ITEM_UNINITIALIZED :
3063
											int offset = info.offset;
3064
											this.contents[localContentsOffset++] = (byte) (offset >> 8);
3065
											this.contents[localContentsOffset++] = (byte) offset;
3066
											break;
3067
										case VerificationTypeInfo.ITEM_OBJECT :
3068
											int indexForType = constantPool.literalIndexForType(info.constantPoolName());
3069
											this.contents[localContentsOffset++] = (byte) (indexForType >> 8);
3070
											this.contents[localContentsOffset++] = (byte) indexForType;
3071
									}
3072
								}
3073
							}
3074
						}
3075
					}
3076
3077
					numberOfFrames--;
3078
					if (numberOfFrames != 0) {
3079
						this.contents[numberOfFramesOffset++] = (byte) (numberOfFrames >> 8);
3080
						this.contents[numberOfFramesOffset] = (byte) numberOfFrames;
3081
3082
						int attributeLength = localContentsOffset - stackMapAttributeLengthOffset - 4;
3083
						this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 24);
3084
						this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 16);
3085
						this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 8);
3086
						this.contents[stackMapAttributeLengthOffset] = (byte) attributeLength;
3087
						attributeNumber++;
3088
					} else {
3089
						localContentsOffset = stackMapTableAttributeOffset;
3090
					}
3091
				}
3092
			}
3093
		}
3094
2755
		// update the number of attributes
3095
		// update the number of attributes
2756
		// ensure first that there is enough space available inside the contents array
3096
		// ensure first that there is enough space available inside the contents array
2757
		if (codeAttributeAttributeOffset + 2 >= this.contents.length) {
3097
		if (codeAttributeAttributeOffset + 2 >= this.contents.length) {
Lines 2866-2872 Link Here
2866
			attributeNumber++;
3206
			attributeNumber++;
2867
		}
3207
		}
2868
3208
2869
		if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) {
3209
		if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP_TABLE) != 0) {
2870
			StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream;
3210
			StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream;
2871
			stackMapFrameCodeStream.removeFramePosition(code_length);
3211
			stackMapFrameCodeStream.removeFramePosition(code_length);
2872
			if (stackMapFrameCodeStream.hasFramePositions()) {
3212
			if (stackMapFrameCodeStream.hasFramePositions()) {
Lines 3216-3221 Link Here
3216
			}
3556
			}
3217
		}
3557
		}
3218
3558
3559
		if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) {
3560
			StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream;
3561
			stackMapFrameCodeStream.removeFramePosition(code_length);
3562
			if (stackMapFrameCodeStream.hasFramePositions()) {
3563
				ArrayList frames = new ArrayList();
3564
				traverse(this.codeStream.methodDeclaration.binding, max_locals, this.contents, codeAttributeOffset + 14, code_length, frames, false);
3565
				int numberOfFrames = frames.size();
3566
				if (numberOfFrames > 1) {
3567
					int stackMapTableAttributeOffset = localContentsOffset;
3568
					// add the stack map table attribute
3569
					if (localContentsOffset + 8 >= this.contents.length) {
3570
						resizeContents(8);
3571
					}
3572
					int stackMapAttributeNameIndex =
3573
						constantPool.literalIndex(AttributeNamesConstants.StackMapName);
3574
					this.contents[localContentsOffset++] = (byte) (stackMapAttributeNameIndex >> 8);
3575
					this.contents[localContentsOffset++] = (byte) stackMapAttributeNameIndex;
3576
3577
					int stackMapAttributeLengthOffset = localContentsOffset;
3578
					// generate the attribute
3579
					localContentsOffset += 4;
3580
					if (localContentsOffset + 4 >= this.contents.length) {
3581
						resizeContents(4);
3582
					}
3583
					int numberOfFramesOffset = localContentsOffset;
3584
					localContentsOffset += 2;
3585
					if (localContentsOffset + 2 >= this.contents.length) {
3586
						resizeContents(2);
3587
					}
3588
					StackMapFrame currentFrame = (StackMapFrame) frames.get(0);
3589
					for (int j = 1; j < numberOfFrames; j++) {
3590
						// select next frame
3591
						currentFrame = (StackMapFrame) frames.get(j);
3592
						// generate current frame
3593
						// need to find differences between the current frame and the previous frame
3594
						int frameOffset = currentFrame.pc;
3595
						// FULL_FRAME
3596
						if (localContentsOffset + 5 >= this.contents.length) {
3597
							resizeContents(5);
3598
						}
3599
						this.contents[localContentsOffset++] = (byte) (frameOffset >> 8);
3600
						this.contents[localContentsOffset++] = (byte) frameOffset;
3601
						int numberOfLocalOffset = localContentsOffset;
3602
						localContentsOffset += 2; // leave two spots for number of locals
3603
						int numberOfLocalEntries = 0;
3604
						int numberOfLocals = currentFrame.getNumberOfLocals();
3605
						int numberOfEntries = 0;
3606
						int localsLength = currentFrame.locals == null ? 0 : currentFrame.locals.length;
3607
						for (int i = 0; i < localsLength && numberOfLocalEntries < numberOfLocals; i++) {
3608
							if (localContentsOffset + 3 >= this.contents.length) {
3609
								resizeContents(3);
3610
							}
3611
							VerificationTypeInfo info = currentFrame.locals[i];
3612
							if (info == null) {
3613
								this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_TOP;
3614
							} else {
3615
								switch(info.id()) {
3616
									case T_boolean :
3617
									case T_byte :
3618
									case T_char :
3619
									case T_int :
3620
									case T_short :
3621
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_INTEGER;
3622
										break;
3623
									case T_float :
3624
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_FLOAT;
3625
										break;
3626
									case T_long :
3627
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_LONG;
3628
										i++;
3629
										break;
3630
									case T_double :
3631
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_DOUBLE;
3632
										i++;
3633
										break;
3634
									case T_null :
3635
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_NULL;
3636
										break;
3637
									default:
3638
										this.contents[localContentsOffset++] = (byte) info.tag;
3639
									switch (info.tag) {
3640
										case VerificationTypeInfo.ITEM_UNINITIALIZED :
3641
											int offset = info.offset;
3642
											this.contents[localContentsOffset++] = (byte) (offset >> 8);
3643
											this.contents[localContentsOffset++] = (byte) offset;
3644
											break;
3645
										case VerificationTypeInfo.ITEM_OBJECT :
3646
											int indexForType = constantPool.literalIndexForType(info.constantPoolName());
3647
											this.contents[localContentsOffset++] = (byte) (indexForType >> 8);
3648
											this.contents[localContentsOffset++] = (byte) indexForType;
3649
									}
3650
								}
3651
								numberOfLocalEntries++;
3652
							}
3653
							numberOfEntries++;
3654
						}
3655
						if (localContentsOffset + 4 >= this.contents.length) {
3656
							resizeContents(4);
3657
						}
3658
						this.contents[numberOfLocalOffset++] = (byte) (numberOfEntries >> 8);
3659
						this.contents[numberOfLocalOffset] = (byte) numberOfEntries;
3660
						int numberOfStackItems = currentFrame.numberOfStackItems;
3661
						this.contents[localContentsOffset++] = (byte) (numberOfStackItems >> 8);
3662
						this.contents[localContentsOffset++] = (byte) numberOfStackItems;
3663
						for (int i = 0; i < numberOfStackItems; i++) {
3664
							if (localContentsOffset + 3 >= this.contents.length) {
3665
								resizeContents(3);
3666
							}
3667
							VerificationTypeInfo info = currentFrame.stackItems[i];
3668
							if (info == null) {
3669
								this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_TOP;
3670
							} else {
3671
								switch(info.id()) {
3672
									case T_boolean :
3673
									case T_byte :
3674
									case T_char :
3675
									case T_int :
3676
									case T_short :
3677
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_INTEGER;
3678
										break;
3679
									case T_float :
3680
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_FLOAT;
3681
										break;
3682
									case T_long :
3683
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_LONG;
3684
										break;
3685
									case T_double :
3686
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_DOUBLE;
3687
										break;
3688
									case T_null :
3689
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_NULL;
3690
										break;
3691
									default:
3692
										this.contents[localContentsOffset++] = (byte) info.tag;
3693
									switch (info.tag) {
3694
										case VerificationTypeInfo.ITEM_UNINITIALIZED :
3695
											int offset = info.offset;
3696
											this.contents[localContentsOffset++] = (byte) (offset >> 8);
3697
											this.contents[localContentsOffset++] = (byte) offset;
3698
											break;
3699
										case VerificationTypeInfo.ITEM_OBJECT :
3700
											int indexForType = constantPool.literalIndexForType(info.constantPoolName());
3701
											this.contents[localContentsOffset++] = (byte) (indexForType >> 8);
3702
											this.contents[localContentsOffset++] = (byte) indexForType;
3703
									}
3704
								}
3705
							}
3706
						}
3707
					}
3708
3709
					numberOfFrames--;
3710
					if (numberOfFrames != 0) {
3711
						this.contents[numberOfFramesOffset++] = (byte) (numberOfFrames >> 8);
3712
						this.contents[numberOfFramesOffset] = (byte) numberOfFrames;
3713
3714
						int attributeLength = localContentsOffset - stackMapAttributeLengthOffset - 4;
3715
						this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 24);
3716
						this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 16);
3717
						this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 8);
3718
						this.contents[stackMapAttributeLengthOffset] = (byte) attributeLength;
3719
						attributeNumber++;
3720
					} else {
3721
						localContentsOffset = stackMapTableAttributeOffset;
3722
					}
3723
				}
3724
			}
3725
		}
3726
3219
		// update the number of attributes
3727
		// update the number of attributes
3220
		// ensure first that there is enough space available inside the contents array
3728
		// ensure first that there is enough space available inside the contents array
3221
		if (codeAttributeAttributeOffset + 2 >= this.contents.length) {
3729
		if (codeAttributeAttributeOffset + 2 >= this.contents.length) {
Lines 3301-3307 Link Here
3301
			attributeNumber++;
3809
			attributeNumber++;
3302
		}
3810
		}
3303
3811
3304
		if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) {
3812
		if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP_TABLE) != 0) {
3305
			StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream;
3813
			StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream;
3306
			stackMapFrameCodeStream.removeFramePosition(code_length);
3814
			stackMapFrameCodeStream.removeFramePosition(code_length);
3307
			if (stackMapFrameCodeStream.hasFramePositions()) {
3815
			if (stackMapFrameCodeStream.hasFramePositions()) {
Lines 3651-3656 Link Here
3651
			}
4159
			}
3652
		}
4160
		}
3653
4161
4162
		if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) {
4163
			StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream;
4164
			stackMapFrameCodeStream.removeFramePosition(code_length);
4165
			if (stackMapFrameCodeStream.hasFramePositions()) {
4166
				ArrayList frames = new ArrayList();
4167
				traverse(this.codeStream.methodDeclaration.binding, max_locals, this.contents, codeAttributeOffset + 14, code_length, frames, false);
4168
				int numberOfFrames = frames.size();
4169
				if (numberOfFrames > 1) {
4170
					int stackMapTableAttributeOffset = localContentsOffset;
4171
					// add the stack map table attribute
4172
					if (localContentsOffset + 8 >= this.contents.length) {
4173
						resizeContents(8);
4174
					}
4175
					int stackMapAttributeNameIndex =
4176
						constantPool.literalIndex(AttributeNamesConstants.StackMapName);
4177
					this.contents[localContentsOffset++] = (byte) (stackMapAttributeNameIndex >> 8);
4178
					this.contents[localContentsOffset++] = (byte) stackMapAttributeNameIndex;
4179
4180
					int stackMapAttributeLengthOffset = localContentsOffset;
4181
					// generate the attribute
4182
					localContentsOffset += 4;
4183
					if (localContentsOffset + 4 >= this.contents.length) {
4184
						resizeContents(4);
4185
					}
4186
					int numberOfFramesOffset = localContentsOffset;
4187
					localContentsOffset += 2;
4188
					if (localContentsOffset + 2 >= this.contents.length) {
4189
						resizeContents(2);
4190
					}
4191
					StackMapFrame currentFrame = (StackMapFrame) frames.get(0);
4192
					for (int j = 1; j < numberOfFrames; j++) {
4193
						// select next frame
4194
						currentFrame = (StackMapFrame) frames.get(j);
4195
						// generate current frame
4196
						// need to find differences between the current frame and the previous frame
4197
						int frameOffset = currentFrame.pc;
4198
						// FULL_FRAME
4199
						if (localContentsOffset + 5 >= this.contents.length) {
4200
							resizeContents(5);
4201
						}
4202
						this.contents[localContentsOffset++] = (byte) (frameOffset >> 8);
4203
						this.contents[localContentsOffset++] = (byte) frameOffset;
4204
						int numberOfLocalOffset = localContentsOffset;
4205
						localContentsOffset += 2; // leave two spots for number of locals
4206
						int numberOfLocalEntries = 0;
4207
						int numberOfLocals = currentFrame.getNumberOfLocals();
4208
						int numberOfEntries = 0;
4209
						int localsLength = currentFrame.locals == null ? 0 : currentFrame.locals.length;
4210
						for (int i = 0; i < localsLength && numberOfLocalEntries < numberOfLocals; i++) {
4211
							if (localContentsOffset + 3 >= this.contents.length) {
4212
								resizeContents(3);
4213
							}
4214
							VerificationTypeInfo info = currentFrame.locals[i];
4215
							if (info == null) {
4216
								this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_TOP;
4217
							} else {
4218
								switch(info.id()) {
4219
									case T_boolean :
4220
									case T_byte :
4221
									case T_char :
4222
									case T_int :
4223
									case T_short :
4224
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_INTEGER;
4225
										break;
4226
									case T_float :
4227
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_FLOAT;
4228
										break;
4229
									case T_long :
4230
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_LONG;
4231
										i++;
4232
										break;
4233
									case T_double :
4234
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_DOUBLE;
4235
										i++;
4236
										break;
4237
									case T_null :
4238
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_NULL;
4239
										break;
4240
									default:
4241
										this.contents[localContentsOffset++] = (byte) info.tag;
4242
									switch (info.tag) {
4243
										case VerificationTypeInfo.ITEM_UNINITIALIZED :
4244
											int offset = info.offset;
4245
											this.contents[localContentsOffset++] = (byte) (offset >> 8);
4246
											this.contents[localContentsOffset++] = (byte) offset;
4247
											break;
4248
										case VerificationTypeInfo.ITEM_OBJECT :
4249
											int indexForType = constantPool.literalIndexForType(info.constantPoolName());
4250
											this.contents[localContentsOffset++] = (byte) (indexForType >> 8);
4251
											this.contents[localContentsOffset++] = (byte) indexForType;
4252
									}
4253
								}
4254
								numberOfLocalEntries++;
4255
							}
4256
							numberOfEntries++;
4257
						}
4258
						if (localContentsOffset + 4 >= this.contents.length) {
4259
							resizeContents(4);
4260
						}
4261
						this.contents[numberOfLocalOffset++] = (byte) (numberOfEntries >> 8);
4262
						this.contents[numberOfLocalOffset] = (byte) numberOfEntries;
4263
						int numberOfStackItems = currentFrame.numberOfStackItems;
4264
						this.contents[localContentsOffset++] = (byte) (numberOfStackItems >> 8);
4265
						this.contents[localContentsOffset++] = (byte) numberOfStackItems;
4266
						for (int i = 0; i < numberOfStackItems; i++) {
4267
							if (localContentsOffset + 3 >= this.contents.length) {
4268
								resizeContents(3);
4269
							}
4270
							VerificationTypeInfo info = currentFrame.stackItems[i];
4271
							if (info == null) {
4272
								this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_TOP;
4273
							} else {
4274
								switch(info.id()) {
4275
									case T_boolean :
4276
									case T_byte :
4277
									case T_char :
4278
									case T_int :
4279
									case T_short :
4280
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_INTEGER;
4281
										break;
4282
									case T_float :
4283
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_FLOAT;
4284
										break;
4285
									case T_long :
4286
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_LONG;
4287
										break;
4288
									case T_double :
4289
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_DOUBLE;
4290
										break;
4291
									case T_null :
4292
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_NULL;
4293
										break;
4294
									default:
4295
										this.contents[localContentsOffset++] = (byte) info.tag;
4296
									switch (info.tag) {
4297
										case VerificationTypeInfo.ITEM_UNINITIALIZED :
4298
											int offset = info.offset;
4299
											this.contents[localContentsOffset++] = (byte) (offset >> 8);
4300
											this.contents[localContentsOffset++] = (byte) offset;
4301
											break;
4302
										case VerificationTypeInfo.ITEM_OBJECT :
4303
											int indexForType = constantPool.literalIndexForType(info.constantPoolName());
4304
											this.contents[localContentsOffset++] = (byte) (indexForType >> 8);
4305
											this.contents[localContentsOffset++] = (byte) indexForType;
4306
									}
4307
								}
4308
							}
4309
						}
4310
					}
4311
4312
					numberOfFrames--;
4313
					if (numberOfFrames != 0) {
4314
						this.contents[numberOfFramesOffset++] = (byte) (numberOfFrames >> 8);
4315
						this.contents[numberOfFramesOffset] = (byte) numberOfFrames;
4316
4317
						int attributeLength = localContentsOffset - stackMapAttributeLengthOffset - 4;
4318
						this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 24);
4319
						this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 16);
4320
						this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 8);
4321
						this.contents[stackMapAttributeLengthOffset] = (byte) attributeLength;
4322
						attributeNumber++;
4323
					} else {
4324
						localContentsOffset = stackMapTableAttributeOffset;
4325
					}
4326
				}
4327
			}
4328
		}
4329
3654
		// then we do the local variable attribute
4330
		// then we do the local variable attribute
3655
		// update the number of attributes// ensure first that there is enough space available inside the localContents array
4331
		// update the number of attributes// ensure first that there is enough space available inside the localContents array
3656
		if (codeAttributeAttributeOffset + 2 >= this.contents.length) {
4332
		if (codeAttributeAttributeOffset + 2 >= this.contents.length) {
Lines 3969-3975 Link Here
3969
			}
4645
			}
3970
		}
4646
		}
3971
4647
3972
		if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) {
4648
		if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP_TABLE) != 0) {
3973
			StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream;
4649
			StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream;
3974
			stackMapFrameCodeStream.removeFramePosition(code_length);
4650
			stackMapFrameCodeStream.removeFramePosition(code_length);
3975
			if (stackMapFrameCodeStream.hasFramePositions()) {
4651
			if (stackMapFrameCodeStream.hasFramePositions()) {
Lines 4319-4324 Link Here
4319
			}
4995
			}
4320
		}
4996
		}
4321
4997
4998
		if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) {
4999
			StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream;
5000
			stackMapFrameCodeStream.removeFramePosition(code_length);
5001
			if (stackMapFrameCodeStream.hasFramePositions()) {
5002
				ArrayList frames = new ArrayList();
5003
				traverse(this.codeStream.methodDeclaration.binding, max_locals, this.contents, codeAttributeOffset + 14, code_length, frames, false);
5004
				int numberOfFrames = frames.size();
5005
				if (numberOfFrames > 1) {
5006
					int stackMapTableAttributeOffset = localContentsOffset;
5007
					// add the stack map table attribute
5008
					if (localContentsOffset + 8 >= this.contents.length) {
5009
						resizeContents(8);
5010
					}
5011
					int stackMapAttributeNameIndex =
5012
						constantPool.literalIndex(AttributeNamesConstants.StackMapName);
5013
					this.contents[localContentsOffset++] = (byte) (stackMapAttributeNameIndex >> 8);
5014
					this.contents[localContentsOffset++] = (byte) stackMapAttributeNameIndex;
5015
5016
					int stackMapAttributeLengthOffset = localContentsOffset;
5017
					// generate the attribute
5018
					localContentsOffset += 4;
5019
					if (localContentsOffset + 4 >= this.contents.length) {
5020
						resizeContents(4);
5021
					}
5022
					int numberOfFramesOffset = localContentsOffset;
5023
					localContentsOffset += 2;
5024
					if (localContentsOffset + 2 >= this.contents.length) {
5025
						resizeContents(2);
5026
					}
5027
					StackMapFrame currentFrame = (StackMapFrame) frames.get(0);
5028
					for (int j = 1; j < numberOfFrames; j++) {
5029
						// select next frame
5030
						currentFrame = (StackMapFrame) frames.get(j);
5031
						// generate current frame
5032
						// need to find differences between the current frame and the previous frame
5033
						int frameOffset = currentFrame.pc;
5034
						// FULL_FRAME
5035
						if (localContentsOffset + 5 >= this.contents.length) {
5036
							resizeContents(5);
5037
						}
5038
						this.contents[localContentsOffset++] = (byte) (frameOffset >> 8);
5039
						this.contents[localContentsOffset++] = (byte) frameOffset;
5040
						int numberOfLocalOffset = localContentsOffset;
5041
						localContentsOffset += 2; // leave two spots for number of locals
5042
						int numberOfLocalEntries = 0;
5043
						int numberOfLocals = currentFrame.getNumberOfLocals();
5044
						int numberOfEntries = 0;
5045
						int localsLength = currentFrame.locals == null ? 0 : currentFrame.locals.length;
5046
						for (int i = 0; i < localsLength && numberOfLocalEntries < numberOfLocals; i++) {
5047
							if (localContentsOffset + 3 >= this.contents.length) {
5048
								resizeContents(3);
5049
							}
5050
							VerificationTypeInfo info = currentFrame.locals[i];
5051
							if (info == null) {
5052
								this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_TOP;
5053
							} else {
5054
								switch(info.id()) {
5055
									case T_boolean :
5056
									case T_byte :
5057
									case T_char :
5058
									case T_int :
5059
									case T_short :
5060
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_INTEGER;
5061
										break;
5062
									case T_float :
5063
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_FLOAT;
5064
										break;
5065
									case T_long :
5066
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_LONG;
5067
										i++;
5068
										break;
5069
									case T_double :
5070
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_DOUBLE;
5071
										i++;
5072
										break;
5073
									case T_null :
5074
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_NULL;
5075
										break;
5076
									default:
5077
										this.contents[localContentsOffset++] = (byte) info.tag;
5078
									switch (info.tag) {
5079
										case VerificationTypeInfo.ITEM_UNINITIALIZED :
5080
											int offset = info.offset;
5081
											this.contents[localContentsOffset++] = (byte) (offset >> 8);
5082
											this.contents[localContentsOffset++] = (byte) offset;
5083
											break;
5084
										case VerificationTypeInfo.ITEM_OBJECT :
5085
											int indexForType = constantPool.literalIndexForType(info.constantPoolName());
5086
											this.contents[localContentsOffset++] = (byte) (indexForType >> 8);
5087
											this.contents[localContentsOffset++] = (byte) indexForType;
5088
									}
5089
								}
5090
								numberOfLocalEntries++;
5091
							}
5092
							numberOfEntries++;
5093
						}
5094
						if (localContentsOffset + 4 >= this.contents.length) {
5095
							resizeContents(4);
5096
						}
5097
						this.contents[numberOfLocalOffset++] = (byte) (numberOfEntries >> 8);
5098
						this.contents[numberOfLocalOffset] = (byte) numberOfEntries;
5099
						int numberOfStackItems = currentFrame.numberOfStackItems;
5100
						this.contents[localContentsOffset++] = (byte) (numberOfStackItems >> 8);
5101
						this.contents[localContentsOffset++] = (byte) numberOfStackItems;
5102
						for (int i = 0; i < numberOfStackItems; i++) {
5103
							if (localContentsOffset + 3 >= this.contents.length) {
5104
								resizeContents(3);
5105
							}
5106
							VerificationTypeInfo info = currentFrame.stackItems[i];
5107
							if (info == null) {
5108
								this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_TOP;
5109
							} else {
5110
								switch(info.id()) {
5111
									case T_boolean :
5112
									case T_byte :
5113
									case T_char :
5114
									case T_int :
5115
									case T_short :
5116
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_INTEGER;
5117
										break;
5118
									case T_float :
5119
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_FLOAT;
5120
										break;
5121
									case T_long :
5122
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_LONG;
5123
										break;
5124
									case T_double :
5125
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_DOUBLE;
5126
										break;
5127
									case T_null :
5128
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_NULL;
5129
										break;
5130
									default:
5131
										this.contents[localContentsOffset++] = (byte) info.tag;
5132
									switch (info.tag) {
5133
										case VerificationTypeInfo.ITEM_UNINITIALIZED :
5134
											int offset = info.offset;
5135
											this.contents[localContentsOffset++] = (byte) (offset >> 8);
5136
											this.contents[localContentsOffset++] = (byte) offset;
5137
											break;
5138
										case VerificationTypeInfo.ITEM_OBJECT :
5139
											int indexForType = constantPool.literalIndexForType(info.constantPoolName());
5140
											this.contents[localContentsOffset++] = (byte) (indexForType >> 8);
5141
											this.contents[localContentsOffset++] = (byte) indexForType;
5142
									}
5143
								}
5144
							}
5145
						}
5146
					}
5147
5148
					numberOfFrames--;
5149
					if (numberOfFrames != 0) {
5150
						this.contents[numberOfFramesOffset++] = (byte) (numberOfFrames >> 8);
5151
						this.contents[numberOfFramesOffset] = (byte) numberOfFrames;
5152
5153
						int attributeLength = localContentsOffset - stackMapAttributeLengthOffset - 4;
5154
						this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 24);
5155
						this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 16);
5156
						this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 8);
5157
						this.contents[stackMapAttributeLengthOffset] = (byte) attributeLength;
5158
						attributeNumber++;
5159
					} else {
5160
						localContentsOffset = stackMapTableAttributeOffset;
5161
					}
5162
				}
5163
			}
5164
		}
5165
4322
		// update the number of attributes// ensure first that there is enough space available inside the localContents array
5166
		// update the number of attributes// ensure first that there is enough space available inside the localContents array
4323
		if (codeAttributeAttributeOffset + 2 >= this.contents.length) {
5167
		if (codeAttributeAttributeOffset + 2 >= this.contents.length) {
4324
			resizeContents(2);
5168
			resizeContents(2);
Lines 4374-4380 Link Here
4374
			resizeContents(40);
5218
			resizeContents(40);
4375
		}
5219
		}
4376
5220
4377
		boolean addStackMaps = (this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0;
5221
		boolean addStackMaps = (this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP_TABLE) != 0;
4378
		if (hasExceptionHandlers) {
5222
		if (hasExceptionHandlers) {
4379
			// write the exception table
5223
			// write the exception table
4380
			ExceptionLabel[] exceptionLabels = codeStream.exceptionLabels;
5224
			ExceptionLabel[] exceptionLabels = codeStream.exceptionLabels;
Lines 4953-4958 Link Here
4953
			}
5797
			}
4954
		}
5798
		}
4955
5799
5800
		if ((this.produceAttributes & ClassFileConstants.ATTR_STACK_MAP) != 0) {
5801
			StackMapFrameCodeStream stackMapFrameCodeStream = (StackMapFrameCodeStream) this.codeStream;
5802
			stackMapFrameCodeStream.removeFramePosition(code_length);
5803
			if (stackMapFrameCodeStream.hasFramePositions()) {
5804
				ArrayList frames = new ArrayList();
5805
				traverse(this.codeStream.methodDeclaration.binding, max_locals, this.contents, codeAttributeOffset + 14, code_length, frames, false);
5806
				int numberOfFrames = frames.size();
5807
				if (numberOfFrames > 1) {
5808
					int stackMapTableAttributeOffset = localContentsOffset;
5809
					// add the stack map table attribute
5810
					if (localContentsOffset + 8 >= this.contents.length) {
5811
						resizeContents(8);
5812
					}
5813
					int stackMapAttributeNameIndex =
5814
						constantPool.literalIndex(AttributeNamesConstants.StackMapName);
5815
					this.contents[localContentsOffset++] = (byte) (stackMapAttributeNameIndex >> 8);
5816
					this.contents[localContentsOffset++] = (byte) stackMapAttributeNameIndex;
5817
5818
					int stackMapAttributeLengthOffset = localContentsOffset;
5819
					// generate the attribute
5820
					localContentsOffset += 4;
5821
					if (localContentsOffset + 4 >= this.contents.length) {
5822
						resizeContents(4);
5823
					}
5824
					int numberOfFramesOffset = localContentsOffset;
5825
					localContentsOffset += 2;
5826
					if (localContentsOffset + 2 >= this.contents.length) {
5827
						resizeContents(2);
5828
					}
5829
					StackMapFrame currentFrame = (StackMapFrame) frames.get(0);
5830
					for (int j = 1; j < numberOfFrames; j++) {
5831
						// select next frame
5832
						currentFrame = (StackMapFrame) frames.get(j);
5833
						// generate current frame
5834
						// need to find differences between the current frame and the previous frame
5835
						int frameOffset = currentFrame.pc;
5836
						// FULL_FRAME
5837
						if (localContentsOffset + 5 >= this.contents.length) {
5838
							resizeContents(5);
5839
						}
5840
						this.contents[localContentsOffset++] = (byte) (frameOffset >> 8);
5841
						this.contents[localContentsOffset++] = (byte) frameOffset;
5842
						int numberOfLocalOffset = localContentsOffset;
5843
						localContentsOffset += 2; // leave two spots for number of locals
5844
						int numberOfLocalEntries = 0;
5845
						int numberOfLocals = currentFrame.getNumberOfLocals();
5846
						int numberOfEntries = 0;
5847
						int localsLength = currentFrame.locals == null ? 0 : currentFrame.locals.length;
5848
						for (int i = 0; i < localsLength && numberOfLocalEntries < numberOfLocals; i++) {
5849
							if (localContentsOffset + 3 >= this.contents.length) {
5850
								resizeContents(3);
5851
							}
5852
							VerificationTypeInfo info = currentFrame.locals[i];
5853
							if (info == null) {
5854
								this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_TOP;
5855
							} else {
5856
								switch(info.id()) {
5857
									case T_boolean :
5858
									case T_byte :
5859
									case T_char :
5860
									case T_int :
5861
									case T_short :
5862
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_INTEGER;
5863
										break;
5864
									case T_float :
5865
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_FLOAT;
5866
										break;
5867
									case T_long :
5868
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_LONG;
5869
										i++;
5870
										break;
5871
									case T_double :
5872
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_DOUBLE;
5873
										i++;
5874
										break;
5875
									case T_null :
5876
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_NULL;
5877
										break;
5878
									default:
5879
										this.contents[localContentsOffset++] = (byte) info.tag;
5880
									switch (info.tag) {
5881
										case VerificationTypeInfo.ITEM_UNINITIALIZED :
5882
											int offset = info.offset;
5883
											this.contents[localContentsOffset++] = (byte) (offset >> 8);
5884
											this.contents[localContentsOffset++] = (byte) offset;
5885
											break;
5886
										case VerificationTypeInfo.ITEM_OBJECT :
5887
											int indexForType = constantPool.literalIndexForType(info.constantPoolName());
5888
											this.contents[localContentsOffset++] = (byte) (indexForType >> 8);
5889
											this.contents[localContentsOffset++] = (byte) indexForType;
5890
									}
5891
								}
5892
								numberOfLocalEntries++;
5893
							}
5894
							numberOfEntries++;
5895
						}
5896
						if (localContentsOffset + 4 >= this.contents.length) {
5897
							resizeContents(4);
5898
						}
5899
						this.contents[numberOfLocalOffset++] = (byte) (numberOfEntries >> 8);
5900
						this.contents[numberOfLocalOffset] = (byte) numberOfEntries;
5901
						int numberOfStackItems = currentFrame.numberOfStackItems;
5902
						this.contents[localContentsOffset++] = (byte) (numberOfStackItems >> 8);
5903
						this.contents[localContentsOffset++] = (byte) numberOfStackItems;
5904
						for (int i = 0; i < numberOfStackItems; i++) {
5905
							if (localContentsOffset + 3 >= this.contents.length) {
5906
								resizeContents(3);
5907
							}
5908
							VerificationTypeInfo info = currentFrame.stackItems[i];
5909
							if (info == null) {
5910
								this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_TOP;
5911
							} else {
5912
								switch(info.id()) {
5913
									case T_boolean :
5914
									case T_byte :
5915
									case T_char :
5916
									case T_int :
5917
									case T_short :
5918
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_INTEGER;
5919
										break;
5920
									case T_float :
5921
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_FLOAT;
5922
										break;
5923
									case T_long :
5924
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_LONG;
5925
										break;
5926
									case T_double :
5927
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_DOUBLE;
5928
										break;
5929
									case T_null :
5930
										this.contents[localContentsOffset++] = (byte) VerificationTypeInfo.ITEM_NULL;
5931
										break;
5932
									default:
5933
										this.contents[localContentsOffset++] = (byte) info.tag;
5934
									switch (info.tag) {
5935
										case VerificationTypeInfo.ITEM_UNINITIALIZED :
5936
											int offset = info.offset;
5937
											this.contents[localContentsOffset++] = (byte) (offset >> 8);
5938
											this.contents[localContentsOffset++] = (byte) offset;
5939
											break;
5940
										case VerificationTypeInfo.ITEM_OBJECT :
5941
											int indexForType = constantPool.literalIndexForType(info.constantPoolName());
5942
											this.contents[localContentsOffset++] = (byte) (indexForType >> 8);
5943
											this.contents[localContentsOffset++] = (byte) indexForType;
5944
									}
5945
								}
5946
							}
5947
						}
5948
					}
5949
5950
					numberOfFrames--;
5951
					if (numberOfFrames != 0) {
5952
						this.contents[numberOfFramesOffset++] = (byte) (numberOfFrames >> 8);
5953
						this.contents[numberOfFramesOffset] = (byte) numberOfFrames;
5954
5955
						int attributeLength = localContentsOffset - stackMapAttributeLengthOffset - 4;
5956
						this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 24);
5957
						this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 16);
5958
						this.contents[stackMapAttributeLengthOffset++] = (byte) (attributeLength >> 8);
5959
						this.contents[stackMapAttributeLengthOffset] = (byte) attributeLength;
5960
						attributeNumber++;
5961
					} else {
5962
						localContentsOffset = stackMapTableAttributeOffset;
5963
					}
5964
				}
5965
			}
5966
		}
5967
4956
		// update the number of attributes
5968
		// update the number of attributes
4957
		// ensure first that there is enough space available inside the contents array
5969
		// ensure first that there is enough space available inside the contents array
4958
		if (codeAttributeAttributeOffset + 2 >= this.contents.length) {
5970
		if (codeAttributeAttributeOffset + 2 >= this.contents.length) {
Lines 5976-5981 Link Here
5976
		this.targetJDK = options.targetJDK;
6988
		this.targetJDK = options.targetJDK;
5977
		this.produceAttributes = options.produceDebugAttributes;
6989
		this.produceAttributes = options.produceDebugAttributes;
5978
		if (this.targetJDK >= ClassFileConstants.JDK1_6) {
6990
		if (this.targetJDK >= ClassFileConstants.JDK1_6) {
6991
			this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP_TABLE;
6992
		} else if (this.targetJDK == ClassFileConstants.CLDC_1_1) {
6993
			this.targetJDK = ClassFileConstants.JDK1_1; // put back 45.3
5979
			this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP;
6994
			this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP;
5980
		}
6995
		}
5981
		this.bytes = null;
6996
		this.bytes = null;
(-)src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java (+2 lines)
Lines 985-990 Link Here
985
        "    -1.7 -7 -7.0       use 1.7 compliance (-source 1.7 -target 1.7)\n" +
985
        "    -1.7 -7 -7.0       use 1.7 compliance (-source 1.7 -target 1.7)\n" +
986
        "    -source <version>  set source level: 1.3 to 1.7 (or 5, 5.0, etc)\n" +
986
        "    -source <version>  set source level: 1.3 to 1.7 (or 5, 5.0, etc)\n" +
987
        "    -target <version>  set classfile target: 1.1 to 1.7 (or 5, 5.0, etc)\n" +
987
        "    -target <version>  set classfile target: 1.1 to 1.7 (or 5, 5.0, etc)\n" +
988
        "                       cldc1.1 can also be used to generate the StackMap\n" + 
989
        "                       attribute\n" + 
988
        " \n" +
990
        " \n" +
989
        " Warning options:\n" +
991
        " Warning options:\n" +
990
        "    -deprecation     + deprecation outside deprecated code (equivalent to\n" +
992
        "    -deprecation     + deprecation outside deprecated code (equivalent to\n" +

Return to bug 120223