Mon, 07 Jun 2010 17:09:52 -0700
Merge
1.1 --- a/src/share/classes/com/sun/tools/javac/code/Types.java Thu Jun 03 13:30:30 2010 -0700 1.2 +++ b/src/share/classes/com/sun/tools/javac/code/Types.java Mon Jun 07 17:09:52 2010 -0700 1.3 @@ -588,10 +588,21 @@ 1.4 case BYTE: case CHAR: case SHORT: case INT: case LONG: case FLOAT: 1.5 case DOUBLE: case BOOLEAN: case VOID: case BOT: case NONE: 1.6 return t.tag == s.tag; 1.7 - case TYPEVAR: 1.8 - return s.isSuperBound() 1.9 - && !s.isExtendsBound() 1.10 - && visit(t, upperBound(s)); 1.11 + case TYPEVAR: { 1.12 + if (s.tag == TYPEVAR) { 1.13 + //type-substitution does not preserve type-var types 1.14 + //check that type var symbols and bounds are indeed the same 1.15 + return t.tsym == s.tsym && 1.16 + visit(t.getUpperBound(), s.getUpperBound()); 1.17 + } 1.18 + else { 1.19 + //special case for s == ? super X, where upper(s) = u 1.20 + //check that u == t, where u has been set by Type.withTypeVar 1.21 + return s.isSuperBound() && 1.22 + !s.isExtendsBound() && 1.23 + visit(t, upperBound(s)); 1.24 + } 1.25 + } 1.26 default: 1.27 throw new AssertionError("isSameType " + t.tag); 1.28 } 1.29 @@ -1850,13 +1861,16 @@ 1.30 1.31 /** 1.32 * Same as {@link #setBounds(Type.TypeVar,List,Type)}, except that 1.33 - * third parameter is computed directly. Note that this test 1.34 - * might cause a symbol completion. Hence, this version of 1.35 + * third parameter is computed directly, as follows: if all 1.36 + * all bounds are interface types, the computed supertype is Object, 1.37 + * otherwise the supertype is simply left null (in this case, the supertype 1.38 + * is assumed to be the head of the bound list passed as second argument). 1.39 + * Note that this check might cause a symbol completion. Hence, this version of 1.40 * setBounds may not be called during a classfile read. 1.41 */ 1.42 public void setBounds(TypeVar t, List<Type> bounds) { 1.43 Type supertype = (bounds.head.tsym.flags() & INTERFACE) != 0 ? 1.44 - supertype(bounds.head) : null; 1.45 + syms.objectType : null; 1.46 setBounds(t, bounds, supertype); 1.47 t.rank_field = -1; 1.48 }
2.1 --- a/src/share/classes/com/sun/tools/javac/comp/Attr.java Thu Jun 03 13:30:30 2010 -0700 2.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java Mon Jun 07 17:09:52 2010 -0700 2.3 @@ -1472,7 +1472,7 @@ 2.4 // Attribute clazz expression and store 2.5 // symbol + type back into the attributed tree. 2.6 Type clazztype = attribType(clazz, env); 2.7 - Pair<Scope,Scope> mapping = getSyntheticScopeMapping((ClassType)clazztype); 2.8 + Pair<Scope,Scope> mapping = getSyntheticScopeMapping(clazztype); 2.9 if (!TreeInfo.isDiamond(tree)) { 2.10 clazztype = chk.checkClassType( 2.11 tree.clazz.pos(), clazztype, true); 2.12 @@ -1640,9 +1640,10 @@ 2.13 List<Type> argtypes, 2.14 List<Type> typeargtypes, 2.15 boolean reportErrors) { 2.16 - if (clazztype.isErroneous()) { 2.17 - //if the type of the instance creation expression is erroneous 2.18 - //return the erroneous type itself 2.19 + if (clazztype.isErroneous() || mapping == erroneousMapping) { 2.20 + //if the type of the instance creation expression is erroneous, 2.21 + //or something prevented us to form a valid mapping, return the 2.22 + //(possibly erroneous) type unchanged 2.23 return clazztype; 2.24 } 2.25 else if (clazztype.isInterface()) { 2.26 @@ -1740,7 +1741,10 @@ 2.27 * inference. The inferred return type of the synthetic constructor IS 2.28 * the inferred type for the diamond operator. 2.29 */ 2.30 - private Pair<Scope, Scope> getSyntheticScopeMapping(ClassType ctype) { 2.31 + private Pair<Scope, Scope> getSyntheticScopeMapping(Type ctype) { 2.32 + if (ctype.tag != CLASS) { 2.33 + return erroneousMapping; 2.34 + } 2.35 Pair<Scope, Scope> mapping = 2.36 new Pair<Scope, Scope>(ctype.tsym.members(), new Scope(ctype.tsym)); 2.37 List<Type> typevars = ctype.tsym.type.getTypeArguments(); 2.38 @@ -1763,6 +1767,8 @@ 2.39 return mapping; 2.40 } 2.41 2.42 + private final Pair<Scope,Scope> erroneousMapping = new Pair<Scope,Scope>(null, null); 2.43 + 2.44 /** Make an attributed null check tree. 2.45 */ 2.46 public JCExpression makeNullCheck(JCExpression arg) {
3.1 --- a/src/share/classes/com/sun/tools/javac/comp/Check.java Thu Jun 03 13:30:30 2010 -0700 3.2 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Mon Jun 07 17:09:52 2010 -0700 3.3 @@ -886,6 +886,7 @@ 3.4 void checkRaw(JCTree tree, Env<AttrContext> env) { 3.5 if (lint.isEnabled(Lint.LintCategory.RAW) && 3.6 tree.type.tag == CLASS && 3.7 + !TreeInfo.isDiamond(tree) && 3.8 !env.enclClass.name.isEmpty() && //anonymous or intersection 3.9 tree.type.isRaw()) { 3.10 log.warning(tree.pos(), "raw.class.use", tree.type, tree.type.tsym.type); 3.11 @@ -915,7 +916,7 @@ 3.12 List<Type> actuals = tree.type.allparams(); 3.13 List<JCExpression> args = tree.arguments; 3.14 List<Type> forms = tree.type.tsym.type.getTypeArguments(); 3.15 - ListBuffer<TypeVar> tvars_buf = new ListBuffer<TypeVar>(); 3.16 + ListBuffer<Type> tvars_buf = new ListBuffer<Type>(); 3.17 3.18 // For matching pairs of actual argument types `a' and 3.19 // formal type parameters with declared bound `b' ... 3.20 @@ -946,12 +947,15 @@ 3.21 } 3.22 3.23 args = tree.arguments; 3.24 - List<TypeVar> tvars = tvars_buf.toList(); 3.25 + List<Type> tvars = tvars_buf.toList(); 3.26 3.27 while (args.nonEmpty() && tvars.nonEmpty()) { 3.28 + Type actual = types.subst(args.head.type, 3.29 + tree.type.tsym.type.getTypeArguments(), 3.30 + tvars_buf.toList()); 3.31 checkExtends(args.head.pos(), 3.32 - args.head.type, 3.33 - tvars.head); 3.34 + actual, 3.35 + (TypeVar)tvars.head); 3.36 args = args.tail; 3.37 tvars = tvars.tail; 3.38 }
4.1 --- a/test/Makefile Thu Jun 03 13:30:30 2010 -0700 4.2 +++ b/test/Makefile Mon Jun 07 17:09:52 2010 -0700 4.3 @@ -50,6 +50,7 @@ 4.4 endif 4.5 endif 4.6 endif 4.7 + EXE_SUFFIX=.exe 4.8 endif 4.9 4.10 # Root of this test area (important to use full paths in some places) 4.11 @@ -105,12 +106,13 @@ 4.12 # PRODUCT_HOME is a JPRT variable pointing to a directory containing the output from 4.13 # make/Makefile 4.14 # For langtools, this is a directory containing build and dist 4.15 -# For a control build, this is build/$(PRODUCT)-$(ARCH)/j2sdk-image 4.16 +# For a control build, this is build/$(PRODUCT)-$(ARCH)/XYZ-image 4.17 +# (i.e, j2sdk-image or jdk-module-image) 4.18 ifdef PRODUCT_HOME 4.19 ifeq ($(shell [ -r $(PRODUCT_HOME)/dist/lib/classes.jar ]; echo $$?),0) 4.20 TESTBOOTCLASSPATH = $(PRODUCT_HOME)/dist/lib/classes.jar 4.21 endif 4.22 - ifeq ($(shell [ -r $(PRODUCT_HOME)/lib/tools.jar ]; echo $$?),0) 4.23 + ifeq ($(shell [ -r $(PRODUCT_HOME)/bin/javac$(EXE_SUFFIX) ]; echo $$?),0) 4.24 TESTJAVA = $(PRODUCT_HOME) 4.25 endif 4.26 endif 4.27 @@ -150,6 +152,16 @@ 4.28 ### -jtoptions:-Ejck.env.runtime.testCompile.groupMode.groupSize=$(JCK_GROUP_SIZE) 4.29 endif 4.30 4.31 +# Timeouts -- by default, increase test timeouts when running on JPRT 4.32 +ifdef JPRT_JOB_ID 4.33 + ifndef JTREG_TIMEOUT_FACTOR 4.34 + JTREG_TIMEOUT_FACTOR = 3 4.35 + endif 4.36 +endif 4.37 +ifdef JTREG_TIMEOUT_FACTOR 4.38 + JTREG_OPTIONS += -timeoutFactor:$(JTREG_TIMEOUT_FACTOR) 4.39 +endif 4.40 + 4.41 # Assertions: some tests show failures when assertions are enabled. 4.42 # Since javac is typically loaded via the bootclassloader (either via TESTJAVA 4.43 # or TESTBOOTCLASSPATH), you may need -esa to enable assertions in javac.
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/test/tools/javac/6948381/T6948381.java Mon Jun 07 17:09:52 2010 -0700 5.3 @@ -0,0 +1,29 @@ 5.4 +/* 5.5 + * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved. 5.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 5.7 + * 5.8 + * This code is free software; you can redistribute it and/or modify it 5.9 + * under the terms of the GNU General Public License version 2 only, as 5.10 + * published by the Free Software Foundation. 5.11 + * 5.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 5.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 5.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 5.15 + * version 2 for more details (a copy is included in the LICENSE file that 5.16 + * accompanied this code). 5.17 + * 5.18 + * You should have received a copy of the GNU General Public License version 5.19 + * 2 along with this work; if not, write to the Free Software Foundation, 5.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 5.21 + * 5.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 5.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 5.24 + * have any questions. 5.25 + */ 5.26 + 5.27 +/** 5.28 + * @test 5.29 + * @bug 6948381 5.30 + * @summary javac Null Pointer Exception in Types.makeCompoundType 5.31 + * @compile npe/A.java npe/B.java 5.32 + */
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/test/tools/javac/6948381/npe/A.java Mon Jun 07 17:09:52 2010 -0700 6.3 @@ -0,0 +1,28 @@ 6.4 +/* 6.5 + * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved. 6.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 6.7 + * 6.8 + * This code is free software; you can redistribute it and/or modify it 6.9 + * under the terms of the GNU General Public License version 2 only, as 6.10 + * published by the Free Software Foundation. 6.11 + * 6.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 6.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 6.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 6.15 + * version 2 for more details (a copy is included in the LICENSE file that 6.16 + * accompanied this code). 6.17 + * 6.18 + * You should have received a copy of the GNU General Public License version 6.19 + * 2 along with this work; if not, write to the Free Software Foundation, 6.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 6.21 + * 6.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 6.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 6.24 + * have any questions. 6.25 + */ 6.26 + 6.27 +package npe; 6.28 + 6.29 +import npe.B.*; 6.30 + 6.31 +public interface A {}
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 7.2 +++ b/test/tools/javac/6948381/npe/B.java Mon Jun 07 17:09:52 2010 -0700 7.3 @@ -0,0 +1,26 @@ 7.4 +/* 7.5 + * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved. 7.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7.7 + * 7.8 + * This code is free software; you can redistribute it and/or modify it 7.9 + * under the terms of the GNU General Public License version 2 only, as 7.10 + * published by the Free Software Foundation. 7.11 + * 7.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 7.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 7.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 7.15 + * version 2 for more details (a copy is included in the LICENSE file that 7.16 + * accompanied this code). 7.17 + * 7.18 + * You should have received a copy of the GNU General Public License version 7.19 + * 2 along with this work; if not, write to the Free Software Foundation, 7.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 7.21 + * 7.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 7.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 7.24 + * have any questions. 7.25 + */ 7.26 + 7.27 +package npe; 7.28 + 7.29 +public interface B<T extends A & java.io.Serializable> {}
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 8.2 +++ b/test/tools/javac/generics/6946618/T6946618a.java Mon Jun 07 17:09:52 2010 -0700 8.3 @@ -0,0 +1,21 @@ 8.4 +/* 8.5 + * @test /nodynamiccopyright/ 8.6 + * @bug 6946618 8.7 + * @summary sqe test fails: javac/generics/NewOnTypeParm in pit jdk7 b91 in all platforms. 8.8 + * @author mcimadamore 8.9 + * @compile/fail/ref=T6946618a.out -XDrawDiagnostics T6946618a.java 8.10 + */ 8.11 + 8.12 +class T6946618a { 8.13 + static class C<T> { 8.14 + T makeT() { 8.15 + return new T(); //error 8.16 + } 8.17 + } 8.18 + 8.19 + static class D<S> { 8.20 + C<S> makeC() { 8.21 + return new C<S>(); //ok 8.22 + } 8.23 + } 8.24 +}
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/test/tools/javac/generics/6946618/T6946618a.out Mon Jun 07 17:09:52 2010 -0700 9.3 @@ -0,0 +1,2 @@ 9.4 +T6946618a.java:12:20: compiler.err.type.found.req: (compiler.misc.type.parameter: T), (compiler.misc.type.req.class) 9.5 +1 error
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/test/tools/javac/generics/6946618/T6946618b.java Mon Jun 07 17:09:52 2010 -0700 10.3 @@ -0,0 +1,21 @@ 10.4 +/* 10.5 + * @test /nodynamiccopyright/ 10.6 + * @bug 6946618 10.7 + * @summary sqe test fails: javac/generics/NewOnTypeParm in pit jdk7 b91 in all platforms. 10.8 + * @author mcimadamore 10.9 + * @compile/fail/ref=T6946618b.out -XDrawDiagnostics T6946618b.java 10.10 + */ 10.11 + 10.12 +class T6946618b { 10.13 + static class C<T> { 10.14 + T makeT() { 10.15 + return new T<>(); //error 10.16 + } 10.17 + } 10.18 + 10.19 + static class D<S> { 10.20 + C<S> makeC() { 10.21 + return new C<>(); //ok 10.22 + } 10.23 + } 10.24 +}
11.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 11.2 +++ b/test/tools/javac/generics/6946618/T6946618b.out Mon Jun 07 17:09:52 2010 -0700 11.3 @@ -0,0 +1,2 @@ 11.4 +T6946618b.java:12:20: compiler.err.type.found.req: (compiler.misc.type.parameter: T), (compiler.misc.type.req.class) 11.5 +1 error
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/test/tools/javac/generics/6946618/T6946618c.java Mon Jun 07 17:09:52 2010 -0700 12.3 @@ -0,0 +1,17 @@ 12.4 +/* 12.5 + * @test /nodynamiccopyright/ 12.6 + * @bug 6946618 12.7 + * @summary sqe test fails: javac/generics/NewOnTypeParm in pit jdk7 b91 in all platforms. 12.8 + * @author mcimadamore 12.9 + * @compile/fail/ref=T6946618c.out -XDrawDiagnostics T6946618c.java 12.10 + */ 12.11 + 12.12 +class T6946618c { 12.13 + static class C<T> { } 12.14 + 12.15 + void test() { 12.16 + C<?> c1 = new C<? extends String>(); 12.17 + C<?> c2 = new C<? super String>(); 12.18 + C<?> c3 = new C<?>(); 12.19 + } 12.20 +}
13.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 13.2 +++ b/test/tools/javac/generics/6946618/T6946618c.out Mon Jun 07 17:09:52 2010 -0700 13.3 @@ -0,0 +1,4 @@ 13.4 +T6946618c.java:13:24: compiler.err.type.found.req: ? extends java.lang.String, class or interface without bounds 13.5 +T6946618c.java:14:24: compiler.err.type.found.req: ? super java.lang.String, class or interface without bounds 13.6 +T6946618c.java:15:24: compiler.err.type.found.req: ?, class or interface without bounds 13.7 +3 errors
14.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 14.2 +++ b/test/tools/javac/generics/diamond/T6951833.java Mon Jun 07 17:09:52 2010 -0700 14.3 @@ -0,0 +1,36 @@ 14.4 +/* 14.5 + * Copyright 2010 Sun Microsystems, Inc. All Rights Reserved. 14.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 14.7 + * 14.8 + * This code is free software; you can redistribute it and/or modify it 14.9 + * under the terms of the GNU General Public License version 2 only, as 14.10 + * published by the Free Software Foundation. 14.11 + * 14.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 14.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 14.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14.15 + * version 2 for more details (a copy is included in the LICENSE file that 14.16 + * accompanied this code). 14.17 + * 14.18 + * You should have received a copy of the GNU General Public License version 14.19 + * 2 along with this work; if not, write to the Free Software Foundation, 14.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 14.21 + * 14.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 14.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 14.24 + * have any questions. 14.25 + */ 14.26 + 14.27 +/* 14.28 + * @test 14.29 + * @bug 6951833 14.30 + * 14.31 + * @summary latest diamond implementation generates spurious raw type warnings 14.32 + * @author mcimadamore 14.33 + * @compile -Xlint:rawtypes -Werror T6951833.java 14.34 + * 14.35 + */ 14.36 + 14.37 +class T6951833<X> { 14.38 + T6951833<String> bug = new T6951833<>(); 14.39 +}
15.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 15.2 +++ b/test/tools/javac/generics/typevars/T6880344.java Mon Jun 07 17:09:52 2010 -0700 15.3 @@ -0,0 +1,40 @@ 15.4 +/* 15.5 + * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved. 15.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 15.7 + * 15.8 + * This code is free software; you can redistribute it and/or modify it 15.9 + * under the terms of the GNU General Public License version 2 only, as 15.10 + * published by the Free Software Foundation. 15.11 + * 15.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 15.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 15.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15.15 + * version 2 for more details (a copy is included in the LICENSE file that 15.16 + * accompanied this code). 15.17 + * 15.18 + * You should have received a copy of the GNU General Public License version 15.19 + * 2 along with this work; if not, write to the Free Software Foundation, 15.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 15.21 + * 15.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 15.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 15.24 + * have any questions. 15.25 + */ 15.26 + 15.27 +/* 15.28 + * @test 15.29 + * @bug 6880344 15.30 + * @summary Recursive type parameters do not compile 15.31 + * @author mcimadamore 15.32 + * @compile T6880344.java 15.33 + */ 15.34 + 15.35 +class T6880344 { 15.36 + static class A<X1 extends G<X1>> { 15.37 + public A<N<X1>> xyz; 15.38 + } 15.39 + 15.40 + static class N<X2 extends G<X2>> implements G<N<X2>> { } 15.41 + 15.42 + interface G<X3 extends G<X3>> { } 15.43 +}