1.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Nov 16 18:27:36 2012 +0000 1.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Sat Nov 17 19:01:03 2012 +0000 1.3 @@ -120,8 +120,7 @@ 1.4 allowCovariantReturns = source.allowCovariantReturns(); 1.5 allowSimplifiedVarargs = source.allowSimplifiedVarargs(); 1.6 allowDefaultMethods = source.allowDefaultMethods(); 1.7 - allowStrictMethodClashCheck = source.allowStrictMethodClashCheck() && 1.8 - options.isSet("strictMethodClashCheck"); //pre-lambda guard 1.9 + allowStrictMethodClashCheck = source.allowStrictMethodClashCheck(); 1.10 complexInference = options.isSet("complexinference"); 1.11 warnOnSyntheticConflicts = options.isSet("warnOnSyntheticConflicts"); 1.12 suppressAbortOnBadClassFile = options.isSet("suppressAbortOnBadClassFile"); 1.13 @@ -451,8 +450,6 @@ 1.14 public Infer.InferenceContext inferenceContext(); 1.15 1.16 public DeferredAttr.DeferredAttrContext deferredAttrContext(); 1.17 - 1.18 - public boolean allowBoxing(); 1.19 } 1.20 1.21 /** 1.22 @@ -487,10 +484,6 @@ 1.23 public DeferredAttrContext deferredAttrContext() { 1.24 return enclosingContext.deferredAttrContext(); 1.25 } 1.26 - 1.27 - public boolean allowBoxing() { 1.28 - return enclosingContext.allowBoxing(); 1.29 - } 1.30 } 1.31 1.32 /** 1.33 @@ -515,10 +508,6 @@ 1.34 public DeferredAttrContext deferredAttrContext() { 1.35 return deferredAttr.emptyDeferredAttrContext; 1.36 } 1.37 - 1.38 - public boolean allowBoxing() { 1.39 - return true; 1.40 - } 1.41 }; 1.42 1.43 /** Check that a given type is assignable to a given proto-type. 1.44 @@ -625,7 +614,7 @@ 1.45 a = types.upperBound(a); 1.46 return types.isSubtype(a, bound); 1.47 } else if (a.isExtendsBound()) { 1.48 - return types.isCastable(bound, types.upperBound(a), Warner.noWarnings); 1.49 + return types.isCastable(bound, types.upperBound(a), types.noWarnings); 1.50 } else if (a.isSuperBound()) { 1.51 return !types.notSoftSubtype(types.lowerBound(a), bound); 1.52 } 1.53 @@ -909,19 +898,21 @@ 1.54 "unchecked.generic.array.creation", 1.55 argtype); 1.56 } 1.57 - Type elemtype = types.elemtype(argtype); 1.58 - switch (tree.getTag()) { 1.59 - case APPLY: 1.60 - ((JCMethodInvocation) tree).varargsElement = elemtype; 1.61 - break; 1.62 - case NEWCLASS: 1.63 - ((JCNewClass) tree).varargsElement = elemtype; 1.64 - break; 1.65 - case REFERENCE: 1.66 - ((JCMemberReference) tree).varargsElement = elemtype; 1.67 - break; 1.68 - default: 1.69 - throw new AssertionError(""+tree); 1.70 + if (!((MethodSymbol)sym.baseSymbol()).isSignaturePolymorphic(types)) { 1.71 + Type elemtype = types.elemtype(argtype); 1.72 + switch (tree.getTag()) { 1.73 + case APPLY: 1.74 + ((JCMethodInvocation) tree).varargsElement = elemtype; 1.75 + break; 1.76 + case NEWCLASS: 1.77 + ((JCNewClass) tree).varargsElement = elemtype; 1.78 + break; 1.79 + case REFERENCE: 1.80 + ((JCMemberReference) tree).varargsElement = elemtype; 1.81 + break; 1.82 + default: 1.83 + throw new AssertionError(""+tree); 1.84 + } 1.85 } 1.86 } 1.87 return owntype; 1.88 @@ -937,65 +928,6 @@ 1.89 return; 1.90 } 1.91 1.92 - void checkAccessibleFunctionalDescriptor(DiagnosticPosition pos, Env<AttrContext> env, Type desc) { 1.93 - AccessChecker accessChecker = new AccessChecker(env); 1.94 - //check args accessibility (only if implicit parameter types) 1.95 - for (Type arg : desc.getParameterTypes()) { 1.96 - if (!accessChecker.visit(arg)) { 1.97 - log.error(pos, "cant.access.arg.type.in.functional.desc", arg); 1.98 - return; 1.99 - } 1.100 - } 1.101 - //check return type accessibility 1.102 - if (!accessChecker.visit(desc.getReturnType())) { 1.103 - log.error(pos, "cant.access.return.in.functional.desc", desc.getReturnType()); 1.104 - return; 1.105 - } 1.106 - //check thrown types accessibility 1.107 - for (Type thrown : desc.getThrownTypes()) { 1.108 - if (!accessChecker.visit(thrown)) { 1.109 - log.error(pos, "cant.access.thrown.in.functional.desc", thrown); 1.110 - return; 1.111 - } 1.112 - } 1.113 - } 1.114 - 1.115 - class AccessChecker extends Types.UnaryVisitor<Boolean> { 1.116 - 1.117 - Env<AttrContext> env; 1.118 - 1.119 - AccessChecker(Env<AttrContext> env) { 1.120 - this.env = env; 1.121 - } 1.122 - 1.123 - Boolean visit(List<Type> ts) { 1.124 - for (Type t : ts) { 1.125 - if (!visit(t)) 1.126 - return false; 1.127 - } 1.128 - return true; 1.129 - } 1.130 - 1.131 - public Boolean visitType(Type t, Void s) { 1.132 - return true; 1.133 - } 1.134 - 1.135 - @Override 1.136 - public Boolean visitArrayType(ArrayType t, Void s) { 1.137 - return visit(t.elemtype); 1.138 - } 1.139 - 1.140 - @Override 1.141 - public Boolean visitClassType(ClassType t, Void s) { 1.142 - return rs.isAccessible(env, t, true) && 1.143 - visit(t.getTypeArguments()); 1.144 - } 1.145 - 1.146 - @Override 1.147 - public Boolean visitWildcardType(WildcardType t, Void s) { 1.148 - return visit(t.type); 1.149 - } 1.150 - }; 1.151 /** 1.152 * Check that type 't' is a valid instantiation of a generic class 1.153 * (see JLS 4.5) 1.154 @@ -1919,8 +1851,8 @@ 1.155 types.isSameType(rt1, rt2) || 1.156 !rt1.isPrimitiveOrVoid() && 1.157 !rt2.isPrimitiveOrVoid() && 1.158 - (types.covariantReturnType(rt1, rt2, Warner.noWarnings) || 1.159 - types.covariantReturnType(rt2, rt1, Warner.noWarnings)) || 1.160 + (types.covariantReturnType(rt1, rt2, types.noWarnings) || 1.161 + types.covariantReturnType(rt2, rt1, types.noWarnings)) || 1.162 checkCommonOverriderIn(s1,s2,site); 1.163 if (!compat) { 1.164 log.error(pos, "types.incompatible.diff.ret", 1.165 @@ -1965,8 +1897,8 @@ 1.166 boolean compat = 1.167 !rt13.isPrimitiveOrVoid() && 1.168 !rt23.isPrimitiveOrVoid() && 1.169 - (types.covariantReturnType(rt13, rt1, Warner.noWarnings) && 1.170 - types.covariantReturnType(rt23, rt2, Warner.noWarnings)); 1.171 + (types.covariantReturnType(rt13, rt1, types.noWarnings) && 1.172 + types.covariantReturnType(rt23, rt2, types.noWarnings)); 1.173 if (compat) 1.174 return true; 1.175 } 1.176 @@ -2280,19 +2212,33 @@ 1.177 c.flags_field |= ACYCLIC; 1.178 } 1.179 1.180 + /** 1.181 + * Check that functional interface methods would make sense when seen 1.182 + * from the perspective of the implementing class 1.183 + */ 1.184 + void checkFunctionalInterface(JCTree tree, Type funcInterface) { 1.185 + ClassType c = new ClassType(Type.noType, List.<Type>nil(), null); 1.186 + ClassSymbol csym = new ClassSymbol(0, names.empty, c, syms.noSymbol); 1.187 + c.interfaces_field = List.of(funcInterface); 1.188 + c.supertype_field = syms.objectType; 1.189 + c.tsym = csym; 1.190 + csym.members_field = new Scope(csym); 1.191 + csym.completer = null; 1.192 + checkImplementations(tree, csym, csym); 1.193 + } 1.194 + 1.195 /** Check that all methods which implement some 1.196 * method conform to the method they implement. 1.197 * @param tree The class definition whose members are checked. 1.198 */ 1.199 void checkImplementations(JCClassDecl tree) { 1.200 - checkImplementations(tree, tree.sym); 1.201 + checkImplementations(tree, tree.sym, tree.sym); 1.202 } 1.203 //where 1.204 /** Check that all methods which implement some 1.205 * method in `ic' conform to the method they implement. 1.206 */ 1.207 - void checkImplementations(JCClassDecl tree, ClassSymbol ic) { 1.208 - ClassSymbol origin = tree.sym; 1.209 + void checkImplementations(JCTree tree, ClassSymbol origin, ClassSymbol ic) { 1.210 for (List<Type> l = types.closure(ic.type); l.nonEmpty(); l = l.tail) { 1.211 ClassSymbol lc = (ClassSymbol)l.head.tsym; 1.212 if ((allowGenerics || origin != lc) && (lc.flags() & ABSTRACT) != 0) {