### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/util/Disassembler.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/Disassembler.java,v retrieving revision 1.96 diff -u -r1.96 Disassembler.java --- model/org/eclipse/jdt/internal/core/util/Disassembler.java 27 Jun 2008 16:03:57 -0000 1.96 +++ model/org/eclipse/jdt/internal/core/util/Disassembler.java 10 Jul 2008 14:42:44 -0000 @@ -563,15 +563,19 @@ CharOperation.replace(methodDescriptor, '/', '.'); final boolean isVarArgs = isVarArgs(methodInfo); char[] methodHeader = null; + char[][] parameterNames = null; + if (!methodInfo.isClinit()) { + parameterNames = getParameterNames(methodDescriptor, codeAttribute, accessFlags); + } if (methodInfo.isConstructor()) { if (checkMode(mode, WORKING_COPY) && signatureAttribute != null) { final char[] signature = signatureAttribute.getSignature(); CharOperation.replace(signature, '/', '.'); disassembleGenericSignature(mode, buffer, signature); buffer.append(' '); - methodHeader = Signature.toCharArray(signature, returnClassName(className, '.', COMPACT), getParameterNames(methodDescriptor, codeAttribute, accessFlags) , !checkMode(mode, COMPACT), false, isVarArgs); + methodHeader = Signature.toCharArray(signature, returnClassName(className, '.', COMPACT), parameterNames, !checkMode(mode, COMPACT), false, isVarArgs); } else { - methodHeader = Signature.toCharArray(methodDescriptor, returnClassName(className, '.', COMPACT), getParameterNames(methodDescriptor, codeAttribute, accessFlags) , !checkMode(mode, COMPACT), false, isVarArgs); + methodHeader = Signature.toCharArray(methodDescriptor, returnClassName(className, '.', COMPACT), parameterNames, !checkMode(mode, COMPACT), false, isVarArgs); } } else if (methodInfo.isClinit()) { methodHeader = Messages.bind(Messages.classfileformat_clinitname).toCharArray(); @@ -581,9 +585,9 @@ CharOperation.replace(signature, '/', '.'); disassembleGenericSignature(mode, buffer, signature); buffer.append(' '); - methodHeader = Signature.toCharArray(signature, methodInfo.getName(), getParameterNames(methodDescriptor, codeAttribute, accessFlags) , !checkMode(mode, COMPACT), true, isVarArgs); + methodHeader = Signature.toCharArray(signature, methodInfo.getName(), parameterNames, !checkMode(mode, COMPACT), true, isVarArgs); } else { - methodHeader = Signature.toCharArray(methodDescriptor, methodInfo.getName(), getParameterNames(methodDescriptor, codeAttribute, accessFlags) , !checkMode(mode, COMPACT), true, isVarArgs); + methodHeader = Signature.toCharArray(methodDescriptor, methodInfo.getName(), parameterNames, !checkMode(mode, COMPACT), true, isVarArgs); } } if (checkMode(mode, DETAILED) && (runtimeInvisibleParameterAnnotationsAttribute != null || runtimeVisibleParameterAnnotationsAttribute != null)) { @@ -704,7 +708,7 @@ if (checkMode(mode, SYSTEM | DETAILED)) { if (codeAttribute != null) { - disassemble(codeAttribute, buffer, lineSeparator, tabNumber, mode); + disassemble(codeAttribute, parameterNames, methodDescriptor, (accessFlags & IModifierConstants.ACC_STATIC) != 0, buffer, lineSeparator, tabNumber, mode); } } if (checkMode(mode, SYSTEM)) { @@ -1037,9 +1041,9 @@ // check the presence of the unspecified Varargs attribute return Util.getAttribute(methodInfo, AttributeNamesConstants.VarargsName) != null; } - private void disassemble(ICodeAttribute codeAttribute, StringBuffer buffer, String lineSeparator, int tabNumber, int mode) { + private void disassemble(ICodeAttribute codeAttribute, char[][] parameterNames, char[] methodDescriptor, boolean isStatic, StringBuffer buffer, String lineSeparator, int tabNumber, int mode) { writeNewLine(buffer, lineSeparator, tabNumber - 1); - DefaultBytecodeVisitor visitor = new DefaultBytecodeVisitor(codeAttribute, buffer, lineSeparator, tabNumber, mode); + DefaultBytecodeVisitor visitor = new DefaultBytecodeVisitor(codeAttribute, parameterNames, methodDescriptor, isStatic, buffer, lineSeparator, tabNumber, mode); try { codeAttribute.traverse(visitor); } catch(ClassFormatException e) { Index: model/org/eclipse/jdt/internal/core/util/DefaultBytecodeVisitor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/util/DefaultBytecodeVisitor.java,v retrieving revision 1.43 diff -u -r1.43 DefaultBytecodeVisitor.java --- model/org/eclipse/jdt/internal/core/util/DefaultBytecodeVisitor.java 27 Jun 2008 16:03:56 -0000 1.43 +++ model/org/eclipse/jdt/internal/core/util/DefaultBytecodeVisitor.java 10 Jul 2008 14:42:44 -0000 @@ -41,17 +41,20 @@ private String lineSeparator; private int tabNumber; private int digitNumberForPC; - private ILocalVariableTableEntry[] localVariableTableEntries; - private int localVariableAttributeLength; + private ILocalVariableTableEntry[] localVariableTableEntries; + private int localVariableAttributeLength; private int mode; + private char[][] parameterNames; + private boolean isStatic; + private int[] argumentSizes; - public DefaultBytecodeVisitor(ICodeAttribute codeAttribute, StringBuffer buffer, String lineSeparator, int tabNumber, int mode) { + public DefaultBytecodeVisitor(ICodeAttribute codeAttribute, char[][] parameterNames, char[] methodDescriptor, boolean isStatic, StringBuffer buffer, String lineSeparator, int tabNumber, int mode) { ILocalVariableAttribute localVariableAttribute = codeAttribute.getLocalVariableAttribute(); this.localVariableAttributeLength = localVariableAttribute == null ? 0 : localVariableAttribute.getLocalVariableTableLength(); if (this.localVariableAttributeLength != 0) { this.localVariableTableEntries = localVariableAttribute.getLocalVariableTable(); } else { - this.localVariableTableEntries = null; + this.localVariableTableEntries = null; } this.buffer = buffer; this.lineSeparator = lineSeparator; @@ -59,6 +62,18 @@ long codeLength = codeAttribute.getCodeLength(); this.digitNumberForPC = Long.toString(codeLength).length(); this.mode = mode; + this.parameterNames = parameterNames; + this.isStatic = isStatic; + // compute argument sizes + if (parameterNames != null) { + char[][] parameterTypes = Signature.getParameterTypes(methodDescriptor); + int length = parameterTypes.length; + this.argumentSizes = new int[length]; + for (int i = 0; i < length; i++) { + char[] parameterType = parameterTypes[i]; + this.argumentSizes[i] = parameterType.length == 1 && (parameterType[0] == 'D' || parameterType[0] == 'J') ? 2 : 1; + } + } } /** * @see IBytecodeVisitor#_aaload(int) @@ -220,35 +235,68 @@ } private String getLocalVariableName(int pc, int index, boolean showIndex) { - int nextPC = pc + 1; - switch(index) { - case 0 : - case 1 : - case 2 : - case 3 : - break; - default : - nextPC = index <= 255 ? pc + 2 : pc + 3; - } - - for (int i = 0, max = this.localVariableAttributeLength; i < max; i++) { - final ILocalVariableTableEntry entry = this.localVariableTableEntries[i]; - final int startPC = entry.getStartPC(); - if (entry.getIndex() == index && (startPC <= nextPC) && ((startPC + entry.getLength()) > nextPC)) { - final StringBuffer stringBuffer = new StringBuffer(); - if (showIndex) { - stringBuffer.append(' ').append(index); - } - stringBuffer.append(' ').append('[').append(entry.getName()).append(']'); - return String.valueOf(stringBuffer); - } - } - if (showIndex) { - final StringBuffer stringBuffer = new StringBuffer(); - stringBuffer.append(' ').append(index); - return String.valueOf(stringBuffer); - } - return EMPTY_LOCAL_NAME; + int nextPC = pc + 1; + switch(index) { + case 0 : + case 1 : + case 2 : + case 3 : + break; + default : + nextPC = index <= 255 ? pc + 2 : pc + 3; + } + + for (int i = 0, max = this.localVariableAttributeLength; i < max; i++) { + final ILocalVariableTableEntry entry = this.localVariableTableEntries[i]; + final int startPC = entry.getStartPC(); + if (entry.getIndex() == index && (startPC <= nextPC) && ((startPC + entry.getLength()) > nextPC)) { + final StringBuffer stringBuffer = new StringBuffer(); + if (showIndex) { + stringBuffer.append(' ').append(index); + } + stringBuffer.append(' ').append('[').append(entry.getName()).append(']'); + return String.valueOf(stringBuffer); + } + } + if (this.parameterNames != null) { + if (index == 0) { + if (!this.isStatic) { + final StringBuffer stringBuffer = new StringBuffer(); + stringBuffer.append(' ').append('[').append("this").append(']'); //$NON-NLS-1$ + return String.valueOf(stringBuffer); + } + } + int indexInParameterNames = index; + if (index != 0) { + int resolvedPosition = 0; + if (!this.isStatic) { + resolvedPosition = 1; + } + int i = 0; + loop: for (int max = this.argumentSizes.length; i < max; i++) { + if (index == resolvedPosition) { + break loop; + } + resolvedPosition += this.argumentSizes[i]; + } + indexInParameterNames = i; + } + if (indexInParameterNames < this.parameterNames.length + && this.parameterNames[indexInParameterNames] != null) { + final StringBuffer stringBuffer = new StringBuffer(); + if (showIndex) { + stringBuffer.append(' ').append(index); + } + stringBuffer.append(' ').append('[').append(this.parameterNames[indexInParameterNames]).append(']'); + return String.valueOf(stringBuffer); + } + } + if (showIndex) { + final StringBuffer stringBuffer = new StringBuffer(); + stringBuffer.append(' ').append(index); + return String.valueOf(stringBuffer); + } + return EMPTY_LOCAL_NAME; } /** #P org.eclipse.jdt.core.tests.compiler Index: src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java,v retrieving revision 1.154 diff -u -r1.154 MethodVerifyTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 27 Jun 2008 16:04:43 -0000 1.154 +++ src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java 10 Jul 2008 14:42:48 -0000 @@ -5656,7 +5656,7 @@ " // Method descriptor #17 ()Ljava/lang/Object;\n" + " // Stack: 1, Locals: 1\n" + " public bridge synthetic java.lang.Object bar() throws java.lang.Exception;\n" + - " 0 aload_0\n" + + " 0 aload_0 [this]\n" + " 1 invokevirtual X.bar() : java.lang.String [21]\n" + " 4 areturn\n" + " Line numbers:\n" + @@ -5665,7 +5665,7 @@ " // Method descriptor #17 ()Ljava/lang/Object;\n" + " // Stack: 1, Locals: 1\n" + " protected bridge synthetic java.lang.Object foo() throws java.lang.Exception;\n" + - " 0 aload_0\n" + + " 0 aload_0 [this]\n" + " 1 invokevirtual X.foo() : java.lang.String [23]\n" + " 4 areturn\n" + " Line numbers:\n" + Index: src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java,v retrieving revision 1.38 diff -u -r1.38 InnerEmulationTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java 27 Jun 2008 16:04:44 -0000 1.38 +++ src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java 10 Jul 2008 14:42:48 -0000 @@ -4862,10 +4862,10 @@ " 0 aload_0 [this]\n" + " 1 invokespecial java.lang.Object() [13]\n" + " 4 aload_0 [this]\n" + - " 5 aload_1\n" + + " 5 aload_1 [arg0]\n" + " 6 putfield X$1$Local.this$0 : X [16]\n" + " 9 aload_0 [this]\n" + - " 10 aload_2\n" + + " 10 aload_2 [arg1]\n" + " 11 putfield X$1$Local.val$s : java.lang.String [18]\n" + " 14 return\n" + " Line numbers:\n" + @@ -4890,9 +4890,9 @@ " // Method descriptor #37 (LX;Ljava/lang/String;LX$1$Local;)V\n" + " // Stack: 3, Locals: 4\n" + " synthetic X$1$Local(X arg0, java.lang.String arg1, new X(){}.Local arg2);\n" + - " 0 aload_0\n" + - " 1 aload_1\n" + - " 2 aload_2\n" + + " 0 aload_0 [this]\n" + + " 1 aload_1 [arg0]\n" + + " 2 aload_2 [arg1]\n" + " 3 invokespecial X$1$Local(X, java.lang.String) [38]\n" + " 6 return\n" + " Line numbers:\n" + @@ -4915,10 +4915,10 @@ " // Stack: 2, Locals: 3\n" + " X$1$Local(X arg0, java.lang.String arg1);\n" + " 0 aload_0 [this]\n" + - " 1 aload_1\n" + + " 1 aload_1 [arg0]\n" + " 2 putfield X$1$Local.this$0 : X [13]\n" + " 5 aload_0 [this]\n" + - " 6 aload_2\n" + + " 6 aload_2 [arg1]\n" + " 7 putfield X$1$Local.val$s : java.lang.String [15]\n" + " 10 aload_0 [this]\n" + " 11 invokespecial java.lang.Object() [17]\n" + @@ -4958,10 +4958,10 @@ " // Stack: 2, Locals: 3\n" + " X$1Local(X arg0, java.lang.String arg1);\n" + " 0 aload_0 [this]\n" + - " 1 aload_1\n" + + " 1 aload_1 [arg0]\n" + " 2 putfield X$1Local.this$0 : X [12]\n" + " 5 aload_0 [this]\n" + - " 6 aload_2\n" + + " 6 aload_2 [arg1]\n" + " 7 putfield X$1Local.val$s : java.lang.String [14]\n" + " 10 aload_0 [this]\n" + " 11 invokespecial java.lang.Object() [16]\n" + Index: src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java,v retrieving revision 1.166 diff -u -r1.166 BatchCompilerTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 27 Jun 2008 16:04:44 -0000 1.166 +++ src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 10 Jul 2008 14:42:45 -0000 @@ -43,7 +43,7 @@ static { // TESTS_NAMES = new String[] { "test000" }; -// TESTS_NUMBERS = new int[] { 152 }; + TESTS_NUMBERS = new int[] { 288 }; // TESTS_RANGE = new int[] { 107, -1 }; } public BatchCompilerTest(String name) { @@ -10941,7 +10941,6 @@ "1 problem (1 error)", true /*shouldFlushOutput*/); } - // command-line expansion // shows that we don't recurse public void test287_option_files() { @@ -10961,4 +10960,46 @@ "Unrecognized option : @options2.txt\n" /* stderr */, true /*shouldFlushOutput*/); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=229092 +public void test288(){ + String setting= System.getProperty("jdt.compiler.useSingleThread"); + try { +// System.setProperty("jdt.compiler.useSingleThread", "false"); + this.runNegativeTest( + new String[] { + "C1.java", + "public class C1 {\r\n" + + " void bar(C2 other) {\r\n" + + " other.missing();\r\n" + + " }\r\n" + + "}", + "C2.java", + "public class C2 {\r\n" + + " void foo() {\r\n" + + " this.wrong();\r\n" + + " }\r\n" + + "}", + }, + "\"" + OUTPUT_DIR + File.separator + "C1.java\"" + + " -classpath \"" + OUTPUT_DIR + "\"" + + " -g -d \"" + OUTPUT_DIR + "\"", + "", + "----------\n" + + "1. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/C1.java (at line 3)\n" + + " other.missing();\n" + + " ^^^^^^^\n" + + "The method missing() is undefined for the type C2\n" + + "----------\n" + + "----------\n" + + "2. ERROR in ---OUTPUT_DIR_PLACEHOLDER---/C2.java (at line 3)\n" + + " this.wrong();\n" + + " ^^^^^\n" + + "The method wrong() is undefined for the type C2\n" + + "----------\n" + + "2 problems (2 errors)", + true); + } finally { + System.setProperty("jdt.compiler.useSingleThread", setting == null ? "false" : setting); + } +} } Index: src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java,v retrieving revision 1.743 diff -u -r1.743 GenericTypeTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 7 Jul 2008 13:08:29 -0000 1.743 +++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 10 Jul 2008 14:42:47 -0000 @@ -24073,7 +24073,7 @@ " // Method descriptor #18 ()Ljava/lang/Object;\n" + " // Stack: 1, Locals: 1\n" + " public bridge synthetic java.lang.Object getIt();\n" + - " 0 aload_0\n" + + " 0 aload_0 [this]\n" + " 1 invokevirtual FooImpl.getIt() : java.lang.String [19]\n" + " 4 areturn\n" + " Line numbers:\n" + @@ -24129,7 +24129,7 @@ " // Method descriptor #18 ()Ljava/lang/Exception;\n" + " // Stack: 1, Locals: 1\n" + " public bridge synthetic java.lang.Exception getIt() throws java.lang.Exception;\n" + - " 0 aload_0\n" + + " 0 aload_0 [this]\n" + " 1 invokevirtual FooImpl.getIt() : java.lang.NullPointerException [22]\n" + " 4 areturn\n" + " Line numbers:\n" + @@ -24413,8 +24413,8 @@ " // Method descriptor #31 (I)Ljava/lang/Object;\n" + " // Stack: 2, Locals: 2\n" + " public bridge synthetic java.lang.Object get(int arg0);\n" + - " 0 aload_0\n" + - " 1 iload_1\n" + + " 0 aload_0 [this]\n" + + " 1 iload_1 [arg0]\n" + " 2 invokevirtual X$Entry$1.get(int) : java.lang.String [36]\n" + " 5 areturn\n" + " Line numbers:\n" + Index: src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java,v retrieving revision 1.127 diff -u -r1.127 EnumTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java 2 Jul 2008 13:11:35 -0000 1.127 +++ src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java 10 Jul 2008 14:42:46 -0000 @@ -2023,8 +2023,8 @@ " // Stack: 3, Locals: 3\n" + " private X(java.lang.String arg0, int arg1);\n" + " 0 aload_0 [this]\n" + - " 1 aload_1\n" + - " 2 iload_2\n" + + " 1 aload_1 [arg0]\n" + + " 2 iload_2 [arg1]\n" + " 3 invokespecial java.lang.Enum(java.lang.String, int) [25]\n" + " 6 return\n"; @@ -2888,8 +2888,8 @@ " // Stack: 3, Locals: 3\n" + " private X(java.lang.String arg0, int arg1);\n" + " 0 aload_0 [this]\n" + - " 1 aload_1\n" + - " 2 iload_2\n" + + " 1 aload_1 [arg0]\n" + + " 2 iload_2 [arg1]\n" + " 3 invokespecial java.lang.Enum(java.lang.String, int) [16]\n" + " 6 return\n" + " Line numbers:\n" + @@ -2923,7 +2923,7 @@ " // Stack: 2, Locals: 1\n" + " public static X valueOf(java.lang.String arg0);\n" + " 0 ldc [1]\n" + - " 2 aload_0\n" + + " 2 aload_0 [arg0]\n" + " 3 invokestatic java.lang.Enum.valueOf(java.lang.Class, java.lang.String) : java.lang.Enum [30]\n" + " 6 checkcast X [1]\n" + " 9 areturn\n" + @@ -4394,8 +4394,8 @@ " // Stack: 3, Locals: 3\n" + " private X(java.lang.String arg0, int arg1);\n" + " 0 aload_0 [this]\n" + - " 1 aload_1\n" + - " 2 iload_2\n" + + " 1 aload_1 [arg0]\n" + + " 2 iload_2 [arg1]\n" + " 3 invokespecial java.lang.Enum(java.lang.String, int) [31]\n" + " 6 return\n" + " Line numbers:\n" + @@ -4429,7 +4429,7 @@ " // Stack: 2, Locals: 1\n" + " public static X valueOf(java.lang.String arg0);\n" + " 0 ldc [1]\n" + - " 2 aload_0\n" + + " 2 aload_0 [arg0]\n" + " 3 invokestatic java.lang.Enum.valueOf(java.lang.Class, java.lang.String) : java.lang.Enum [43]\n" + " 6 checkcast X [1]\n" + " 9 areturn\n" +