### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java,v retrieving revision 1.95 diff -u -r1.95 ParameterizedTypeBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java 25 May 2007 13:49:54 -0000 1.95 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedTypeBinding.java 13 Sep 2007 10:56:24 -0000 @@ -362,29 +362,40 @@ * LY; */ public char[] genericTypeSignature() { - if (this.genericTypeSignature == null) { - StringBuffer sig = new StringBuffer(10); - if (this.isMemberType() && this.enclosingType().isParameterizedType()) { - char[] typeSig = this.enclosingType().genericTypeSignature(); - for (int i = 0; i < typeSig.length-1; i++) sig.append(typeSig[i]); // copy all but trailing semicolon - sig.append('.').append(this.sourceName()); + if (this.genericTypeSignature == null) { + if ((this.modifiers & ExtraCompilerModifiers.AccGenericSignature) == 0) { + this.genericTypeSignature = this.type.signature(); } else { - char[] typeSig = this.type.signature(); - for (int i = 0; i < typeSig.length-1; i++) sig.append(typeSig[i]); // copy all but trailing semicolon - } - if (this.arguments != null) { - sig.append('<'); - for (int i = 0, length = this.arguments.length; i < length; i++) { - sig.append(this.arguments[i].genericTypeSignature()); - } - sig.append('>'); - } - sig.append(';'); - int sigLength = sig.length(); - this.genericTypeSignature = new char[sigLength]; - sig.getChars(0, sigLength, this.genericTypeSignature, 0); - } - return this.genericTypeSignature; + StringBuffer sig = new StringBuffer(10); + if (this.isMemberType()) { + ReferenceBinding enclosing = enclosingType(); + boolean hasParameterizedEnclosing = enclosing.isParameterizedType(); + char[] typeSig = hasParameterizedEnclosing ? enclosing.genericTypeSignature() : enclosing.signature(); + sig.append(typeSig, 0, typeSig.length-1);// copy all but trailing semicolon + if (hasParameterizedEnclosing && (enclosing.modifiers & ExtraCompilerModifiers.AccGenericSignature) != 0) { + sig.append('.'); + } else { + sig.append('$'); + } + sig.append(this.sourceName()); + } else { + char[] typeSig = this.type.signature(); + sig.append(typeSig, 0, typeSig.length-1);// copy all but trailing semicolon + } + if (this.arguments != null) { + sig.append('<'); + for (int i = 0, length = this.arguments.length; i < length; i++) { + sig.append(this.arguments[i].genericTypeSignature()); + } + sig.append('>'); + } + sig.append(';'); + int sigLength = sig.length(); + this.genericTypeSignature = new char[sigLength]; + sig.getChars(0, sigLength, this.genericTypeSignature, 0); + } + } + return this.genericTypeSignature; } /** Index: compiler/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java,v retrieving revision 1.31 diff -u -r1.31 RawTypeBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java 27 Apr 2007 15:51:38 -0000 1.31 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java 13 Sep 2007 10:56:24 -0000 @@ -75,21 +75,33 @@ * LY; */ public char[] genericTypeSignature() { - - if (this.genericTypeSignature == null) { - StringBuffer sig = new StringBuffer(10); - if (this.isMemberType() && this.enclosingType().isParameterizedType()) { - char[] typeSig = this.enclosingType().genericTypeSignature(); - for (int i = 0; i < typeSig.length-1; i++) sig.append(typeSig[i]); // copy all but trailing semicolon - sig.append('.').append(this.sourceName()).append(';'); + if (this.genericTypeSignature == null) { + if ((this.modifiers & ExtraCompilerModifiers.AccGenericSignature) == 0) { + this.genericTypeSignature = genericType().signature(); + } else { + StringBuffer sig = new StringBuffer(10); + if (this.isMemberType()) { + ReferenceBinding enclosing = enclosingType(); + boolean hasParameterizedEnclosing = enclosing.isParameterizedType(); + char[] typeSig = hasParameterizedEnclosing ? enclosing.genericTypeSignature() : enclosing.signature(); + sig.append(typeSig, 0, typeSig.length-1);// copy all but trailing semicolon + if (hasParameterizedEnclosing && (enclosing.modifiers & ExtraCompilerModifiers.AccGenericSignature) != 0) { + sig.append('.'); + } else { + sig.append('$'); + } + sig.append(this.sourceName()); + } else { + char[] typeSig = genericType().signature(); + sig.append(typeSig, 0, typeSig.length-1);// copy all but trailing semicolon + } + sig.append(';'); int sigLength = sig.length(); this.genericTypeSignature = new char[sigLength]; - sig.getChars(0, sigLength, this.genericTypeSignature, 0); - } else { - this.genericTypeSignature = genericType().signature(); // erasure + sig.getChars(0, sigLength, this.genericTypeSignature, 0); } - } - return this.genericTypeSignature; + } + return this.genericTypeSignature; } public boolean isEquivalentTo(TypeBinding otherType) { Index: compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java,v retrieving revision 1.106 diff -u -r1.106 BlockScope.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java 6 Mar 2007 02:38:50 -0000 1.106 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java 13 Sep 2007 10:56:24 -0000 @@ -125,6 +125,7 @@ return methodScope.isInsideInitializer() // inside initializer || ((AbstractMethodDeclaration) methodScope.referenceContext).isInitializationMethod(); // inside constructor or clinit } + String basicToString(int tab) { String newLine = "\n"; //$NON-NLS-1$ for (int i = tab; --i >= 0;) @@ -822,6 +823,30 @@ return max; } +/** + * Returns true if the context requires to check initialization of final blank fields. + * in other words, it is inside an initializer, a constructor or a clinit + */ +public final boolean needBlankFinalFieldInitializationCheck(FieldBinding binding) { + boolean isStatic = binding.isStatic(); + ReferenceBinding fieldDeclaringClass = binding.declaringClass; + // loop in enclosing context, until reaching the field declaring context + MethodScope methodScope = methodScope(); + while (methodScope != null) { + if (methodScope.isStatic != isStatic) + return false; + if (!methodScope.isInsideInitializer() // inside initializer + && !((AbstractMethodDeclaration) methodScope.referenceContext).isInitializationMethod()) { // inside constructor or clinit + return false; // found some non-initializer context + } + if (fieldDeclaringClass == methodScope.enclosingReceiverType()) { + return true; // found the field context, no need to check any further + } + methodScope = methodScope.enclosingMethodScope(); + } + return false; +} + /* Answer the problem reporter to use for raising new problems. * * Note that as a side-effect, this updates the current reference context Index: buildnotes_jdt-core.html =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/buildnotes_jdt-core.html,v retrieving revision 1.5933.2.37 diff -u -r1.5933.2.37 buildnotes_jdt-core.html --- buildnotes_jdt-core.html 31 Aug 2007 09:23:50 -0000 1.5933.2.37 +++ buildnotes_jdt-core.html 13 Sep 2007 10:56:23 -0000 @@ -44,6 +44,21 @@ + + +

