langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java
changeset 18657 2bd14bebdf57
parent 18644 02f65c63159c
child 18662 1cac45e71eb9
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Jun 27 09:54:50 2013 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java	Thu Jun 27 16:04:05 2013 +0100
@@ -756,25 +756,15 @@
                                       JCTree.JCExpression initializer,
                                       Type type) {
 
-        // in case no lint value has been set up for this env, scan up
-        // env stack looking for smallest enclosing env for which it is set.
-        Env<AttrContext> lintEnv = env;
-        while (lintEnv.info.lint == null)
-            lintEnv = lintEnv.next;
-
-        // Having found the enclosing lint value, we can initialize the lint value for this class
-        // ... but ...
-        // There's a problem with evaluating annotations in the right order, such that
-        // env.info.enclVar.attributes_field might not yet have been evaluated, and so might be
-        // null. In that case, calling augment will throw an NPE. To avoid this, for now we
-        // revert to the jdk 6 behavior and ignore the (unevaluated) attributes.
-        if (env.info.enclVar.annotationsPendingCompletion()) {
-            env.info.lint = lintEnv.info.lint;
-        } else {
-            env.info.lint = lintEnv.info.lint.augment(env.info.enclVar);
-        }
-
-        Lint prevLint = chk.setLint(env.info.lint);
+        /*  When this env was created, it didn't have the correct lint nor had
+         *  annotations has been processed.
+         *  But now at this phase we have already processed annotations and the
+         *  correct lint must have been set in chk, so we should use that one to
+         *  attribute the initializer.
+         */
+        Lint prevLint = env.info.lint;
+        env.info.lint = chk.getLint();
+
         JavaFileObject prevSource = log.useSource(env.toplevel.sourcefile);
 
         try {
@@ -786,10 +776,11 @@
             memberEnter.typeAnnotate(initializer, env, null);
             annotate.flush();
             Type itype = attribExpr(initializer, env, type);
-            if (itype.constValue() != null)
+            if (itype.constValue() != null) {
                 return coerce(itype, type).constValue();
-            else
+            } else {
                 return null;
+            }
         } finally {
             env.info.lint = prevLint;
             log.useSource(prevSource);