# HG changeset patch # User lana # Date 1414097036 25200 # Node ID 53be48209e412fa2a90b75ad2bd93bd4d525089f # Parent 7994f62705874d5eda7ec174bb941fd4c69e34ae# Parent da96e0643b5ce15c4a442e864c64722db8642531 Merge diff -r 7994f6270587 -r 53be48209e41 langtools/make/build.properties --- a/langtools/make/build.properties Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/make/build.properties Thu Oct 23 13:43:56 2014 -0700 @@ -32,8 +32,8 @@ # boot.java.home = /opt/jdk/1.7.0 boot.java = ${boot.java.home}/bin/java boot.javac = ${boot.java.home}/bin/javac -boot.javac.source = 7 -boot.javac.target = 7 +boot.javac.source = 8 +boot.javac.target = 8 # This is the JDK used to run the product version of the tools, # for example, for testing. If you're building a complete JDK, specify that. diff -r 7994f6270587 -r 53be48209e41 langtools/make/tools/crules/MutableFieldsAnalyzer.java --- a/langtools/make/tools/crules/MutableFieldsAnalyzer.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/make/tools/crules/MutableFieldsAnalyzer.java Thu Oct 23 13:43:56 2014 -0700 @@ -30,7 +30,6 @@ import com.sun.source.util.JavacTask; import com.sun.source.util.TaskEvent.Kind; -import com.sun.tools.javac.code.Kinds; import com.sun.tools.javac.tree.JCTree.JCVariableDecl; import com.sun.tools.javac.tree.TreeScanner; @@ -38,6 +37,7 @@ import static com.sun.tools.javac.code.Flags.FINAL; import static com.sun.tools.javac.code.Flags.STATIC; import static com.sun.tools.javac.code.Flags.SYNTHETIC; +import static com.sun.tools.javac.code.Kinds.Kind.*; public class MutableFieldsAnalyzer extends AbstractCodingRulesAnalyzer { @@ -68,7 +68,7 @@ .contains(packageToCheck); if (isJavacPack && (tree.sym.flags() & SYNTHETIC) == 0 && - tree.sym.owner.kind == Kinds.TYP) { + tree.sym.owner.kind == TYP) { if (!ignoreField(tree.sym.owner.flatName().toString(), tree.getName().toString())) { boolean enumClass = (tree.sym.owner.flags() & ENUM) != 0; diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java Thu Oct 23 13:43:56 2014 -0700 @@ -56,7 +56,6 @@ import com.sun.source.util.JavacTask; import com.sun.source.util.TreePath; import com.sun.tools.javac.code.Flags; -import com.sun.tools.javac.code.Kinds; import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Symbol.ClassSymbol; import com.sun.tools.javac.code.Symbol.MethodSymbol; @@ -106,6 +105,7 @@ import com.sun.tools.javac.util.Names; import com.sun.tools.javac.util.Pair; import com.sun.tools.javac.util.Position; +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.code.TypeTag.*; /** @@ -474,7 +474,7 @@ searched.add(tsym); for (Symbol sym : tsym.members().getSymbolsByName(fieldName)) { - if (sym.kind == Kinds.VAR) { + if (sym.kind == VAR) { return (VarSymbol)sym; } } @@ -516,7 +516,7 @@ /** @see com.sun.tools.javadoc.ClassDocImpl#findConstructor */ MethodSymbol findConstructor(ClassSymbol tsym, List paramTypes) { for (Symbol sym : tsym.members().getSymbolsByName(names.init)) { - if (sym.kind == Kinds.MTH) { + if (sym.kind == MTH) { if (hasParameterTypes((MethodSymbol) sym, paramTypes)) { return (MethodSymbol) sym; } @@ -557,7 +557,7 @@ // attempt to emulate the old behavior. MethodSymbol lastFound = null; for (Symbol sym : tsym.members().getSymbolsByName(methodName)) { - if (sym.kind == Kinds.MTH) { + if (sym.kind == MTH) { if (sym.name == methodName) { lastFound = (MethodSymbol)sym; } @@ -569,7 +569,7 @@ } else { for (Symbol sym : tsym.members().getSymbolsByName(methodName)) { if (sym != null && - sym.kind == Kinds.MTH) { + sym.kind == MTH) { if (hasParameterTypes((MethodSymbol) sym, paramTypes)) { return (MethodSymbol) sym; } diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/ClassFinder.java Thu Oct 23 13:43:56 2014 -0700 @@ -43,7 +43,7 @@ import com.sun.tools.javac.util.*; import static com.sun.tools.javac.code.Flags.*; -import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.main.Option.*; diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Kinds.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Kinds.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Kinds.java Thu Oct 23 13:43:56 2014 -0700 @@ -26,11 +26,13 @@ package com.sun.tools.javac.code; import java.util.EnumSet; +import java.util.Set; import java.util.Locale; import com.sun.source.tree.MemberReferenceTree; import com.sun.tools.javac.api.Formattable; import com.sun.tools.javac.api.Messages; + import static com.sun.tools.javac.code.Flags.*; import static com.sun.tools.javac.code.TypeTag.CLASS; import static com.sun.tools.javac.code.TypeTag.PACKAGE; @@ -49,55 +51,166 @@ private Kinds() {} // uninstantiable - /** The empty set of kinds. - */ - public final static int NIL = 0; - - /** The kind of package symbols. + /** + * Kind of symbols. + * + * IMPORTANT: This is an ordered type. The ordering of + * declarations in this enum matters. Be careful when changing + * it. */ - public final static int PCK = 1 << 0; + public enum Kind { + NIL(Category.BASIC, KindSelector.NIL), + PCK(Category.BASIC, KindName.PACKAGE, KindSelector.PCK), + TYP(Category.BASIC, KindName.CLASS, KindSelector.TYP), + VAR(Category.BASIC, KindName.VAR, KindSelector.VAR), + MTH(Category.BASIC, KindName.METHOD, KindSelector.MTH), + POLY(Category.BASIC, KindSelector.POLY), + ERR(Category.ERROR, KindSelector.ERR), + AMBIGUOUS(Category.OVERLOAD), + HIDDEN(Category.OVERLOAD), + STATICERR(Category.OVERLOAD), + MISSING_ENCL(Category.OVERLOAD), + ABSENT_VAR(Category.OVERLOAD, KindName.VAR), + WRONG_MTHS(Category.OVERLOAD, KindName.METHOD), + WRONG_MTH(Category.OVERLOAD, KindName.METHOD), + ABSENT_MTH(Category.OVERLOAD, KindName.METHOD), + ABSENT_TYP(Category.OVERLOAD, KindName.CLASS), + WRONG_STATICNESS(Category.OVERLOAD, KindName.METHOD); - /** The kind of type symbols (classes, interfaces and type variables). - */ - public final static int TYP = 1 << 1; + // There are essentially two "levels" to the Kind datatype. + // The first is a totally-ordered set of categories of + // solutions. Within each category, we have more + // possibilities. + private enum Category { + BASIC, ERROR, OVERLOAD; + } - /** The kind of variable symbols. - */ - public final static int VAR = 1 << 2; + private final KindName kindName; + private final KindName absentKind; + private final KindSelector selector; + private final Category category; + + private Kind(Category category) { + this(category, null, null, null); + } + + private Kind(Category category, + KindSelector selector) { + this(category, null, null, selector); + } + + private Kind(Category category, + KindName absentKind) { + this(category, null, absentKind, null); + } - /** The kind of values (variables or non-variable expressions), includes VAR. - */ - public final static int VAL = (1 << 3) | VAR; + private Kind(Category category, + KindName kindName, + KindSelector selector) { + this(category, kindName, null, selector); + } - /** The kind of methods. - */ - public final static int MTH = 1 << 4; + private Kind(Category category, + KindName kindName, + KindName absentKind, + KindSelector selector) { + this.category = category; + this.kindName = kindName; + this.absentKind = absentKind; + this.selector = selector; + } + + public KindSelector toSelector() { + return selector; + } + + public boolean matches(KindSelector kindSelectors) { + return selector.contains(kindSelectors); + } - /** Poly kind, for deferred types. - */ - public final static int POLY = 1 << 5; + public boolean isOverloadError() { + return category == Category.OVERLOAD; + } + + public boolean isValid() { + return category == Category.BASIC; + } + + public boolean betterThan(Kind other) { + return ordinal() < other.ordinal(); + } + + public KindName kindName() { + if (kindName == null) { + throw new AssertionError("Unexpected kind: " + this); + } else { + return kindName; + } + } - /** The error kind, which includes all other kinds. - */ - public final static int ERR = (1 << 6) - 1; + public KindName absentKind() { + if (absentKind == null) { + throw new AssertionError("Unexpected kind: " + this); + } else { + return absentKind; + } + } + } - /** The set of all kinds. - */ - public final static int AllKinds = ERR; + public static class KindSelector { + + //basic selectors + public static final KindSelector NIL = new KindSelector(0); + public static final KindSelector PCK = new KindSelector(0x01); + public static final KindSelector TYP = new KindSelector(0x02); + public static final KindSelector VAR = new KindSelector(0x04); + public static final KindSelector VAL = new KindSelector(0x0c); + public static final KindSelector MTH = new KindSelector(0x10); + public static final KindSelector ERR = new KindSelector(0x3f); + public static final KindSelector POLY = new KindSelector(0x20); - /** Kinds for erroneous symbols that complement the above - */ - public static final int ERRONEOUS = 1 << 7; - public static final int AMBIGUOUS = ERRONEOUS + 1; // ambiguous reference - public static final int HIDDEN = ERRONEOUS + 2; // hidden method or field - public static final int STATICERR = ERRONEOUS + 3; // nonstatic member from static context - public static final int MISSING_ENCL = ERRONEOUS + 4; // missing enclosing class - public static final int ABSENT_VAR = ERRONEOUS + 5; // missing variable - public static final int WRONG_MTHS = ERRONEOUS + 6; // methods with wrong arguments - public static final int WRONG_MTH = ERRONEOUS + 7; // one method with wrong arguments - public static final int ABSENT_MTH = ERRONEOUS + 8; // missing method - public static final int ABSENT_TYP = ERRONEOUS + 9; // missing type - public static final int WRONG_STATICNESS = ERRONEOUS + 10; // wrong staticness for method references + //common derived selectors + public static final KindSelector TYP_PCK = of(TYP, PCK); + public static final KindSelector VAL_MTH = of(VAL, MTH); + public static final KindSelector VAL_POLY = of(VAL, POLY); + public static final KindSelector VAL_TYP = of(VAL, TYP); + public static final KindSelector VAL_TYP_PCK = of(VAL, TYP, PCK); + + private final byte data; + + private KindSelector(int data) { + this.data = (byte) data; + } + + public static KindSelector of(KindSelector... kindSelectors) { + byte newData = 0; + for (KindSelector kindSel : kindSelectors) { + newData |= kindSel.data; + } + return new KindSelector(newData); + } + + public boolean subset(KindSelector other) { + return (data & ~other.data) == 0; + } + + public boolean contains(KindSelector other) { + return (data & other.data) != 0; + } + + /** A set of KindName(s) representing a set of symbol's kinds. */ + public Set kindNames() { + EnumSet kinds = EnumSet.noneOf(KindName.class); + if ((data & VAL.data) != 0) { + if ((data & VAL.data) == VAR.data) kinds.add(KindName.VAR); + else kinds.add(KindName.VAL); + } + if ((data & MTH.data) != 0) kinds.add(KindName.METHOD); + if ((data & TYP.data) != 0) kinds.add(KindName.CLASS); + if ((data & PCK.data) != 0) kinds.add(KindName.PACKAGE); + return kinds; + } + } public enum KindName implements Formattable { ANNOTATION("kindname.annotation"), @@ -135,19 +248,6 @@ } } - /** A KindName representing a given symbol kind - */ - public static KindName kindName(int kind) { - switch (kind) { - case PCK: return KindName.PACKAGE; - case TYP: return KindName.CLASS; - case VAR: return KindName.VAR; - case VAL: return KindName.VAL; - case MTH: return KindName.METHOD; - default : throw new AssertionError("Unexpected kind: "+kind); - } - } - public static KindName kindName(MemberReferenceTree.ReferenceMode mode) { switch (mode) { case INVOKE: return KindName.METHOD; @@ -195,27 +295,10 @@ return KindName.INSTANCE_INIT; default: - if (sym.kind == VAL) - // I don't think this can happen but it can't harm - // playing it safe --ahe - return KindName.VAL; - else throw new AssertionError("Unexpected kind: "+sym.getKind()); } } - /** A set of KindName(s) representing a set of symbol's kinds. - */ - public static EnumSet kindNames(int kind) { - EnumSet kinds = EnumSet.noneOf(KindName.class); - if ((kind & VAL) != 0) - kinds.add(((kind & VAL) == VAR) ? KindName.VAR : KindName.VAL); - if ((kind & MTH) != 0) kinds.add(KindName.METHOD); - if ((kind & TYP) != 0) kinds.add(KindName.CLASS); - if ((kind & PCK) != 0) kinds.add(KindName.PACKAGE); - return kinds; - } - /** A KindName representing the kind of a given class/interface type. */ public static KindName typeKindName(Type t) { @@ -232,19 +315,4 @@ return KindName.CLASS; } - /** A KindName representing the kind of a missing symbol, given an - * error kind. - * */ - public static KindName absentKind(int kind) { - switch (kind) { - case ABSENT_VAR: - return KindName.VAR; - case WRONG_MTHS: case WRONG_MTH: case ABSENT_MTH: case WRONG_STATICNESS: - return KindName.METHOD; - case ABSENT_TYP: - return KindName.CLASS; - default: - throw new AssertionError("Unexpected kind: "+kind); - } - } } diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Printer.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Printer.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Printer.java Thu Oct 23 13:43:56 2014 -0700 @@ -36,6 +36,7 @@ import static com.sun.tools.javac.code.BoundKind.*; import static com.sun.tools.javac.code.Flags.*; +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.code.TypeTag.CLASS; import static com.sun.tools.javac.code.TypeTag.FORALL; @@ -224,7 +225,7 @@ @Override public String visitClassType(ClassType t, Locale locale) { StringBuilder buf = new StringBuilder(); - if (t.getEnclosingType().hasTag(CLASS) && t.tsym.owner.kind == Kinds.TYP) { + if (t.getEnclosingType().hasTag(CLASS) && t.tsym.owner.kind == TYP) { buf.append(visit(t.getEnclosingType(), locale)); buf.append('.'); buf.append(printAnnotations(t)); diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java Thu Oct 23 13:43:56 2014 -0700 @@ -45,6 +45,7 @@ import com.sun.tools.javac.util.Name; import static com.sun.tools.javac.code.Flags.*; import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; import static com.sun.tools.javac.code.TypeTag.CLASS; import static com.sun.tools.javac.code.TypeTag.FORALL; @@ -65,7 +66,7 @@ /** The kind of this symbol. * @see Kinds */ - public int kind; + public Kind kind; /** The flags of this symbol. */ @@ -232,7 +233,7 @@ /** Construct a symbol with given kind, flags, name, type and owner. */ - public Symbol(int kind, long flags, Name name, Type type, Symbol owner) { + public Symbol(Kind kind, long flags, Name name, Type type, Symbol owner) { this.kind = kind; this.flags_field = flags; this.type = type; @@ -268,7 +269,9 @@ */ public Symbol location() { if (owner.name == null || (owner.name.isEmpty() && - (owner.flags() & BLOCK) == 0 && owner.kind != PCK && owner.kind != TYP)) { + (owner.flags() & BLOCK) == 0 && + owner.kind != PCK && + owner.kind != TYP)) { return null; } return owner; @@ -344,8 +347,8 @@ */ public boolean isLocal() { return - (owner.kind & (VAR | MTH)) != 0 || - (owner.kind == TYP && owner.isLocal()); + (owner.kind.matches(KindSelector.VAL_MTH) || + (owner.kind == TYP && owner.isLocal())); } /** Has this symbol an empty name? This includes anonymous @@ -407,7 +410,7 @@ public ClassSymbol enclClass() { Symbol c = this; while (c != null && - ((c.kind & TYP) == 0 || !c.type.hasTag(CLASS))) { + (!c.kind.matches(KindSelector.TYP) || !c.type.hasTag(CLASS))) { c = c.owner; } return (ClassSymbol)c; @@ -669,16 +672,16 @@ /** A base class for Symbols representing types. */ public static abstract class TypeSymbol extends Symbol { - public TypeSymbol(int kind, long flags, Name name, Type type, Symbol owner) { + public TypeSymbol(Kind kind, long flags, Name name, Type type, Symbol owner) { super(kind, flags, name, type, owner); } /** form a fully qualified name from a name and an owner */ static public Name formFullName(Name name, Symbol owner) { if (owner == null) return name; - if (((owner.kind != ERR)) && - ((owner.kind & (VAR | MTH)) != 0 - || (owner.kind == TYP && owner.type.hasTag(TYPEVAR)) + if ((owner.kind != ERR) && + (owner.kind.matches(KindSelector.VAL_MTH) || + (owner.kind == TYP && owner.type.hasTag(TYPEVAR)) )) return name; Name prefix = owner.getQualifiedName(); if (prefix == null || prefix == prefix.table.names.empty) @@ -690,9 +693,8 @@ * converting to flat representation */ static public Name formFlatName(Name name, Symbol owner) { - if (owner == null || - (owner.kind & (VAR | MTH)) != 0 - || (owner.kind == TYP && owner.type.hasTag(TYPEVAR)) + if (owner == null || owner.kind.matches(KindSelector.VAL_MTH) || + (owner.kind == TYP && owner.type.hasTag(TYPEVAR)) ) return name; char sep = owner.kind == TYP ? '$' : '.'; Name prefix = owner.flatName(); @@ -1558,7 +1560,7 @@ // where public static final Filter implementation_filter = new Filter() { public boolean accepts(Symbol s) { - return s.kind == Kinds.MTH && + return s.kind == MTH && (s.flags() & SYNTHETIC) == 0; } }; diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java Thu Oct 23 13:43:56 2014 -0700 @@ -64,8 +64,7 @@ import com.sun.tools.javac.util.Names; import static com.sun.tools.javac.code.Flags.*; -import static com.sun.tools.javac.code.Kinds.PCK; -import static com.sun.tools.javac.code.Kinds.TYP; +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.jvm.ByteCodes.*; import static com.sun.tools.javac.code.TypeTag.*; @@ -426,7 +425,7 @@ return messages.getLocalizedString("compiler.misc.unnamed.package"); } }; - noSymbol = new TypeSymbol(Kinds.NIL, 0, names.empty, Type.noType, rootPackage) { + noSymbol = new TypeSymbol(NIL, 0, names.empty, Type.noType, rootPackage) { @DefinedBy(Api.LANGUAGE_MODEL) public R accept(ElementVisitor v, P p) { return v.visitUnknown(this, p); diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java Thu Oct 23 13:43:56 2014 -0700 @@ -39,7 +39,7 @@ import com.sun.tools.javac.util.DefinedBy.Api; 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.Kinds.Kind.*; import static com.sun.tools.javac.code.TypeTag.*; /** This class represents Java types. The class itself defines the behavior of diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Thu Oct 23 13:43:56 2014 -0700 @@ -73,6 +73,8 @@ import com.sun.tools.javac.util.Names; import com.sun.tools.javac.util.Options; +import static com.sun.tools.javac.code.Kinds.Kind.*; + /** * Contains operations specific to processing type annotations. * This class has two functions: @@ -182,43 +184,43 @@ } Attribute.Enum e = (Attribute.Enum) app; if (e.value.name == names.TYPE) { - if (s.kind == Kinds.TYP) + if (s.kind == TYP) isDecl = true; } else if (e.value.name == names.FIELD) { - if (s.kind == Kinds.VAR && - s.owner.kind != Kinds.MTH) + if (s.kind == VAR && + s.owner.kind != MTH) isDecl = true; } else if (e.value.name == names.METHOD) { - if (s.kind == Kinds.MTH && + if (s.kind == MTH && !s.isConstructor()) isDecl = true; } else if (e.value.name == names.PARAMETER) { - if (s.kind == Kinds.VAR && - s.owner.kind == Kinds.MTH && + if (s.kind == VAR && + s.owner.kind == MTH && (s.flags() & Flags.PARAMETER) != 0) isDecl = true; } else if (e.value.name == names.CONSTRUCTOR) { - if (s.kind == Kinds.MTH && + if (s.kind == MTH && s.isConstructor()) isDecl = true; } else if (e.value.name == names.LOCAL_VARIABLE) { - if (s.kind == Kinds.VAR && - s.owner.kind == Kinds.MTH && + if (s.kind == VAR && + s.owner.kind == MTH && (s.flags() & Flags.PARAMETER) == 0) isDecl = true; } else if (e.value.name == names.ANNOTATION_TYPE) { - if (s.kind == Kinds.TYP && + if (s.kind == TYP && (s.flags() & Flags.ANNOTATION) != 0) isDecl = true; } else if (e.value.name == names.PACKAGE) { - if (s.kind == Kinds.PCK) + if (s.kind == PCK) isDecl = true; } else if (e.value.name == names.TYPE_USE) { - if (s.kind == Kinds.TYP || - s.kind == Kinds.VAR || - (s.kind == Kinds.MTH && !s.isConstructor() && + if (s.kind == TYP || + s.kind == VAR || + (s.kind == MTH && !s.isConstructor() && !s.type.getReturnType().hasTag(TypeTag.VOID)) || - (s.kind == Kinds.MTH && s.isConstructor())) + (s.kind == MTH && s.isConstructor())) isType = true; } else if (e.value.name == names.TYPE_PARAMETER) { /* Irrelevant in this case */ diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java Thu Oct 23 13:43:56 2014 -0700 @@ -46,6 +46,7 @@ import static com.sun.tools.javac.code.BoundKind.*; import static com.sun.tools.javac.code.Flags.*; +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.code.Scope.*; import static com.sun.tools.javac.code.Symbol.*; import static com.sun.tools.javac.code.Type.*; @@ -667,7 +668,7 @@ //where private Filter bridgeFilter = new Filter() { public boolean accepts(Symbol t) { - return t.kind == Kinds.MTH && + return t.kind == MTH && t.name != names.init && t.name != names.clinit && (t.flags() & SYNTHETIC) == 0; @@ -708,7 +709,7 @@ @Override public boolean accepts(Symbol sym) { - return sym.kind == Kinds.MTH && + return sym.kind == MTH && (sym.flags() & (ABSTRACT | DEFAULT)) == ABSTRACT && !overridesObjectMethod(origin, sym) && (interfaceCandidates(origin.type, (MethodSymbol)sym).head.flags() & DEFAULT) == 0; @@ -793,7 +794,6 @@ public boolean isSubtype(Type t, Type s, boolean capture) { if (t == s) return true; - if (s.isPartial()) return isSuperType(s, t); @@ -2809,7 +2809,7 @@ } public boolean accepts(Symbol s) { - return s.kind == Kinds.MTH && + return s.kind == MTH && s.name == msym.name && (s.flags() & SYNTHETIC) == 0 && s.isInheritedIn(site.tsym, Types.this) && @@ -3634,7 +3634,8 @@ for (Type erasedSupertype : mec) { List 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))); + Type superType = asSuper(ts[i], erasedSupertype.tsym); + lci = intersect(lci, superType != null ? List.of(superType) : List.nil()); } candidates = candidates.appendList(lci); } @@ -4714,7 +4715,7 @@ Type outer = ct.getEnclosingType(); if (outer.allparams().nonEmpty()) { boolean rawOuter = - c.owner.kind == Kinds.MTH || // either a local class + c.owner.kind == MTH || // either a local class c.name == types.names.empty; // or anonymous assembleClassSig(rawOuter ? types.erasure(outer) diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Annotate.java Thu Oct 23 13:43:56 2014 -0700 @@ -39,7 +39,7 @@ import com.sun.tools.javac.tree.*; import com.sun.tools.javac.tree.JCTree.*; -import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.code.TypeTag.ARRAY; import static com.sun.tools.javac.code.TypeTag.CLASS; import static com.sun.tools.javac.tree.JCTree.Tag.*; @@ -458,7 +458,7 @@ Symbol sym = TreeInfo.symbol(tree); if (sym == null || TreeInfo.nonstaticSelect(tree) || - sym.kind != Kinds.VAR || + sym.kind != VAR || (sym.flags() & Flags.ENUM) == 0) { log.error(tree.pos(), "enum.annotation.must.be.enum.constant"); return new Attribute.Error(result.getOriginalType()); @@ -657,7 +657,7 @@ nr_value_elems++; if (nr_value_elems == 1 && - elm.kind == Kinds.MTH) { + elm.kind == MTH) { containerValueSymbol = (MethodSymbol)elm; } else { error = true; @@ -678,7 +678,7 @@ // validate that the 'value' element is a method // probably "impossible" to fail this - if (containerValueSymbol.kind != Kinds.MTH) { + if (containerValueSymbol.kind != MTH) { log.error(pos, "invalid.repeatable.annotation.invalid.value", targetContainerType); @@ -909,7 +909,7 @@ annotations.nonEmpty()) log.error(annotations.head.pos, "already.annotated", - kindName(s), s); + Kinds.kindName(s), s); actualEnterAnnotations(annotations, localEnv, s); } finally { if (prevLint != null) @@ -1066,7 +1066,7 @@ DiagnosticPosition prevPos = deferPos; deferPos = tree.pos(); try { - if (sym != null && sym.kind == Kinds.VAR) { + if (sym != null && sym.kind == VAR) { // Don't visit a parameter once when the sym is the method // and once when the sym is the parameter. scan(tree.mods); diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java Thu Oct 23 13:43:56 2014 -0700 @@ -57,7 +57,7 @@ import static com.sun.tools.javac.code.Flags.ANNOTATION; import static com.sun.tools.javac.code.Flags.BLOCK; import static com.sun.tools.javac.code.Kinds.*; -import static com.sun.tools.javac.code.Kinds.ERRONEOUS; +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.code.TypeTag.*; import static com.sun.tools.javac.code.TypeTag.WILDCARD; import static com.sun.tools.javac.tree.JCTree.Tag.*; @@ -147,12 +147,12 @@ useBeforeDeclarationWarning = options.isSet("useBeforeDeclarationWarning"); identifyLambdaCandidate = options.getBoolean("identifyLambdaCandidate", false); - statInfo = new ResultInfo(NIL, Type.noType); - varInfo = new ResultInfo(VAR, Type.noType); - unknownExprInfo = new ResultInfo(VAL, Type.noType); - unknownAnyPolyInfo = new ResultInfo(VAL, Infer.anyPoly); - unknownTypeInfo = new ResultInfo(TYP, Type.noType); - unknownTypeExprInfo = new ResultInfo(Kinds.TYP | Kinds.VAL, Type.noType); + statInfo = new ResultInfo(KindSelector.NIL, Type.noType); + varInfo = new ResultInfo(KindSelector.VAR, Type.noType); + unknownExprInfo = new ResultInfo(KindSelector.VAL, Type.noType); + unknownAnyPolyInfo = new ResultInfo(KindSelector.VAL, Infer.anyPoly); + unknownTypeInfo = new ResultInfo(KindSelector.TYP, Type.noType); + unknownTypeExprInfo = new ResultInfo(KindSelector.VAL_TYP, Type.noType); recoveryInfo = new RecoveryInfo(deferredAttr.emptyDeferredAttrContext); } @@ -223,14 +223,17 @@ * @param ownkind The computed kind of the tree * @param resultInfo The expected result of the tree */ - Type check(final JCTree tree, final Type found, final int ownkind, final ResultInfo resultInfo) { + Type check(final JCTree tree, + final Type found, + final KindSelector ownkind, + final ResultInfo resultInfo) { InferenceContext inferenceContext = resultInfo.checkContext.inferenceContext(); Type owntype; if (!found.hasTag(ERROR) && !resultInfo.pt.hasTag(METHOD) && !resultInfo.pt.hasTag(FORALL)) { - if ((ownkind & ~resultInfo.pkind) != 0) { + if (!ownkind.subset(resultInfo.pkind)) { log.error(tree.pos(), "unexpected.type", - kindNames(resultInfo.pkind), - kindName(ownkind)); + resultInfo.pkind.kindNames(), + ownkind.kindNames()); owntype = types.createErrorType(found); } else if (allowPoly && inferenceContext.free(found)) { //delay the check if there are inference variables in the found type @@ -348,7 +351,8 @@ Name name = (Name)node.getIdentifier(); if (site.kind == PCK) { env.toplevel.packge = (PackageSymbol)site; - return rs.findIdentInPackage(env, (TypeSymbol)site, name, TYP | PCK); + return rs.findIdentInPackage(env, (TypeSymbol)site, name, + KindSelector.TYP_PCK); } else { env.enclClass.sym = (ClassSymbol)site; return rs.findMemberType(env, site.asType(), name, (TypeSymbol)site); @@ -357,7 +361,7 @@ @Override @DefinedBy(Api.COMPILER_TREE) public Symbol visitIdentifier(IdentifierTree node, Env env) { - return rs.findIdent(env, (Name)node.getName(), TYP | PCK); + return rs.findIdent(env, (Name)node.getName(), KindSelector.TYP_PCK); } } @@ -374,9 +378,9 @@ public Type attribImportQualifier(JCImport tree, Env env) { // Attribute qualifying package or class. JCFieldAccess s = (JCFieldAccess)tree.qualid; - return attribTree(s.selected, - env, - new ResultInfo(tree.staticImport ? TYP : (TYP | PCK), + return attribTree(s.selected, env, + new ResultInfo(tree.staticImport ? + KindSelector.TYP : KindSelector.TYP_PCK, Type.noType)); } @@ -431,15 +435,16 @@ } class ResultInfo { - final int pkind; + final KindSelector pkind; final Type pt; final CheckContext checkContext; - ResultInfo(int pkind, Type pt) { + ResultInfo(KindSelector pkind, Type pt) { this(pkind, pt, chk.basicHandler); } - protected ResultInfo(int pkind, Type pt, CheckContext checkContext) { + protected ResultInfo(KindSelector pkind, + Type pt, CheckContext checkContext) { this.pkind = pkind; this.pt = pt; this.checkContext = checkContext; @@ -474,7 +479,8 @@ class RecoveryInfo extends ResultInfo { public RecoveryInfo(final DeferredAttr.DeferredAttrContext deferredAttrContext) { - super(Kinds.VAL, Type.recoveryType, new Check.NestedCheckContext(chk.basicHandler) { + super(KindSelector.VAL, Type.recoveryType, + new Check.NestedCheckContext(chk.basicHandler) { @Override public DeferredAttr.DeferredAttrContext deferredAttrContext() { return deferredAttrContext; @@ -503,7 +509,7 @@ return resultInfo.pt; } - int pkind() { + KindSelector pkind() { return resultInfo.pkind; } @@ -575,7 +581,7 @@ /** Derived visitor method: attribute an expression tree. */ public Type attribExpr(JCTree tree, Env env, Type pt) { - return attribTree(tree, env, new ResultInfo(VAL, !pt.hasTag(ERROR) ? pt : Type.noType)); + return attribTree(tree, env, new ResultInfo(KindSelector.VAL, !pt.hasTag(ERROR) ? pt : Type.noType)); } /** Derived visitor method: attribute an expression tree with @@ -595,7 +601,7 @@ /** Derived visitor method: attribute a type tree. */ Type attribType(JCTree tree, Env env, Type pt) { - Type result = attribTree(tree, env, new ResultInfo(TYP, pt)); + Type result = attribTree(tree, env, new ResultInfo(KindSelector.TYP, pt)); return result; } @@ -623,19 +629,19 @@ /** Attribute the arguments in a method call, returning the method kind. */ - int attribArgs(List trees, Env env, ListBuffer argtypes) { - int kind = VAL; + KindSelector attribArgs(List trees, Env env, ListBuffer argtypes) { + boolean polykind = false; for (JCExpression arg : trees) { Type argtype; if (allowPoly && deferredAttr.isDeferred(env, arg)) { argtype = deferredAttr.new DeferredType(arg, env); - kind |= POLY; + polykind = true; } else { argtype = chk.checkNonVoid(arg, attribTree(arg, env, unknownAnyPolyInfo)); } argtypes.append(argtype); } - return kind; + return polykind ? KindSelector.VAL_POLY : KindSelector.VAL; } /** Attribute a type argument list, returning a list of types. @@ -792,7 +798,7 @@ public void visitClassDef(JCClassDecl tree) { // 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) { + if (env.info.scope.owner.kind.matches(KindSelector.VAL_MTH)) { enter.classEnter(tree, env); } else { // If this class declaration is part of a class level annotation, @@ -1282,7 +1288,10 @@ chk.basicHandler.report(pos, diags.fragment("try.not.applicable.to.type", details)); } }; - ResultInfo twrResult = new ResultInfo(VAL, syms.autoCloseableType, twrContext); + ResultInfo twrResult = + new ResultInfo(KindSelector.VAL, + syms.autoCloseableType, + twrContext); if (resource.hasTag(VARDEF)) { attribStat(resource, tryEnv); twrResult.check(resource, resource.type); @@ -1314,7 +1323,7 @@ //multi-catch parameter is implicitly marked as final c.param.sym.flags_field |= FINAL | UNION; } - if (c.param.sym.kind == Kinds.VAR) { + if (c.param.sym.kind == VAR) { c.param.sym.setData(ElementKind.EXCEPTION_PARAMETER); } chk.checkType(c.param.vartype.pos(), @@ -1399,7 +1408,7 @@ //constant folding owntype = cfolder.coerce(condtype.isTrue() ? truetype : falsetype, owntype); } - result = check(tree, owntype, VAL, resultInfo); + result = check(tree, owntype, KindSelector.VAL, resultInfo); } //where private boolean isBooleanOrNumeric(Env env, JCExpression tree) { @@ -1749,7 +1758,8 @@ // ...and check that it is legal in the current context. // (this will also set the tree's type) Type mpt = newMethodTemplate(resultInfo.pt, argtypes, typeargtypes); - checkId(tree.meth, site, sym, localEnv, new ResultInfo(MTH, mpt)); + checkId(tree.meth, site, sym, localEnv, + new ResultInfo(KindSelector.MTH, mpt)); } // Otherwise, `site' is an error type and we do nothing } @@ -1757,7 +1767,7 @@ } else { // Otherwise, we are seeing a regular method call. // Attribute the arguments, yielding list of argument types, ... - int kind = attribArgs(tree.args, localEnv, argtypesBuf); + KindSelector kind = attribArgs(tree.args, localEnv, argtypesBuf); argtypes = argtypesBuf.toList(); typeargtypes = attribAnyTypes(tree.typeargs, localEnv); @@ -1782,7 +1792,7 @@ // Check that value of resulting type is admissible in the // current context. Also, capture the return type - result = check(tree, capture(restype), VAL, resultInfo); + result = check(tree, capture(restype), KindSelector.VAL, resultInfo); } chk.validate(tree.typeargs, localEnv); } @@ -1936,7 +1946,8 @@ // Attribute constructor arguments. ListBuffer argtypesBuf = new ListBuffer<>(); - int pkind = attribArgs(tree.args, localEnv, argtypesBuf); + final KindSelector pkind = + attribArgs(tree.args, localEnv, argtypesBuf); List argtypes = argtypesBuf.toList(); List typeargtypes = attribTypes(tree.typeargs, localEnv); @@ -2096,7 +2107,7 @@ clazztype = cdef.sym.type; Symbol sym = tree.constructor = rs.resolveConstructor( tree.pos(), localEnv, clazztype, argtypes, typeargtypes); - Assert.check(sym.kind < AMBIGUOUS); + Assert.check(!sym.kind.isOverloadError()); tree.constructor = sym; tree.constructorType = checkId(tree, clazztype, @@ -2108,7 +2119,7 @@ if (tree.constructor != null && tree.constructor.kind == MTH) owntype = clazztype; } - result = check(tree, owntype, VAL, resultInfo); + result = check(tree, owntype, KindSelector.VAL, resultInfo); chk.validate(tree.typeargs, localEnv); } //where @@ -2118,7 +2129,7 @@ try { //create a 'fake' diamond AST node by removing type-argument trees ta.arguments = List.nil(); - ResultInfo findDiamondResult = new ResultInfo(VAL, + ResultInfo findDiamondResult = new ResultInfo(KindSelector.VAL, resultInfo.checkContext.inferenceContext().free(resultInfo.pt) ? Type.noType : pt()); Type inferred = deferredAttr.attribSpeculative(tree, env, findDiamondResult).type; Type polyPt = allowPoly ? @@ -2209,7 +2220,7 @@ } if (!types.isReifiable(elemtype)) log.error(tree.pos(), "generic.array.creation"); - result = check(tree, owntype, VAL, resultInfo); + result = check(tree, owntype, KindSelector.VAL, resultInfo); } /* @@ -2318,7 +2329,8 @@ ResultInfo bodyResultInfo = lambdaType.getReturnType() == Type.recoveryType ? recoveryInfo : - new ResultInfo(VAL, lambdaType.getReturnType(), funcContext); + new ResultInfo(KindSelector.VAL, + lambdaType.getReturnType(), funcContext); localEnv.info.returnResult = bodyResultInfo; if (that.getBodyKind() == JCLambda.BodyKind.EXPRESSION) { @@ -2328,7 +2340,7 @@ attribStats(body.stats, localEnv); } - result = check(that, currentTarget, VAL, resultInfo); + result = check(that, currentTarget, KindSelector.VAL, resultInfo); boolean isSpeculativeRound = resultInfo.checkContext.deferredAttrContext().mode == DeferredAttr.AttrMode.SPECULATIVE; @@ -2349,7 +2361,7 @@ checkAccessibleTypes(that, localEnv, resultInfo.checkContext.inferenceContext(), lambdaType, currentTarget); } - result = check(that, currentTarget, VAL, resultInfo); + result = check(that, currentTarget, KindSelector.VAL, resultInfo); } catch (Types.FunctionDescriptorLookupError ex) { JCDiagnostic cause = ex.getDiagnostic(); resultInfo.checkContext.report(that, cause); @@ -2802,7 +2814,7 @@ if (!isSpeculativeRound) { checkAccessibleTypes(that, localEnv, resultInfo.checkContext.inferenceContext(), desc, currentTarget); } - result = check(that, currentTarget, VAL, resultInfo); + result = check(that, currentTarget, KindSelector.VAL, resultInfo); } catch (Types.FunctionDescriptorLookupError ex) { JCDiagnostic cause = ex.getDiagnostic(); resultInfo.checkContext.report(that, cause); @@ -2813,7 +2825,9 @@ //where ResultInfo memberReferenceQualifierResult(JCMemberReference tree) { //if this is a constructor reference, the expected kind must be a type - return new ResultInfo(tree.getMode() == ReferenceMode.INVOKE ? VAL | TYP : TYP, Type.noType); + return new ResultInfo(tree.getMode() == ReferenceMode.INVOKE ? + KindSelector.VAL_TYP : KindSelector.TYP, + Type.noType); } @@ -2912,7 +2926,7 @@ Type owntype = attribTree(tree.expr, env, resultInfo); result = check(tree, owntype, pkind(), resultInfo); Symbol sym = TreeInfo.symbol(tree); - if (sym != null && (sym.kind&(TYP|PCK)) != 0) + if (sym != null && sym.kind.matches(KindSelector.TYP_PCK)) log.error(tree.pos(), "illegal.start.of.type"); } @@ -2920,7 +2934,7 @@ Type owntype = attribTree(tree.lhs, env.dup(tree), varInfo); Type capturedType = capture(owntype); attribExpr(tree.rhs, env, owntype); - result = check(tree, capturedType, VAL, resultInfo); + result = check(tree, capturedType, KindSelector.VAL, resultInfo); } public void visitAssignop(JCAssignOp tree) { @@ -2945,7 +2959,7 @@ operator.type.getReturnType(), owntype); } - result = check(tree, owntype, VAL, resultInfo); + result = check(tree, owntype, KindSelector.VAL, resultInfo); } public void visitUnary(JCUnary tree) { @@ -2974,14 +2988,13 @@ } } } - result = check(tree, owntype, VAL, resultInfo); + result = check(tree, owntype, KindSelector.VAL, resultInfo); } public void visitBinary(JCBinary tree) { // Attribute arguments. Type left = chk.checkNonVoid(tree.lhs.pos(), attribExpr(tree.lhs, env)); Type right = chk.checkNonVoid(tree.lhs.pos(), attribExpr(tree.rhs, env)); - // Find operator. Symbol operator = tree.operator = rs.resolveBinaryOperator(tree.pos(), tree.getTag(), env, left, right); @@ -3019,7 +3032,7 @@ chk.checkDivZero(tree.rhs.pos(), operator, right); } - result = check(tree, owntype, VAL, resultInfo); + result = check(tree, owntype, KindSelector.VAL, resultInfo); } public void visitTypeCast(final JCTypeCast tree) { @@ -3034,7 +3047,8 @@ boolean isPoly = allowPoly && (expr.hasTag(LAMBDA) || expr.hasTag(REFERENCE)); if (isPoly) { //expression is a poly - we need to propagate target type info - castInfo = new ResultInfo(VAL, clazztype, new Check.NestedCheckContext(resultInfo.checkContext) { + castInfo = new ResultInfo(KindSelector.VAL, clazztype, + new Check.NestedCheckContext(resultInfo.checkContext) { @Override public boolean compatible(Type found, Type req, Warner warn) { return types.isCastable(found, req, warn); @@ -3048,14 +3062,14 @@ Type owntype = isPoly ? clazztype : chk.checkCastable(tree.expr.pos(), exprtype, clazztype); if (exprtype.constValue() != null) owntype = cfolder.coerce(exprtype, owntype); - result = check(tree, capture(owntype), VAL, resultInfo); + result = check(tree, capture(owntype), KindSelector.VAL, resultInfo); if (!isPoly) chk.checkRedundantCast(localEnv, tree); } public void visitTypeTest(JCInstanceOf tree) { Type exprtype = chk.checkNullOrRefType( - tree.expr.pos(), attribExpr(tree.expr, env)); + tree.expr.pos(), attribExpr(tree.expr, env)); Type clazztype = attribType(tree.clazz, env); if (!clazztype.hasTag(TYPEVAR)) { clazztype = chk.checkClassOrArrayType(tree.clazz.pos(), clazztype); @@ -3066,7 +3080,7 @@ } chk.validate(tree.clazz, env, false); chk.checkCastable(tree.expr.pos(), exprtype, clazztype); - result = check(tree, syms.booleanType, VAL, resultInfo); + result = check(tree, syms.booleanType, KindSelector.VAL, resultInfo); } public void visitIndexed(JCArrayAccess tree) { @@ -3077,8 +3091,9 @@ owntype = types.elemtype(atype); else if (!atype.hasTag(ERROR)) log.error(tree.pos(), "array.req.but.found", atype); - if ((pkind() & VAR) == 0) owntype = capture(owntype); - result = check(tree, owntype, VAR, resultInfo); + if (!pkind().contains(KindSelector.VAL)) + owntype = capture(owntype); + result = check(tree, owntype, KindSelector.VAR, resultInfo); } public void visitIdent(JCIdent tree) { @@ -3107,7 +3122,7 @@ Env symEnv = env; boolean noOuterThisPath = false; if (env.enclClass.sym.owner.kind != PCK && // we are in an inner class - (sym.kind & (VAR | MTH | TYP)) != 0 && + sym.kind.matches(KindSelector.VAL_MTH) && sym.owner.kind == TYP && tree.name != names._this && tree.name != names._super) { @@ -3130,7 +3145,7 @@ // If we are expecting a variable (as opposed to a value), check // that the variable is assignable in the current environment. - if (pkind() == VAR) + if (pkind() == KindSelector.VAR) checkAssignable(tree.pos(), v, null, env); } @@ -3138,13 +3153,15 @@ // if symbol is a field or instance method, check that it is // not accessed before the supertype constructor is called. if ((symEnv.info.isSelfCall || noOuterThisPath) && - (sym.kind & (VAR | MTH)) != 0 && + sym.kind.matches(KindSelector.VAL_MTH) && sym.owner.kind == TYP && (sym.flags() & STATIC) == 0) { - chk.earlyRefError(tree.pos(), sym.kind == VAR ? sym : thisSym(tree.pos(), env)); + chk.earlyRefError(tree.pos(), sym.kind == VAR ? + sym : thisSym(tree.pos(), env)); } Env env1 = env; - if (sym.kind != ERR && sym.kind != TYP && sym.owner != null && sym.owner != env1.enclClass.sym) { + if (sym.kind != ERR && sym.kind != TYP && + sym.owner != null && sym.owner != env1.enclClass.sym) { // If the found symbol is inaccessible, then it is // accessed through an enclosing instance. Locate this // enclosing instance: @@ -3161,24 +3178,27 @@ public void visitSelect(JCFieldAccess tree) { // Determine the expected kind of the qualifier expression. - int skind = 0; + KindSelector skind = KindSelector.NIL; if (tree.name == names._this || tree.name == names._super || - tree.name == names._class) + tree.name == names._class) { - skind = TYP; + skind = KindSelector.TYP; } else { - if ((pkind() & PCK) != 0) skind = skind | PCK; - if ((pkind() & TYP) != 0) skind = skind | TYP | PCK; - if ((pkind() & (VAL | MTH)) != 0) skind = skind | VAL | TYP; + if (pkind().contains(KindSelector.PCK)) + skind = KindSelector.of(skind, KindSelector.PCK); + if (pkind().contains(KindSelector.TYP)) + skind = KindSelector.of(skind, KindSelector.TYP, KindSelector.PCK); + if (pkind().contains(KindSelector.VAL_MTH)) + skind = KindSelector.of(skind, KindSelector.VAL, KindSelector.TYP); } // Attribute the qualifier expression, and determine its symbol (if any). Type site = attribTree(tree.selected, env, new ResultInfo(skind, Infer.anyPoly)); - if ((pkind() & (PCK | TYP)) == 0) + if (!pkind().contains(KindSelector.TYP_PCK)) site = capture(site); // Capture field access // don't allow T.class T[].class, etc - if (skind == TYP) { + if (skind == KindSelector.TYP) { Type elt = site; while (elt.hasTag(ARRAY)) elt = ((ArrayType)elt).elemtype; @@ -3202,7 +3222,7 @@ // Determine the symbol represented by the selection. env.info.pendingResolutionPhase = null; Symbol sym = selectSym(tree, sitesym, site, env, resultInfo); - if (sym.exists() && !isType(sym) && (pkind() & (PCK | TYP)) != 0) { + if (sym.exists() && !isType(sym) && pkind().contains(KindSelector.TYP_PCK)) { site = capture(site); sym = selectSym(tree, sitesym, site, env, resultInfo); } @@ -3224,7 +3244,7 @@ // If we are expecting a variable (as opposed to a value), check // that the variable is assignable in the current environment. - if (pkind() == VAR) + if (pkind() == KindSelector.VAR) checkAssignable(tree.pos(), v, tree.selected, env); } @@ -3239,9 +3259,11 @@ } // Disallow selecting a type from an expression - if (isType(sym) && (sitesym==null || (sitesym.kind&(TYP|PCK)) == 0)) { + if (isType(sym) && (sitesym == null || !sitesym.kind.matches(KindSelector.TYP_PCK))) { tree.type = check(tree.selected, pt(), - sitesym == null ? VAL : sitesym.kind, new ResultInfo(TYP|PCK, pt())); + sitesym == null ? + KindSelector.VAL : sitesym.kind.toSelector(), + new ResultInfo(KindSelector.TYP_PCK, pt())); } if (isType(sitesym)) { @@ -3266,10 +3288,13 @@ sym.isStatic() && sym.kind == MTH) { log.error(tree.pos(), "static.intf.method.invoke.not.supported.in.source", sourceName); } - } else if (sym.kind != ERR && (sym.flags() & STATIC) != 0 && sym.name != names._class) { + } else if (sym.kind != ERR && + (sym.flags() & STATIC) != 0 && + sym.name != names._class) { // If the qualified item is not a type and the selected item is static, report // a warning. Make allowance for the class of an array type e.g. Object[].class) - chk.warnStatic(tree, "static.not.qualified.by.type", Kinds.kindName(sym.kind), sym.owner); + chk.warnStatic(tree, "static.not.qualified.by.type", + sym.kind.kindName(), sym.owner); } // If we are selecting an instance member via a `super', ... @@ -3330,7 +3355,6 @@ } else { // We are seeing a plain identifier as selector. Symbol sym = rs.findIdentInType(env, site, name, resultInfo.pkind); - if ((resultInfo.pkind & ERRONEOUS) == 0) sym = rs.accessBase(sym, pos, location, site, name, true); return sym; } @@ -3438,7 +3462,7 @@ Symbol sym, Env env, ResultInfo resultInfo) { - if ((resultInfo.pkind & POLY) != 0) { + if (resultInfo.pkind.contains(KindSelector.POLY)) { Type pt = resultInfo.pt.map(deferredAttr.new RecoveryDeferredTypeMap(AttrMode.SPECULATIVE, sym, env.info.pendingResolutionPhase)); Type owntype = checkIdInternal(tree, site, sym, pt, env, resultInfo); resultInfo.pt.map(deferredAttr.new RecoveryDeferredTypeMap(AttrMode.CHECK, sym, env.info.pendingResolutionPhase)); @@ -3503,7 +3527,7 @@ // Test (4): if symbol is an instance field of a raw type, // which is being assigned to, issue an unchecked warning if // its type changes under erasure. - if (resultInfo.pkind == VAR && + if (resultInfo.pkind == KindSelector.VAR && v.owner.kind == TYP && (v.flags() & STATIC) == 0 && (site.hasTag(CLASS) || site.hasTag(TYPEVAR))) { @@ -3528,7 +3552,7 @@ if (v.getConstValue() != null && isStaticReference(tree)) owntype = owntype.constType(v.getConstValue()); - if (resultInfo.pkind == VAL) { + if (resultInfo.pkind == KindSelector.VAL) { owntype = capture(owntype); // capture "names as expressions" } break; @@ -3559,7 +3583,7 @@ // Test (3): if symbol is a variable, check that its type and // kind are compatible with the prototype and protokind. - return check(tree, owntype, sym.kind, resultInfo); + return check(tree, owntype, sym.kind.toSelector(), resultInfo); } /** Check that variable is initialized and evaluate the variable's @@ -3799,8 +3823,8 @@ } public void visitLiteral(JCLiteral tree) { - result = check( - tree, litType(tree.typetag).constType(tree.value), VAL, resultInfo); + result = check(tree, litType(tree.typetag).constType(tree.value), + KindSelector.VAL, resultInfo); } //where /** Return the type of a literal with given type tag. @@ -3810,13 +3834,13 @@ } public void visitTypeIdent(JCPrimitiveTypeTree tree) { - result = check(tree, syms.typeOfTag[tree.typetag.ordinal()], TYP, resultInfo); + result = check(tree, syms.typeOfTag[tree.typetag.ordinal()], KindSelector.TYP, resultInfo); } public void visitTypeArray(JCArrayTypeTree tree) { Type etype = attribType(tree.elemtype, env); Type type = new ArrayType(etype, syms.arrayClass); - result = check(tree, type, TYP, resultInfo); + result = check(tree, type, KindSelector.TYP, resultInfo); } /** Visitor method for parameterized types. @@ -3875,7 +3899,7 @@ owntype = types.createErrorType(tree.type); } } - result = check(tree, owntype, TYP, resultInfo); + result = check(tree, owntype, KindSelector.TYP, resultInfo); } public void visitTypeUnion(JCTypeUnion tree) { @@ -3912,7 +3936,8 @@ all_multicatchTypes.append(ctype); } } - Type t = check(tree, types.lub(multicatchTypes.toList()), TYP, resultInfo); + Type t = check(tree, types.lub(multicatchTypes.toList()), + KindSelector.TYP, resultInfo); if (t.hasTag(CLASS)) { List alternatives = ((all_multicatchTypes == null) ? multicatchTypes : all_multicatchTypes).toList(); @@ -4016,7 +4041,7 @@ result = check(tree, new WildcardType(chk.checkRefType(tree.pos(), type), tree.kind.kind, syms.boundClass), - TYP, resultInfo); + KindSelector.TYP, resultInfo); } public void visitAnnotation(JCAnnotation tree) { @@ -4064,7 +4089,7 @@ public void visitErroneous(JCErroneous tree) { if (tree.errs != null) for (JCTree err : tree.errs) - attribTree(err, env, new ResultInfo(ERR, pt())); + attribTree(err, env, new ResultInfo(KindSelector.ERR, pt())); result = tree.type = syms.errType; } @@ -4315,7 +4340,7 @@ public static final Filter anyNonAbstractOrDefaultMethod = new Filter() { @Override public boolean accepts(Symbol s) { - return s.kind == Kinds.MTH && + return s.kind == MTH && (s.flags() & (DEFAULT | ABSTRACT)) != ABSTRACT; } }; diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Thu Oct 23 13:43:56 2014 -0700 @@ -54,6 +54,7 @@ import static com.sun.tools.javac.code.Flags.ANNOTATION; import static com.sun.tools.javac.code.Flags.SYNCHRONIZED; import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; import static com.sun.tools.javac.code.TypeTag.*; import static com.sun.tools.javac.code.TypeTag.WILDCARD; @@ -349,7 +350,7 @@ for (Symbol sym : s.getSymbolsByName(v.name)) { if (sym.owner != v.owner) break; if (sym.kind == VAR && - (sym.owner.kind & (VAR | MTH)) != 0 && + sym.owner.kind.matches(KindSelector.VAL_MTH) && v.name != names.error) { duplicateError(pos, sym); return; @@ -367,7 +368,7 @@ for (Symbol sym : s.getSymbolsByName(c.name)) { if (sym.owner != c.owner) break; if (sym.kind == TYP && !sym.type.hasTag(TYPEVAR) && - (sym.owner.kind & (VAR | MTH)) != 0 && + sym.owner.kind.matches(KindSelector.VAL_MTH) && c.name != names.error) { duplicateError(pos, sym); return; @@ -2573,7 +2574,7 @@ void checkElemAccessFromSerializableLambda(final JCTree tree) { if (warnOnAccessToSensitiveMembers) { Symbol sym = TreeInfo.symbol(tree); - if ((sym.kind & (VAR | MTH)) == 0) { + if (!sym.kind.matches(KindSelector.VAL_MTH)) { return; } @@ -2599,7 +2600,7 @@ return false; } - while (sym.kind != Kinds.PCK) { + while (sym.kind != PCK) { if ((sym.flags() & PUBLIC) == 0) { return true; } @@ -2957,7 +2958,7 @@ Scope scope = container.members(); for(Symbol elm : scope.getSymbols()) { if (elm.name != names.value && - elm.kind == Kinds.MTH && + elm.kind == MTH && ((MethodSymbol)elm).defaultValue == null) { log.error(pos, "invalid.repeatable.annotation.elem.nondefault", @@ -3041,8 +3042,7 @@ else if (target == names.METHOD) { if (s.kind == MTH && !s.isConstructor()) return true; } else if (target == names.PARAMETER) - { if (s.kind == VAR && - s.owner.kind == MTH && + { if (s.kind == VAR && s.owner.kind == MTH && (s.flags() & PARAMETER) != 0) return true; } @@ -3060,8 +3060,7 @@ else if (target == names.PACKAGE) { if (s.kind == PCK) return true; } else if (target == names.TYPE_USE) - { if (s.kind == TYP || - s.kind == VAR || + { if (s.kind == TYP || s.kind == VAR || (s.kind == MTH && !s.isConstructor() && !s.type.getReturnType().hasTag(VOID)) || (s.kind == MTH && s.isConstructor())) @@ -3243,7 +3242,7 @@ try { tsym.flags_field |= LOCKED; for (Symbol s : tsym.members().getSymbols(NON_RECURSIVE)) { - if (s.kind != Kinds.MTH) + if (s.kind != MTH) continue; checkAnnotationResType(pos, ((MethodSymbol)s).type.getReturnType()); } diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Thu Oct 23 13:43:56 2014 -0700 @@ -47,9 +47,10 @@ import java.util.Set; import java.util.WeakHashMap; -import static com.sun.tools.javac.code.Kinds.VAL; import static com.sun.tools.javac.code.TypeTag.*; import static com.sun.tools.javac.tree.JCTree.Tag.*; +import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Kinds.Kind.*; /** * This is an helper class that is used to perform deferred type-analysis. @@ -700,7 +701,7 @@ * which may happen if lambda's return type is an * inference variable */ - Attr.ResultInfo bodyResultInfo = attr.new ResultInfo(VAL, Type.noType); + Attr.ResultInfo bodyResultInfo = attr.new ResultInfo(KindSelector.VAL, Type.noType); localEnv.info.returnResult = bodyResultInfo; // discard any log output @@ -768,10 +769,10 @@ switch (lookupSym.kind) { //note: as argtypes are erroneous types, type-errors must //have been caused by arity mismatch - case Kinds.ABSENT_MTH: - case Kinds.WRONG_MTH: - case Kinds.WRONG_MTHS: - case Kinds.WRONG_STATICNESS: + case ABSENT_MTH: + case WRONG_MTH: + case WRONG_MTHS: + case WRONG_STATICNESS: checkContext.report(tree, diags.fragment("incompatible.arg.types.in.mref")); } } @@ -1185,7 +1186,7 @@ rs.getMemberReference(tree, localEnv, mref2, exprTree.type, tree.name); tree.sym = res; - if (res.kind >= Kinds.ERRONEOUS || + if (res.kind.isOverloadError() || res.type.hasTag(FORALL) || (res.flags() & Flags.VARARGS) != 0 || (TreeInfo.isStaticSelector(exprTree, tree.name.table.names) && @@ -1380,13 +1381,13 @@ */ E analyzeCandidateMethods(Symbol sym, E defaultValue, MethodAnalyzer analyzer) { switch (sym.kind) { - case Kinds.MTH: + case MTH: return analyzer.process((MethodSymbol) sym); - case Kinds.AMBIGUOUS: + case AMBIGUOUS: Resolve.AmbiguityError err = (Resolve.AmbiguityError)sym.baseSymbol(); E res = defaultValue; for (Symbol s : err.ambiguousSyms) { - if (s.kind == Kinds.MTH) { + if (s.kind == MTH) { res = analyzer.reduce(res, analyzer.process((MethodSymbol) s)); if (analyzer.shouldStop(res)) return res; diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Enter.java Thu Oct 23 13:43:56 2014 -0700 @@ -30,6 +30,7 @@ import javax.tools.JavaFileManager; import com.sun.tools.javac.code.*; +import com.sun.tools.javac.code.Kinds.KindSelector; import com.sun.tools.javac.code.Scope.*; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.code.Type.*; @@ -43,7 +44,7 @@ import static com.sun.tools.javac.code.Flags.*; -import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Kinds.Kind.*; /** This class enters symbols for all encountered definitions into * the symbol table. The pass consists of two phases, organized as @@ -402,7 +403,7 @@ // which contains this class in a non-static context // (its "enclosing instance class"), provided such a class exists. Symbol owner1 = owner; - while ((owner1.kind & (VAR | MTH)) != 0 && + while (owner1.kind.matches(KindSelector.VAL_MTH) && (owner1.flags_field & STATIC) == 0) { owner1 = owner1.owner; } diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java Thu Oct 23 13:43:56 2014 -0700 @@ -40,7 +40,7 @@ import static com.sun.tools.javac.code.Flags.*; import static com.sun.tools.javac.code.Flags.BLOCK; -import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.code.TypeTag.BOOLEAN; import static com.sun.tools.javac.code.TypeTag.VOID; import static com.sun.tools.javac.tree.JCTree.Tag.*; diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java Thu Oct 23 13:43:56 2014 -0700 @@ -177,7 +177,6 @@ resolveContext.methodCheck.argumentsAcceptable(env, deferredAttrContext, //B2 argtypes, mt.getParameterTypes(), warn); - if (allowGraphInference && resultInfo != null && !warn.hasNonSilentLint(Lint.LintCategory.UNCHECKED)) { @@ -867,7 +866,10 @@ while (tmpTail.nonEmpty()) { Type b1 = boundList.head; Type b2 = tmpTail.head; - if (b1 != b2) { + /* This wildcard check is temporary workaround. This code may need to be + * revisited once spec bug JDK-7034922 is fixed. + */ + if (b1 != b2 && !b1.hasTag(WILDCARD) && !b2.hasTag(WILDCARD)) { for (Pair commonSupers : infer.getParameterizedSupers(b1, b2)) { List allParamsSuperBound1 = commonSupers.fst.allparams(); List allParamsSuperBound2 = commonSupers.snd.allparams(); diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Thu Oct 23 13:43:56 2014 -0700 @@ -30,7 +30,6 @@ import com.sun.tools.javac.tree.TreeMaker; import com.sun.tools.javac.tree.TreeTranslator; import com.sun.tools.javac.code.Attribute; -import com.sun.tools.javac.code.Kinds; import com.sun.tools.javac.code.Scope.WriteableScope; import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Symbol.ClassSymbol; @@ -58,7 +57,7 @@ import static com.sun.tools.javac.comp.LambdaToMethod.LambdaSymbolKind.*; import static com.sun.tools.javac.code.Flags.*; -import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.code.TypeTag.*; import static com.sun.tools.javac.tree.JCTree.Tag.*; @@ -727,7 +726,7 @@ * with the generated signature. */ private List convertArgs(Symbol meth, List args, Type varargsElement) { - Assert.check(meth.kind == Kinds.MTH); + Assert.check(meth.kind == MTH); List formals = types.erasure(meth.type).getParameterTypes(); if (varargsElement != null) { Assert.check((meth.flags() & VARARGS) != 0); diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java Thu Oct 23 13:43:56 2014 -0700 @@ -28,6 +28,7 @@ import java.util.*; import com.sun.tools.javac.code.*; +import com.sun.tools.javac.code.Kinds.KindSelector; import com.sun.tools.javac.code.Scope.WriteableScope; import com.sun.tools.javac.jvm.*; import com.sun.tools.javac.main.Option.PkgInfo; @@ -45,9 +46,9 @@ import static com.sun.tools.javac.code.Flags.*; import static com.sun.tools.javac.code.Flags.BLOCK; -import static com.sun.tools.javac.code.Kinds.*; import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; import static com.sun.tools.javac.code.TypeTag.*; +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.jvm.ByteCodes.*; import static com.sun.tools.javac.tree.JCTree.Tag.*; @@ -358,10 +359,10 @@ return null; } Symbol currentOwner = c.owner; - while ((currentOwner.owner.kind & TYP) != 0 && currentOwner.isLocal()) { + while (currentOwner.owner.kind.matches(KindSelector.TYP) && currentOwner.isLocal()) { currentOwner = currentOwner.owner; } - if ((currentOwner.owner.kind & (VAR | MTH)) != 0 && c.isSubClass(currentOwner, types)) { + if (currentOwner.owner.kind.matches(KindSelector.VAL_MTH) && c.isSubClass(currentOwner, types)) { return (ClassSymbol)currentOwner; } return null; @@ -376,7 +377,7 @@ if (fvs != null) { return fvs; } - if ((c.owner.kind & (VAR | MTH)) != 0) { + if (c.owner.kind.matches(KindSelector.VAL_MTH)) { FreeVarCollector collector = new FreeVarCollector(c); collector.scan(classDef(c)); fvs = collector.fvs; @@ -2090,7 +2091,7 @@ ClassSymbol c = types.boxedClass(type); Symbol typeSym = rs.accessBase( - rs.findIdentInType(attrEnv, c.type, names.TYPE, VAR), + rs.findIdentInType(attrEnv, c.type, names.TYPE, KindSelector.VAR), pos, c.type, names.TYPE, true); if (typeSym.kind == VAR) ((VarSymbol)typeSym).getConstValue(); // ensure initializer is evaluated diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/MemberEnter.java Thu Oct 23 13:43:56 2014 -0700 @@ -48,8 +48,9 @@ import static com.sun.tools.javac.code.Flags.*; import static com.sun.tools.javac.code.Flags.ANNOTATION; +import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; import static com.sun.tools.javac.code.Kinds.*; -import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.code.TypeTag.CLASS; import static com.sun.tools.javac.code.TypeTag.ERROR; import static com.sun.tools.javac.code.TypeTag.TYPEVAR; @@ -341,7 +342,7 @@ ImportFilter typeImportFilter = new ImportFilter() { @Override public boolean accepts(Scope origin, Symbol t) { - return t.kind == Kinds.TYP; + return t.kind == TYP; } }; @@ -575,7 +576,8 @@ localEnv.enclMethod = tree; if (tree.sym.type != null) { //when this is called in the enter stage, there's no type to be set - localEnv.info.returnResult = attr.new ResultInfo(VAL, tree.sym.type.getReturnType()); + localEnv.info.returnResult = attr.new ResultInfo(KindSelector.VAL, + tree.sym.type.getReturnType()); } if ((tree.mods.flags & STATIC) != 0) localEnv.info.staticLevel++; return localEnv; diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java Thu Oct 23 13:43:56 2014 -0700 @@ -55,6 +55,7 @@ import java.util.Arrays; import java.util.Collection; +import java.util.EnumMap; import java.util.EnumSet; import java.util.Iterator; import java.util.LinkedHashMap; @@ -65,7 +66,7 @@ import static com.sun.tools.javac.code.Flags.*; import static com.sun.tools.javac.code.Flags.BLOCK; import static com.sun.tools.javac.code.Kinds.*; -import static com.sun.tools.javac.code.Kinds.ERRONEOUS; +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.code.TypeTag.*; import static com.sun.tools.javac.comp.Resolve.MethodResolutionPhase.*; import static com.sun.tools.javac.tree.JCTree.Tag.*; @@ -154,6 +155,11 @@ return instance; } + private static Symbol bestOf(Symbol s1, + Symbol s2) { + return s1.kind.betterThan(s2.kind) ? s1 : s2; + } + // enum VerboseResolutionMode { SUCCESS("success"), @@ -192,7 +198,7 @@ void reportVerboseResolutionDiagnostic(DiagnosticPosition dpos, Name name, Type site, List argtypes, List typeargtypes, Symbol bestSoFar) { - boolean success = bestSoFar.kind < ERRONEOUS; + boolean success = !bestSoFar.kind.isOverloadError(); if (success && !verboseResolutionMode.contains(VerboseResolutionMode.SUCCESS)) { return; @@ -517,7 +523,6 @@ boolean allowBoxing, boolean useVarargs, Warner warn) throws Infer.InferenceException { - Type mt = types.memberType(site, m); // tvars is the list of formal type variables for which type arguments // need to inferred. @@ -536,9 +541,10 @@ while (formals.nonEmpty() && actuals.nonEmpty()) { List bounds = types.subst(types.getBounds((TypeVar)formals.head), pmt.tvars, typeargtypes); - for (; bounds.nonEmpty(); bounds = bounds.tail) + for (; bounds.nonEmpty(); bounds = bounds.tail) { if (!types.isSubtypeUnchecked(actuals.head, bounds.head, warn)) throw inapplicableMethodException.setMessage("explicit.param.do.not.conform.to.bounds",actuals.head, bounds); + } formals = formals.tail; actuals = actuals.tail; } @@ -558,7 +564,7 @@ if (l.head.hasTag(FORALL)) instNeeded = true; } - if (instNeeded) + if (instNeeded) { return infer.instantiateMethod(env, tvars, (MethodType)mt, @@ -569,6 +575,7 @@ useVarargs, currentResolutionContext, warn); + } DeferredAttr.DeferredAttrContext dc = currentResolutionContext.deferredAttrContext(m, infer.emptyContext, resultInfo, warn); currentResolutionContext.methodCheck.argumentsAcceptable(env, dc, @@ -992,7 +999,7 @@ class MethodResultInfo extends ResultInfo { public MethodResultInfo(Type pt, CheckContext checkContext) { - attr.super(VAL, pt, checkContext); + attr.super(KindSelector.VAL, pt, checkContext); } @Override @@ -1071,7 +1078,7 @@ */ ResultInfo methodCheckResult(Type to, DeferredAttr.DeferredAttrContext deferredAttrContext, Warner rsWarner, Type actual) { - return attr.new ResultInfo(Kinds.VAL, to, + return attr.new ResultInfo(KindSelector.VAL, to, new MostSpecificCheckContext(strict, deferredAttrContext, rsWarner, actual)); } @@ -1304,7 +1311,7 @@ Type st = types.supertype(c.type); if (st != null && (st.hasTag(CLASS) || st.hasTag(TYPEVAR))) { sym = findField(env, site, name, st.tsym); - if (sym.kind < bestSoFar.kind) bestSoFar = sym; + bestSoFar = bestOf(bestSoFar, sym); } for (List l = types.interfaces(c.type); bestSoFar.kind != AMBIGUOUS && l.nonEmpty(); @@ -1313,8 +1320,8 @@ if (bestSoFar.exists() && sym.exists() && sym.owner != bestSoFar.owner) bestSoFar = new AmbiguityError(bestSoFar, sym); - else if (sym.kind < bestSoFar.kind) - bestSoFar = sym; + else + bestSoFar = bestOf(bestSoFar, sym); } return bestSoFar; } @@ -1364,8 +1371,8 @@ return new StaticError(sym); else return sym; - } else if (sym.kind < bestSoFar.kind) { - bestSoFar = sym; + } else { + bestSoFar = bestOf(bestSoFar, sym); } if ((env1.enclClass.sym.flags() & STATIC) != 0) staticOnly = true; @@ -1383,10 +1390,11 @@ for (Symbol currentSymbol : sc.getSymbolsByName(name)) { if (currentSymbol.kind != VAR) continue; - // invariant: sym.kind == VAR - if (bestSoFar.kind < AMBIGUOUS && currentSymbol.owner != bestSoFar.owner) + // invariant: sym.kind == Symbol.Kind.VAR + if (!bestSoFar.kind.isOverloadError() && + currentSymbol.owner != bestSoFar.owner) return new AmbiguityError(bestSoFar, currentSymbol); - else if (bestSoFar.kind >= VAR) { + else if (!bestSoFar.kind.betterThan(VAR)) { origin = sc.getOrigin(currentSymbol).owner; bestSoFar = isAccessible(env, origin.type, currentSymbol) ? currentSymbol : new AccessError(env, origin.type, currentSymbol); @@ -1427,11 +1435,11 @@ !sym.isInheritedIn(site.tsym, types)) { return bestSoFar; } else if (useVarargs && (sym.flags() & VARARGS) == 0) { - return bestSoFar.kind >= ERRONEOUS ? + return bestSoFar.kind.isOverloadError() ? new BadVarargsMethod((ResolveError)bestSoFar.baseSymbol()) : bestSoFar; } - Assert.check(sym.kind < AMBIGUOUS); + Assert.check(!sym.kind.isOverloadError()); try { Type mt = rawInstantiate(env, site, sym, null, argtypes, typeargtypes, allowBoxing, useVarargs, types.noWarnings); @@ -1455,7 +1463,7 @@ ? new AccessError(env, site, sym) : bestSoFar; } - return (bestSoFar.kind > AMBIGUOUS) + return (bestSoFar.kind.isOverloadError() && bestSoFar.kind != AMBIGUOUS) ? sym : mostSpecific(argtypes, sym, bestSoFar, env, site, allowBoxing && operator, useVarargs); @@ -1689,6 +1697,7 @@ boolean operator) { @SuppressWarnings({"unchecked","rawtypes"}) List[] itypes = (List[])new List[] { List.nil(), List.nil() }; + InterfaceLookupPhase iphase = InterfaceLookupPhase.ABSTRACT_OK; for (TypeSymbol s : superclasses(intype)) { bestSoFar = findMethodInScope(env, site, name, argtypes, typeargtypes, @@ -1702,7 +1711,7 @@ } } - Symbol concrete = bestSoFar.kind < ERR && + Symbol concrete = bestSoFar.kind.isValid() && (bestSoFar.flags() & ABSTRACT) == 0 ? bestSoFar : methodNotFound; @@ -1715,7 +1724,8 @@ bestSoFar = findMethodInScope(env, site, name, argtypes, typeargtypes, itype.tsym.members(), bestSoFar, allowBoxing, useVarargs, operator, true); if (concrete != bestSoFar && - concrete.kind < ERR && bestSoFar.kind < ERR && + concrete.kind.isValid() && + bestSoFar.kind.isValid() && types.isSubSignature(concrete.type, bestSoFar.type)) { //this is an hack - as javac does not do full membership checks //most specific ends up comparing abstract methods that might have @@ -1832,8 +1842,8 @@ sym.owner.kind == TYP && (sym.flags() & STATIC) == 0) return new StaticError(sym); else return sym; - } else if (sym.kind < bestSoFar.kind) { - bestSoFar = sym; + } else { + bestSoFar = bestOf(bestSoFar, sym); } if ((env1.enclClass.sym.flags() & STATIC) != 0) staticOnly = true; env1 = env1.outer; @@ -1936,17 +1946,18 @@ Type st = types.supertype(c.type); if (st != null && st.hasTag(CLASS)) { sym = findMemberType(env, site, name, st.tsym); - if (sym.kind < bestSoFar.kind) bestSoFar = sym; + bestSoFar = bestOf(bestSoFar, sym); } for (List l = types.interfaces(c.type); bestSoFar.kind != AMBIGUOUS && l.nonEmpty(); l = l.tail) { sym = findMemberType(env, site, name, l.head.tsym); - if (bestSoFar.kind < AMBIGUOUS && sym.kind < AMBIGUOUS && + if (!bestSoFar.kind.isOverloadError() && + !sym.kind.isOverloadError() && sym.owner != bestSoFar.owner) bestSoFar = new AmbiguityError(bestSoFar, sym); - else if (sym.kind < bestSoFar.kind) - bestSoFar = sym; + else + bestSoFar = bestOf(bestSoFar, sym); } return bestSoFar; } @@ -1985,8 +1996,8 @@ if (bestSoFar.kind == TYP && sym.kind == TYP && bestSoFar != sym) return new AmbiguityError(bestSoFar, sym); - else if (sym.kind < bestSoFar.kind) - bestSoFar = sym; + else + bestSoFar = bestOf(bestSoFar, sym); } return bestSoFar; } @@ -2041,7 +2052,7 @@ sym.type.getEnclosingType().isParameterized()) return new StaticError(sym); else if (sym.exists()) return sym; - else if (sym.kind < bestSoFar.kind) bestSoFar = sym; + else bestSoFar = bestOf(bestSoFar, sym); JCClassDecl encl = env1.baseClause ? (JCClassDecl)env1.tree : env1.enclClass; if ((encl.sym.flags() & STATIC) != 0) @@ -2051,15 +2062,15 @@ if (!env.tree.hasTag(IMPORT)) { sym = findGlobalType(env, env.toplevel.namedImportScope, name); if (sym.exists()) return sym; - else if (sym.kind < bestSoFar.kind) bestSoFar = sym; + else bestSoFar = bestOf(bestSoFar, sym); sym = findGlobalType(env, env.toplevel.packge.members(), name); if (sym.exists()) return sym; - else if (sym.kind < bestSoFar.kind) bestSoFar = sym; + else bestSoFar = bestOf(bestSoFar, sym); sym = findGlobalType(env, env.toplevel.starImportScope, name); if (sym.exists()) return sym; - else if (sym.kind < bestSoFar.kind) bestSoFar = sym; + else bestSoFar = bestOf(bestSoFar, sym); } return bestSoFar; @@ -2071,23 +2082,25 @@ * @param kind Indicates the possible symbol kinds * (a subset of VAL, TYP, PCK). */ - Symbol findIdent(Env env, Name name, int kind) { + Symbol findIdent(Env env, Name name, KindSelector kind) { Symbol bestSoFar = typeNotFound; Symbol sym; - if ((kind & VAR) != 0) { + if (kind.contains(KindSelector.VAL)) { sym = findVar(env, name); if (sym.exists()) return sym; - else if (sym.kind < bestSoFar.kind) bestSoFar = sym; + else bestSoFar = bestOf(bestSoFar, sym); } - if ((kind & TYP) != 0) { + if (kind.contains(KindSelector.TYP)) { sym = findType(env, name); + if (sym.exists()) return sym; - else if (sym.kind < bestSoFar.kind) bestSoFar = sym; + else bestSoFar = bestOf(bestSoFar, sym); } - if ((kind & PCK) != 0) return syms.enterPackage(name); + if (kind.contains(KindSelector.PCK)) + return syms.enterPackage(name); else return bestSoFar; } @@ -2098,21 +2111,21 @@ * (a nonempty subset of TYP, PCK). */ Symbol findIdentInPackage(Env env, TypeSymbol pck, - Name name, int kind) { + Name name, KindSelector kind) { Name fullname = TypeSymbol.formFullName(name, pck); Symbol bestSoFar = typeNotFound; PackageSymbol pack = null; - if ((kind & PCK) != 0) { + if (kind.contains(KindSelector.PCK)) { pack = syms.enterPackage(fullname); if (pack.exists()) return pack; } - if ((kind & TYP) != 0) { + if (kind.contains(KindSelector.TYP)) { Symbol sym = loadClass(env, fullname); if (sym.exists()) { // don't allow programs to use flatnames if (name == sym.name) return sym; } - else if (sym.kind < bestSoFar.kind) bestSoFar = sym; + else bestSoFar = bestOf(bestSoFar, sym); } return (pack != null) ? pack : bestSoFar; } @@ -2125,19 +2138,19 @@ * (a subset of VAL, TYP). */ Symbol findIdentInType(Env env, Type site, - Name name, int kind) { + Name name, KindSelector kind) { Symbol bestSoFar = typeNotFound; Symbol sym; - if ((kind & VAR) != 0) { + if (kind.contains(KindSelector.VAL)) { sym = findField(env, site, name, site.tsym); if (sym.exists()) return sym; - else if (sym.kind < bestSoFar.kind) bestSoFar = sym; + else bestSoFar = bestOf(bestSoFar, sym); } - if ((kind & TYP) != 0) { + if (kind.contains(KindSelector.TYP)) { sym = findMemberType(env, site, name, site.tsym); if (sym.exists()) return sym; - else if (sym.kind < bestSoFar.kind) bestSoFar = sym; + else bestSoFar = bestOf(bestSoFar, sym); } return bestSoFar; } @@ -2175,7 +2188,7 @@ List argtypes, List typeargtypes, LogResolveHelper logResolveHelper) { - if (sym.kind >= AMBIGUOUS) { + if (sym.kind.isOverloadError()) { ResolveError errSym = (ResolveError)sym.baseSymbol(); sym = errSym.access(name, qualified ? site.tsym : syms.noSymbol); argtypes = logResolveHelper.getArgumentTypes(errSym, sym, name, argtypes); @@ -2307,7 +2320,7 @@ * @param kind The set of admissible symbol kinds for the identifier. */ Symbol resolveIdent(DiagnosticPosition pos, Env env, - Name name, int kind) { + Name name, KindSelector kind) { return accessBase( findIdent(env, name, kind), pos, env.enclClass.sym.type, name, false); @@ -2367,7 +2380,7 @@ } @Override Symbol access(Env env, DiagnosticPosition pos, Symbol location, Symbol sym) { - if (sym.kind >= AMBIGUOUS) { + if (sym.kind.isOverloadError()) { sym = super.access(env, pos, location, sym); } else if (allowMethodHandles) { MethodSymbol msym = (MethodSymbol)sym; @@ -2524,8 +2537,9 @@ } @Override Symbol access(Env env, DiagnosticPosition pos, Symbol location, Symbol sym) { - if (sym.kind >= AMBIGUOUS) { - if (sym.kind != WRONG_MTH && sym.kind != WRONG_MTHS) { + if (sym.kind.isOverloadError()) { + if (sym.kind != WRONG_MTH && + sym.kind != WRONG_MTHS) { sym = super.access(env, pos, location, sym); } else { final JCDiagnostic details = sym.kind == WRONG_MTH ? @@ -2713,7 +2727,7 @@ if (isStaticSelector && !name.equals(names.init) && !boundSym.isStatic() && - boundSym.kind < ERRONEOUS) { + !boundSym.kind.isOverloadError()) { boundSym = methodNotFound; } @@ -2726,7 +2740,7 @@ unboundSym = lookupMethod(unboundEnv, env.tree.pos(), site.tsym, arityMethodCheck, unboundLookupHelper); if (unboundSym.isStatic() && - unboundSym.kind < ERRONEOUS) { + !unboundSym.kind.isOverloadError()) { unboundSym = methodNotFound; } } @@ -2801,11 +2815,11 @@ boundSearchResultKind = SearchResultKind.BAD_MATCH_MORE_SPECIFIC; } else { boundSearchResultKind = SearchResultKind.BAD_MATCH; - if (boundSym.kind < ERRONEOUS) { + if (!boundSym.kind.isOverloadError()) { boundSym = methodWithCorrectStaticnessNotFound; } } - } else if (boundSym.kind < ERRONEOUS) { + } else if (!boundSym.kind.isOverloadError()) { boundSearchResultKind = SearchResultKind.GOOD_MATCH; } } @@ -2835,11 +2849,11 @@ unboundSearchResultKind = SearchResultKind.BAD_MATCH_MORE_SPECIFIC; } else { unboundSearchResultKind = SearchResultKind.BAD_MATCH; - if (unboundSym.kind < ERRONEOUS) { + if (!unboundSym.kind.isOverloadError()) { unboundSym = methodWithCorrectStaticnessNotFound; } } - } else if (unboundSym.kind < ERRONEOUS) { + } else if (!unboundSym.kind.isOverloadError()) { unboundSearchResultKind = SearchResultKind.GOOD_MATCH; } } @@ -2849,7 +2863,8 @@ //merge results Pair res; Symbol bestSym = choose(boundSym, unboundSym); - if (bestSym.kind < ERRONEOUS && (staticErrorForBound || staticErrorForUnbound)) { + if (!bestSym.kind.isOverloadError() && + (staticErrorForBound || staticErrorForUnbound)) { if (staticErrorForBound) { boundSym = methodWithCorrectStaticnessNotFound; } @@ -2983,7 +2998,7 @@ */ final boolean shouldStop(Symbol sym, MethodResolutionPhase phase) { return phase.ordinal() > maxPhase.ordinal() || - sym.kind < ERRONEOUS || sym.kind == AMBIGUOUS; + !sym.kind.isOverloadError() || sym.kind == AMBIGUOUS; } /** @@ -3029,7 +3044,7 @@ @Override Symbol access(Env env, DiagnosticPosition pos, Symbol location, Symbol sym) { - if (sym.kind >= AMBIGUOUS) { + if (sym.kind.isOverloadError()) { //if nothing is found return the 'first' error sym = accessMethod(sym, pos, location, site, name, true, argtypes, typeargtypes); } @@ -3228,7 +3243,7 @@ return sym.kind != MTH || site.getEnclosingType().hasTag(NONE) || hasEnclosingInstance(env, site) ? - sym : new InvalidSymbolError(Kinds.MISSING_ENCL, sym, null) { + sym : new InvalidSymbolError(MISSING_ENCL, sym, null) { @Override JCDiagnostic getDiagnostic(DiagnosticType dkind, DiagnosticPosition pos, Symbol location, Type site, Name name, List argtypes, List typeargtypes) { return diags.create(dkind, log.currentSource(), pos, @@ -3369,7 +3384,7 @@ boolean hasEnclosingInstance(Env env, Type type) { Symbol encl = resolveSelfContainingInternal(env, type.tsym, false); - return encl != null && encl.kind < ERRONEOUS; + return encl != null && !encl.kind.isOverloadError(); } private Symbol resolveSelfContainingInternal(Env env, @@ -3405,7 +3420,7 @@ } Type resolveImplicitThis(DiagnosticPosition pos, Env env, Type t, boolean isSuperCall) { - Type thisType = (((t.tsym.owner.kind & (MTH|VAR)) != 0) + Type thisType = (t.tsym.owner.kind.matches(KindSelector.VAL_MTH) ? resolveSelf(pos, env, t.getEnclosingType().tsym, names._this) : resolveSelfContaining(pos, env, t.tsym, isSuperCall)).type; if (env.info.isSelfCall && thisType.tsym == env.enclClass.sym) @@ -3466,7 +3481,7 @@ /** The name of the kind of error, for debugging only. */ final String debugName; - ResolveError(int kind, String debugName) { + ResolveError(Kind kind, String debugName) { super(kind, 0, null, null, null); this.debugName = debugName; } @@ -3534,7 +3549,7 @@ /** The invalid symbol found during resolution */ Symbol sym; - InvalidSymbolError(int kind, Symbol sym, String debugName) { + InvalidSymbolError(Kind kind, Symbol sym, String debugName) { super(kind, debugName); this.sym = sym; } @@ -3551,7 +3566,7 @@ @Override public Symbol access(Name name, TypeSymbol location) { - if ((sym.kind & ERRONEOUS) == 0 && (sym.kind & TYP) != 0) + if (!sym.kind.isOverloadError() && sym.kind.matches(KindSelector.TYP)) return types.createErrorType(name, location, sym.type).tsym; else return sym; @@ -3564,11 +3579,11 @@ */ class SymbolNotFoundError extends ResolveError { - SymbolNotFoundError(int kind) { + SymbolNotFoundError(Kind kind) { this(kind, "symbol not found error"); } - SymbolNotFoundError(int kind, String debugName) { + SymbolNotFoundError(Kind kind, String debugName) { super(kind, debugName); } @@ -3609,7 +3624,7 @@ } boolean isConstructor = (kind == ABSENT_MTH || kind == WRONG_STATICNESS) && name == names.init; - KindName kindname = isConstructor ? KindName.CONSTRUCTOR : absentKind(kind); + KindName kindname = isConstructor ? KindName.CONSTRUCTOR : kind.absentKind(); Name idname = isConstructor ? site.tsym.name : name; String errKey = getErrorKey(kindname, typeargtypes.nonEmpty(), hasLocation); if (hasLocation) { @@ -3669,7 +3684,7 @@ this(WRONG_MTH, "inapplicable symbol error", context); } - protected InapplicableSymbolError(int kind, String debugName, MethodResolutionContext context) { + protected InapplicableSymbolError(Kind kind, String debugName, MethodResolutionContext context) { super(kind, debugName); this.resolveContext = context; } @@ -3784,7 +3799,7 @@ log.currentSource(), pos, "cant.apply.symbols", - name == names.init ? KindName.CONSTRUCTOR : absentKind(kind), + name == names.init ? KindName.CONSTRUCTOR : kind.absentKind(), name == names.init ? site.tsym.name : name, methodArguments(argtypes)); return new JCDiagnostic.MultilineDiagnostic(err, candidateDetails(filteredCandidates, site)); @@ -4164,8 +4179,8 @@ @Override public Symbol mergeResults(Symbol bestSoFar, Symbol sym) { //Check invariants (see {@code LookupHelper.shouldStop}) - Assert.check(bestSoFar.kind >= ERRONEOUS && bestSoFar.kind != AMBIGUOUS); - if (sym.kind < ERRONEOUS) { + Assert.check(bestSoFar.kind.isOverloadError() && bestSoFar.kind != AMBIGUOUS); + if (!sym.kind.isOverloadError()) { //varargs resolution successful return sym; } else { diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java Thu Oct 23 13:43:56 2014 -0700 @@ -36,7 +36,7 @@ import com.sun.tools.javac.util.List; import static com.sun.tools.javac.code.Flags.*; -import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; import static com.sun.tools.javac.code.TypeTag.CLASS; import static com.sun.tools.javac.code.TypeTag.TYPEVAR; diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/BaseFileObject.java diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/CacheFSInfo.java diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/FSInfo.java diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/JavacFileManager.java diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/Locations.java diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/RegularFileObject.java diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/RelativePath.java diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/SymbolArchive.java diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/ZipArchive.java diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/ZipFileIndex.java diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/ZipFileIndexArchive.java diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/file/ZipFileIndexCache.java diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java Thu Oct 23 13:43:56 2014 -0700 @@ -51,7 +51,7 @@ import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; import static com.sun.tools.javac.code.Flags.*; -import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.code.TypeTag.CLASS; import static com.sun.tools.javac.code.TypeTag.TYPEVAR; import static com.sun.tools.javac.jvm.ClassFile.*; @@ -994,7 +994,7 @@ // but the class name does not match the file name, then it is // an auxiliary class. String sn = n.toString(); - if (c.owner.kind == Kinds.PCK && + if (c.owner.kind == PCK && sn.endsWith(".java") && !sn.equals(c.name.toString()+".java")) { c.flags_field |= AUXILIARY; diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Thu Oct 23 13:43:56 2014 -0700 @@ -48,7 +48,7 @@ import com.sun.tools.javac.util.*; import static com.sun.tools.javac.code.Flags.*; -import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; import static com.sun.tools.javac.code.TypeTag.*; import static com.sun.tools.javac.main.Option.*; diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Code.java Thu Oct 23 13:43:56 2014 -0700 @@ -2017,13 +2017,12 @@ List 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); + } } } } diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java Thu Oct 23 13:43:56 2014 -0700 @@ -44,7 +44,7 @@ import com.sun.tools.javac.tree.JCTree.*; import static com.sun.tools.javac.code.Flags.*; -import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; import static com.sun.tools.javac.code.TypeTag.*; import static com.sun.tools.javac.jvm.ByteCodes.*; diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/JNIWriter.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/JNIWriter.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/JNIWriter.java Thu Oct 23 13:43:56 2014 -0700 @@ -51,7 +51,7 @@ import com.sun.tools.javac.util.Pair; import static com.sun.tools.javac.main.Option.*; -import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; /** This class provides operations to write native header files for classes. diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Pool.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Pool.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Pool.java Thu Oct 23 13:43:56 2014 -0700 @@ -25,7 +25,6 @@ package com.sun.tools.javac.jvm; -import com.sun.tools.javac.code.Kinds; import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.code.TypeTag; @@ -43,6 +42,9 @@ import com.sun.tools.javac.util.DefinedBy; import com.sun.tools.javac.util.DefinedBy.Api; +import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Kinds.Kind.*; + /** An internal structure that corresponds to the constant pool of a classfile. * *

