src/share/classes/com/sun/tools/javac/comp/Resolve.java

changeset 2261
79dc4b992c0a
parent 2260
fb870c70e774
child 2368
0524f786d7e8
equal deleted inserted replaced
2260:fb870c70e774 2261:79dc4b992c0a
90 Infer infer; 90 Infer infer;
91 ClassReader reader; 91 ClassReader reader;
92 TreeInfo treeinfo; 92 TreeInfo treeinfo;
93 Types types; 93 Types types;
94 JCDiagnostic.Factory diags; 94 JCDiagnostic.Factory diags;
95 public final boolean boxingEnabled; // = source.allowBoxing(); 95 public final boolean boxingEnabled;
96 public final boolean varargsEnabled; // = source.allowVarargs(); 96 public final boolean varargsEnabled;
97 public final boolean allowMethodHandles; 97 public final boolean allowMethodHandles;
98 public final boolean allowDefaultMethodsResolution;
99 public final boolean allowStructuralMostSpecific; 98 public final boolean allowStructuralMostSpecific;
100 private final boolean debugResolve; 99 private final boolean debugResolve;
101 private final boolean compactMethodDiags; 100 private final boolean compactMethodDiags;
102 final EnumSet<VerboseResolutionMode> verboseResolutionMode; 101 final EnumSet<VerboseResolutionMode> verboseResolutionMode;
103 102
135 compactMethodDiags = options.isSet(Option.XDIAGS, "compact") || 134 compactMethodDiags = options.isSet(Option.XDIAGS, "compact") ||
136 options.isUnset(Option.XDIAGS) && options.isUnset("rawDiagnostics"); 135 options.isUnset(Option.XDIAGS) && options.isUnset("rawDiagnostics");
137 verboseResolutionMode = VerboseResolutionMode.getVerboseResolutionMode(options); 136 verboseResolutionMode = VerboseResolutionMode.getVerboseResolutionMode(options);
138 Target target = Target.instance(context); 137 Target target = Target.instance(context);
139 allowMethodHandles = target.hasMethodHandles(); 138 allowMethodHandles = target.hasMethodHandles();
140 allowDefaultMethodsResolution = source.allowDefaultMethodsResolution();
141 allowStructuralMostSpecific = source.allowStructuralMostSpecific(); 139 allowStructuralMostSpecific = source.allowStructuralMostSpecific();
142 polymorphicSignatureScope = new Scope(syms.noSymbol); 140 polymorphicSignatureScope = new Scope(syms.noSymbol);
143 141
144 inapplicableMethodException = new InapplicableMethodException(diags); 142 inapplicableMethodException = new InapplicableMethodException(diags);
145 } 143 }
1679 Symbol concrete = bestSoFar.kind < ERR && 1677 Symbol concrete = bestSoFar.kind < ERR &&
1680 (bestSoFar.flags() & ABSTRACT) == 0 ? 1678 (bestSoFar.flags() & ABSTRACT) == 0 ?
1681 bestSoFar : methodNotFound; 1679 bestSoFar : methodNotFound;
1682 1680
1683 for (InterfaceLookupPhase iphase2 : InterfaceLookupPhase.values()) { 1681 for (InterfaceLookupPhase iphase2 : InterfaceLookupPhase.values()) {
1684 if (iphase2 == InterfaceLookupPhase.DEFAULT_OK && !allowDefaultMethodsResolution) break;
1685 //keep searching for abstract methods 1682 //keep searching for abstract methods
1686 for (Type itype : itypes[iphase2.ordinal()]) { 1683 for (Type itype : itypes[iphase2.ordinal()]) {
1687 if (!itype.isInterface()) continue; //skip j.l.Object (included by Types.closure()) 1684 if (!itype.isInterface()) continue; //skip j.l.Object (included by Types.closure())
1688 if (iphase2 == InterfaceLookupPhase.DEFAULT_OK && 1685 if (iphase2 == InterfaceLookupPhase.DEFAULT_OK &&
1689 (itype.tsym.flags() & DEFAULT) == 0) continue; 1686 (itype.tsym.flags() & DEFAULT) == 0) continue;
1712 //We should not look for abstract methods if receiver is a concrete class 1709 //We should not look for abstract methods if receiver is a concrete class
1713 //(as concrete classes are expected to implement all abstracts coming 1710 //(as concrete classes are expected to implement all abstracts coming
1714 //from superinterfaces) 1711 //from superinterfaces)
1715 if ((s.flags() & (ABSTRACT | INTERFACE | ENUM)) != 0) { 1712 if ((s.flags() & (ABSTRACT | INTERFACE | ENUM)) != 0) {
1716 return this; 1713 return this;
1717 } else if (rs.allowDefaultMethodsResolution) { 1714 } else {
1718 return DEFAULT_OK; 1715 return DEFAULT_OK;
1719 } else {
1720 return null;
1721 } 1716 }
1722 } 1717 }
1723 }, 1718 },
1724 DEFAULT_OK() { 1719 DEFAULT_OK() {
1725 @Override 1720 @Override
3339 } 3334 }
3340 } 3335 }
3341 if ((env1.enclClass.sym.flags() & STATIC) != 0) staticOnly = true; 3336 if ((env1.enclClass.sym.flags() & STATIC) != 0) staticOnly = true;
3342 env1 = env1.outer; 3337 env1 = env1.outer;
3343 } 3338 }
3344 if (allowDefaultMethodsResolution && c.isInterface() && 3339 if (c.isInterface() &&
3345 name == names._super && !isStatic(env) && 3340 name == names._super && !isStatic(env) &&
3346 types.isDirectSuperInterface(c, env.enclClass.sym)) { 3341 types.isDirectSuperInterface(c, env.enclClass.sym)) {
3347 //this might be a default super call if one of the superinterfaces is 'c' 3342 //this might be a default super call if one of the superinterfaces is 'c'
3348 for (Type t : pruneInterfaces(env.enclClass.type)) { 3343 for (Type t : pruneInterfaces(env.enclClass.type)) {
3349 if (t.tsym == c) { 3344 if (t.tsym == c) {
3350 env.info.defaultSuperCallSite = t; 3345 env.info.defaultSuperCallSite = t;
3351 return new VarSymbol(0, names._super, 3346 return new VarSymbol(0, names._super,

mercurial