changeset 2638:88ce114c6adc jdk8u40-b13

Merge
author lana
date Fri, 31 Oct 2014 20:19:04 -0700
parents 93cc96153390 (current diff) ac75605c22f6 (diff)
children f18c5b47f27b 8dcde670aed3
files
diffstat 8 files changed, 459 insertions(+), 284 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/tools/javac/code/Types.java	Wed Oct 29 10:50:43 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/code/Types.java	Fri Oct 31 20:19:04 2014 -0700
@@ -1892,7 +1892,12 @@
      * Mapping to take element type of an arraytype
      */
     private Mapping elemTypeFun = new Mapping ("elemTypeFun") {
-        public Type apply(Type t) { return elemtype(t); }
+        public Type apply(Type t) {
+            while (t.hasTag(TYPEVAR)) {
+                t = t.getUpperBound();
+            }
+            return elemtype(t);
+        }
     };
 
     /**
@@ -3521,40 +3526,46 @@
     }
 
     /**
-     * Return the least upper bound of pair of types.  if the lub does
+     * Return the least upper bound of list of types.  if the lub does
      * not exist return null.
      */
-    public Type lub(Type t1, Type t2) {
-        return lub(List.of(t1, t2));
+    public Type lub(List<Type> ts) {
+        return lub(ts.toArray(new Type[ts.length()]));
     }
 
     /**
      * Return the least upper bound (lub) of set of types.  If the lub
      * does not exist return the type of null (bottom).
      */
-    public Type lub(List<Type> ts) {
+    public Type lub(Type... ts) {
+        final int UNKNOWN_BOUND = 0;
         final int ARRAY_BOUND = 1;
         final int CLASS_BOUND = 2;
-        int boundkind = 0;
-        for (Type t : ts) {
+
+        int[] kinds = new int[ts.length];
+
+        int boundkind = UNKNOWN_BOUND;
+        for (int i = 0 ; i < ts.length ; i++) {
+            Type t = ts[i];
             switch (t.getTag()) {
             case CLASS:
-                boundkind |= CLASS_BOUND;
+                boundkind |= kinds[i] = CLASS_BOUND;
                 break;
             case ARRAY:
-                boundkind |= ARRAY_BOUND;
+                boundkind |= kinds[i] = ARRAY_BOUND;
                 break;
             case  TYPEVAR:
                 do {
                     t = t.getUpperBound();
                 } while (t.hasTag(TYPEVAR));
                 if (t.hasTag(ARRAY)) {
-                    boundkind |= ARRAY_BOUND;
+                    boundkind |= kinds[i] = ARRAY_BOUND;
                 } else {
-                    boundkind |= CLASS_BOUND;
+                    boundkind |= kinds[i] = CLASS_BOUND;
                 }
                 break;
             default:
+                kinds[i] = UNKNOWN_BOUND;
                 if (t.isPrimitive())
                     return syms.errType;
             }
@@ -3565,15 +3576,16 @@
 
         case ARRAY_BOUND:
             // calculate lub(A[], B[])
-            List<Type> elements = Type.map(ts, elemTypeFun);
-            for (Type t : elements) {
-                if (t.isPrimitive()) {
+            Type[] elements = new Type[ts.length];
+            for (int i = 0 ; i < ts.length ; i++) {
+                Type elem = elements[i] = elemTypeFun.apply(ts[i]);
+                if (elem.isPrimitive()) {
                     // if a primitive type is found, then return
                     // arraySuperType unless all the types are the
                     // same
-                    Type first = ts.head;
-                    for (Type s : ts.tail) {
-                        if (!isSameType(first, s)) {
+                    Type first = ts[0];
+                    for (int j = 1 ; j < ts.length ; j++) {
+                        if (!isSameType(first, ts[j])) {
                              // lub(int[], B[]) is Cloneable & Serializable
                             return arraySuperType();
                         }
@@ -3588,13 +3600,20 @@
 
         case CLASS_BOUND:
             // calculate lub(A, B)
-            while (!ts.head.hasTag(CLASS) && !ts.head.hasTag(TYPEVAR)) {
-                ts = ts.tail;
+            int startIdx = 0;
+            for (int i = 0; i < ts.length ; i++) {
+                Type t = ts[i];
+                if (t.hasTag(CLASS) || t.hasTag(TYPEVAR)) {
+                    break;
+                } else {
+                    startIdx++;
+                }
             }
-            Assert.check(!ts.isEmpty());
+            Assert.check(startIdx < ts.length);
             //step 1 - compute erased candidate set (EC)
-            List<Type> cl = erasedSupertypes(ts.head);
-            for (Type t : ts.tail) {
+            List<Type> cl = erasedSupertypes(ts[startIdx]);
+            for (int i = startIdx + 1 ; i < ts.length ; i++) {
+                Type t = ts[i];
                 if (t.hasTag(CLASS) || t.hasTag(TYPEVAR))
                     cl = intersect(cl, erasedSupertypes(t));
             }
@@ -3603,9 +3622,9 @@
             //step 3 - for each element G in MEC, compute lci(Inv(G))
             List<Type> candidates = List.nil();
             for (Type erasedSupertype : mec) {
-                List<Type> lci = List.of(asSuper(ts.head, erasedSupertype.tsym));
-                for (Type t : ts) {
-                    lci = intersect(lci, List.of(asSuper(t, erasedSupertype.tsym)));
+                List<Type> lci = List.of(asSuper(ts[startIdx], erasedSupertype.tsym));
+                for (int i = startIdx + 1 ; i < ts.length ; i++) {
+                    lci = intersect(lci, List.of(asSuper(ts[i], erasedSupertype.tsym)));
                 }
                 candidates = candidates.appendList(lci);
             }
@@ -3616,9 +3635,9 @@
         default:
             // calculate lub(A, B[])
             List<Type> classes = List.of(arraySuperType());
-            for (Type t : ts) {
-                if (!t.hasTag(ARRAY)) // Filter out any arrays
-                    classes = classes.prepend(t);
+            for (int i = 0 ; i < ts.length ; i++) {
+                if (kinds[i] != ARRAY_BOUND) // Filter out any arrays
+                    classes = classes.prepend(ts[i]);
             }
             // lub(A, B[]) is lub(A, arraySuperType)
             return lub(classes);
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java	Wed Oct 29 10:50:43 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java	Fri Oct 31 20:19:04 2014 -0700
@@ -1010,8 +1010,12 @@
                 // parameters have already been entered
                 env.info.scope.enter(tree.sym);
             } else {
-                memberEnter.memberEnter(tree, env);
-                annotate.flush();
+                try {
+                    annotate.enterStart();
+                    memberEnter.memberEnter(tree, env);
+                } finally {
+                    annotate.enterDone();
+                }
             }
         } else {
             if (tree.init != null) {
--- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Wed Oct 29 10:50:43 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java	Fri Oct 31 20:19:04 2014 -0700
@@ -575,51 +575,46 @@
 
         Env<AttrContext> localEnv = methodEnv(tree, env);
 
-        annotate.enterStart();
+        DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos());
         try {
-            DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos());
-            try {
-                // Compute the method type
-                m.type = signature(m, tree.typarams, tree.params,
-                                   tree.restype, tree.recvparam,
-                                   tree.thrown,
-                                   localEnv);
-            } finally {
-                deferredLintHandler.setPos(prevLintPos);
-            }
+            // Compute the method type
+            m.type = signature(m, tree.typarams, tree.params,
+                               tree.restype, tree.recvparam,
+                               tree.thrown,
+                               localEnv);
+        } finally {
+            deferredLintHandler.setPos(prevLintPos);
+        }
 
-            if (types.isSignaturePolymorphic(m)) {
-                m.flags_field |= SIGNATURE_POLYMORPHIC;
-            }
+        if (types.isSignaturePolymorphic(m)) {
+            m.flags_field |= SIGNATURE_POLYMORPHIC;
+        }
 
-            // Set m.params
-            ListBuffer<VarSymbol> params = new ListBuffer<VarSymbol>();
-            JCVariableDecl lastParam = null;
-            for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) {
-                JCVariableDecl param = lastParam = l.head;
-                params.append(Assert.checkNonNull(param.sym));
-            }
-            m.params = params.toList();
+        // Set m.params
+        ListBuffer<VarSymbol> params = new ListBuffer<VarSymbol>();
+        JCVariableDecl lastParam = null;
+        for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) {
+            JCVariableDecl param = lastParam = l.head;
+            params.append(Assert.checkNonNull(param.sym));
+        }
+        m.params = params.toList();
 
-            // mark the method varargs, if necessary
-            if (lastParam != null && (lastParam.mods.flags & Flags.VARARGS) != 0)
-                m.flags_field |= Flags.VARARGS;
+        // mark the method varargs, if necessary
+        if (lastParam != null && (lastParam.mods.flags & Flags.VARARGS) != 0)
+            m.flags_field |= Flags.VARARGS;
 
-            localEnv.info.scope.leave();
-            if (chk.checkUnique(tree.pos(), m, enclScope)) {
-            enclScope.enter(m);
-            }
+        localEnv.info.scope.leave();
+        if (chk.checkUnique(tree.pos(), m, enclScope)) {
+        enclScope.enter(m);
+        }
 
-            annotateLater(tree.mods.annotations, localEnv, m, tree.pos());
-            // Visit the signature of the method. Note that
-            // TypeAnnotate doesn't descend into the body.
-            typeAnnotate(tree, localEnv, m, tree.pos());
+        annotateLater(tree.mods.annotations, localEnv, m, tree.pos());
+        // Visit the signature of the method. Note that
+        // TypeAnnotate doesn't descend into the body.
+        typeAnnotate(tree, localEnv, m, tree.pos());
 
-            if (tree.defaultValue != null)
-                annotateDefaultValueLater(tree.defaultValue, localEnv, m);
-        } finally {
-            annotate.enterDone();
-        }
+        if (tree.defaultValue != null)
+            annotateDefaultValueLater(tree.defaultValue, localEnv, m);
     }
 
     /** Create a fresh environment for method bodies.
@@ -647,54 +642,49 @@
             localEnv.info.staticLevel++;
         }
         DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos());
-        annotate.enterStart();
         try {
-            try {
-                if (TreeInfo.isEnumInit(tree)) {
-                    attr.attribIdentAsEnumType(localEnv, (JCIdent)tree.vartype);
-                } else {
-                    attr.attribType(tree.vartype, localEnv);
-                    if (TreeInfo.isReceiverParam(tree))
-                        checkReceiver(tree, localEnv);
-                }
-            } finally {
-                deferredLintHandler.setPos(prevLintPos);
-            }
-
-            if ((tree.mods.flags & VARARGS) != 0) {
-                //if we are entering a varargs parameter, we need to
-                //replace its type (a plain array type) with the more
-                //precise VarargsType --- we need to do it this way
-                //because varargs is represented in the tree as a
-                //modifier on the parameter declaration, and not as a
-                //distinct type of array node.
-                ArrayType atype = (ArrayType)tree.vartype.type.unannotatedType();
-                tree.vartype.type = atype.makeVarargs();
+            if (TreeInfo.isEnumInit(tree)) {
+                attr.attribIdentAsEnumType(localEnv, (JCIdent)tree.vartype);
+            } else {
+                attr.attribType(tree.vartype, localEnv);
+                if (TreeInfo.isReceiverParam(tree))
+                    checkReceiver(tree, localEnv);
             }
-            Scope enclScope = enter.enterScope(env);
-            VarSymbol v =
-                new VarSymbol(0, tree.name, tree.vartype.type, enclScope.owner);
-            v.flags_field = chk.checkFlags(tree.pos(), tree.mods.flags, v, tree);
-            tree.sym = v;
-            if (tree.init != null) {
-                v.flags_field |= HASINIT;
-                if ((v.flags_field & FINAL) != 0 &&
-                    needsLazyConstValue(tree.init)) {
-                    Env<AttrContext> initEnv = getInitEnv(tree, env);
-                    initEnv.info.enclVar = v;
-                    v.setLazyConstValue(initEnv(tree, initEnv), attr, tree);
-                }
+        } finally {
+            deferredLintHandler.setPos(prevLintPos);
+        }
+
+        if ((tree.mods.flags & VARARGS) != 0) {
+            //if we are entering a varargs parameter, we need to
+            //replace its type (a plain array type) with the more
+            //precise VarargsType --- we need to do it this way
+            //because varargs is represented in the tree as a
+            //modifier on the parameter declaration, and not as a
+            //distinct type of array node.
+            ArrayType atype = (ArrayType)tree.vartype.type.unannotatedType();
+            tree.vartype.type = atype.makeVarargs();
+        }
+        Scope enclScope = enter.enterScope(env);
+        VarSymbol v =
+            new VarSymbol(0, tree.name, tree.vartype.type, enclScope.owner);
+        v.flags_field = chk.checkFlags(tree.pos(), tree.mods.flags, v, tree);
+        tree.sym = v;
+        if (tree.init != null) {
+            v.flags_field |= HASINIT;
+            if ((v.flags_field & FINAL) != 0 &&
+                needsLazyConstValue(tree.init)) {
+                Env<AttrContext> initEnv = getInitEnv(tree, env);
+                initEnv.info.enclVar = v;
+                v.setLazyConstValue(initEnv(tree, initEnv), attr, tree);
             }
-            if (chk.checkUnique(tree.pos(), v, enclScope)) {
-                chk.checkTransparentVar(tree.pos(), v, enclScope);
-                enclScope.enter(v);
-            }
-            annotateLater(tree.mods.annotations, localEnv, v, tree.pos());
-            typeAnnotate(tree.vartype, env, v, tree.pos());
-            v.pos = tree.pos;
-        } finally {
-            annotate.enterDone();
         }
+        if (chk.checkUnique(tree.pos(), v, enclScope)) {
+            chk.checkTransparentVar(tree.pos(), v, enclScope);
+            enclScope.enter(v);
+        }
+        annotateLater(tree.mods.annotations, localEnv, v, tree.pos());
+        typeAnnotate(tree.vartype, env, v, tree.pos());
+        v.pos = tree.pos;
     }
     // where
     void checkType(JCTree tree, Type type, String diag) {
@@ -1030,189 +1020,194 @@
         JCClassDecl tree = (JCClassDecl)env.tree;
         boolean wasFirst = isFirst;
         isFirst = false;
+        try {
+            annotate.enterStart();
 
-        JavaFileObject prev = log.useSource(env.toplevel.sourcefile);
-        DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos());
-        try {
-            // Save class environment for later member enter (2) processing.
-            halfcompleted.append(env);
+            JavaFileObject prev = log.useSource(env.toplevel.sourcefile);
+            DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos());
+            try {
+                // Save class environment for later member enter (2) processing.
+                halfcompleted.append(env);
+
+                // Mark class as not yet attributed.
+                c.flags_field |= UNATTRIBUTED;
 
-            // Mark class as not yet attributed.
-            c.flags_field |= UNATTRIBUTED;
+                // If this is a toplevel-class, make sure any preceding import
+                // clauses have been seen.
+                if (c.owner.kind == PCK) {
+                    memberEnter(env.toplevel, env.enclosing(TOPLEVEL));
+                    todo.append(env);
+                }
+
+                if (c.owner.kind == TYP)
+                    c.owner.complete();
+
+                // create an environment for evaluating the base clauses
+                Env<AttrContext> baseEnv = baseEnv(tree, env);
+
+                if (tree.extending != null)
+                    typeAnnotate(tree.extending, baseEnv, sym, tree.pos());
+                for (JCExpression impl : tree.implementing)
+                    typeAnnotate(impl, baseEnv, sym, tree.pos());
+                annotate.flush();
 
-            // If this is a toplevel-class, make sure any preceding import
-            // clauses have been seen.
-            if (c.owner.kind == PCK) {
-                memberEnter(env.toplevel, env.enclosing(TOPLEVEL));
-                todo.append(env);
-            }
+                // Determine supertype.
+                Type supertype =
+                    (tree.extending != null)
+                    ? attr.attribBase(tree.extending, baseEnv, true, false, true)
+                    : ((tree.mods.flags & Flags.ENUM) != 0)
+                    ? attr.attribBase(enumBase(tree.pos, c), baseEnv,
+                                      true, false, false)
+                    : (c.fullname == names.java_lang_Object)
+                    ? Type.noType
+                    : syms.objectType;
+                ct.supertype_field = modelMissingTypes(supertype, tree.extending, false);
 
-            if (c.owner.kind == TYP)
-                c.owner.complete();
-
-            // create an environment for evaluating the base clauses
-            Env<AttrContext> baseEnv = baseEnv(tree, env);
+                // Determine interfaces.
+                ListBuffer<Type> interfaces = new ListBuffer<Type>();
+                ListBuffer<Type> all_interfaces = null; // lazy init
+                Set<Type> interfaceSet = new HashSet<Type>();
+                List<JCExpression> interfaceTrees = tree.implementing;
+                for (JCExpression iface : interfaceTrees) {
+                    Type i = attr.attribBase(iface, baseEnv, false, true, true);
+                    if (i.hasTag(CLASS)) {
+                        interfaces.append(i);
+                        if (all_interfaces != null) all_interfaces.append(i);
+                        chk.checkNotRepeated(iface.pos(), types.erasure(i), interfaceSet);
+                    } else {
+                        if (all_interfaces == null)
+                            all_interfaces = new ListBuffer<Type>().appendList(interfaces);
+                        all_interfaces.append(modelMissingTypes(i, iface, true));
+                    }
+                }
+                if ((c.flags_field & ANNOTATION) != 0) {
+                    ct.interfaces_field = List.of(syms.annotationType);
+                    ct.all_interfaces_field = ct.interfaces_field;
+                }  else {
+                    ct.interfaces_field = interfaces.toList();
+                    ct.all_interfaces_field = (all_interfaces == null)
+                            ? ct.interfaces_field : all_interfaces.toList();
+                }
 
-            if (tree.extending != null)
-                typeAnnotate(tree.extending, baseEnv, sym, tree.pos());
-            for (JCExpression impl : tree.implementing)
-                typeAnnotate(impl, baseEnv, sym, tree.pos());
-            annotate.flush();
+                if (c.fullname == names.java_lang_Object) {
+                    if (tree.extending != null) {
+                        chk.checkNonCyclic(tree.extending.pos(),
+                                           supertype);
+                        ct.supertype_field = Type.noType;
+                    }
+                    else if (tree.implementing.nonEmpty()) {
+                        chk.checkNonCyclic(tree.implementing.head.pos(),
+                                           ct.interfaces_field.head);
+                        ct.interfaces_field = List.nil();
+                    }
+                }
 
-            // Determine supertype.
-            Type supertype =
-                (tree.extending != null)
-                ? attr.attribBase(tree.extending, baseEnv, true, false, true)
-                : ((tree.mods.flags & Flags.ENUM) != 0)
-                ? attr.attribBase(enumBase(tree.pos, c), baseEnv,
-                                  true, false, false)
-                : (c.fullname == names.java_lang_Object)
-                ? Type.noType
-                : syms.objectType;
-            ct.supertype_field = modelMissingTypes(supertype, tree.extending, false);
+                // Annotations.
+                // In general, we cannot fully process annotations yet,  but we
+                // can attribute the annotation types and then check to see if the
+                // @Deprecated annotation is present.
+                attr.attribAnnotationTypes(tree.mods.annotations, baseEnv);
+                if (hasDeprecatedAnnotation(tree.mods.annotations))
+                    c.flags_field |= DEPRECATED;
+                annotateLater(tree.mods.annotations, baseEnv, c, tree.pos());
+                // class type parameters use baseEnv but everything uses env
+
+                chk.checkNonCyclicDecl(tree);
+
+                attr.attribTypeVariables(tree.typarams, baseEnv);
+                // Do this here, where we have the symbol.
+                for (JCTypeParameter tp : tree.typarams)
+                    typeAnnotate(tp, baseEnv, sym, tree.pos());
 
-            // Determine interfaces.
-            ListBuffer<Type> interfaces = new ListBuffer<Type>();
-            ListBuffer<Type> all_interfaces = null; // lazy init
-            Set<Type> interfaceSet = new HashSet<Type>();
-            List<JCExpression> interfaceTrees = tree.implementing;
-            for (JCExpression iface : interfaceTrees) {
-                Type i = attr.attribBase(iface, baseEnv, false, true, true);
-                if (i.hasTag(CLASS)) {
-                    interfaces.append(i);
-                    if (all_interfaces != null) all_interfaces.append(i);
-                    chk.checkNotRepeated(iface.pos(), types.erasure(i), interfaceSet);
-                } else {
-                    if (all_interfaces == null)
-                        all_interfaces = new ListBuffer<Type>().appendList(interfaces);
-                    all_interfaces.append(modelMissingTypes(i, iface, true));
+                // Add default constructor if needed.
+                if ((c.flags() & INTERFACE) == 0 &&
+                    !TreeInfo.hasConstructors(tree.defs)) {
+                    List<Type> argtypes = List.nil();
+                    List<Type> typarams = List.nil();
+                    List<Type> thrown = List.nil();
+                    long ctorFlags = 0;
+                    boolean based = false;
+                    boolean addConstructor = true;
+                    JCNewClass nc = null;
+                    if (c.name.isEmpty()) {
+                        nc = (JCNewClass)env.next.tree;
+                        if (nc.constructor != null) {
+                            addConstructor = nc.constructor.kind != ERR;
+                            Type superConstrType = types.memberType(c.type,
+                                                                    nc.constructor);
+                            argtypes = superConstrType.getParameterTypes();
+                            typarams = superConstrType.getTypeArguments();
+                            ctorFlags = nc.constructor.flags() & VARARGS;
+                            if (nc.encl != null) {
+                                argtypes = argtypes.prepend(nc.encl.type);
+                                based = true;
+                            }
+                            thrown = superConstrType.getThrownTypes();
+                        }
+                    }
+                    if (addConstructor) {
+                        MethodSymbol basedConstructor = nc != null ?
+                                (MethodSymbol)nc.constructor : null;
+                        JCTree constrDef = DefaultConstructor(make.at(tree.pos), c,
+                                                            basedConstructor,
+                                                            typarams, argtypes, thrown,
+                                                            ctorFlags, based);
+                        tree.defs = tree.defs.prepend(constrDef);
+                    }
                 }
-            }
-            if ((c.flags_field & ANNOTATION) != 0) {
-                ct.interfaces_field = List.of(syms.annotationType);
-                ct.all_interfaces_field = ct.interfaces_field;
-            }  else {
-                ct.interfaces_field = interfaces.toList();
-                ct.all_interfaces_field = (all_interfaces == null)
-                        ? ct.interfaces_field : all_interfaces.toList();
-            }
+
+                // enter symbols for 'this' into current scope.
+                VarSymbol thisSym =
+                    new VarSymbol(FINAL | HASINIT, names._this, c.type, c);
+                thisSym.pos = Position.FIRSTPOS;
+                env.info.scope.enter(thisSym);
+                // if this is a class, enter symbol for 'super' into current scope.
+                if ((c.flags_field & INTERFACE) == 0 &&
+                        ct.supertype_field.hasTag(CLASS)) {
+                    VarSymbol superSym =
+                        new VarSymbol(FINAL | HASINIT, names._super,
+                                      ct.supertype_field, c);
+                    superSym.pos = Position.FIRSTPOS;
+                    env.info.scope.enter(superSym);
+                }
 
-            if (c.fullname == names.java_lang_Object) {
-                if (tree.extending != null) {
-                    chk.checkNonCyclic(tree.extending.pos(),
-                                       supertype);
-                    ct.supertype_field = Type.noType;
+                // check that no package exists with same fully qualified name,
+                // but admit classes in the unnamed package which have the same
+                // name as a top-level package.
+                if (checkClash &&
+                    c.owner.kind == PCK && c.owner != syms.unnamedPackage &&
+                    reader.packageExists(c.fullname)) {
+                    log.error(tree.pos, "clash.with.pkg.of.same.name", Kinds.kindName(sym), c);
                 }
-                else if (tree.implementing.nonEmpty()) {
-                    chk.checkNonCyclic(tree.implementing.head.pos(),
-                                       ct.interfaces_field.head);
-                    ct.interfaces_field = List.nil();
+                if (c.owner.kind == PCK && (c.flags_field & PUBLIC) == 0 &&
+                    !env.toplevel.sourcefile.isNameCompatible(c.name.toString(),JavaFileObject.Kind.SOURCE)) {
+                    c.flags_field |= AUXILIARY;
                 }
+            } catch (CompletionFailure ex) {
+                chk.completionError(tree.pos(), ex);
+            } finally {
+                deferredLintHandler.setPos(prevLintPos);
+                log.useSource(prev);
             }
 
-            // Annotations.
-            // In general, we cannot fully process annotations yet,  but we
-            // can attribute the annotation types and then check to see if the
-            // @Deprecated annotation is present.
-            attr.attribAnnotationTypes(tree.mods.annotations, baseEnv);
-            if (hasDeprecatedAnnotation(tree.mods.annotations))
-                c.flags_field |= DEPRECATED;
-            annotateLater(tree.mods.annotations, baseEnv, c, tree.pos());
-            // class type parameters use baseEnv but everything uses env
-
-            chk.checkNonCyclicDecl(tree);
-
-            attr.attribTypeVariables(tree.typarams, baseEnv);
-            // Do this here, where we have the symbol.
-            for (JCTypeParameter tp : tree.typarams)
-                typeAnnotate(tp, baseEnv, sym, tree.pos());
-
-            // Add default constructor if needed.
-            if ((c.flags() & INTERFACE) == 0 &&
-                !TreeInfo.hasConstructors(tree.defs)) {
-                List<Type> argtypes = List.nil();
-                List<Type> typarams = List.nil();
-                List<Type> thrown = List.nil();
-                long ctorFlags = 0;
-                boolean based = false;
-                boolean addConstructor = true;
-                JCNewClass nc = null;
-                if (c.name.isEmpty()) {
-                    nc = (JCNewClass)env.next.tree;
-                    if (nc.constructor != null) {
-                        addConstructor = nc.constructor.kind != ERR;
-                        Type superConstrType = types.memberType(c.type,
-                                                                nc.constructor);
-                        argtypes = superConstrType.getParameterTypes();
-                        typarams = superConstrType.getTypeArguments();
-                        ctorFlags = nc.constructor.flags() & VARARGS;
-                        if (nc.encl != null) {
-                            argtypes = argtypes.prepend(nc.encl.type);
-                            based = true;
+            // Enter all member fields and methods of a set of half completed
+            // classes in a second phase.
+            if (wasFirst) {
+                try {
+                    while (halfcompleted.nonEmpty()) {
+                        Env<AttrContext> toFinish = halfcompleted.next();
+                        finish(toFinish);
+                        if (allowTypeAnnos) {
+                            typeAnnotations.organizeTypeAnnotationsSignatures(toFinish, (JCClassDecl)toFinish.tree);
+                            typeAnnotations.validateTypeAnnotationsSignatures(toFinish, (JCClassDecl)toFinish.tree);
                         }
-                        thrown = superConstrType.getThrownTypes();
                     }
-                }
-                if (addConstructor) {
-                    MethodSymbol basedConstructor = nc != null ?
-                            (MethodSymbol)nc.constructor : null;
-                    JCTree constrDef = DefaultConstructor(make.at(tree.pos), c,
-                                                        basedConstructor,
-                                                        typarams, argtypes, thrown,
-                                                        ctorFlags, based);
-                    tree.defs = tree.defs.prepend(constrDef);
+                } finally {
+                    isFirst = true;
                 }
             }
-
-            // enter symbols for 'this' into current scope.
-            VarSymbol thisSym =
-                new VarSymbol(FINAL | HASINIT, names._this, c.type, c);
-            thisSym.pos = Position.FIRSTPOS;
-            env.info.scope.enter(thisSym);
-            // if this is a class, enter symbol for 'super' into current scope.
-            if ((c.flags_field & INTERFACE) == 0 &&
-                    ct.supertype_field.hasTag(CLASS)) {
-                VarSymbol superSym =
-                    new VarSymbol(FINAL | HASINIT, names._super,
-                                  ct.supertype_field, c);
-                superSym.pos = Position.FIRSTPOS;
-                env.info.scope.enter(superSym);
-            }
-
-            // check that no package exists with same fully qualified name,
-            // but admit classes in the unnamed package which have the same
-            // name as a top-level package.
-            if (checkClash &&
-                c.owner.kind == PCK && c.owner != syms.unnamedPackage &&
-                reader.packageExists(c.fullname)) {
-                log.error(tree.pos, "clash.with.pkg.of.same.name", Kinds.kindName(sym), c);
-            }
-            if (c.owner.kind == PCK && (c.flags_field & PUBLIC) == 0 &&
-                !env.toplevel.sourcefile.isNameCompatible(c.name.toString(),JavaFileObject.Kind.SOURCE)) {
-                c.flags_field |= AUXILIARY;
-            }
-        } catch (CompletionFailure ex) {
-            chk.completionError(tree.pos(), ex);
         } finally {
-            deferredLintHandler.setPos(prevLintPos);
-            log.useSource(prev);
-        }
-
-        // Enter all member fields and methods of a set of half completed
-        // classes in a second phase.
-        if (wasFirst) {
-            try {
-                while (halfcompleted.nonEmpty()) {
-                    Env<AttrContext> toFinish = halfcompleted.next();
-                    finish(toFinish);
-                    if (allowTypeAnnos) {
-                        typeAnnotations.organizeTypeAnnotationsSignatures(toFinish, (JCClassDecl)toFinish.tree);
-                        typeAnnotations.validateTypeAnnotationsSignatures(toFinish, (JCClassDecl)toFinish.tree);
-                    }
-                }
-            } finally {
-                isFirst = true;
-            }
+            annotate.enterDone();
         }
     }
 
--- a/src/share/classes/com/sun/tools/javac/jvm/Code.java	Wed Oct 29 10:50:43 2014 -0700
+++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java	Fri Oct 31 20:19:04 2014 -0700
@@ -2017,13 +2017,12 @@
         List<VarSymbol> locals = lvtRanges.getVars(meth, tree);
         for (LocalVar localVar: lvar) {
             for (VarSymbol aliveLocal : locals) {
-                if (localVar == null) {
-                    return;
-                }
-                if (localVar.sym == aliveLocal && localVar.lastRange() != null) {
-                    char length = (char)(closingCP - localVar.lastRange().start_pc);
-                    if (length < Character.MAX_VALUE) {
-                        localVar.closeRange(length);
+                if (localVar != null) {
+                    if (localVar.sym == aliveLocal && localVar.lastRange() != null) {
+                        char length = (char)(closingCP - localVar.lastRange().start_pc);
+                        if (length < Character.MAX_VALUE) {
+                            localVar.closeRange(length);
+                        }
                     }
                 }
             }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/annotations/FinalStringInNested.java	Fri Oct 31 20:19:04 2014 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8054448
+ * @summary Verify that constant strings in nested classes in anonymous classes
+ *          can be used in annotations.
+ * @compile FinalStringInNested.java
+ */
+
+public class FinalStringInNested {
+
+    public void f() {
+        Object o = new Object() {
+            @FinalStringInNested.Annotation(Nested.ID)
+            class Nested {
+                static final String ID = "B";
+            }
+        };
+    }
+
+    @interface Annotation {
+        String value();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/8058511/T8058511a.java	Fri Oct 31 20:19:04 2014 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8058511
+ * @summary StackOverflowError at com.sun.tools.javac.code.Types.lub
+ * @compile T8058511a.java
+ */
+class T8058511a {
+    <Z> void choose(Z z1, Z z2) { }
+
+    void test(Class<Double> cd, Class<? extends double[]> cdarr) {
+        choose(cd, cdarr);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/8058511/T8058511b.java	Fri Oct 31 20:19:04 2014 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8058511
+ * @summary StackOverflowError at com.sun.tools.javac.code.Types.lub
+ * @compile T8058511b.java
+ */
+class T8058511b {
+    void test(Class<Double> cd, Class<? extends double[]> cdarr) {
+        ((false) ? cd : cdarr).toString();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/javac/generics/inference/8058511/T8058511c.java	Fri Oct 31 20:19:04 2014 -0700
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 8058511
+ * @summary StackOverflowError at com.sun.tools.javac.code.Types.lub
+ * @compile T8058511c.java
+ */
+import java.util.List;
+
+class T8058511c {
+    void test(List<? extends double[]> l) {
+        (true ? l.get(0) : l.get(0)).toString();
+    }
+}