changeset 14052:8b839ae9074b

8000233: Fix issues in recent push Summary: Forgot to incorporate review comments in pushed changesets Reviewed-by: jjg
author mcimadamore
date Fri, 28 Sep 2012 16:56:53 +0100
parents 9097cec96212
children 99e71e40b111
files langtools/src/share/classes/com/sun/tools/javac/code/Type.java langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java langtools/src/share/classes/com/sun/tools/javac/jvm/Pool.java langtools/src/share/classes/com/sun/tools/javac/util/Names.java
diffstat 4 files changed, 34 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Type.java	Wed Sep 26 14:22:41 2012 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Type.java	Fri Sep 28 16:56:53 2012 +0100
@@ -27,18 +27,19 @@
 
 import java.util.Collections;
 
+import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.util.*;
-import com.sun.tools.javac.code.Symbol.*;
 
 import java.util.EnumMap;
 import java.util.EnumSet;
 import java.util.Map;
 import java.util.Set;
+
 import javax.lang.model.type.*;
 
+import static com.sun.tools.javac.code.BoundKind.*;
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Kinds.*;
-import static com.sun.tools.javac.code.BoundKind.*;
 import static com.sun.tools.javac.code.TypeTags.*;
 
 /** This class represents Java types. The class itself defines the behavior of
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Wed Sep 26 14:22:41 2012 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Fri Sep 28 16:56:53 2012 +0100
@@ -27,8 +27,8 @@
 
 import com.sun.tools.javac.api.Formattable.LocalizedString;
 import com.sun.tools.javac.code.*;
+import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.code.Type.*;
-import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.comp.Attr.ResultInfo;
 import com.sun.tools.javac.comp.Check.CheckContext;
 import com.sun.tools.javac.comp.Infer.InferenceContext;
@@ -48,6 +48,7 @@
 import java.util.EnumMap;
 import java.util.EnumSet;
 import java.util.HashSet;
+import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 
@@ -60,7 +61,6 @@
 import static com.sun.tools.javac.code.TypeTags.*;
 import static com.sun.tools.javac.comp.Resolve.MethodResolutionPhase.*;
 import static com.sun.tools.javac.tree.JCTree.Tag.*;
-import java.util.Iterator;
 
 /** Helper class for name resolution, used mostly by the attribution phase.
  *
@@ -1200,7 +1200,10 @@
         for (TypeSymbol s : superclasses(intype)) {
             bestSoFar = lookupMethod(env, site, name, argtypes, typeargtypes,
                     s.members(), bestSoFar, allowBoxing, useVarargs, operator, true);
-            abstractOk &= excludeAbstractsFilter.accepts(s);
+            //We should not look for abstract methods if receiver is a concrete class
+            //(as concrete classes are expected to implement all abstracts coming
+            //from superinterfaces)
+            abstractOk &= (s.flags() & (ABSTRACT | INTERFACE | ENUM)) != 0;
             if (abstractOk) {
                 for (Type itype : types.interfaces(s.type)) {
                     itypes = types.union(types.closure(itype), itypes);
@@ -1247,36 +1250,41 @@
                 return new Iterator<TypeSymbol>() {
 
                     List<TypeSymbol> seen = List.nil();
-                    TypeSymbol currentSym = getSymbol(intype);
+                    TypeSymbol currentSym = symbolFor(intype);
+                    TypeSymbol prevSym = null;
 
                     public boolean hasNext() {
+                        if (currentSym == syms.noSymbol) {
+                            currentSym = symbolFor(types.supertype(prevSym.type));
+                        }
                         return currentSym != null;
                     }
 
                     public TypeSymbol next() {
-                        TypeSymbol prevSym = currentSym;
-                        currentSym = getSymbol(types.supertype(currentSym.type));
+                        prevSym = currentSym;
+                        currentSym = syms.noSymbol;
+                        Assert.check(prevSym != null || prevSym != syms.noSymbol);
                         return prevSym;
                     }
 
                     public void remove() {
-                        throw new UnsupportedOperationException("Not supported yet.");
+                        throw new UnsupportedOperationException();
                     }
 
-                    TypeSymbol getSymbol(Type intype) {
-                        if (intype.tag != CLASS &&
-                                intype.tag != TYPEVAR) {
+                    TypeSymbol symbolFor(Type t) {
+                        if (t.tag != CLASS &&
+                                t.tag != TYPEVAR) {
                             return null;
                         }
-                        while (intype.tag == TYPEVAR)
-                            intype = intype.getUpperBound();
-                        if (seen.contains(intype.tsym)) {
+                        while (t.tag == TYPEVAR)
+                            t = t.getUpperBound();
+                        if (seen.contains(t.tsym)) {
                             //degenerate case in which we have a circular
                             //class hierarchy - because of ill-formed classfiles
                             return null;
                         }
-                        seen = seen.prepend(intype.tsym);
-                        return intype.tsym;
+                        seen = seen.prepend(t.tsym);
+                        return t.tsym;
                     }
                 };
             }
@@ -1284,17 +1292,6 @@
     }
 
     /**
-     * We should not look for abstract methods if receiver is a concrete class
-     * (as concrete classes are expected to implement all abstracts coming
-     * from superinterfaces)
-     */
-    Filter<Symbol> excludeAbstractsFilter = new Filter<Symbol>() {
-        public boolean accepts(Symbol s) {
-            return (s.flags() & (ABSTRACT | INTERFACE | ENUM)) != 0;
-        }
-    };
-
-    /**
      * Lookup a method with given name and argument types in a given scope
      */
     Symbol lookupMethod(Env<AttrContext> env,
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Pool.java	Wed Sep 26 14:22:41 2012 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Pool.java	Fri Sep 28 16:56:53 2012 +0100
@@ -27,17 +27,17 @@
 
 import com.sun.tools.javac.code.Flags;
 import com.sun.tools.javac.code.Kinds;
-import java.util.*;
-
 import com.sun.tools.javac.code.Symbol;
 import com.sun.tools.javac.code.Symbol.*;
 import com.sun.tools.javac.code.Type;
-import com.sun.tools.javac.util.ArrayUtils;
+
 import com.sun.tools.javac.util.Assert;
 import com.sun.tools.javac.util.Filter;
 import com.sun.tools.javac.util.Name;
 import com.sun.tools.javac.util.Names;
 
+import java.util.*;
+
 /** An internal structure that corresponds to the constant pool of a classfile.
  *
  *  <p><b>This is NOT part of any supported API.
@@ -177,13 +177,9 @@
         /** Reference symbol */
         Symbol refSym;
 
-        /** Reference to the name table */
-        Names names;
-
-        public MethodHandle(int refKind, Symbol refSym, Names names) {
+        public MethodHandle(int refKind, Symbol refSym) {
             this.refKind = refKind;
             this.refSym = refSym;
-            this.names = names;
             checkConsistent();
         }
         public boolean equals(Object other) {
@@ -244,13 +240,13 @@
         //where
                 Filter<Name> nonInitFilter = new Filter<Name>() {
                     public boolean accepts(Name n) {
-                        return n != names.init && n != names.clinit;
+                        return n != n.table.names.init && n != n.table.names.clinit;
                     }
                 };
 
                 Filter<Name> initFilter = new Filter<Name>() {
                     public boolean accepts(Name n) {
-                        return n == names.init;
+                        return n == n.table.names.init;
                     }
                 };
     }
--- a/langtools/src/share/classes/com/sun/tools/javac/util/Names.java	Wed Sep 26 14:22:41 2012 +0100
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/Names.java	Fri Sep 28 16:56:53 2012 +0100
@@ -118,6 +118,7 @@
     // attribute names
     public final Name Annotation;
     public final Name AnnotationDefault;
+    public final Name BootstrapMethods;
     public final Name Bridge;
     public final Name CharacterRangeTable;
     public final Name Code;
@@ -169,9 +170,6 @@
     public final Name ex;
     public final Name package_info;
 
-    // lambda-related
-    public final Name BootstrapMethods;
-
     public final Name.Table table;
 
     public Names(Context context) {
@@ -249,6 +247,7 @@
         // attribute names
         Annotation = fromString("Annotation");
         AnnotationDefault = fromString("AnnotationDefault");
+        BootstrapMethods = fromString("BootstrapMethods");
         Bridge = fromString("Bridge");
         CharacterRangeTable = fromString("CharacterRangeTable");
         Code = fromString("Code");
@@ -299,9 +298,6 @@
         deprecated = fromString("deprecated");
         ex = fromString("ex");
         package_info = fromString("package-info");
-
-        //lambda-related
-        BootstrapMethods = fromString("BootstrapMethods");
     }
 
     protected Name.Table createTable(Options options) {