Lines 2374-2379
Link Here
|
2374 |
"SUCCESS" |
2374 |
"SUCCESS" |
2375 |
); |
2375 |
); |
2376 |
} |
2376 |
} |
|
|
2377 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=359284 |
2378 |
// Verify that checkcast is emitted for a cast expression. |
2379 |
public void test061b() throws Exception { |
2380 |
String source = |
2381 |
"public class X {\n" + |
2382 |
"public X() {\n" + |
2383 |
" Object[] x = (Object[])null;\n" + |
2384 |
"}\n" + |
2385 |
"}\n"; |
2386 |
this.runConformTest( |
2387 |
new String[] { |
2388 |
"X.java", |
2389 |
source |
2390 |
}, |
2391 |
"" |
2392 |
); |
2393 |
String expectedOutput = |
2394 |
"public class X {\n" + |
2395 |
" \n" + |
2396 |
" // Method descriptor #6 ()V\n" + |
2397 |
" // Stack: 1, Locals: 2\n" + |
2398 |
" public X();\n" + |
2399 |
" 0 aload_0 [this]\n" + |
2400 |
" 1 invokespecial java.lang.Object() [8]\n" + |
2401 |
" 4 aconst_null\n" + |
2402 |
" 5 checkcast java.lang.Object[] [10]\n" + |
2403 |
" 8 astore_1 [x]\n" + |
2404 |
" 9 return\n" + |
2405 |
" Line numbers:\n" + |
2406 |
" [pc: 0, line: 2]\n" + |
2407 |
" [pc: 4, line: 3]\n" + |
2408 |
" [pc: 9, line: 4]\n" + |
2409 |
" Local variable table:\n" + |
2410 |
" [pc: 0, pc: 10] local: this index: 0 type: X\n" + |
2411 |
" [pc: 9, pc: 10] local: x index: 1 type: java.lang.Object[]\n" + |
2412 |
"}"; |
2413 |
File f = new File(OUTPUT_DIR + File.separator + "X.class"); |
2414 |
byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); |
2415 |
ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); |
2416 |
String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); |
2417 |
int index = result.indexOf(expectedOutput); |
2418 |
if (index == -1 || expectedOutput.length() == 0) { |
2419 |
System.out.println(Util.displayString(result, 3)); |
2420 |
} |
2421 |
if (index == -1) { |
2422 |
assertEquals("Wrong contents", expectedOutput, result); |
2423 |
} |
2424 |
} |
2377 |
public static Class testClass() { |
2425 |
public static Class testClass() { |
2378 |
return CastTest.class; |
2426 |
return CastTest.class; |
2379 |
} |
2427 |
} |