+Eclipse Platform Build Notes
+Java Development Tooling Core

+Eclipse SDK 3.3.2 - %date% - 3.3.2 RELEASE +
Project org.eclipse.jdt.core v_780_R33x +(cvs). +

What's new in this drop

+ +

Problem Reports Fixed

+203061 +203061 [compiler] Uninitialized member variables used in nonstatic initializers of peer members don't trigger compilation error + +

Eclipse Platform Build Notes
Index: batch/org/eclipse/jdt/internal/compiler/batch/messages.properties =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/batch/org/eclipse/jdt/internal/compiler/batch/messages.properties,v retrieving revision 1.645.2.10 diff -u -r1.645.2.10 messages.properties --- batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 30 Aug 2007 14:14:34 -0000 1.645.2.10 +++ batch/org/eclipse/jdt/internal/compiler/batch/messages.properties 13 Sep 2007 10:56:23 -0000 @@ -14,7 +14,7 @@ #Format: compiler.name = word1 word2 word3 compiler.name = Eclipse Java Compiler #Format: compiler.version = 0.XXX[, other words (don't forget the comma if adding other words)] -compiler.version = 0.779_R33x, 3.3.1 +compiler.version = 0.780_R33x, pre-3.3.2 compiler.copyright = Copyright IBM Corp 2000, 2007. All rights reserved. ### progress Index: compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java,v retrieving revision 1.97 diff -u -r1.97 SingleNameReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 2 May 2007 00:32:25 -0000 1.97 +++ compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java 13 Sep 2007 10:56:23 -0000 @@ -41,7 +41,7 @@ case Binding.FIELD : // reading a field FieldBinding fieldBinding; if ((fieldBinding = (FieldBinding) binding).isBlankFinal() - && currentScope.allowBlankFinalFieldAssignment(fieldBinding)) { + && currentScope.needBlankFinalFieldInitializationCheck(fieldBinding)) { if (!flowInfo.isDefinitelyAssigned(fieldBinding)) { currentScope.problemReporter().uninitializedBlankFinalField(fieldBinding, this); } @@ -152,7 +152,7 @@ } } // check if reading a final blank field - if (fieldBinding.isBlankFinal() && currentScope.allowBlankFinalFieldAssignment(fieldBinding)) { + if (fieldBinding.isBlankFinal() && currentScope.needBlankFinalFieldInitializationCheck(fieldBinding)) { if (!flowInfo.isDefinitelyAssigned(fieldBinding)) { currentScope.problemReporter().uninitializedBlankFinalField(fieldBinding, this); } Index: compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java,v retrieving revision 1.109 diff -u -r1.109 FieldReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java 15 Mar 2007 14:04:15 -0000 1.109 +++ compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java 13 Sep 2007 10:56:23 -0000 @@ -46,7 +46,7 @@ if (isCompound) { // check the variable part is initialized if blank final if (binding.isBlankFinal() && receiver.isThis() - && currentScope.allowBlankFinalFieldAssignment(binding) + && currentScope.needBlankFinalFieldInitializationCheck(binding) && (!flowInfo.isDefinitelyAssigned(binding))) { currentScope.problemReporter().uninitializedBlankFinalField(binding, this); // we could improve error msg here telling "cannot use compound assignment on final blank field" Index: compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java,v retrieving revision 1.116 diff -u -r1.116 QualifiedNameReference.java --- compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java 30 Mar 2007 17:32:05 -0000 1.116 +++ compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java 13 Sep 2007 10:56:23 -0000 @@ -85,7 +85,7 @@ // check if final blank field if (lastFieldBinding.isBlankFinal() && this.otherBindings != null // the last field binding is only assigned - && currentScope.allowBlankFinalFieldAssignment(lastFieldBinding)) { + && currentScope.needBlankFinalFieldInitializationCheck(lastFieldBinding)) { if (!flowInfo.isDefinitelyAssigned(lastFieldBinding)) { currentScope.problemReporter().uninitializedBlankFinalField( lastFieldBinding, @@ -134,7 +134,7 @@ if (isCompound) { if (otherBindingsCount == 0 && lastFieldBinding.isBlankFinal() - && currentScope.allowBlankFinalFieldAssignment(lastFieldBinding) + && currentScope.needBlankFinalFieldInitializationCheck(lastFieldBinding) && (!flowInfo.isDefinitelyAssigned(lastFieldBinding))) { currentScope.problemReporter().uninitializedBlankFinalField(lastFieldBinding, this); } @@ -237,7 +237,7 @@ } // check if reading a final blank field if (fieldBinding.isBlankFinal() - && currentScope.allowBlankFinalFieldAssignment(fieldBinding) + && currentScope.needBlankFinalFieldInitializationCheck(fieldBinding) && !flowInfo.isDefinitelyAssigned(fieldBinding)) { currentScope.problemReporter().uninitializedBlankFinalField(fieldBinding, this); } Index: eval/org/eclipse/jdt/internal/eval/CodeSnippetSingleNameReference.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/eval/org/eclipse/jdt/internal/eval/CodeSnippetSingleNameReference.java,v retrieving revision 1.47 diff -u -r1.47 CodeSnippetSingleNameReference.java --- eval/org/eclipse/jdt/internal/eval/CodeSnippetSingleNameReference.java 29 Mar 2006 02:57:52 -0000 1.47 +++ eval/org/eclipse/jdt/internal/eval/CodeSnippetSingleNameReference.java 13 Sep 2007 10:56:24 -0000 @@ -56,7 +56,7 @@ // check if reading a final blank field FieldBinding fieldBinding; if ((fieldBinding = (FieldBinding) this.binding).isBlankFinal() - && currentScope.allowBlankFinalFieldAssignment(fieldBinding)) { + && currentScope.needBlankFinalFieldInitializationCheck(fieldBinding)) { if (!flowInfo.isDefinitelyAssigned(fieldBinding)) { currentScope.problemReporter().uninitializedBlankFinalField(fieldBinding, this); } #P org.eclipse.jdt.core.tests Index: Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InitializationTest.java =================================================================== RCS file: /home/cvs/numbat/org.eclipse.jdt.core.tests/Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InitializationTest.java,v retrieving revision 1.106 diff -u -r1.106 InitializationTest.java --- Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InitializationTest.java 15 Mar 2007 14:04:34 -0000 1.106 +++ Eclipse Java Tests Compiler/org/eclipse/jdt/tests/compiler/regression/InitializationTest.java 13 Sep 2007 10:56:27 -0000 @@ -5473,6 +5473,155 @@ assertTrue(false); } } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=203061 +public void test192() { + this.runNegativeTest( + new String[] { + "X.java", + "public final class X {\n" + + " private final Object mObj;\n" + + " private final Object mDependent = new Object() {\n" + + " {\n" + + " Object o1 = mObj;\n" + + " }\n" + + " Object o2 = mObj;\n" + + " void foo() {\n" + + " Object o3 = mObj;\n" + + " }\n" + + " };\n" + + " public X() {\n" + + " mObj = \"\";\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " private final Object mDependent = new Object() {\n" + + " ^^^^^^^^^^\n" + + "The field X.mDependent is never read locally\n" + + "----------\n" + + "2. WARNING in X.java (at line 5)\n" + + " Object o1 = mObj;\n" + + " ^^^^\n" + + "Read access to enclosing field X.mObj is emulated by a synthetic accessor method. Increasing its visibility will improve your performance\n" + + "----------\n" + + "3. ERROR in X.java (at line 5)\n" + + " Object o1 = mObj;\n" + + " ^^^^\n" + + "The blank final field mObj may not have been initialized\n" + + "----------\n" + + "4. WARNING in X.java (at line 7)\n" + + " Object o2 = mObj;\n" + + " ^^\n" + + "The field new Object(){}.o2 is never read locally\n" + + "----------\n" + + "5. WARNING in X.java (at line 7)\n" + + " Object o2 = mObj;\n" + + " ^^^^\n" + + "Read access to enclosing field X.mObj is emulated by a synthetic accessor method. Increasing its visibility will improve your performance\n" + + "----------\n" + + "6. ERROR in X.java (at line 7)\n" + + " Object o2 = mObj;\n" + + " ^^^^\n" + + "The blank final field mObj may not have been initialized\n" + + "----------\n" + + "7. WARNING in X.java (at line 8)\n" + + " void foo() {\n" + + " ^^^^^\n" + + "The method foo() from the type new Object(){} is never used locally\n" + + "----------\n" + + "8. WARNING in X.java (at line 9)\n" + + " Object o3 = mObj;\n" + + " ^^^^\n" + + "Read access to enclosing field X.mObj is emulated by a synthetic accessor method. Increasing its visibility will improve your performance\n" + + "----------\n"); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=203061 - variation +public void test193() { + this.runNegativeTest( + new String[] { + "X.java", + "public final class X {\n" + + " private final Object mObj;\n" + + " private final Object mDependent = new Object() {\n" + + " {\n" + + " Object o1 = mObj;\n" + + " mObj = \"1\";\n" + + " }\n" + + " Object o2 = mObj = \"2\";\n" + + " void foo() {\n" + + " Object o3 = mObj;\n" + + " mObj = \"3\";\n" + + " }\n" + + " };\n" + + " public X() {\n" + + " mObj = \"\";\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " private final Object mDependent = new Object() {\n" + + " ^^^^^^^^^^\n" + + "The field X.mDependent is never read locally\n" + + "----------\n" + + "2. WARNING in X.java (at line 5)\n" + + " Object o1 = mObj;\n" + + " ^^^^\n" + + "Read access to enclosing field X.mObj is emulated by a synthetic accessor method. Increasing its visibility will improve your performance\n" + + "----------\n" + + "3. ERROR in X.java (at line 5)\n" + + " Object o1 = mObj;\n" + + " ^^^^\n" + + "The blank final field mObj may not have been initialized\n" + + "----------\n" + + "4. WARNING in X.java (at line 6)\n" + + " mObj = \"1\";\n" + + " ^^^^\n" + + "Write access to enclosing field X.mObj is emulated by a synthetic accessor method. Increasing its visibility will improve your performance\n" + + "----------\n" + + "5. ERROR in X.java (at line 6)\n" + + " mObj = \"1\";\n" + + " ^^^^\n" + + "The final field X.mObj cannot be assigned\n" + + "----------\n" + + "6. WARNING in X.java (at line 8)\n" + + " Object o2 = mObj = \"2\";\n" + + " ^^\n" + + "The field new Object(){}.o2 is never read locally\n" + + "----------\n" + + "7. WARNING in X.java (at line 8)\n" + + " Object o2 = mObj = \"2\";\n" + + " ^^^^\n" + + "Write access to enclosing field X.mObj is emulated by a synthetic accessor method. Increasing its visibility will improve your performance\n" + + "----------\n" + + "8. ERROR in X.java (at line 8)\n" + + " Object o2 = mObj = \"2\";\n" + + " ^^^^\n" + + "The final field X.mObj cannot be assigned\n" + + "----------\n" + + "9. WARNING in X.java (at line 9)\n" + + " void foo() {\n" + + " ^^^^^\n" + + "The method foo() from the type new Object(){} is never used locally\n" + + "----------\n" + + "10. WARNING in X.java (at line 10)\n" + + " Object o3 = mObj;\n" + + " ^^^^\n" + + "Read access to enclosing field X.mObj is emulated by a synthetic accessor method. Increasing its visibility will improve your performance\n" + + "----------\n" + + "11. WARNING in X.java (at line 11)\n" + + " mObj = \"3\";\n" + + " ^^^^\n" + + "Write access to enclosing field X.mObj is emulated by a synthetic accessor method. Increasing its visibility will improve your performance\n" + + "----------\n" + + "12. ERROR in X.java (at line 11)\n" + + " mObj = \"3\";\n" + + " ^^^^\n" + + "The final field X.mObj cannot be assigned\n" + + "----------\n"); +} + public static Class testClass() { return InitializationTest.class; } #P org.eclipse.jdt.core.tests.compiler 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.631.2.3 diff -u -r1.631.2.3 GenericTypeTest.java --- src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 24 Aug 2007 14:28:09 -0000 1.631.2.3 +++ src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java 13 Sep 2007 10:56:32 -0000 @@ -38065,4 +38065,472 @@ false, // do not flush output null); } +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=189158 +public void test1150() { + this.runConformTest( + new String[] { + "X.java", + "import java.lang.ref.Reference;\n"+ + "public class X {\n" + + " static class Rather {\n" + + " static class Deeply {\n" + + " static class Inside {\n" + + " }\n" + + " }\n" + + " }\n" + + " Reference x;\n" + + " Reference y; \n" + + " Reference z; \n" + + "\n" + + " public static void main(String[] args) throws Exception {\n" + + " System.out.print(X.class.getDeclaredField(\"x\").getGenericType());\n" + + " System.out.print(\"##\");\n" + + " System.out.print(X.class.getDeclaredField(\"y\").getGenericType());\n" + + " System.out.print(\"##\");\n" + + " System.out.print(X.class.getDeclaredField(\"z\").getGenericType());\n" + + " System.out.println();\n" + + " }\n" + + "}\n" + }, + "java.lang.ref.Reference##java.lang.ref.Reference##java.lang.ref.Reference" + ); + String expectedOutput = + " // Field descriptor #6 Ljava/lang/ref/Reference;\n" + + " // Signature: Ljava/lang/ref/Reference;\n" + + " java.lang.ref.Reference x;\n" + + " \n" + + " // Field descriptor #6 Ljava/lang/ref/Reference;\n" + + " // Signature: Ljava/lang/ref/Reference;\n" + + " java.lang.ref.Reference y;\n" + + " \n" + + " // Field descriptor #6 Ljava/lang/ref/Reference;\n" + + " // Signature: Ljava/lang/ref/Reference;\n" + + " java.lang.ref.Reference z;\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=189158 - variation +public void test1151() { + this.runConformTest( + new String[] { + "X.java", + "import java.lang.ref.Reference;\n"+ + "public class X {\n" + + " class Other {\n" + + " class Deeply {\n" + + " class Inside {\n" + + " } \n" + + " }\n" + + " }\n" + + " Reference.Other.Deeply> t;\n" + + " Reference.Other.Deeply.Inside> u;\n" + + "\n" + + " public static void main(String[] args) throws Exception {\n" + + " System.out.print(X.class.getDeclaredField(\"t\").getGenericType());\n" + + " //System.out.print(\"##\");\n" + + " //System.out.print(X.class.getDeclaredField(\"u\").getGenericType());\n" + // TODO disabled due to bug in libs (unable to re-read the generated signature) + " System.out.println();\n" + + " }\n" + + "}\n" + }, + //"java.lang.ref.Reference.Other.Deeply>##java.lang.ref.Reference.Other.Deeply$Inside>" + "java.lang.ref.Reference.Other.Deeply>" + ); + String expectedOutput = + " // Field descriptor #6 Ljava/lang/ref/Reference;\n" + + " // Signature: Ljava/lang/ref/Reference.Other.Deeply;>;\n" + + " java.lang.ref.Reference t;\n" + + " \n" + + " // Field descriptor #6 Ljava/lang/ref/Reference;\n" + + " // Signature: Ljava/lang/ref/Reference.Other.Deeply.Inside;>;\n" + + " java.lang.ref.Reference u;\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=189158 - variation +public void test1152() { + this.runNegativeTest( + new String[] { + "X.java", + "import java.lang.ref.Reference;\n"+ + "public class X {\n" + + " class Other {\n" + + " class Deeply {\n" + + " class Inside {\n" + + " } \n" + + " }\n" + + " }\n" + + " Reference.Other.Deeply.Inside> u;\n" + + "\n" + + " public static void main(String[] args) throws Exception {\n" + + " System.out.print(X.class.getDeclaredField(\"u\").getGenericType());\n" + + " System.out.println();\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. ERROR in X.java (at line 9)\n" + + " Reference.Other.Deeply.Inside> u;\n" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" + + "The member type X.Other.Deeply.Inside must be parameterized, since it is qualified with a parameterized type\n" + + "----------\n" ); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=189158 - variation +public void test1153() { + // check proper decoding of binary signatures, by compiling against generated binary + this.runConformTest( + new String[] { + "p/X.java", + "package p;\n" + + "import java.lang.ref.Reference;\n" + + "public class X {\n" + + " public static class Rather {\n" + + " public static class Deeply {\n" + + " public static class Inside {\n" + + " }\n" + + " }\n" + + " }\n" + + " public class Other {\n" + + " public class Deeply {\n" + + " public class Inside {\n" + + " } \n" + + " }\n" + + " }\n" + + " public Reference x;\n" + + " public Reference y; \n" + + " public Reference z; \n" + + " public Reference.Other.Deeply> t;\n" + + " public Reference.Other.Deeply.Inside> u;\n" + + "}\n", + }, + "" + ); + this.runConformTest( + new String[] { + "Y.java", + "import java.lang.ref.Reference;\n" + + "import p.X;\n" + + "public class Y {\n" + + " Reference x;\n" + + " Reference y; \n" + + " Reference z; \n" + + " Reference.Other.Deeply> t;\n" + + " Reference.Other.Deeply.Inside> u;\n" + + " Y(X someX) {\n" + + " this.x = someX.x;\n" + + " this. y = someX.y; \n" + + " this.z = someX.z; \n" + + " this.t = someX.t;\n" + + " this.u = someX.u; \n" + + " }\n" + + " public static void main(String[] args) throws Exception {\n" + + " System.out.print(Y.class.getDeclaredField(\"x\").getGenericType());\n" + + " System.out.print(\"##\");\n" + + " System.out.print(Y.class.getDeclaredField(\"y\").getGenericType());\n" + + " System.out.print(\"##\");\n" + + " System.out.print(Y.class.getDeclaredField(\"z\").getGenericType());\n" + + " System.out.print(\"##\");\n" + + " System.out.print(Y.class.getDeclaredField(\"t\").getGenericType());\n" + + " //System.out.print(\"##\");\n" + + " //System.out.print(Y.class.getDeclaredField(\"u\").getGenericType());\n" + // TODO disabled due to bug in libs (unable to re-read the generated signature) + " System.out.println();\n" + + " }\n" + + "}\n" + }, + "java.lang.ref.Reference##java.lang.ref.Reference##java.lang.ref.Reference##java.lang.ref.Reference.Other.Deeply>", + null, + false, // do not flush output + null); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=189158 - variation +public void test1154() { + this.runConformTest( + new String[] { + "X.java", + "import java.lang.ref.Reference;\n" + + "public class X {\n" + + " class Other {\n" + + " class Deeply {\n" + + " class Deeper {\n" + + " class Inside {\n" + + " } \n" + + " }\n" + + " }\n" + + " }\n" + + " Reference.Deeply> t;\n" + + " Reference.Deeply.Deeper.Inside> u;\n" + + "\n" + + " public static void main(String[] args) throws Exception {\n" + + " //System.out.print(X.class.getDeclaredField(\"t\").getGenericType());\n" + // TODO disabled due to bug in libs (unable to re-read the generated signature) + " //System.out.print(\"##\");\n" + + " //System.out.print(X.class.getDeclaredField(\"u\").getGenericType());\n" + // TODO disabled due to bug in libs (unable to re-read the generated signature) + " System.out.println();\n" + + " }\n" + + "}\n" + }, + ""); + + String expectedOutput = + " // Field descriptor #6 Ljava/lang/ref/Reference;\n" + + " // Signature: Ljava/lang/ref/Reference.Deeply;>;\n" + + " java.lang.ref.Reference t;\n" + + " \n" + + " // Field descriptor #6 Ljava/lang/ref/Reference;\n" + + " // Signature: Ljava/lang/ref/Reference.Deeply.Deeper.Inside;>;\n" + + " java.lang.ref.Reference u;\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=189158 - variation +public void test1155() { + this.runConformTest( + new String[] { + "X.java", + "import java.lang.ref.Reference;\n" + + "public class X {\n" + + " class Other {\n" + + " class Deeply {\n" + + " class Deeper {\n" + + " class Inside {\n" + + " } \n" + + " }\n" + + " }\n" + + " }\n" + + " Reference.Other.Deeply> t;\n" + + " Reference.Other.Deeply.Deeper.Inside> u;\n" + + "\n" + + " public static void main(String[] args) throws Exception {\n" + + " System.out.print(X.class.getDeclaredField(\"t\").getGenericType());\n" + + " //System.out.print(\"##\");\n" + + " //System.out.print(X.class.getDeclaredField(\"u\").getGenericType());\n" + // TODO disabled due to bug in libs (unable to re-read the generated signature) + " System.out.println();\n" + + " }\n" + + "}\n" + }, + "java.lang.ref.Reference.Other.Deeply>" ); + + String expectedOutput = + " // Field descriptor #6 Ljava/lang/ref/Reference;\n" + + " // Signature: Ljava/lang/ref/Reference.Other.Deeply;>;\n" + + " java.lang.ref.Reference t;\n" + + " \n" + + " // Field descriptor #6 Ljava/lang/ref/Reference;\n" + + " // Signature: Ljava/lang/ref/Reference.Other.Deeply.Deeper.Inside;>;\n" + + " java.lang.ref.Reference u;\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=203061 - variation +public void test1163() { + this.runNegativeTest( + new String[] { + "X.java", + "public final class X {\n" + + " private final Object mObj;\n" + + " private final Object mDependent = new Object() {\n" + + " {\n" + + " Object o1 = mObj;\n" + + " }\n" + + " Object o2 = mObj;\n" + + " void foo() {\n" + + " Object o3 = mObj;\n" + + " }\n" + + " };\n" + + " public X() {\n" + + " mObj = \"\";\n" + + " }\n" + + "}\n", // ================= + }, + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " private final Object mDependent = new Object() {\n" + + " ^^^^^^^^^^\n" + + "The field X.mDependent is never read locally\n" + + "----------\n" + + "2. WARNING in X.java (at line 5)\n" + + " Object o1 = mObj;\n" + + " ^^^^\n" + + "Read access to enclosing field X.mObj is emulated by a synthetic accessor method. Increasing its visibility will improve your performance\n" + + "----------\n" + + "3. ERROR in X.java (at line 5)\n" + + " Object o1 = mObj;\n" + + " ^^^^\n" + + "The blank final field mObj may not have been initialized\n" + + "----------\n" + + "4. WARNING in X.java (at line 7)\n" + + " Object o2 = mObj;\n" + + " ^^\n" + + "The field new Object(){}.o2 is never read locally\n" + + "----------\n" + + "5. WARNING in X.java (at line 7)\n" + + " Object o2 = mObj;\n" + + " ^^^^\n" + + "Read access to enclosing field X.mObj is emulated by a synthetic accessor method. Increasing its visibility will improve your performance\n" + + "----------\n" + + "6. ERROR in X.java (at line 7)\n" + + " Object o2 = mObj;\n" + + " ^^^^\n" + + "The blank final field mObj may not have been initialized\n" + + "----------\n" + + "7. WARNING in X.java (at line 8)\n" + + " void foo() {\n" + + " ^^^^^\n" + + "The method foo() from the type new Object(){} is never used locally\n" + + "----------\n" + + "8. WARNING in X.java (at line 9)\n" + + " Object o3 = mObj;\n" + + " ^^^^\n" + + "Read access to enclosing field X.mObj is emulated by a synthetic accessor method. Increasing its visibility will improve your performance\n" + + "----------\n"); +} +//https://bugs.eclipse.org/bugs/show_bug.cgi?id=203061 - variation +public void test1164() { + this.runNegativeTest( + new String[] { + "X.java", + "public final class X {\n" + + " private final Object mObj;\n" + + " private final Object mDependent = new Object() {\n" + + " {\n" + + " Object o1 = mObj;\n" + + " mObj = \"1\";\n" + + " }\n" + + " Object o2 = mObj = \"2\";\n" + + " void foo() {\n" + + " Object o3 = mObj;\n" + + " mObj = \"3\";\n" + + " }\n" + + " };\n" + + " public X() {\n" + + " mObj = \"\";\n" + + " }\n" + + "}\n" + }, + "----------\n" + + "1. WARNING in X.java (at line 3)\n" + + " private final Object mDependent = new Object() {\n" + + " ^^^^^^^^^^\n" + + "The field X.mDependent is never read locally\n" + + "----------\n" + + "2. WARNING in X.java (at line 5)\n" + + " Object o1 = mObj;\n" + + " ^^^^\n" + + "Read access to enclosing field X.mObj is emulated by a synthetic accessor method. Increasing its visibility will improve your performance\n" + + "----------\n" + + "3. ERROR in X.java (at line 5)\n" + + " Object o1 = mObj;\n" + + " ^^^^\n" + + "The blank final field mObj may not have been initialized\n" + + "----------\n" + + "4. WARNING in X.java (at line 6)\n" + + " mObj = \"1\";\n" + + " ^^^^\n" + + "Write access to enclosing field X.mObj is emulated by a synthetic accessor method. Increasing its visibility will improve your performance\n" + + "----------\n" + + "5. ERROR in X.java (at line 6)\n" + + " mObj = \"1\";\n" + + " ^^^^\n" + + "The final field X.mObj cannot be assigned\n" + + "----------\n" + + "6. WARNING in X.java (at line 8)\n" + + " Object o2 = mObj = \"2\";\n" + + " ^^\n" + + "The field new Object(){}.o2 is never read locally\n" + + "----------\n" + + "7. WARNING in X.java (at line 8)\n" + + " Object o2 = mObj = \"2\";\n" + + " ^^^^\n" + + "Write access to enclosing field X.mObj is emulated by a synthetic accessor method. Increasing its visibility will improve your performance\n" + + "----------\n" + + "8. ERROR in X.java (at line 8)\n" + + " Object o2 = mObj = \"2\";\n" + + " ^^^^\n" + + "The final field X.mObj cannot be assigned\n" + + "----------\n" + + "9. WARNING in X.java (at line 9)\n" + + " void foo() {\n" + + " ^^^^^\n" + + "The method foo() from the type new Object(){} is never used locally\n" + + "----------\n" + + "10. WARNING in X.java (at line 10)\n" + + " Object o3 = mObj;\n" + + " ^^^^\n" + + "Read access to enclosing field X.mObj is emulated by a synthetic accessor method. Increasing its visibility will improve your performance\n" + + "----------\n" + + "11. WARNING in X.java (at line 11)\n" + + " mObj = \"3\";\n" + + " ^^^^\n" + + "Write access to enclosing field X.mObj is emulated by a synthetic accessor method. Increasing its visibility will improve your performance\n" + + "----------\n" + + "12. ERROR in X.java (at line 11)\n" + + " mObj = \"3\";\n" + + " ^^^^\n" + + "The final field X.mObj cannot be assigned\n" + + "----------\n"); +} }