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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java (-2 / +120 lines)
Lines 11-17 Link Here
11
package org.eclipse.jdt.core.tests.compiler.regression;
11
package org.eclipse.jdt.core.tests.compiler.regression;
12
12
13
import java.io.File;
13
import java.io.File;
14
15
import junit.framework.Test;
14
import junit.framework.Test;
16
15
17
import org.eclipse.jdt.core.ToolFactory;
16
import org.eclipse.jdt.core.ToolFactory;
Lines 32-38 Link Here
32
	static {
31
	static {
33
//		TESTS_PREFIX = "testBug95521";
32
//		TESTS_PREFIX = "testBug95521";
34
//		TESTS_NAMES = new String[] { "testBug83127a" };
33
//		TESTS_NAMES = new String[] { "testBug83127a" };
35
//		TESTS_NUMBERS = new int[] { 38 };
34
//		TESTS_NUMBERS = new int[] { 40, 41 };
36
//		TESTS_RANGE = new int[] { 23 -1,};
35
//		TESTS_RANGE = new int[] { 23 -1,};
37
	}
36
	}
38
	public static Test suite() {
37
	public static Test suite() {
Lines 6117-6120 Link Here
6117
			},
6116
			},
6118
		"SUCCESS");
6117
		"SUCCESS");
6119
	}
6118
	}
6119
6120
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=251539
6121
	public void test040() throws Exception {
6122
		this.runConformTest(
6123
			new String[] {
6124
				"I.java",
6125
				"public interface I {\n" + 
6126
				"\n" + 
6127
				"	public Object foo();\n" + 
6128
				"\n" + 
6129
				"	public static class B implements I {\n" + 
6130
				"		public Object foo() {\n" + 
6131
				"			return X.myI.foo();\n" + 
6132
				"		}\n" + 
6133
				"	}\n" + 
6134
				"}",
6135
				"X.java",
6136
				"public class X {\n" + 
6137
				"	public static final I myI = new I.B() {\n" + 
6138
				"		int a = 0;\n" + 
6139
				"		int b = 1;\n" + 
6140
				"	};\n" + 
6141
				"\n" + 
6142
				"	private Object bar() {\n" + 
6143
				"		Object o = null;\n" + 
6144
				"		if (o != null) {\n" + 
6145
				"			o.toString();\n" + 
6146
				"		}\n" + 
6147
				"		return null;\n" + 
6148
				"	}\n" + 
6149
				"\n" + 
6150
				"}",
6151
			},
6152
		"");
6153
		String expectedOutput =
6154
			"  // Stack: 1, Locals: 2\n" + 
6155
			"  private java.lang.Object bar();\n" + 
6156
			"     0  aconst_null\n" + 
6157
			"     1  astore_1 [o]\n" + 
6158
			"     2  aload_1 [o]\n" + 
6159
			"     3  ifnull 11\n" + 
6160
			"     6  aload_1 [o]\n" + 
6161
			"     7  invokevirtual java.lang.Object.toString() : java.lang.String [24]\n" + 
6162
			"    10  pop\n" + 
6163
			"    11  aconst_null\n" + 
6164
			"    12  areturn\n" + 
6165
			"      Line numbers:\n" + 
6166
			"        [pc: 0, line: 8]\n" + 
6167
			"        [pc: 2, line: 9]\n" + 
6168
			"        [pc: 6, line: 10]\n" + 
6169
			"        [pc: 11, line: 12]\n" + 
6170
			"      Local variable table:\n" + 
6171
			"        [pc: 0, pc: 13] local: this index: 0 type: X\n" + 
6172
			"        [pc: 2, pc: 13] local: o index: 1 type: java.lang.Object\n" + 
6173
			"      Stack map table: number of frames 1\n" + 
6174
			"        [pc: 11, append: {java.lang.Object}]\n";
6175
		checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput);
6176
	}
6177
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=251539
6178
	public void test041() throws Exception {
6179
		this.runConformTest(
6180
			new String[] {
6181
				"I.java",
6182
				"public interface I {\n" + 
6183
				"\n" + 
6184
				"	public Object foo();\n" + 
6185
				"\n" + 
6186
				"	public static class B implements I {\n" + 
6187
				"		public Object foo() {\n" + 
6188
				"			return String.valueOf(X.myI.foo()) + String.valueOf(X.myU.foo());\n" + 
6189
				"		}\n" + 
6190
				"	}\n" + 
6191
				"}",
6192
				"X.java",
6193
				"public class X {\n" + 
6194
				"	public static final I myI = new I.B() {\n" + 
6195
				"		int a = 0;\n" + 
6196
				"		int b = 1;\n" + 
6197
				"	};\n" + 
6198
				"	public static final I myU = new I.B() {\n" + 
6199
				"		int a = 0;\n" + 
6200
				"		int b = 1;\n" + 
6201
				"		int c = 2;\n" + 
6202
				"	};\n" +
6203
				"	private Object bar() {\n" + 
6204
				"		Object o = null;\n" + 
6205
				"		if (o != null) {\n" + 
6206
				"			o.toString();\n" + 
6207
				"		}\n" + 
6208
				"		return null;\n" + 
6209
				"	}\n" + 
6210
				"}",
6211
			},
6212
		"");
6213
	
6214
		String expectedOutput =
6215
			"  // Stack: 1, Locals: 2\n" + 
6216
			"  private java.lang.Object bar();\n" + 
6217
			"     0  aconst_null\n" + 
6218
			"     1  astore_1 [o]\n" + 
6219
			"     2  aload_1 [o]\n" + 
6220
			"     3  ifnull 11\n" + 
6221
			"     6  aload_1 [o]\n" + 
6222
			"     7  invokevirtual java.lang.Object.toString() : java.lang.String [30]\n" + 
6223
			"    10  pop\n" + 
6224
			"    11  aconst_null\n" + 
6225
			"    12  areturn\n" + 
6226
			"      Line numbers:\n" + 
6227
			"        [pc: 0, line: 12]\n" + 
6228
			"        [pc: 2, line: 13]\n" + 
6229
			"        [pc: 6, line: 14]\n" + 
6230
			"        [pc: 11, line: 16]\n" + 
6231
			"      Local variable table:\n" + 
6232
			"        [pc: 0, pc: 13] local: this index: 0 type: X\n" + 
6233
			"        [pc: 2, pc: 13] local: o index: 1 type: java.lang.Object\n" + 
6234
			"      Stack map table: number of frames 1\n" + 
6235
			"        [pc: 11, append: {java.lang.Object}]\n";
6236
		checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput);
