Thu, 06 Nov 2014 09:49:49 -0800
Merge
.hgtags | file | annotate | diff | comparison | revisions |
1.1 --- a/.hgtags Mon Oct 27 14:35:21 2014 -0700 1.2 +++ b/.hgtags Thu Nov 06 09:49:49 2014 -0800 1.3 @@ -340,6 +340,8 @@ 1.4 6ce4f2acf83e17d084b9b9bce2ef98438e984064 jdk8u31-b03 1.5 c271515197807db2f0496945241f0b09885af99b jdk8u31-b04 1.6 2deb2110e81fc38f5b45842fd478aae168d2d27a jdk8u31-b05 1.7 +fe1980c653be1fa9fb50353c5a5305855dcd7bd4 jdk8u31-b06 1.8 +03b8ef4cf0c00aa040db27c7d8e68fa8b6133afd jdk8u31-b07 1.9 d231957fe3103e790465fcf058fb8cb33bbc4c4e jdk8u40-b00 1.10 bf89a471779d13a9407f7d1c86f7716258bc4aa6 jdk8u40-b01 1.11 0b6cc4ea670f5d17b56c088f202869bdbb80a5ce jdk8u40-b02 1.12 @@ -352,4 +354,6 @@ 1.13 8bb38a35072279618aa2cacd4fea74155a6dccf9 jdk8u40-b09 1.14 69b84370397fbb5a66b99578242c47da7f8b3cb5 jdk8u40-b10 1.15 d3c93dc64c5e1ffd610fb31362a78bedfd8097ba jdk8u40-b11 1.16 +e7560bceb36a933f5eb6ce8c33dce030ba0288f2 jdk8u40-b12 1.17 +88ce114c6adc387dc7fc5831b8263f152f0412fb jdk8u40-b13 1.18 dbae37f50c43453f7d6f22d96adc8b5b6cd1e90d jdk8u45-b00
2.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java Mon Oct 27 14:35:21 2014 -0700 2.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Thu Nov 06 09:49:49 2014 -0800 2.3 @@ -1892,7 +1892,12 @@ 2.4 * Mapping to take element type of an arraytype 2.5 */ 2.6 private Mapping elemTypeFun = new Mapping ("elemTypeFun") { 2.7 - public Type apply(Type t) { return elemtype(t); } 2.8 + public Type apply(Type t) { 2.9 + while (t.hasTag(TYPEVAR)) { 2.10 + t = t.getUpperBound(); 2.11 + } 2.12 + return elemtype(t); 2.13 + } 2.14 }; 2.15 2.16 /** 2.17 @@ -3521,40 +3526,46 @@ 2.18 } 2.19 2.20 /** 2.21 - * Return the least upper bound of pair of types. if the lub does 2.22 + * Return the least upper bound of list of types. if the lub does 2.23 * not exist return null. 2.24 */ 2.25 - public Type lub(Type t1, Type t2) { 2.26 - return lub(List.of(t1, t2)); 2.27 + public Type lub(List<Type> ts) { 2.28 + return lub(ts.toArray(new Type[ts.length()])); 2.29 } 2.30 2.31 /** 2.32 * Return the least upper bound (lub) of set of types. If the lub 2.33 * does not exist return the type of null (bottom). 2.34 */ 2.35 - public Type lub(List<Type> ts) { 2.36 + public Type lub(Type... ts) { 2.37 + final int UNKNOWN_BOUND = 0; 2.38 final int ARRAY_BOUND = 1; 2.39 final int CLASS_BOUND = 2; 2.40 - int boundkind = 0; 2.41 - for (Type t : ts) { 2.42 + 2.43 + int[] kinds = new int[ts.length]; 2.44 + 2.45 + int boundkind = UNKNOWN_BOUND; 2.46 + for (int i = 0 ; i < ts.length ; i++) { 2.47 + Type t = ts[i]; 2.48 switch (t.getTag()) { 2.49 case CLASS: 2.50 - boundkind |= CLASS_BOUND; 2.51 + boundkind |= kinds[i] = CLASS_BOUND; 2.52 break; 2.53 case ARRAY: 2.54 - boundkind |= ARRAY_BOUND; 2.55 + boundkind |= kinds[i] = ARRAY_BOUND; 2.56 break; 2.57 case TYPEVAR: 2.58 do { 2.59 t = t.getUpperBound(); 2.60 } while (t.hasTag(TYPEVAR)); 2.61 if (t.hasTag(ARRAY)) { 2.62 - boundkind |= ARRAY_BOUND; 2.63 + boundkind |= kinds[i] = ARRAY_BOUND; 2.64 } else { 2.65 - boundkind |= CLASS_BOUND; 2.66 + boundkind |= kinds[i] = CLASS_BOUND; 2.67 } 2.68 break; 2.69 default: 2.70 + kinds[i] = UNKNOWN_BOUND; 2.71 if (t.isPrimitive()) 2.72 return syms.errType; 2.73 } 2.74 @@ -3565,15 +3576,16 @@ 2.75 2.76 case ARRAY_BOUND: 2.77 // calculate lub(A[], B[]) 2.78 - List<Type> elements = Type.map(ts, elemTypeFun); 2.79 - for (Type t : elements) { 2.80 - if (t.isPrimitive()) { 2.81 + Type[] elements = new Type[ts.length]; 2.82 + for (int i = 0 ; i < ts.length ; i++) { 2.83 + Type elem = elements[i] = elemTypeFun.apply(ts[i]); 2.84 + if (elem.isPrimitive()) { 2.85 // if a primitive type is found, then return 2.86 // arraySuperType unless all the types are the 2.87 // same 2.88 - Type first = ts.head; 2.89 - for (Type s : ts.tail) { 2.90 - if (!isSameType(first, s)) { 2.91 + Type first = ts[0]; 2.92 + for (int j = 1 ; j < ts.length ; j++) { 2.93 + if (!isSameType(first, ts[j])) { 2.94 // lub(int[], B[]) is Cloneable & Serializable 2.95 return arraySuperType(); 2.96 } 2.97 @@ -3588,13 +3600,20 @@ 2.98 2.99 case CLASS_BOUND: 2.100 // calculate lub(A, B) 2.101 - while (!ts.head.hasTag(CLASS) && !ts.head.hasTag(TYPEVAR)) { 2.102 - ts = ts.tail; 2.103 + int startIdx = 0; 2.104 + for (int i = 0; i < ts.length ; i++) { 2.105 + Type t = ts[i]; 2.106 + if (t.hasTag(CLASS) || t.hasTag(TYPEVAR)) { 2.107 + break; 2.108 + } else { 2.109 + startIdx++; 2.110 + } 2.111 } 2.112 - Assert.check(!ts.isEmpty()); 2.113 + Assert.check(startIdx < ts.length); 2.114 //step 1 - compute erased candidate set (EC) 2.115 - List<Type> cl = erasedSupertypes(ts.head); 2.116 - for (Type t : ts.tail) { 2.117 + List<Type> cl = erasedSupertypes(ts[startIdx]); 2.118 + for (int i = startIdx + 1 ; i < ts.length ; i++) { 2.119 + Type t = ts[i]; 2.120 if (t.hasTag(CLASS) || t.hasTag(TYPEVAR)) 2.121 cl = intersect(cl, erasedSupertypes(t)); 2.122 } 2.123 @@ -3603,9 +3622,9 @@ 2.124 //step 3 - for each element G in MEC, compute lci(Inv(G)) 2.125 List<Type> candidates = List.nil(); 2.126 for (Type erasedSupertype : mec) { 2.127 - List<Type> lci = List.of(asSuper(ts.head, erasedSupertype.tsym)); 2.128 - for (Type t : ts) { 2.129 - lci = intersect(lci, List.of(asSuper(t, erasedSupertype.tsym))); 2.130 + List<Type> lci = List.of(asSuper(ts[startIdx], erasedSupertype.tsym)); 2.131 + for (int i = startIdx + 1 ; i < ts.length ; i++) { 2.132 + lci = intersect(lci, List.of(asSuper(ts[i], erasedSupertype.tsym))); 2.133 } 2.134 candidates = candidates.appendList(lci); 2.135 } 2.136 @@ -3616,9 +3635,9 @@ 2.137 default: 2.138 // calculate lub(A, B[]) 2.139 List<Type> classes = List.of(arraySuperType()); 2.140 - for (Type t : ts) { 2.141 - if (!t.hasTag(ARRAY)) // Filter out any arrays 2.142 - classes = classes.prepend(t); 2.143 + for (int i = 0 ; i < ts.length ; i++) { 2.144 + if (kinds[i] != ARRAY_BOUND) // Filter out any arrays 2.145 + classes = classes.prepend(ts[i]); 2.146 } 2.147 // lub(A, B[]) is lub(A, arraySuperType) 2.148 return lub(classes);
3.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Mon Oct 27 14:35:21 2014 -0700 3.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Thu Nov 06 09:49:49 2014 -0800 3.3 @@ -1010,8 +1010,12 @@ 3.4 // parameters have already been entered 3.5 env.info.scope.enter(tree.sym); 3.6 } else { 3.7 - memberEnter.memberEnter(tree, env); 3.8 - annotate.flush(); 3.9 + try { 3.10 + annotate.enterStart(); 3.11 + memberEnter.memberEnter(tree, env); 3.12 + } finally { 3.13 + annotate.enterDone(); 3.14 + } 3.15 } 3.16 } else { 3.17 if (tree.init != null) {
4.1 --- a/src/share/classes/com/sun/tools/javac/comp/Flow.java Mon Oct 27 14:35:21 2014 -0700 4.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Flow.java Thu Nov 06 09:49:49 2014 -0800 4.3 @@ -247,7 +247,7 @@ 4.4 return !env.info.scope.includes(sym) && 4.5 sym.owner.kind == MTH; 4.6 } 4.7 - }.analyzeTree(env); 4.8 + }.analyzeTree(env, that); 4.9 LambdaFlowAnalyzer flowAnalyzer = new LambdaFlowAnalyzer(); 4.10 flowAnalyzer.analyzeTree(env, that, make); 4.11 return flowAnalyzer.inferredThrownTypes;
5.1 --- a/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Mon Oct 27 14:35:21 2014 -0700 5.2 +++ b/src/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java Thu Nov 06 09:49:49 2014 -0800 5.3 @@ -846,6 +846,10 @@ 5.4 if (rcvr == null) return null; 5.5 JCExpression rcvrExpr = make.Ident(rcvr); 5.6 Type rcvrType = tree.sym.enclClass().type; 5.7 + if (rcvrType == syms.arrayClass.type) { 5.8 + // Map the receiver type to the actually type, not just "array" 5.9 + rcvrType = tree.getQualifierExpression().type; 5.10 + } 5.11 if (!rcvr.type.tsym.isSubClass(rcvrType.tsym, types)) { 5.12 rcvrExpr = make.TypeCast(make.Type(rcvrType), rcvrExpr).setType(rcvrType); 5.13 }
6.1 --- a/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Mon Oct 27 14:35:21 2014 -0700 6.2 +++ b/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Thu Nov 06 09:49:49 2014 -0800 6.3 @@ -575,51 +575,46 @@ 6.4 6.5 Env<AttrContext> localEnv = methodEnv(tree, env); 6.6 6.7 - annotate.enterStart(); 6.8 + DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos()); 6.9 try { 6.10 - DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos()); 6.11 - try { 6.12 - // Compute the method type 6.13 - m.type = signature(m, tree.typarams, tree.params, 6.14 - tree.restype, tree.recvparam, 6.15 - tree.thrown, 6.16 - localEnv); 6.17 - } finally { 6.18 - deferredLintHandler.setPos(prevLintPos); 6.19 - } 6.20 + // Compute the method type 6.21 + m.type = signature(m, tree.typarams, tree.params, 6.22 + tree.restype, tree.recvparam, 6.23 + tree.thrown, 6.24 + localEnv); 6.25 + } finally { 6.26 + deferredLintHandler.setPos(prevLintPos); 6.27 + } 6.28 6.29 - if (types.isSignaturePolymorphic(m)) { 6.30 - m.flags_field |= SIGNATURE_POLYMORPHIC; 6.31 - } 6.32 + if (types.isSignaturePolymorphic(m)) { 6.33 + m.flags_field |= SIGNATURE_POLYMORPHIC; 6.34 + } 6.35 6.36 - // Set m.params 6.37 - ListBuffer<VarSymbol> params = new ListBuffer<VarSymbol>(); 6.38 - JCVariableDecl lastParam = null; 6.39 - for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) { 6.40 - JCVariableDecl param = lastParam = l.head; 6.41 - params.append(Assert.checkNonNull(param.sym)); 6.42 - } 6.43 - m.params = params.toList(); 6.44 + // Set m.params 6.45 + ListBuffer<VarSymbol> params = new ListBuffer<VarSymbol>(); 6.46 + JCVariableDecl lastParam = null; 6.47 + for (List<JCVariableDecl> l = tree.params; l.nonEmpty(); l = l.tail) { 6.48 + JCVariableDecl param = lastParam = l.head; 6.49 + params.append(Assert.checkNonNull(param.sym)); 6.50 + } 6.51 + m.params = params.toList(); 6.52 6.53 - // mark the method varargs, if necessary 6.54 - if (lastParam != null && (lastParam.mods.flags & Flags.VARARGS) != 0) 6.55 - m.flags_field |= Flags.VARARGS; 6.56 + // mark the method varargs, if necessary 6.57 + if (lastParam != null && (lastParam.mods.flags & Flags.VARARGS) != 0) 6.58 + m.flags_field |= Flags.VARARGS; 6.59 6.60 - localEnv.info.scope.leave(); 6.61 - if (chk.checkUnique(tree.pos(), m, enclScope)) { 6.62 - enclScope.enter(m); 6.63 - } 6.64 + localEnv.info.scope.leave(); 6.65 + if (chk.checkUnique(tree.pos(), m, enclScope)) { 6.66 + enclScope.enter(m); 6.67 + } 6.68 6.69 - annotateLater(tree.mods.annotations, localEnv, m, tree.pos()); 6.70 - // Visit the signature of the method. Note that 6.71 - // TypeAnnotate doesn't descend into the body. 6.72 - typeAnnotate(tree, localEnv, m, tree.pos()); 6.73 + annotateLater(tree.mods.annotations, localEnv, m, tree.pos()); 6.74 + // Visit the signature of the method. Note that 6.75 + // TypeAnnotate doesn't descend into the body. 6.76 + typeAnnotate(tree, localEnv, m, tree.pos()); 6.77 6.78 - if (tree.defaultValue != null) 6.79 - annotateDefaultValueLater(tree.defaultValue, localEnv, m); 6.80 - } finally { 6.81 - annotate.enterDone(); 6.82 - } 6.83 + if (tree.defaultValue != null) 6.84 + annotateDefaultValueLater(tree.defaultValue, localEnv, m); 6.85 } 6.86 6.87 /** Create a fresh environment for method bodies. 6.88 @@ -647,54 +642,49 @@ 6.89 localEnv.info.staticLevel++; 6.90 } 6.91 DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos()); 6.92 - annotate.enterStart(); 6.93 try { 6.94 - try { 6.95 - if (TreeInfo.isEnumInit(tree)) { 6.96 - attr.attribIdentAsEnumType(localEnv, (JCIdent)tree.vartype); 6.97 - } else { 6.98 - attr.attribType(tree.vartype, localEnv); 6.99 - if (TreeInfo.isReceiverParam(tree)) 6.100 - checkReceiver(tree, localEnv); 6.101 - } 6.102 - } finally { 6.103 - deferredLintHandler.setPos(prevLintPos); 6.104 + if (TreeInfo.isEnumInit(tree)) { 6.105 + attr.attribIdentAsEnumType(localEnv, (JCIdent)tree.vartype); 6.106 + } else { 6.107 + attr.attribType(tree.vartype, localEnv); 6.108 + if (TreeInfo.isReceiverParam(tree)) 6.109 + checkReceiver(tree, localEnv); 6.110 } 6.111 + } finally { 6.112 + deferredLintHandler.setPos(prevLintPos); 6.113 + } 6.114 6.115 - if ((tree.mods.flags & VARARGS) != 0) { 6.116 - //if we are entering a varargs parameter, we need to 6.117 - //replace its type (a plain array type) with the more 6.118 - //precise VarargsType --- we need to do it this way 6.119 - //because varargs is represented in the tree as a 6.120 - //modifier on the parameter declaration, and not as a 6.121 - //distinct type of array node. 6.122 - ArrayType atype = (ArrayType)tree.vartype.type.unannotatedType(); 6.123 - tree.vartype.type = atype.makeVarargs(); 6.124 + if ((tree.mods.flags & VARARGS) != 0) { 6.125 + //if we are entering a varargs parameter, we need to 6.126 + //replace its type (a plain array type) with the more 6.127 + //precise VarargsType --- we need to do it this way 6.128 + //because varargs is represented in the tree as a 6.129 + //modifier on the parameter declaration, and not as a 6.130 + //distinct type of array node. 6.131 + ArrayType atype = (ArrayType)tree.vartype.type.unannotatedType(); 6.132 + tree.vartype.type = atype.makeVarargs(); 6.133 + } 6.134 + Scope enclScope = enter.enterScope(env); 6.135 + VarSymbol v = 6.136 + new VarSymbol(0, tree.name, tree.vartype.type, enclScope.owner); 6.137 + v.flags_field = chk.checkFlags(tree.pos(), tree.mods.flags, v, tree); 6.138 + tree.sym = v; 6.139 + if (tree.init != null) { 6.140 + v.flags_field |= HASINIT; 6.141 + if ((v.flags_field & FINAL) != 0 && 6.142 + needsLazyConstValue(tree.init)) { 6.143 + Env<AttrContext> initEnv = getInitEnv(tree, env); 6.144 + initEnv.info.enclVar = v; 6.145 + v.setLazyConstValue(initEnv(tree, initEnv), attr, tree); 6.146 } 6.147 - Scope enclScope = enter.enterScope(env); 6.148 - VarSymbol v = 6.149 - new VarSymbol(0, tree.name, tree.vartype.type, enclScope.owner); 6.150 - v.flags_field = chk.checkFlags(tree.pos(), tree.mods.flags, v, tree); 6.151 - tree.sym = v; 6.152 - if (tree.init != null) { 6.153 - v.flags_field |= HASINIT; 6.154 - if ((v.flags_field & FINAL) != 0 && 6.155 - needsLazyConstValue(tree.init)) { 6.156 - Env<AttrContext> initEnv = getInitEnv(tree, env); 6.157 - initEnv.info.enclVar = v; 6.158 - v.setLazyConstValue(initEnv(tree, initEnv), attr, tree); 6.159 - } 6.160 - } 6.161 - if (chk.checkUnique(tree.pos(), v, enclScope)) { 6.162 - chk.checkTransparentVar(tree.pos(), v, enclScope); 6.163 - enclScope.enter(v); 6.164 - } 6.165 - annotateLater(tree.mods.annotations, localEnv, v, tree.pos()); 6.166 - typeAnnotate(tree.vartype, env, v, tree.pos()); 6.167 - v.pos = tree.pos; 6.168 - } finally { 6.169 - annotate.enterDone(); 6.170 } 6.171 + if (chk.checkUnique(tree.pos(), v, enclScope)) { 6.172 + chk.checkTransparentVar(tree.pos(), v, enclScope); 6.173 + enclScope.enter(v); 6.174 + } 6.175 + annotateLater(tree.mods.annotations, localEnv, v, tree.pos()); 6.176 + typeAnnotate(tree.vartype, env, v, tree.pos()); 6.177 + v.pos = tree.pos; 6.178 } 6.179 // where 6.180 void checkType(JCTree tree, Type type, String diag) { 6.181 @@ -1030,189 +1020,194 @@ 6.182 JCClassDecl tree = (JCClassDecl)env.tree; 6.183 boolean wasFirst = isFirst; 6.184 isFirst = false; 6.185 + try { 6.186 + annotate.enterStart(); 6.187 6.188 - JavaFileObject prev = log.useSource(env.toplevel.sourcefile); 6.189 - DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos()); 6.190 - try { 6.191 - // Save class environment for later member enter (2) processing. 6.192 - halfcompleted.append(env); 6.193 + JavaFileObject prev = log.useSource(env.toplevel.sourcefile); 6.194 + DiagnosticPosition prevLintPos = deferredLintHandler.setPos(tree.pos()); 6.195 + try { 6.196 + // Save class environment for later member enter (2) processing. 6.197 + halfcompleted.append(env); 6.198 6.199 - // Mark class as not yet attributed. 6.200 - c.flags_field |= UNATTRIBUTED; 6.201 + // Mark class as not yet attributed. 6.202 + c.flags_field |= UNATTRIBUTED; 6.203 6.204 - // If this is a toplevel-class, make sure any preceding import 6.205 - // clauses have been seen. 6.206 - if (c.owner.kind == PCK) { 6.207 - memberEnter(env.toplevel, env.enclosing(TOPLEVEL)); 6.208 - todo.append(env); 6.209 + // If this is a toplevel-class, make sure any preceding import 6.210 + // clauses have been seen. 6.211 + if (c.owner.kind == PCK) { 6.212 + memberEnter(env.toplevel, env.enclosing(TOPLEVEL)); 6.213 + todo.append(env); 6.214 + } 6.215 + 6.216 + if (c.owner.kind == TYP) 6.217 + c.owner.complete(); 6.218 + 6.219 + // create an environment for evaluating the base clauses 6.220 + Env<AttrContext> baseEnv = baseEnv(tree, env); 6.221 + 6.222 + if (tree.extending != null) 6.223 + typeAnnotate(tree.extending, baseEnv, sym, tree.pos()); 6.224 + for (JCExpression impl : tree.implementing) 6.225 + typeAnnotate(impl, baseEnv, sym, tree.pos()); 6.226 + annotate.flush(); 6.227 + 6.228 + // Determine supertype. 6.229 + Type supertype = 6.230 + (tree.extending != null) 6.231 + ? attr.attribBase(tree.extending, baseEnv, true, false, true) 6.232 + : ((tree.mods.flags & Flags.ENUM) != 0) 6.233 + ? attr.attribBase(enumBase(tree.pos, c), baseEnv, 6.234 + true, false, false) 6.235 + : (c.fullname == names.java_lang_Object) 6.236 + ? Type.noType 6.237 + : syms.objectType; 6.238 + ct.supertype_field = modelMissingTypes(supertype, tree.extending, false); 6.239 + 6.240 + // Determine interfaces. 6.241 + ListBuffer<Type> interfaces = new ListBuffer<Type>(); 6.242 + ListBuffer<Type> all_interfaces = null; // lazy init 6.243 + Set<Type> interfaceSet = new HashSet<Type>(); 6.244 + List<JCExpression> interfaceTrees = tree.implementing; 6.245 + for (JCExpression iface : interfaceTrees) { 6.246 + Type i = attr.attribBase(iface, baseEnv, false, true, true); 6.247 + if (i.hasTag(CLASS)) { 6.248 + interfaces.append(i); 6.249 + if (all_interfaces != null) all_interfaces.append(i); 6.250 + chk.checkNotRepeated(iface.pos(), types.erasure(i), interfaceSet); 6.251 + } else { 6.252 + if (all_interfaces == null) 6.253 + all_interfaces = new ListBuffer<Type>().appendList(interfaces); 6.254 + all_interfaces.append(modelMissingTypes(i, iface, true)); 6.255 + } 6.256 + } 6.257 + if ((c.flags_field & ANNOTATION) != 0) { 6.258 + ct.interfaces_field = List.of(syms.annotationType); 6.259 + ct.all_interfaces_field = ct.interfaces_field; 6.260 + } else { 6.261 + ct.interfaces_field = interfaces.toList(); 6.262 + ct.all_interfaces_field = (all_interfaces == null) 6.263 + ? ct.interfaces_field : all_interfaces.toList(); 6.264 + } 6.265 + 6.266 + if (c.fullname == names.java_lang_Object) { 6.267 + if (tree.extending != null) { 6.268 + chk.checkNonCyclic(tree.extending.pos(), 6.269 + supertype); 6.270 + ct.supertype_field = Type.noType; 6.271 + } 6.272 + else if (tree.implementing.nonEmpty()) { 6.273 + chk.checkNonCyclic(tree.implementing.head.pos(), 6.274 + ct.interfaces_field.head); 6.275 + ct.interfaces_field = List.nil(); 6.276 + } 6.277 + } 6.278 + 6.279 + // Annotations. 6.280 + // In general, we cannot fully process annotations yet, but we 6.281 + // can attribute the annotation types and then check to see if the 6.282 + // @Deprecated annotation is present. 6.283 + attr.attribAnnotationTypes(tree.mods.annotations, baseEnv); 6.284 + if (hasDeprecatedAnnotation(tree.mods.annotations)) 6.285 + c.flags_field |= DEPRECATED; 6.286 + annotateLater(tree.mods.annotations, baseEnv, c, tree.pos()); 6.287 + // class type parameters use baseEnv but everything uses env 6.288 + 6.289 + chk.checkNonCyclicDecl(tree); 6.290 + 6.291 + attr.attribTypeVariables(tree.typarams, baseEnv); 6.292 + // Do this here, where we have the symbol. 6.293 + for (JCTypeParameter tp : tree.typarams) 6.294 + typeAnnotate(tp, baseEnv, sym, tree.pos()); 6.295 + 6.296 + // Add default constructor if needed. 6.297 + if ((c.flags() & INTERFACE) == 0 && 6.298 + !TreeInfo.hasConstructors(tree.defs)) { 6.299 + List<Type> argtypes = List.nil(); 6.300 + List<Type> typarams = List.nil(); 6.301 + List<Type> thrown = List.nil(); 6.302 + long ctorFlags = 0; 6.303 + boolean based = false; 6.304 + boolean addConstructor = true; 6.305 + JCNewClass nc = null; 6.306 + if (c.name.isEmpty()) { 6.307 + nc = (JCNewClass)env.next.tree; 6.308 + if (nc.constructor != null) { 6.309 + addConstructor = nc.constructor.kind != ERR; 6.310 + Type superConstrType = types.memberType(c.type, 6.311 + nc.constructor); 6.312 + argtypes = superConstrType.getParameterTypes(); 6.313 + typarams = superConstrType.getTypeArguments(); 6.314 + ctorFlags = nc.constructor.flags() & VARARGS; 6.315 + if (nc.encl != null) { 6.316 + argtypes = argtypes.prepend(nc.encl.type); 6.317 + based = true; 6.318 + } 6.319 + thrown = superConstrType.getThrownTypes(); 6.320 + } 6.321 + } 6.322 + if (addConstructor) { 6.323 + MethodSymbol basedConstructor = nc != null ? 6.324 + (MethodSymbol)nc.constructor : null; 6.325 + JCTree constrDef = DefaultConstructor(make.at(tree.pos), c, 6.326 + basedConstructor, 6.327 + typarams, argtypes, thrown, 6.328 + ctorFlags, based); 6.329 + tree.defs = tree.defs.prepend(constrDef); 6.330 + } 6.331 + } 6.332 + 6.333 + // enter symbols for 'this' into current scope. 6.334 + VarSymbol thisSym = 6.335 + new VarSymbol(FINAL | HASINIT, names._this, c.type, c); 6.336 + thisSym.pos = Position.FIRSTPOS; 6.337 + env.info.scope.enter(thisSym); 6.338 + // if this is a class, enter symbol for 'super' into current scope. 6.339 + if ((c.flags_field & INTERFACE) == 0 && 6.340 + ct.supertype_field.hasTag(CLASS)) { 6.341 + VarSymbol superSym = 6.342 + new VarSymbol(FINAL | HASINIT, names._super, 6.343 + ct.supertype_field, c); 6.344 + superSym.pos = Position.FIRSTPOS; 6.345 + env.info.scope.enter(superSym); 6.346 + } 6.347 + 6.348 + // check that no package exists with same fully qualified name, 6.349 + // but admit classes in the unnamed package which have the same 6.350 + // name as a top-level package. 6.351 + if (checkClash && 6.352 + c.owner.kind == PCK && c.owner != syms.unnamedPackage && 6.353 + reader.packageExists(c.fullname)) { 6.354 + log.error(tree.pos, "clash.with.pkg.of.same.name", Kinds.kindName(sym), c); 6.355 + } 6.356 + if (c.owner.kind == PCK && (c.flags_field & PUBLIC) == 0 && 6.357 + !env.toplevel.sourcefile.isNameCompatible(c.name.toString(),JavaFileObject.Kind.SOURCE)) { 6.358 + c.flags_field |= AUXILIARY; 6.359 + } 6.360 + } catch (CompletionFailure ex) { 6.361 + chk.completionError(tree.pos(), ex); 6.362 + } finally { 6.363 + deferredLintHandler.setPos(prevLintPos); 6.364 + log.useSource(prev); 6.365 } 6.366 6.367 - if (c.owner.kind == TYP) 6.368 - c.owner.complete(); 6.369 - 6.370 - // create an environment for evaluating the base clauses 6.371 - Env<AttrContext> baseEnv = baseEnv(tree, env); 6.372 - 6.373 - if (tree.extending != null) 6.374 - typeAnnotate(tree.extending, baseEnv, sym, tree.pos()); 6.375 - for (JCExpression impl : tree.implementing) 6.376 - typeAnnotate(impl, baseEnv, sym, tree.pos()); 6.377 - annotate.flush(); 6.378 - 6.379 - // Determine supertype. 6.380 - Type supertype = 6.381 - (tree.extending != null) 6.382 - ? attr.attribBase(tree.extending, baseEnv, true, false, true) 6.383 - : ((tree.mods.flags & Flags.ENUM) != 0) 6.384 - ? attr.attribBase(enumBase(tree.pos, c), baseEnv, 6.385 - true, false, false) 6.386 - : (c.fullname == names.java_lang_Object) 6.387 - ? Type.noType 6.388 - : syms.objectType; 6.389 - ct.supertype_field = modelMissingTypes(supertype, tree.extending, false); 6.390 - 6.391 - // Determine interfaces. 6.392 - ListBuffer<Type> interfaces = new ListBuffer<Type>(); 6.393 - ListBuffer<Type> all_interfaces = null; // lazy init 6.394 - Set<Type> interfaceSet = new HashSet<Type>(); 6.395 - List<JCExpression> interfaceTrees = tree.implementing; 6.396 - for (JCExpression iface : interfaceTrees) { 6.397 - Type i = attr.attribBase(iface, baseEnv, false, true, true); 6.398 - if (i.hasTag(CLASS)) { 6.399 - interfaces.append(i); 6.400 - if (all_interfaces != null) all_interfaces.append(i); 6.401 - chk.checkNotRepeated(iface.pos(), types.erasure(i), interfaceSet); 6.402 - } else { 6.403 - if (all_interfaces == null) 6.404 - all_interfaces = new ListBuffer<Type>().appendList(interfaces); 6.405 - all_interfaces.append(modelMissingTypes(i, iface, true)); 6.406 + // Enter all member fields and methods of a set of half completed 6.407 + // classes in a second phase. 6.408 + if (wasFirst) { 6.409 + try { 6.410 + while (halfcompleted.nonEmpty()) { 6.411 + Env<AttrContext> toFinish = halfcompleted.next(); 6.412 + finish(toFinish); 6.413 + if (allowTypeAnnos) { 6.414 + typeAnnotations.organizeTypeAnnotationsSignatures(toFinish, (JCClassDecl)toFinish.tree); 6.415 + typeAnnotations.validateTypeAnnotationsSignatures(toFinish, (JCClassDecl)toFinish.tree); 6.416 + } 6.417 + } 6.418 + } finally { 6.419 + isFirst = true; 6.420 } 6.421 } 6.422 - if ((c.flags_field & ANNOTATION) != 0) { 6.423 - ct.interfaces_field = List.of(syms.annotationType); 6.424 - ct.all_interfaces_field = ct.interfaces_field; 6.425 - } else { 6.426 - ct.interfaces_field = interfaces.toList(); 6.427 - ct.all_interfaces_field = (all_interfaces == null) 6.428 - ? ct.interfaces_field : all_interfaces.toList(); 6.429 - } 6.430 - 6.431 - if (c.fullname == names.java_lang_Object) { 6.432 - if (tree.extending != null) { 6.433 - chk.checkNonCyclic(tree.extending.pos(), 6.434 - supertype); 6.435 - ct.supertype_field = Type.noType; 6.436 - } 6.437 - else if (tree.implementing.nonEmpty()) { 6.438 - chk.checkNonCyclic(tree.implementing.head.pos(), 6.439 - ct.interfaces_field.head); 6.440 - ct.interfaces_field = List.nil(); 6.441 - } 6.442 - } 6.443 - 6.444 - // Annotations. 6.445 - // In general, we cannot fully process annotations yet, but we 6.446 - // can attribute the annotation types and then check to see if the 6.447 - // @Deprecated annotation is present. 6.448 - attr.attribAnnotationTypes(tree.mods.annotations, baseEnv); 6.449 - if (hasDeprecatedAnnotation(tree.mods.annotations)) 6.450 - c.flags_field |= DEPRECATED; 6.451 - annotateLater(tree.mods.annotations, baseEnv, c, tree.pos()); 6.452 - // class type parameters use baseEnv but everything uses env 6.453 - 6.454 - chk.checkNonCyclicDecl(tree); 6.455 - 6.456 - attr.attribTypeVariables(tree.typarams, baseEnv); 6.457 - // Do this here, where we have the symbol. 6.458 - for (JCTypeParameter tp : tree.typarams) 6.459 - typeAnnotate(tp, baseEnv, sym, tree.pos()); 6.460 - 6.461 - // Add default constructor if needed. 6.462 - if ((c.flags() & INTERFACE) == 0 && 6.463 - !TreeInfo.hasConstructors(tree.defs)) { 6.464 - List<Type> argtypes = List.nil(); 6.465 - List<Type> typarams = List.nil(); 6.466 - List<Type> thrown = List.nil(); 6.467 - long ctorFlags = 0; 6.468 - boolean based = false; 6.469 - boolean addConstructor = true; 6.470 - JCNewClass nc = null; 6.471 - if (c.name.isEmpty()) { 6.472 - nc = (JCNewClass)env.next.tree; 6.473 - if (nc.constructor != null) { 6.474 - addConstructor = nc.constructor.kind != ERR; 6.475 - Type superConstrType = types.memberType(c.type, 6.476 - nc.constructor); 6.477 - argtypes = superConstrType.getParameterTypes(); 6.478 - typarams = superConstrType.getTypeArguments(); 6.479 - ctorFlags = nc.constructor.flags() & VARARGS; 6.480 - if (nc.encl != null) { 6.481 - argtypes = argtypes.prepend(nc.encl.type); 6.482 - based = true; 6.483 - } 6.484 - thrown = superConstrType.getThrownTypes(); 6.485 - } 6.486 - } 6.487 - if (addConstructor) { 6.488 - MethodSymbol basedConstructor = nc != null ? 6.489 - (MethodSymbol)nc.constructor : null; 6.490 - JCTree constrDef = DefaultConstructor(make.at(tree.pos), c, 6.491 - basedConstructor, 6.492 - typarams, argtypes, thrown, 6.493 - ctorFlags, based); 6.494 - tree.defs = tree.defs.prepend(constrDef); 6.495 - } 6.496 - } 6.497 - 6.498 - // enter symbols for 'this' into current scope. 6.499 - VarSymbol thisSym = 6.500 - new VarSymbol(FINAL | HASINIT, names._this, c.type, c); 6.501 - thisSym.pos = Position.FIRSTPOS; 6.502 - env.info.scope.enter(thisSym); 6.503 - // if this is a class, enter symbol for 'super' into current scope. 6.504 - if ((c.flags_field & INTERFACE) == 0 && 6.505 - ct.supertype_field.hasTag(CLASS)) { 6.506 - VarSymbol superSym = 6.507 - new VarSymbol(FINAL | HASINIT, names._super, 6.508 - ct.supertype_field, c); 6.509 - superSym.pos = Position.FIRSTPOS; 6.510 - env.info.scope.enter(superSym); 6.511 - } 6.512 - 6.513 - // check that no package exists with same fully qualified name, 6.514 - // but admit classes in the unnamed package which have the same 6.515 - // name as a top-level package. 6.516 - if (checkClash && 6.517 - c.owner.kind == PCK && c.owner != syms.unnamedPackage && 6.518 - reader.packageExists(c.fullname)) { 6.519 - log.error(tree.pos, "clash.with.pkg.of.same.name", Kinds.kindName(sym), c); 6.520 - } 6.521 - if (c.owner.kind == PCK && (c.flags_field & PUBLIC) == 0 && 6.522 - !env.toplevel.sourcefile.isNameCompatible(c.name.toString(),JavaFileObject.Kind.SOURCE)) { 6.523 - c.flags_field |= AUXILIARY; 6.524 - } 6.525 - } catch (CompletionFailure ex) { 6.526 - chk.completionError(tree.pos(), ex); 6.527 } finally { 6.528 - deferredLintHandler.setPos(prevLintPos); 6.529 - log.useSource(prev); 6.530 - } 6.531 - 6.532 - // Enter all member fields and methods of a set of half completed 6.533 - // classes in a second phase. 6.534 - if (wasFirst) { 6.535 - try { 6.536 - while (halfcompleted.nonEmpty()) { 6.537 - Env<AttrContext> toFinish = halfcompleted.next(); 6.538 - finish(toFinish); 6.539 - if (allowTypeAnnos) { 6.540 - typeAnnotations.organizeTypeAnnotationsSignatures(toFinish, (JCClassDecl)toFinish.tree); 6.541 - typeAnnotations.validateTypeAnnotationsSignatures(toFinish, (JCClassDecl)toFinish.tree); 6.542 - } 6.543 - } 6.544 - } finally { 6.545 - isFirst = true; 6.546 - } 6.547 + annotate.enterDone(); 6.548 } 6.549 } 6.550
7.1 --- a/src/share/classes/com/sun/tools/javac/jvm/Code.java Mon Oct 27 14:35:21 2014 -0700 7.2 +++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java Thu Nov 06 09:49:49 2014 -0800 7.3 @@ -2017,13 +2017,12 @@ 7.4 List<VarSymbol> locals = lvtRanges.getVars(meth, tree); 7.5 for (LocalVar localVar: lvar) { 7.6 for (VarSymbol aliveLocal : locals) { 7.7 - if (localVar == null) { 7.8 - return; 7.9 - } 7.10 - if (localVar.sym == aliveLocal && localVar.lastRange() != null) { 7.11 - char length = (char)(closingCP - localVar.lastRange().start_pc); 7.12 - if (length < Character.MAX_VALUE) { 7.13 - localVar.closeRange(length); 7.14 + if (localVar != null) { 7.15 + if (localVar.sym == aliveLocal && localVar.lastRange() != null) { 7.16 + char length = (char)(closingCP - localVar.lastRange().start_pc); 7.17 + if (length < Character.MAX_VALUE) { 7.18 + localVar.closeRange(length); 7.19 + } 7.20 } 7.21 } 7.22 }
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/test/tools/javac/annotations/FinalStringInNested.java Thu Nov 06 09:49:49 2014 -0800 8.3 @@ -0,0 +1,46 @@ 8.4 +/* 8.5 + * Copyright (c) 2014, 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 +/* 8.28 + * @test 8.29 + * @bug 8054448 8.30 + * @summary Verify that constant strings in nested classes in anonymous classes 8.31 + * can be used in annotations. 8.32 + * @compile FinalStringInNested.java 8.33 + */ 8.34 + 8.35 +public class FinalStringInNested { 8.36 + 8.37 + public void f() { 8.38 + Object o = new Object() { 8.39 + @FinalStringInNested.Annotation(Nested.ID) 8.40 + class Nested { 8.41 + static final String ID = "B"; 8.42 + } 8.43 + }; 8.44 + } 8.45 + 8.46 + @interface Annotation { 8.47 + String value(); 8.48 + } 8.49 +}
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/test/tools/javac/flow/T8042741/LambdaArgumentsTest.java Thu Nov 06 09:49:49 2014 -0800 9.3 @@ -0,0 +1,44 @@ 9.4 +/* 9.5 + * Copyright (c) 2014, 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 +/* @test 9.28 + * @bug 8054210 9.29 + * @summary NullPointerException when compiling specific code 9.30 + * @compile LambdaArgumentsTest.java 9.31 + */ 9.32 + 9.33 +public class LambdaArgumentsTest { 9.34 + interface Thrower<E extends Exception> { void apply() throws E; } 9.35 + interface Consumer<E> { void take(E arg); } 9.36 + 9.37 + <E extends Exception> 9.38 + void m1(Thrower<E> a1, Consumer<E> a2) {} 9.39 + 9.40 + <E extends Exception> 9.41 + void m2(Thrower<E> a1, Consumer<RuntimeException> a2) {} 9.42 + 9.43 + void test() { 9.44 + m1(() -> {}, e -> {}); 9.45 + m2(() -> {}, (RuntimeException e) -> {}); 9.46 + } 9.47 +}
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/test/tools/javac/generics/inference/8058511/T8058511a.java Thu Nov 06 09:49:49 2014 -0800 10.3 @@ -0,0 +1,38 @@ 10.4 +/* 10.5 + * Copyright (c) 2014, 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. Oracle designates this 10.11 + * particular file as subject to the "Classpath" exception as provided 10.12 + * by Oracle in the LICENSE file that accompanied this code. 10.13 + * 10.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 10.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 10.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 10.17 + * version 2 for more details (a copy is included in the LICENSE file that 10.18 + * accompanied this code). 10.19 + * 10.20 + * You should have received a copy of the GNU General Public License version 10.21 + * 2 along with this work; if not, write to the Free Software Foundation, 10.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 10.23 + * 10.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 10.25 + * or visit www.oracle.com if you need additional information or have any 10.26 + * questions. 10.27 + */ 10.28 + 10.29 +/** 10.30 + * @test 10.31 + * @bug 8058511 10.32 + * @summary StackOverflowError at com.sun.tools.javac.code.Types.lub 10.33 + * @compile T8058511a.java 10.34 + */ 10.35 +class T8058511a { 10.36 + <Z> void choose(Z z1, Z z2) { } 10.37 + 10.38 + void test(Class<Double> cd, Class<? extends double[]> cdarr) { 10.39 + choose(cd, cdarr); 10.40 + } 10.41 +}
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/test/tools/javac/generics/inference/8058511/T8058511b.java Thu Nov 06 09:49:49 2014 -0800 11.3 @@ -0,0 +1,36 @@ 11.4 +/* 11.5 + * Copyright (c) 2014, 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. Oracle designates this 11.11 + * particular file as subject to the "Classpath" exception as provided 11.12 + * by Oracle in the LICENSE file that accompanied this code. 11.13 + * 11.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 11.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 11.17 + * version 2 for more details (a copy is included in the LICENSE file that 11.18 + * accompanied this code). 11.19 + * 11.20 + * You should have received a copy of the GNU General Public License version 11.21 + * 2 along with this work; if not, write to the Free Software Foundation, 11.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 11.23 + * 11.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 11.25 + * or visit www.oracle.com if you need additional information or have any 11.26 + * questions. 11.27 + */ 11.28 + 11.29 +/** 11.30 + * @test 11.31 + * @bug 8058511 11.32 + * @summary StackOverflowError at com.sun.tools.javac.code.Types.lub 11.33 + * @compile T8058511b.java 11.34 + */ 11.35 +class T8058511b { 11.36 + void test(Class<Double> cd, Class<? extends double[]> cdarr) { 11.37 + ((false) ? cd : cdarr).toString(); 11.38 + } 11.39 +}
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/test/tools/javac/generics/inference/8058511/T8058511c.java Thu Nov 06 09:49:49 2014 -0800 12.3 @@ -0,0 +1,38 @@ 12.4 +/* 12.5 + * Copyright (c) 2014, 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. Oracle designates this 12.11 + * particular file as subject to the "Classpath" exception as provided 12.12 + * by Oracle in the LICENSE file that accompanied this code. 12.13 + * 12.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 12.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12.17 + * version 2 for more details (a copy is included in the LICENSE file that 12.18 + * accompanied this code). 12.19 + * 12.20 + * You should have received a copy of the GNU General Public License version 12.21 + * 2 along with this work; if not, write to the Free Software Foundation, 12.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 12.23 + * 12.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 12.25 + * or visit www.oracle.com if you need additional information or have any 12.26 + * questions. 12.27 + */ 12.28 + 12.29 +/** 12.30 + * @test 12.31 + * @bug 8058511 12.32 + * @summary StackOverflowError at com.sun.tools.javac.code.Types.lub 12.33 + * @compile T8058511c.java 12.34 + */ 12.35 +import java.util.List; 12.36 + 12.37 +class T8058511c { 12.38 + void test(List<? extends double[]> l) { 12.39 + (true ? l.get(0) : l.get(0)).toString(); 12.40 + } 12.41 +}
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/test/tools/javac/lambda/MethodReferenceArrayClone.java Thu Nov 06 09:49:49 2014 -0800 13.3 @@ -0,0 +1,67 @@ 13.4 +/* 13.5 + * Copyright (c) 2014, 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 + 13.27 +/* 13.28 + * @test 13.29 + * @bug 8056051 13.30 + * @summary int[]::clone causes "java.lang.NoClassDefFoundError: Array" 13.31 + * @run main MethodReferenceArrayClone 13.32 + */ 13.33 + 13.34 +import java.util.Arrays; 13.35 +import java.util.function.Function; 13.36 +import java.util.function.Supplier; 13.37 + 13.38 +public class MethodReferenceArrayClone { 13.39 + public static void main(String[] args) { 13.40 + int[] intArgs = new int[] {1, 2, 3, 4, 5}; 13.41 + checkInt("int[]::clone", int[]::clone, intArgs); 13.42 + checkInt("a -> a.clone()", a -> a.clone(), intArgs); 13.43 + checkInt("intArgs::clone", intArgs::clone, intArgs); 13.44 + 13.45 + String[] stringArgs = new String[] {"hi", "de", "ho"}; 13.46 + checkString("String[]::clone", String[]::clone, stringArgs); 13.47 + checkString("a -> a.clone()", a -> a.clone(), stringArgs); 13.48 + checkString("args::clone", stringArgs::clone, stringArgs); 13.49 + } 13.50 + 13.51 + private static void checkInt(String label, Supplier<int[]> s, int[] expected) { 13.52 + if (!Arrays.equals(s.get(), expected)) { 13.53 + throw new RuntimeException("Unexpected value " + label + ": " + Arrays.toString(s.get())); 13.54 + } 13.55 + } 13.56 + 13.57 + private static void checkInt(String label, Function<int[], int[]> f, int[] a) { 13.58 + checkInt(label, () -> f.apply(a), a); 13.59 + } 13.60 + 13.61 + private static void checkString(String label, Supplier<String[]> s, String[] expected) { 13.62 + if (!Arrays.equals(s.get(), expected)) { 13.63 + throw new RuntimeException("Unexpected value " + label + ": " + Arrays.toString(s.get())); 13.64 + } 13.65 + } 13.66 + 13.67 + private static void checkString(String label, Function<String[], String[]> f, String[] a) { 13.68 + checkString(label, () -> f.apply(a), a); 13.69 + } 13.70 +}