Merge
authorlana
Tue, 24 Jan 2012 13:44:01 -0800
changeset 11555 6662fc41e1c3
parent 11548 7ac48efacb1f (current diff)
parent 11554 64d41533dc9e (diff)
child 11556 585124537be0
Merge
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Fri Jan 20 13:08:51 2012 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java	Tue Jan 24 13:44:01 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -3600,39 +3600,44 @@
 
         @Override
         public Type visitCapturedType(CapturedType t, Void s) {
-            Type bound = visitWildcardType(t.wildcard, null);
-            return (bound.contains(t)) ?
-                    erasure(bound) :
-                    bound;
+            Type w_bound = t.wildcard.type;
+            Type bound = w_bound.contains(t) ?
+                        erasure(w_bound) :
+                        visit(w_bound);
+            return rewriteAsWildcardType(visit(bound), t.wildcard.bound, t.wildcard.kind);
         }
 
         @Override
         public Type visitTypeVar(TypeVar t, Void s) {
             if (rewriteTypeVars) {
-                Type bound = high ?
-                    (t.bound.contains(t) ?
+                Type bound = t.bound.contains(t) ?
                         erasure(t.bound) :
-                        visit(t.bound)) :
-                    syms.botType;
-                return rewriteAsWildcardType(bound, t);
+                        visit(t.bound);
+                return rewriteAsWildcardType(bound, t, EXTENDS);
+            } else {
+                return t;
             }
-            else
-                return t;
         }
 
         @Override
         public Type visitWildcardType(WildcardType t, Void s) {
-            Type bound = high ? t.getExtendsBound() :
-                                t.getSuperBound();
-            if (bound == null)
-            bound = high ? syms.objectType : syms.botType;
-            return rewriteAsWildcardType(visit(bound), t.bound);
+            Type bound2 = visit(t.type);
+            return t.type == bound2 ? t : rewriteAsWildcardType(bound2, t.bound, t.kind);
         }
 
-        private Type rewriteAsWildcardType(Type bound, TypeVar formal) {
-            return high ?
-                makeExtendsWildcard(B(bound), formal) :
-                makeSuperWildcard(B(bound), formal);
+        private Type rewriteAsWildcardType(Type bound, TypeVar formal, BoundKind bk) {
+            switch (bk) {
+               case EXTENDS: return high ?
+                       makeExtendsWildcard(B(bound), formal) :
+                       makeExtendsWildcard(syms.objectType, formal);
+               case SUPER: return high ?
+                       makeSuperWildcard(syms.botType, formal) :
+                       makeSuperWildcard(B(bound), formal);
+               case UNBOUND: return makeExtendsWildcard(syms.objectType, formal);
+               default:
+                   Assert.error("Invalid bound kind " + bk);
+                   return null;
+            }
         }
 
         Type B(Type t) {
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java	Fri Jan 20 13:08:51 2012 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java	Tue Jan 24 13:44:01 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -332,25 +332,29 @@
             //replace uninferred type-vars
             targs = types.subst(targs,
                     that.tvars,
-                    instaniateAsUninferredVars(undetvars, that.tvars));
+                    instantiateAsUninferredVars(undetvars, that.tvars));
         }
         return chk.checkType(warn.pos(), that.inst(targs, types), to);
     }
     //where