6237
	}
6120
}
6238
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java (-2 / +6 lines)
Lines 1016-1022 Link Here
1016
				}
1016
				}
1017
			} while ((current = current.enclosingType()) != null);
1017
			} while ((current = current.enclosingType()) != null);
1018
		}
1018
		}
1019
		this.maxFieldCount = 0;
1019
		// this.maxFieldCount might already be set
1020
		int localMaxFieldCount = 0;
1020
		int lastVisibleFieldID = -1;
1021
		int lastVisibleFieldID = -1;
1021
		boolean hasEnumConstants = false;
1022
		boolean hasEnumConstants = false;
1022
		FieldDeclaration[] enumConstantsWithoutBody = null;
1023
		FieldDeclaration[] enumConstantsWithoutBody = null;
Lines 1057-1063 Link Here
1057
								&& TypeBinding.LONG == fieldBinding.type) {
1058
								&& TypeBinding.LONG == fieldBinding.type) {
1058
							needSerialVersion = false;
1059
							needSerialVersion = false;
1059
						}
1060
						}
1060
						this.maxFieldCount++;
1061
						localMaxFieldCount++;
1061
						lastVisibleFieldID = field.binding.id;
1062
						lastVisibleFieldID = field.binding.id;
1062
						break;
1063
						break;
1063
1064
Lines 1068-1073 Link Here
1068
				field.resolve(field.isStatic() ? this.staticInitializerScope : this.initializerScope);
1069
				field.resolve(field.isStatic() ? this.staticInitializerScope : this.initializerScope);
1069
			}
1070
			}
1070
		}
1071
		}
1072
		if (this.maxFieldCount < localMaxFieldCount) {
1073
			this.maxFieldCount = localMaxFieldCount;
1074
		}
1071
		if (needSerialVersion) {
1075
		if (needSerialVersion) {
1072
			this.scope.problemReporter().missingSerialVersion(this);
1076
			this.scope.problemReporter().missingSerialVersion(this);
1073
		}
1077
		}
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetClassFile.java (-6 / +1 lines)
Lines 127-138 Link Here
127
	}
127
	}
128
	// retrieve the enclosing one guaranteed to be the one matching the propagated flow info
128
	// retrieve the enclosing one guaranteed to be the one matching the propagated flow info
129
	// 1FF9ZBU: LFCOM:ALL - Local variable attributes busted (Sanity check)
129
	// 1FF9ZBU: LFCOM:ALL - Local variable attributes busted (Sanity check)
130
	if (this.enclosingClassFile == null) {
130
	this.codeStream.maxFieldCount = aType.scope.outerMostClassScope().referenceType().maxFieldCount;
131
		this.codeStream.maxFieldCount = aType.scope.referenceType().maxFieldCount;
132
	} else {
133
		ClassFile outermostClassFile = outerMostEnclosingClassFile();
134
		this.codeStream.maxFieldCount = outermostClassFile.codeStream.maxFieldCount;
135
	}
136
}
131
}
137
/**
132
/**
138
 * INTERNAL USE-ONLY
133
 * INTERNAL USE-ONLY
(-)compiler/org/eclipse/jdt/internal/compiler/ClassFile.java (-6 / +1 lines)
Lines 6915-6926 Link Here
6915
6915
6916
		// retrieve the enclosing one guaranteed to be the one matching the propagated flow info
6916
		// retrieve the enclosing one guaranteed to be the one matching the propagated flow info
6917
		// 1FF9ZBU: LFCOM:ALL - Local variable attributes busted (Sanity check)
6917
		// 1FF9ZBU: LFCOM:ALL - Local variable attributes busted (Sanity check)
6918
		if (this.enclosingClassFile == null) {
6918
		this.codeStream.maxFieldCount = aType.scope.outerMostClassScope().referenceType().maxFieldCount;
6919
			this.codeStream.maxFieldCount = aType.scope.referenceType().maxFieldCount;
6920
		} else {
6921
			ClassFile outermostClassFile = outerMostEnclosingClassFile();
6922
			this.codeStream.maxFieldCount = outermostClassFile.codeStream.maxFieldCount;
6923
		}
6924
	}
6919
	}
6925
6920
6926
	private void initializeDefaultLocals(StackMapFrame frame,
6921
	private void initializeDefaultLocals(StackMapFrame frame,

Return to bug 251539