Merge
diff --git a/src/share/classes/com/sun/tools/javac/code/Types.java b/src/share/classes/com/sun/tools/javac/code/Types.java
index 070bf9d..c9cc2ce 100644
--- a/src/share/classes/com/sun/tools/javac/code/Types.java
+++ b/src/share/classes/com/sun/tools/javac/code/Types.java
@@ -1298,7 +1298,7 @@
                     return t;
 
                 Type st = supertype(t);
-                if (st.tag == CLASS || st.tag == ERROR) {
+                if (st.tag == CLASS || st.tag == TYPEVAR || st.tag == ERROR) {
                     Type x = asSuper(st, sym);
                     if (x != null)
                         return x;
@@ -1320,7 +1320,10 @@
 
             @Override
             public Type visitTypeVar(TypeVar t, Symbol sym) {
-                return asSuper(t.bound, sym);
+                if (t.tsym == sym)
+                    return t;
+                else
+                    return asSuper(t.bound, sym);
             }
 
             @Override
diff --git a/src/share/classes/com/sun/tools/javac/comp/Attr.java b/src/share/classes/com/sun/tools/javac/comp/Attr.java
index f597bc7..89fa138 100644
--- a/src/share/classes/com/sun/tools/javac/comp/Attr.java
+++ b/src/share/classes/com/sun/tools/javac/comp/Attr.java
@@ -2199,7 +2199,7 @@
                 (env.tree.getTag() != JCTree.ASSIGN ||
                  TreeInfo.skipParens(((JCAssign) env.tree).lhs) != tree)) {
 
-                if (!onlyWarning || isNonStaticEnumField(v)) {
+                if (!onlyWarning || isStaticEnumField(v)) {
                     log.error(tree.pos(), "illegal.forward.ref");
                 } else if (useBeforeDeclarationWarning) {
                     log.warning(tree.pos(), "forward.ref", v);
@@ -2233,7 +2233,7 @@
             // initializer expressions of an enum constant e to refer
             // to itself or to an enum constant of the same type that
             // is declared to the right of e."
-            if (isNonStaticEnumField(v)) {
+            if (isStaticEnumField(v)) {
                 ClassSymbol enclClass = env.info.scope.owner.enclClass();
 
                 if (enclClass == null || enclClass.owner == null)
@@ -2254,8 +2254,14 @@
             }
         }
 
-        private boolean isNonStaticEnumField(VarSymbol v) {
-            return Flags.isEnum(v.owner) && Flags.isStatic(v) && !Flags.isConstant(v);
+        /** Is the given symbol a static, non-constant field of an Enum?
+         *  Note: enum literals should not be regarded as such
+         */
+        private boolean isStaticEnumField(VarSymbol v) {
+            return Flags.isEnum(v.owner) &&
+                   Flags.isStatic(v) &&
+                   !Flags.isConstant(v) &&
+                   v.name != names._class;
         }
 
         /** Can the given symbol be the owner of code which forms part
diff --git a/src/share/classes/com/sun/tools/javac/comp/Infer.java b/src/share/classes/com/sun/tools/javac/comp/Infer.java
index 071d2fc..3539a50 100644
--- a/src/share/classes/com/sun/tools/javac/comp/Infer.java
+++ b/src/share/classes/com/sun/tools/javac/comp/Infer.java
@@ -157,6 +157,19 @@
                     if (isSubClass(bs.head, that.hibounds))
                         that.inst = types.fromUnknownFun.apply(bs.head);
                 }
+                if (that.inst == null) {
+                    int classCount = 0, interfaceCount = 0;
+                    for (Type t : that.hibounds) {
+                        if (t.tag == CLASS) {
+                            if (t.isInterface())
+                                interfaceCount++;
+                            else
+                                classCount++;
+                        }
+                    }
+                    if ((that.hibounds.size() == classCount + interfaceCount) && classCount == 1)
+                        that.inst = types.makeCompoundType(that.hibounds);
+                }
                 if (that.inst == null || !types.isSubtypeUnchecked(that.inst, that.hibounds, warn))
                     throw ambiguousNoInstanceException
                         .setMessage("no.unique.maximal.instance.exists",
diff --git a/src/share/classes/com/sun/tools/javac/comp/Resolve.java b/src/share/classes/com/sun/tools/javac/comp/Resolve.java
index 1df0bb7..f567133 100644
--- a/src/share/classes/com/sun/tools/javac/comp/Resolve.java
+++ b/src/share/classes/com/sun/tools/javac/comp/Resolve.java
@@ -407,6 +407,8 @@
                      Type site,
                      Name name,
                      TypeSymbol c) {
+        while (c.type.tag == TYPEVAR)
+            c = c.type.getUpperBound().tsym;
         Symbol bestSoFar = varNotFound;
         Symbol sym;
         Scope.Entry e = c.members().lookup(name);
@@ -418,7 +420,7 @@
             e = e.next();
         }
         Type st = types.supertype(c.type);
-        if (st != null && st.tag == CLASS) {
+        if (st != null && (st.tag == CLASS || st.tag == TYPEVAR)) {
             sym = findField(env, site, name, st.tsym);
             if (sym.kind < bestSoFar.kind) bestSoFar = sym;
         }
@@ -733,7 +735,9 @@
                               boolean allowBoxing,
                               boolean useVarargs,
                               boolean operator) {
-        for (Type ct = intype; ct.tag == CLASS; ct = types.supertype(ct)) {
+        for (Type ct = intype; ct.tag == CLASS || ct.tag == TYPEVAR; ct = types.supertype(ct)) {
+            while (ct.tag == TYPEVAR)
+                ct = ct.getUpperBound();
             ClassSymbol c = (ClassSymbol)ct.tsym;
             if ((c.flags() & (ABSTRACT | INTERFACE)) == 0)
                 abstractok = false;
diff --git a/test/tools/javac/6304921/T6304921.java b/test/tools/javac/6304921/T6304921.java
index 609110e..061817d 100644
--- a/test/tools/javac/6304921/T6304921.java
+++ b/test/tools/javac/6304921/T6304921.java
@@ -1,8 +1,6 @@
 /*
  * @test (important: no SCCS keywords to affect offsets in golden file.)  /nodynamiccopyright/
  * @bug 6304921
- * @ignore
- *    Need to fix this test post whitespace normalization
  * @compile/fail/ref=T6304921.out -XDstdout -XDcompilePolicy=bytodo -XDdiags=%b:%s/%o/%e:%_%t%m|%p%m -Xjcov -Xlint:all,-path -Werror T6304921.java
  */
 
diff --git a/test/tools/javac/6304921/T6304921.out b/test/tools/javac/6304921/T6304921.out
index 10340e2..32218ac 100644
--- a/test/tools/javac/6304921/T6304921.out
+++ b/test/tools/javac/6304921/T6304921.out
@@ -1,20 +1,20 @@
-T6304921.java:569/569/584: warning: [unchecked] unchecked conversion
+T6304921.java:667/667/682: warning: [unchecked] unchecked conversion
 found   : java.util.ArrayList
 required: java.util.List<java.lang.Integer>
         List<Integer> list = new ArrayList();
                              ^
-T6304921.java:410/410/418: warning: [fallthrough] possible fall-through into case
+T6304921.java:445/445/453: warning: [fallthrough] possible fall-through into case
         default:
         ^
-T6304921.java:452/522/523: warning: [finally] finally clause cannot complete normally
+T6304921.java:522/613/614: warning: [finally] finally clause cannot complete normally
         }
         ^
-T6304921.java:622/628/632: cannot find symbol
+T6304921.java:727/733/737: cannot find symbol
 symbol  : variable orr
 location: class java.lang.System
         System.orr.println("abc"); // name not found
               ^
-T6304921.java:700/704/710: operator + cannot be applied to int,boolean
+T6304921.java:812/816/822: operator + cannot be applied to int,boolean
         return 123 + true; // bad binary expression
                    ^
 2 errors
diff --git a/test/tools/javac/api/6431257/T6431257.java b/test/tools/javac/api/6431257/T6431257.java
index 4d751eb..3be14e2 100644
--- a/test/tools/javac/api/6431257/T6431257.java
+++ b/test/tools/javac/api/6431257/T6431257.java
@@ -27,6 +27,7 @@
  * @summary JSR 199: Changes to JavaFileManager to support JSR 269 Filer API
  * @author  Peter von der Ah\u00e9
  * @library ../lib
+ * @ignore  Need to fix this test when 6508981 is fixed.
  * @compile T6431257.java package-info.java
  * @run main T6431257 foo.bar.baz foo/bar/baz
  */
diff --git a/test/tools/javac/enum/T6509042.java b/test/tools/javac/enum/T6509042.java
new file mode 100644
index 0000000..53a59bf
--- /dev/null
+++ b/test/tools/javac/enum/T6509042.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6509042
+ *
+ * @summary javac rejects class literals in enum constructors
+ * @author Maurizio Cimadamore
+ *
+ * @compile T6509042.java
+ */
+enum T6509042 {
+     A, B;
+
+     Class<T6509042> cl = T6509042.class;
+
+     T6509042() {
+         Class<T6509042> cl2 = T6509042.class;
+     }
+}
diff --git a/test/tools/javac/generics/6531090/T6531090a.java b/test/tools/javac/generics/6531090/T6531090a.java
new file mode 100644
index 0000000..f00235e
--- /dev/null
+++ b/test/tools/javac/generics/6531090/T6531090a.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6531090
+ *
+ * @summary Cannot access methods/fields of a captured type belonging to an intersection type
+ * @author Maurizio Cimadamore
+ *
+ */
+public class T6531090a {
+
+    static class E {}
+
+    static class F extends E implements I1 {}
+
+    static interface I {}
+
+    static interface I1 {}
+
+    static class G extends F implements I {}
+
+    static class C<T extends E & I> {
+        T field;
+    }
+
+    public static void main(String... args) {
+        test(new C<G>());
+    }
+
+    static <W extends F> void test(C<? extends W> arg) {
+        F vf = arg.field;
+        I vi = arg.field;
+        I1 vi1 = arg.field;
+        E ve = arg.field;
+        W vt = arg.field;
+    }
+}
diff --git a/test/tools/javac/generics/6531090/T6531090b.java b/test/tools/javac/generics/6531090/T6531090b.java
new file mode 100644
index 0000000..ede819f
--- /dev/null
+++ b/test/tools/javac/generics/6531090/T6531090b.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug 6531090
+ *
+ * @summary Cannot access methods/fields of a captured type belonging to an intersection type
+ * @author Maurizio Cimadamore
+ *
+ */
+public class T6531090b {
+
+    static class A {
+        public void a() {}
+        public A a;
+    }
+    static class B extends A {
+        public void b(){}
+        public B b;
+    }
+    static interface I{
+        void i();
+    }
+    static interface I1{
+        void i1();
+    }
+    static class E extends B implements I, I1{
+        public void i() {}
+        public void i1() {}
+    }
+    static class C<W extends B & I1, T extends W>{
+        T t;
+        W w;
+        C(W w, T t) {
+            this.w = w;
+            this.t = t;
+        }
+    }
+
+    public static void main(String... args) {
+        C<E,E> c = new C<E,E>(new E(), new E());
+        testMemberMethods(c);
+        testMemberFields(c);
+    }
+
+    static void testMemberMethods(C<? extends A, ? extends I> arg) {
+        arg.t.a();
+        arg.t.b();
+        arg.t.i1();
+        arg.w.a();
+        arg.w.b();
+        arg.w.i1();
+    }
+
+    static void testMemberFields(C<? extends A, ? extends I> arg) {
+        A ta = arg.t.a;
+        B tb = arg.t.b;
+        A wa = arg.w.a;
+        B wb = arg.w.b;
+    }
+}
diff --git a/test/tools/javac/generics/inference/6569789/T6569789.java b/test/tools/javac/generics/inference/6569789/T6569789.java
new file mode 100644
index 0000000..d7036ff
--- /dev/null
+++ b/test/tools/javac/generics/inference/6569789/T6569789.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2008 Sun Microsystems, Inc.  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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+/*
+ * @test
+ * @bug     6569789
+ * @summary Compiler test lang/TYPE/type153/type15304/type15304.html fails since jdk7 b05
+ * @compile T6569789.java
+ */
+
+class C {}
+interface I {}
+interface I1 {}
+interface I2 {}
+class CT extends C implements I, I1, I2 {}
+
+public class T6569789 {
+    public static void m() {
+        CT ct = new CT();
+        testMethod(ct);
+    }
+
+    static <W extends C & I & I1 & I2, T extends W> void testMethod(T t) {}
+}
\ No newline at end of file