-    private List<Type> instaniateAsUninferredVars(List<Type> undetvars, List<Type> tvars) {
+    private List<Type> instantiateAsUninferredVars(List<Type> undetvars, List<Type> tvars) {
+        Assert.check(undetvars.length() == tvars.length());
         ListBuffer<Type> new_targs = ListBuffer.lb();
-        //step 1 - create syntethic captured vars
+        //step 1 - create synthetic captured vars
         for (Type t : undetvars) {
             UndetVar uv = (UndetVar)t;
             Type newArg = new CapturedType(t.tsym.name, t.tsym, uv.inst, syms.botType, null);
             new_targs = new_targs.append(newArg);
         }
         //step 2 - replace synthetic vars in their bounds
+        List<Type> formals = tvars;
         for (Type t : new_targs.toList()) {
             CapturedType ct = (CapturedType)t;
             ct.bound = types.subst(ct.bound, tvars, new_targs.toList());
-            WildcardType wt = new WildcardType(ct.bound, BoundKind.EXTENDS, syms.boundClass);
+            WildcardType wt = new WildcardType(syms.objectType, BoundKind.UNBOUND, syms.boundClass);
+            wt.bound = (TypeVar)formals.head;
             ct.wildcard = wt;
+            formals = formals.tail;
         }
         return new_targs.toList();
     }
--- a/langtools/src/share/classes/javax/lang/model/element/Element.java	Fri Jan 20 13:08:51 2012 -0800
+++ b/langtools/src/share/classes/javax/lang/model/element/Element.java	Tue Jan 24 13:44:01 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -214,14 +214,13 @@
      * Returns the elements that are, loosely speaking, directly
      * enclosed by this element.
      *
-     * A class or interface is considered to enclose the fields,
-     * methods, constructors, and member types that it directly
-     * declares.  This includes any (implicit) default constructor and
-     * the implicit {@code values} and {@code valueOf} methods of an
-     * enum type.
+     * A {@linkplain TypeElement#getEnclosedElements class or
+     * interface} is considered to enclose the fields, methods,
+     * constructors, and member types that it directly declares.
      *
-     * A package encloses the top-level classes and interfaces within
-     * it, but is not considered to enclose subpackages.
+     * A {@linkplain PackageElement#getEnclosedElements package}
+     * encloses the top-level classes and interfaces within it, but is
+     * not considered to enclose subpackages.
      *
      * Other kinds of elements are not currently considered to enclose
      * any elements; however, that may change as this API or the
@@ -231,6 +230,8 @@
      * methods in {@link ElementFilter}.
      *
      * @return the enclosed elements, or an empty list if none
+     * @see PackageElement#getEnclosedElements
+     * @see TypeElement#getEnclosedElements
      * @see Elements#getAllMembers
      * @jls 8.8.9 Default Constructor
      * @jls 8.9 Enums
--- a/langtools/src/share/classes/javax/lang/model/element/PackageElement.java	Fri Jan 20 13:08:51 2012 -0800
+++ b/langtools/src/share/classes/javax/lang/model/element/PackageElement.java	Tue Jan 24 13:44:01 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
 
 package javax.lang.model.element;
 
+import java.util.List;
+
 /**
  * Represents a package program element.  Provides access to information
  * about the package and its members.
@@ -49,7 +51,7 @@
 
     /**
      * Returns the simple name of this package.  For an unnamed
-     * package, an empty name is returned
+     * package, an empty name is returned.
      *
      * @return the simple name of this package or an empty name if
      * this is an unnamed package
@@ -58,6 +60,18 @@
     Name getSimpleName();
 
     /**
+     * Returns the {@linkplain NestingKind#TOP_LEVEL top-level}
+     * classes and interfaces within this package.  Note that
+     * subpackages are <em>not</em> considered to be enclosed by a
+     * package.
+     *
+     * @return the top-level classes and interfaces within this
+     * package
+     */
+    @Override
+    List<? extends Element> getEnclosedElements();
+
+    /**
      * Returns {@code true} is this is an unnamed package and {@code
      * false} otherwise.
      *
--- a/langtools/src/share/classes/javax/lang/model/element/TypeElement.java	Fri Jan 20 13:08:51 2012 -0800
+++ b/langtools/src/share/classes/javax/lang/model/element/TypeElement.java	Tue Jan 24 13:44:01 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -61,7 +61,12 @@
  */
 public interface TypeElement extends Element, Parameterizable, QualifiedNameable {
     /**
-     * {@inheritDoc}
+     * Returns the fields, methods, constructors, and member types
+     * that are directly declared in this class or interface.
+     *
+     * This includes any (implicit) default constructor and
+     * the implicit {@code values} and {@code valueOf} methods of an
+     * enum type.
      *
      * <p> Note that as a particular instance of the {@linkplain
      * javax.lang.model.element general accuracy requirements} and the
@@ -75,6 +80,7 @@
      *
      * @return the enclosed elements in proper order, or an empty list if none
      */
+    @Override
     List<? extends Element> getEnclosedElements();
 
     /**
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/cast/7123100/T7123100a.java	Tue Jan 24 13:44:01 2012 -0800
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug     7123100
+ * @summary javac fails with java.lang.StackOverflowError
+ * @compile/fail/ref=T7123100a.out -Werror -Xlint:unchecked -XDrawDiagnostics T7123100a.java
+ */
+
+class T7123100a {
+    <E extends Enum<E>> E m() {
+        return null;
+    }
+
+    <Z> void test() {
+        Z z = (Z)m();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/cast/7123100/T7123100a.out	Tue Jan 24 13:44:01 2012 -0800
@@ -0,0 +1,4 @@
+T7123100a.java:14:19: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), compiler.misc.type.captureof: 1, ?, Z
+- compiler.err.warnings.and.werror
+1 error
+1 warning
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/cast/7123100/T7123100b.java	Tue Jan 24 13:44:01 2012 -0800
@@ -0,0 +1,12 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug     7123100
+ * @summary javac fails with java.lang.StackOverflowError
+ * @compile/fail/ref=T7123100b.out -Werror -Xlint:unchecked -XDrawDiagnostics T7123100b.java
+ */
+
+class T7123100b {
+    <Z> void test(Enum<?> e) {
+        Z z = (Z)e;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/cast/7123100/T7123100b.out	Tue Jan 24 13:44:01 2012 -0800
@@ -0,0 +1,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
+- compiler.err.warnings.and.werror
+1 error
+1 warning
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/cast/7123100/T7123100c.java	Tue Jan 24 13:44:01 2012 -0800
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug     7123100
+ * @summary javac fails with java.lang.StackOverflowError
+ * @compile/fail/ref=T7123100c.out -Werror -Xlint:unchecked -XDrawDiagnostics T7123100c.java
+ */
+
+class T7123100c {
+    <E> E m(E e) {
+        return null;
+    }
+
+    <Z> void test(Enum<?> e) {
+        Z z = (Z)m(e);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/cast/7123100/T7123100c.out	Tue Jan 24 13:44:01 2012 -0800
@@ -0,0 +1,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
+- compiler.err.warnings.and.werror
+1 error
+1 warning
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/cast/7123100/T7123100d.java	Tue Jan 24 13:44:01 2012 -0800
@@ -0,0 +1,16 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug     7123100
+ * @summary javac fails with java.lang.StackOverflowError
+ * @compile/fail/ref=T7123100d.out -Werror -Xlint:unchecked -XDrawDiagnostics T7123100d.java
+ */
+
+class T7123100d {
+    <E extends Enum<E>> E m(Enum<E> e) {
+        return null;
+    }
+
+    <Z> void test(Enum<?> e) {
+        Z z = (Z)m(e);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/cast/7123100/T7123100d.out	Tue Jan 24 13:44:01 2012 -0800
@@ -0,0 +1,4 @@
+T7123100d.java:14:19: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), compiler.misc.type.captureof: 1, ?, Z
+- compiler.err.warnings.and.werror
+1 error
+1 warning
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/cast/7126754/T7126754.java	Tue Jan 24 13:44:01 2012 -0800
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @author mcimadamore
+ * @bug     7005671
+ * @summary Generics compilation failure casting List<? extends Set...> to List<Set...>
+ * @compile/fail/ref=T7126754.out -Xlint:unchecked -Werror -XDrawDiagnostics T7126754.java
+ */
+
+import java.util.List;
+
+class T7126754 {
+    List<? extends List<? extends String>> c = null;
+    List<List<? extends String>> d = (List<List<? extends String>>)c;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/cast/7126754/T7126754.out	Tue Jan 24 13:44:01 2012 -0800
@@ -0,0 +1,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>>
+- compiler.err.warnings.and.werror
+1 error
+1 warning
--- a/langtools/test/tools/javac/diags/CheckExamples.java	Fri Jan 20 13:08:51 2012 -0800
+++ b/langtools/test/tools/javac/diags/CheckExamples.java	Tue Jan 24 13:44:01 2012 -0800
@@ -23,10 +23,13 @@
 
 /*
  * @test
- * @bug 6968063
+ * @bug 6968063 7127924
  * @summary provide examples of code that generate diagnostics
  * @build Example CheckExamples
- * @run main CheckExamples
+ * @run main/othervm CheckExamples
+ */
+/*
+ *      See CR 7127924 for info on why othervm is used.
  */
 
 import java.io.*;
--- a/langtools/test/tools/javac/diags/MessageInfo.java	Fri Jan 20 13:08:51 2012 -0800
+++ b/langtools/test/tools/javac/diags/MessageInfo.java	Tue Jan 24 13:44:01 2012 -0800
@@ -23,10 +23,13 @@
 
 /**
  * @test
- * @bug 7013272
+ * @bug 7013272 7127924
  * @summary Automatically generate info about how compiler resource keys are used
  * @build Example ArgTypeCompilerFactory MessageFile MessageInfo
- * @run main MessageInfo
+ * @run main/othervm MessageInfo
+ */
+/*
+ *      See CR 7127924 for info on why othervm is used.
  */
 
 import java.io.*;
--- a/langtools/test/tools/javac/diags/RunExamples.java	Fri Jan 20 13:08:51 2012 -0800
+++ b/langtools/test/tools/javac/diags/RunExamples.java	Tue Jan 24 13:44:01 2012 -0800
@@ -23,10 +23,13 @@
 
 /**
  * @test
- * @bug 6968063
+ * @bug 6968063 7127924
  * @summary provide examples of code that generate diagnostics
  * @build ArgTypeCompilerFactory Example HTMLWriter RunExamples
- * @run main RunExamples
+ * @run main/othervm RunExamples
+ */
+/*
+ *      See CR 7127924 for info on why othervm is used.
  */
 
 import java.io.*;