### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/DebugAttributeTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/DebugAttributeTest.java,v retrieving revision 1.10 diff -u -r1.10 DebugAttributeTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/DebugAttributeTest.java 27 Jun 2008 16:04:44 -0000 1.10 +++ src/org/eclipse/jdt/core/tests/compiler/regression/DebugAttributeTest.java 17 Dec 2008 16:20:15 -0000 @@ -133,4 +133,104 @@ assertEquals("Wrong contents", expectedOutput, result); } } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=258950 +public void test003() throws Exception { + this.runConformTest( + new String[] { + "X.java", + "import java.util.List;\n" + + "import java.util.ArrayList;\n" + + "import java.util.Iterator;\n" + + "public class X {\n" + + " public static void main(String[] args) {\n" + + " List l = new ArrayList();\n" + + " List l2 = new ArrayList();\n" + + " l.add(new X());\n" + + " for (Iterator iterator = l.iterator(); iterator.hasNext() ;) {\n" + + " l2.add(((X) iterator.next()).toString()\n" + + " .substring(3));\n" + + " }\n" + + " for (Iterator iterator = l2.iterator(); iterator.hasNext() ;) {\n" + + " System.out.println(iterator.next());\n" + + " }\n" + + " }" + + " public String toString() {\n" + + " return \"NO_SUCCESS\";\n" + + " }\n" + + "}", + }, + "SUCCESS"); + + String expectedOutput = + " // Method descriptor #15 ([Ljava/lang/String;)V\n" + + " // Stack: 3, Locals: 4\n" + + " public static void main(java.lang.String[] args);\n" + + " 0 new java.util.ArrayList [16]\n" + + " 3 dup\n" + + " 4 invokespecial java.util.ArrayList() [18]\n" + + " 7 astore_1 [l]\n" + + " 8 new java.util.ArrayList [16]\n" + + " 11 dup\n" + + " 12 invokespecial java.util.ArrayList() [18]\n" + + " 15 astore_2 [l2]\n" + + " 16 aload_1 [l]\n" + + " 17 new X [1]\n" + + " 20 dup\n" + + " 21 invokespecial X() [19]\n" + + " 24 invokeinterface java.util.List.add(java.lang.Object) : boolean [20] [nargs: 2]\n" + + " 29 pop\n" + + " 30 aload_1 [l]\n" + + " 31 invokeinterface java.util.List.iterator() : java.util.Iterator [26] [nargs: 1]\n" + + " 36 astore_3 [iterator]\n" + + " 37 goto 63\n" + + " 40 aload_2 [l2]\n" + + " 41 aload_3 [iterator]\n" + + " 42 invokeinterface java.util.Iterator.next() : java.lang.Object [30] [nargs: 1]\n" + + " 47 checkcast X [1]\n" + + " 50 invokevirtual X.toString() : java.lang.String [36]\n" + + " 53 iconst_3\n" + + " 54 invokevirtual java.lang.String.substring(int) : java.lang.String [40]\n" + + " 57 invokeinterface java.util.List.add(java.lang.Object) : boolean [20] [nargs: 2]\n" + + " 62 pop\n" + + " 63 aload_3 [iterator]\n" + + " 64 invokeinterface java.util.Iterator.hasNext() : boolean [46] [nargs: 1]\n" + + " 69 ifne 40\n" + + " 72 aload_2 [l2]\n" + + " 73 invokeinterface java.util.List.iterator() : java.util.Iterator [26] [nargs: 1]\n" + + " 78 astore_3 [iterator]\n" + + " 79 goto 94\n" + + " 82 getstatic java.lang.System.out : java.io.PrintStream [50]\n" + + " 85 aload_3 [iterator]\n" + + " 86 invokeinterface java.util.Iterator.next() : java.lang.Object [30] [nargs: 1]\n" + + " 91 invokevirtual java.io.PrintStream.println(java.lang.Object) : void [56]\n" + + " 94 aload_3 [iterator]\n" + + " 95 invokeinterface java.util.Iterator.hasNext() : boolean [46] [nargs: 1]\n" + + " 100 ifne 82\n" + + " 103 return\n" + + " Line numbers:\n" + + " [pc: 0, line: 6]\n" + + " [pc: 8, line: 7]\n" + + " [pc: 16, line: 8]\n" + + " [pc: 30, line: 9]\n" + + " [pc: 40, line: 10]\n" + + " [pc: 53, line: 11]\n" + + " [pc: 57, line: 10]\n" + + " [pc: 63, line: 9]\n" + + " [pc: 72, line: 13]\n" + + " [pc: 82, line: 14]\n" + + " [pc: 94, line: 13]\n" + + " [pc: 103, line: 16]\n"; + + 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); + } +} } #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java,v retrieving revision 1.137 diff -u -r1.137 MessageSend.java --- compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java 1 Oct 2008 22:27:55 -0000 1.137 +++ compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java 17 Dec 2008 16:20:16 -0000 @@ -140,11 +140,10 @@ codeStream.checkcast(this.actualReceiverType); } codeStream.recordPositionsFrom(pc, this.sourceStart); - } // generate arguments generateArguments(this.binding, this.arguments, currentScope, codeStream); - + pc = codeStream.position; // actual message invocation if (this.syntheticAccessor == null){ TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenBinding, this.actualReceiverType, this.receiver.isImplicitThis());