diff -r d94fe2d29b1e -r 380f6c17ea01 src/share/classes/com/sun/tools/javac/comp/Attr.java --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Wed Jun 10 09:13:27 2015 +0200 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Jan 10 12:47:15 2014 +0100 @@ -825,9 +825,18 @@ } public void visitClassDef(JCClassDecl tree) { - // Local classes have not been entered yet, so we need to do it now: - if ((env.info.scope.owner.kind & (VAR | MTH)) != 0) + // Local and anonymous classes have not been entered yet, so we need to + // do it now. + if ((env.info.scope.owner.kind & (VAR | MTH)) != 0) { enter.classEnter(tree, env); + } else { + // If this class declaration is part of a class level annotation, + // as in @MyAnno(new Object() {}) class MyClass {}, enter it in + // order to simplify later steps and allow for sensible error + // messages. + if (env.tree.hasTag(NEWCLASS) && TreeInfo.isInAnnotation(env, tree)) + enter.classEnter(tree, env); + } ClassSymbol c = tree.sym; if (c == null) {