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 129830 Details for
Bug 267670
Private enum constant incorrectly marked as never read locally
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Proposed patch & tests
patch.txt (text/plain), 4.50 KB, created by
Srikanth Sankaran
on 2009-03-25 07:36:06 EDT
(
hide
)
Description:
Proposed patch & tests
Filename:
MIME Type:
Creator:
Srikanth Sankaran
Created:
2009-03-25 07:36:06 EDT
Size:
4.50 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.141 >diff -u -r1.141 EnumTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java 6 Feb 2009 13:38:57 -0000 1.141 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/EnumTest.java 25 Mar 2009 09:03:09 -0000 >@@ -6132,5 +6132,74 @@ > "Cannot reference a field before it is defined\n" + > "----------\n"); > } >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=267670. Make sure we don't emit any unused >+// warnings about enumerators. Since these could be used in indirect ways not obvious. >+public void test171() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING); >+ this.runConformTest( >+ true, >+ new String[] { >+ "X.java", >+ "public class X { \n" + >+ " private enum Colors {\n" + >+ " BLEU,\n" + >+ " BLANC,\n" + >+ " ROUGE\n" + >+ " }\n" + >+ " public static void main(String[] args) {\n" + >+ " for (Colors c: Colors.values()) {\n" + >+ " System.out.print(c);\n" + >+ " }\n" + >+ " }\n" + >+ "}\n" >+ }, >+ null, customOptions, >+ "", >+ "BLEUBLANCROUGE", null, >+ JavacTestOptions.Excuse.EclipseHasSomeMoreWarnings); >+} >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=267670. Make sure we don't emit any unused >+// warnings about enumerators. Since these could be used in indirect ways not obvious. This >+// test also verifies that while we don't complain about individual enumerators not being used >+// we DO complain if the enumeration type itself is not used. >+public void test172() { >+ Map customOptions = getCompilerOptions(); >+ customOptions.put(CompilerOptions.OPTION_ReportUnusedLocal, CompilerOptions.WARNING); >+ this.runConformTest( >+ true, >+ new String[] { >+ "X.java", >+ "public class X { \n" + >+ " private enum Greet {\n" + >+ " HELLO, HOWDY, BONJOUR; \n" + >+ " }\n" + >+ " private enum Colors {\n" + >+ " RED, BLACK, BLUE;\n"+ >+ " }\n" + >+ " private enum Complaint {" + >+ " WARNING, ERROR, FATAL_ERROR, PANIC;\n" + >+ " }\n" + >+ " public static void main(String[] args) {\n" + >+ " Greet g = Greet.valueOf(\"HELLO\");\n" + >+ " System.out.print(g);\n" + >+ " Colors c = Greet.valueOf(Colors.class, \"RED\");\n" + >+ " System.out.print(c);\n" + >+ " }\n" + >+ "}\n" >+ }, >+ null, customOptions, >+ "----------\n" + >+ "1. WARNING in X.java (at line 8)\n" + >+ " private enum Complaint { WARNING, ERROR, FATAL_ERROR, PANIC;\n" + >+ " ^^^^^^^^^\n" + >+ "The type X.Complaint is never used locally\n" + >+ "----------\n", >+ "HELLORED", null, >+ JavacTestOptions.Excuse.EclipseHasSomeMoreWarnings); >+} >+ > } > >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java,v >retrieving revision 1.169 >diff -u -r1.169 ClassScope.java >--- compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java 13 Feb 2009 21:40:39 -0000 1.169 >+++ compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java 25 Mar 2009 09:03:12 -0000 >@@ -651,7 +651,11 @@ > problemReporter().illegalModifierForEnumConstant(declaringClass, fieldDecl); > > // set the modifiers >- final int IMPLICIT_MODIFIERS = ClassFileConstants.AccPublic | ClassFileConstants.AccStatic | ClassFileConstants.AccFinal | ClassFileConstants.AccEnum; >+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=267670. Force all enumerators to be marked >+ // as used locally. We are unable to track the usage of these reliably as they could be used >+ // in non obvious ways via the synthesized methods values() and valueOf(String) or by using >+ // Enum.valueOf(Class<T>, String). >+ final int IMPLICIT_MODIFIERS = ClassFileConstants.AccPublic | ClassFileConstants.AccStatic | ClassFileConstants.AccFinal | ClassFileConstants.AccEnum | ExtraCompilerModifiers.AccLocallyUsed; > fieldBinding.modifiers|= IMPLICIT_MODIFIERS; > return; > }
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 267670
:
129830
|
130205