Index: compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java,v
--- compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java 23 Aug 2006 16:32:56 -0000 1.60
+++ compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java 2 Apr 2007 19:58:40 -0000
@@ -248,18 +248,24 @@
actionLabel.tagBits |= BranchLabel.USED;
BranchLabel conditionLabel = new BranchLabel(codeStream);
breakLabel.initialize(codeStream);
- if (this.continueLabel != null) {
+ if (this.continueLabel == null) {
+ conditionLabel.place();
+ if ((condition != null) && (condition.constant == Constant.NotAConstant)) {
+ condition.generateOptimizedBoolean(scope, codeStream, null, breakLabel, true);
+ }
+ } else {
this.continueLabel.initialize(codeStream);
+ // jump over the actionBlock
+ if ((condition != null)
+ && (condition.constant == Constant.NotAConstant)
+ && !((action == null || action.isEmptyBlock()) && (increments == null))) {
+ conditionLabel.tagBits |= BranchLabel.USED;
+ int jumpPC = codeStream.position;
+ codeStream.goto_(conditionLabel);
+ codeStream.recordPositionsFrom(jumpPC, condition.sourceStart);
+ }
}
- // jump over the actionBlock
- if ((condition != null)
- && (condition.constant == Constant.NotAConstant)
- && !((action == null || action.isEmptyBlock()) && (increments == null))) {
- conditionLabel.tagBits |= BranchLabel.USED;
- int jumpPC = codeStream.position;
- codeStream.goto_(conditionLabel);
- codeStream.recordPositionsFrom(jumpPC, condition.sourceStart);
- }
+
// generate the loop action
if (action != null) {
// Required to fix 1PR0XVS: LFRE:WINNT - Compiler: variable table for method appears incorrect
@@ -287,23 +293,26 @@
increments[i].generateCode(scope, codeStream);
}
}
- }
-
- // May loose some local variable initializations : affecting the local variable attributes
- if (preCondInitStateIndex != -1) {
- codeStream.removeNotDefinitelyAssignedVariables(currentScope, preCondInitStateIndex);
- }
-
- // generate the condition
- conditionLabel.place();
- if ((condition != null) && (condition.constant == Constant.NotAConstant)) {
- condition.generateOptimizedBoolean(scope, codeStream, actionLabel, null, true);
- } else {
- if (continueLabel != null) {
+ // May loose some local variable initializations : affecting the local variable attributes
+ if (preCondInitStateIndex != -1) {
+ codeStream.removeNotDefinitelyAssignedVariables(currentScope, preCondInitStateIndex);
+ }
+ // generate the condition
+ conditionLabel.place();
+ if ((condition != null) && (condition.constant == Constant.NotAConstant)) {
+ condition.generateOptimizedBoolean(scope, codeStream, actionLabel, null, true);
+ } else {
codeStream.goto_(actionLabel);
}
+
+ } else {
+ // May loose some local variable initializations : affecting the local variable attributes
+ if (preCondInitStateIndex != -1) {
+ codeStream.removeNotDefinitelyAssignedVariables(currentScope, preCondInitStateIndex);
+ }
}
+
// May loose some local variable initializations : affecting the local variable attributes
if (neededScope) {
codeStream.exitUserScope(scope);
Index: compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java,v
--- compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java 29 Mar 2007 13:17:27 -0000 1.44
+++ compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java 2 Apr 2007 19:58:40 -0000
@@ -134,8 +134,10 @@
if (!hasEmptyAction
|| this.elementVariable.binding.resolvedPosition != -1) {
this.collectionVariable.useFlag = LocalVariableBinding.USED;
- this.indexVariable.useFlag = LocalVariableBinding.USED;
- this.maxVariable.useFlag = LocalVariableBinding.USED;
+ if (this.continueLabel != null) {
+ this.indexVariable.useFlag = LocalVariableBinding.USED;
+ this.maxVariable.useFlag = LocalVariableBinding.USED;
+ }
}
break;
case RAW_ITERABLE :
@@ -192,12 +194,16 @@
switch(this.kind) {
case ARRAY :
collection.generateCode(scope, codeStream, true);
- codeStream.store(this.collectionVariable, false);
- codeStream.iconst_0();
- codeStream.store(this.indexVariable, false);
- codeStream.load(this.collectionVariable);
- codeStream.arraylength();
- codeStream.store(this.maxVariable, false);
+ codeStream.store(this.collectionVariable, true);
+ if (this.continueLabel != null) {
+ // int length = (collectionVariable = [collection]).length;
+ codeStream.arraylength();
+ codeStream.store(this.maxVariable, false);
+ codeStream.iconst_0();
+ codeStream.store(this.indexVariable, false);
+ } else {
+ // leave collectionVariable on execution stack (will be consumed when swapping condition further down)
+ }
break;
case RAW_ITERABLE :
case GENERIC_ITERABLE :
@@ -225,12 +231,31 @@
BranchLabel conditionLabel = new BranchLabel(codeStream);
conditionLabel.tagBits |= BranchLabel.USED;
breakLabel.initialize(codeStream);
- if (this.continueLabel != null) {
+ if (this.continueLabel == null) {
+ // generate the condition (swapped for optimizing)
+ conditionLabel.place();
+ int conditionPC = codeStream.position;
+ switch(this.kind) {
+ case ARRAY :
+ // inline the arraylength call
+ // collectionVariable is already on execution stack
+ codeStream.arraylength();
+ codeStream.ifeq(breakLabel);
+ break;
+ case RAW_ITERABLE :
+ case GENERIC_ITERABLE :
+ codeStream.load(this.indexVariable);
+ codeStream.invokeJavaUtilIteratorHasNext();
+ codeStream.ifeq(breakLabel);
+ break;
+ }
+ codeStream.recordPositionsFrom(conditionPC, this.elementVariable.sourceStart);
+ } else {
this.continueLabel.initialize(codeStream);
this.continueLabel.tagBits |= BranchLabel.USED;
+ // jump over the actionBlock
+ codeStream.goto_(conditionLabel);
}
- // jump over the actionBlock
- codeStream.goto_(conditionLabel);
// generate the loop action
actionLabel.place();
@@ -240,7 +265,11 @@
case ARRAY :
if (this.elementVariable.binding.resolvedPosition != -1) {
codeStream.load(this.collectionVariable);
- codeStream.load(this.indexVariable);
+ if (this.continueLabel == null) {
+ codeStream.iconst_0(); // no continue, thus simply hardcode offset 0
+ } else {
+ codeStream.load(this.indexVariable);
+ }
codeStream.arrayAt(this.collectionElementType.id);
if (this.elementVariableImplicitWidening != -1) {
codeStream.generateImplicitConversion(this.elementVariableImplicitWidening);
@@ -294,33 +323,26 @@
// generate the increments for next iteration
switch(this.kind) {
case ARRAY :
- if (hasEmptyAction && this.elementVariable.binding.resolvedPosition == -1) break;
- codeStream.iinc(this.indexVariable.resolvedPosition, 1);
+ if (!hasEmptyAction || this.elementVariable.binding.resolvedPosition >= 0) {
+ codeStream.iinc(this.indexVariable.resolvedPosition, 1);
+ }
+ // generate the condition
+ conditionLabel.place();
+ codeStream.load(this.indexVariable);
+ codeStream.load(this.maxVariable);
+ codeStream.if_icmplt(actionLabel);
break;
case RAW_ITERABLE :
case GENERIC_ITERABLE :
+ // generate the condition
+ conditionLabel.place();
+ codeStream.load(this.indexVariable);
+ codeStream.invokeJavaUtilIteratorHasNext();
+ codeStream.ifne(actionLabel);
break;
}
codeStream.recordPositionsFrom(continuationPC, this.elementVariable.sourceStart);
}
- // generate the condition
- conditionLabel.place();
- int conditionPC = codeStream.position;
- switch(this.kind) {
- case ARRAY :
- codeStream.load(this.indexVariable);
- codeStream.load(this.maxVariable);
- codeStream.if_icmplt(actionLabel);
- break;
- case RAW_ITERABLE :
- case GENERIC_ITERABLE :
- codeStream.load(this.indexVariable);
- codeStream.invokeJavaUtilIteratorHasNext();
- codeStream.ifne(actionLabel);
- break;
- }
- codeStream.recordPositionsFrom(conditionPC, this.elementVariable.sourceStart);
-
codeStream.exitUserScope(scope);
if (mergedInitStateIndex != -1) {
codeStream.removeNotDefinitelyAssignedVariables(currentScope, mergedInitStateIndex);
Index: buildnotes_jdt-core.html
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/buildnotes_jdt-core.html,v
--- buildnotes_jdt-core.html 2 Apr 2007 11:34:20 -0000 1.5807
+++ buildnotes_jdt-core.html 2 Apr 2007 19:58:40 -0000
@@ -52,7 +52,9 @@
What's new in this drop
Problem Reports Fixed
-176320
+180471
+[compiler] Unoptimal code generation for for-loops when no continuation point
+
176320
Non linear progress in open type dialog
176472
[compiler][null] extraneous error in case of a labeled while(true) statement
Index: src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java,v
--- src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java 23 Aug 2006 16:33:07 -0000 1.34
+++ src/org/eclipse/jdt/core/tests/compiler/regression/ForeachStatementTest.java 2 Apr 2007 19:58:44 -0000
@@ -257,38 +257,38 @@
" 46 iastore\n" +
" 47 astore_2 [tab]\n" +
" 48 aload_2 [tab]\n" +
- " 49 astore 6\n" +
- " 51 iconst_0\n" +
- " 52 istore 4\n" +
- " 54 aload 6\n" +
- " 56 arraylength\n" +
- " 57 istore 5\n" +
- " 59 goto 73\n" +
- " 62 aload 6\n" +
- " 64 iload 4\n" +
- " 66 iaload\n" +
- " 67 istore_3 [e]\n" +
- " 68 iload_3 [e]\n" +
- " 69 istore_1\n" +
- " 70 iinc 4 1\n" +
- " 73 iload 4\n" +
- " 75 iload 5\n" +
- " 77 if_icmplt 62\n" +
- " 80 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
- " 83 ldc [22]\n" +
- " 85 invokevirtual java.io.PrintStream.println(java.lang.String) : void [24]\n" +
- " 88 return\n" +
+ " 49 dup\n" +
+ " 50 astore 6\n" +
+ " 52 arraylength\n" +
+ " 53 istore 5\n" +
+ " 55 iconst_0\n" +
+ " 56 istore 4\n" +
+ " 58 goto 72\n" +
+ " 61 aload 6\n" +
+ " 63 iload 4\n" +
+ " 65 iaload\n" +
+ " 66 istore_3 [e]\n" +
+ " 67 iload_3 [e]\n" +
+ " 68 istore_1\n" +
+ " 69 iinc 4 1\n" +
+ " 72 iload 4\n" +
+ " 74 iload 5\n" +
+ " 76 if_icmplt 61\n" +
+ " 79 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
+ " 82 ldc [22]\n" +
+ " 84 invokevirtual java.io.PrintStream.println(java.lang.String) : void [24]\n" +
+ " 87 return\n" +
" Line numbers:\n" +
" [pc: 0, line: 5]\n" +
" [pc: 48, line: 6]\n" +
- " [pc: 68, line: 7]\n" +
- " [pc: 70, line: 6]\n" +
- " [pc: 80, line: 9]\n" +
- " [pc: 88, line: 10]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 89] local: args index: 0 type: java.lang.String[]\n" +
- " [pc: 48, pc: 89] local: tab index: 2 type: int[]\n" +
- " [pc: 68, pc: 70] local: e index: 3 type: int\n";
+ " [pc: 67, line: 7]\n" +
+ " [pc: 69, line: 6]\n" +
+ " [pc: 79, line: 9]\n" +
+ " [pc: 87, line: 10]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 88] local: args index: 0 type: java.lang.String[]\n" +
+ " [pc: 48, pc: 88] local: tab index: 2 type: int[]\n" +
+ " [pc: 67, pc: 69] local: e index: 3 type: int\n";
try {
File f = new File(OUTPUT_DIR + File.separator + "X.class");
@@ -595,29 +595,29 @@
" 6 iastore\n" +
" 7 astore_1 [tab]\n" +
" 8 aload_1 [tab]\n" +
- " 9 astore 4\n" +
- " 11 iconst_0\n" +
- " 12 istore_2\n" +
- " 13 aload 4\n" +
- " 15 arraylength\n" +
- " 16 istore_3\n" +
- " 17 goto 23\n" +
- " 20 iinc 2 1\n" +
- " 23 iload_2\n" +
- " 24 iload_3\n" +
- " 25 if_icmplt 20\n" +
- " 28 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
- " 31 ldc [22]\n" +
- " 33 invokevirtual java.io.PrintStream.println(java.lang.String) : void [24]\n" +
- " 36 return\n" +
+ " 9 dup\n" +
+ " 10 astore 4\n" +
+ " 12 arraylength\n" +
+ " 13 istore_3\n" +
+ " 14 iconst_0\n" +
+ " 15 istore_2\n" +
+ " 16 goto 22\n" +
+ " 19 iinc 2 1\n" +
+ " 22 iload_2\n" +
+ " 23 iload_3\n" +
+ " 24 if_icmplt 19\n" +
+ " 27 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
+ " 30 ldc [22]\n" +
+ " 32 invokevirtual java.io.PrintStream.println(java.lang.String) : void [24]\n" +
+ " 35 return\n" +
" Line numbers:\n" +
" [pc: 0, line: 4]\n" +
" [pc: 8, line: 5]\n" +
- " [pc: 28, line: 7]\n" +
- " [pc: 36, line: 8]\n" +
+ " [pc: 27, line: 7]\n" +
+ " [pc: 35, line: 8]\n" +
" Local variable table:\n" +
- " [pc: 0, pc: 37] local: args index: 0 type: java.lang.String[]\n" +
- " [pc: 8, pc: 37] local: tab index: 1 type: int[]\n";
+ " [pc: 0, pc: 36] local: args index: 0 type: java.lang.String[]\n" +
+ " [pc: 8, pc: 36] local: tab index: 1 type: int[]\n";
try {
File f = new File(OUTPUT_DIR + File.separator + "X.class");
@@ -677,7 +677,7 @@
"1");
String expectedOutput =
" // Method descriptor #15 ([Ljava/lang/String;)V\n" +
- " // Stack: 4, Locals: 6\n" +
+ " // Stack: 4, Locals: 4\n" +
" public static void main(java.lang.String[] args);\n" +
" 0 iconst_1\n" +
" 1 newarray int [10]\n" +
@@ -687,36 +687,27 @@
" 6 iastore\n" +
" 7 astore_1 [tab]\n" +
" 8 aload_1 [tab]\n" +
- " 9 astore 5\n" +
- " 11 iconst_0\n" +
- " 12 istore_3\n" +
- " 13 aload 5\n" +
- " 15 arraylength\n" +
- " 16 istore 4\n" +
- " 18 goto 36\n" +
- " 21 aload 5\n" +
- " 23 iload_3\n" +
- " 24 iaload\n" +
- " 25 istore_2 [e]\n" +
- " 26 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
- " 29 iload_2 [e]\n" +
- " 30 invokevirtual java.io.PrintStream.println(int) : void [22]\n" +
- " 33 goto 42\n" +
- " 36 iload_3\n" +
- " 37 iload 4\n" +
- " 39 if_icmplt 21\n" +
- " 42 return\n" +
+ " 9 dup\n" +
+ " 10 astore_3\n" +
+ " 11 arraylength\n" +
+ " 12 ifeq 26\n" +
+ " 15 aload_3\n" +
+ " 16 iconst_0\n" +
+ " 17 iaload\n" +
+ " 18 istore_2 [e]\n" +
+ " 19 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
+ " 22 iload_2 [e]\n" +
+ " 23 invokevirtual java.io.PrintStream.println(int) : void [22]\n" +
+ " 26 return\n" +
" Line numbers:\n" +
" [pc: 0, line: 4]\n" +
" [pc: 8, line: 5]\n" +
- " [pc: 26, line: 6]\n" +
- " [pc: 33, line: 7]\n" +
- " [pc: 36, line: 5]\n" +
- " [pc: 42, line: 9]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 43] local: args index: 0 type: java.lang.String[]\n" +
- " [pc: 8, pc: 43] local: tab index: 1 type: int[]\n" +
- " [pc: 26, pc: 36] local: e index: 2 type: int\n";
+ " [pc: 19, line: 6]\n" +
+ " [pc: 26, line: 9]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 27] local: args index: 0 type: java.lang.String[]\n" +
+ " [pc: 8, pc: 27] local: tab index: 1 type: int[]\n" +
+ " [pc: 19, pc: 26] local: e index: 2 type: int\n";
try {
File f = new File(OUTPUT_DIR + File.separator + "X.class");
@@ -760,7 +751,7 @@
String expectedOutput =
" // Method descriptor #15 ([Ljava/lang/String;)V\n" +
- " // Stack: 2, Locals: 5\n" +
+ " // Stack: 2, Locals: 3\n" +
" public static void main(java.lang.String[] args);\n" +
" 0 iconst_0\n" +
" 1 newarray int [10]\n" +
@@ -769,36 +760,27 @@
" 7 ldc [22]\n" +
" 9 invokevirtual java.io.PrintStream.print(java.lang.String) : void [24]\n" +
" 12 aload_1 [tab]\n" +
- " 13 astore 4\n" +
- " 15 iconst_0\n" +
- " 16 istore_2\n" +
- " 17 aload 4\n" +
- " 19 arraylength\n" +
- " 20 istore_3\n" +
- " 21 goto 35\n" +
- " 24 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
- " 27 ldc [30]\n" +
- " 29 invokevirtual java.io.PrintStream.print(java.lang.String) : void [24]\n" +
- " 32 goto 40\n" +
- " 35 iload_2\n" +
- " 36 iload_3\n" +
- " 37 if_icmplt 24\n" +
- " 40 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
- " 43 ldc [32]\n" +
- " 45 invokevirtual java.io.PrintStream.println(java.lang.String) : void [34]\n" +
- " 48 return\n" +
+ " 13 dup\n" +
+ " 14 astore_2\n" +
+ " 15 arraylength\n" +
+ " 16 ifeq 27\n" +
+ " 19 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
+ " 22 ldc [30]\n" +
+ " 24 invokevirtual java.io.PrintStream.print(java.lang.String) : void [24]\n" +
+ " 27 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
+ " 30 ldc [32]\n" +
+ " 32 invokevirtual java.io.PrintStream.println(java.lang.String) : void [34]\n" +
+ " 35 return\n" +
" Line numbers:\n" +
" [pc: 0, line: 4]\n" +
" [pc: 4, line: 5]\n" +
" [pc: 12, line: 6]\n" +
- " [pc: 24, line: 7]\n" +
- " [pc: 32, line: 8]\n" +
- " [pc: 35, line: 6]\n" +
- " [pc: 40, line: 10]\n" +
- " [pc: 48, line: 11]\n" +
+ " [pc: 19, line: 7]\n" +
+ " [pc: 27, line: 10]\n" +
+ " [pc: 35, line: 11]\n" +
" Local variable table:\n" +
- " [pc: 0, pc: 49] local: args index: 0 type: java.lang.String[]\n" +
- " [pc: 4, pc: 49] local: tab index: 1 type: int[]\n";
+ " [pc: 0, pc: 36] local: args index: 0 type: java.lang.String[]\n" +
+ " [pc: 4, pc: 36] local: tab index: 1 type: int[]\n";
try {
File f = new File(OUTPUT_DIR + File.separator + "X.class");
@@ -851,35 +833,35 @@
" 7 ldc [22]\n" +
" 9 invokevirtual java.io.PrintStream.print(java.lang.String) : void [24]\n" +
" 12 aload_1 [tab]\n" +
- " 13 astore 4\n" +
- " 15 iconst_0\n" +
- " 16 istore_2\n" +
- " 17 aload 4\n" +
- " 19 arraylength\n" +
- " 20 istore_3\n" +
- " 21 goto 35\n" +
- " 24 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
- " 27 ldc [30]\n" +
- " 29 invokevirtual java.io.PrintStream.print(java.lang.String) : void [24]\n" +
- " 32 iinc 2 1\n" +
- " 35 iload_2\n" +
- " 36 iload_3\n" +
- " 37 if_icmplt 24\n" +
- " 40 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
- " 43 ldc [32]\n" +
- " 45 invokevirtual java.io.PrintStream.println(java.lang.String) : void [34]\n" +
- " 48 return\n" +
+ " 13 dup\n" +
+ " 14 astore 4\n" +
+ " 16 arraylength\n" +
+ " 17 istore_3\n" +
+ " 18 iconst_0\n" +
+ " 19 istore_2\n" +
+ " 20 goto 34\n" +
+ " 23 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
+ " 26 ldc [30]\n" +
+ " 28 invokevirtual java.io.PrintStream.print(java.lang.String) : void [24]\n" +
+ " 31 iinc 2 1\n" +
+ " 34 iload_2\n" +
+ " 35 iload_3\n" +
+ " 36 if_icmplt 23\n" +
+ " 39 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
+ " 42 ldc [32]\n" +
+ " 44 invokevirtual java.io.PrintStream.println(java.lang.String) : void [34]\n" +
+ " 47 return\n" +
" Line numbers:\n" +
" [pc: 0, line: 4]\n" +
" [pc: 4, line: 5]\n" +
" [pc: 12, line: 6]\n" +
- " [pc: 24, line: 7]\n" +
- " [pc: 32, line: 6]\n" +
- " [pc: 40, line: 10]\n" +
- " [pc: 48, line: 11]\n" +
+ " [pc: 23, line: 7]\n" +
+ " [pc: 31, line: 6]\n" +
+ " [pc: 39, line: 10]\n" +
+ " [pc: 47, line: 11]\n" +
" Local variable table:\n" +
- " [pc: 0, pc: 49] local: args index: 0 type: java.lang.String[]\n" +
- " [pc: 4, pc: 49] local: tab index: 1 type: int[]\n";
+ " [pc: 0, pc: 48] local: args index: 0 type: java.lang.String[]\n" +
+ " [pc: 4, pc: 48] local: tab index: 1 type: int[]\n";
try {
File f = new File(OUTPUT_DIR + File.separator + "X.class");
@@ -976,59 +958,59 @@
" 51 istore_3 [i]\n" +
" 52 iinc 3 1 [i]\n" +
" 55 aload_1 [tab]\n" +
- " 56 astore 7\n" +
- " 58 iconst_0\n" +
- " 59 istore 5\n" +
- " 61 aload 7\n" +
- " 63 arraylength\n" +
- " 64 istore 6\n" +
- " 66 goto 101\n" +
- " 69 aload 7\n" +
- " 71 iload 5\n" +
- " 73 iaload\n" +
- " 74 istore 4 [e]\n" +
- " 76 iload_2 [sum]\n" +
- " 77 iload 4 [e]\n" +
- " 79 iadd\n" +
- " 80 istore_2 [sum]\n" +
- " 81 iload_3 [i]\n" +
- " 82 iconst_3\n" +
- " 83 if_icmpne 89\n" +
- " 86 goto 111\n" +
- " 89 iload 4 [e]\n" +
- " 91 iconst_5\n" +
- " 92 if_icmpne 98\n" +
- " 95 goto 52\n" +
- " 98 iinc 5 1\n" +
- " 101 iload 5\n" +
- " 103 iload 6\n" +
- " 105 if_icmplt 69\n" +
- " 108 goto 52\n" +
- " 111 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
- " 114 iload_2 [sum]\n" +
- " 115 invokevirtual java.io.PrintStream.println(int) : void [22]\n" +
- " 118 return\n" +
+ " 56 dup\n" +
+ " 57 astore 7\n" +
+ " 59 arraylength\n" +
+ " 60 istore 6\n" +
+ " 62 iconst_0\n" +
+ " 63 istore 5\n" +
+ " 65 goto 100\n" +
+ " 68 aload 7\n" +
+ " 70 iload 5\n" +
+ " 72 iaload\n" +
+ " 73 istore 4 [e]\n" +
+ " 75 iload_2 [sum]\n" +
+ " 76 iload 4 [e]\n" +
+ " 78 iadd\n" +
+ " 79 istore_2 [sum]\n" +
+ " 80 iload_3 [i]\n" +
+ " 81 iconst_3\n" +
+ " 82 if_icmpne 88\n" +
+ " 85 goto 110\n" +
+ " 88 iload 4 [e]\n" +
+ " 90 iconst_5\n" +
+ " 91 if_icmpne 97\n" +
+ " 94 goto 52\n" +
+ " 97 iinc 5 1\n" +
+ " 100 iload 5\n" +
+ " 102 iload 6\n" +
+ " 104 if_icmplt 68\n" +
+ " 107 goto 52\n" +
+ " 110 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
+ " 113 iload_2 [sum]\n" +
+ " 114 invokevirtual java.io.PrintStream.println(int) : void [22]\n" +
+ " 117 return\n" +
" Line numbers:\n" +
" [pc: 0, line: 3]\n" +
" [pc: 48, line: 4]\n" +
" [pc: 50, line: 5]\n" +
" [pc: 52, line: 7]\n" +
" [pc: 55, line: 8]\n" +
- " [pc: 76, line: 9]\n" +
- " [pc: 81, line: 10]\n" +
- " [pc: 86, line: 11]\n" +
- " [pc: 89, line: 12]\n" +
- " [pc: 95, line: 13]\n" +
- " [pc: 98, line: 8]\n" +
- " [pc: 108, line: 6]\n" +
- " [pc: 111, line: 19]\n" +
- " [pc: 118, line: 20]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 119] local: args index: 0 type: java.lang.String[]\n" +
- " [pc: 48, pc: 119] local: tab index: 1 type: int[]\n" +
- " [pc: 50, pc: 119] local: sum index: 2 type: int\n" +
- " [pc: 52, pc: 119] local: i index: 3 type: int\n" +
- " [pc: 76, pc: 98] local: e index: 4 type: int\n";
+ " [pc: 75, line: 9]\n" +
+ " [pc: 80, line: 10]\n" +
+ " [pc: 85, line: 11]\n" +
+ " [pc: 88, line: 12]\n" +
+ " [pc: 94, line: 13]\n" +
+ " [pc: 97, line: 8]\n" +
+ " [pc: 107, line: 6]\n" +
+ " [pc: 110, line: 19]\n" +
+ " [pc: 117, line: 20]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 118] local: args index: 0 type: java.lang.String[]\n" +
+ " [pc: 48, pc: 118] local: tab index: 1 type: int[]\n" +
+ " [pc: 50, pc: 118] local: sum index: 2 type: int\n" +
+ " [pc: 52, pc: 118] local: i index: 3 type: int\n" +
+ " [pc: 75, pc: 97] local: e index: 4 type: int\n";
try {
File f = new File(OUTPUT_DIR + File.separator + "X.class");
@@ -1221,55 +1203,55 @@
" 14 invokespecial java.util.ArrayList() [22]\n" +
" 17 astore_2 [list]\n" +
" 18 aload_1 [tab]\n" +
- " 19 astore 6\n" +
- " 21 iconst_0\n" +
- " 22 istore 4\n" +
- " 24 aload 6\n" +
- " 26 arraylength\n" +
- " 27 istore 5\n" +
- " 29 goto 49\n" +
- " 32 aload 6\n" +
- " 34 iload 4\n" +
- " 36 aaload\n" +
- " 37 astore_3 [arg]\n" +
- " 38 aload_2 [list]\n" +
- " 39 aload_3 [arg]\n" +
- " 40 invokeinterface java.util.List.add(java.lang.Object) : boolean [23] [nargs: 2]\n" +
- " 45 pop\n" +
- " 46 iinc 4 1\n" +
- " 49 iload 4\n" +
- " 51 iload 5\n" +
- " 53 if_icmplt 32\n" +
- " 56 aload_2 [list]\n" +
- " 57 invokeinterface java.util.List.iterator() : java.util.Iterator [29] [nargs: 1]\n" +
- " 62 astore 4\n" +
- " 64 goto 82\n" +
- " 67 aload 4\n" +
- " 69 invokeinterface java.util.Iterator.next() : java.lang.Object [33] [nargs: 1]\n" +
- " 74 astore_3 [arg]\n" +
- " 75 getstatic java.lang.System.out : java.io.PrintStream [39]\n" +
- " 78 aload_3 [arg]\n" +
- " 79 invokevirtual java.io.PrintStream.print(java.lang.Object) : void [45]\n" +
- " 82 aload 4\n" +
- " 84 invokeinterface java.util.Iterator.hasNext() : boolean [51] [nargs: 1]\n" +
- " 89 ifne 67\n" +
- " 92 return\n" +
+ " 19 dup\n" +
+ " 20 astore 6\n" +
+ " 22 arraylength\n" +
+ " 23 istore 5\n" +
+ " 25 iconst_0\n" +
+ " 26 istore 4\n" +
+ " 28 goto 48\n" +
+ " 31 aload 6\n" +
+ " 33 iload 4\n" +
+ " 35 aaload\n" +
+ " 36 astore_3 [arg]\n" +
+ " 37 aload_2 [list]\n" +
+ " 38 aload_3 [arg]\n" +
+ " 39 invokeinterface java.util.List.add(java.lang.Object) : boolean [23] [nargs: 2]\n" +
+ " 44 pop\n" +
+ " 45 iinc 4 1\n" +
+ " 48 iload 4\n" +
+ " 50 iload 5\n" +
+ " 52 if_icmplt 31\n" +
+ " 55 aload_2 [list]\n" +
+ " 56 invokeinterface java.util.List.iterator() : java.util.Iterator [29] [nargs: 1]\n" +
+ " 61 astore 4\n" +
+ " 63 goto 81\n" +
+ " 66 aload 4\n" +
+ " 68 invokeinterface java.util.Iterator.next() : java.lang.Object [33] [nargs: 1]\n" +
+ " 73 astore_3 [arg]\n" +
+ " 74 getstatic java.lang.System.out : java.io.PrintStream [39]\n" +
+ " 77 aload_3 [arg]\n" +
+ " 78 invokevirtual java.io.PrintStream.print(java.lang.Object) : void [45]\n" +
+ " 81 aload 4\n" +
+ " 83 invokeinterface java.util.Iterator.hasNext() : boolean [51] [nargs: 1]\n" +
+ " 88 ifne 66\n" +
+ " 91 return\n" +
" Line numbers:\n" +
" [pc: 0, line: 6]\n" +
" [pc: 10, line: 7]\n" +
" [pc: 18, line: 8]\n" +
- " [pc: 38, line: 9]\n" +
- " [pc: 46, line: 8]\n" +
- " [pc: 56, line: 11]\n" +
- " [pc: 75, line: 12]\n" +
- " [pc: 82, line: 11]\n" +
- " [pc: 92, line: 14]\n" +
- " Local variable table:\n" +
- " [pc: 0, pc: 93] local: args index: 0 type: java.lang.String[]\n" +
- " [pc: 10, pc: 93] local: tab index: 1 type: java.lang.String[]\n" +
- " [pc: 18, pc: 93] local: list index: 2 type: java.util.List\n" +
- " [pc: 38, pc: 46] local: arg index: 3 type: java.lang.String\n" +
- " [pc: 75, pc: 82] local: arg index: 3 type: java.lang.Object\n";
+ " [pc: 37, line: 9]\n" +
+ " [pc: 45, line: 8]\n" +
+ " [pc: 55, line: 11]\n" +
+ " [pc: 74, line: 12]\n" +
+ " [pc: 81, line: 11]\n" +
+ " [pc: 91, line: 14]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 92] local: args index: 0 type: java.lang.String[]\n" +
+ " [pc: 10, pc: 92] local: tab index: 1 type: java.lang.String[]\n" +
+ " [pc: 18, pc: 92] local: list index: 2 type: java.util.List\n" +
+ " [pc: 37, pc: 45] local: arg index: 3 type: java.lang.String\n" +
+ " [pc: 74, pc: 81] local: arg index: 3 type: java.lang.Object\n";
try {
File f = new File(OUTPUT_DIR + File.separator + "X.class");
@@ -1360,45 +1342,38 @@
String expectedOutput =
" // Method descriptor #15 ([Ljava/lang/String;)V\n" +
- " // Stack: 2, Locals: 5\n" +
+ " // Stack: 2, Locals: 3\n" +
" public static void main(java.lang.String[] args);\n" +
" 0 iconst_0\n" +
" 1 anewarray java.lang.Object [3]\n" +
" 4 astore_1 [array]\n" +
" 5 aload_1 [array]\n" +
- " 6 astore 4\n" +
- " 8 iconst_0\n" +
- " 9 istore_2\n" +
- " 10 aload 4\n" +
- " 12 arraylength\n" +
- " 13 istore_3\n" +
- " 14 goto 27\n" +
- " 17 aload_0 [args]\n" +
- " 18 ifnonnull 26\n" +
- " 21 aconst_null\n" +
- " 22 pop\n" +
- " 23 goto 32\n" +
- " 26 return\n" +
- " 27 iload_2\n" +
- " 28 iload_3\n" +
- " 29 if_icmplt 17\n" +
- " 32 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
- " 35 ldc [22]\n" +
- " 37 invokevirtual java.io.PrintStream.println(java.lang.String) : void [24]\n" +
- " 40 return\n" +
+ " 6 dup\n" +
+ " 7 astore_2\n" +
+ " 8 arraylength\n" +
+ " 9 ifeq 22\n" +
+ " 12 aload_0 [args]\n" +
+ " 13 ifnonnull 21\n" +
+ " 16 aconst_null\n" +
+ " 17 pop\n" +
+ " 18 goto 22\n" +
+ " 21 return\n" +
+ " 22 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
+ " 25 ldc [22]\n" +
+ " 27 invokevirtual java.io.PrintStream.println(java.lang.String) : void [24]\n" +
+ " 30 return\n" +
" Line numbers:\n" +
" [pc: 0, line: 3]\n" +
" [pc: 5, line: 6]\n" +
- " [pc: 17, line: 7]\n" +
- " [pc: 21, line: 8]\n" +
- " [pc: 23, line: 9]\n" +
- " [pc: 26, line: 11]\n" +
- " [pc: 27, line: 6]\n" +
- " [pc: 32, line: 13]\n" +
- " [pc: 40, line: 14]\n" +
+ " [pc: 12, line: 7]\n" +
+ " [pc: 16, line: 8]\n" +
+ " [pc: 18, line: 9]\n" +
+ " [pc: 21, line: 11]\n" +
+ " [pc: 22, line: 13]\n" +
+ " [pc: 30, line: 14]\n" +
" Local variable table:\n" +
- " [pc: 0, pc: 41] local: args index: 0 type: java.lang.String[]\n" +
- " [pc: 5, pc: 41] local: array index: 1 type: java.lang.Object[]\n";
+ " [pc: 0, pc: 31] local: args index: 0 type: java.lang.String[]\n" +
+ " [pc: 5, pc: 31] local: array index: 1 type: java.lang.Object[]\n";
try {
File f = new File(OUTPUT_DIR + File.separator + "X.class");
@@ -2386,27 +2361,27 @@
" // Stack: 2, Locals: 5\n" +
" public static void main(java.lang.String[] args);\n" +
" 0 invokestatic X.initForEach() : int[] [16]\n" +
- " 3 astore 4\n" +
- " 5 iconst_0\n" +
- " 6 istore_2\n" +
- " 7 aload 4\n" +
- " 9 arraylength\n" +
- " 10 istore_3\n" +
- " 11 goto 22\n" +
- " 14 aload 4\n" +
- " 16 iload_2\n" +
- " 17 iaload\n" +
- " 18 istore_1\n" +
- " 19 iinc 2 1\n" +
- " 22 iload_2\n" +
- " 23 iload_3\n" +
- " 24 if_icmplt 14\n" +
- " 27 return\n" +
+ " 3 dup\n" +
+ " 4 astore 4\n" +
+ " 6 arraylength\n" +
+ " 7 istore_3\n" +
+ " 8 iconst_0\n" +
+ " 9 istore_2\n" +
+ " 10 goto 21\n" +
+ " 13 aload 4\n" +
+ " 15 iload_2\n" +
+ " 16 iaload\n" +
+ " 17 istore_1\n" +
+ " 18 iinc 2 1\n" +
+ " 21 iload_2\n" +
+ " 22 iload_3\n" +
+ " 23 if_icmplt 13\n" +
+ " 26 return\n" +
" Line numbers:\n" +
" [pc: 0, line: 3]\n" +
- " [pc: 27, line: 5]\n" +
+ " [pc: 26, line: 5]\n" +
" Local variable table:\n" +
- " [pc: 0, pc: 28] local: args index: 0 type: java.lang.String[]\n";
+ " [pc: 0, pc: 27] local: args index: 0 type: java.lang.String[]\n";
try {
File f = new File(OUTPUT_DIR + File.separator + "X.class");
@@ -2510,12 +2485,12 @@
" // Stack: 2, Locals: 4\n" +
" public static void foo();\n" +
" 0 invokestatic X.initForEach() : int[] [21]\n" +
- " 3 astore_3\n" +
- " 4 iconst_0\n" +
- " 5 istore_1\n" +
- " 6 aload_3\n" +
- " 7 arraylength\n" +
- " 8 istore_2\n" +
+ " 3 dup\n" +
+ " 4 astore_3\n" +
+ " 5 arraylength\n" +
+ " 6 istore_2\n" +
+ " 7 iconst_0\n" +
+ " 8 istore_1\n" +
" 9 goto 19\n" +
" 12 aload_3\n" +
" 13 iload_1\n" +
@@ -2579,33 +2554,33 @@
" // Stack: 2, Locals: 5\n" +
" public static void main(java.lang.String[] args);\n" +
" 0 invokestatic X.initForEach() : int[] [16]\n" +
- " 3 astore 4\n" +
- " 5 iconst_0\n" +
- " 6 istore_2\n" +
- " 7 aload 4\n" +
- " 9 arraylength\n" +
- " 10 istore_3\n" +
- " 11 goto 30\n" +
- " 14 aload 4\n" +
- " 16 iload_2\n" +
- " 17 iaload\n" +
- " 18 istore_1 [i]\n" +
- " 19 getstatic java.lang.System.out : java.io.PrintStream [20]\n" +
- " 22 bipush 97\n" +
- " 24 invokevirtual java.io.PrintStream.print(char) : void [26]\n" +
- " 27 iinc 2 1\n" +
- " 30 iload_2\n" +
- " 31 iload_3\n" +
- " 32 if_icmplt 14\n" +
- " 35 return\n" +
+ " 3 dup\n" +
+ " 4 astore 4\n" +
+ " 6 arraylength\n" +
+ " 7 istore_3\n" +
+ " 8 iconst_0\n" +
+ " 9 istore_2\n" +
+ " 10 goto 29\n" +
+ " 13 aload 4\n" +
+ " 15 iload_2\n" +
+ " 16 iaload\n" +
+ " 17 istore_1 [i]\n" +
+ " 18 getstatic java.lang.System.out : java.io.PrintStream [20]\n" +
+ " 21 bipush 97\n" +
+ " 23 invokevirtual java.io.PrintStream.print(char) : void [26]\n" +
+ " 26 iinc 2 1\n" +
+ " 29 iload_2\n" +
+ " 30 iload_3\n" +
+ " 31 if_icmplt 13\n" +
+ " 34 return\n" +
" Line numbers:\n" +
" [pc: 0, line: 3]\n" +
- " [pc: 19, line: 4]\n" +
- " [pc: 27, line: 3]\n" +
- " [pc: 35, line: 6]\n" +
+ " [pc: 18, line: 4]\n" +
+ " [pc: 26, line: 3]\n" +
+ " [pc: 34, line: 6]\n" +
" Local variable table:\n" +
- " [pc: 0, pc: 36] local: args index: 0 type: java.lang.String[]\n" +
- " [pc: 19, pc: 27] local: i index: 1 type: int\n";
+ " [pc: 0, pc: 35] local: args index: 0 type: java.lang.String[]\n" +
+ " [pc: 18, pc: 26] local: i index: 1 type: int\n";
try {
File f = new File(OUTPUT_DIR + File.separator + "X.class");
@@ -2656,12 +2631,12 @@
" // Stack: 2, Locals: 4\n" +
" public static void main(java.lang.String[] args);\n" +
" 0 invokestatic X.initForEach() : int[] [16]\n" +
- " 3 astore_3\n" +
- " 4 iconst_0\n" +
- " 5 istore_1\n" +
- " 6 aload_3\n" +
- " 7 arraylength\n" +
- " 8 istore_2\n" +
+ " 3 dup\n" +
+ " 4 astore_3\n" +
+ " 5 arraylength\n" +
+ " 6 istore_2\n" +
+ " 7 iconst_0\n" +
+ " 8 istore_1\n" +
" 9 goto 23\n" +
" 12 getstatic java.lang.System.out : java.io.PrintStream [20]\n" +
" 15 bipush 97\n" +
@@ -2697,6 +2672,188 @@
assertTrue(false);
}
}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=180471
+public void test047() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " void foo3(int[] array) {\n" +
+ " for (int i : array) {\n" +
+ " System.out.println(i);\n" +
+ " break;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n", // =================
+ },
+ "");
+
+ String expectedOutput =
+ " // Method descriptor #15 ([I)V\n" +
+ " // Stack: 2, Locals: 4\n" +
+ " void foo3(int[] array);\n" +
+ " 0 aload_1 [array]\n" +
+ " 1 dup\n" +
+ " 2 astore_3\n" +
+ " 3 arraylength\n" +
+ " 4 ifeq 18\n" +
+ " 7 aload_3\n" +
+ " 8 iconst_0\n" +
+ " 9 iaload\n" +
+ " 10 istore_2 [i]\n" +
+ " 11 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
+ " 14 iload_2 [i]\n" +
+ " 15 invokevirtual java.io.PrintStream.println(int) : void [22]\n" +
+ " 18 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 3]\n" +
+ " [pc: 11, line: 4]\n" +
+ " [pc: 18, line: 7]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 19] local: this index: 0 type: X\n" +
+ " [pc: 0, pc: 19] local: array index: 1 type: int[]\n" +
+ " [pc: 11, pc: 18] local: i index: 2 type: int\n";
+
+ try {
+ File f = new File(OUTPUT_DIR + File.separator + "X.class");
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=180471 - variation
+public void test048() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " void foo3(java.util.List ls) {\n" +
+ " for (String s : ls) {\n" +
+ " System.out.println(s);\n" +
+ " break;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n", // =================
+ },
+ "");
+
+ String expectedOutput =
+ " // Method descriptor #15 ([I)V\n" +
+ " // Stack: 2, Locals: 4\n" +
+ " void foo3(int[] array);\n" +
+ " 0 aload_1 [array]\n" +
+ " 1 dup\n" +
+ " 2 astore_3\n" +
+ " 3 arraylength\n" +
+ " 4 ifeq 18\n" +
+ " 7 aload_3\n" +
+ " 8 iconst_0\n" +
+ " 9 iaload\n" +
+ " 10 istore_2 [i]\n" +
+ " 11 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
+ " 14 iload_2 [i]\n" +
+ " 15 invokevirtual java.io.PrintStream.println(int) : void [22]\n" +
+ " 18 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 3]\n" +
+ " [pc: 11, line: 4]\n" +
+ " [pc: 18, line: 7]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 19] local: this index: 0 type: X\n" +
+ " [pc: 0, pc: 19] local: array index: 1 type: int[]\n" +
+ " [pc: 11, pc: 18] local: i index: 2 type: int\n";
+
+ try {
+ File f = new File(OUTPUT_DIR + File.separator + "X.class");
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=180471 - variation
+public void test049() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " void foo3(int[] array) {\n" +
+ " void foo3(java.util.List l) {\n" +
+ " for (Object o : l) {\n" +
+ " System.out.println(o);\n" +
+ " break;\n" +
+ " }\n" +
+ " }\n" +
+ " }\n" +
+ "}\n", // =================
+ },
+ "");
+
+ String expectedOutput =
+ " // Method descriptor #15 ([I)V\n" +
+ " // Stack: 2, Locals: 4\n" +
+ " void foo3(int[] array);\n" +
+ " 0 aload_1 [array]\n" +
+ " 1 dup\n" +
+ " 2 astore_3\n" +
+ " 3 arraylength\n" +
+ " 4 ifeq 18\n" +
+ " 7 aload_3\n" +
+ " 8 iconst_0\n" +
+ " 9 iaload\n" +
+ " 10 istore_2 [i]\n" +
+ " 11 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
+ " 14 iload_2 [i]\n" +
+ " 15 invokevirtual java.io.PrintStream.println(int) : void [22]\n" +
+ " 18 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 3]\n" +
+ " [pc: 11, line: 4]\n" +
+ " [pc: 18, line: 7]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 19] local: this index: 0 type: X\n" +
+ " [pc: 0, pc: 19] local: array index: 1 type: int[]\n" +
+ " [pc: 11, pc: 18] local: i index: 2 type: int\n";
+
+ try {
+ File f = new File(OUTPUT_DIR + File.separator + "X.class");
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+}
public static Class testClass() {
return ForeachStatementTest.class;
}
Index: src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java,v
--- src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java 6 Feb 2007 14:22:07 -0000 1.23
+++ src/org/eclipse/jdt/core/tests/compiler/regression/StackMapAttributeTest.java 2 Apr 2007 19:58:45 -0000
@@ -1734,53 +1734,53 @@
" 2 iconst_0\n" +
" 3 istore_2 [n]\n" +
" 4 invokestatic X.values() : X[] [46]\n" +
- " 7 astore 6\n" +
- " 9 iconst_0\n" +
- " 10 istore 4\n" +
- " 12 aload 6\n" +
- " 14 arraylength\n" +
- " 15 istore 5\n" +
- " 17 goto 49\n" +
- " 20 aload 6\n" +
- " 22 iload 4\n" +
- " 24 aaload\n" +
- " 25 astore_3 [e]\n" +
- " 26 iload_2 [n]\n" +
- " 27 iconst_1\n" +
- " 28 if_icmpne 34\n" +
- " 31 goto 46\n" +
- " 34 aload_3 [e]\n" +
- " 35 invokevirtual X.value() : int [50]\n" +
- " 38 istore_0 [val]\n" +
- " 39 getstatic java.lang.System.out : java.io.PrintStream [52]\n" +
- " 42 iload_0 [val]\n" +
- " 43 invokevirtual java.io.PrintStream.println(int) : void [58]\n" +
- " 46 iinc 4 1\n" +
- " 49 iload 4\n" +
- " 51 iload 5\n" +
- " 53 if_icmplt 20\n" +
- " 56 iload_1 [res]\n" +
- " 57 ireturn\n" +
+ " 7 dup\n" +
+ " 8 astore 6\n" +
+ " 10 arraylength\n" +
+ " 11 istore 5\n" +
+ " 13 iconst_0\n" +
+ " 14 istore 4\n" +
+ " 16 goto 48\n" +
+ " 19 aload 6\n" +
+ " 21 iload 4\n" +
+ " 23 aaload\n" +
+ " 24 astore_3 [e]\n" +
+ " 25 iload_2 [n]\n" +
+ " 26 iconst_1\n" +
+ " 27 if_icmpne 33\n" +
+ " 30 goto 45\n" +
+ " 33 aload_3 [e]\n" +
+ " 34 invokevirtual X.value() : int [50]\n" +
+ " 37 istore_0 [val]\n" +
+ " 38 getstatic java.lang.System.out : java.io.PrintStream [52]\n" +
+ " 41 iload_0 [val]\n" +
+ " 42 invokevirtual java.io.PrintStream.println(int) : void [58]\n" +
+ " 45 iinc 4 1\n" +
+ " 48 iload 4\n" +
+ " 50 iload 5\n" +
+ " 52 if_icmplt 19\n" +
+ " 55 iload_1 [res]\n" +
+ " 56 ireturn\n" +
" Line numbers:\n" +
" [pc: 0, line: 14]\n" +
" [pc: 2, line: 15]\n" +
" [pc: 4, line: 16]\n" +
- " [pc: 26, line: 17]\n" +
- " [pc: 31, line: 18]\n" +
- " [pc: 34, line: 20]\n" +
- " [pc: 39, line: 21]\n" +
- " [pc: 46, line: 16]\n" +
- " [pc: 56, line: 23]\n" +
+ " [pc: 25, line: 17]\n" +
+ " [pc: 30, line: 18]\n" +
+ " [pc: 33, line: 20]\n" +
+ " [pc: 38, line: 21]\n" +
+ " [pc: 45, line: 16]\n" +
+ " [pc: 55, line: 23]\n" +
" Local variable table:\n" +
- " [pc: 39, pc: 46] local: val index: 0 type: int\n" +
- " [pc: 2, pc: 58] local: res index: 1 type: int\n" +
- " [pc: 4, pc: 58] local: n index: 2 type: int\n" +
- " [pc: 26, pc: 46] local: e index: 3 type: X\n" +
+ " [pc: 38, pc: 45] local: val index: 0 type: int\n" +
+ " [pc: 2, pc: 57] local: res index: 1 type: int\n" +
+ " [pc: 4, pc: 57] local: n index: 2 type: int\n" +
+ " [pc: 25, pc: 45] local: e index: 3 type: X\n" +
" Stack map table: number of frames 4\n" +
- " [pc: 20, full, stack: {}, locals: {_, int, int, _, int, int, X[]}]\n" +
- " [pc: 34, full, stack: {}, locals: {_, int, int, X, int, int, X[]}]\n" +
- " [pc: 46, full, stack: {}, locals: {_, int, int, _, int, int, X[]}]\n" +
- " [pc: 49, same]\n";
+ " [pc: 19, full, stack: {}, locals: {_, int, int, _, int, int, X[]}]\n" +
+ " [pc: 33, full, stack: {}, locals: {_, int, int, X, int, int, X[]}]\n" +
+ " [pc: 45, full, stack: {}, locals: {_, int, int, _, int, int, X[]}]\n" +
+ " [pc: 48, same]\n";
int index = actualOutput.indexOf(expectedOutput);
if (index == -1 || expectedOutput.length() == 0) {
Index: src/org/eclipse/jdt/core/tests/compiler/regression/ForStatementTest.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ForStatementTest.java,v
--- src/org/eclipse/jdt/core/tests/compiler/regression/ForStatementTest.java 14 Aug 2006 18:22:45 -0000 1.1
+++ src/org/eclipse/jdt/core/tests/compiler/regression/ForStatementTest.java 2 Apr 2007 19:58:42 -0000
@@ -10,10 +10,15 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
+import java.io.File;
+import java.io.IOException;
import java.util.Map;
import junit.framework.Test;
+import org.eclipse.jdt.core.ToolFactory;
+import org.eclipse.jdt.core.tests.util.Util;
+import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
public class ForStatementTest extends AbstractRegressionTest {
@@ -71,6 +76,164 @@
},
"SUCCESS");
}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=180471
+public void test002() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " void foo2(int[] array) {\n" +
+ " for (int i = 0; i < array.length; i++) {\n" +
+ " System.out.println(i);\n" +
+ " break;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n", // =================
+ },
+ "");
+
+ String expectedOutput =
+ " // Method descriptor #15 ([I)V\n" +
+ " // Stack: 2, Locals: 3\n" +
+ " void foo2(int[] array);\n" +
+ " 0 iconst_0\n" +
+ " 1 istore_2 [i]\n" +
+ " 2 iload_2 [i]\n" +
+ " 3 aload_1 [array]\n" +
+ " 4 arraylength\n" +
+ " 5 if_icmpge 15\n" +
+ " 8 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
+ " 11 iload_2 [i]\n" +
+ " 12 invokevirtual java.io.PrintStream.println(int) : void [22]\n" +
+ " 15 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 3]\n" +
+ " [pc: 8, line: 4]\n" +
+ " [pc: 15, line: 7]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 16] local: this index: 0 type: X\n" +
+ " [pc: 0, pc: 16] local: array index: 1 type: int[]\n" +
+ " [pc: 2, pc: 15] local: i index: 2 type: int\n";
+
+ try {
+ File f = new File(OUTPUT_DIR + File.separator + "X.class");
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=180471 - variation
+public void test003() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " void foo4(int[] array) {\n" +
+ " do {\n" +
+ " System.out.println();\n" +
+ " break;\n" +
+ " } while (array.length > 0);\n" +
+ " }\n" +
+ "}\n", // =================
+ },
+ "");
+
+ String expectedOutput =
+ " // Method descriptor #15 ([I)V\n" +
+ " // Stack: 1, Locals: 2\n" +
+ " void foo4(int[] array);\n" +
+ " 0 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
+ " 3 invokevirtual java.io.PrintStream.println() : void [22]\n" +
+ " 6 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 4]\n" +
+ " [pc: 6, line: 7]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 7] local: this index: 0 type: X\n" +
+ " [pc: 0, pc: 7] local: array index: 1 type: int[]\n";
+
+ try {
+ File f = new File(OUTPUT_DIR + File.separator + "X.class");
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+}
+//https://bugs.eclipse.org/bugs/show_bug.cgi?id=180471 - variation
+public void test004() {
+ this.runConformTest(
+ new String[] {
+ "X.java",
+ "public class X {\n" +
+ " void foo1(int[] array) {\n" +
+ " while (array.length > 0) {\n" +
+ " System.out.println();\n" +
+ " break;\n" +
+ " }\n" +
+ " }\n" +
+ "}\n", // =================
+ },
+ "");
+
+ String expectedOutput =
+ " // Method descriptor #15 ([I)V\n" +
+ " // Stack: 1, Locals: 2\n" +
+ " void foo1(int[] array);\n" +
+ " 0 aload_1 [array]\n" +
+ " 1 arraylength\n" +
+ " 2 ifle 11\n" +
+ " 5 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
+ " 8 invokevirtual java.io.PrintStream.println() : void [22]\n" +
+ " 11 return\n" +
+ " Line numbers:\n" +
+ " [pc: 0, line: 3]\n" +
+ " [pc: 5, line: 4]\n" +
+ " [pc: 11, line: 7]\n" +
+ " Local variable table:\n" +
+ " [pc: 0, pc: 12] local: this index: 0 type: X\n" +
+ " [pc: 0, pc: 12] local: array index: 1 type: int[]\n";
+
+ try {
+ File f = new File(OUTPUT_DIR + File.separator + "X.class");
+ byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
+ ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
+ String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
+ int index = result.indexOf(expectedOutput);
+ if (index == -1 || expectedOutput.length() == 0) {
+ System.out.println(Util.displayString(result, 3));
+ }
+ if (index == -1) {
+ assertEquals("Wrong contents", expectedOutput, result);
+ }
+ } catch (org.eclipse.jdt.core.util.ClassFormatException e) {
+ assertTrue(false);
+ } catch (IOException e) {
+ assertTrue(false);
+ }
+}
+
public static Class testClass() {
return ForStatementTest.class;
}
Index: src/org/eclipse/jdt/core/tests/compiler/regression/TryStatementTest.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryStatementTest.java,v
--- src/org/eclipse/jdt/core/tests/compiler/regression/TryStatementTest.java 12 Feb 2007 18:32:15 -0000 1.35
+++ src/org/eclipse/jdt/core/tests/compiler/regression/TryStatementTest.java 2 Apr 2007 19:58:48 -0000
@@ -3633,28 +3633,24 @@
" float foo4();\n" +
" 0 iconst_0\n" +
" 1 istore_1 [i]\n" +
- " 2 goto 7\n" +
- " 5 fconst_0\n" +
- " 6 freturn\n" +
- " 7 aload_0 [this]\n" +
- " 8 invokevirtual X.bool() : boolean [17]\n" +
- " 11 ifne 5\n" +
- " 14 goto 18\n" +
- " 17 astore_1\n" +
- " 18 fconst_1\n" +
- " 19 freturn\n" +
+ " 2 aload_0 [this]\n" +
+ " 3 invokevirtual X.bool() : boolean [17]\n" +
+ " 6 ifeq 12\n" +
+ " 9 fconst_0\n" +
+ " 10 freturn\n" +
+ " 11 astore_1\n" +
+ " 12 fconst_1\n" +
+ " 13 freturn\n" +
" Exception Table:\n" +
- " [pc: 0, pc: 5] -> 17 when : java.lang.Exception\n" +
- " [pc: 7, pc: 14] -> 17 when : java.lang.Exception\n" +
+ " [pc: 0, pc: 9] -> 11 when : java.lang.Exception\n" +
" Line numbers:\n" +
" [pc: 0, line: 31]\n" +
- " [pc: 5, line: 32]\n" +
- " [pc: 7, line: 31]\n" +
- " [pc: 17, line: 34]\n" +
- " [pc: 18, line: 36]\n" +
+ " [pc: 9, line: 32]\n" +
+ " [pc: 11, line: 34]\n" +
+ " [pc: 12, line: 36]\n" +
" Local variable table:\n" +
- " [pc: 0, pc: 20] local: this index: 0 type: X\n" +
- " [pc: 2, pc: 14] local: i index: 1 type: int\n" +
+ " [pc: 0, pc: 14] local: this index: 0 type: X\n" +
+ " [pc: 2, pc: 11] local: i index: 1 type: int\n" +
" \n" +
" // Method descriptor #30 ()D\n" +
" // Stack: 2, Locals: 1\n" +
@@ -3783,33 +3779,28 @@
" float foo4();\n" +
" 0 iconst_0\n" +
" 1 istore_1 [i]\n" +
- " 2 goto 7\n" +
- " 5 fconst_0\n" +
- " 6 freturn\n" +
- " 7 aload_0 [this]\n" +
- " 8 invokevirtual X.bool() : boolean [17]\n" +
- " 11 ifne 5\n" +
- " 14 goto 18\n" +
- " 17 astore_1\n" +
- " 18 fconst_1\n" +
- " 19 freturn\n" +
+ " 2 aload_0 [this]\n" +
+ " 3 invokevirtual X.bool() : boolean [17]\n" +
+ " 6 ifeq 12\n" +
+ " 9 fconst_0\n" +
+ " 10 freturn\n" +
+ " 11 astore_1\n" +
+ " 12 fconst_1\n" +
+ " 13 freturn\n" +
" Exception Table:\n" +
- " [pc: 0, pc: 5] -> 17 when : java.lang.Exception\n" +
- " [pc: 7, pc: 14] -> 17 when : java.lang.Exception\n" +
+ " [pc: 0, pc: 9] -> 11 when : java.lang.Exception\n" +
" Line numbers:\n" +
" [pc: 0, line: 31]\n" +
- " [pc: 5, line: 32]\n" +
- " [pc: 7, line: 31]\n" +
- " [pc: 17, line: 34]\n" +
- " [pc: 18, line: 36]\n" +
+ " [pc: 9, line: 32]\n" +
+ " [pc: 11, line: 34]\n" +
+ " [pc: 12, line: 36]\n" +
" Local variable table:\n" +
- " [pc: 0, pc: 20] local: this index: 0 type: X\n" +
- " [pc: 2, pc: 14] local: i index: 1 type: int\n" +
- " Stack map table: number of frames 4\n" +
- " [pc: 5, append: {int}]\n" +
- " [pc: 7, same]\n" +
- " [pc: 17, full, stack: {java.lang.Exception}, locals: {X}]\n" +
- " [pc: 18, same]\n" +
+ " [pc: 0, pc: 14] local: this index: 0 type: X\n" +
+ " [pc: 2, pc: 11] local: i index: 1 type: int\n" +
+ " Stack map table: number of frames 3\n" +
+ " [pc: 9, append: {int}]\n" +
+ " [pc: 11, full, stack: {java.lang.Exception}, locals: {X}]\n" +
+ " [pc: 12, same]\n" +
" \n" +
" // Method descriptor #31 ()D\n" +
" // Stack: 2, Locals: 1\n" +
@@ -4024,28 +4015,25 @@
" void foo4();\n" +
" 0 iconst_0\n" +
" 1 istore_1 [i]\n" +
- " 2 goto 13\n" +
- " 5 new java.lang.NullPointerException [19]\n" +
- " 8 dup\n" +
- " 9 invokespecial java.lang.NullPointerException() [21]\n" +
- " 12 athrow\n" +
- " 13 aload_0 [this]\n" +
- " 14 invokevirtual X.bool() : boolean [17]\n" +
- " 17 ifne 5\n" +
- " 20 goto 24\n" +
- " 23 astore_1\n" +
- " 24 return\n" +
+ " 2 aload_0 [this]\n" +
+ " 3 invokevirtual X.bool() : boolean [17]\n" +
+ " 6 ifeq 18\n" +
+ " 9 new java.lang.NullPointerException [19]\n" +
+ " 12 dup\n" +
+ " 13 invokespecial java.lang.NullPointerException() [21]\n" +
+ " 16 athrow\n" +
+ " 17 astore_1\n" +
+ " 18 return\n" +
" Exception Table:\n" +
- " [pc: 0, pc: 20] -> 23 when : java.lang.Exception\n" +
+ " [pc: 0, pc: 17] -> 17 when : java.lang.Exception\n" +
" Line numbers:\n" +
" [pc: 0, line: 29]\n" +
- " [pc: 5, line: 30]\n" +
- " [pc: 13, line: 29]\n" +
- " [pc: 23, line: 32]\n" +
- " [pc: 24, line: 34]\n" +
+ " [pc: 9, line: 30]\n" +
+ " [pc: 17, line: 32]\n" +
+ " [pc: 18, line: 34]\n" +
" Local variable table:\n" +
- " [pc: 0, pc: 25] local: this index: 0 type: X\n" +
- " [pc: 2, pc: 20] local: i index: 1 type: int\n" +
+ " [pc: 0, pc: 19] local: this index: 0 type: X\n" +
+ " [pc: 2, pc: 17] local: i index: 1 type: int\n" +
" \n" +
" // Method descriptor #6 ()V\n" +
" // Stack: 2, Locals: 1\n" +
@@ -4185,33 +4173,29 @@
" void foo4();\n" +
" 0 iconst_0\n" +
" 1 istore_1 [i]\n" +
- " 2 goto 13\n" +
- " 5 new java.lang.NullPointerException [19]\n" +
- " 8 dup\n" +
- " 9 invokespecial java.lang.NullPointerException() [21]\n" +
- " 12 athrow\n" +
- " 13 aload_0 [this]\n" +
- " 14 invokevirtual X.bool() : boolean [17]\n" +
- " 17 ifne 5\n" +
- " 20 goto 24\n" +
- " 23 astore_1\n" +
- " 24 return\n" +
+ " 2 aload_0 [this]\n" +
+ " 3 invokevirtual X.bool() : boolean [17]\n" +
+ " 6 ifeq 18\n" +
+ " 9 new java.lang.NullPointerException [19]\n" +
+ " 12 dup\n" +
+ " 13 invokespecial java.lang.NullPointerException() [21]\n" +
+ " 16 athrow\n" +
+ " 17 astore_1\n" +
+ " 18 return\n" +
" Exception Table:\n" +
- " [pc: 0, pc: 20] -> 23 when : java.lang.Exception\n" +
+ " [pc: 0, pc: 17] -> 17 when : java.lang.Exception\n" +
" Line numbers:\n" +
" [pc: 0, line: 29]\n" +
- " [pc: 5, line: 30]\n" +
- " [pc: 13, line: 29]\n" +
- " [pc: 23, line: 32]\n" +
- " [pc: 24, line: 34]\n" +
+ " [pc: 9, line: 30]\n" +
+ " [pc: 17, line: 32]\n" +
+ " [pc: 18, line: 34]\n" +
" Local variable table:\n" +
- " [pc: 0, pc: 25] local: this index: 0 type: X\n" +
- " [pc: 2, pc: 20] local: i index: 1 type: int\n" +
- " Stack map table: number of frames 4\n" +
- " [pc: 5, append: {int}]\n" +
- " [pc: 13, same]\n" +
- " [pc: 23, full, stack: {java.lang.Exception}, locals: {X}]\n" +
- " [pc: 24, same]\n" +
+ " [pc: 0, pc: 19] local: this index: 0 type: X\n" +
+ " [pc: 2, pc: 17] local: i index: 1 type: int\n" +
+ " Stack map table: number of frames 3\n" +
+ " [pc: 9, append: {int}]\n" +
+ " [pc: 17, full, stack: {java.lang.Exception}, locals: {X}]\n" +
+ " [pc: 18, same]\n" +
" \n" +
" // Method descriptor #6 ()V\n" +
" // Stack: 2, Locals: 1\n" +
@@ -4420,7 +4404,7 @@
" 1 istore_1 [i]\n" +
" 2 aload_0 [this]\n" +
" 3 invokevirtual X.bool() : boolean [17]\n" +
- " 6 ifne 13\n" +
+ " 6 ifeq 13\n" +
" 9 goto 13\n" +
" 12 astore_1\n" +
" 13 return\n" +
@@ -4428,11 +4412,12 @@
" [pc: 0, pc: 9] -> 12 when : java.lang.Exception\n" +
" Line numbers:\n" +
" [pc: 0, line: 29]\n" +
+ " [pc: 9, line: 30]\n" +
" [pc: 12, line: 32]\n" +
" [pc: 13, line: 34]\n" +
" Local variable table:\n" +
" [pc: 0, pc: 14] local: this index: 0 type: X\n" +
- " [pc: 2, pc: 9] local: i index: 1 type: int\n" +
+ " [pc: 2, pc: 12] local: i index: 1 type: int\n" +
" \n" +
" // Method descriptor #6 ()V\n" +
" // Stack: 1, Locals: 1\n" +
@@ -4552,7 +4537,7 @@
" 1 istore_1 [i]\n" +
" 2 aload_0 [this]\n" +
" 3 invokevirtual X.bool() : boolean [17]\n" +
- " 6 ifne 13\n" +
+ " 6 ifeq 13\n" +
" 9 goto 13\n" +
" 12 astore_1\n" +
" 13 return\n" +
@@ -4560,13 +4545,14 @@
" [pc: 0, pc: 9] -> 12 when : java.lang.Exception\n" +
" Line numbers:\n" +
" [pc: 0, line: 29]\n" +
+ " [pc: 9, line: 30]\n" +
" [pc: 12, line: 32]\n" +
" [pc: 13, line: 34]\n" +
" Local variable table:\n" +
" [pc: 0, pc: 14] local: this index: 0 type: X\n" +
- " [pc: 2, pc: 9] local: i index: 1 type: int\n" +
+ " [pc: 2, pc: 12] local: i index: 1 type: int\n" +
" Stack map table: number of frames 3\n" +
- " [pc: 2, append: {int}]\n" +
+ " [pc: 9, append: {int}]\n" +
" [pc: 12, full, stack: {java.lang.Exception}, locals: {X}]\n" +
" [pc: 13, same]\n" +
" \n" +
@@ -4777,53 +4763,46 @@
" public static void main(java.lang.String[] argv);\n" +
" 0 iconst_0\n" +
" 1 istore_1 [i]\n" +
- " 2 goto 8\n" +
- " 5 goto 5\n" +
- " 8 iload_1 [i]\n" +
- " 9 iflt 5\n" +
- " 12 goto 16\n" +
- " 15 astore_1\n" +
- " 16 return\n" +
+ " 2 iload_1 [i]\n" +
+ " 3 ifge 10\n" +
+ " 6 goto 6\n" +
+ " 9 astore_1\n" +
+ " 10 return\n" +
" Exception Table:\n" +
- " [pc: 0, pc: 12] -> 15 when : java.lang.Exception\n" +
+ " [pc: 0, pc: 9] -> 9 when : java.lang.Exception\n" +
" Line numbers:\n" +
" [pc: 0, line: 4]\n" +
- " [pc: 5, line: 5]\n" +
- " [pc: 8, line: 4]\n" +
- " [pc: 15, line: 6]\n" +
- " [pc: 16, line: 8]\n" +
+ " [pc: 6, line: 5]\n" +
+ " [pc: 9, line: 6]\n" +
+ " [pc: 10, line: 8]\n" +
" Local variable table:\n" +
- " [pc: 0, pc: 17] local: argv index: 0 type: java.lang.String[]\n" +
- " [pc: 2, pc: 12] local: i index: 1 type: int\n"
+ " [pc: 0, pc: 11] local: argv index: 0 type: java.lang.String[]\n" +
+ " [pc: 2, pc: 9] local: i index: 1 type: int\n"
:
" // Method descriptor #15 ([Ljava/lang/String;)V\n" +
" // Stack: 1, Locals: 2\n" +
" public static void main(java.lang.String[] argv);\n" +
" 0 iconst_0\n" +
" 1 istore_1 [i]\n" +
- " 2 goto 8\n" +
- " 5 goto 5\n" +
- " 8 iload_1 [i]\n" +
- " 9 iflt 5\n" +
- " 12 goto 16\n" +
- " 15 astore_1\n" +
- " 16 return\n" +
+ " 2 iload_1 [i]\n" +
+ " 3 ifge 10\n" +
+ " 6 goto 6\n" +
+ " 9 astore_1\n" +
+ " 10 return\n" +
" Exception Table:\n" +
- " [pc: 0, pc: 12] -> 15 when : java.lang.Exception\n" +
+ " [pc: 0, pc: 9] -> 9 when : java.lang.Exception\n" +
" Line numbers:\n" +
" [pc: 0, line: 4]\n" +
- " [pc: 5, line: 5]\n" +
- " [pc: 8, line: 4]\n" +
- " [pc: 15, line: 6]\n" +
- " [pc: 16, line: 8]\n" +
+ " [pc: 6, line: 5]\n" +
+ " [pc: 9, line: 6]\n" +
+ " [pc: 10, line: 8]\n" +
" Local variable table:\n" +
- " [pc: 0, pc: 17] local: argv index: 0 type: java.lang.String[]\n" +
- " [pc: 2, pc: 12] local: i index: 1 type: int\n" +
- " Stack map table: number of frames 4\n" +
- " [pc: 5, append: {int}]\n" +
- " [pc: 8, same]\n" +
- " [pc: 15, full, stack: {java.lang.Exception}, locals: {java.lang.String[]}]\n" +
- " [pc: 16, same]\n";
+ " [pc: 0, pc: 11] local: argv index: 0 type: java.lang.String[]\n" +
+ " [pc: 2, pc: 9] local: i index: 1 type: int\n" +
+ " Stack map table: number of frames 3\n" +
+ " [pc: 6, append: {int}]\n" +
+ " [pc: 9, full, stack: {java.lang.Exception}, locals: {java.lang.String[]}]\n" +
+ " [pc: 10, same]\n";
try {
File f = new File(OUTPUT_DIR + File.separator + "X.class");
@@ -4868,7 +4847,7 @@
" 0 bipush 7\n" +
" 2 istore_1 [val]\n" +
" 3 iload_1 [val]\n" +
- " 4 ifgt 7\n" +
+ " 4 ifle 7\n" +
" 7 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
" 10 iload_1 [val]\n" +
" 11 invokevirtual java.io.PrintStream.println(int) : void [22]\n" +
@@ -4892,7 +4871,7 @@
" 0 bipush 7\n" +
" 2 istore_1 [val]\n" +
" 3 iload_1 [val]\n" +
- " 4 ifgt 7\n" +
+ " 4 ifle 7\n" +
" 7 getstatic java.lang.System.out : java.io.PrintStream [16]\n" +
" 10 iload_1 [val]\n" +
" 11 invokevirtual java.io.PrintStream.println(int) : void [22]\n" +
@@ -4909,9 +4888,8 @@
" Local variable table:\n" +
" [pc: 0, pc: 19] local: args index: 0 type: java.lang.String[]\n" +
" [pc: 3, pc: 17] local: val index: 1 type: int\n" +
- " Stack map table: number of frames 4\n" +
- " [pc: 3, append: {int}]\n" +
- " [pc: 7, same]\n" +
+ " Stack map table: number of frames 3\n" +
+ " [pc: 7, append: {int}]\n" +
" [pc: 17, full, stack: {java.lang.Exception}, locals: {java.lang.String[]}]\n" +
" [pc: 18, same]\n";