changeset 829:02e6e7dd1a64

6510286: Wording of javac error for inner classes Summary: 'inner classes cannot have static declarations' message needs to be reworked Reviewed-by: jjg
author mcimadamore
date Mon, 24 Jan 2011 15:45:06 +0000
parents ce6175cfe11e
children 812c6251ea78
files src/share/classes/com/sun/tools/javac/comp/Attr.java src/share/classes/com/sun/tools/javac/resources/compiler.properties test/tools/javac/InnerNamedConstant_2.out
diffstat 3 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Jan 24 15:44:51 2011 +0000
+++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Mon Jan 24 15:45:06 2011 +0000
@@ -3156,7 +3156,7 @@
                 if (sym == null ||
                     sym.kind != VAR ||
                     ((VarSymbol) sym).getConstValue() == null)
-                    log.error(l.head.pos(), "icls.cant.have.static.decl");
+                    log.error(l.head.pos(), "icls.cant.have.static.decl", sym.location());
             }
         }
 
--- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Mon Jan 24 15:44:51 2011 +0000
+++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Mon Jan 24 15:45:06 2011 +0000
@@ -196,7 +196,8 @@
     a generic class may not extend java.lang.Throwable
 
 compiler.err.icls.cant.have.static.decl=\
-    inner classes cannot have static declarations
+    Illegal static declaration in inner class {0}\n\
+    modifier \''static\'' is only allowed in constant variable declarations
 compiler.err.illegal.char=\
     illegal character: \\{0}
 compiler.err.illegal.char.for.encoding=\
--- a/test/tools/javac/InnerNamedConstant_2.out	Mon Jan 24 15:44:51 2011 +0000
+++ b/test/tools/javac/InnerNamedConstant_2.out	Mon Jan 24 15:45:06 2011 +0000
@@ -1,5 +1,5 @@
-InnerNamedConstant_2.java:22:20: compiler.err.icls.cant.have.static.decl
-InnerNamedConstant_2.java:23:29: compiler.err.icls.cant.have.static.decl
+InnerNamedConstant_2.java:22:20: compiler.err.icls.cant.have.static.decl: InnerNamedConstant_2.Inner2
+InnerNamedConstant_2.java:23:29: compiler.err.icls.cant.have.static.decl: InnerNamedConstant_2.Inner2
 InnerNamedConstant_2.java:25:13: compiler.err.cant.assign.val.to.final.var: z
-InnerNamedConstant_2.java:34:26: compiler.err.icls.cant.have.static.decl
+InnerNamedConstant_2.java:34:26: compiler.err.icls.cant.have.static.decl: InnerNamedConstant_2.Inner3
 4 errors