Tue, 24 Jan 2012 13:44:01 -0800
Merge
1.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java Fri Jan 20 13:08:51 2012 -0800 1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Tue Jan 24 13:44:01 2012 -0800 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -3600,39 +3600,44 @@ 1.11 1.12 @Override 1.13 public Type visitCapturedType(CapturedType t, Void s) { 1.14 - Type bound = visitWildcardType(t.wildcard, null); 1.15 - return (bound.contains(t)) ? 1.16 - erasure(bound) : 1.17 - bound; 1.18 + Type w_bound = t.wildcard.type; 1.19 + Type bound = w_bound.contains(t) ? 1.20 + erasure(w_bound) : 1.21 + visit(w_bound); 1.22 + return rewriteAsWildcardType(visit(bound), t.wildcard.bound, t.wildcard.kind); 1.23 } 1.24 1.25 @Override 1.26 public Type visitTypeVar(TypeVar t, Void s) { 1.27 if (rewriteTypeVars) { 1.28 - Type bound = high ? 1.29 - (t.bound.contains(t) ? 1.30 + Type bound = t.bound.contains(t) ? 1.31 erasure(t.bound) : 1.32 - visit(t.bound)) : 1.33 - syms.botType; 1.34 - return rewriteAsWildcardType(bound, t); 1.35 + visit(t.bound); 1.36 + return rewriteAsWildcardType(bound, t, EXTENDS); 1.37 + } else { 1.38 + return t; 1.39 } 1.40 - else 1.41 - return t; 1.42 } 1.43 1.44 @Override 1.45 public Type visitWildcardType(WildcardType t, Void s) { 1.46 - Type bound = high ? t.getExtendsBound() : 1.47 - t.getSuperBound(); 1.48 - if (bound == null) 1.49 - bound = high ? syms.objectType : syms.botType; 1.50 - return rewriteAsWildcardType(visit(bound), t.bound); 1.51 + Type bound2 = visit(t.type); 1.52 + return t.type == bound2 ? t : rewriteAsWildcardType(bound2, t.bound, t.kind); 1.53 } 1.54 1.55 - private Type rewriteAsWildcardType(Type bound, TypeVar formal) { 1.56 - return high ? 1.57 - makeExtendsWildcard(B(bound), formal) : 1.58 - makeSuperWildcard(B(bound), formal); 1.59 + private Type rewriteAsWildcardType(Type bound, TypeVar formal, BoundKind bk) { 1.60 + switch (bk) { 1.61 + case EXTENDS: return high ? 1.62 + makeExtendsWildcard(B(bound), formal) : 1.63 + makeExtendsWildcard(syms.objectType, formal); 1.64 + case SUPER: return high ? 1.65 + makeSuperWildcard(syms.botType, formal) : 1.66 + makeSuperWildcard(B(bound), formal); 1.67 + case UNBOUND: return makeExtendsWildcard(syms.objectType, formal); 1.68 + default: 1.69 + Assert.error("Invalid bound kind " + bk); 1.70 + return null; 1.71 + } 1.72 } 1.73 1.74 Type B(Type t) {
2.1 --- a/src/share/classes/com/sun/tools/javac/comp/Infer.java Fri Jan 20 13:08:51 2012 -0800 2.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java Tue Jan 24 13:44:01 2012 -0800 2.3 @@ -1,5 +1,5 @@ 2.4 /* 2.5 - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 2.6 + * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. 2.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.8 * 2.9 * This code is free software; you can redistribute it and/or modify it 2.10 @@ -332,25 +332,29 @@ 2.11 //replace uninferred type-vars 2.12 targs = types.subst(targs, 2.13 that.tvars, 2.14 - instaniateAsUninferredVars(undetvars, that.tvars)); 2.15 + instantiateAsUninferredVars(undetvars, that.tvars)); 2.16 } 2.17 return chk.checkType(warn.pos(), that.inst(targs, types), to); 2.18 } 2.19 //where 2.20 - private List<Type> instaniateAsUninferredVars(List<Type> undetvars, List<Type> tvars) { 2.21 + private List<Type> instantiateAsUninferredVars(List<Type> undetvars, List<Type> tvars) { 2.22 + Assert.check(undetvars.length() == tvars.length()); 2.23 ListBuffer<Type> new_targs = ListBuffer.lb(); 2.24 - //step 1 - create syntethic captured vars 2.25 + //step 1 - create synthetic captured vars 2.26 for (Type t : undetvars) { 2.27 UndetVar uv = (UndetVar)t; 2.28 Type newArg = new CapturedType(t.tsym.name, t.tsym, uv.inst, syms.botType, null); 2.29 new_targs = new_targs.append(newArg); 2.30 } 2.31 //step 2 - replace synthetic vars in their bounds 2.32 + List<Type> formals = tvars; 2.33 for (Type t : new_targs.toList()) { 2.34 CapturedType ct = (CapturedType)t; 2.35 ct.bound = types.subst(ct.bound, tvars, new_targs.toList()); 2.36 - WildcardType wt = new WildcardType(ct.bound, BoundKind.EXTENDS, syms.boundClass); 2.37 + WildcardType wt = new WildcardType(syms.objectType, BoundKind.UNBOUND, syms.boundClass); 2.38 + wt.bound = (TypeVar)formals.head; 2.39 ct.wildcard = wt; 2.40 + formals = formals.tail; 2.41 } 2.42 return new_targs.toList(); 2.43 }
3.1 --- a/src/share/classes/javax/lang/model/element/Element.java Fri Jan 20 13:08:51 2012 -0800 3.2 +++ b/src/share/classes/javax/lang/model/element/Element.java Tue Jan 24 13:44:01 2012 -0800 3.3 @@ -1,5 +1,5 @@ 3.4 /* 3.5 - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 3.6 + * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. 3.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3.8 * 3.9 * This code is free software; you can redistribute it and/or modify it 3.10 @@ -214,14 +214,13 @@ 3.11 * Returns the elements that are, loosely speaking, directly 3.12 * enclosed by this element. 3.13 * 3.14 - * A class or interface is considered to enclose the fields, 3.15 - * methods, constructors, and member types that it directly 3.16 - * declares. This includes any (implicit) default constructor and 3.17 - * the implicit {@code values} and {@code valueOf} methods of an 3.18 - * enum type. 3.19 + * A {@linkplain TypeElement#getEnclosedElements class or 3.20 + * interface} is considered to enclose the fields, methods, 3.21 + * constructors, and member types that it directly declares. 3.22 * 3.23 - * A package encloses the top-level classes and interfaces within 3.24 - * it, but is not considered to enclose subpackages. 3.25 + * A {@linkplain PackageElement#getEnclosedElements package} 3.26 + * encloses the top-level classes and interfaces within it, but is 3.27 + * not considered to enclose subpackages. 3.28 * 3.29 * Other kinds of elements are not currently considered to enclose 3.30 * any elements; however, that may change as this API or the 3.31 @@ -231,6 +230,8 @@ 3.32 * methods in {@link ElementFilter}. 3.33 * 3.34 * @return the enclosed elements, or an empty list if none 3.35 + * @see PackageElement#getEnclosedElements 3.36 + * @see TypeElement#getEnclosedElements 3.37 * @see Elements#getAllMembers 3.38 * @jls 8.8.9 Default Constructor 3.39 * @jls 8.9 Enums
4.1 --- a/src/share/classes/javax/lang/model/element/PackageElement.java Fri Jan 20 13:08:51 2012 -0800 4.2 +++ b/src/share/classes/javax/lang/model/element/PackageElement.java Tue Jan 24 13:44:01 2012 -0800 4.3 @@ -1,5 +1,5 @@ 4.4 /* 4.5 - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 4.6 + * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. 4.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4.8 * 4.9 * This code is free software; you can redistribute it and/or modify it 4.10 @@ -25,6 +25,8 @@ 4.11 4.12 package javax.lang.model.element; 4.13 4.14 +import java.util.List; 4.15 + 4.16 /** 4.17 * Represents a package program element. Provides access to information 4.18 * about the package and its members. 4.19 @@ -49,7 +51,7 @@ 4.20 4.21 /** 4.22 * Returns the simple name of this package. For an unnamed 4.23 - * package, an empty name is returned 4.24 + * package, an empty name is returned. 4.25 * 4.26 * @return the simple name of this package or an empty name if 4.27 * this is an unnamed package 4.28 @@ -58,6 +60,18 @@ 4.29 Name getSimpleName(); 4.30 4.31 /** 4.32 + * Returns the {@linkplain NestingKind#TOP_LEVEL top-level} 4.33 + * classes and interfaces within this package. Note that 4.34 + * subpackages are <em>not</em> considered to be enclosed by a 4.35 + * package. 4.36 + * 4.37 + * @return the top-level classes and interfaces within this 4.38 + * package 4.39 + */ 4.40 + @Override 4.41 + List<? extends Element> getEnclosedElements(); 4.42 + 4.43 + /** 4.44 * Returns {@code true} is this is an unnamed package and {@code 4.45 * false} otherwise. 4.46 *
5.1 --- a/src/share/classes/javax/lang/model/element/TypeElement.java Fri Jan 20 13:08:51 2012 -0800 5.2 +++ b/src/share/classes/javax/lang/model/element/TypeElement.java Tue Jan 24 13:44:01 2012 -0800 5.3 @@ -1,5 +1,5 @@ 5.4 /* 5.5 - * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. 5.6 + * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. 5.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.8 * 5.9 * This code is free software; you can redistribute it and/or modify it 5.10 @@ -61,7 +61,12 @@ 5.11 */ 5.12 public interface TypeElement extends Element, Parameterizable, QualifiedNameable { 5.13 /** 5.14 - * {@inheritDoc} 5.15 + * Returns the fields, methods, constructors, and member types 5.16 + * that are directly declared in this class or interface. 5.17 + * 5.18 + * This includes any (implicit) default constructor and 5.19 + * the implicit {@code values} and {@code valueOf} methods of an 5.20 + * enum type. 5.21 * 5.22 * <p> Note that as a particular instance of the {@linkplain 5.23 * javax.lang.model.element general accuracy requirements} and the 5.24 @@ -75,6 +80,7 @@ 5.25 * 5.26 * @return the enclosed elements in proper order, or an empty list if none 5.27 */ 5.28 + @Override 5.29 List<? extends Element> getEnclosedElements(); 5.30 5.31 /**
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/test/tools/javac/cast/7123100/T7123100a.java Tue Jan 24 13:44:01 2012 -0800 6.3 @@ -0,0 +1,16 @@ 6.4 +/* 6.5 + * @test /nodynamiccopyright/ 6.6 + * @bug 7123100 6.7 + * @summary javac fails with java.lang.StackOverflowError 6.8 + * @compile/fail/ref=T7123100a.out -Werror -Xlint:unchecked -XDrawDiagnostics T7123100a.java 6.9 + */ 6.10 + 6.11 +class T7123100a { 6.12 + <E extends Enum<E>> E m() { 6.13 + return null; 6.14 + } 6.15 + 6.16 + <Z> void test() { 6.17 + Z z = (Z)m(); 6.18 + } 6.19 +}
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 7.2 +++ b/test/tools/javac/cast/7123100/T7123100a.out Tue Jan 24 13:44:01 2012 -0800 7.3 @@ -0,0 +1,4 @@ 7.4 +T7123100a.java:14:19: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), compiler.misc.type.captureof: 1, ?, Z 7.5 +- compiler.err.warnings.and.werror 7.6 +1 error 7.7 +1 warning
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/test/tools/javac/cast/7123100/T7123100b.java Tue Jan 24 13:44:01 2012 -0800 8.3 @@ -0,0 +1,12 @@ 8.4 +/* 8.5 + * @test /nodynamiccopyright/ 8.6 + * @bug 7123100 8.7 + * @summary javac fails with java.lang.StackOverflowError 8.8 + * @compile/fail/ref=T7123100b.out -Werror -Xlint:unchecked -XDrawDiagnostics T7123100b.java 8.9 + */ 8.10 + 8.11 +class T7123100b { 8.12 + <Z> void test(Enum<?> e) { 8.13 + Z z = (Z)e; 8.14 + } 8.15 +}
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/test/tools/javac/cast/7123100/T7123100b.out Tue Jan 24 13:44:01 2012 -0800 9.3 @@ -0,0 +1,4 @@ 9.4 +T7123100b.java:10:18: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), java.lang.Enum<compiler.misc.type.captureof: 1, ?>, Z 9.5 +- compiler.err.warnings.and.werror 9.6 +1 error 9.7 +1 warning
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/test/tools/javac/cast/7123100/T7123100c.java Tue Jan 24 13:44:01 2012 -0800 10.3 @@ -0,0 +1,16 @@ 10.4 +/* 10.5 + * @test /nodynamiccopyright/ 10.6 + * @bug 7123100 10.7 + * @summary javac fails with java.lang.StackOverflowError 10.8 + * @compile/fail/ref=T7123100c.out -Werror -Xlint:unchecked -XDrawDiagnostics T7123100c.java 10.9 + */ 10.10 + 10.11 +class T7123100c { 10.12 + <E> E m(E e) { 10.13 + return null; 10.14 + } 10.15 + 10.16 + <Z> void test(Enum<?> e) { 10.17 + Z z = (Z)m(e); 10.18 + } 10.19 +}
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/test/tools/javac/cast/7123100/T7123100c.out Tue Jan 24 13:44:01 2012 -0800 11.3 @@ -0,0 +1,4 @@ 11.4 +T7123100c.java:14:19: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), java.lang.Enum<compiler.misc.type.captureof: 1, ?>, Z 11.5 +- compiler.err.warnings.and.werror 11.6 +1 error 11.7 +1 warning
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/test/tools/javac/cast/7123100/T7123100d.java Tue Jan 24 13:44:01 2012 -0800 12.3 @@ -0,0 +1,16 @@ 12.4 +/* 12.5 + * @test /nodynamiccopyright/ 12.6 + * @bug 7123100 12.7 + * @summary javac fails with java.lang.StackOverflowError 12.8 + * @compile/fail/ref=T7123100d.out -Werror -Xlint:unchecked -XDrawDiagnostics T7123100d.java 12.9 + */ 12.10 + 12.11 +class T7123100d { 12.12 + <E extends Enum<E>> E m(Enum<E> e) { 12.13 + return null; 12.14 + } 12.15 + 12.16 + <Z> void test(Enum<?> e) { 12.17 + Z z = (Z)m(e); 12.18 + } 12.19 +}
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/test/tools/javac/cast/7123100/T7123100d.out Tue Jan 24 13:44:01 2012 -0800 13.3 @@ -0,0 +1,4 @@ 13.4 +T7123100d.java:14:19: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), compiler.misc.type.captureof: 1, ?, Z 13.5 +- compiler.err.warnings.and.werror 13.6 +1 error 13.7 +1 warning
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 14.2 +++ b/test/tools/javac/cast/7126754/T7126754.java Tue Jan 24 13:44:01 2012 -0800 14.3 @@ -0,0 +1,14 @@ 14.4 +/* 14.5 + * @test /nodynamiccopyright/ 14.6 + * @author mcimadamore 14.7 + * @bug 7005671 14.8 + * @summary Generics compilation failure casting List<? extends Set...> to List<Set...> 14.9 + * @compile/fail/ref=T7126754.out -Xlint:unchecked -Werror -XDrawDiagnostics T7126754.java 14.10 + */ 14.11 + 14.12 +import java.util.List; 14.13 + 14.14 +class T7126754 { 14.15 + List<? extends List<? extends String>> c = null; 14.16 + List<List<? extends String>> d = (List<List<? extends String>>)c; 14.17 +}
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 15.2 +++ b/test/tools/javac/cast/7126754/T7126754.out Tue Jan 24 13:44:01 2012 -0800 15.3 @@ -0,0 +1,4 @@ 15.4 +T7126754.java:13:68: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), java.util.List<compiler.misc.type.captureof: 1, ? extends java.util.List<? extends java.lang.String>>, java.util.List<java.util.List<? extends java.lang.String>> 15.5 +- compiler.err.warnings.and.werror 15.6 +1 error 15.7 +1 warning
16.1 --- a/test/tools/javac/diags/CheckExamples.java Fri Jan 20 13:08:51 2012 -0800 16.2 +++ b/test/tools/javac/diags/CheckExamples.java Tue Jan 24 13:44:01 2012 -0800 16.3 @@ -23,10 +23,13 @@ 16.4 16.5 /* 16.6 * @test 16.7 - * @bug 6968063 16.8 + * @bug 6968063 7127924 16.9 * @summary provide examples of code that generate diagnostics 16.10 * @build Example CheckExamples 16.11 - * @run main CheckExamples 16.12 + * @run main/othervm CheckExamples 16.13 + */ 16.14 +/* 16.15 + * See CR 7127924 for info on why othervm is used. 16.16 */ 16.17 16.18 import java.io.*;
17.1 --- a/test/tools/javac/diags/MessageInfo.java Fri Jan 20 13:08:51 2012 -0800 17.2 +++ b/test/tools/javac/diags/MessageInfo.java Tue Jan 24 13:44:01 2012 -0800 17.3 @@ -23,10 +23,13 @@ 17.4 17.5 /** 17.6 * @test 17.7 - * @bug 7013272 17.8 + * @bug 7013272 7127924 17.9 * @summary Automatically generate info about how compiler resource keys are used 17.10 * @build Example ArgTypeCompilerFactory MessageFile MessageInfo 17.11 - * @run main MessageInfo 17.12 + * @run main/othervm MessageInfo 17.13 + */ 17.14 +/* 17.15 + * See CR 7127924 for info on why othervm is used. 17.16 */ 17.17 17.18 import java.io.*;
18.1 --- a/test/tools/javac/diags/RunExamples.java Fri Jan 20 13:08:51 2012 -0800 18.2 +++ b/test/tools/javac/diags/RunExamples.java Tue Jan 24 13:44:01 2012 -0800 18.3 @@ -23,10 +23,13 @@ 18.4 18.5 /** 18.6 * @test 18.7 - * @bug 6968063 18.8 + * @bug 6968063 7127924 18.9 * @summary provide examples of code that generate diagnostics 18.10 * @build ArgTypeCompilerFactory Example HTMLWriter RunExamples 18.11 - * @run main RunExamples 18.12 + * @run main/othervm RunExamples 18.13 + */ 18.14 +/* 18.15 + * See CR 7127924 for info on why othervm is used. 18.16 */ 18.17 18.18 import java.io.*;