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

changeset 2260
fb870c70e774
parent 2219
5bf0af735c61
child 2261
79dc4b992c0a
equal deleted inserted replaced
2259:fcebccb14d4b 2260:fb870c70e774
1 /* 1 /*
2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this 7 * published by the Free Software Foundation. Oracle designates this
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; // = source.allowBoxing();
96 public final boolean varargsEnabled; // = source.allowVarargs(); 96 public final boolean varargsEnabled; // = source.allowVarargs();
97 public final boolean allowMethodHandles; 97 public final boolean allowMethodHandles;
98 public final boolean allowDefaultMethods; 98 public final boolean allowDefaultMethodsResolution;
99 public final boolean allowStructuralMostSpecific; 99 public final boolean allowStructuralMostSpecific;
100 private final boolean debugResolve; 100 private final boolean debugResolve;
101 private final boolean compactMethodDiags; 101 private final boolean compactMethodDiags;
102 final EnumSet<VerboseResolutionMode> verboseResolutionMode; 102 final EnumSet<VerboseResolutionMode> verboseResolutionMode;
103 103
135 compactMethodDiags = options.isSet(Option.XDIAGS, "compact") || 135 compactMethodDiags = options.isSet(Option.XDIAGS, "compact") ||
136 options.isUnset(Option.XDIAGS) && options.isUnset("rawDiagnostics"); 136 options.isUnset(Option.XDIAGS) && options.isUnset("rawDiagnostics");
137 verboseResolutionMode = VerboseResolutionMode.getVerboseResolutionMode(options); 137 verboseResolutionMode = VerboseResolutionMode.getVerboseResolutionMode(options);
138 Target target = Target.instance(context); 138 Target target = Target.instance(context);
139 allowMethodHandles = target.hasMethodHandles(); 139 allowMethodHandles = target.hasMethodHandles();
140 allowDefaultMethods = source.allowDefaultMethods(); 140 allowDefaultMethodsResolution = source.allowDefaultMethodsResolution();
141 allowStructuralMostSpecific = source.allowStructuralMostSpecific(); 141 allowStructuralMostSpecific = source.allowStructuralMostSpecific();
142 polymorphicSignatureScope = new Scope(syms.noSymbol); 142 polymorphicSignatureScope = new Scope(syms.noSymbol);
143 143
144 inapplicableMethodException = new InapplicableMethodException(diags); 144 inapplicableMethodException = new InapplicableMethodException(diags);
145 } 145 }
1679 Symbol concrete = bestSoFar.kind < ERR && 1679 Symbol concrete = bestSoFar.kind < ERR &&
1680 (bestSoFar.flags() & ABSTRACT) == 0 ? 1680 (bestSoFar.flags() & ABSTRACT) == 0 ?
1681 bestSoFar : methodNotFound; 1681 bestSoFar : methodNotFound;
1682 1682
1683 for (InterfaceLookupPhase iphase2 : InterfaceLookupPhase.values()) { 1683 for (InterfaceLookupPhase iphase2 : InterfaceLookupPhase.values()) {
1684 if (iphase2 == InterfaceLookupPhase.DEFAULT_OK && !allowDefaultMethods) break; 1684 if (iphase2 == InterfaceLookupPhase.DEFAULT_OK && !allowDefaultMethodsResolution) break;
1685 //keep searching for abstract methods 1685 //keep searching for abstract methods
1686 for (Type itype : itypes[iphase2.ordinal()]) { 1686 for (Type itype : itypes[iphase2.ordinal()]) {
1687 if (!itype.isInterface()) continue; //skip j.l.Object (included by Types.closure()) 1687 if (!itype.isInterface()) continue; //skip j.l.Object (included by Types.closure())
1688 if (iphase2 == InterfaceLookupPhase.DEFAULT_OK && 1688 if (iphase2 == InterfaceLookupPhase.DEFAULT_OK &&
1689 (itype.tsym.flags() & DEFAULT) == 0) continue; 1689 (itype.tsym.flags() & DEFAULT) == 0) continue;
1712 //We should not look for abstract methods if receiver is a concrete class 1712 //We should not look for abstract methods if receiver is a concrete class
1713 //(as concrete classes are expected to implement all abstracts coming 1713 //(as concrete classes are expected to implement all abstracts coming
1714 //from superinterfaces) 1714 //from superinterfaces)
1715 if ((s.flags() & (ABSTRACT | INTERFACE | ENUM)) != 0) { 1715 if ((s.flags() & (ABSTRACT | INTERFACE | ENUM)) != 0) {
1716 return this; 1716 return this;
1717 } else if (rs.allowDefaultMethods) { 1717 } else if (rs.allowDefaultMethodsResolution) {
1718 return DEFAULT_OK; 1718 return DEFAULT_OK;
1719 } else { 1719 } else {
1720 return null; 1720 return null;
1721 } 1721 }
1722 } 1722 }
3339 } 3339 }
3340 } 3340 }
3341 if ((env1.enclClass.sym.flags() & STATIC) != 0) staticOnly = true; 3341 if ((env1.enclClass.sym.flags() & STATIC) != 0) staticOnly = true;
3342 env1 = env1.outer; 3342 env1 = env1.outer;
3343 } 3343 }
3344 if (allowDefaultMethods && c.isInterface() && 3344 if (allowDefaultMethodsResolution && c.isInterface() &&
3345 name == names._super && !isStatic(env) && 3345 name == names._super && !isStatic(env) &&
3346 types.isDirectSuperInterface(c, env.enclClass.sym)) { 3346 types.isDirectSuperInterface(c, env.enclClass.sym)) {
3347 //this might be a default super call if one of the superinterfaces is 'c' 3347 //this might be a default super call if one of the superinterfaces is 'c'
3348 for (Type t : pruneInterfaces(env.enclClass.type)) { 3348 for (Type t : pruneInterfaces(env.enclClass.type)) {
3349 if (t.tsym == c) { 3349 if (t.tsym == c) {

mercurial