Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 115952 Details for
Bug 251814
[1.5][compiler] Dup Enum#valueOf(...) should keep the synthetic one
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch with testcases
patch.txt (text/plain), 7.55 KB, created by
Kent Johnson
on 2008-10-23 12:04:21 EDT
(
hide
)
Description:
Proposed patch with testcases
Filename:
MIME Type:
Creator:
Kent Johnson
Created:
2008-10-23 12:04:21 EDT
Size:
7.55 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core.tests.compiler >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.134 >diff -u -r1.134 EnumTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java 23 Oct 2008 08:09:00 -0000 1.134 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java 23 Oct 2008 16:03:43 -0000 >@@ -5828,7 +5828,12 @@ > "1. ERROR in X.java (at line 3)\n" + > " private int valueOf(String arg0) { return 0; }//11\n" + > " ^^^^^^^^^^^^^^^^^^^^\n" + >- "The enum X already defines the method valueOf(String) implicitly\n" + >+ "The enum X already defines the method valueOf(String) implicitly\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 5)\n" + >+ " int i = valueOf(\"\");\n" + >+ " ^^^^^^^^^^^\n" + >+ "Type mismatch: cannot convert from X to int\n" + > "----------\n", > null, > true, // flush output >@@ -5838,19 +5843,34 @@ > false); > // check for presence of #valueOf(...) in problem type > String expectedOutput = >- " // Method descriptor #20 (Ljava/lang/String;)I\n" + >- " // Stack: 3, Locals: 2\n" + >- " private int valueOf(java.lang.String arg0);\n" + >+ "public final enum X {\n" + >+ " \n" + >+ " // Method descriptor #6 (Ljava/lang/String;I)V\n" + >+ " // Stack: 3, Locals: 3\n" + >+ " private X(java.lang.String arg0, int arg1);\n" + > " 0 new java.lang.Error [8]\n" + > " 3 dup\n" + >- " 4 ldc <String \"Unresolved compilation problem: \\n\\tThe enum X already defines the method valueOf(String) implicitly\\n\"> [10]\n" + >+ " 4 ldc <String \"Unresolved compilation problems: \\n\\tThe enum X already defines the method valueOf(String) implicitly\\n\\tType mismatch: cannot convert from X to int\\n\"> [10]\n" + > " 6 invokespecial java.lang.Error(java.lang.String) [12]\n" + > " 9 athrow\n" + > " Line numbers:\n" + > " [pc: 0, line: 3]\n" + > " Local variable table:\n" + > " [pc: 0, pc: 10] local: this index: 0 type: X\n" + >- " [pc: 0, pc: 10] local: arg0 index: 1 type: java.lang.String\n"; >+ " \n" + >+ " // Method descriptor #20 ()V\n" + >+ " // Stack: 3, Locals: 1\n" + >+ " void foo();\n" + >+ " 0 new java.lang.Error [8]\n" + >+ " 3 dup\n" + >+ " 4 ldc <String \"Unresolved compilation problem: \\n\\tType mismatch: cannot convert from X to int\\n\"> [21]\n" + >+ " 6 invokespecial java.lang.Error(java.lang.String) [12]\n" + >+ " 9 athrow\n" + >+ " Line numbers:\n" + >+ " [pc: 0, line: 5]\n" + >+ " Local variable table:\n" + >+ " [pc: 0, pc: 10] local: this index: 0 type: X\n" + >+ "}"; > > checkDisassembledClassFile(OUTPUT_DIR + File.separator + "X.class", "X", expectedOutput); > } >@@ -5858,14 +5878,47 @@ > public void test167() throws Exception { > this.runNegativeTest( > new String[] { >- "X.java", // ================= >- "public enum X {\n" + >- " ;\n" + >- " static int valueOf(String arg0) { return 0; }//9\n" + >- " void foo() {\n" + >- " int i = X.valueOf(\"\");\n" + >- " }\n" + >- "}\n", >+ "X.java", // ================= >+ "public enum X {\n" + >+ " ;\n" + >+ " static int valueOf(String arg0) { return 0; }//9\n" + >+ " void foo() {\n" + >+ " int i = X.valueOf(\"\");\n" + >+ " }\n" + >+ "}\n", >+ "Other.java",// ================= >+ "public class Other {\n" + >+ " void foo() {\n" + >+ " int i = X.valueOf(\"\");\n" + >+ " }\n" + >+ "}\n", // ================= >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 3)\n" + >+ " static int valueOf(String arg0) { return 0; }//9\n" + >+ " ^^^^^^^^^^^^^^^^^^^^\n" + >+ "The enum X already defines the method valueOf(String) implicitly\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 5)\n" + >+ " int i = X.valueOf(\"\");\n" + >+ " ^^^^^^^^^^^^^\n" + >+ "Type mismatch: cannot convert from X to int\n" + >+ "----------\n" + >+ "----------\n" + >+ "1. ERROR in Other.java (at line 3)\n" + >+ " int i = X.valueOf(\"\");\n" + >+ " ^^^^^^^^^^^^^\n" + >+ "Type mismatch: cannot convert from X to int\n" + >+ "----------\n", >+ null, >+ true, // flush output >+ null, >+ true, // generate output >+ false, >+ false); >+ // check consistency of problem when incremental compiling against X problemType >+ this.runNegativeTest( >+ new String[] { > "Other.java",// ================= > "public class Other {\n" + > " void foo() {\n" + >@@ -5873,33 +5926,17 @@ > " }\n" + > "}\n", // ================= > }, >- "----------\n" + >- "1. ERROR in X.java (at line 3)\n" + >- " static int valueOf(String arg0) { return 0; }//9\n" + >- " ^^^^^^^^^^^^^^^^^^^^\n" + >- "The enum X already defines the method valueOf(String) implicitly\n" + >+ "----------\n" + >+ "1. ERROR in Other.java (at line 3)\n" + >+ " int i = X.valueOf(\"\");\n" + >+ " ^^^^^^^\n" + >+ "The method valueOf(Class<T>, String) in the type Enum<X> is not applicable for the arguments (String)\n" + > "----------\n", > null, >- true, // flush output >+ false, // flush output > null, > true, // generate output > false, > false); >- // check consistency of problem when incremental compiling against X problemType >- this.runNegativeTest( >- new String[] { >- "Other.java",// ================= >- "public class Other {\n" + >- " void foo() {\n" + >- " int i = X.valueOf(\"\");\n" + >- " }\n" + >- "}\n", // ================= >- }, >- "", >- null, >- false, // flush output >- null, >- true, // generate output >- false, >- false);} >+ } > } >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java,v >retrieving revision 1.167 >diff -u -r1.167 SourceTypeBinding.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 21 Oct 2008 17:54:42 -0000 1.167 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java 23 Oct 2008 16:03:44 -0000 >@@ -1168,10 +1168,18 @@ > if (methodDecl == null) { > methodDecl = method.sourceMethod(); // cannot be retrieved after binding is lost & may still be null if method is special > if (methodDecl != null && methodDecl.binding != null) { // ensure its a valid user defined method >- if (isEnumSpecialMethod) >+ if (isEnumSpecialMethod) { > this.scope.problemReporter().duplicateEnumSpecialMethod(this, methodDecl); >- else >+ // remove user defined methods & keep the synthetic >+ methodDecl.binding = null; >+ // do not alter original method array until resolution is over, due to reentrance (143259) >+ if (resolvedMethods == this.methods) >+ System.arraycopy(this.methods, 0, resolvedMethods = new MethodBinding[length], 0, length); >+ resolvedMethods[i] = null; >+ failed++; >+ } else { > this.scope.problemReporter().duplicateMethodInType(this, methodDecl, method.areParametersEqual(method2)); >+ } > } > } > AbstractMethodDeclaration method2Decl = method2.sourceMethod();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 251814
: 115952