This is NOT part of any supported API. @@ -289,7 +291,7 @@ @SuppressWarnings("fallthrough") private void checkConsistent() { boolean staticOk = false; - int expectedKind = -1; + Kind expectedKind = null; Filter nameFilter = nonInitFilter; boolean interfaceOwner = false; switch (refKind) { @@ -298,25 +300,25 @@ staticOk = true; case ClassFile.REF_getField: case ClassFile.REF_putField: - expectedKind = Kinds.VAR; + expectedKind = VAR; break; case ClassFile.REF_newInvokeSpecial: nameFilter = initFilter; - expectedKind = Kinds.MTH; + expectedKind = MTH; break; case ClassFile.REF_invokeInterface: interfaceOwner = true; - expectedKind = Kinds.MTH; + expectedKind = MTH; break; case ClassFile.REF_invokeStatic: interfaceOwner = true; staticOk = true; case ClassFile.REF_invokeVirtual: - expectedKind = Kinds.MTH; + expectedKind = MTH; break; case ClassFile.REF_invokeSpecial: interfaceOwner = true; - expectedKind = Kinds.MTH; + expectedKind = MTH; break; } Assert.check(!refSym.isStatic() || staticOk); diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/JavaCompiler.java Thu Oct 23 13:43:56 2014 -0700 @@ -68,12 +68,11 @@ import com.sun.tools.javac.util.*; import com.sun.tools.javac.util.Log.WriterKind; -import static javax.tools.StandardLocation.CLASS_OUTPUT; - +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.code.TypeTag.CLASS; import static com.sun.tools.javac.main.Option.*; import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag.*; - +import static javax.tools.StandardLocation.CLASS_OUTPUT; /** This class could be the main entry point for GJC when GJC is used as a * component in a larger software system. It provides operations to @@ -1105,23 +1104,23 @@ for (String nameStr : classnames) { Symbol sym = resolveBinaryNameOrIdent(nameStr); if (sym == null || - (sym.kind == Kinds.PCK && !processPcks) || - sym.kind == Kinds.ABSENT_TYP) { + (sym.kind == PCK && !processPcks) || + sym.kind == ABSENT_TYP) { log.error("proc.cant.find.class", nameStr); errors = true; continue; } try { - if (sym.kind == Kinds.PCK) + if (sym.kind == PCK) sym.complete(); if (sym.exists()) { - if (sym.kind == Kinds.PCK) + if (sym.kind == PCK) pckSymbols = pckSymbols.prepend((PackageSymbol)sym); else classSymbols = classSymbols.prepend((ClassSymbol)sym); continue; } - Assert.check(sym.kind == Kinds.PCK); + Assert.check(sym.kind == PCK); log.warning("proc.package.does.not.exist", nameStr); pckSymbols = pckSymbols.prepend((PackageSymbol)sym); } catch (CompletionFailure e) { diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/main/Main.java diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/AnnotationProxyMaker.java Thu Oct 23 13:43:56 2014 -0700 @@ -44,6 +44,7 @@ import com.sun.tools.javac.util.*; import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; +import static com.sun.tools.javac.code.Kinds.Kind.*; /** * A generator of dynamic proxy implementations of @@ -121,7 +122,7 @@ // First find the default values. ClassSymbol sym = (ClassSymbol) anno.type.tsym; for (Symbol s : sym.members().getSymbols(NON_RECURSIVE)) { - if (s.kind == Kinds.MTH) { + if (s.kind == MTH) { MethodSymbol m = (MethodSymbol) s; Attribute def = m.getDefaultValue(); if (def != null) diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacElements.java Thu Oct 23 13:43:56 2014 -0700 @@ -49,6 +49,7 @@ import com.sun.tools.javac.util.*; import com.sun.tools.javac.util.DefinedBy.Api; import com.sun.tools.javac.util.Name; +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; import static com.sun.tools.javac.code.TypeTag.CLASS; import static com.sun.tools.javac.tree.JCTree.Tag.*; @@ -120,7 +121,7 @@ sym.complete(); - return (sym.kind != Kinds.ERR && + return (sym.kind != ERR && sym.exists() && clazz.isInstance(sym) && name.equals(sym.getQualifiedName())) @@ -460,7 +461,7 @@ // Only static methods can hide other methods. // Methods only hide methods with matching signatures. - if (hider.kind == Kinds.MTH) { + if (hider.kind == MTH) { if (!hider.isStatic() || !types.isSubSignature(hider.type, hidee.type)) { return false; @@ -592,7 +593,7 @@ private Env getEnterEnv(Symbol sym) { // Get enclosing class of sym, or sym itself if it is a class // or package. - TypeSymbol ts = (sym.kind != Kinds.PCK) + TypeSymbol ts = (sym.kind != PCK) ? sym.enclClass() : (PackageSymbol) sym; return (ts != null) diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacTypes.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacTypes.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/model/JavacTypes.java Thu Oct 23 13:43:56 2014 -0700 @@ -39,6 +39,8 @@ import com.sun.tools.javac.util.*; import com.sun.tools.javac.util.DefinedBy.Api; +import static com.sun.tools.javac.code.Kinds.Kind.*; + /** * Utility methods for operating on types. * @@ -328,7 +330,7 @@ if (t != origin.type) { ClassSymbol c = (ClassSymbol) t.tsym; for (Symbol sym : c.members().getSymbolsByName(m.name)) { - if (sym.kind == Kinds.MTH && m.overrides(sym, origin, types, true)) { + if (sym.kind == MTH && m.overrides(sym, origin, types, true)) { results.add((MethodSymbol) sym); } } diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/nio/JavacPathFileManager.java diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Thu Oct 23 13:43:56 2014 -0700 @@ -75,6 +75,7 @@ import com.sun.tools.javac.util.Options; import com.sun.tools.javac.util.ServiceLoader; import static com.sun.tools.javac.code.Lint.LintCategory.PROCESSING; +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.main.Option.*; import static com.sun.tools.javac.comp.CompileStates.CompileState; import static com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag.*; @@ -1079,7 +1080,7 @@ boolean foundError = false; for (ClassSymbol cs : symtab.classes.values()) { - if (cs.kind == Kinds.ERR) { + if (cs.kind == ERR) { foundError = true; break; } @@ -1087,7 +1088,7 @@ if (foundError) { for (ClassSymbol cs : symtab.classes.values()) { - if (cs.classfile != null || cs.kind == Kinds.ERR) { + if (cs.classfile != null || cs.kind == ERR) { cs.reset(); cs.type = new ClassType(cs.type.getEnclosingType(), null, cs); if (cs.completer == null) { diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/sym/CreateSymbols.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/sym/CreateSymbols.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/sym/CreateSymbols.java Thu Oct 23 13:43:56 2014 -0700 @@ -26,7 +26,6 @@ package com.sun.tools.javac.sym; import com.sun.tools.javac.api.JavacTaskImpl; -import com.sun.tools.javac.code.Kinds; import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.code.Symbol; @@ -69,6 +68,8 @@ import javax.tools.StandardLocation; import javax.tools.ToolProvider; +import static com.sun.tools.javac.code.Kinds.Kind.*; + /** * Used to generate a "symbol file" representing rt.jar that only * includes supported or legacy proprietary API. Valid annotation @@ -221,7 +222,7 @@ continue; } TypeSymbol sym = (TypeSymbol)compiler.resolveIdent(className); - if (sym.kind != Kinds.TYP) { + if (sym.kind != TYP) { if (className.indexOf('$') < 0) { System.err.println("Ignoring (other) " + className + " : " + sym); System.err.println(" " + sym.getClass().getSimpleName() + " " + sym.type); @@ -263,7 +264,7 @@ cs.pool = pool; writer.writeClass(cs); for (Symbol sym : cs.members().getSymbols(NON_RECURSIVE)) { - if (sym.kind == Kinds.TYP) { + if (sym.kind == TYP) { ClassSymbol nestedClass = (ClassSymbol)sym; nestedClass.complete(); writeClass(pool, nestedClass, writer); diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java Thu Oct 23 13:43:56 2014 -0700 @@ -37,6 +37,7 @@ import com.sun.tools.javac.util.*; import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; import static com.sun.tools.javac.code.Flags.*; +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.code.TypeTag.BOT; import static com.sun.tools.javac.tree.JCTree.Tag.*; import static com.sun.tools.javac.tree.JCTree.Tag.BLOCK; @@ -339,8 +340,7 @@ //where private static boolean isStaticSym(JCTree tree) { Symbol sym = symbol(tree); - return (sym.kind == Kinds.TYP || - sym.kind == Kinds.PCK); + return (sym.kind == TYP || sym.kind == PCK); } /** Return true if a tree represents the null literal. */ @@ -876,7 +876,7 @@ if (!tree.hasTag(SELECT)) return false; JCFieldAccess s = (JCFieldAccess) tree; Symbol e = symbol(s.selected); - return e == null || (e.kind != Kinds.PCK && e.kind != Kinds.TYP); + return e == null || (e.kind != PCK && e.kind != TYP); } /** If this tree is an identifier or a field, set its symbol, otherwise skip. diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeMaker.java Thu Oct 23 13:43:56 2014 -0700 @@ -36,7 +36,7 @@ import com.sun.tools.javac.tree.JCTree.*; import static com.sun.tools.javac.code.Flags.*; -import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.code.TypeTag.*; /** Factory class for trees. diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/RichDiagnosticFormatter.java Thu Oct 23 13:43:56 2014 -0700 @@ -31,7 +31,6 @@ import java.util.Locale; import java.util.Map; -import com.sun.tools.javac.code.Kinds; import com.sun.tools.javac.code.Printer; import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Symbol.*; @@ -42,6 +41,8 @@ import static com.sun.tools.javac.code.TypeTag.*; import static com.sun.tools.javac.code.Flags.*; +import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.util.LayoutCharacters.*; import static com.sun.tools.javac.util.RichDiagnosticFormatter.RichConfiguration.*; @@ -305,7 +306,7 @@ Symbol s2 = s; while (s2.type.hasTag(CLASS) && s2.type.getEnclosingType().hasTag(CLASS) && - s2.owner.kind == Kinds.TYP) { + s2.owner.kind == TYP) { l = l.prepend(s2.getSimpleName()); s2 = s2.owner; } @@ -562,7 +563,7 @@ //this is a true typevar JCDiagnostic d = diags.fragment("where.typevar" + (boundErroneous ? ".1" : ""), t, bounds, - Kinds.kindName(t.tsym.location()), t.tsym.location()); + kindName(t.tsym.location()), t.tsym.location()); whereClauses.get(WhereClauseKind.TYPEVAR).put(t, d); symbolPreprocessor.visit(t.tsym.location(), null); visit(bounds); diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javah/Gen.java diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javah/JavahTask.java diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/javap/JavapTask.java diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/JavacState.java diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/client/SjavacClient.java diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/comp/SmartFileObject.java diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/comp/dependencies/TypeAndSupertypesDependency.java --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/comp/dependencies/TypeAndSupertypesDependency.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/sjavac/comp/dependencies/TypeAndSupertypesDependency.java Thu Oct 23 13:43:56 2014 -0700 @@ -36,6 +36,7 @@ import com.sun.tools.javac.code.Kinds; import com.sun.tools.javac.code.Type; +import static com.sun.tools.javac.code.Kinds.Kind.*; public class TypeAndSupertypesDependency implements Dependency { @@ -61,7 +62,7 @@ @Override public Set getPackages() { - if (type.kind == Kinds.ERR) + if (type.kind == ERR) return Collections.emptySet(); if (type instanceof ClassSymbol) { return allSupertypes(type).stream() diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/AnnotationTypeDocImpl.java --- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/AnnotationTypeDocImpl.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/AnnotationTypeDocImpl.java Thu Oct 23 13:43:56 2014 -0700 @@ -28,13 +28,14 @@ import com.sun.javadoc.*; import com.sun.source.util.TreePath; -import com.sun.tools.javac.code.Kinds; import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.util.List; import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; +import static com.sun.tools.javac.code.Kinds.Kind.*; + /** * Represents an annotation type. * @@ -94,7 +95,7 @@ public AnnotationTypeElementDoc[] elements() { List elements = List.nil(); for (Symbol sym : tsym.members().getSymbols(NON_RECURSIVE)) { - if (sym != null && sym.kind == Kinds.MTH) { + if (sym != null && sym.kind == MTH) { MethodSymbol s = (MethodSymbol)sym; elements = elements.prepend(env.getAnnotationTypeElementDoc(s)); } diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/ClassDocImpl.java --- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Thu Oct 23 13:43:56 2014 -0700 @@ -41,6 +41,7 @@ import com.sun.source.util.TreePath; import com.sun.tools.javac.code.Flags; import com.sun.tools.javac.code.Kinds; +import com.sun.tools.javac.code.Kinds.KindSelector; import com.sun.tools.javac.code.Scope; import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Symbol.*; @@ -58,7 +59,7 @@ import com.sun.tools.javac.util.Name; import com.sun.tools.javac.util.Names; import com.sun.tools.javac.util.Position; -import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; import static com.sun.tools.javac.code.TypeTag.CLASS; import static com.sun.tools.javac.tree.JCTree.Tag.*; @@ -617,7 +618,7 @@ List methods = List.nil(); for (Symbol sym :tsym.members().getSymbols(NON_RECURSIVE)) { if (sym != null - && sym.kind == Kinds.MTH + && sym.kind == MTH && sym.name != names.init && sym.name != names.clinit) { MethodSymbol s = (MethodSymbol)sym; @@ -652,7 +653,7 @@ List constructors = List.nil(); for (Symbol sym : tsym.members().getSymbols(NON_RECURSIVE)) { if (sym != null && - sym.kind == Kinds.MTH && sym.name == names.init) { + sym.kind == MTH && sym.name == names.init) { MethodSymbol s = (MethodSymbol)sym; if (!filter || env.shouldDocument(s)) { constructors = constructors.prepend(env.getConstructorDoc(s)); @@ -687,7 +688,7 @@ l.append(this); List more = List.nil(); for (Symbol sym : tsym.members().getSymbols(NON_RECURSIVE)) { - if (sym != null && sym.kind == Kinds.TYP) { + if (sym != null && sym.kind == TYP) { ClassSymbol s = (ClassSymbol)sym; ClassDocImpl c = env.getClassDoc(s); if (c.isSynthetic()) continue; @@ -714,7 +715,7 @@ public ClassDoc[] innerClasses(boolean filter) { ListBuffer innerClasses = new ListBuffer<>(); for (Symbol sym : tsym.members().getSymbols(NON_RECURSIVE)) { - if (sym != null && sym.kind == Kinds.TYP) { + if (sym != null && sym.kind == TYP) { ClassSymbol s = (ClassSymbol)sym; if ((s.flags_field & Flags.SYNTHETIC) != 0) continue; if (!filter || env.isVisible(s)) { @@ -810,7 +811,7 @@ Scope s = compenv.toplevel.namedImportScope; for (Symbol sym : s.getSymbolsByName(names.fromString(className))) { - if (sym.kind == Kinds.TYP) { + if (sym.kind == TYP) { ClassDoc c = env.getClassDoc((ClassSymbol)sym); return c; } @@ -818,7 +819,7 @@ s = compenv.toplevel.starImportScope; for (Symbol sym : s.getSymbolsByName(names.fromString(className))) { - if (sym.kind == Kinds.TYP) { + if (sym.kind == TYP) { ClassDoc c = env.getClassDoc((ClassSymbol)sym); return c; } @@ -931,7 +932,7 @@ // attempt to emulate the old behavior. MethodSymbol lastFound = null; for (Symbol sym : tsym.members().getSymbolsByName(names.fromString(methodName))) { - if (sym.kind == Kinds.MTH) { + if (sym.kind == MTH) { //### Should intern methodName as Name. if (sym.name.toString().equals(methodName)) { lastFound = (MethodSymbol)sym; @@ -944,7 +945,7 @@ } else { for (Symbol sym : tsym.members().getSymbolsByName(names.fromString(methodName))) { if (sym != null && - sym.kind == Kinds.MTH) { + sym.kind == MTH) { //### Should intern methodName as Name. if (hasParameterTypes((MethodSymbol)sym, paramTypes)) { return env.getMethodDoc((MethodSymbol)sym); @@ -1005,7 +1006,7 @@ String[] paramTypes) { Names names = tsym.name.table.names; for (Symbol sym : tsym.members().getSymbolsByName(names.fromString(""))) { - if (sym.kind == Kinds.MTH) { + if (sym.kind == MTH) { if (hasParameterTypes((MethodSymbol)sym, paramTypes)) { return env.getConstructorDoc((MethodSymbol)sym); } @@ -1047,7 +1048,7 @@ searched.add(this); for (Symbol sym : tsym.members().getSymbolsByName(names.fromString(fieldName))) { - if (sym.kind == Kinds.VAR) { + if (sym.kind == VAR) { //### Should intern fieldName as Name. return env.getFieldDoc((VarSymbol)sym); } @@ -1111,7 +1112,7 @@ if (t.hasTag(IMPORT)) { JCTree imp = ((JCImport) t).qualid; if ((TreeInfo.name(imp) != asterisk) && - (imp.type.tsym.kind & Kinds.TYP) != 0) { + imp.type.tsym.kind.matches(KindSelector.TYP)) { importedClasses.append( env.getClassDoc((ClassSymbol)imp.type.tsym)); } diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/JavadocEnter.java --- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/JavadocEnter.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/JavadocEnter.java Thu Oct 23 13:43:56 2014 -0700 @@ -28,7 +28,6 @@ import javax.tools.JavaFileObject; import com.sun.source.util.TreePath; -import com.sun.tools.javac.code.Kinds; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.comp.Enter; import com.sun.tools.javac.tree.JCTree.*; @@ -36,6 +35,8 @@ import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; import com.sun.tools.javac.util.List; +import static com.sun.tools.javac.code.Kinds.Kind.*; + /** * Javadoc's own enter phase does a few things above and beyond that * done by javac. @@ -95,7 +96,7 @@ public void visitClassDef(JCClassDecl tree) { super.visitClassDef(tree); if (tree.sym == null) return; - if (tree.sym.kind == Kinds.TYP || tree.sym.kind == Kinds.ERR) { + if (tree.sym.kind == TYP || tree.sym.kind == ERR) { ClassSymbol c = tree.sym; docenv.makeClassDoc(c, docenv.getTreePath(env.toplevel, tree)); } diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java --- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/JavadocMemberEnter.java Thu Oct 23 13:43:56 2014 -0700 @@ -27,7 +27,6 @@ import com.sun.source.util.TreePath; import com.sun.tools.javac.code.Flags; -import com.sun.tools.javac.code.Kinds; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.comp.MemberEnter; import com.sun.tools.javac.tree.JCTree; @@ -35,6 +34,7 @@ import com.sun.tools.javac.util.Context; import static com.sun.tools.javac.code.Flags.*; +import static com.sun.tools.javac.code.Kinds.Kind.*; /** * Javadoc's own memberEnter phase does a few things above and beyond that @@ -74,7 +74,7 @@ public void visitMethodDef(JCMethodDecl tree) { super.visitMethodDef(tree); MethodSymbol meth = tree.sym; - if (meth == null || meth.kind != Kinds.MTH) return; + if (meth == null || meth.kind != MTH) return; TreePath treePath = docenv.getTreePath(env.toplevel, env.enclClass, tree); if (meth.isConstructor()) docenv.makeConstructorDoc(meth, treePath); @@ -102,7 +102,7 @@ } super.visitVarDef(tree); if (tree.sym != null && - tree.sym.kind == Kinds.VAR && + tree.sym.kind == VAR && !isParameter(tree.sym)) { docenv.makeFieldDoc(tree.sym, docenv.getTreePath(env.toplevel, env.enclClass, tree)); } diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/SeeTagImpl.java --- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/SeeTagImpl.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/SeeTagImpl.java Thu Oct 23 13:43:56 2014 -0700 @@ -29,12 +29,13 @@ import java.util.Locale; import com.sun.javadoc.*; -import com.sun.tools.javac.code.Kinds; import com.sun.tools.javac.code.Printer; import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Type.CapturedType; import com.sun.tools.javac.util.*; +import static com.sun.tools.javac.code.Kinds.Kind.*; + /** * Represents a see also documentation tag. * The @see tag can be plain text, or reference a class or member. @@ -132,7 +133,7 @@ sb.append("+++ ").append(file).append(": ") .append(name()).append(" ").append(seetext).append(": "); sb.append(sym.getKind()).append(" "); - if (sym.kind == Kinds.MTH || sym.kind == Kinds.VAR) + if (sym.kind == MTH || sym.kind == VAR) sb.append(printer.visit(sym.owner, locale)).append("."); sb.append(printer.visit(sym, locale)); diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/SerializedForm.java --- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/SerializedForm.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/SerializedForm.java Thu Oct 23 13:43:56 2014 -0700 @@ -32,6 +32,7 @@ import com.sun.tools.javac.code.Symbol.VarSymbol; import com.sun.tools.javac.util.*; +import static com.sun.tools.javac.code.Kinds.Kind.*; import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE; /** @@ -158,7 +159,7 @@ * so must lookup by ClassSymbol, not by ClassDocImpl. */ for (Symbol sym : def.members().getSymbolsByName(names.fromString(SERIALIZABLE_FIELDS))) { - if (sym.kind == Kinds.VAR) { + if (sym.kind == VAR) { VarSymbol f = (VarSymbol)sym; if ((f.flags() & Flags.STATIC) != 0 && (f.flags() & Flags.PRIVATE) != 0) { @@ -179,7 +180,7 @@ ClassSymbol def, ClassDocImpl cd) { for (Symbol sym : def.members().getSymbols(NON_RECURSIVE)) { - if (sym != null && sym.kind == Kinds.VAR) { + if (sym != null && sym.kind == VAR) { VarSymbol f = (VarSymbol)sym; if ((f.flags() & Flags.STATIC) == 0 && (f.flags() & Flags.TRANSIENT) == 0) { @@ -208,7 +209,7 @@ Names names = def.name.table.names; for (Symbol sym : def.members().getSymbolsByName(names.fromString(methodName))) { - if (sym.kind == Kinds.MTH) { + if (sym.kind == MTH) { MethodSymbol md = (MethodSymbol)sym; if ((md.flags() & Flags.STATIC) == 0) { /* @@ -240,7 +241,7 @@ // Look for a FieldDocImpl that is documented by serialFieldTagImpl. for (Symbol sym : def.members().getSymbolsByName(fieldName)) { - if (sym.kind == Kinds.VAR) { + if (sym.kind == VAR) { VarSymbol f = (VarSymbol) sym; FieldDocImpl fdi = env.getFieldDoc(f); ((SerialFieldTagImpl) (tag)).mapToFieldDocImpl(fdi); diff -r 7994f6270587 -r 53be48209e41 langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java --- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/TypeVariableImpl.java Thu Oct 23 13:43:56 2014 -0700 @@ -30,6 +30,7 @@ import com.sun.tools.javac.code.Attribute; import com.sun.tools.javac.code.Attribute.TypeCompound; import com.sun.tools.javac.code.Kinds; +import com.sun.tools.javac.code.Kinds.KindSelector; import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Symbol.ClassSymbol; import com.sun.tools.javac.code.Symbol.MethodSymbol; @@ -70,7 +71,7 @@ */ public ProgramElementDoc owner() { Symbol osym = type.tsym.owner; - if ((osym.kind & Kinds.TYP) != 0) { + if (osym.kind.matches(KindSelector.TYP)) { return env.getClassDoc((ClassSymbol)osym); } Names names = osym.name.table.names; diff -r 7994f6270587 -r 53be48209e41 langtools/test/tools/javac/6889255/T6889255.java --- a/langtools/test/tools/javac/6889255/T6889255.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/test/tools/javac/6889255/T6889255.java Thu Oct 23 13:43:56 2014 -0700 @@ -31,7 +31,6 @@ import java.util.*; import javax.tools.StandardLocation; import com.sun.tools.javac.code.Flags; -import com.sun.tools.javac.code.Kinds; import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.code.Symtab; @@ -385,7 +384,7 @@ for (Symbol s : sym.members_field.getSymbols(NON_RECURSIVE)) { System.err.println("Checking member " + s); switch (s.kind) { - case Kinds.TYP: { + case TYP: { String name = s.flatName().toString(); if (!classes.contains(name)) { classes.add(name); @@ -393,7 +392,7 @@ } break; } - case Kinds.MTH: + case MTH: verify((MethodSymbol) s, expectNames); break; } diff -r 7994f6270587 -r 53be48209e41 langtools/test/tools/javac/T6725036.java diff -r 7994f6270587 -r 53be48209e41 langtools/test/tools/javac/api/6440528/T6440528.java diff -r 7994f6270587 -r 53be48209e41 langtools/test/tools/javac/file/T7018098.java diff -r 7994f6270587 -r 53be48209e41 langtools/test/tools/javac/file/T7068437.java diff -r 7994f6270587 -r 53be48209e41 langtools/test/tools/javac/file/T7068451.java diff -r 7994f6270587 -r 53be48209e41 langtools/test/tools/javac/lambda/T8057800/NPEMethodReferenceAndGenericsTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/lambda/T8057800/NPEMethodReferenceAndGenericsTest.java Thu Oct 23 13:43:56 2014 -0700 @@ -0,0 +1,39 @@ +/* + * 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 8057800 + * @summary Method reference with generic type creates NPE when compiling + * @compile NPEMethodReferenceAndGenericsTest.java + */ + +public class NPEMethodReferenceAndGenericsTest { + public void foo(java.util.Comparator comparator) {} + + public > void foo() { + foo(C::compareTo); + } +} diff -r 7994f6270587 -r 53be48209e41 langtools/test/tools/javac/processing/errors/CrashOnNonExistingAnnotation/Processor.java diff -r 7994f6270587 -r 53be48209e41 langtools/test/tools/javac/processing/errors/StopOnInapplicableAnnotations/Processor.java diff -r 7994f6270587 -r 53be48209e41 langtools/test/tools/javac/scope/HashCollisionTest.java --- a/langtools/test/tools/javac/scope/HashCollisionTest.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/test/tools/javac/scope/HashCollisionTest.java Thu Oct 23 13:43:56 2014 -0700 @@ -41,6 +41,8 @@ import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.file.JavacFileManager; +import static com.sun.tools.javac.code.Kinds.Kind.*; + public class HashCollisionTest { public static void main(String... args) throws Exception { new HashCollisionTest().run(); @@ -116,7 +118,7 @@ ImportFilter typeFilter = new ImportFilter() { @Override public boolean accepts(Scope origin, Symbol sym) { - return sym.kind == Kinds.TYP; + return sym.kind == TYP; } }; starImportScope.importAll(fromScope, fromScope, typeFilter, false); diff -r 7994f6270587 -r 53be48209e41 langtools/test/tools/javac/scope/StarImportTest.java --- a/langtools/test/tools/javac/scope/StarImportTest.java Thu Oct 23 11:19:28 2014 -0700 +++ b/langtools/test/tools/javac/scope/StarImportTest.java Thu Oct 23 13:43:56 2014 -0700 @@ -38,7 +38,7 @@ import com.sun.tools.javac.file.JavacFileManager; import com.sun.tools.javac.util.*; -import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Kinds.Kind.*; public class StarImportTest { public static void main(String... args) throws Exception { diff -r 7994f6270587 -r 53be48209e41 langtools/test/tools/javac/warnings/suppress/VerifySuppressWarnings.java diff -r 7994f6270587 -r 53be48209e41 langtools/test/tools/javap/WhitespaceTest.java