Lines 16-21
Link Here
|
16 |
|
16 |
|
17 |
import org.eclipse.jdt.core.ToolFactory; |
17 |
import org.eclipse.jdt.core.ToolFactory; |
18 |
import org.eclipse.jdt.core.util.ClassFileBytesDisassembler; |
18 |
import org.eclipse.jdt.core.util.ClassFileBytesDisassembler; |
|
|
19 |
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants; |
19 |
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; |
20 |
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; |
20 |
import org.eclipse.jdt.core.tests.util.Util; |
21 |
import org.eclipse.jdt.core.tests.util.Util; |
21 |
|
22 |
|
Lines 1405-1410
Link Here
|
1405 |
}, |
1406 |
}, |
1406 |
""); |
1407 |
""); |
1407 |
String expectedOutput = |
1408 |
String expectedOutput = |
|
|
1409 |
" // Method descriptor #15 (Ljava/lang/String;Ljava/lang/String;[LX$IContributionItem;)V\n" + |
1410 |
" // Stack: 3, Locals: 8\n" + |
1408 |
" public static void findInsertionPoint(java.lang.String startId, java.lang.String sortId, X.IContributionItem[] items);\n" + |
1411 |
" public static void findInsertionPoint(java.lang.String startId, java.lang.String sortId, X.IContributionItem[] items);\n" + |
1409 |
" 0 iconst_0\n" + |
1412 |
" 0 iconst_0\n" + |
1410 |
" 1 istore_3 [insertIndex]\n" + |
1413 |
" 1 istore_3 [insertIndex]\n" + |
Lines 1433-1453
Link Here
|
1433 |
" 43 iconst_1\n" + |
1436 |
" 43 iconst_1\n" + |
1434 |
" 44 iadd\n" + |
1437 |
" 44 iadd\n" + |
1435 |
" 45 istore 5 [nX]\n" + |
1438 |
" 45 istore 5 [nX]\n" + |
1436 |
" 47 goto 129\n" + |
1439 |
" 47 goto 123\n" + |
1437 |
" 50 aload_2 [items]\n" + |
1440 |
" 50 aload_2 [items]\n" + |
1438 |
" 51 iload 5 [nX]\n" + |
1441 |
" 51 iload 5 [nX]\n" + |
1439 |
" 53 aaload\n" + |
1442 |
" 53 aaload\n" + |
1440 |
" 54 astore 6 [item]\n" + |
1443 |
" 54 astore 6 [item]\n" + |
1441 |
" 56 aload 6 [item]\n" + |
1444 |
" 56 aload 6 [item]\n" + |
1442 |
" 58 invokeinterface X$IContributionItem.isSeparator() : boolean [28] [nargs: 1]\n" + |
1445 |
" 58 invokeinterface X$IContributionItem.isSeparator() : boolean [28] [nargs: 1]\n" + |
1443 |
" 63 ifne 140\n" + |
1446 |
" 63 ifne 134\n" + |
1444 |
" 66 aload 6 [item]\n" + |
1447 |
" 66 aload 6 [item]\n" + |
1445 |
" 68 invokeinterface X$IContributionItem.isGroupMarker() : boolean [32] [nargs: 1]\n" + |
1448 |
" 68 invokeinterface X$IContributionItem.isGroupMarker() : boolean [32] [nargs: 1]\n" + |
1446 |
" 73 ifeq 79\n" + |
1449 |
" 73 ifeq 79\n" + |
1447 |
" 76 goto 140\n" + |
1450 |
" 76 goto 134\n" + |
1448 |
" 79 aload 6 [item]\n" + |
1451 |
" 79 aload 6 [item]\n" + |
1449 |
" 81 instanceof X$IActionSetContributionItem [35]\n" + |
1452 |
" 81 instanceof X$IActionSetContributionItem [35]\n" + |
1450 |
" 84 ifeq 140\n" + |
1453 |
" 84 ifeq 134\n" + |
1451 |
" 87 aload_1 [sortId]\n" + |
1454 |
" 87 aload_1 [sortId]\n" + |
1452 |
" 88 ifnull 117\n" + |
1455 |
" 88 ifnull 117\n" + |
1453 |
" 91 aload 6 [item]\n" + |
1456 |
" 91 aload 6 [item]\n" + |
Lines 1459-1477
Link Here
|
1459 |
" 106 invokevirtual java.lang.String.compareTo(java.lang.String) : int [40]\n" + |
1462 |
" 106 invokevirtual java.lang.String.compareTo(java.lang.String) : int [40]\n" + |
1460 |
" 109 iload 4 [compareMetric]\n" + |
1463 |
" 109 iload 4 [compareMetric]\n" + |
1461 |
" 111 if_icmpge 117\n" + |
1464 |
" 111 if_icmpge 117\n" + |
1462 |
" 114 goto 140\n" + |
1465 |
" 114 goto 134\n" + |
1463 |
" 117 iload 5 [nX]\n" + |
1466 |
" 117 iload 5 [nX]\n" + |
1464 |
" 119 istore_3 [insertIndex]\n" + |
1467 |
" 119 istore_3 [insertIndex]\n" + |
1465 |
" 120 goto 126\n" + |
1468 |
" 120 iinc 5 1 [nX]\n" + |
1466 |
" 123 goto 140\n" + |
1469 |
" 123 iload 5 [nX]\n" + |
1467 |
" 126 iinc 5 1 [nX]\n" + |
1470 |
" 125 aload_2 [items]\n" + |
1468 |
" 129 iload 5 [nX]\n" + |
1471 |
" 126 arraylength\n" + |
1469 |
" 131 aload_2 [items]\n" + |
1472 |
" 127 if_icmplt 50\n" + |
1470 |
" 132 arraylength\n" + |
1473 |
" 130 goto 134\n" + |
1471 |
" 133 if_icmplt 50\n" + |
1474 |
" 133 astore_3\n" + |
1472 |
" 136 goto 140\n" + |
1475 |
" 134 return\n" + |
1473 |
" 139 astore_3\n" + |
1476 |
" Exception Table:\n" + |
1474 |
" 140 return\n"; |
1477 |
" [pc: 0, pc: 38] -> 133 when : java.lang.Exception\n" + |
|
|
1478 |
" [pc: 39, pc: 133] -> 133 when : java.lang.Exception\n" + |
1479 |
" Line numbers:\n" + |
1480 |
" [pc: 0, line: 16]\n" + |
1481 |
" [pc: 2, line: 17]\n" + |
1482 |
" [pc: 5, line: 18]\n" + |
1483 |
" [pc: 20, line: 19]\n" + |
1484 |
" [pc: 23, line: 20]\n" + |
1485 |
" [pc: 26, line: 17]\n" + |
1486 |
" [pc: 32, line: 22]\n" + |
1487 |
" [pc: 38, line: 23]\n" + |
1488 |
" [pc: 39, line: 25]\n" + |
1489 |
" [pc: 42, line: 30]\n" + |
1490 |
" [pc: 50, line: 31]\n" + |
1491 |
" [pc: 56, line: 32]\n" + |
1492 |
" [pc: 76, line: 34]\n" + |
1493 |
" [pc: 79, line: 36]\n" + |
1494 |
" [pc: 87, line: 37]\n" + |
1495 |
" [pc: 91, line: 38]\n" + |
1496 |
" [pc: 96, line: 39]\n" + |
1497 |
" [pc: 101, line: 38]\n" + |
1498 |
" [pc: 103, line: 40]\n" + |
1499 |
" [pc: 114, line: 41]\n" + |
1500 |
" [pc: 117, line: 43]\n" + |
1501 |
" [pc: 120, line: 30]\n" + |
1502 |
" [pc: 133, line: 48]\n" + |
1503 |
" [pc: 134, line: 49]\n" + |
1504 |
" Local variable table:\n" + |
1505 |
" [pc: 0, pc: 135] local: startId index: 0 type: java.lang.String\n" + |
1506 |
" [pc: 0, pc: 135] local: sortId index: 1 type: java.lang.String\n" + |
1507 |
" [pc: 0, pc: 135] local: items index: 2 type: X.IContributionItem[]\n" + |
1508 |
" [pc: 2, pc: 133] local: insertIndex index: 3 type: int\n" + |
1509 |
" [pc: 42, pc: 133] local: compareMetric index: 4 type: int\n" + |
1510 |
" [pc: 47, pc: 130] local: nX index: 5 type: int\n" + |
1511 |
" [pc: 56, pc: 120] local: item index: 6 type: X.IContributionItem\n" + |
1512 |
" [pc: 103, pc: 117] local: testId index: 7 type: java.lang.String\n"; |
1475 |
|
1513 |
|
1476 |
try { |
1514 |
try { |
1477 |
File f = new File(OUTPUT_DIR + File.separator + "X.class"); |
1515 |
File f = new File(OUTPUT_DIR + File.separator + "X.class"); |
Lines 2970-2975
Link Here
|
2970 |
assertTrue(false); |
3008 |
assertTrue(false); |
2971 |
} |
3009 |
} |
2972 |
} |
3010 |
} |
|
|
3011 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=114894 |
3012 |
public void test048() { |
3013 |
this.runConformTest( |
3014 |
new String[] { |
3015 |
"X.java", |
3016 |
"public class X {\n" + |
3017 |
" boolean bool() { return true; }\n" + |
3018 |
" void foo() {\n" + |
3019 |
" try {\n" + |
3020 |
" if (bool()) {\n" + |
3021 |
" return;\n" + |
3022 |
" }\n" + |
3023 |
" } catch (Exception e) {\n" + |
3024 |
" }\n" + |
3025 |
" }\n" + |
3026 |
" int foo2() {\n" + |
3027 |
" try {\n" + |
3028 |
" while (bool()) {\n" + |
3029 |
" return 0;\n" + |
3030 |
" }\n" + |
3031 |
" } catch (Exception e) {\n" + |
3032 |
" }\n" + |
3033 |
" return 1;\n" + |
3034 |
" }\n" + |
3035 |
" long foo3() {\n" + |
3036 |
" try {\n" + |
3037 |
" do {\n" + |
3038 |
" if (true) return 0L;\n" + |
3039 |
" } while (bool());\n" + |
3040 |
" } catch (Exception e) {\n" + |
3041 |
" }\n" + |
3042 |
" return 1L;\n" + |
3043 |
" } \n" + |
3044 |
" float foo4() {\n" + |
3045 |
" try {\n" + |
3046 |
" for (int i = 0; bool(); i++) {\n" + |
3047 |
" return 0.0F;\n" + |
3048 |
" }\n" + |
3049 |
" } catch (Exception e) {\n" + |
3050 |
" }\n" + |
3051 |
" return 1.0F;\n" + |
3052 |
" } \n" + |
3053 |
" double bar() {\n" + |
3054 |
" if (bool()) {\n" + |
3055 |
" if (bool())\n" + |
3056 |
" return 0.0;\n" + |
3057 |
" } else {\n" + |
3058 |
" if (bool()) {\n" + |
3059 |
" throw new NullPointerException();\n" + |
3060 |
" }\n" + |
3061 |
" }\n" + |
3062 |
" return 1.0;\n" + |
3063 |
" }\n" + |
3064 |
" void baz(int i) {\n" + |
3065 |
" if (bool()) {\n" + |
3066 |
" switch(i) {\n" + |
3067 |
" case 0 : return;\n" + |
3068 |
" default : break;\n" + |
3069 |
" }\n" + |
3070 |
" } else {\n" + |
3071 |
" bool();\n" + |
3072 |
" }\n" + |
3073 |
" }\n" + |
3074 |
"}\n", |
3075 |
}, |
3076 |
""); |
3077 |
|
3078 |
String expectedOutput = new CompilerOptions(this.getCompilerOptions()).complianceLevel < ClassFileConstants.JDK1_6 |
3079 |
? " // Method descriptor #6 ()V\n" + |
3080 |
" // Stack: 1, Locals: 2\n" + |
3081 |
" void foo();\n" + |
3082 |
" 0 aload_0 [this]\n" + |
3083 |
" 1 invokevirtual X.bool() : boolean [17]\n" + |
3084 |
" 4 ifeq 9\n" + |
3085 |
" 7 return\n" + |
3086 |
" 8 astore_1\n" + |
3087 |
" 9 return\n" + |
3088 |
" Exception Table:\n" + |
3089 |
" [pc: 0, pc: 7] -> 8 when : java.lang.Exception\n" + |
3090 |
" Line numbers:\n" + |
3091 |
" [pc: 0, line: 5]\n" + |
3092 |
" [pc: 7, line: 6]\n" + |
3093 |
" [pc: 8, line: 8]\n" + |
3094 |
" [pc: 9, line: 10]\n" + |
3095 |
" Local variable table:\n" + |
3096 |
" [pc: 0, pc: 10] local: this index: 0 type: X\n" + |
3097 |
" \n" + |
3098 |
" // Method descriptor #22 ()I\n" + |
3099 |
" // Stack: 1, Locals: 2\n" + |
3100 |
" int foo2();\n" + |
3101 |
" 0 aload_0 [this]\n" + |
3102 |
" 1 invokevirtual X.bool() : boolean [17]\n" + |
3103 |
" 4 ifeq 10\n" + |
3104 |
" 7 iconst_0\n" + |
3105 |
" 8 ireturn\n" + |
3106 |
" 9 astore_1\n" + |
3107 |
" 10 iconst_1\n" + |
3108 |
" 11 ireturn\n" + |
3109 |
" Exception Table:\n" + |
3110 |
" [pc: 0, pc: 7] -> 9 when : java.lang.Exception\n" + |
3111 |
" Line numbers:\n" + |
3112 |
" [pc: 0, line: 13]\n" + |
3113 |
" [pc: 7, line: 14]\n" + |
3114 |
" [pc: 9, line: 16]\n" + |
3115 |
" [pc: 10, line: 18]\n" + |
3116 |
" Local variable table:\n" + |
3117 |
" [pc: 0, pc: 12] local: this index: 0 type: X\n" + |
3118 |
" \n" + |
3119 |
" // Method descriptor #24 ()J\n" + |
3120 |
" // Stack: 2, Locals: 2\n" + |
3121 |
" long foo3();\n" + |
3122 |
" 0 lconst_0\n" + |
3123 |
" 1 lreturn\n" + |
3124 |
" 2 astore_1\n" + |
3125 |
" 3 lconst_1\n" + |
3126 |
" 4 lreturn\n" + |
3127 |
" Line numbers:\n" + |
3128 |
" [pc: 0, line: 23]\n" + |
3129 |
" [pc: 2, line: 25]\n" + |
3130 |
" [pc: 3, line: 27]\n" + |
3131 |
" Local variable table:\n" + |
3132 |
" [pc: 0, pc: 5] local: this index: 0 type: X\n" + |
3133 |
" \n" + |
3134 |
" // Method descriptor #26 ()F\n" + |
3135 |
" // Stack: 1, Locals: 2\n" + |
3136 |
" float foo4();\n" + |
3137 |
" 0 iconst_0\n" + |
3138 |
" 1 istore_1 [i]\n" + |
3139 |
" 2 goto 7\n" + |
3140 |
" 5 fconst_0\n" + |
3141 |
" 6 freturn\n" + |
3142 |
" 7 aload_0 [this]\n" + |
3143 |
" 8 invokevirtual X.bool() : boolean [17]\n" + |
3144 |
" 11 ifne 5\n" + |
3145 |
" 14 goto 18\n" + |
3146 |
" 17 astore_1\n" + |
3147 |
" 18 fconst_1\n" + |
3148 |
" 19 freturn\n" + |
3149 |
" Exception Table:\n" + |
3150 |
" [pc: 0, pc: 5] -> 17 when : java.lang.Exception\n" + |
3151 |
" [pc: 7, pc: 17] -> 17 when : java.lang.Exception\n" + |
3152 |
" Line numbers:\n" + |
3153 |
" [pc: 0, line: 31]\n" + |
3154 |
" [pc: 5, line: 32]\n" + |
3155 |
" [pc: 7, line: 31]\n" + |
3156 |
" [pc: 17, line: 34]\n" + |
3157 |
" [pc: 18, line: 36]\n" + |
3158 |
" Local variable table:\n" + |
3159 |
" [pc: 0, pc: 20] local: this index: 0 type: X\n" + |
3160 |
" [pc: 2, pc: 14] local: i index: 1 type: int\n" + |
3161 |
" \n" + |
3162 |
" // Method descriptor #30 ()D\n" + |
3163 |
" // Stack: 2, Locals: 1\n" + |
3164 |
" double bar();\n" + |
3165 |
" 0 aload_0 [this]\n" + |
3166 |
" 1 invokevirtual X.bool() : boolean [17]\n" + |
3167 |
" 4 ifeq 16\n" + |
3168 |
" 7 aload_0 [this]\n" + |
3169 |
" 8 invokevirtual X.bool() : boolean [17]\n" + |
3170 |
" 11 ifeq 31\n" + |
3171 |
" 14 dconst_0\n" + |
3172 |
" 15 dreturn\n" + |
3173 |
" 16 aload_0 [this]\n" + |
3174 |
" 17 invokevirtual X.bool() : boolean [17]\n" + |
3175 |
" 20 ifeq 31\n" + |
3176 |
" 23 new java.lang.NullPointerException [31]\n" + |
3177 |
" 26 dup\n" + |
3178 |
" 27 invokespecial java.lang.NullPointerException() [33]\n" + |
3179 |
" 30 athrow\n" + |
3180 |
" 31 dconst_1\n" + |
3181 |
" 32 dreturn\n" + |
3182 |
" Line numbers:\n" + |
3183 |
" [pc: 0, line: 39]\n" + |
3184 |
" [pc: 7, line: 40]\n" + |
3185 |
" [pc: 14, line: 41]\n" + |
3186 |
" [pc: 16, line: 43]\n" + |
3187 |
" [pc: 23, line: 44]\n" + |
3188 |
" [pc: 31, line: 47]\n" + |
3189 |
" Local variable table:\n" + |
3190 |
" [pc: 0, pc: 33] local: this index: 0 type: X\n" + |
3191 |
" \n" + |
3192 |
" // Method descriptor #35 (I)V\n" + |
3193 |
" // Stack: 1, Locals: 2\n" + |
3194 |
" void baz(int i);\n" + |
3195 |
" 0 aload_0 [this]\n" + |
3196 |
" 1 invokevirtual X.bool() : boolean [17]\n" + |
3197 |
" 4 ifeq 32\n" + |
3198 |
" 7 iload_1 [i]\n" + |
3199 |
" 8 tableswitch default: 29\n" + |
3200 |
" case 0: 28\n" + |
3201 |
" 28 return\n" + |
3202 |
" 29 goto 37\n" + |
3203 |
" 32 aload_0 [this]\n" + |
3204 |
" 33 invokevirtual X.bool() : boolean [17]\n" + |
3205 |
" 36 pop\n" + |
3206 |
" 37 return\n" + |
3207 |
" Line numbers:\n" + |
3208 |
" [pc: 0, line: 50]\n" + |
3209 |
" [pc: 7, line: 51]\n" + |
3210 |
" [pc: 28, line: 52]\n" + |
3211 |
" [pc: 32, line: 56]\n" + |
3212 |
" [pc: 37, line: 58]\n" + |
3213 |
" Local variable table:\n" + |
3214 |
" [pc: 0, pc: 38] local: this index: 0 type: X\n" + |
3215 |
" [pc: 0, pc: 38] local: i index: 1 type: int\n" |
3216 |
: |
3217 |
" // Method descriptor #6 ()V\n" + |
3218 |
" // Stack: 1, Locals: 2\n" + |
3219 |
" void foo();\n" + |
3220 |
" 0 aload_0 [this]\n" + |
3221 |
" 1 invokevirtual X.bool() : boolean [17]\n" + |
3222 |
" 4 ifeq 9\n" + |
3223 |
" 7 return\n" + |
3224 |
" 8 astore_1\n" + |
3225 |
" 9 return\n" + |
3226 |
" Exception Table:\n" + |
3227 |
" [pc: 0, pc: 7] -> 8 when : java.lang.Exception\n" + |
3228 |
" Line numbers:\n" + |
3229 |
" [pc: 0, line: 5]\n" + |
3230 |
" [pc: 7, line: 6]\n" + |
3231 |
" [pc: 8, line: 8]\n" + |
3232 |
" [pc: 9, line: 10]\n" + |
3233 |
" Local variable table:\n" + |
3234 |
" [pc: 0, pc: 10] local: this index: 0 type: X\n" + |
3235 |
" Stack map table: number of frames 2\n" + |
3236 |
" [pc: 8, same_locals_1_stack_item, stack: {java.lang.Exception}]\n" + |
3237 |
" [pc: 9, same]\n" + |
3238 |
" \n" + |
3239 |
" // Method descriptor #23 ()I\n" + |
3240 |
" // Stack: 1, Locals: 2\n" + |
3241 |
" int foo2();\n" + |
3242 |
" 0 aload_0 [this]\n" + |
3243 |
" 1 invokevirtual X.bool() : boolean [17]\n" + |
3244 |
" 4 ifeq 10\n" + |
3245 |
" 7 iconst_0\n" + |
3246 |
" 8 ireturn\n" + |
3247 |
" 9 astore_1\n" + |
3248 |
" 10 iconst_1\n" + |
3249 |
" 11 ireturn\n" + |
3250 |
" Exception Table:\n" + |
3251 |
" [pc: 0, pc: 7] -> 9 when : java.lang.Exception\n" + |
3252 |
" Line numbers:\n" + |
3253 |
" [pc: 0, line: 13]\n" + |
3254 |
" [pc: 7, line: 14]\n" + |
3255 |
" [pc: 9, line: 16]\n" + |
3256 |
" [pc: 10, line: 18]\n" + |
3257 |
" Local variable table:\n" + |
3258 |
" [pc: 0, pc: 12] local: this index: 0 type: X\n" + |
3259 |
" Stack map table: number of frames 3\n" + |
3260 |
" [pc: 7, same]\n" + |
3261 |
" [pc: 9, same_locals_1_stack_item, stack: {java.lang.Exception}]\n" + |
3262 |
" [pc: 10, same]\n" + |
3263 |
" \n" + |
3264 |
" // Method descriptor #25 ()J\n" + |
3265 |
" // Stack: 2, Locals: 2\n" + |
3266 |
" long foo3();\n" + |
3267 |
" 0 lconst_0\n" + |
3268 |
" 1 lreturn\n" + |
3269 |
" 2 astore_1\n" + |
3270 |
" 3 lconst_1\n" + |
3271 |
" 4 lreturn\n" + |
3272 |
" Line numbers:\n" + |
3273 |
" [pc: 0, line: 23]\n" + |
3274 |
" [pc: 2, line: 25]\n" + |
3275 |
" [pc: 3, line: 27]\n" + |
3276 |
" Local variable table:\n" + |
3277 |
" [pc: 0, pc: 5] local: this index: 0 type: X\n" + |
3278 |
" Stack map table: number of frames 2\n" + |
3279 |
" [pc: 0, same]\n" + |
3280 |
" [pc: 2, same_locals_1_stack_item, stack: {java.lang.Exception}]\n" + |
3281 |
" \n" + |
3282 |
" // Method descriptor #27 ()F\n" + |
3283 |
" // Stack: 1, Locals: 2\n" + |
3284 |
" float foo4();\n" + |
3285 |
" 0 iconst_0\n" + |
3286 |
" 1 istore_1 [i]\n" + |
3287 |
" 2 goto 7\n" + |
3288 |
" 5 fconst_0\n" + |
3289 |
" 6 freturn\n" + |
3290 |
" 7 aload_0 [this]\n" + |
3291 |
" 8 invokevirtual X.bool() : boolean [17]\n" + |
3292 |
" 11 ifne 5\n" + |
3293 |
" 14 goto 18\n" + |
3294 |
" 17 astore_1\n" + |
3295 |
" 18 fconst_1\n" + |
3296 |
" 19 freturn\n" + |
3297 |
" Exception Table:\n" + |
3298 |
" [pc: 0, pc: 5] -> 17 when : java.lang.Exception\n" + |
3299 |
" [pc: 7, pc: 17] -> 17 when : java.lang.Exception\n" + |
3300 |
" Line numbers:\n" + |
3301 |
" [pc: 0, line: 31]\n" + |
3302 |
" [pc: 5, line: 32]\n" + |
3303 |
" [pc: 7, line: 31]\n" + |
3304 |
" [pc: 17, line: 34]\n" + |
3305 |
" [pc: 18, line: 36]\n" + |
3306 |
" Local variable table:\n" + |
3307 |
" [pc: 0, pc: 20] local: this index: 0 type: X\n" + |
3308 |
" [pc: 2, pc: 14] local: i index: 1 type: int\n" + |
3309 |
" Stack map table: number of frames 4\n" + |
3310 |
" [pc: 5, append: {int}]\n" + |
3311 |
" [pc: 7, same]\n" + |
3312 |
" [pc: 17, full, stack: {java.lang.Exception}, locals: {X}]\n" + |
3313 |
" [pc: 18, same]\n" + |
3314 |
" \n" + |
3315 |
" // Method descriptor #31 ()D\n" + |
3316 |
" // Stack: 2, Locals: 1\n" + |
3317 |
" double bar();\n" + |
3318 |
" 0 aload_0 [this]\n" + |
3319 |
" 1 invokevirtual X.bool() : boolean [17]\n" + |
3320 |
" 4 ifeq 16\n" + |
3321 |
" 7 aload_0 [this]\n" + |
3322 |
" 8 invokevirtual X.bool() : boolean [17]\n" + |
3323 |
" 11 ifeq 31\n" + |
3324 |
" 14 dconst_0\n" + |
3325 |
" 15 dreturn\n" + |
3326 |
" 16 aload_0 [this]\n" + |
3327 |
" 17 invokevirtual X.bool() : boolean [17]\n" + |
3328 |
" 20 ifeq 31\n" + |
3329 |
" 23 new java.lang.NullPointerException [32]\n" + |
3330 |
" 26 dup\n" + |
3331 |
" 27 invokespecial java.lang.NullPointerException() [34]\n" + |
3332 |
" 30 athrow\n" + |
3333 |
" 31 dconst_1\n" + |
3334 |
" 32 dreturn\n" + |
3335 |
" Line numbers:\n" + |
3336 |
" [pc: 0, line: 39]\n" + |
3337 |
" [pc: 7, line: 40]\n" + |
3338 |
" [pc: 14, line: 41]\n" + |
3339 |
" [pc: 16, line: 43]\n" + |
3340 |
" [pc: 23, line: 44]\n" + |
3341 |
" [pc: 31, line: 47]\n" + |
3342 |
" Local variable table:\n" + |
3343 |
" [pc: 0, pc: 33] local: this index: 0 type: X\n" + |
3344 |
" Stack map table: number of frames 2\n" + |
3345 |
" [pc: 16, same]\n" + |
3346 |
" [pc: 31, same]\n" + |
3347 |
" \n" + |
3348 |
" // Method descriptor #36 (I)V\n" + |
3349 |
" // Stack: 1, Locals: 2\n" + |
3350 |
" void baz(int i);\n" + |
3351 |
" 0 aload_0 [this]\n" + |
3352 |
" 1 invokevirtual X.bool() : boolean [17]\n" + |
3353 |
" 4 ifeq 32\n" + |
3354 |
" 7 iload_1 [i]\n" + |
3355 |
" 8 tableswitch default: 29\n" + |
3356 |
" case 0: 28\n" + |
3357 |
" 28 return\n" + |
3358 |
" 29 goto 37\n" + |
3359 |
" 32 aload_0 [this]\n" + |
3360 |
" 33 invokevirtual X.bool() : boolean [17]\n" + |
3361 |
" 36 pop\n" + |
3362 |
" 37 return\n" + |
3363 |
" Line numbers:\n" + |
3364 |
" [pc: 0, line: 50]\n" + |
3365 |
" [pc: 7, line: 51]\n" + |
3366 |
" [pc: 28, line: 52]\n" + |
3367 |
" [pc: 32, line: 56]\n" + |
3368 |
" [pc: 37, line: 58]\n" + |
3369 |
" Local variable table:\n" + |
3370 |
" [pc: 0, pc: 38] local: this index: 0 type: X\n" + |
3371 |
" [pc: 0, pc: 38] local: i index: 1 type: int\n" + |
3372 |
" Stack map table: number of frames 4\n" + |
3373 |
" [pc: 28, same]\n" + |
3374 |
" [pc: 29, same]\n" + |
3375 |
" [pc: 32, same]\n" + |
3376 |
" [pc: 37, same]\n"; |
3377 |
try { |
3378 |
File f = new File(OUTPUT_DIR + File.separator + "X.class"); |
3379 |
byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); |
3380 |
ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); |
3381 |
String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); |
3382 |
int index = result.indexOf(expectedOutput); |
3383 |
if (index == -1 || expectedOutput.length() == 0) { |
3384 |
System.out.println(Util.displayString(result, 3)); |
3385 |
} |
3386 |
if (index == -1) { |
3387 |
assertEquals("Wrong contents", expectedOutput, result); |
3388 |
} |
3389 |
} catch (org.eclipse.jdt.core.util.ClassFormatException e) { |
3390 |
assertTrue(false); |
3391 |
} catch (IOException e) { |
3392 |
assertTrue(false); |
3393 |
} |
3394 |
} |
3395 |
|
3396 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=114894 - variation |
3397 |
public void test049() { |
3398 |
this.runConformTest( |
3399 |
new String[] { |
3400 |
"X.java", |
3401 |
"public class X {\n" + |
3402 |
" boolean bool() { return true; }\n" + |
3403 |
" void foo() {\n" + |
3404 |
" try {\n" + |
3405 |
" if (bool()) {\n" + |
3406 |
" throw new NullPointerException();\n" + |
3407 |
" }\n" + |
3408 |
" } catch (Exception e) {\n" + |
3409 |
" }\n" + |
3410 |
" }\n" + |
3411 |
" void foo2() {\n" + |
3412 |
" try {\n" + |
3413 |
" while (bool()) {\n" + |
3414 |
" throw new NullPointerException();\n" + |
3415 |
" }\n" + |
3416 |
" } catch (Exception e) {\n" + |
3417 |
" }\n" + |
3418 |
" }\n" + |
3419 |
" void foo3() {\n" + |
3420 |
" try {\n" + |
3421 |
" do {\n" + |
3422 |
" if (true) throw new NullPointerException();\n" + |
3423 |
" } while (bool());\n" + |
3424 |
" } catch (Exception e) {\n" + |
3425 |
" }\n" + |
3426 |
" } \n" + |
3427 |
" void foo4() {\n" + |
3428 |
" try {\n" + |
3429 |
" for (int i = 0; bool(); i++) {\n" + |
3430 |
" throw new NullPointerException();\n" + |
3431 |
" }\n" + |
3432 |
" } catch (Exception e) {\n" + |
3433 |
" }\n" + |
3434 |
" } \n" + |
3435 |
" void bar() {\n" + |
3436 |
" if (bool()) {\n" + |
3437 |
" if (bool())\n" + |
3438 |
" throw new NullPointerException();\n" + |
3439 |
" } else {\n" + |
3440 |
" if (bool()) {\n" + |
3441 |
" throw new NullPointerException();\n" + |
3442 |
" }\n" + |
3443 |
" }\n" + |
3444 |
" }\n" + |
3445 |
" void baz(int i) {\n" + |
3446 |
" if (bool()) {\n" + |
3447 |
" switch(i) {\n" + |
3448 |
" case 0 : throw new NullPointerException();\n" + |
3449 |
" default : break;\n" + |
3450 |
" }\n" + |
3451 |
" } else {\n" + |
3452 |
" bool();\n" + |
3453 |
" }\n" + |
3454 |
" }\n" + |
3455 |
"}\n", |
3456 |
}, |
3457 |
""); |
3458 |
|
3459 |
String expectedOutput = new CompilerOptions(this.getCompilerOptions()).complianceLevel < ClassFileConstants.JDK1_6 |
3460 |
? " // Method descriptor #6 ()V\n" + |
3461 |
" // Stack: 2, Locals: 2\n" + |
3462 |
" void foo();\n" + |
3463 |
" 0 aload_0 [this]\n" + |
3464 |
" 1 invokevirtual X.bool() : boolean [17]\n" + |
3465 |
" 4 ifeq 16\n" + |
3466 |
" 7 new java.lang.NullPointerException [19]\n" + |
3467 |
" 10 dup\n" + |
3468 |
" 11 invokespecial java.lang.NullPointerException() [21]\n" + |
3469 |
" 14 athrow\n" + |
3470 |
" 15 astore_1\n" + |
3471 |
" 16 return\n" + |
3472 |
" Exception Table:\n" + |
3473 |
" [pc: 0, pc: 15] -> 15 when : java.lang.Exception\n" + |
3474 |
" Line numbers:\n" + |
3475 |
" [pc: 0, line: 5]\n" + |
3476 |
" [pc: 7, line: 6]\n" + |
3477 |
" [pc: 15, line: 8]\n" + |
3478 |
" [pc: 16, line: 10]\n" + |
3479 |
" Local variable table:\n" + |
3480 |
" [pc: 0, pc: 17] local: this index: 0 type: X\n" + |
3481 |
" \n" + |
3482 |
" // Method descriptor #6 ()V\n" + |
3483 |
" // Stack: 2, Locals: 2\n" + |
3484 |
" void foo2();\n" + |
3485 |
" 0 aload_0 [this]\n" + |
3486 |
" 1 invokevirtual X.bool() : boolean [17]\n" + |
3487 |
" 4 ifeq 16\n" + |
3488 |
" 7 new java.lang.NullPointerException [19]\n" + |
3489 |
" 10 dup\n" + |
3490 |
" 11 invokespecial java.lang.NullPointerException() [21]\n" + |
3491 |
" 14 athrow\n" + |
3492 |
" 15 astore_1\n" + |
3493 |
" 16 return\n" + |
3494 |
" Exception Table:\n" + |
3495 |
" [pc: 0, pc: 15] -> 15 when : java.lang.Exception\n" + |
3496 |
" Line numbers:\n" + |
3497 |
" [pc: 0, line: 13]\n" + |
3498 |
" [pc: 7, line: 14]\n" + |
3499 |
" [pc: 15, line: 16]\n" + |
3500 |
" [pc: 16, line: 18]\n" + |
3501 |
" Local variable table:\n" + |
3502 |
" [pc: 0, pc: 17] local: this index: 0 type: X\n" + |
3503 |
" \n" + |
3504 |
" // Method descriptor #6 ()V\n" + |
3505 |
" // Stack: 2, Locals: 2\n" + |
3506 |
" void foo3();\n" + |
3507 |
" 0 new java.lang.NullPointerException [19]\n" + |
3508 |
" 3 dup\n" + |
3509 |
" 4 invokespecial java.lang.NullPointerException() [21]\n" + |
3510 |
" 7 athrow\n" + |
3511 |
" 8 astore_1\n" + |
3512 |
" 9 return\n" + |
3513 |
" Exception Table:\n" + |
3514 |
" [pc: 0, pc: 8] -> 8 when : java.lang.Exception\n" + |
3515 |
" Line numbers:\n" + |
3516 |
" [pc: 0, line: 22]\n" + |
3517 |
" [pc: 8, line: 24]\n" + |
3518 |
" [pc: 9, line: 26]\n" + |
3519 |
" Local variable table:\n" + |
3520 |
" [pc: 0, pc: 10] local: this index: 0 type: X\n" + |
3521 |
" \n" + |
3522 |
" // Method descriptor #6 ()V\n" + |
3523 |
" // Stack: 2, Locals: 2\n" + |
3524 |
" void foo4();\n" + |
3525 |
" 0 iconst_0\n" + |
3526 |
" 1 istore_1 [i]\n" + |
3527 |
" 2 goto 13\n" + |
3528 |
" 5 new java.lang.NullPointerException [19]\n" + |
3529 |
" 8 dup\n" + |
3530 |
" 9 invokespecial java.lang.NullPointerException() [21]\n" + |
3531 |
" 12 athrow\n" + |
3532 |
" 13 aload_0 [this]\n" + |
3533 |
" 14 invokevirtual X.bool() : boolean [17]\n" + |
3534 |
" 17 ifne 5\n" + |
3535 |
" 20 goto 24\n" + |
3536 |
" 23 astore_1\n" + |
3537 |
" 24 return\n" + |
3538 |
" Exception Table:\n" + |
3539 |
" [pc: 0, pc: 23] -> 23 when : java.lang.Exception\n" + |
3540 |
" Line numbers:\n" + |
3541 |
" [pc: 0, line: 29]\n" + |
3542 |
" [pc: 5, line: 30]\n" + |
3543 |
" [pc: 13, line: 29]\n" + |
3544 |
" [pc: 23, line: 32]\n" + |
3545 |
" [pc: 24, line: 34]\n" + |
3546 |
" Local variable table:\n" + |
3547 |
" [pc: 0, pc: 25] local: this index: 0 type: X\n" + |
3548 |
" [pc: 2, pc: 20] local: i index: 1 type: int\n" + |
3549 |
" \n" + |
3550 |
" // Method descriptor #6 ()V\n" + |
3551 |
" // Stack: 2, Locals: 1\n" + |
3552 |
" void bar();\n" + |
3553 |
" 0 aload_0 [this]\n" + |
3554 |
" 1 invokevirtual X.bool() : boolean [17]\n" + |
3555 |
" 4 ifeq 22\n" + |
3556 |
" 7 aload_0 [this]\n" + |
3557 |
" 8 invokevirtual X.bool() : boolean [17]\n" + |
3558 |
" 11 ifeq 37\n" + |
3559 |
" 14 new java.lang.NullPointerException [19]\n" + |
3560 |
" 17 dup\n" + |
3561 |
" 18 invokespecial java.lang.NullPointerException() [21]\n" + |
3562 |
" 21 athrow\n" + |
3563 |
" 22 aload_0 [this]\n" + |
3564 |
" 23 invokevirtual X.bool() : boolean [17]\n" + |
3565 |
" 26 ifeq 37\n" + |
3566 |
" 29 new java.lang.NullPointerException [19]\n" + |
3567 |
" 32 dup\n" + |
3568 |
" 33 invokespecial java.lang.NullPointerException() [21]\n" + |
3569 |
" 36 athrow\n" + |
3570 |
" 37 return\n" + |
3571 |
" Line numbers:\n" + |
3572 |
" [pc: 0, line: 36]\n" + |
3573 |
" [pc: 7, line: 37]\n" + |
3574 |
" [pc: 14, line: 38]\n" + |
3575 |
" [pc: 22, line: 40]\n" + |
3576 |
" [pc: 29, line: 41]\n" + |
3577 |
" [pc: 37, line: 44]\n" + |
3578 |
" Local variable table:\n" + |
3579 |
" [pc: 0, pc: 38] local: this index: 0 type: X\n" + |
3580 |
" \n" + |
3581 |
" // Method descriptor #31 (I)V\n" + |
3582 |
" // Stack: 2, Locals: 2\n" + |
3583 |
" void baz(int i);\n" + |
3584 |
" 0 aload_0 [this]\n" + |
3585 |
" 1 invokevirtual X.bool() : boolean [17]\n" + |
3586 |
" 4 ifeq 39\n" + |
3587 |
" 7 iload_1 [i]\n" + |
3588 |
" 8 tableswitch default: 36\n" + |
3589 |
" case 0: 28\n" + |
3590 |
" 28 new java.lang.NullPointerException [19]\n" + |
3591 |
" 31 dup\n" + |
3592 |
" 32 invokespecial java.lang.NullPointerException() [21]\n" + |
3593 |
" 35 athrow\n" + |
3594 |
" 36 goto 44\n" + |
3595 |
" 39 aload_0 [this]\n" + |
3596 |
" 40 invokevirtual X.bool() : boolean [17]\n" + |
3597 |
" 43 pop\n" + |
3598 |
" 44 return\n" + |
3599 |
" Line numbers:\n" + |
3600 |
" [pc: 0, line: 46]\n" + |
3601 |
" [pc: 7, line: 47]\n" + |
3602 |
" [pc: 28, line: 48]\n" + |
3603 |
" [pc: 39, line: 52]\n" + |
3604 |
" [pc: 44, line: 54]\n" + |
3605 |
" Local variable table:\n" + |
3606 |
" [pc: 0, pc: 45] local: this index: 0 type: X\n" + |
3607 |
" [pc: 0, pc: 45] local: i index: 1 type: int\n" |
3608 |
: |
3609 |
" // Method descriptor #6 ()V\n" + |
3610 |
" // Stack: 2, Locals: 2\n" + |
3611 |
" void foo();\n" + |
3612 |
" 0 aload_0 [this]\n" + |
3613 |
" 1 invokevirtual X.bool() : boolean [17]\n" + |
3614 |
" 4 ifeq 16\n" + |
3615 |
" 7 new java.lang.NullPointerException [19]\n" + |
3616 |
" 10 dup\n" + |
3617 |
" 11 invokespecial java.lang.NullPointerException() [21]\n" + |
3618 |
" 14 athrow\n" + |
3619 |
" 15 astore_1\n" + |
3620 |
" 16 return\n" + |
3621 |
" Exception Table:\n" + |
3622 |
" [pc: 0, pc: 15] -> 15 when : java.lang.Exception\n" + |
3623 |
" Line numbers:\n" + |
3624 |
" [pc: 0, line: 5]\n" + |
3625 |
" [pc: 7, line: 6]\n" + |
3626 |
" [pc: 15, line: 8]\n" + |
3627 |
" [pc: 16, line: 10]\n" + |
3628 |
" Local variable table:\n" + |
3629 |
" [pc: 0, pc: 17] local: this index: 0 type: X\n" + |
3630 |
" Stack map table: number of frames 2\n" + |
3631 |
" [pc: 15, same_locals_1_stack_item, stack: {java.lang.Exception}]\n" + |
3632 |
" [pc: 16, same]\n" + |
3633 |
" \n" + |
3634 |
" // Method descriptor #6 ()V\n" + |
3635 |
" // Stack: 2, Locals: 2\n" + |
3636 |
" void foo2();\n" + |
3637 |
" 0 aload_0 [this]\n" + |
3638 |
" 1 invokevirtual X.bool() : boolean [17]\n" + |
3639 |
" 4 ifeq 16\n" + |
3640 |
" 7 new java.lang.NullPointerException [19]\n" + |
3641 |
" 10 dup\n" + |
3642 |
" 11 invokespecial java.lang.NullPointerException() [21]\n" + |
3643 |
" 14 athrow\n" + |
3644 |
" 15 astore_1\n" + |
3645 |
" 16 return\n" + |
3646 |
" Exception Table:\n" + |
3647 |
" [pc: 0, pc: 15] -> 15 when : java.lang.Exception\n" + |
3648 |
" Line numbers:\n" + |
3649 |
" [pc: 0, line: 13]\n" + |
3650 |
" [pc: 7, line: 14]\n" + |
3651 |
" [pc: 15, line: 16]\n" + |
3652 |
" [pc: 16, line: 18]\n" + |
3653 |
" Local variable table:\n" + |
3654 |
" [pc: 0, pc: 17] local: this index: 0 type: X\n" + |
3655 |
" Stack map table: number of frames 3\n" + |
3656 |
" [pc: 7, same]\n" + |
3657 |
" [pc: 15, same_locals_1_stack_item, stack: {java.lang.Exception}]\n" + |
3658 |
" [pc: 16, same]\n" + |
3659 |
" \n" + |
3660 |
" // Method descriptor #6 ()V\n" + |
3661 |
" // Stack: 2, Locals: 2\n" + |
3662 |
" void foo3();\n" + |
3663 |
" 0 new java.lang.NullPointerException [19]\n" + |
3664 |
" 3 dup\n" + |
3665 |
" 4 invokespecial java.lang.NullPointerException() [21]\n" + |
3666 |
" 7 athrow\n" + |
3667 |
" 8 astore_1\n" + |
3668 |
" 9 return\n" + |
3669 |
" Exception Table:\n" + |
3670 |
" [pc: 0, pc: 8] -> 8 when : java.lang.Exception\n" + |
3671 |
" Line numbers:\n" + |
3672 |
" [pc: 0, line: 22]\n" + |
3673 |
" [pc: 8, line: 24]\n" + |
3674 |
" [pc: 9, line: 26]\n" + |
3675 |
" Local variable table:\n" + |
3676 |
" [pc: 0, pc: 10] local: this index: 0 type: X\n" + |
3677 |
" Stack map table: number of frames 2\n" + |
3678 |
" [pc: 0, same]\n" + |
3679 |
" [pc: 8, same_locals_1_stack_item, stack: {java.lang.Exception}]\n" + |
3680 |
" \n" + |
3681 |
" // Method descriptor #6 ()V\n" + |
3682 |
" // Stack: 2, Locals: 2\n" + |
3683 |
" void foo4();\n" + |
3684 |
" 0 iconst_0\n" + |
3685 |
" 1 istore_1 [i]\n" + |
3686 |
" 2 goto 13\n" + |
3687 |
" 5 new java.lang.NullPointerException [19]\n" + |
3688 |
" 8 dup\n" + |
3689 |
" 9 invokespecial java.lang.NullPointerException() [21]\n" + |
3690 |
" 12 athrow\n" + |
3691 |
" 13 aload_0 [this]\n" + |
3692 |
" 14 invokevirtual X.bool() : boolean [17]\n" + |
3693 |
" 17 ifne 5\n" + |
3694 |
" 20 goto 24\n" + |
3695 |
" 23 astore_1\n" + |
3696 |
" 24 return\n" + |
3697 |
" Exception Table:\n" + |
3698 |
" [pc: 0, pc: 23] -> 23 when : java.lang.Exception\n" + |
3699 |
" Line numbers:\n" + |
3700 |
" [pc: 0, line: 29]\n" + |
3701 |
" [pc: 5, line: 30]\n" + |
3702 |
" [pc: 13, line: 29]\n" + |
3703 |
" [pc: 23, line: 32]\n" + |
3704 |
" [pc: 24, line: 34]\n" + |
3705 |
" Local variable table:\n" + |
3706 |
" [pc: 0, pc: 25] local: this index: 0 type: X\n" + |
3707 |
" [pc: 2, pc: 20] local: i index: 1 type: int\n" + |
3708 |
" Stack map table: number of frames 4\n" + |
3709 |
" [pc: 5, append: {int}]\n" + |
3710 |
" [pc: 13, same]\n" + |
3711 |
" [pc: 23, full, stack: {java.lang.Exception}, locals: {X}]\n" + |
3712 |
" [pc: 24, same]\n" + |
3713 |
" \n" + |
3714 |
" // Method descriptor #6 ()V\n" + |
3715 |
" // Stack: 2, Locals: 1\n" + |
3716 |
" void bar();\n" + |
3717 |
" 0 aload_0 [this]\n" + |
3718 |
" 1 invokevirtual X.bool() : boolean [17]\n" + |
3719 |
" 4 ifeq 22\n" + |
3720 |
" 7 aload_0 [this]\n" + |
3721 |
" 8 invokevirtual X.bool() : boolean [17]\n" + |
3722 |
" 11 ifeq 37\n" + |
3723 |
" 14 new java.lang.NullPointerException [19]\n" + |
3724 |
" 17 dup\n" + |
3725 |
" 18 invokespecial java.lang.NullPointerException() [21]\n" + |
3726 |
" 21 athrow\n" + |
3727 |
" 22 aload_0 [this]\n" + |
3728 |
" 23 invokevirtual X.bool() : boolean [17]\n" + |
3729 |
" 26 ifeq 37\n" + |
3730 |
" 29 new java.lang.NullPointerException [19]\n" + |
3731 |
" 32 dup\n" + |
3732 |
" 33 invokespecial java.lang.NullPointerException() [21]\n" + |
3733 |
" 36 athrow\n" + |
3734 |
" 37 return\n" + |
3735 |
" Line numbers:\n" + |
3736 |
" [pc: 0, line: 36]\n" + |
3737 |
" [pc: 7, line: 37]\n" + |
3738 |
" [pc: 14, line: 38]\n" + |
3739 |
" [pc: 22, line: 40]\n" + |
3740 |
" [pc: 29, line: 41]\n" + |
3741 |
" [pc: 37, line: 44]\n" + |
3742 |
" Local variable table:\n" + |
3743 |
" [pc: 0, pc: 38] local: this index: 0 type: X\n" + |
3744 |
" Stack map table: number of frames 2\n" + |
3745 |
" [pc: 22, same]\n" + |
3746 |
" [pc: 37, same]\n" + |
3747 |
" \n" + |
3748 |
" // Method descriptor #32 (I)V\n" + |
3749 |
" // Stack: 2, Locals: 2\n" + |
3750 |
" void baz(int i);\n" + |
3751 |
" 0 aload_0 [this]\n" + |
3752 |
" 1 invokevirtual X.bool() : boolean [17]\n" + |
3753 |
" 4 ifeq 39\n" + |
3754 |
" 7 iload_1 [i]\n" + |
3755 |
" 8 tableswitch default: 36\n" + |
3756 |
" case 0: 28\n" + |
3757 |
" 28 new java.lang.NullPointerException [19]\n" + |
3758 |
" 31 dup\n" + |
3759 |
" 32 invokespecial java.lang.NullPointerException() [21]\n" + |
3760 |
" 35 athrow\n" + |
3761 |
" 36 goto 44\n" + |
3762 |
" 39 aload_0 [this]\n" + |
3763 |
" 40 invokevirtual X.bool() : boolean [17]\n" + |
3764 |
" 43 pop\n" + |
3765 |
" 44 return\n" + |
3766 |
" Line numbers:\n" + |
3767 |
" [pc: 0, line: 46]\n" + |
3768 |
" [pc: 7, line: 47]\n" + |
3769 |
" [pc: 28, line: 48]\n" + |
3770 |
" [pc: 39, line: 52]\n" + |
3771 |
" [pc: 44, line: 54]\n" + |
3772 |
" Local variable table:\n" + |
3773 |
" [pc: 0, pc: 45] local: this index: 0 type: X\n" + |
3774 |
" [pc: 0, pc: 45] local: i index: 1 type: int\n" + |
3775 |
" Stack map table: number of frames 4\n" + |
3776 |
" [pc: 28, same]\n" + |
3777 |
" [pc: 36, same]\n" + |
3778 |
" [pc: 39, same]\n" + |
3779 |
" [pc: 44, same]\n"; |
3780 |
try { |
3781 |
File f = new File(OUTPUT_DIR + File.separator + "X.class"); |
3782 |
byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); |
3783 |
ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); |
3784 |
String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); |
3785 |
int index = result.indexOf(expectedOutput); |
3786 |
if (index == -1 || expectedOutput.length() == 0) { |
3787 |
System.out.println(Util.displayString(result, 3)); |
3788 |
} |
3789 |
if (index == -1) { |
3790 |
assertEquals("Wrong contents", expectedOutput, result); |
3791 |
} |
3792 |
} catch (org.eclipse.jdt.core.util.ClassFormatException e) { |
3793 |
assertTrue(false); |
3794 |
} catch (IOException e) { |
3795 |
assertTrue(false); |
3796 |
} |
3797 |
} |
3798 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=114894 - variation |
3799 |
public void test050() { |
3800 |
this.runConformTest( |
3801 |
new String[] { |
3802 |
"X.java", |
3803 |
"public class X {\n" + |
3804 |
" boolean bool() { return true; }\n" + |
3805 |
" void foo() {\n" + |
3806 |
" check: try {\n" + |
3807 |
" if (bool()) {\n" + |
3808 |
" break check;\n" + |
3809 |
" }\n" + |
3810 |
" } catch (Exception e) {\n" + |
3811 |
" }\n" + |
3812 |
" }\n" + |
3813 |
" void foo2() {\n" + |
3814 |
" check: try {\n" + |
3815 |
" while (bool()) {\n" + |
3816 |
" break check;\n" + |
3817 |
" }\n" + |
3818 |
" } catch (Exception e) {\n" + |
3819 |
" }\n" + |
3820 |
" }\n" + |
3821 |
" void foo3() {\n" + |
3822 |
" check: try {\n" + |
3823 |
" do {\n" + |
3824 |
" if (true) break check;\n" + |
3825 |
" } while (bool());\n" + |
3826 |
" } catch (Exception e) {\n" + |
3827 |
" }\n" + |
3828 |
" } \n" + |
3829 |
" void foo4() {\n" + |
3830 |
" check: try {\n" + |
3831 |
" for (int i = 0; bool(); i++) {\n" + |
3832 |
" break check;\n" + |
3833 |
" }\n" + |
3834 |
" } catch (Exception e) {\n" + |
3835 |
" }\n" + |
3836 |
" } \n" + |
3837 |
" void bar() {\n" + |
3838 |
" check: if (bool()) {\n" + |
3839 |
" if (bool())\n" + |
3840 |
" break check;\n" + |
3841 |
" } else {\n" + |
3842 |
" if (bool()) {\n" + |
3843 |
" break check;\n" + |
3844 |
" }\n" + |
3845 |
" }\n" + |
3846 |
" }\n" + |
3847 |
" void baz(int i) {\n" + |
3848 |
" check: if (bool()) {\n" + |
3849 |
" switch(i) {\n" + |
3850 |
" case 0 : break check;\n" + |
3851 |
" default : break;\n" + |
3852 |
" }\n" + |
3853 |
" } else {\n" + |
3854 |
" bool();\n" + |
3855 |
" }\n" + |
3856 |
" }\n" + |
3857 |
"}\n", |
3858 |
}, |
3859 |
""); |
3860 |
|
3861 |
String expectedOutput = new CompilerOptions(this.getCompilerOptions()).complianceLevel < ClassFileConstants.JDK1_6 |
3862 |
? " // Method descriptor #6 ()V\n" + |
3863 |
" // Stack: 1, Locals: 2\n" + |
3864 |
" void foo();\n" + |
3865 |
" 0 aload_0 [this]\n" + |
3866 |
" 1 invokevirtual X.bool() : boolean [17]\n" + |
3867 |
" 4 ifeq 11\n" + |
3868 |
" 7 goto 11\n" + |
3869 |
" 10 astore_1\n" + |
3870 |
" 11 return\n" + |
3871 |
" Exception Table:\n" + |
3872 |
" [pc: 0, pc: 7] -> 10 when : java.lang.Exception\n" + |
3873 |
" Line numbers:\n" + |
3874 |
" [pc: 0, line: 5]\n" + |
3875 |
" [pc: 7, line: 6]\n" + |
3876 |
" [pc: 10, line: 8]\n" + |
3877 |
" [pc: 11, line: 10]\n" + |
3878 |
" Local variable table:\n" + |
3879 |
" [pc: 0, pc: 12] local: this index: 0 type: X\n" + |
3880 |
" \n" + |
3881 |
" // Method descriptor #6 ()V\n" + |
3882 |
" // Stack: 1, Locals: 2\n" + |
3883 |
" void foo2();\n" + |
3884 |
" 0 aload_0 [this]\n" + |
3885 |
" 1 invokevirtual X.bool() : boolean [17]\n" + |
3886 |
" 4 ifeq 11\n" + |
3887 |
" 7 goto 11\n" + |
3888 |
" 10 astore_1\n" + |
3889 |
" 11 return\n" + |
3890 |
" Exception Table:\n" + |
3891 |
" [pc: 0, pc: 7] -> 10 when : java.lang.Exception\n" + |
3892 |
" Line numbers:\n" + |
3893 |
" [pc: 0, line: 13]\n" + |
3894 |
" [pc: 7, line: 14]\n" + |
3895 |
" [pc: 10, line: 16]\n" + |
3896 |
" [pc: 11, line: 18]\n" + |
3897 |
" Local variable table:\n" + |
3898 |
" [pc: 0, pc: 12] local: this index: 0 type: X\n" + |
3899 |
" \n" + |
3900 |
" // Method descriptor #6 ()V\n" + |
3901 |
" // Stack: 1, Locals: 2\n" + |
3902 |
" void foo3();\n" + |
3903 |
" 0 goto 4\n" + |
3904 |
" 3 astore_1\n" + |
3905 |
" 4 return\n" + |
3906 |
" Line numbers:\n" + |
3907 |
" [pc: 0, line: 22]\n" + |
3908 |
" [pc: 3, line: 24]\n" + |
3909 |
" [pc: 4, line: 26]\n" + |
3910 |
" Local variable table:\n" + |
3911 |
" [pc: 0, pc: 5] local: this index: 0 type: X\n" + |
3912 |
" \n" + |
3913 |
" // Method descriptor #6 ()V\n" + |
3914 |
" // Stack: 1, Locals: 2\n" + |
3915 |
" void foo4();\n" + |
3916 |
" 0 iconst_0\n" + |
3917 |
" 1 istore_1 [i]\n" + |
3918 |
" 2 aload_0 [this]\n" + |
3919 |
" 3 invokevirtual X.bool() : boolean [17]\n" + |
3920 |
" 6 ifne 13\n" + |
3921 |
" 9 goto 13\n" + |
3922 |
" 12 astore_1\n" + |
3923 |
" 13 return\n" + |
3924 |
" Exception Table:\n" + |
3925 |
" [pc: 0, pc: 12] -> 12 when : java.lang.Exception\n" + |
3926 |
" Line numbers:\n" + |
3927 |
" [pc: 0, line: 29]\n" + |
3928 |
" [pc: 12, line: 32]\n" + |
3929 |
" [pc: 13, line: 34]\n" + |
3930 |
" Local variable table:\n" + |
3931 |
" [pc: 0, pc: 14] local: this index: 0 type: X\n" + |
3932 |
" [pc: 2, pc: 9] local: i index: 1 type: int\n" + |
3933 |
" \n" + |
3934 |
" // Method descriptor #6 ()V\n" + |
3935 |
" // Stack: 1, Locals: 1\n" + |
3936 |
" void bar();\n" + |
3937 |
" 0 aload_0 [this]\n" + |
3938 |
" 1 invokevirtual X.bool() : boolean [17]\n" + |
3939 |
" 4 ifeq 17\n" + |
3940 |
" 7 aload_0 [this]\n" + |
3941 |
" 8 invokevirtual X.bool() : boolean [17]\n" + |
3942 |
" 11 ifeq 24\n" + |
3943 |
" 14 goto 24\n" + |
3944 |
" 17 aload_0 [this]\n" + |
3945 |
" 18 invokevirtual X.bool() : boolean [17]\n" + |
3946 |
" 21 ifeq 24\n" + |
3947 |
" 24 return\n" + |
3948 |
" Line numbers:\n" + |
3949 |
" [pc: 0, line: 36]\n" + |
3950 |
" [pc: 7, line: 37]\n" + |
3951 |
" [pc: 14, line: 38]\n" + |
3952 |
" [pc: 17, line: 40]\n" + |
3953 |
" [pc: 24, line: 44]\n" + |
3954 |
" Local variable table:\n" + |
3955 |
" [pc: 0, pc: 25] local: this index: 0 type: X\n" + |
3956 |
" \n" + |
3957 |
" // Method descriptor #28 (I)V\n" + |
3958 |
" // Stack: 1, Locals: 2\n" + |
3959 |
" void baz(int i);\n" + |
3960 |
" 0 aload_0 [this]\n" + |
3961 |
" 1 invokevirtual X.bool() : boolean [17]\n" + |
3962 |
" 4 ifeq 34\n" + |
3963 |
" 7 iload_1 [i]\n" + |
3964 |
" 8 tableswitch default: 31\n" + |
3965 |
" case 0: 28\n" + |
3966 |
" 28 goto 39\n" + |
3967 |
" 31 goto 39\n" + |
3968 |
" 34 aload_0 [this]\n" + |
3969 |
" 35 invokevirtual X.bool() : boolean [17]\n" + |
3970 |
" 38 pop\n" + |
3971 |
" 39 return\n" + |
3972 |
" Line numbers:\n" + |
3973 |
" [pc: 0, line: 46]\n" + |
3974 |
" [pc: 7, line: 47]\n" + |
3975 |
" [pc: 28, line: 48]\n" + |
3976 |
" [pc: 34, line: 52]\n" + |
3977 |
" [pc: 39, line: 54]\n" + |
3978 |
" Local variable table:\n" + |
3979 |
" [pc: 0, pc: 40] local: this index: 0 type: X\n" + |
3980 |
" [pc: 0, pc: 40] local: i index: 1 type: int\n" |
3981 |
: |
3982 |
" // Method descriptor #6 ()V\n" + |
3983 |
" // Stack: 1, Locals: 2\n" + |
3984 |
" void foo();\n" + |
3985 |
" 0 aload_0 [this]\n" + |
3986 |
" 1 invokevirtual X.bool() : boolean [17]\n" + |
3987 |
" 4 ifeq 11\n" + |
3988 |
" 7 goto 11\n" + |
3989 |
" 10 astore_1\n" + |
3990 |
" 11 return\n" + |
3991 |
" Exception Table:\n" + |
3992 |
" [pc: 0, pc: 7] -> 10 when : java.lang.Exception\n" + |
3993 |
" Line numbers:\n" + |
3994 |
" [pc: 0, line: 5]\n" + |
3995 |
" [pc: 7, line: 6]\n" + |
3996 |
" [pc: 10, line: 8]\n" + |
3997 |
" [pc: 11, line: 10]\n" + |
3998 |
" Local variable table:\n" + |
3999 |
" [pc: 0, pc: 12] local: this index: 0 type: X\n" + |
4000 |
" Stack map table: number of frames 2\n" + |
4001 |
" [pc: 10, same_locals_1_stack_item, stack: {java.lang.Exception}]\n" + |
4002 |
" [pc: 11, same]\n" + |
4003 |
" \n" + |
4004 |
" // Method descriptor #6 ()V\n" + |
4005 |
" // Stack: 1, Locals: 2\n" + |
4006 |
" void foo2();\n" + |
4007 |
" 0 aload_0 [this]\n" + |
4008 |
" 1 invokevirtual X.bool() : boolean [17]\n" + |
4009 |
" 4 ifeq 11\n" + |
4010 |
" 7 goto 11\n" + |
4011 |
" 10 astore_1\n" + |
4012 |
" 11 return\n" + |
4013 |
" Exception Table:\n" + |
4014 |
" [pc: 0, pc: 7] -> 10 when : java.lang.Exception\n" + |
4015 |
" Line numbers:\n" + |
4016 |
" [pc: 0, line: 13]\n" + |
4017 |
" [pc: 7, line: 14]\n" + |
4018 |
" [pc: 10, line: 16]\n" + |
4019 |
" [pc: 11, line: 18]\n" + |
4020 |
" Local variable table:\n" + |
4021 |
" [pc: 0, pc: 12] local: this index: 0 type: X\n" + |
4022 |
" Stack map table: number of frames 3\n" + |
4023 |
" [pc: 7, same]\n" + |
4024 |
" [pc: 10, same_locals_1_stack_item, stack: {java.lang.Exception}]\n" + |
4025 |
" [pc: 11, same]\n" + |
4026 |
" \n" + |
4027 |
" // Method descriptor #6 ()V\n" + |
4028 |
" // Stack: 1, Locals: 2\n" + |
4029 |
" void foo3();\n" + |
4030 |
" 0 goto 4\n" + |
4031 |
" 3 astore_1\n" + |
4032 |
" 4 return\n" + |
4033 |
" Line numbers:\n" + |
4034 |
" [pc: 0, line: 22]\n" + |
4035 |
" [pc: 3, line: 24]\n" + |
4036 |
" [pc: 4, line: 26]\n" + |
4037 |
" Local variable table:\n" + |
4038 |
" [pc: 0, pc: 5] local: this index: 0 type: X\n" + |
4039 |
" Stack map table: number of frames 3\n" + |
4040 |
" [pc: 0, same]\n" + |
4041 |
" [pc: 3, same_locals_1_stack_item, stack: {java.lang.Exception}]\n" + |
4042 |
" [pc: 4, same]\n" + |
4043 |
" \n" + |
4044 |
" // Method descriptor #6 ()V\n" + |
4045 |
" // Stack: 1, Locals: 2\n" + |
4046 |
" void foo4();\n" + |
4047 |
" 0 iconst_0\n" + |
4048 |
" 1 istore_1 [i]\n" + |
4049 |
" 2 aload_0 [this]\n" + |
4050 |
" 3 invokevirtual X.bool() : boolean [17]\n" + |
4051 |
" 6 ifne 13\n" + |
4052 |
" 9 goto 13\n" + |
4053 |
" 12 astore_1\n" + |
4054 |
" 13 return\n" + |
4055 |
" Exception Table:\n" + |
4056 |
" [pc: 0, pc: 12] -> 12 when : java.lang.Exception\n" + |
4057 |
" Line numbers:\n" + |
4058 |
" [pc: 0, line: 29]\n" + |
4059 |
" [pc: 12, line: 32]\n" + |
4060 |
" [pc: 13, line: 34]\n" + |
4061 |
" Local variable table:\n" + |
4062 |
" [pc: 0, pc: 14] local: this index: 0 type: X\n" + |
4063 |
" [pc: 2, pc: 9] local: i index: 1 type: int\n" + |
4064 |
" Stack map table: number of frames 3\n" + |
4065 |
" [pc: 2, append: {int}]\n" + |
4066 |
" [pc: 12, full, stack: {java.lang.Exception}, locals: {X}]\n" + |
4067 |
" [pc: 13, same]\n" + |
4068 |
" \n" + |
4069 |
" // Method descriptor #6 ()V\n" + |
4070 |
" // Stack: 1, Locals: 1\n" + |
4071 |
" void bar();\n" + |
4072 |
" 0 aload_0 [this]\n" + |
4073 |
" 1 invokevirtual X.bool() : boolean [17]\n" + |
4074 |
" 4 ifeq 17\n" + |
4075 |
" 7 aload_0 [this]\n" + |
4076 |
" 8 invokevirtual X.bool() : boolean [17]\n" + |
4077 |
" 11 ifeq 24\n" + |
4078 |
" 14 goto 24\n" + |
4079 |
" 17 aload_0 [this]\n" + |
4080 |
" 18 invokevirtual X.bool() : boolean [17]\n" + |
4081 |
" 21 ifeq 24\n" + |
4082 |
" 24 return\n" + |
4083 |
" Line numbers:\n" + |
4084 |
" [pc: 0, line: 36]\n" + |
4085 |
" [pc: 7, line: 37]\n" + |
4086 |
" [pc: 14, line: 38]\n" + |
4087 |
" [pc: 17, line: 40]\n" + |
4088 |
" [pc: 24, line: 44]\n" + |
4089 |
" Local variable table:\n" + |
4090 |
" [pc: 0, pc: 25] local: this index: 0 type: X\n" + |
4091 |
" Stack map table: number of frames 2\n" + |
4092 |
" [pc: 17, same]\n" + |
4093 |
" [pc: 24, same]\n" + |
4094 |
" \n" + |
4095 |
" // Method descriptor #29 (I)V\n" + |
4096 |
" // Stack: 1, Locals: 2\n" + |
4097 |
" void baz(int i);\n" + |
4098 |
" 0 aload_0 [this]\n" + |
4099 |
" 1 invokevirtual X.bool() : boolean [17]\n" + |
4100 |
" 4 ifeq 34\n" + |
4101 |
" 7 iload_1 [i]\n" + |
4102 |
" 8 tableswitch default: 31\n" + |
4103 |
" case 0: 28\n" + |
4104 |
" 28 goto 39\n" + |
4105 |
" 31 goto 39\n" + |
4106 |
" 34 aload_0 [this]\n" + |
4107 |
" 35 invokevirtual X.bool() : boolean [17]\n" + |
4108 |
" 38 pop\n" + |
4109 |
" 39 return\n" + |
4110 |
" Line numbers:\n" + |
4111 |
" [pc: 0, line: 46]\n" + |
4112 |
" [pc: 7, line: 47]\n" + |
4113 |
" [pc: 28, line: 48]\n" + |
4114 |
" [pc: 34, line: 52]\n" + |
4115 |
" [pc: 39, line: 54]\n" + |
4116 |
" Local variable table:\n" + |
4117 |
" [pc: 0, pc: 40] local: this index: 0 type: X\n" + |
4118 |
" [pc: 0, pc: 40] local: i index: 1 type: int\n" + |
4119 |
" Stack map table: number of frames 4\n" + |
4120 |
" [pc: 28, same]\n" + |
4121 |
" [pc: 31, same]\n" + |
4122 |
" [pc: 34, same]\n" + |
4123 |
" [pc: 39, same]\n"; |
4124 |
|
4125 |
try { |
4126 |
File f = new File(OUTPUT_DIR + File.separator + "X.class"); |
4127 |
byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); |
4128 |
ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); |
4129 |
String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); |
4130 |
int index = result.indexOf(expectedOutput); |
4131 |
if (index == -1 || expectedOutput.length() == 0) { |
4132 |
System.out.println(Util.displayString(result, 3)); |
4133 |
} |
4134 |
if (index == -1) { |
4135 |
assertEquals("Wrong contents", expectedOutput, result); |
4136 |
} |
4137 |
} catch (org.eclipse.jdt.core.util.ClassFormatException e) { |
4138 |
assertTrue(false); |
4139 |
} catch (IOException e) { |
4140 |
assertTrue(false); |
4141 |
} |
4142 |
} |
4143 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=114894 - variation |
4144 |
public void test051() { |
4145 |
this.runConformTest( |
4146 |
new String[] { |
4147 |
"X.java", |
4148 |
"public class X {\n" + |
4149 |
" public static void main(String argv[]) {\n" + |
4150 |
" System.out.println(\"[count=\" + count() + \"]\");\n" + |
4151 |
" }\n" + |
4152 |
" static int count() {\n" + |
4153 |
" int count = 0;\n" + |
4154 |
" try {\n" + |
4155 |
" for (int i = 0;;) {\n" + |
4156 |
" count++;\n" + |
4157 |
" if (i++ > 10) \n" + |
4158 |
" break; \n" + |
4159 |
" }\n" + |
4160 |
" } catch(Exception e) {\n" + |
4161 |
" }\n" + |
4162 |
" return count;\n" + |
4163 |
" }\n" + |
4164 |
"}\n", |
4165 |
}, |
4166 |
"[count=12]"); |
4167 |
|
4168 |
String expectedOutput = new CompilerOptions(this.getCompilerOptions()).complianceLevel < ClassFileConstants.JDK1_6 |
4169 |
? " // Method descriptor #32 ()I\n" + |
4170 |
" // Stack: 2, Locals: 2\n" + |
4171 |
" static int count();\n" + |
4172 |
" 0 iconst_0\n" + |
4173 |
" 1 istore_0 [count]\n" + |
4174 |
" 2 iconst_0\n" + |
4175 |
" 3 istore_1 [i]\n" + |
4176 |
" 4 iinc 0 1 [count]\n" + |
4177 |
" 7 iload_1 [i]\n" + |
4178 |
" 8 iinc 1 1 [i]\n" + |
4179 |
" 11 bipush 10\n" + |
4180 |
" 13 if_icmple 4\n" + |
4181 |
" 16 goto 20\n" + |
4182 |
" 19 astore_1\n" + |
4183 |
" 20 iload_0 [count]\n" + |
4184 |
" 21 ireturn\n" + |
4185 |
" Exception Table:\n" + |
4186 |
" [pc: 2, pc: 19] -> 19 when : java.lang.Exception\n" + |
4187 |
" Line numbers:\n" + |
4188 |
" [pc: 0, line: 6]\n" + |
4189 |
" [pc: 2, line: 8]\n" + |
4190 |
" [pc: 4, line: 9]\n" + |
4191 |
" [pc: 7, line: 10]\n" + |
4192 |
" [pc: 19, line: 13]\n" + |
4193 |
" [pc: 20, line: 15]\n" + |
4194 |
" Local variable table:\n" + |
4195 |
" [pc: 2, pc: 22] local: count index: 0 type: int\n" + |
4196 |
" [pc: 4, pc: 16] local: i index: 1 type: int\n" |
4197 |
: |
4198 |
" // Method descriptor #32 ()I\n" + |
4199 |
" // Stack: 2, Locals: 2\n" + |
4200 |
" static int count();\n" + |
4201 |
" 0 iconst_0\n" + |
4202 |
" 1 istore_0 [count]\n" + |
4203 |
" 2 iconst_0\n" + |
4204 |
" 3 istore_1 [i]\n" + |
4205 |
" 4 iinc 0 1 [count]\n" + |
4206 |
" 7 iload_1 [i]\n" + |
4207 |
" 8 iinc 1 1 [i]\n" + |
4208 |
" 11 bipush 10\n" + |
4209 |
" 13 if_icmple 4\n" + |
4210 |
" 16 goto 20\n" + |
4211 |
" 19 astore_1\n" + |
4212 |
" 20 iload_0 [count]\n" + |
4213 |
" 21 ireturn\n" + |
4214 |
" Exception Table:\n" + |
4215 |
" [pc: 2, pc: 19] -> 19 when : java.lang.Exception\n" + |
4216 |
" Line numbers:\n" + |
4217 |
" [pc: 0, line: 6]\n" + |
4218 |
" [pc: 2, line: 8]\n" + |
4219 |
" [pc: 4, line: 9]\n" + |
4220 |
" [pc: 7, line: 10]\n" + |
4221 |
" [pc: 19, line: 13]\n" + |
4222 |
" [pc: 20, line: 15]\n" + |
4223 |
" Local variable table:\n" + |
4224 |
" [pc: 2, pc: 22] local: count index: 0 type: int\n" + |
4225 |
" [pc: 4, pc: 16] local: i index: 1 type: int\n" + |
4226 |
" Stack map table: number of frames 3\n" + |
4227 |
" [pc: 4, append: {int, int}]\n" + |
4228 |
" [pc: 19, full, stack: {java.lang.Exception}, locals: {int}]\n" + |
4229 |
" [pc: 20, same]\n"; |
4230 |
|
4231 |
try { |
4232 |
File f = new File(OUTPUT_DIR + File.separator + "X.class"); |
4233 |
byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); |
4234 |
ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); |
4235 |
String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); |
4236 |
int index = result.indexOf(expectedOutput); |
4237 |
if (index == -1 || expectedOutput.length() == 0) { |
4238 |
System.out.println(Util.displayString(result, 3)); |
4239 |
} |
4240 |
if (index == -1) { |
4241 |
assertEquals("Wrong contents", expectedOutput, result); |
4242 |
} |
4243 |
} catch (org.eclipse.jdt.core.util.ClassFormatException e) { |
4244 |
assertTrue(false); |
4245 |
} catch (IOException e) { |
4246 |
assertTrue(false); |
4247 |
} |
4248 |
} |
4249 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=114894 - variation |
4250 |
public void test052() { |
4251 |
this.runConformTest( |
4252 |
new String[] { |
4253 |
"X.java", |
4254 |
"public class X {\n" + |
4255 |
" public static void main(String argv[]) {\n" + |
4256 |
" try {\n" + |
4257 |
" for (int i = 0; i < 0; i++)\n" + |
4258 |
" do ; while (true);\n" + |
4259 |
" } catch(Exception e) {\n" + |
4260 |
" }\n" + |
4261 |
" } \n" + |
4262 |
"}\n", |
4263 |
}, |
4264 |
""); |
4265 |
|
4266 |
String expectedOutput = new CompilerOptions(this.getCompilerOptions()).complianceLevel < ClassFileConstants.JDK1_6 |
4267 |
? " // Method descriptor #15 ([Ljava/lang/String;)V\n" + |
4268 |
" // Stack: 1, Locals: 2\n" + |
4269 |
" public static void main(java.lang.String[] argv);\n" + |
4270 |
" 0 iconst_0\n" + |
4271 |
" 1 istore_1 [i]\n" + |
4272 |
" 2 goto 8\n" + |
4273 |
" 5 goto 5\n" + |
4274 |
" 8 iload_1 [i]\n" + |
4275 |
" 9 iflt 5\n" + |
4276 |
" 12 goto 16\n" + |
4277 |
" 15 astore_1\n" + |
4278 |
" 16 return\n" + |
4279 |
" Exception Table:\n" + |
4280 |
" [pc: 0, pc: 15] -> 15 when : java.lang.Exception\n" + |
4281 |
" Line numbers:\n" + |
4282 |
" [pc: 0, line: 4]\n" + |
4283 |
" [pc: 5, line: 5]\n" + |
4284 |
" [pc: 8, line: 4]\n" + |
4285 |
" [pc: 15, line: 6]\n" + |
4286 |
" [pc: 16, line: 8]\n" + |
4287 |
" Local variable table:\n" + |
4288 |
" [pc: 0, pc: 17] local: argv index: 0 type: java.lang.String[]\n" + |
4289 |
" [pc: 2, pc: 12] local: i index: 1 type: int\n" |
4290 |
: |
4291 |
" // Method descriptor #15 ([Ljava/lang/String;)V\n" + |
4292 |
" // Stack: 1, Locals: 2\n" + |
4293 |
" public static void main(java.lang.String[] argv);\n" + |
4294 |
" 0 iconst_0\n" + |
4295 |
" 1 istore_1 [i]\n" + |
4296 |
" 2 goto 8\n" + |
4297 |
" 5 goto 5\n" + |
4298 |
" 8 iload_1 [i]\n" + |
4299 |
" 9 iflt 5\n" + |
4300 |
" 12 goto 16\n" + |
4301 |
" 15 astore_1\n" + |
4302 |
" 16 return\n" + |
4303 |
" Exception Table:\n" + |
4304 |
" [pc: 0, pc: 15] -> 15 when : java.lang.Exception\n" + |
4305 |
" Line numbers:\n" + |
4306 |
" [pc: 0, line: 4]\n" + |
4307 |
" [pc: 5, line: 5]\n" + |
4308 |
" [pc: 8, line: 4]\n" + |
4309 |
" [pc: 15, line: 6]\n" + |
4310 |
" [pc: 16, line: 8]\n" + |
4311 |
" Local variable table:\n" + |
4312 |
" [pc: 0, pc: 17] local: argv index: 0 type: java.lang.String[]\n" + |
4313 |
" [pc: 2, pc: 12] local: i index: 1 type: int\n" + |
4314 |
" Stack map table: number of frames 4\n" + |
4315 |
" [pc: 5, append: {int}]\n" + |
4316 |
" [pc: 8, same]\n" + |
4317 |
" [pc: 15, full, stack: {java.lang.Exception}, locals: {java.lang.String[]}]\n" + |
4318 |
" [pc: 16, same]\n"; |
4319 |
|
4320 |
try { |
4321 |
File f = new File(OUTPUT_DIR + File.separator + "X.class"); |
4322 |
byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); |
4323 |
ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); |
4324 |
String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); |
4325 |
int index = result.indexOf(expectedOutput); |
4326 |
if (index == -1 || expectedOutput.length() == 0) { |
4327 |
System.out.println(Util.displayString(result, 3)); |
4328 |
} |
4329 |
if (index == -1) { |
4330 |
assertEquals("Wrong contents", expectedOutput, result); |
4331 |
} |
4332 |
} catch (org.eclipse.jdt.core.util.ClassFormatException e) { |
4333 |
assertTrue(false); |
4334 |
} catch (IOException e) { |
4335 |
assertTrue(false); |
4336 |
} |
4337 |
} |
4338 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=114894 - variation |
4339 |
public void test053() { |
4340 |
this.runConformTest( |
4341 |
new String[] { |
4342 |
"X.java", |
4343 |
"public class X {\n" + |
4344 |
" public static void main(String[] args) {\n" + |
4345 |
" try {\n" + |
4346 |
" final int val;\n" + |
4347 |
" for (val = 7; val > 0;) break;\n" + |
4348 |
" System.out.println(val);\n" + |
4349 |
" } catch(Exception e) {\n" + |
4350 |
" }\n" + |
4351 |
" } \n" + |
4352 |
"}\n", |
4353 |
}, |
4354 |
"7"); |
4355 |
|
4356 |
String expectedOutput = new CompilerOptions(this.getCompilerOptions()).complianceLevel < ClassFileConstants.JDK1_6 |
4357 |
? " // Method descriptor #15 ([Ljava/lang/String;)V\n" + |
4358 |
" // Stack: 2, Locals: 2\n" + |
4359 |
" public static void main(java.lang.String[] args);\n" + |
4360 |
" 0 bipush 7\n" + |
4361 |
" 2 istore_1 [val]\n" + |
4362 |
" 3 iload_1 [val]\n" + |
4363 |
" 4 ifgt 7\n" + |
4364 |
" 7 getstatic java.lang.System.out : java.io.PrintStream [16]\n" + |
4365 |
" 10 iload_1 [val]\n" + |
4366 |
" 11 invokevirtual java.io.PrintStream.println(int) : void [22]\n" + |
4367 |
" 14 goto 18\n" + |
4368 |
" 17 astore_1\n" + |
4369 |
" 18 return\n" + |
4370 |
" Exception Table:\n" + |
4371 |
" [pc: 0, pc: 17] -> 17 when : java.lang.Exception\n" + |
4372 |
" Line numbers:\n" + |
4373 |
" [pc: 0, line: 5]\n" + |
4374 |
" [pc: 7, line: 6]\n" + |
4375 |
" [pc: 17, line: 7]\n" + |
4376 |
" [pc: 18, line: 9]\n" + |
4377 |
" Local variable table:\n" + |
4378 |
" [pc: 0, pc: 19] local: args index: 0 type: java.lang.String[]\n" + |
4379 |
" [pc: 3, pc: 17] local: val index: 1 type: int\n" |
4380 |
: |
4381 |
" // Method descriptor #15 ([Ljava/lang/String;)V\n" + |
4382 |
" // Stack: 2, Locals: 2\n" + |
4383 |
" public static void main(java.lang.String[] args);\n" + |
4384 |
" 0 bipush 7\n" + |
4385 |
" 2 istore_1 [val]\n" + |
4386 |
" 3 iload_1 [val]\n" + |
4387 |
" 4 ifgt 7\n" + |
4388 |
" 7 getstatic java.lang.System.out : java.io.PrintStream [16]\n" + |
4389 |
" 10 iload_1 [val]\n" + |
4390 |
" 11 invokevirtual java.io.PrintStream.println(int) : void [22]\n" + |
4391 |
" 14 goto 18\n" + |
4392 |
" 17 astore_1\n" + |
4393 |
" 18 return\n" + |
4394 |
" Exception Table:\n" + |
4395 |
" [pc: 0, pc: 17] -> 17 when : java.lang.Exception\n" + |
4396 |
" Line numbers:\n" + |
4397 |
" [pc: 0, line: 5]\n" + |
4398 |
" [pc: 7, line: 6]\n" + |
4399 |
" [pc: 17, line: 7]\n" + |
4400 |
" [pc: 18, line: 9]\n" + |
4401 |
" Local variable table:\n" + |
4402 |
" [pc: 0, pc: 19] local: args index: 0 type: java.lang.String[]\n" + |
4403 |
" [pc: 3, pc: 17] local: val index: 1 type: int\n" + |
4404 |
" Stack map table: number of frames 4\n" + |
4405 |
" [pc: 3, append: {int}]\n" + |
4406 |
" [pc: 7, same]\n" + |
4407 |
" [pc: 17, full, stack: {java.lang.Exception}, locals: {java.lang.String[]}]\n" + |
4408 |
" [pc: 18, same]\n"; |
4409 |
|
4410 |
try { |
4411 |
File f = new File(OUTPUT_DIR + File.separator + "X.class"); |
4412 |
byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); |
4413 |
ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); |
4414 |
String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); |
4415 |
int index = result.indexOf(expectedOutput); |
4416 |
if (index == -1 || expectedOutput.length() == 0) { |
4417 |
System.out.println(Util.displayString(result, 3)); |
4418 |
} |
4419 |
if (index == -1) { |
4420 |
assertEquals("Wrong contents", expectedOutput, result); |
4421 |
} |
4422 |
} catch (org.eclipse.jdt.core.util.ClassFormatException e) { |
4423 |
assertTrue(false); |
4424 |
} catch (IOException e) { |
4425 |
assertTrue(false); |
4426 |
} |
4427 |
} |
4428 |
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=114894 - variation |
4429 |
public void test054() { |
4430 |
this.runConformTest( |
4431 |
new String[] { |
4432 |
"X.java", |
4433 |
"public class X {\n" + |
4434 |
" X parent;\n" + |
4435 |
" int kind;\n" + |
4436 |
" static boolean F = false;\n" + |
4437 |
" public static void main(String[] args) {\n" + |
4438 |
" X x = new X();\n" + |
4439 |
" x.kind = 2; \n" + |
4440 |
" try {\n" + |
4441 |
" x.foo();\n" + |
4442 |
" } catch(NullPointerException e) { \n" + |
4443 |
" System.out.println(\"SUCCESS\");\n" + |
4444 |
" return;\n" + |
4445 |
" }\n" + |
4446 |
" System.out.println(\"FAILED\"); \n" + |
4447 |
" }\n" + |
4448 |
" void foo() {\n" + |
4449 |
" X x = this;\n" + |
4450 |
" done : while (true) {\n" + |
4451 |
" switch (x.kind) {\n" + |
4452 |
" case 2 :\n" + |
4453 |
" if (F) {\n" + |
4454 |
" return;\n" + |
4455 |
" }\n" + |
4456 |
" break;\n" + |
4457 |
" case 3 :\n" + |
4458 |
" break done;\n" + |
4459 |
" }\n" + |
4460 |
" x = x.parent; // should throw npe\n" + |
4461 |
" }\n" + |
4462 |
" } \n" + |
4463 |
"}\n", |
4464 |
}, |
4465 |
"SUCCESS"); |
4466 |
|
4467 |
String expectedOutput = new CompilerOptions(this.getCompilerOptions()).complianceLevel < ClassFileConstants.JDK1_6 |
4468 |
? " // Method descriptor #12 ()V\n" + |
4469 |
" // Stack: 1, Locals: 2\n" + |
4470 |
" void foo();\n" + |
4471 |
" 0 aload_0 [this]\n" + |
4472 |
" 1 astore_1 [x]\n" + |
4473 |
" 2 aload_1 [x]\n" + |
4474 |
" 3 getfield X.kind : int [25]\n" + |
4475 |
" 6 tableswitch default: 38\n" + |
4476 |
" case 2: 28\n" + |
4477 |
" case 3: 35\n" + |
4478 |
" 28 getstatic X.F : boolean [14]\n" + |
4479 |
" 31 ifeq 38\n" + |
4480 |
" 34 return\n" + |
4481 |
" 35 goto 46\n" + |
4482 |
" 38 aload_1 [x]\n" + |
4483 |
" 39 getfield X.parent : X [53]\n" + |
4484 |
" 42 astore_1 [x]\n" + |
4485 |
" 43 goto 2\n" + |
4486 |
" 46 return\n" + |
4487 |
" Line numbers:\n" + |
4488 |
" [pc: 0, line: 17]\n" + |
4489 |
" [pc: 2, line: 19]\n" + |
4490 |
" [pc: 28, line: 21]\n" + |
4491 |
" [pc: 34, line: 22]\n" + |
4492 |
" [pc: 35, line: 26]\n" + |
4493 |
" [pc: 38, line: 28]\n" + |
4494 |
" [pc: 43, line: 18]\n" + |
4495 |
" [pc: 46, line: 30]\n" + |
4496 |
" Local variable table:\n" + |
4497 |
" [pc: 0, pc: 47] local: this index: 0 type: X\n" + |
4498 |
" [pc: 2, pc: 47] local: x index: 1 type: X\n" |
4499 |
: |
4500 |
" // Method descriptor #12 ()V\n" + |
4501 |
" // Stack: 1, Locals: 2\n" + |
4502 |
" void foo();\n" + |
4503 |
" 0 aload_0 [this]\n" + |
4504 |
" 1 astore_1 [x]\n" + |
4505 |
" 2 aload_1 [x]\n" + |
4506 |
" 3 getfield X.kind : int [25]\n" + |
4507 |
" 6 tableswitch default: 38\n" + |
4508 |
" case 2: 28\n" + |
4509 |
" case 3: 35\n" + |
4510 |
" 28 getstatic X.F : boolean [14]\n" + |
4511 |
" 31 ifeq 38\n" + |
4512 |
" 34 return\n" + |
4513 |
" 35 goto 46\n" + |
4514 |
" 38 aload_1 [x]\n" + |
4515 |
" 39 getfield X.parent : X [55]\n" + |
4516 |
" 42 astore_1 [x]\n" + |
4517 |
" 43 goto 2\n" + |
4518 |
" 46 return\n" + |
4519 |
" Line numbers:\n" + |
4520 |
" [pc: 0, line: 17]\n" + |
4521 |
" [pc: 2, line: 19]\n" + |
4522 |
" [pc: 28, line: 21]\n" + |
4523 |
" [pc: 34, line: 22]\n" + |
4524 |
" [pc: 35, line: 26]\n" + |
4525 |
" [pc: 38, line: 28]\n" + |
4526 |
" [pc: 43, line: 18]\n" + |
4527 |
" [pc: 46, line: 30]\n" + |
4528 |
" Local variable table:\n" + |
4529 |
" [pc: 0, pc: 47] local: this index: 0 type: X\n" + |
4530 |
" [pc: 2, pc: 47] local: x index: 1 type: X\n" + |
4531 |
" Stack map table: number of frames 5\n" + |
4532 |
" [pc: 2, append: {X}]\n" + |
4533 |
" [pc: 28, same]\n" + |
4534 |
" [pc: 35, same]\n" + |
4535 |
" [pc: 38, same]\n" + |
4536 |
" [pc: 46, same]\n"; |
4537 |
|
4538 |
try { |
4539 |
File f = new File(OUTPUT_DIR + File.separator + "X.class"); |
4540 |
byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f); |
4541 |
ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler(); |
4542 |
String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED); |
4543 |
int index = result.indexOf(expectedOutput); |
4544 |
if (index == -1 || expectedOutput.length() == 0) { |
4545 |
System.out.println(Util.displayString(result, 3)); |
4546 |
} |
4547 |
if (index == -1) { |
4548 |
assertEquals("Wrong contents", expectedOutput, result); |
4549 |
} |
4550 |
} catch (org.eclipse.jdt.core.util.ClassFormatException e) { |
4551 |
assertTrue(false); |
4552 |
} catch (IOException e) { |
4553 |
assertTrue(false); |
4554 |
} |
4555 |
} |
2973 |
public static Class testClass() { |
4556 |
public static Class testClass() { |
2974 |
return TryStatementTest.class; |
4557 |
return TryStatementTest.class; |
2975 |
} |
4558 |
} |