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 |
} |