7098660: Write better overload resolution/inference tests

Mon, 24 Oct 2011 13:00:30 +0100

author
mcimadamore
date
Mon, 24 Oct 2011 13:00:30 +0100
changeset 1114
05814303a056
parent 1113
d346ab55031b
child 1115
b73a9be0b993

7098660: Write better overload resolution/inference tests
Summary: Add overload/inference debug diagnostics - added test harness using annotations to check outcome of overload resolution/inference
Reviewed-by: jjg

src/share/classes/com/sun/tools/javac/code/Printer.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/comp/Infer.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/comp/Resolve.java file | annotate | diff | comparison | revisions
src/share/classes/com/sun/tools/javac/resources/compiler.properties file | annotate | diff | comparison | revisions
test/tools/javac/diags/examples/ApplicableMethodFound.java file | annotate | diff | comparison | revisions
test/tools/javac/diags/examples/ApplicableMethodFound1.java file | annotate | diff | comparison | revisions
test/tools/javac/diags/examples/DeferredMethodInst.java file | annotate | diff | comparison | revisions
test/tools/javac/diags/examples/FullInstSig.java file | annotate | diff | comparison | revisions
test/tools/javac/diags/examples/NotApplicableMethodFound.java file | annotate | diff | comparison | revisions
test/tools/javac/diags/examples/PartialInstSig.java file | annotate | diff | comparison | revisions
test/tools/javac/diags/examples/VerboseResolveMulti.java file | annotate | diff | comparison | revisions
test/tools/javac/diags/examples/VerboseResolveMulti1.java file | annotate | diff | comparison | revisions
test/tools/javac/resolve/Candidate.java file | annotate | diff | comparison | revisions
test/tools/javac/resolve/Pos.java file | annotate | diff | comparison | revisions
test/tools/javac/resolve/ResolveHarness.java file | annotate | diff | comparison | revisions
test/tools/javac/resolve/TraceResolve.java file | annotate | diff | comparison | revisions
test/tools/javac/resolve/tests/BoxedReturnTypeInference.java file | annotate | diff | comparison | revisions
test/tools/javac/resolve/tests/PrimitiveOverReferenceOverInferred.java file | annotate | diff | comparison | revisions
test/tools/javac/resolve/tests/PrimitiveOverReferenceOverVarargs.java file | annotate | diff | comparison | revisions
test/tools/javac/resolve/tests/PrimitiveOverReferenceVarargsAmbiguous.java file | annotate | diff | comparison | revisions
test/tools/javac/resolve/tests/PrimitiveOverload.java file | annotate | diff | comparison | revisions
test/tools/javac/resolve/tests/PrimitiveReturnTypeInference.java file | annotate | diff | comparison | revisions
test/tools/javac/resolve/tests/ReferenceOverInferred.java file | annotate | diff | comparison | revisions
test/tools/javac/resolve/tests/ReferenceOverVarargs.java file | annotate | diff | comparison | revisions
test/tools/javac/resolve/tests/ReferenceOverload.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/classes/com/sun/tools/javac/code/Printer.java	Mon Oct 24 13:00:20 2011 +0100
     1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Printer.java	Mon Oct 24 13:00:30 2011 +0100
     1.3 @@ -258,7 +258,7 @@
     1.4              ClassType norm = (ClassType) t.tsym.type;
     1.5              if (norm == null) {
     1.6                  s = localize(locale, "compiler.misc.anonymous.class", (Object) null);
     1.7 -            } else if (norm.interfaces_field.nonEmpty()) {
     1.8 +            } else if (norm.interfaces_field != null && norm.interfaces_field.nonEmpty()) {
     1.9                  s = localize(locale, "compiler.misc.anonymous.class",
    1.10                          visit(norm.interfaces_field.head, locale));
    1.11              } else {
     2.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java	Mon Oct 24 13:00:20 2011 +0100
     2.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java	Mon Oct 24 13:00:30 2011 +0100
     2.3 @@ -34,7 +34,8 @@
     2.4  import com.sun.tools.javac.code.Type.*;
     2.5  import com.sun.tools.javac.code.Type.ForAll.ConstraintKind;
     2.6  import com.sun.tools.javac.code.Symbol.*;
     2.7 -import com.sun.tools.javac.util.JCDiagnostic;
     2.8 +import com.sun.tools.javac.comp.Resolve.VerboseResolutionMode;
     2.9 +import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
    2.10  
    2.11  import static com.sun.tools.javac.code.TypeTags.*;
    2.12  
    2.13 @@ -56,6 +57,7 @@
    2.14      Types types;
    2.15      Check chk;
    2.16      Resolve rs;
    2.17 +    Log log;
    2.18      JCDiagnostic.Factory diags;
    2.19  
    2.20      public static Infer instance(Context context) {
    2.21 @@ -70,6 +72,7 @@
    2.22          syms = Symtab.instance(context);
    2.23          types = Types.instance(context);
    2.24          rs = Resolve.instance(context);
    2.25 +        log = Log.instance(context);
    2.26          chk = Check.instance(context);
    2.27          diags = JCDiagnostic.Factory.instance(context);
    2.28          ambiguousNoInstanceException =
    2.29 @@ -460,7 +463,7 @@
    2.30              // quantify result type with them
    2.31              final List<Type> inferredTypes = insttypes.toList();
    2.32              final List<Type> all_tvars = tvars; //this is the wrong tvars
    2.33 -            return new UninferredMethodType(mt, restvars.toList()) {
    2.34 +            return new UninferredMethodType(env.tree.pos(), msym, mt, restvars.toList()) {
    2.35                  @Override
    2.36                  List<Type> getConstraints(TypeVar tv, ConstraintKind ck) {
    2.37                      for (Type t : restundet.toList()) {
    2.38 @@ -502,13 +505,17 @@
    2.39           * type - when the return type is instantiated (see Infer.instantiateExpr)
    2.40           * the underlying method type is also updated.
    2.41           */
    2.42 -        static abstract class UninferredMethodType extends DelegatedType {
    2.43 +        abstract class UninferredMethodType extends DelegatedType {
    2.44  
    2.45              final List<Type> tvars;
    2.46 +            final Symbol msym;
    2.47 +            final DiagnosticPosition pos;
    2.48  
    2.49 -            public UninferredMethodType(MethodType mtype, List<Type> tvars) {
    2.50 +            public UninferredMethodType(DiagnosticPosition pos, Symbol msym, MethodType mtype, List<Type> tvars) {
    2.51                  super(METHOD, new MethodType(mtype.argtypes, null, mtype.thrown, mtype.tsym));
    2.52                  this.tvars = tvars;
    2.53 +                this.msym = msym;
    2.54 +                this.pos = pos;
    2.55                  asMethodType().restype = new UninferredReturnType(tvars, mtype.restype);
    2.56              }
    2.57  
    2.58 @@ -543,6 +550,9 @@
    2.59                  public Type inst(List<Type> actuals, Types types) {
    2.60                      Type newRestype = super.inst(actuals, types);
    2.61                      instantiateReturnType(newRestype, actuals, types);
    2.62 +                    if (rs.verboseResolutionMode.contains(VerboseResolutionMode.DEFERRED_INST)) {
    2.63 +                        log.note(pos, "deferred.method.inst", msym, UninferredMethodType.this.qtype, newRestype);
    2.64 +                    }
    2.65                      return newRestype;
    2.66                  }
    2.67                  @Override
     3.1 --- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Mon Oct 24 13:00:20 2011 +0100
     3.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java	Mon Oct 24 13:00:30 2011 +0100
     3.3 @@ -25,29 +25,33 @@
     3.4  
     3.5  package com.sun.tools.javac.comp;
     3.6  
     3.7 -import com.sun.tools.javac.util.*;
     3.8 -import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
     3.9 +import com.sun.tools.javac.api.Formattable.LocalizedString;
    3.10  import com.sun.tools.javac.code.*;
    3.11 +import com.sun.tools.javac.code.Type.*;
    3.12 +import com.sun.tools.javac.code.Symbol.*;
    3.13  import com.sun.tools.javac.jvm.*;
    3.14  import com.sun.tools.javac.tree.*;
    3.15 -import com.sun.tools.javac.api.Formattable.LocalizedString;
    3.16 -import static com.sun.tools.javac.comp.Resolve.MethodResolutionPhase.*;
    3.17 +import com.sun.tools.javac.tree.JCTree.*;
    3.18 +import com.sun.tools.javac.util.*;
    3.19 +import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
    3.20 +import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
    3.21 +import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType;
    3.22  
    3.23 -import com.sun.tools.javac.code.Type.*;
    3.24 -import com.sun.tools.javac.code.Symbol.*;
    3.25 -import com.sun.tools.javac.tree.JCTree.*;
    3.26 +import java.util.Arrays;
    3.27 +import java.util.Collection;
    3.28 +import java.util.EnumSet;
    3.29 +import java.util.HashMap;
    3.30 +import java.util.HashSet;
    3.31 +import java.util.LinkedHashMap;
    3.32 +import java.util.Map;
    3.33 +import java.util.Set;
    3.34 +
    3.35 +import javax.lang.model.element.ElementVisitor;
    3.36  
    3.37  import static com.sun.tools.javac.code.Flags.*;
    3.38  import static com.sun.tools.javac.code.Kinds.*;
    3.39  import static com.sun.tools.javac.code.TypeTags.*;
    3.40 -import com.sun.tools.javac.util.JCDiagnostic.DiagnosticFlag;
    3.41 -import com.sun.tools.javac.util.JCDiagnostic.DiagnosticType;
    3.42 -import javax.lang.model.element.ElementVisitor;
    3.43 -
    3.44 -import java.util.Map;
    3.45 -import java.util.Set;
    3.46 -import java.util.HashMap;
    3.47 -import java.util.HashSet;
    3.48 +import static com.sun.tools.javac.comp.Resolve.MethodResolutionPhase.*;
    3.49  
    3.50  /** Helper class for name resolution, used mostly by the attribution phase.
    3.51   *
    3.52 @@ -73,9 +77,45 @@
    3.53      public final boolean varargsEnabled; // = source.allowVarargs();
    3.54      public final boolean allowMethodHandles;
    3.55      private final boolean debugResolve;
    3.56 +    final EnumSet<VerboseResolutionMode> verboseResolutionMode;
    3.57  
    3.58      Scope polymorphicSignatureScope;
    3.59  
    3.60 +    enum VerboseResolutionMode {
    3.61 +        SUCCESS("success"),
    3.62 +        FAILURE("failure"),
    3.63 +        APPLICABLE("applicable"),
    3.64 +        INAPPLICABLE("inapplicable"),
    3.65 +        DEFERRED_INST("deferred-inference"),
    3.66 +        PREDEF("predef"),
    3.67 +        OBJECT_INIT("object-init"),
    3.68 +        INTERNAL("internal");
    3.69 +
    3.70 +        String opt;
    3.71 +
    3.72 +        private VerboseResolutionMode(String opt) {
    3.73 +            this.opt = opt;
    3.74 +        }
    3.75 +
    3.76 +        static EnumSet<VerboseResolutionMode> getVerboseResolutionMode(Options opts) {
    3.77 +            String s = opts.get("verboseResolution");
    3.78 +            EnumSet<VerboseResolutionMode> res = EnumSet.noneOf(VerboseResolutionMode.class);
    3.79 +            if (s == null) return res;
    3.80 +            if (s.contains("all")) {
    3.81 +                res = EnumSet.allOf(VerboseResolutionMode.class);
    3.82 +            }
    3.83 +            Collection<String> args = Arrays.asList(s.split(","));
    3.84 +            for (VerboseResolutionMode mode : values()) {
    3.85 +                if (args.contains(mode.opt)) {
    3.86 +                    res.add(mode);
    3.87 +                } else if (args.contains("-" + mode.opt)) {
    3.88 +                    res.remove(mode);
    3.89 +                }
    3.90 +            }
    3.91 +            return res;
    3.92 +        }
    3.93 +    }
    3.94 +
    3.95      public static Resolve instance(Context context) {
    3.96          Resolve instance = context.get(resolveKey);
    3.97          if (instance == null)
    3.98 @@ -111,6 +151,7 @@
    3.99          varargsEnabled = source.allowVarargs();
   3.100          Options options = Options.instance(context);
   3.101          debugResolve = options.isSet("debugresolve");
   3.102 +        verboseResolutionMode = VerboseResolutionMode.getVerboseResolutionMode(options);
   3.103          Target target = Target.instance(context);
   3.104          allowMethodHandles = target.hasMethodHandles();
   3.105          polymorphicSignatureScope = new Scope(syms.noSymbol);
   3.106 @@ -684,9 +725,11 @@
   3.107          if (!sym.isInheritedIn(site.tsym, types)) return bestSoFar;
   3.108          Assert.check(sym.kind < AMBIGUOUS);
   3.109          try {
   3.110 -            rawInstantiate(env, site, sym, argtypes, typeargtypes,
   3.111 +            Type mt = rawInstantiate(env, site, sym, argtypes, typeargtypes,
   3.112                                 allowBoxing, useVarargs, Warner.noWarnings);
   3.113 +            if (!operator) addVerboseApplicableCandidateDiag(sym ,mt);
   3.114          } catch (InapplicableMethodException ex) {
   3.115 +            if (!operator) addVerboseInapplicableCandidateDiag(sym, ex.getDiagnostic());
   3.116              switch (bestSoFar.kind) {
   3.117              case ABSENT_MTH:
   3.118                  return wrongMethod.setWrongSym(sym, ex.getDiagnostic());
   3.119 @@ -709,6 +752,34 @@
   3.120              : mostSpecific(sym, bestSoFar, env, site,
   3.121                             allowBoxing && operator, useVarargs);
   3.122      }
   3.123 +    //where
   3.124 +        void addVerboseApplicableCandidateDiag(Symbol sym, Type inst) {
   3.125 +            if (!verboseResolutionMode.contains(VerboseResolutionMode.APPLICABLE))
   3.126 +                return;
   3.127 +
   3.128 +            JCDiagnostic subDiag = null;
   3.129 +            if (inst.getReturnType().tag == FORALL) {
   3.130 +                Type diagType = types.createMethodTypeWithReturn(inst.asMethodType(),
   3.131 +                                                                ((ForAll)inst.getReturnType()).qtype);
   3.132 +                subDiag = diags.fragment("partial.inst.sig", diagType);
   3.133 +            } else if (sym.type.tag == FORALL) {
   3.134 +                subDiag = diags.fragment("full.inst.sig", inst.asMethodType());
   3.135 +            }
   3.136 +
   3.137 +            String key = subDiag == null ?
   3.138 +                    "applicable.method.found" :
   3.139 +                    "applicable.method.found.1";
   3.140 +
   3.141 +            verboseResolutionCandidateDiags.put(sym,
   3.142 +                    diags.fragment(key, verboseResolutionCandidateDiags.size(), sym, subDiag));
   3.143 +        }
   3.144 +
   3.145 +        void addVerboseInapplicableCandidateDiag(Symbol sym, JCDiagnostic subDiag) {
   3.146 +            if (!verboseResolutionMode.contains(VerboseResolutionMode.INAPPLICABLE))
   3.147 +                return;
   3.148 +            verboseResolutionCandidateDiags.put(sym,
   3.149 +                    diags.fragment("not.applicable.method.found", verboseResolutionCandidateDiags.size(), sym, subDiag));
   3.150 +        }
   3.151  
   3.152      /* Return the most specific of the two methods for a call,
   3.153       *  given that both are accessible and applicable.
   3.154 @@ -906,8 +977,9 @@
   3.155                        boolean allowBoxing,
   3.156                        boolean useVarargs,
   3.157                        boolean operator) {
   3.158 +        verboseResolutionCandidateDiags.clear();
   3.159          Symbol bestSoFar = methodNotFound;
   3.160 -        return findMethod(env,
   3.161 +        bestSoFar = findMethod(env,
   3.162                            site,
   3.163                            name,
   3.164                            argtypes,
   3.165 @@ -919,6 +991,8 @@
   3.166                            useVarargs,
   3.167                            operator,
   3.168                            new HashSet<TypeSymbol>());
   3.169 +        reportVerboseResolutionDiagnostic(env.tree.pos(), name, site, argtypes, typeargtypes, bestSoFar);
   3.170 +        return bestSoFar;
   3.171      }
   3.172      // where
   3.173      private Symbol findMethod(Env<AttrContext> env,
   3.174 @@ -976,6 +1050,37 @@
   3.175          }
   3.176          return bestSoFar;
   3.177      }
   3.178 +    //where
   3.179 +        void reportVerboseResolutionDiagnostic(DiagnosticPosition dpos, Name name, Type site, List<Type> argtypes, List<Type> typeargtypes, Symbol bestSoFar) {
   3.180 +            boolean success = bestSoFar.kind < ERRONEOUS;
   3.181 +
   3.182 +            if (success && !verboseResolutionMode.contains(VerboseResolutionMode.SUCCESS)) {
   3.183 +                return;
   3.184 +            } else if (!success && !verboseResolutionMode.contains(VerboseResolutionMode.FAILURE)) {
   3.185 +                return;
   3.186 +            }
   3.187 +
   3.188 +            if (bestSoFar.name == names.init &&
   3.189 +                    bestSoFar.owner == syms.objectType.tsym &&
   3.190 +                    !verboseResolutionMode.contains(VerboseResolutionMode.OBJECT_INIT)) {
   3.191 +                return; //skip diags for Object constructor resolution
   3.192 +            } else if (site == syms.predefClass.type && !verboseResolutionMode.contains(VerboseResolutionMode.PREDEF)) {
   3.193 +                return; //skip spurious diags for predef symbols (i.e. operators)
   3.194 +            } else if (internalResolution && !verboseResolutionMode.contains(VerboseResolutionMode.INTERNAL)) {
   3.195 +                return;
   3.196 +            }
   3.197 +
   3.198 +            int pos = 0;
   3.199 +            for (Symbol s : verboseResolutionCandidateDiags.keySet()) {
   3.200 +                if (s == bestSoFar) break;
   3.201 +                pos++;
   3.202 +            }
   3.203 +            String key = success ? "verbose.resolve.multi" : "verbose.resolve.multi.1";
   3.204 +            JCDiagnostic main = diags.note(log.currentSource(), dpos, key, name, site.tsym, pos, currentStep,
   3.205 +                    methodArguments(argtypes), methodArguments(typeargtypes));
   3.206 +            JCDiagnostic d = new JCDiagnostic.MultilineDiagnostic(main, List.from(verboseResolutionCandidateDiags.values().toArray(new JCDiagnostic[verboseResolutionCandidateDiags.size()])));
   3.207 +            log.report(d);
   3.208 +        }
   3.209  
   3.210      /** Find unqualified method matching given name, type and value arguments.
   3.211       *  @param env       The current environment.
   3.212 @@ -1544,12 +1649,19 @@
   3.213                                          Type site, Name name,
   3.214                                          List<Type> argtypes,
   3.215                                          List<Type> typeargtypes) {
   3.216 -        Symbol sym = resolveQualifiedMethod(
   3.217 -            pos, env, site.tsym, site, name, argtypes, typeargtypes);
   3.218 -        if (sym.kind == MTH) return (MethodSymbol)sym;
   3.219 -        else throw new FatalError(
   3.220 -                 diags.fragment("fatal.err.cant.locate.meth",
   3.221 -                                name));
   3.222 +        boolean prevInternal = internalResolution;
   3.223 +        try {
   3.224 +            internalResolution = true;
   3.225 +            Symbol sym = resolveQualifiedMethod(
   3.226 +                pos, env, site.tsym, site, name, argtypes, typeargtypes);
   3.227 +            if (sym.kind == MTH) return (MethodSymbol)sym;
   3.228 +            else throw new FatalError(
   3.229 +                     diags.fragment("fatal.err.cant.locate.meth",
   3.230 +                                    name));
   3.231 +        }
   3.232 +        finally {
   3.233 +            internalResolution = prevInternal;
   3.234 +        }
   3.235      }
   3.236  
   3.237      /** Resolve constructor.
   3.238 @@ -1830,7 +1942,7 @@
   3.239      private final LocalizedString noArgs = new LocalizedString("compiler.misc.no.args");
   3.240  
   3.241      public Object methodArguments(List<Type> argtypes) {
   3.242 -        return argtypes.isEmpty() ? noArgs : argtypes;
   3.243 +        return argtypes == null || argtypes.isEmpty() ? noArgs : argtypes;
   3.244      }
   3.245  
   3.246      /**
   3.247 @@ -2377,10 +2489,15 @@
   3.248      private Map<MethodResolutionPhase, Symbol> methodResolutionCache =
   3.249          new HashMap<MethodResolutionPhase, Symbol>(MethodResolutionPhase.values().length);
   3.250  
   3.251 +    private Map<Symbol, JCDiagnostic> verboseResolutionCandidateDiags =
   3.252 +        new LinkedHashMap<Symbol, JCDiagnostic>();
   3.253 +
   3.254      final List<MethodResolutionPhase> methodResolutionSteps = List.of(BASIC, BOX, VARARITY);
   3.255  
   3.256      private MethodResolutionPhase currentStep = null;
   3.257  
   3.258 +    private boolean internalResolution = false;
   3.259 +
   3.260      private MethodResolutionPhase firstErroneousResolutionPhase() {
   3.261          MethodResolutionPhase bestSoFar = BASIC;
   3.262          Symbol sym = methodNotFound;
     4.1 --- a/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Mon Oct 24 13:00:20 2011 +0100
     4.2 +++ b/src/share/classes/com/sun/tools/javac/resources/compiler.properties	Mon Oct 24 13:00:30 2011 +0100
     4.3 @@ -1944,6 +1944,55 @@
     4.4      (use -source 7 or higher to enable strings in switch)
     4.5  
     4.6  ########################################
     4.7 +# Diagnostics for verbose resolution
     4.8 +# used by Resolve (debug only)
     4.9 +########################################
    4.10 +
    4.11 +# 0: number, 1: symbol, 2: unused
    4.12 +compiler.misc.applicable.method.found=\
    4.13 +    #{0} applicable method found: {1}
    4.14 +
    4.15 +# 0: number, 1: symbol, 2: message segment
    4.16 +compiler.misc.applicable.method.found.1=\
    4.17 +    #{0} applicable method found: {1}\n\
    4.18 +    ({2})
    4.19 +
    4.20 +# 0: number, 1: symbol, 2: message segment
    4.21 +compiler.misc.not.applicable.method.found=\
    4.22 +    #{0} not applicable method found: {1}\n\
    4.23 +    ({2})
    4.24 +
    4.25 +# 0: type
    4.26 +compiler.misc.full.inst.sig=\
    4.27 +    fully instantiated to: {0}
    4.28 +
    4.29 +# 0: type
    4.30 +compiler.misc.partial.inst.sig=\
    4.31 +    partially instantiated to: {0}
    4.32 +
    4.33 +# 0: name, 1: symbol, 2: number, 3: MethodResolutionPhase, 4: list of type or message segment, 5: list of type or message segment
    4.34 +compiler.note.verbose.resolve.multi=\
    4.35 +    resolving method {0} in type {1} to candidate {2}\n\
    4.36 +    phase: {3}\n\
    4.37 +    with actuals: {4}\n\
    4.38 +    with type-args: {5}\n\
    4.39 +    candidates:
    4.40 +
    4.41 +# 0: name, 1: symbol, 2: unused, 3: MethodResolutionPhase, 4: list of type or message segment, 5: list of type or message segment
    4.42 +compiler.note.verbose.resolve.multi.1=\
    4.43 +    erroneous resolution for method {0} in type {1}\n\
    4.44 +    phase: {3}\n\
    4.45 +    with actuals: {4}\n\
    4.46 +    with type-args: {5}\n\
    4.47 +    candidates:
    4.48 +
    4.49 +# 0: symbol, 1: type, 2: type
    4.50 +compiler.note.deferred.method.inst=\
    4.51 +    Deferred instantiation of method {0}\n\
    4.52 +    instantiated signature: {1}\n\
    4.53 +    target-type: {2}
    4.54 +
    4.55 +########################################
    4.56  # Diagnostics for where clause implementation
    4.57  # used by the RichDiagnosticFormatter.
    4.58  ########################################
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/test/tools/javac/diags/examples/ApplicableMethodFound.java	Mon Oct 24 13:00:30 2011 +0100
     5.3 @@ -0,0 +1,33 @@
     5.4 +/*
     5.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
     5.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.7 + *
     5.8 + * This code is free software; you can redistribute it and/or modify it
     5.9 + * under the terms of the GNU General Public License version 2 only, as
    5.10 + * published by the Free Software Foundation.
    5.11 + *
    5.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    5.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    5.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    5.15 + * version 2 for more details (a copy is included in the LICENSE file that
    5.16 + * accompanied this code).
    5.17 + *
    5.18 + * You should have received a copy of the GNU General Public License version
    5.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    5.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    5.21 + *
    5.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    5.23 + * or visit www.oracle.com if you need additional information or have any
    5.24 + * questions.
    5.25 + */
    5.26 +
    5.27 +// key: compiler.misc.applicable.method.found
    5.28 +// key: compiler.note.verbose.resolve.multi
    5.29 +// options: -XDverboseResolution=applicable,success
    5.30 +
    5.31 +class ApplicableMethodFound {
    5.32 +
    5.33 +    void m() {}
    5.34 +
    5.35 +    { m(); }
    5.36 +}
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/test/tools/javac/diags/examples/ApplicableMethodFound1.java	Mon Oct 24 13:00:30 2011 +0100
     6.3 @@ -0,0 +1,34 @@
     6.4 +/*
     6.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
     6.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.7 + *
     6.8 + * This code is free software; you can redistribute it and/or modify it
     6.9 + * under the terms of the GNU General Public License version 2 only, as
    6.10 + * published by the Free Software Foundation.
    6.11 + *
    6.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    6.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    6.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    6.15 + * version 2 for more details (a copy is included in the LICENSE file that
    6.16 + * accompanied this code).
    6.17 + *
    6.18 + * You should have received a copy of the GNU General Public License version
    6.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    6.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    6.21 + *
    6.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    6.23 + * or visit www.oracle.com if you need additional information or have any
    6.24 + * questions.
    6.25 + */
    6.26 +
    6.27 +// key: compiler.misc.applicable.method.found.1
    6.28 +// key: compiler.note.verbose.resolve.multi
    6.29 +// key: compiler.misc.full.inst.sig
    6.30 +// options: -XDverboseResolution=applicable,success
    6.31 +
    6.32 +class ApplicableMethodFound1 {
    6.33 +
    6.34 +    <X> void m(X x) {}
    6.35 +
    6.36 +    { m(1); }
    6.37 +}
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/test/tools/javac/diags/examples/DeferredMethodInst.java	Mon Oct 24 13:00:30 2011 +0100
     7.3 @@ -0,0 +1,35 @@
     7.4 +/*
     7.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
     7.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.7 + *
     7.8 + * This code is free software; you can redistribute it and/or modify it
     7.9 + * under the terms of the GNU General Public License version 2 only, as
    7.10 + * published by the Free Software Foundation.
    7.11 + *
    7.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    7.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    7.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    7.15 + * version 2 for more details (a copy is included in the LICENSE file that
    7.16 + * accompanied this code).
    7.17 + *
    7.18 + * You should have received a copy of the GNU General Public License version
    7.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    7.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    7.21 + *
    7.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    7.23 + * or visit www.oracle.com if you need additional information or have any
    7.24 + * questions.
    7.25 + */
    7.26 +
    7.27 +// key: compiler.misc.applicable.method.found.1
    7.28 +// key: compiler.note.verbose.resolve.multi
    7.29 +// key: compiler.note.deferred.method.inst
    7.30 +// key: compiler.misc.partial.inst.sig
    7.31 +// options: -XDverboseResolution=applicable,success,deferred-inference
    7.32 +
    7.33 +class DeferredMethodInst {
    7.34 +
    7.35 +    <X> X m() { return null; }
    7.36 +
    7.37 +    { Integer i = m(); }
    7.38 +}
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/test/tools/javac/diags/examples/FullInstSig.java	Mon Oct 24 13:00:30 2011 +0100
     8.3 @@ -0,0 +1,34 @@
     8.4 +/*
     8.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
     8.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     8.7 + *
     8.8 + * This code is free software; you can redistribute it and/or modify it
     8.9 + * under the terms of the GNU General Public License version 2 only, as
    8.10 + * published by the Free Software Foundation.
    8.11 + *
    8.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    8.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    8.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    8.15 + * version 2 for more details (a copy is included in the LICENSE file that
    8.16 + * accompanied this code).
    8.17 + *
    8.18 + * You should have received a copy of the GNU General Public License version
    8.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    8.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    8.21 + *
    8.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    8.23 + * or visit www.oracle.com if you need additional information or have any
    8.24 + * questions.
    8.25 + */
    8.26 +
    8.27 +// key: compiler.misc.applicable.method.found.1
    8.28 +// key: compiler.note.verbose.resolve.multi
    8.29 +// key: compiler.misc.full.inst.sig
    8.30 +// options: -XDverboseResolution=applicable,success
    8.31 +
    8.32 +class FullInstSig {
    8.33 +
    8.34 +    <X> void m(X x) {}
    8.35 +
    8.36 +    { m(1); }
    8.37 +}
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/test/tools/javac/diags/examples/NotApplicableMethodFound.java	Mon Oct 24 13:00:30 2011 +0100
     9.3 @@ -0,0 +1,35 @@
     9.4 +/*
     9.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
     9.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     9.7 + *
     9.8 + * This code is free software; you can redistribute it and/or modify it
     9.9 + * under the terms of the GNU General Public License version 2 only, as
    9.10 + * published by the Free Software Foundation.
    9.11 + *
    9.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    9.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    9.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    9.15 + * version 2 for more details (a copy is included in the LICENSE file that
    9.16 + * accompanied this code).
    9.17 + *
    9.18 + * You should have received a copy of the GNU General Public License version
    9.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    9.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    9.21 + *
    9.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    9.23 + * or visit www.oracle.com if you need additional information or have any
    9.24 + * questions.
    9.25 + */
    9.26 +
    9.27 +// key: compiler.misc.not.applicable.method.found
    9.28 +// key: compiler.note.verbose.resolve.multi.1
    9.29 +// key: compiler.err.cant.apply.symbol.1
    9.30 +// key: compiler.misc.no.conforming.assignment.exists
    9.31 +// options: -XDverboseResolution=inapplicable,failure
    9.32 +
    9.33 +class NotApplicableMethodFound {
    9.34 +
    9.35 +    void m(int i) {}
    9.36 +
    9.37 +    { m(""); }
    9.38 +}
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/test/tools/javac/diags/examples/PartialInstSig.java	Mon Oct 24 13:00:30 2011 +0100
    10.3 @@ -0,0 +1,34 @@
    10.4 +/*
    10.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    10.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    10.7 + *
    10.8 + * This code is free software; you can redistribute it and/or modify it
    10.9 + * under the terms of the GNU General Public License version 2 only, as
   10.10 + * published by the Free Software Foundation.
   10.11 + *
   10.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   10.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   10.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   10.15 + * version 2 for more details (a copy is included in the LICENSE file that
   10.16 + * accompanied this code).
   10.17 + *
   10.18 + * You should have received a copy of the GNU General Public License version
   10.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   10.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   10.21 + *
   10.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   10.23 + * or visit www.oracle.com if you need additional information or have any
   10.24 + * questions.
   10.25 + */
   10.26 +
   10.27 +// key: compiler.misc.applicable.method.found.1
   10.28 +// key: compiler.note.verbose.resolve.multi
   10.29 +// key: compiler.misc.partial.inst.sig
   10.30 +// options: -XDverboseResolution=applicable,success
   10.31 +
   10.32 +class PartialInstSig {
   10.33 +
   10.34 +    <X> X m() { return null; }
   10.35 +
   10.36 +    { m(); }
   10.37 +}
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/test/tools/javac/diags/examples/VerboseResolveMulti.java	Mon Oct 24 13:00:30 2011 +0100
    11.3 @@ -0,0 +1,33 @@
    11.4 +/*
    11.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    11.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    11.7 + *
    11.8 + * This code is free software; you can redistribute it and/or modify it
    11.9 + * under the terms of the GNU General Public License version 2 only, as
   11.10 + * published by the Free Software Foundation.
   11.11 + *
   11.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   11.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   11.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   11.15 + * version 2 for more details (a copy is included in the LICENSE file that
   11.16 + * accompanied this code).
   11.17 + *
   11.18 + * You should have received a copy of the GNU General Public License version
   11.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   11.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   11.21 + *
   11.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   11.23 + * or visit www.oracle.com if you need additional information or have any
   11.24 + * questions.
   11.25 + */
   11.26 +
   11.27 +// key: compiler.misc.applicable.method.found
   11.28 +// key: compiler.note.verbose.resolve.multi
   11.29 +// options: -XDverboseResolution=applicable,success
   11.30 +
   11.31 +class VerboseResolveMulti {
   11.32 +
   11.33 +    void m() {}
   11.34 +
   11.35 +    { m(); }
   11.36 +}
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/test/tools/javac/diags/examples/VerboseResolveMulti1.java	Mon Oct 24 13:00:30 2011 +0100
    12.3 @@ -0,0 +1,35 @@
    12.4 +/*
    12.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    12.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    12.7 + *
    12.8 + * This code is free software; you can redistribute it and/or modify it
    12.9 + * under the terms of the GNU General Public License version 2 only, as
   12.10 + * published by the Free Software Foundation.
   12.11 + *
   12.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   12.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   12.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   12.15 + * version 2 for more details (a copy is included in the LICENSE file that
   12.16 + * accompanied this code).
   12.17 + *
   12.18 + * You should have received a copy of the GNU General Public License version
   12.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   12.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   12.21 + *
   12.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   12.23 + * or visit www.oracle.com if you need additional information or have any
   12.24 + * questions.
   12.25 + */
   12.26 +
   12.27 +// key: compiler.misc.not.applicable.method.found
   12.28 +// key: compiler.note.verbose.resolve.multi.1
   12.29 +// key: compiler.err.cant.apply.symbol.1
   12.30 +// key: compiler.misc.no.conforming.assignment.exists
   12.31 +// options: -XDverboseResolution=inapplicable,failure
   12.32 +
   12.33 +class VerboseResolveMulti1 {
   12.34 +
   12.35 +    void m(int i) {}
   12.36 +
   12.37 +    { m(""); }
   12.38 +}
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/test/tools/javac/resolve/Candidate.java	Mon Oct 24 13:00:30 2011 +0100
    13.3 @@ -0,0 +1,68 @@
    13.4 +/*
    13.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    13.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    13.7 + *
    13.8 + * This code is free software; you can redistribute it and/or modify it
    13.9 + * under the terms of the GNU General Public License version 2 only, as
   13.10 + * published by the Free Software Foundation.
   13.11 + *
   13.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   13.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   13.15 + * version 2 for more details (a copy is included in the LICENSE file that
   13.16 + * accompanied this code).
   13.17 + *
   13.18 + * You should have received a copy of the GNU General Public License version
   13.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   13.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   13.21 + *
   13.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   13.23 + * or visit www.oracle.com if you need additional information or have any
   13.24 + * questions.
   13.25 + */
   13.26 +import java.lang.annotation.ElementType;
   13.27 +import java.lang.annotation.Target;
   13.28 +
   13.29 +@Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
   13.30 +@interface Candidate {
   13.31 +    /**
   13.32 +     * the candidate position (line/col of the method call for which this candidate
   13.33 +     * is a potential overload candidate)
   13.34 +     */
   13.35 +    Pos pos() default @Pos(userDefined=false);
   13.36 +    /**
   13.37 +     * resolution phases for which this candidate is applicable
   13.38 +     */
   13.39 +    Phase[] applicable() default { };
   13.40 +    /**
   13.41 +     * is this candidate the most specific (in the resolution phases for which it
   13.42 +     * is also applicable)
   13.43 +     */
   13.44 +    boolean mostSpecific() default false;
   13.45 +    /**
   13.46 +     * this candidate inferred signature (in the resolution phases for which it
   13.47 +     * is also applicable, in case it corresponds to a generic method)
   13.48 +     */
   13.49 +    String sig() default "";
   13.50 +}
   13.51 +
   13.52 +enum Phase {
   13.53 +    BASIC("BASIC"),
   13.54 +    BOX("BOX"),
   13.55 +    VARARGS("VARARITY");
   13.56 +
   13.57 +    final String javacString;
   13.58 +
   13.59 +    private Phase(String javacString) {
   13.60 +        this.javacString = javacString;
   13.61 +    }
   13.62 +
   13.63 +    static Phase fromString(String s) {
   13.64 +        for (Phase phase : Phase.values()) {
   13.65 +            if (phase.javacString.equals(s)) {
   13.66 +                return phase;
   13.67 +            }
   13.68 +        }
   13.69 +        throw new AssertionError("Invalid resolution phase string " + s);
   13.70 +    }
   13.71 +}
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/test/tools/javac/resolve/Pos.java	Mon Oct 24 13:00:30 2011 +0100
    14.3 @@ -0,0 +1,31 @@
    14.4 +/*
    14.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    14.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    14.7 + *
    14.8 + * This code is free software; you can redistribute it and/or modify it
    14.9 + * under the terms of the GNU General Public License version 2 only, as
   14.10 + * published by the Free Software Foundation.
   14.11 + *
   14.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   14.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   14.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14.15 + * version 2 for more details (a copy is included in the LICENSE file that
   14.16 + * accompanied this code).
   14.17 + *
   14.18 + * You should have received a copy of the GNU General Public License version
   14.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   14.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   14.21 + *
   14.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   14.23 + * or visit www.oracle.com if you need additional information or have any
   14.24 + * questions.
   14.25 + */
   14.26 +import java.lang.annotation.ElementType;
   14.27 +import java.lang.annotation.Target;
   14.28 +
   14.29 +@Target(ElementType.ANNOTATION_TYPE)
   14.30 +@interface Pos {
   14.31 +    long line() default -1;
   14.32 +    long col() default -1;
   14.33 +    boolean userDefined() default true;
   14.34 +}
   14.35 \ No newline at end of file
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/test/tools/javac/resolve/ResolveHarness.java	Mon Oct 24 13:00:30 2011 +0100
    15.3 @@ -0,0 +1,475 @@
    15.4 +/*
    15.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    15.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    15.7 + *
    15.8 + * This code is free software; you can redistribute it and/or modify it
    15.9 + * under the terms of the GNU General Public License version 2 only, as
   15.10 + * published by the Free Software Foundation.
   15.11 + *
   15.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   15.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   15.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   15.15 + * version 2 for more details (a copy is included in the LICENSE file that
   15.16 + * accompanied this code).
   15.17 + *
   15.18 + * You should have received a copy of the GNU General Public License version
   15.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   15.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   15.21 + *
   15.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   15.23 + * or visit www.oracle.com if you need additional information or have any
   15.24 + * questions.
   15.25 + */
   15.26 +
   15.27 +/*
   15.28 + * @test
   15.29 + * @bug 7098660
   15.30 + * @summary Write better overload resolution/inference tests
   15.31 + * @library ../lib
   15.32 + * @build JavacTestingAbstractProcessor ResolveHarness
   15.33 + * @run main ResolveHarness
   15.34 + */
   15.35 +
   15.36 +import com.sun.source.util.JavacTask;
   15.37 +import com.sun.tools.javac.api.ClientCodeWrapper.DiagnosticSourceUnwrapper;
   15.38 +import com.sun.tools.javac.code.Type.MethodType;
   15.39 +import com.sun.tools.javac.util.JCDiagnostic;
   15.40 +
   15.41 +import java.io.File;
   15.42 +import java.util.Set;
   15.43 +import java.util.Arrays;
   15.44 +import java.util.ArrayList;
   15.45 +import java.util.Collections;
   15.46 +import java.util.HashMap;
   15.47 +import java.util.HashSet;
   15.48 +import java.util.List;
   15.49 +import java.util.Map;
   15.50 +
   15.51 +import javax.annotation.processing.AbstractProcessor;
   15.52 +import javax.annotation.processing.RoundEnvironment;
   15.53 +import javax.annotation.processing.SupportedAnnotationTypes;
   15.54 +import javax.lang.model.element.Element;
   15.55 +import javax.lang.model.element.TypeElement;
   15.56 +import javax.tools.Diagnostic;
   15.57 +import javax.tools.Diagnostic.Kind;
   15.58 +import javax.tools.DiagnosticListener;
   15.59 +import javax.tools.JavaCompiler;
   15.60 +import javax.tools.JavaFileObject;
   15.61 +import javax.tools.StandardJavaFileManager;
   15.62 +import javax.tools.ToolProvider;
   15.63 +
   15.64 +import static javax.tools.StandardLocation.*;
   15.65 +
   15.66 +public class ResolveHarness implements javax.tools.DiagnosticListener<JavaFileObject> {
   15.67 +
   15.68 +    static int nerrors = 0;
   15.69 +
   15.70 +    static final JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
   15.71 +    static final StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
   15.72 +
   15.73 +    public static void main(String[] args) throws Exception {
   15.74 +        fm.setLocation(SOURCE_PATH,
   15.75 +                Arrays.asList(new File(System.getProperty("test.src"), "tests")));
   15.76 +        for (JavaFileObject jfo : fm.list(SOURCE_PATH, "", Collections.singleton(JavaFileObject.Kind.SOURCE), true)) {
   15.77 +            new ResolveHarness(jfo).check();
   15.78 +        }
   15.79 +        if (nerrors > 0) {
   15.80 +            throw new AssertionError("Errors were found");
   15.81 +        }
   15.82 +    }
   15.83 +
   15.84 +
   15.85 +    JavaFileObject jfo;
   15.86 +    DiagnosticProcessor[] diagProcessors;
   15.87 +    Map<ElementKey, Candidate> candidatesMap = new HashMap<ElementKey, Candidate>();
   15.88 +    Set<String> declaredKeys = new HashSet<>();
   15.89 +    List<Diagnostic<? extends JavaFileObject>> diags = new ArrayList<>();
   15.90 +    List<ElementKey> seenCandidates = new ArrayList<>();
   15.91 +
   15.92 +    protected ResolveHarness(JavaFileObject jfo) {
   15.93 +        this.jfo = jfo;
   15.94 +        this.diagProcessors = new DiagnosticProcessor[] {
   15.95 +            new VerboseResolutionNoteProcessor(),
   15.96 +            new VerboseDeferredInferenceNoteProcessor(),
   15.97 +            new ErrorProcessor()
   15.98 +        };
   15.99 +    }
  15.100 +
  15.101 +    protected void check() throws Exception {
  15.102 +        String[] options = {
  15.103 +            "-XDshouldStopPolicy=ATTR",
  15.104 +            "-XDverboseResolution=success,failure,applicable,inapplicable,deferred-inference"
  15.105 +        };
  15.106 +
  15.107 +        AbstractProcessor[] processors = { new ResolveCandidateFinder(), null };
  15.108 +
  15.109 +        @SuppressWarnings("unchecked")
  15.110 +        DiagnosticListener<? super JavaFileObject>[] diagListeners =
  15.111 +                new DiagnosticListener[] { new DiagnosticHandler(false), new DiagnosticHandler(true) };
  15.112 +
  15.113 +        for (int i = 0 ; i < options.length ; i ++) {
  15.114 +            JavacTask ct = (JavacTask)comp.getTask(null, fm, diagListeners[i],
  15.115 +                    Arrays.asList(options[i]), null, Arrays.asList(jfo));
  15.116 +            if (processors[i] != null) {
  15.117 +                ct.setProcessors(Collections.singleton(processors[i]));
  15.118 +            }
  15.119 +            ct.analyze();
  15.120 +        }
  15.121 +
  15.122 +        //check diags
  15.123 +        for (Diagnostic<? extends JavaFileObject> diag : diags) {
  15.124 +            for (DiagnosticProcessor proc : diagProcessors) {
  15.125 +                if (proc.matches(diag)) {
  15.126 +                    proc.process(diag);
  15.127 +                    break;
  15.128 +                }
  15.129 +            }
  15.130 +        }
  15.131 +        //check all candidates have been used up
  15.132 +        for (Map.Entry<ElementKey, Candidate> entry : candidatesMap.entrySet()) {
  15.133 +            if (!seenCandidates.contains(entry.getKey())) {
  15.134 +                error("Redundant @Candidate annotation on method " + entry.getKey().elem);
  15.135 +            }
  15.136 +        }
  15.137 +    }
  15.138 +
  15.139 +    public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
  15.140 +        diags.add(diagnostic);
  15.141 +    }
  15.142 +
  15.143 +    Candidate getCandidateAtPos(Element methodSym, long line, long col) {
  15.144 +        Candidate c = candidatesMap.get(new ElementKey(methodSym));
  15.145 +        if (c != null) {
  15.146 +            Pos pos = c.pos();
  15.147 +            if (!pos.userDefined() ||
  15.148 +                    (pos.line() == line && pos.col() == col)) {
  15.149 +                seenCandidates.add(new ElementKey(methodSym));
  15.150 +                return c;
  15.151 +            }
  15.152 +        } else {
  15.153 +            error("Missing @Candidate annotation on method " + methodSym);
  15.154 +        }
  15.155 +        return null;
  15.156 +    }
  15.157 +
  15.158 +    void checkSig(Candidate c, Element methodSym, MethodType mtype) {
  15.159 +        if (c.sig().length() > 0 && !c.sig().equals(mtype.toString())) {
  15.160 +            error("Inferred type mismatch for method: " + methodSym);
  15.161 +        }
  15.162 +    }
  15.163 +
  15.164 +    protected void error(String msg) {
  15.165 +        nerrors++;
  15.166 +        System.err.printf("Error occurred while checking file: %s\nreason: %s\n", jfo.getName(), msg);
  15.167 +    }
  15.168 +
  15.169 +    /**
  15.170 +     * Base class for diagnostic processor. It provides methods for matching and
  15.171 +     * processing a given diagnostic object (overridden by subclasses).
  15.172 +     */
  15.173 +    abstract class DiagnosticProcessor {
  15.174 +
  15.175 +        List<String> codes;
  15.176 +        Diagnostic.Kind kind;
  15.177 +
  15.178 +        public DiagnosticProcessor(Kind kind, String... codes) {
  15.179 +            this.codes = Arrays.asList(codes);
  15.180 +            this.kind = kind;
  15.181 +        }
  15.182 +
  15.183 +        abstract void process(Diagnostic<? extends JavaFileObject> diagnostic);
  15.184 +
  15.185 +        boolean matches(Diagnostic<? extends JavaFileObject> diagnostic) {
  15.186 +            return (codes.isEmpty() || codes.contains(diagnostic.getCode())) &&
  15.187 +                    diagnostic.getKind() == kind;
  15.188 +        }
  15.189 +
  15.190 +        JCDiagnostic asJCDiagnostic(Diagnostic<? extends JavaFileObject> diagnostic) {
  15.191 +            if (diagnostic instanceof JCDiagnostic) {
  15.192 +                return (JCDiagnostic)diagnostic;
  15.193 +            } else if (diagnostic instanceof DiagnosticSourceUnwrapper) {
  15.194 +                return ((DiagnosticSourceUnwrapper)diagnostic).d;
  15.195 +            } else {
  15.196 +                throw new AssertionError("Cannot convert diagnostic to JCDiagnostic: " + diagnostic.getClass().getName());
  15.197 +            }
  15.198 +        }
  15.199 +
  15.200 +        List<JCDiagnostic> subDiagnostics(Diagnostic<? extends JavaFileObject> diagnostic) {
  15.201 +            JCDiagnostic diag = asJCDiagnostic(diagnostic);
  15.202 +            if (diag instanceof JCDiagnostic.MultilineDiagnostic) {
  15.203 +                return ((JCDiagnostic.MultilineDiagnostic)diag).getSubdiagnostics();
  15.204 +            } else {
  15.205 +                throw new AssertionError("Cannot extract subdiagnostics: " + diag.getClass().getName());
  15.206 +            }
  15.207 +        }
  15.208 +    }
  15.209 +
  15.210 +    /**
  15.211 +     * Processor for verbose resolution notes generated by javac. The processor
  15.212 +     * checks that the diagnostic is associated with a method declared by
  15.213 +     * a class annotated with the special @TraceResolve marker annotation. If
  15.214 +     * that's the case, all subdiagnostics (one for each resolution candidate)
  15.215 +     * are checked against the corresponding @Candidate annotations, using
  15.216 +     * a VerboseCandidateSubdiagProcessor.
  15.217 +     */
  15.218 +    class VerboseResolutionNoteProcessor extends DiagnosticProcessor {
  15.219 +
  15.220 +        VerboseResolutionNoteProcessor() {
  15.221 +            super(Kind.NOTE,
  15.222 +                    "compiler.note.verbose.resolve.multi",
  15.223 +                    "compiler.note.verbose.resolve.multi.1");
  15.224 +        }
  15.225 +
  15.226 +        @Override
  15.227 +        void process(Diagnostic<? extends JavaFileObject> diagnostic) {
  15.228 +            Element siteSym = getSiteSym(diagnostic);
  15.229 +            if (siteSym.getAnnotation(TraceResolve.class) == null) {
  15.230 +                return;
  15.231 +            }
  15.232 +            int candidateIdx = 0;
  15.233 +            for (JCDiagnostic d : subDiagnostics(diagnostic)) {
  15.234 +                boolean isMostSpecific = candidateIdx++ == mostSpecific(diagnostic);
  15.235 +                VerboseCandidateSubdiagProcessor subProc =
  15.236 +                        new VerboseCandidateSubdiagProcessor(isMostSpecific, phase(diagnostic), success(diagnostic));
  15.237 +                if (subProc.matches(d)) {
  15.238 +                    subProc.process(d);
  15.239 +                } else {
  15.240 +                    throw new AssertionError("Bad subdiagnostic: " + d.getCode());
  15.241 +                }
  15.242 +            }
  15.243 +        }
  15.244 +
  15.245 +        Element getSiteSym(Diagnostic<? extends JavaFileObject> diagnostic) {
  15.246 +            return (Element)asJCDiagnostic(diagnostic).getArgs()[1];
  15.247 +        }
  15.248 +
  15.249 +        int mostSpecific(Diagnostic<? extends JavaFileObject> diagnostic) {
  15.250 +            return success(diagnostic) ?
  15.251 +                    (Integer)asJCDiagnostic(diagnostic).getArgs()[2] : -1;
  15.252 +        }
  15.253 +
  15.254 +        boolean success(Diagnostic<? extends JavaFileObject> diagnostic) {
  15.255 +            return diagnostic.getCode().equals("compiler.note.verbose.resolve.multi");
  15.256 +        }
  15.257 +
  15.258 +        Phase phase(Diagnostic<? extends JavaFileObject> diagnostic) {
  15.259 +            return Phase.fromString(asJCDiagnostic(diagnostic).getArgs()[3].toString());
  15.260 +        }
  15.261 +    }
  15.262 +
  15.263 +    /**
  15.264 +     * Processor for verbose resolution subdiagnostic notes generated by javac.
  15.265 +     * The processor checks that the details of the overload candidate
  15.266 +     * match against the info contained in the corresponding @Candidate
  15.267 +     * annotation (if any).
  15.268 +     */
  15.269 +    class VerboseCandidateSubdiagProcessor extends DiagnosticProcessor {
  15.270 +
  15.271 +        boolean mostSpecific;
  15.272 +        Phase phase;
  15.273 +        boolean success;
  15.274 +
  15.275 +        public VerboseCandidateSubdiagProcessor(boolean mostSpecific, Phase phase, boolean success) {
  15.276 +            super(Kind.OTHER,
  15.277 +                    "compiler.misc.applicable.method.found",
  15.278 +                    "compiler.misc.applicable.method.found.1",
  15.279 +                    "compiler.misc.not.applicable.method.found");
  15.280 +            this.mostSpecific = mostSpecific;
  15.281 +            this.phase = phase;
  15.282 +            this.success = success;
  15.283 +        }
  15.284 +
  15.285 +        @Override
  15.286 +        void process(Diagnostic<? extends JavaFileObject> diagnostic) {
  15.287 +            Element methodSym = methodSym(diagnostic);
  15.288 +            Candidate c = getCandidateAtPos(methodSym,
  15.289 +                    asJCDiagnostic(diagnostic).getLineNumber(),
  15.290 +                    asJCDiagnostic(diagnostic).getColumnNumber());
  15.291 +            if (c == null) {
  15.292 +                return; //nothing to check
  15.293 +            }
  15.294 +
  15.295 +            if (c.applicable().length == 0 && c.mostSpecific()) {
  15.296 +                error("Inapplicable method cannot be most specific " + methodSym);
  15.297 +            }
  15.298 +
  15.299 +            if (isApplicable(diagnostic) != Arrays.asList(c.applicable()).contains(phase)) {
  15.300 +                error("Invalid candidate's applicability " + methodSym);
  15.301 +            }
  15.302 +
  15.303 +            if (success) {
  15.304 +                for (Phase p : c.applicable()) {
  15.305 +                    if (phase.ordinal() < p.ordinal()) {
  15.306 +                        error("Invalid phase " + p + " on method " + methodSym);
  15.307 +                    }
  15.308 +                }
  15.309 +            }
  15.310 +
  15.311 +            if (Arrays.asList(c.applicable()).contains(phase)) { //applicable
  15.312 +                if (c.mostSpecific() != mostSpecific) {
  15.313 +                    error("Invalid most specific value for method " + methodSym);
  15.314 +                }
  15.315 +                MethodType mtype = getSig(diagnostic);
  15.316 +                if (mtype != null) {
  15.317 +                    checkSig(c, methodSym, mtype);
  15.318 +                }
  15.319 +            }
  15.320 +        }
  15.321 +
  15.322 +        boolean isApplicable(Diagnostic<? extends JavaFileObject> diagnostic) {
  15.323 +            return !diagnostic.getCode().equals("compiler.misc.not.applicable.method.found");
  15.324 +        }
  15.325 +
  15.326 +        Element methodSym(Diagnostic<? extends JavaFileObject> diagnostic) {
  15.327 +            return (Element)asJCDiagnostic(diagnostic).getArgs()[1];
  15.328 +        }
  15.329 +
  15.330 +        MethodType getSig(Diagnostic<? extends JavaFileObject> diagnostic) {
  15.331 +            JCDiagnostic details = (JCDiagnostic)asJCDiagnostic(diagnostic).getArgs()[2];
  15.332 +            if (details == null) {
  15.333 +                return null;
  15.334 +            } else if (details instanceof JCDiagnostic) {
  15.335 +                return details.getCode().equals("compiler.misc.full.inst.sig") ?
  15.336 +                        (MethodType)details.getArgs()[0] : null;
  15.337 +            } else {
  15.338 +                throw new AssertionError("Bad diagnostic arg: " + details);
  15.339 +            }
  15.340 +        }
  15.341 +    }
  15.342 +
  15.343 +    /**
  15.344 +     * Processor for verbose deferred inference notes generated by javac. The
  15.345 +     * processor checks that the inferred signature for a given generic method
  15.346 +     * call corresponds to the one (if any) declared in the @Candidate annotation.
  15.347 +     */
  15.348 +    class VerboseDeferredInferenceNoteProcessor extends DiagnosticProcessor {
  15.349 +
  15.350 +        public VerboseDeferredInferenceNoteProcessor() {
  15.351 +            super(Kind.NOTE, "compiler.note.deferred.method.inst");
  15.352 +        }
  15.353 +
  15.354 +        @Override
  15.355 +        void process(Diagnostic<? extends JavaFileObject> diagnostic) {
  15.356 +            Element methodSym = methodSym(diagnostic);
  15.357 +            Candidate c = getCandidateAtPos(methodSym,
  15.358 +                    asJCDiagnostic(diagnostic).getLineNumber(),
  15.359 +                    asJCDiagnostic(diagnostic).getColumnNumber());
  15.360 +            MethodType sig = sig(diagnostic);
  15.361 +            if (c != null && sig != null) {
  15.362 +                checkSig(c, methodSym, sig);
  15.363 +            }
  15.364 +        }
  15.365 +
  15.366 +        Element methodSym(Diagnostic<? extends JavaFileObject> diagnostic) {
  15.367 +            return (Element)asJCDiagnostic(diagnostic).getArgs()[0];
  15.368 +        }
  15.369 +
  15.370 +        MethodType sig(Diagnostic<? extends JavaFileObject> diagnostic) {
  15.371 +            return (MethodType)asJCDiagnostic(diagnostic).getArgs()[1];
  15.372 +        }
  15.373 +    }
  15.374 +
  15.375 +    /**
  15.376 +     * Processor for all error diagnostics; if the error key is not declared in
  15.377 +     * the test file header, the processor reports an error.
  15.378 +     */
  15.379 +    class ErrorProcessor extends DiagnosticProcessor {
  15.380 +
  15.381 +        public ErrorProcessor() {
  15.382 +            super(Diagnostic.Kind.ERROR);
  15.383 +        }
  15.384 +
  15.385 +        @Override
  15.386 +        void process(Diagnostic<? extends JavaFileObject> diagnostic) {
  15.387 +            if (!declaredKeys.contains(diagnostic.getCode())) {
  15.388 +                error("Unexpected compilation error key '" + diagnostic.getCode() + "'");
  15.389 +            }
  15.390 +        }
  15.391 +    }
  15.392 +
  15.393 +    @SupportedAnnotationTypes({"Candidate","TraceResolve"})
  15.394 +    class ResolveCandidateFinder extends JavacTestingAbstractProcessor {
  15.395 +
  15.396 +        @Override
  15.397 +        public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
  15.398 +            if (roundEnv.processingOver())
  15.399 +                return true;
  15.400 +
  15.401 +            TypeElement traceResolveAnno = elements.getTypeElement("TraceResolve");
  15.402 +            TypeElement candidateAnno = elements.getTypeElement("Candidate");
  15.403 +
  15.404 +            if (!annotations.contains(traceResolveAnno)) {
  15.405 +                error("no @TraceResolve annotation found in test class");
  15.406 +            }
  15.407 +
  15.408 +            if (!annotations.contains(candidateAnno)) {
  15.409 +                error("no @candidate annotation found in test class");
  15.410 +            }
  15.411 +
  15.412 +            for (Element elem: roundEnv.getElementsAnnotatedWith(traceResolveAnno)) {
  15.413 +                TraceResolve traceResolve = elem.getAnnotation(TraceResolve.class);
  15.414 +                declaredKeys.addAll(Arrays.asList(traceResolve.keys()));
  15.415 +            }
  15.416 +
  15.417 +            for (Element elem: roundEnv.getElementsAnnotatedWith(candidateAnno)) {
  15.418 +                candidatesMap.put(new ElementKey(elem), elem.getAnnotation(Candidate.class));
  15.419 +            }
  15.420 +            return true;
  15.421 +        }
  15.422 +    }
  15.423 +
  15.424 +    class ElementKey {
  15.425 +
  15.426 +        String key;
  15.427 +        Element elem;
  15.428 +
  15.429 +        public ElementKey(Element elem) {
  15.430 +            this.elem = elem;
  15.431 +            this.key = computeKey(elem);
  15.432 +        }
  15.433 +
  15.434 +        @Override
  15.435 +        public boolean equals(Object obj) {
  15.436 +            if (obj instanceof ElementKey) {
  15.437 +                ElementKey other = (ElementKey)obj;
  15.438 +                return other.key.equals(key);
  15.439 +            }
  15.440 +            return false;
  15.441 +        }
  15.442 +
  15.443 +        @Override
  15.444 +        public int hashCode() {
  15.445 +            return key.hashCode();
  15.446 +        }
  15.447 +
  15.448 +        String computeKey(Element e) {
  15.449 +            StringBuilder buf = new StringBuilder();
  15.450 +            while (e != null) {
  15.451 +                buf.append(e.toString());
  15.452 +                e = e.getEnclosingElement();
  15.453 +            }
  15.454 +            buf.append(jfo.getName());
  15.455 +            return buf.toString();
  15.456 +        }
  15.457 +
  15.458 +        @Override
  15.459 +        public String toString() {
  15.460 +            return "Key{"+key+"}";
  15.461 +        }
  15.462 +    }
  15.463 +
  15.464 +    class DiagnosticHandler implements DiagnosticListener<JavaFileObject> {
  15.465 +
  15.466 +        boolean shouldRecordDiags;
  15.467 +
  15.468 +        DiagnosticHandler(boolean shouldRecordDiags) {
  15.469 +            this.shouldRecordDiags = shouldRecordDiags;
  15.470 +        }
  15.471 +
  15.472 +        public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
  15.473 +            if (shouldRecordDiags)
  15.474 +                diags.add(diagnostic);
  15.475 +        }
  15.476 +
  15.477 +    }
  15.478 +}
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/test/tools/javac/resolve/TraceResolve.java	Mon Oct 24 13:00:30 2011 +0100
    16.3 @@ -0,0 +1,29 @@
    16.4 +/*
    16.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    16.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    16.7 + *
    16.8 + * This code is free software; you can redistribute it and/or modify it
    16.9 + * under the terms of the GNU General Public License version 2 only, as
   16.10 + * published by the Free Software Foundation.
   16.11 + *
   16.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   16.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   16.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   16.15 + * version 2 for more details (a copy is included in the LICENSE file that
   16.16 + * accompanied this code).
   16.17 + *
   16.18 + * You should have received a copy of the GNU General Public License version
   16.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   16.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   16.21 + *
   16.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   16.23 + * or visit www.oracle.com if you need additional information or have any
   16.24 + * questions.
   16.25 + */
   16.26 +import java.lang.annotation.ElementType;
   16.27 +import java.lang.annotation.Target;
   16.28 +
   16.29 +@Target(ElementType.TYPE)
   16.30 +@interface TraceResolve {
   16.31 +    String[] keys() default {};
   16.32 +}
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/test/tools/javac/resolve/tests/BoxedReturnTypeInference.java	Mon Oct 24 13:00:30 2011 +0100
    17.3 @@ -0,0 +1,60 @@
    17.4 +/*
    17.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    17.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    17.7 + *
    17.8 + * This code is free software; you can redistribute it and/or modify it
    17.9 + * under the terms of the GNU General Public License version 2 only, as
   17.10 + * published by the Free Software Foundation.
   17.11 + *
   17.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   17.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   17.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   17.15 + * version 2 for more details (a copy is included in the LICENSE file that
   17.16 + * accompanied this code).
   17.17 + *
   17.18 + * You should have received a copy of the GNU General Public License version
   17.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   17.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   17.21 + *
   17.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   17.23 + * or visit www.oracle.com if you need additional information or have any
   17.24 + * questions.
   17.25 + */
   17.26 +
   17.27 +@TraceResolve
   17.28 +class BoxedReturnTypeInference {
   17.29 +    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Byte", mostSpecific=true)
   17.30 +    static <B> B m_byte() { return null; }
   17.31 +
   17.32 +    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Short", mostSpecific=true)
   17.33 +    static <S> S m_short() { return null; }
   17.34 +
   17.35 +    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Integer", mostSpecific=true)
   17.36 +    static <I> I m_int() { return null; }
   17.37 +
   17.38 +    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Long", mostSpecific=true)
   17.39 +    static <L> L m_long() { return null; }
   17.40 +
   17.41 +    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Float", mostSpecific=true)
   17.42 +    static <F> F m_float() { return null; }
   17.43 +
   17.44 +    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Double", mostSpecific=true)
   17.45 +    static <D> D m_double() { return null; }
   17.46 +
   17.47 +    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Character", mostSpecific=true)
   17.48 +    static <C> C m_char() { return null; }
   17.49 +
   17.50 +    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Boolean", mostSpecific=true)
   17.51 +    static <Z> Z m_bool() { return null; }
   17.52 +
   17.53 +    {
   17.54 +        Byte b = m_byte();
   17.55 +        Short s = m_short();
   17.56 +        Integer i = m_int();
   17.57 +        Long l = m_long();
   17.58 +        Float f = m_float();
   17.59 +        Double d = m_double();
   17.60 +        Character c= m_char();
   17.61 +        Boolean z = m_bool();
   17.62 +    }
   17.63 +}
    18.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    18.2 +++ b/test/tools/javac/resolve/tests/PrimitiveOverReferenceOverInferred.java	Mon Oct 24 13:00:30 2011 +0100
    18.3 @@ -0,0 +1,92 @@
    18.4 +/*
    18.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    18.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    18.7 + *
    18.8 + * This code is free software; you can redistribute it and/or modify it
    18.9 + * under the terms of the GNU General Public License version 2 only, as
   18.10 + * published by the Free Software Foundation.
   18.11 + *
   18.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   18.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   18.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   18.15 + * version 2 for more details (a copy is included in the LICENSE file that
   18.16 + * accompanied this code).
   18.17 + *
   18.18 + * You should have received a copy of the GNU General Public License version
   18.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   18.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   18.21 + *
   18.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   18.23 + * or visit www.oracle.com if you need additional information or have any
   18.24 + * questions.
   18.25 + */
   18.26 +
   18.27 +@TraceResolve
   18.28 +class PrimitiveOverReference {
   18.29 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
   18.30 +    static void m_byte(byte b) {}
   18.31 +    @Candidate
   18.32 +    static void m_byte(Byte b) {}
   18.33 +    @Candidate
   18.34 +    static <B> void m_byte(B b) {}
   18.35 +
   18.36 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
   18.37 +    static void m_short(short s) {}
   18.38 +    @Candidate
   18.39 +    static void m_short(Short s) {}
   18.40 +    @Candidate
   18.41 +    static <S> void m_short(S s) {}
   18.42 +
   18.43 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
   18.44 +    static void m_int(int i) {}
   18.45 +    @Candidate
   18.46 +    static void m_int(Integer i) {}
   18.47 +    @Candidate
   18.48 +    static <I> void m_int(I i) {}
   18.49 +
   18.50 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
   18.51 +    static void m_long(long l) {}
   18.52 +    @Candidate
   18.53 +    static void m_long(Long l) {}
   18.54 +    @Candidate
   18.55 +    static <L> void m_long(L l) {}
   18.56 +
   18.57 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
   18.58 +    static void m_float(float f) {}
   18.59 +    @Candidate
   18.60 +    static void m_float(Float f) {}
   18.61 +    @Candidate
   18.62 +    static <F> void m_float(F f) {}
   18.63 +
   18.64 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
   18.65 +    static void m_double(double d) {}
   18.66 +    @Candidate
   18.67 +    static void m_double(Double d) {}
   18.68 +    @Candidate
   18.69 +    static <D> void m_double(D d) {}
   18.70 +
   18.71 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
   18.72 +    static void m_char(char c) {}
   18.73 +    @Candidate
   18.74 +    static void m_char(Character c) {}
   18.75 +    @Candidate
   18.76 +    static <C> void m_char(C c) {}
   18.77 +
   18.78 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
   18.79 +    static void m_bool(boolean z) {}
   18.80 +    @Candidate
   18.81 +    static void m_bool(Boolean z) {}
   18.82 +    @Candidate
   18.83 +    static <Z> void m_bool(Z z) {}
   18.84 +
   18.85 +    {
   18.86 +        m_byte((byte)0);
   18.87 +        m_short((short)0);
   18.88 +        m_int(0);
   18.89 +        m_long(0L);
   18.90 +        m_float(0.0f);
   18.91 +        m_double(0.0);
   18.92 +        m_char('?');
   18.93 +        m_bool(false);
   18.94 +    }
   18.95 +}
    19.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    19.2 +++ b/test/tools/javac/resolve/tests/PrimitiveOverReferenceOverVarargs.java	Mon Oct 24 13:00:30 2011 +0100
    19.3 @@ -0,0 +1,108 @@
    19.4 +/*
    19.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    19.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    19.7 + *
    19.8 + * This code is free software; you can redistribute it and/or modify it
    19.9 + * under the terms of the GNU General Public License version 2 only, as
   19.10 + * published by the Free Software Foundation.
   19.11 + *
   19.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   19.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   19.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   19.15 + * version 2 for more details (a copy is included in the LICENSE file that
   19.16 + * accompanied this code).
   19.17 + *
   19.18 + * You should have received a copy of the GNU General Public License version
   19.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   19.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   19.21 + *
   19.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   19.23 + * or visit www.oracle.com if you need additional information or have any
   19.24 + * questions.
   19.25 + */
   19.26 +
   19.27 +@TraceResolve
   19.28 +class PrimitiveOverReference {
   19.29 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
   19.30 +    static void m_byte(byte b) {}
   19.31 +    @Candidate
   19.32 +    static void m_byte(Byte b) {}
   19.33 +    @Candidate
   19.34 +    static void m_byte(byte... b) {}
   19.35 +    @Candidate
   19.36 +    static void m_byte(Byte... b) {}
   19.37 +
   19.38 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
   19.39 +    static void m_short(short s) {}
   19.40 +    @Candidate
   19.41 +    static void m_short(Short s) {}
   19.42 +    @Candidate
   19.43 +    static void m_short(short... s) {}
   19.44 +    @Candidate
   19.45 +    static void m_short(Short... s) {}
   19.46 +
   19.47 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
   19.48 +    static void m_int(int i) {}
   19.49 +    @Candidate
   19.50 +    static void m_int(Integer i) {}
   19.51 +    @Candidate
   19.52 +    static void m_int(int... i) {}
   19.53 +    @Candidate
   19.54 +    static void m_int(Integer... i) {}
   19.55 +
   19.56 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
   19.57 +    static void m_long(long l) {}
   19.58 +    @Candidate
   19.59 +    static void m_long(Long l) {}
   19.60 +    @Candidate
   19.61 +    static void m_long(long... l) {}
   19.62 +    @Candidate
   19.63 +    static void m_long(Long... l) {}
   19.64 +
   19.65 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
   19.66 +    static void m_float(float f) {}
   19.67 +    @Candidate
   19.68 +    static void m_float(Float f) {}
   19.69 +    @Candidate
   19.70 +    static void m_float(float... f) {}
   19.71 +    @Candidate
   19.72 +    static void m_float(Float... f) {}
   19.73 +
   19.74 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
   19.75 +    static void m_double(double d) {}
   19.76 +    @Candidate
   19.77 +    static void m_double(Double d) {}
   19.78 +    @Candidate
   19.79 +    static void m_double(double... d) {}
   19.80 +    @Candidate
   19.81 +    static void m_double(Double... d) {}
   19.82 +
   19.83 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
   19.84 +    static void m_char(char c) {}
   19.85 +    @Candidate
   19.86 +    static void m_char(Character c) {}
   19.87 +    @Candidate
   19.88 +    static void m_char(char... c) {}
   19.89 +    @Candidate
   19.90 +    static void m_char(Character... c) {}
   19.91 +
   19.92 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
   19.93 +    static void m_bool(boolean z) {}
   19.94 +    @Candidate
   19.95 +    static void m_bool(Boolean z) {}
   19.96 +    @Candidate
   19.97 +    static void m_bool(boolean... z) {}
   19.98 +    @Candidate
   19.99 +    static void m_bool(Boolean... z) {}
  19.100 +
  19.101 +    {
  19.102 +        m_byte((byte)0);
  19.103 +        m_short((short)0);
  19.104 +        m_int(0);
  19.105 +        m_long(0L);
  19.106 +        m_float(0.0f);
  19.107 +        m_double(0.0);
  19.108 +        m_char('?');
  19.109 +        m_bool(false);
  19.110 +    }
  19.111 +}
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/test/tools/javac/resolve/tests/PrimitiveOverReferenceVarargsAmbiguous.java	Mon Oct 24 13:00:30 2011 +0100
    20.3 @@ -0,0 +1,76 @@
    20.4 +/*
    20.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    20.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    20.7 + *
    20.8 + * This code is free software; you can redistribute it and/or modify it
    20.9 + * under the terms of the GNU General Public License version 2 only, as
   20.10 + * published by the Free Software Foundation.
   20.11 + *
   20.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   20.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   20.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   20.15 + * version 2 for more details (a copy is included in the LICENSE file that
   20.16 + * accompanied this code).
   20.17 + *
   20.18 + * You should have received a copy of the GNU General Public License version
   20.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   20.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20.21 + *
   20.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   20.23 + * or visit www.oracle.com if you need additional information or have any
   20.24 + * questions.
   20.25 + */
   20.26 +
   20.27 +@TraceResolve(keys={"compiler.err.ref.ambiguous"})
   20.28 +class PrimitiveOverReferenceVarargsAmbiguous {
   20.29 +    @Candidate(applicable=Phase.VARARGS, mostSpecific=false)
   20.30 +    static void m_byte(byte... b) {}
   20.31 +    @Candidate(applicable=Phase.VARARGS, mostSpecific=false)
   20.32 +    static void m_byte(Byte... b) {}
   20.33 +
   20.34 +    @Candidate(applicable=Phase.VARARGS, mostSpecific=false)
   20.35 +    static void m_short(short... s) {}
   20.36 +    @Candidate(applicable=Phase.VARARGS, mostSpecific=false)
   20.37 +    static void m_short(Short... s) {}
   20.38 +
   20.39 +    @Candidate(applicable=Phase.VARARGS, mostSpecific=false)
   20.40 +    static void m_int(int... i) {}
   20.41 +    @Candidate(applicable=Phase.VARARGS, mostSpecific=false)
   20.42 +    static void m_int(Integer... i) {}
   20.43 +
   20.44 +    @Candidate(applicable=Phase.VARARGS, mostSpecific=false)
   20.45 +    static void m_long(long... l) {}
   20.46 +    @Candidate(applicable=Phase.VARARGS, mostSpecific=false)
   20.47 +    static void m_long(Long... l) {}
   20.48 +
   20.49 +    @Candidate(applicable=Phase.VARARGS, mostSpecific=false)
   20.50 +    static void m_float(float... f) {}
   20.51 +    @Candidate(applicable=Phase.VARARGS, mostSpecific=false)
   20.52 +    static void m_float(Float... f) {}
   20.53 +
   20.54 +    @Candidate(applicable=Phase.VARARGS, mostSpecific=false)
   20.55 +    static void m_double(double... d) {}
   20.56 +    @Candidate(applicable=Phase.VARARGS, mostSpecific=false)
   20.57 +    static void m_double(Double... d) {}
   20.58 +
   20.59 +    @Candidate(applicable=Phase.VARARGS, mostSpecific=false)
   20.60 +    static void m_char(char... c) {}
   20.61 +    @Candidate(applicable=Phase.VARARGS, mostSpecific=false)
   20.62 +    static void m_char(Character... c) {}
   20.63 +
   20.64 +    @Candidate(applicable=Phase.VARARGS, mostSpecific=false)
   20.65 +    static void m_bool(boolean... z) {}
   20.66 +    @Candidate(applicable=Phase.VARARGS, mostSpecific=false)
   20.67 +    static void m_bool(Boolean... z) {}
   20.68 +
   20.69 +    {
   20.70 +        m_byte((byte)0);
   20.71 +        m_short((short)0);
   20.72 +        m_int(0);
   20.73 +        m_long(0L);
   20.74 +        m_float(0.0f);
   20.75 +        m_double(0.0);
   20.76 +        m_char('?');
   20.77 +        m_bool(false);
   20.78 +    }
   20.79 +}
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/test/tools/javac/resolve/tests/PrimitiveOverload.java	Mon Oct 24 13:00:30 2011 +0100
    21.3 @@ -0,0 +1,113 @@
    21.4 +/*
    21.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    21.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    21.7 + *
    21.8 + * This code is free software; you can redistribute it and/or modify it
    21.9 + * under the terms of the GNU General Public License version 2 only, as
   21.10 + * published by the Free Software Foundation.
   21.11 + *
   21.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   21.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   21.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   21.15 + * version 2 for more details (a copy is included in the LICENSE file that
   21.16 + * accompanied this code).
   21.17 + *
   21.18 + * You should have received a copy of the GNU General Public License version
   21.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   21.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   21.21 + *
   21.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   21.23 + * or visit www.oracle.com if you need additional information or have any
   21.24 + * questions.
   21.25 + */
   21.26 +
   21.27 +@TraceResolve
   21.28 +class PrimitiveOverload {
   21.29 +
   21.30 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
   21.31 +    static void m_byte(byte b) {}
   21.32 +    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
   21.33 +    static void m_byte(short b) {}
   21.34 +    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
   21.35 +    static void m_byte(int b) {}
   21.36 +    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
   21.37 +    static void m_byte(long b) {}
   21.38 +    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
   21.39 +    static void m_byte(float b) {}
   21.40 +    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
   21.41 +    static void m_byte(double b) {}
   21.42 +
   21.43 +    @Candidate
   21.44 +    static void m_short(byte b) {}
   21.45 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
   21.46 +    static void m_short(short b) {}
   21.47 +    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
   21.48 +    static void m_short(int b) {}
   21.49 +    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
   21.50 +    static void m_short(long b) {}
   21.51 +    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
   21.52 +    static void m_short(float b) {}
   21.53 +    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
   21.54 +    static void m_short(double b) {}
   21.55 +
   21.56 +    @Candidate
   21.57 +    static void m_int(byte b) {}
   21.58 +    @Candidate
   21.59 +    static void m_int(short b) {}
   21.60 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
   21.61 +    static void m_int(int b) {}
   21.62 +    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
   21.63 +    static void m_int(long b) {}
   21.64 +    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
   21.65 +    static void m_int(float b) {}
   21.66 +    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
   21.67 +    static void m_int(double b) {}
   21.68 +
   21.69 +    @Candidate
   21.70 +    static void m_long(byte b) {}
   21.71 +    @Candidate
   21.72 +    static void m_long(short b) {}
   21.73 +    @Candidate
   21.74 +    static void m_long(int b) {}
   21.75 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
   21.76 +    static void m_long(long b) {}
   21.77 +    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
   21.78 +    static void m_long(float b) {}
   21.79 +    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
   21.80 +    static void m_long(double b) {}
   21.81 +
   21.82 +    @Candidate
   21.83 +    static void m_float(byte b) {}
   21.84 +    @Candidate
   21.85 +    static void m_float(short b) {}
   21.86 +    @Candidate
   21.87 +    static void m_float(int b) {}
   21.88 +    @Candidate
   21.89 +    static void m_float(long b) {}
   21.90 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
   21.91 +    static void m_float(float b) {}
   21.92 +    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
   21.93 +    static void m_float(double b) {}
   21.94 +
   21.95 +    @Candidate
   21.96 +    static void m_double(byte b) {}
   21.97 +    @Candidate
   21.98 +    static void m_double(short b) {}
   21.99 +    @Candidate
  21.100 +    static void m_double(int b) {}
  21.101 +    @Candidate
  21.102 +    static void m_double(long b) {}
  21.103 +    @Candidate
  21.104 +    static void m_double(float b) {}
  21.105 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
  21.106 +    static void m_double(double b) {}
  21.107 +
  21.108 +    {
  21.109 +        m_byte((byte)0);
  21.110 +        m_short((short)0);
  21.111 +        m_int(0);
  21.112 +        m_long(0L);
  21.113 +        m_float(0.0f);
  21.114 +        m_double(0.0);
  21.115 +    }
  21.116 +}
    22.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    22.2 +++ b/test/tools/javac/resolve/tests/PrimitiveReturnTypeInference.java	Mon Oct 24 13:00:30 2011 +0100
    22.3 @@ -0,0 +1,60 @@
    22.4 +/*
    22.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    22.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    22.7 + *
    22.8 + * This code is free software; you can redistribute it and/or modify it
    22.9 + * under the terms of the GNU General Public License version 2 only, as
   22.10 + * published by the Free Software Foundation.
   22.11 + *
   22.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   22.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   22.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   22.15 + * version 2 for more details (a copy is included in the LICENSE file that
   22.16 + * accompanied this code).
   22.17 + *
   22.18 + * You should have received a copy of the GNU General Public License version
   22.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   22.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   22.21 + *
   22.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   22.23 + * or visit www.oracle.com if you need additional information or have any
   22.24 + * questions.
   22.25 + */
   22.26 +
   22.27 +@TraceResolve
   22.28 +class PrimitiveReturnTypeInference {
   22.29 +    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Byte", mostSpecific=true)
   22.30 +    static <B> B m_byte() { return null; }
   22.31 +
   22.32 +    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Short", mostSpecific=true)
   22.33 +    static <S> S m_short() { return null; }
   22.34 +
   22.35 +    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Integer", mostSpecific=true)
   22.36 +    static <I> I m_int() { return null; }
   22.37 +
   22.38 +    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Long", mostSpecific=true)
   22.39 +    static <L> L m_long() { return null; }
   22.40 +
   22.41 +    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Float", mostSpecific=true)
   22.42 +    static <F> F m_float() { return null; }
   22.43 +
   22.44 +    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Double", mostSpecific=true)
   22.45 +    static <D> D m_double() { return null; }
   22.46 +
   22.47 +    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Character", mostSpecific=true)
   22.48 +    static <C> C m_char() { return null; }
   22.49 +
   22.50 +    @Candidate(applicable=Phase.BASIC, sig="()java.lang.Boolean", mostSpecific=true)
   22.51 +    static <Z> Z m_bool() { return null; }
   22.52 +
   22.53 +    {
   22.54 +        byte b = m_byte();
   22.55 +        short s = m_short();
   22.56 +        int i = m_int();
   22.57 +        long l = m_long();
   22.58 +        float f = m_float();
   22.59 +        double d = m_double();
   22.60 +        char c= m_char();
   22.61 +        boolean z = m_bool();
   22.62 +    }
   22.63 +}
    23.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    23.2 +++ b/test/tools/javac/resolve/tests/ReferenceOverInferred.java	Mon Oct 24 13:00:30 2011 +0100
    23.3 @@ -0,0 +1,76 @@
    23.4 +/*
    23.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    23.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    23.7 + *
    23.8 + * This code is free software; you can redistribute it and/or modify it
    23.9 + * under the terms of the GNU General Public License version 2 only, as
   23.10 + * published by the Free Software Foundation.
   23.11 + *
   23.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   23.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   23.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   23.15 + * version 2 for more details (a copy is included in the LICENSE file that
   23.16 + * accompanied this code).
   23.17 + *
   23.18 + * You should have received a copy of the GNU General Public License version
   23.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   23.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   23.21 + *
   23.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   23.23 + * or visit www.oracle.com if you need additional information or have any
   23.24 + * questions.
   23.25 + */
   23.26 +
   23.27 +@TraceResolve
   23.28 +class PrimitiveOverInferred {
   23.29 +    @Candidate(applicable=Phase.BOX, mostSpecific=true)
   23.30 +    static void m_byte(Byte b) {}
   23.31 +    @Candidate(applicable=Phase.BOX, sig="(java.lang.Byte)void")
   23.32 +    static <B> void m_byte(B b) {}
   23.33 +
   23.34 +    @Candidate(applicable=Phase.BOX, mostSpecific=true)
   23.35 +    static void m_short(Short s) {}
   23.36 +    @Candidate(applicable=Phase.BOX, sig="(java.lang.Short)void")
   23.37 +    static <S> void m_short(S s) {}
   23.38 +
   23.39 +    @Candidate(applicable=Phase.BOX, mostSpecific=true)
   23.40 +    static void m_int(Integer i) {}
   23.41 +    @Candidate(applicable=Phase.BOX, sig="(java.lang.Integer)void")
   23.42 +    static <I> void m_int(I i) {}
   23.43 +
   23.44 +    @Candidate(applicable=Phase.BOX, mostSpecific=true)
   23.45 +    static void m_long(Long l) {}
   23.46 +    @Candidate(applicable=Phase.BOX, sig="(java.lang.Long)void")
   23.47 +    static <L> void m_long(L l) {}
   23.48 +
   23.49 +    @Candidate(applicable=Phase.BOX, mostSpecific=true)
   23.50 +    static void m_float(Float f) {}
   23.51 +    @Candidate(applicable=Phase.BOX, sig="(java.lang.Float)void")
   23.52 +    static <F> void m_float(F f) {}
   23.53 +
   23.54 +    @Candidate(applicable=Phase.BOX, mostSpecific=true)
   23.55 +    static void m_double(Double d) {}
   23.56 +    @Candidate(applicable=Phase.BOX, sig="(java.lang.Double)void")
   23.57 +    static <D> void m_double(D d) {}
   23.58 +
   23.59 +    @Candidate(applicable=Phase.BOX, mostSpecific=true)
   23.60 +    static void m_char(Character c) {}
   23.61 +    @Candidate(applicable=Phase.BOX, sig="(java.lang.Character)void")
   23.62 +    static <C> void m_char(C c) {}
   23.63 +
   23.64 +    @Candidate(applicable=Phase.BOX, mostSpecific=true)
   23.65 +    static void m_bool(Boolean z) {}
   23.66 +    @Candidate(applicable=Phase.BOX, sig="(java.lang.Boolean)void")
   23.67 +    static <Z> void m_bool(Z z) {}
   23.68 +
   23.69 +    {
   23.70 +        m_byte((byte)0);
   23.71 +        m_short((short)0);
   23.72 +        m_int(0);
   23.73 +        m_long(0L);
   23.74 +        m_float(0.0f);
   23.75 +        m_double(0.0);
   23.76 +        m_char('?');
   23.77 +        m_bool(false);
   23.78 +    }
   23.79 +}
    24.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    24.2 +++ b/test/tools/javac/resolve/tests/ReferenceOverVarargs.java	Mon Oct 24 13:00:30 2011 +0100
    24.3 @@ -0,0 +1,93 @@
    24.4 +/*
    24.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    24.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    24.7 + *
    24.8 + * This code is free software; you can redistribute it and/or modify it
    24.9 + * under the terms of the GNU General Public License version 2 only, as
   24.10 + * published by the Free Software Foundation.
   24.11 + *
   24.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   24.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   24.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   24.15 + * version 2 for more details (a copy is included in the LICENSE file that
   24.16 + * accompanied this code).
   24.17 + *
   24.18 + * You should have received a copy of the GNU General Public License version
   24.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   24.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   24.21 + *
   24.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   24.23 + * or visit www.oracle.com if you need additional information or have any
   24.24 + * questions.
   24.25 + */
   24.26 +
   24.27 +@TraceResolve
   24.28 +class ReferenceOverVarargs {
   24.29 +
   24.30 +    @Candidate(applicable=Phase.BOX, mostSpecific=true)
   24.31 +    static void m_byte(Byte b) {}
   24.32 +    @Candidate
   24.33 +    static void m_byte(byte... b) {}
   24.34 +    @Candidate
   24.35 +    static void m_byte(Byte... b) {}
   24.36 +
   24.37 +    @Candidate(applicable=Phase.BOX, mostSpecific=true)
   24.38 +    static void m_short(Short s) {}
   24.39 +    @Candidate
   24.40 +    static void m_short(short... s) {}
   24.41 +    @Candidate
   24.42 +    static void m_short(Short... s) {}
   24.43 +
   24.44 +    @Candidate(applicable=Phase.BOX, mostSpecific=true)
   24.45 +    static void m_int(Integer i) {}
   24.46 +    @Candidate
   24.47 +    static void m_int(int... i) {}
   24.48 +    @Candidate
   24.49 +    static void m_int(Integer... i) {}
   24.50 +
   24.51 +    @Candidate(applicable=Phase.BOX, mostSpecific=true)
   24.52 +    static void m_long(Long l) {}
   24.53 +    @Candidate
   24.54 +    static void m_long(long... l) {}
   24.55 +    @Candidate
   24.56 +    static void m_long(Long... l) {}
   24.57 +
   24.58 +    @Candidate(applicable=Phase.BOX, mostSpecific=true)
   24.59 +    static void m_float(Float f) {}
   24.60 +    @Candidate
   24.61 +    static void m_float(float... f) {}
   24.62 +    @Candidate
   24.63 +    static void m_float(Float... f) {}
   24.64 +
   24.65 +    @Candidate(applicable=Phase.BOX, mostSpecific=true)
   24.66 +    static void m_double(Double d) {}
   24.67 +    @Candidate
   24.68 +    static void m_double(double... d) {}
   24.69 +    @Candidate
   24.70 +    static void m_double(Double... d) {}
   24.71 +
   24.72 +    @Candidate(applicable=Phase.BOX, mostSpecific=true)
   24.73 +    static void m_char(Character c) {}
   24.74 +    @Candidate
   24.75 +    static void m_char(char... c) {}
   24.76 +    @Candidate
   24.77 +    static void m_char(Character... c) {}
   24.78 +
   24.79 +    @Candidate(applicable=Phase.BOX, mostSpecific=true)
   24.80 +    static void m_bool(Boolean z) {}
   24.81 +    @Candidate
   24.82 +    static void m_bool(boolean... z) {}
   24.83 +    @Candidate
   24.84 +    static void m_bool(Boolean... z) {}
   24.85 +
   24.86 +    {
   24.87 +        m_byte((byte)0);
   24.88 +        m_short((short)0);
   24.89 +        m_int(0);
   24.90 +        m_long(0L);
   24.91 +        m_float(0.0f);
   24.92 +        m_double(0.0);
   24.93 +        m_char('?');
   24.94 +        m_bool(false);
   24.95 +    }
   24.96 +}
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/test/tools/javac/resolve/tests/ReferenceOverload.java	Mon Oct 24 13:00:30 2011 +0100
    25.3 @@ -0,0 +1,95 @@
    25.4 +/*
    25.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
    25.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    25.7 + *
    25.8 + * This code is free software; you can redistribute it and/or modify it
    25.9 + * under the terms of the GNU General Public License version 2 only, as
   25.10 + * published by the Free Software Foundation.
   25.11 + *
   25.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
   25.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   25.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   25.15 + * version 2 for more details (a copy is included in the LICENSE file that
   25.16 + * accompanied this code).
   25.17 + *
   25.18 + * You should have received a copy of the GNU General Public License version
   25.19 + * 2 along with this work; if not, write to the Free Software Foundation,
   25.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   25.21 + *
   25.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   25.23 + * or visit www.oracle.com if you need additional information or have any
   25.24 + * questions.
   25.25 + */
   25.26 +
   25.27 +@TraceResolve
   25.28 +class ReferenceOverload {
   25.29 +
   25.30 +    static class A {}
   25.31 +    static class B extends A {}
   25.32 +    static class C extends B {}
   25.33 +    static class D extends C {}
   25.34 +    static class E extends D {}
   25.35 +
   25.36 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
   25.37 +    static void m_A(A a) {}
   25.38 +    @Candidate
   25.39 +    static void m_A(B a) {}
   25.40 +    @Candidate
   25.41 +    static void m_A(C a) {}
   25.42 +    @Candidate
   25.43 +    static void m_A(D a) {}
   25.44 +    @Candidate
   25.45 +    static void m_A(E a) {}
   25.46 +
   25.47 +    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
   25.48 +    static void m_B(A b) {}
   25.49 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
   25.50 +    static void m_B(B b) {}
   25.51 +    @Candidate
   25.52 +    static void m_B(C b) {}
   25.53 +    @Candidate
   25.54 +    static void m_B(D b) {}
   25.55 +    @Candidate
   25.56 +    static void m_B(E b) {}
   25.57 +
   25.58 +    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
   25.59 +    static void m_C(A c) {}
   25.60 +    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
   25.61 +    static void m_C(B c) {}
   25.62 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
   25.63 +    static void m_C(C c) {}
   25.64 +    @Candidate
   25.65 +    static void m_C(D c) {}
   25.66 +    @Candidate
   25.67 +    static void m_C(E c) {}
   25.68 +
   25.69 +    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
   25.70 +    static void m_D(A d) {}
   25.71 +    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
   25.72 +    static void m_D(B d) {}
   25.73 +    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
   25.74 +    static void m_D(C d) {}
   25.75 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
   25.76 +    static void m_D(D d) {}
   25.77 +    @Candidate
   25.78 +    static void m_D(E d) {}
   25.79 +
   25.80 +    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
   25.81 +    static void m_E(A e) {}
   25.82 +    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
   25.83 +    static void m_E(B e) {}
   25.84 +    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
   25.85 +    static void m_E(C e) {}
   25.86 +    @Candidate(applicable=Phase.BASIC, mostSpecific=false)
   25.87 +    static void m_E(D e) {}
   25.88 +    @Candidate(applicable=Phase.BASIC, mostSpecific=true)
   25.89 +    static void m_E(E e) {}
   25.90 +
   25.91 +    {
   25.92 +        m_A((A)null);
   25.93 +        m_B((B)null);
   25.94 +        m_C((C)null);
   25.95 +        m_D((D)null);
   25.96 +        m_E((E)null);
   25.97 +    }
   25.98 +}

mercurial