changeset 10551:99dd9e50f37e

Merge
author henryjen
date Mon, 11 Nov 2013 23:17:30 -0800
parents f82b730c798b ed09558136be
children 2b0c2fc213d6
files .hgtags .jcheck/conf makefiles/CreateJars.gmk makefiles/CreateSecurityJars.gmk src/macosx/native/sun/osxapp/NSApplicationAWT.m src/share/classes/java/awt/EventDispatchThread.java src/share/classes/java/beans/EventHandler.java src/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java src/share/classes/java/lang/invoke/TypeConvertingMethodAdapter.java src/share/classes/java/util/Arrays.java src/share/classes/java/util/PriorityQueue.java src/share/classes/java/util/concurrent/ArrayBlockingQueue.java src/share/classes/java/util/concurrent/ConcurrentSkipListMap.java src/share/classes/java/util/regex/Pattern.java src/share/classes/java/util/stream/DistinctOps.java src/share/classes/java/util/stream/StreamSpliterators.java src/share/classes/sun/awt/datatransfer/DataTransferer.java src/share/javavm/export/jvm.h src/solaris/classes/sun/nio/fs/UnixPath.java src/windows/classes/sun/nio/fs/WindowsPath.java test/ProblemList.txt test/java/util/stream/test/org/openjdk/tests/java/lang/invoke/SerializedLambdaTest.java
diffstat 136 files changed, 19157 insertions(+), 79 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Thu Oct 31 16:44:18 2013 -0700
+++ b/.hgignore	Mon Nov 11 23:17:30 2013 -0800
@@ -5,3 +5,19 @@
 ^make/netbeans/.*/dist/
 ^.hgtip
 .DS_Store
+^test-ng/gen-separate/
+^test-ng/lib/
+^.idea/
+^combo-tests/gen/
+^combo-tests/build/
+^out/
+.*\.rej$
+.*\.orig$
+.*\.iml$
+.*~$
+^webrev/
+webrev.zip$
+^.classpath
+^.project
+JTreport
+JTwork
--- a/.hgtags	Thu Oct 31 16:44:18 2013 -0700
+++ b/.hgtags	Mon Nov 11 23:17:30 2013 -0800
@@ -167,16 +167,20 @@
 b3246687c3695dff6f461bb407f9db88f7d072e7 jdk8-b43
 db471a7af03168e4441c245b1d9976f720a7cb77 jdk8-b44
 b92353a01aa049bc508fc56f0347d5934b7c4390 jdk8-b45
+077225955d5722f0fbd780650178c5931693c07e lambda-b45
 8d2ed9d58453c8049715a72a6d26b6b66b37a94c jdk8-b46
 00b22b23269a57d0bb46c57753be2fe9a9d2c1a3 jdk8-b47
 3e4ab821f46166fcf63e8fe5c8046216003c941f jdk8-b48
+b3b65a3d441e7f39cb68140d2db547704ea0a670 lambda-b48
 51707c3b75c0f521794d9ab425f4e5b2351c70c1 jdk8-b49
 e4bae5c53fca8fcb9393d47fd36a34b9e2e8d4ec jdk8-b50
+958eaa191b79bf79be82979240903199791ed9f7 lambda-b50
 e865efbc71059a414b3b2dd2e0adfcb3d2ab6ff9 jdk8-b51
 e8569a473cee7f4955bd9e76a9bdf6c6a07ced27 jdk8-b52
 2c6933c5106b81a8578b70996fe5b735fb3adb60 jdk8-b53
 70ad0ed1d6cef0e7712690d1bab21e4769708aad jdk8-b54
 1f3f4b333341873f00da3dee85e4879f0e89c9bb jdk8-b55
+2e6170973d921fe4b8d2dfd6032f5aaf4150a542 lambda-b56
 2e9eeef2909b33c9224a024afddb61ccb0b77f14 jdk8-b56
 51594d095a4bcffac4a314bf6e148214501399e0 jdk8-b57
 d94613ac03d8de375ef60493e2bb76dbd30d875d jdk8-b58
--- a/.jcheck/conf	Thu Oct 31 16:44:18 2013 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-project=jdk8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/build.xml	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="jdk" default="test">
+
+    <property name="build.dir" value="../../build/combo-tests" />
+    <property name="gen.dir" value="${build.dir}/gen" />
+    <property name="test.classes.dir" value="${build.dir}/test-classes"/>
+    <property name="test.reports.dir" value="${build.dir}/test-reports"/>
+    <property name="test.src.dir" value="tests"/>
+    <property name="lib.dir" location="lib" />
+    <property name="test.pattern" value="*Test" />
+    <property name="lambda.metafactory" value="" />
+    <property name="combo.debug" value="" />
+    <property name="heap.size" value="4G" />
+
+    <property name="lib.testng.jar" value="${lib.dir}/testng-6.7.jar"/>
+    <property name="lib.tools.jar" value="${java.home}/../lib/tools.jar"/>
+
+    <path id="test.class.path">
+        <pathelement path="${sun.boot.class.path}" />
+        <pathelement location="${test.classes.dir}" />
+        <pathelement location="${lib.testng.jar}"/>
+        <pathelement location="${lib.tools.jar}"/>
+    </path>
+
+    <taskdef name="testng" classpathref="test.class.path" classname="org.testng.TestNGAntTask" />
+
+    <target name="prepare">
+        <mkdir dir="${build.dir}"/>
+        <mkdir dir="${lib.dir}"/>
+        <mkdir dir="${test.classes.dir}"/>
+        <mkdir dir="${test.reports.dir}"/>
+    </target>
+
+    <target name="test-compile" depends="prepare">
+        <javac destdir="${test.classes.dir}" debug="on" srcdir="${test.src.dir}" fork="true"
+               classpathref="test.class.path">
+            <compilerarg value="-XDlambdaToMethod"/>
+        </javac>
+    </target>
+
+    <target name="test" depends="test-compile" >
+        <delete dir="${gen.dir}" />
+        <testng outputdir="${test.reports.dir}" usedefaultlisteners="false"
+                listeners="org.testng.reporters.FailedReporter,org.testng.reporters.XMLReporter">
+            <classpath refid="test.class.path" />
+            <classfileset dir="${test.classes.dir}" includes="**/${test.pattern}.class"/>
+            <jvmarg value="-Xms1G" />
+            <jvmarg value="-Xmx${heap.size}" />
+            <jvmarg value="-XX:+UseNUMA" />
+            <jvmarg value="-XX:+UseG1GC" />
+            <jvmarg value="-ea" />
+            <jvmarg value="-esa" />
+            <jvmarg value="-Xverify:all" />
+            <sysproperty key="lambda.metafactory" value="${lambda.metafactory}" />
+            <sysproperty key="combo.debug" value="${combo.debug}" />
+        </testng>
+    </target>
+   
+    <!-- New target added that uses a different set of listeners to show results in Aurora --> 
+    <target name="aurora-test" depends="test-compile" >
+        <testng outputdir="${test.reports.dir}" usedefaultlisteners="false"
+                listeners="org.testng.reporters.JUnitXMLReporter,org.testng.reporters.JUnitReportReporter,
+                           org.testng.reporters.XMLReporter">
+            <classpath refid="test.class.path" />
+            <classfileset dir="${test.classes.dir}" includes="**/${test.pattern}.class"/>
+            <jvmarg value="-Xms1G" />
+            <jvmarg value="-Xmx2G" />
+            <jvmarg value="-XX:+UseNUMA" />
+            <jvmarg value="-XX:+UseG1GC" />
+            <jvmarg value="-ea" />
+            <jvmarg value="-esa" />
+            <jvmarg value="-Xverify:all" />
+            <sysproperty key="lambda.metafactory" value="${lambda.metafactory}" />
+            <sysproperty key="combo.debug" value="${combo.debug}" />
+        </testng>
+    </target>
+
+    <target name="clean">
+        <delete dir="${build.dir}" />
+        <delete dir="${gen.dir}" />
+    </target>
+</project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/combo/BridgeMethodTestCase.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,423 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.combo;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringJoiner;
+
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.fail;
+
+/**
+ * BridgeMethodTestCase -- used for asserting linkage to bridges under separate compilation.
+ *
+ * Example test case:
+ *     public void test1() throws IOException, ReflectiveOperationException {
+ *         compileSpec("C(Bc1(A))");
+ *         assertLinkage("C", LINKAGE_ERROR, "B1");
+ *         recompileSpec("C(Bc1(Ac0))", "A");
+ *          assertLinkage("C", "A0", "B1");
+ *     }
+ *
+ * This compiles A, B, and C, asserts that C.m()Object does not exist, asserts
+ * that C.m()Number eventually invokes B.m()Number, recompiles B, and then asserts
+ * that the result of calling C.m()Object now arrives at A.
+ *
+ * @author Brian Goetz
+ */
+
+@Test
+public abstract class BridgeMethodTestCase extends JavacTemplateTestBase {
+
+    private static final String TYPE_LETTERS = "ABCDIJK";
+
+    private static final String BASE_INDEX_CLASS = "class C0 {\n" +
+                                                   "    int val;\n" +
+                                                   "    C0(int val) { this.val = val; }\n" +
+                                                   "    public int getVal() { return val; }\n" +
+                                                   "}\n";
+    
+    private static final String INDEX_CLASS_TEMPLATE = "class C#ID extends C#PREV {\n" +
+                                                       "    C#ID(int val) { super(val); }\n" +
+                                                       "}\n";
+
+
+
+    protected static String LINKAGE_ERROR = "-1";
+
+    private List<File> compileDirs = new ArrayList<>();
+
+    /**
+     * Compile all the classes in a class spec, and put them on the classpath.
+     *
+     * The spec is the specification for a nest of classes, using the following notation
+     * A, B represent abstract classes
+     * C represents a concrete class
+     * I, J, K represent interfaces
+     * Lowercase 'c' following a class means that the method m() is concrete
+     * Lowercase 'a' following a class or interface means that the method m() is abstract
+     * Lowercase 'd' following an interface means that the method m() is default
+     * A number 0, 1, or 2 following the lowercase letter indicates the return type of that method
+     * 0 = Object, 1 = Number, 2 = Integer (these form an inheritance chain so bridges are generated)
+     * A classes supertypes follow its method spec, in parentheses
+     * Examples:
+     *   C(Ia0, Jd0) -- C extends I and J, I has abstract m()Object, J has default m()Object
+     *   Cc1(Ia0) -- C has concrete m()Number, extends I with abstract m()Object
+     * If a type must appear multiple times, its full spec must be in the first occurrence
+     * Example:
+     *   C(I(Kd0), J(K))
+     */
+    protected void compileSpec(String spec) throws IOException {
+        compileSpec(spec, false);
+    }
+
+    /**
+     * Compile all the classes in a class spec, and assert that there were compilation errors.
+     */
+    protected void compileSpec(String spec, String... errorKeys) throws IOException {
+        compileSpec(spec, false, errorKeys);
+    }
+
+    protected void compileSpec(String spec, boolean debug, String... errorKeys) throws IOException {
+        ClassModel cm = new Parser(spec).parseClassModel();
+        for (int i = 0; i <= cm.maxIndex() ; i++) {
+            if (debug) System.out.println(indexClass(i));
+            addSourceFile(String.format("C%d.java", i), new StringTemplate(indexClass(i)));
+        }  
+        for (Map.Entry<String, ClassModel> e : classes(cm).entrySet()) {
+            if (debug) System.out.println(e.getValue().toSource());
+            addSourceFile(e.getKey() + ".java", new StringTemplate(e.getValue().toSource()));
+        }
+        compileDirs.add(compile(true));
+        resetSourceFiles();
+        if (errorKeys.length == 0)
+            assertCompileSucceeded();
+        else
+            assertCompileErrors(errorKeys);
+    }
+
+    /**
+     * Recompile only a subset of classes in the class spec, as named by names,
+     * and put them on the classpath such that they shadow earlier versions of that class.
+     */
+    protected void recompileSpec(String spec, String... names) throws IOException {
+        List<String> nameList = Arrays.asList(names);
+        ClassModel cm = new Parser(spec).parseClassModel();
+        for (int i = 0; i <= cm.maxIndex() ; i++) {
+            addSourceFile(String.format("C%d.java", i), new StringTemplate(indexClass(i)));
+        }
+        for (Map.Entry<String, ClassModel> e : classes(cm).entrySet())
+            if (nameList.contains(e.getKey()))
+                addSourceFile(e.getKey() + ".java", new StringTemplate(e.getValue().toSource()));
+        compileDirs.add(compile(Arrays.asList(classPaths()), true));
+        resetSourceFiles();
+        assertCompileSucceeded();
+    }
+
+    protected void assertLinkage(String name, String... expected) throws ReflectiveOperationException {
+        for (int i=0; i<expected.length; i++) {
+            String e = expected[i];
+            if (e.equals(LINKAGE_ERROR)) {
+                try {
+                    int actual = invoke(name, i);
+                    fail("Expected linkage error, got" + fromNum(actual));
+                }
+                catch (LinkageError x) {
+                    // success
+                }
+            }
+            else {
+                if (e.length() == 1)
+                    e += "0";
+                int expectedInt = toNum(e);
+                int actual = invoke(name, i);
+                if (expectedInt != actual)
+                    fail(String.format("Expected %s but found %s for %s.m()%d", fromNum(expectedInt), fromNum(actual), name, i));
+            }
+        }
+    }
+
+    private Map<String, ClassModel> classes(ClassModel cm) {
+        HashMap<String, ClassModel> m = new HashMap<>();
+        classesHelper(cm, m);
+        return m;
+    }
+
+    private String indexClass(int index) {
+        if (index == 0) {
+            return BASE_INDEX_CLASS;
+        } else {
+            return INDEX_CLASS_TEMPLATE
+                    .replace("#ID", String.valueOf(index))
+                    .replace("#PREV", String.valueOf(index - 1));
+        }
+    }
+
+    private static String overrideName(int index) {
+        return "C" + index;
+    }
+
+    private void classesHelper(ClassModel cm, Map<String, ClassModel> m) {
+        if (!m.containsKey(cm.name))
+            m.put(cm.name, cm);
+        for (ClassModel s : cm.supertypes)
+            classesHelper(s, m);
+    }
+
+    private static String fromNum(int num) {
+        return String.format("%c%d", TYPE_LETTERS.charAt(num / 10), num % 10);
+    }
+
+    private static int toNum(String name, int index) {
+        return 10*(TYPE_LETTERS.indexOf(name.charAt(0))) + index;
+    }
+
+    private static int toNum(String string) {
+        return 10*(TYPE_LETTERS.indexOf(string.charAt(0))) + Integer.parseInt(string.substring(1, 2));
+    }
+
+    private int invoke(String name, int index) throws ReflectiveOperationException {
+        File[] files = classPaths();
+        Class clazz = loadClass(name, files);
+        Method[] ms = clazz.getMethods();
+        for (Method m : ms) {
+            if (m.getName().equals("m") && m.getReturnType().getName().equals(overrideName(index))) {
+                m.setAccessible(true);
+                Object instance = clazz.newInstance();
+                Object c0 = m.invoke(instance);
+                Method getVal = c0.getClass().getMethod("getVal");
+                getVal.setAccessible(true);
+                return (int)getVal.invoke(c0);
+            }
+        }
+        throw new NoSuchMethodError("cannot find method m()" + index + " in class " + name);
+    }
+
+    private File[] classPaths() {
+        File[] files = new File[compileDirs.size()];
+        for (int i=0; i<files.length; i++)
+            files[files.length - i - 1] = compileDirs.get(i);
+        return files;
+    }
+
+    @BeforeMethod
+    @Override
+    public void reset() {
+        compileDirs.clear();
+        super.reset();
+    }
+
+    private static class ClassModel {
+
+        enum MethodType {
+            ABSTRACT('a'), CONCRETE('c'), DEFAULT('d');
+
+            public final char designator;
+
+            MethodType(char designator) {
+                this.designator = designator;
+            }
+
+            public static MethodType find(char c) {
+                for (MethodType m : values())
+                    if (m.designator == c)
+                        return m;
+                throw new IllegalArgumentException();
+            }
+        }
+
+        private final String name;
+        private final boolean isInterface;
+        private final List<ClassModel> supertypes;
+        private final MethodType methodType;
+        private final int methodIndex;
+
+        private ClassModel(String name,
+                           boolean anInterface,
+                           List<ClassModel> supertypes,
+                           MethodType methodType,
+                           int methodIndex) {
+            this.name = name;
+            isInterface = anInterface;
+            this.supertypes = supertypes;
+            this.methodType = methodType;
+            this.methodIndex = methodIndex;
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder();
+            sb.append(name);
+            if (methodType != null) {
+                sb.append(methodType.designator);
+                sb.append(methodIndex);
+            }
+            if (!supertypes.isEmpty()) {
+                sb.append("(");
+                for (int i=0; i<supertypes.size(); i++) {
+                    if (i > 0)
+                        sb.append(",");
+                    sb.append(supertypes.get(i).toString());
+                }
+                sb.append(")");
+            }
+            return sb.toString();
+        }
+
+        int maxIndex() {
+            int maxSoFar = methodIndex;
+            for (ClassModel cm : supertypes) {
+                maxSoFar = Math.max(cm.maxIndex(), maxSoFar);
+            }
+            return maxSoFar;
+        }
+
+        public String toSource() {
+            String extendsClause = "";
+            String implementsClause = "";
+            String methodBody = "";
+            boolean isAbstract = "AB".contains(name);
+
+            for (ClassModel s : supertypes) {
+                if (!s.isInterface) {
+                    extendsClause = String.format("extends %s", s.name);
+                    break;
+                }
+            }
+
+            StringJoiner sj = new StringJoiner(", ");
+            for (ClassModel s : supertypes)
+                if (s.isInterface)
+                    sj.add(s.name);
+            if (sj.length() > 0) {
+                if (isInterface)
+                    implementsClause = "extends " + sj.toString();
+                else
+                implementsClause = "implements " + sj.toString();
+            }
+            if (methodType != null) {
+                switch (methodType) {
+                    case ABSTRACT:
+                        methodBody = String.format("public abstract %s m();", overrideName(methodIndex));
+                        break;
+                    case CONCRETE:
+                        methodBody = String.format("public %s m() { return new %s(%d); };",
+                                overrideName(methodIndex), overrideName(methodIndex), toNum(name, methodIndex));
+                        break;
+                    case DEFAULT:
+                        methodBody = String.format("public default %s m() { return new %s(%d); };",
+                                overrideName(methodIndex), overrideName(methodIndex), toNum(name, methodIndex));
+                        break;
+
+                }
+            }
+
+            return String.format("public %s %s %s %s %s {  %s }", isAbstract ? "abstract" : "",
+                                 isInterface ? "interface" : "class",
+                                 name, extendsClause, implementsClause, methodBody);
+        }
+    }
+
+    private static class Parser {
+        private final String input;
+        private final char[] chars;
+        private int index;
+
+        private Parser(String s) {
+            input = s;
+            chars = s.toCharArray();
+        }
+
+        private char peek() {
+            return index < chars.length ? chars[index] : 0;
+        }
+
+        private boolean peek(String validChars) {
+            return validChars.indexOf(peek()) >= 0;
+        }
+
+        private char advanceIf(String validChars) {
+            if (peek(validChars))
+                return chars[index++];
+            else
+                return 0;
+        }
+
+        private char advanceIfDigit() {
+            return advanceIf("0123456789");
+        }
+
+        private int index() {
+            StringBuilder buf = new StringBuilder();
+            char c = advanceIfDigit();
+            while (c != 0) {
+                buf.append(c);
+                c = advanceIfDigit();
+            }
+            return Integer.valueOf(buf.toString());
+        }
+
+        private char advance() {
+            return chars[index++];
+        }
+
+        private char expect(String validChars) {
+            char c = advanceIf(validChars);
+            if (c == 0)
+                throw new IllegalArgumentException(String.format("Expecting %s at position %d of %s", validChars, index, input));
+            return c;
+        }
+
+        public ClassModel parseClassModel() {
+            List<ClassModel> supers = new ArrayList<>();
+            char name = expect(TYPE_LETTERS);
+            boolean isInterface = "IJK".indexOf(name) >= 0;
+            ClassModel.MethodType methodType = peek(isInterface ? "ad" : "ac") ? ClassModel.MethodType.find(advance()) : null;
+            int methodIndex = 0;
+            if (methodType != null) {
+                methodIndex = index();
+            }
+            if (peek() == '(') {
+                advance();
+                supers.add(parseClassModel());
+                while (peek() == ',') {
+                    advance();
+                    supers.add(parseClassModel());
+                }
+                expect(")");
+            }
+            return new ClassModel(new String(new char[]{ name }), isInterface, supers, methodType, methodIndex);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/combo/BridgeMethodsLinearTest.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,1083 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.combo;
+
+import java.io.IOException;
+
+import org.testng.annotations.Test;
+
+/**
+ * BridgeMethodsLinearTest
+ *
+ * @author Brian Goetz
+ */
+@Test
+public class BridgeMethodsLinearTest extends BridgeMethodTestCase {
+
+    /*
+     * Cc1(A) -> Cc1(Ac0)
+     *
+     * 0*: Inherited from A
+     * 1: Declared in C
+     */
+    public void test1() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc1(A)");
+        assertLinkage("C", LINKAGE_ERROR, "C1");
+        recompileSpec("Cc1(Ac0)", "A");
+        assertLinkage("C", "A0", "C1");
+    }
+
+    /*
+     * Cc1(I) -> Cc1(Id0)
+     *
+     * 0*: Inherited default from I
+     * 1: Declared in C
+     */
+    public void test2() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc1(I)");
+        assertLinkage("C", LINKAGE_ERROR, "C1");
+        recompileSpec("Cc1(Id0)", "I");
+        assertLinkage("C", "I0", "C1");
+    }
+
+    /*
+     * C(Bc1(A)) -> C(Bc1(Ac0))
+     *
+     * 0*: Inherited from A
+     * 1: Inherited from B
+     */
+    public void test3() throws IOException, ReflectiveOperationException {
+        compileSpec("C(Bc1(A))");
+        assertLinkage("C", LINKAGE_ERROR, "B1");
+        recompileSpec("C(Bc1(Ac0))", "A");
+        assertLinkage("C", "A0", "B1");
+    }
+
+    /*
+     * C(B(Ac0)) -> C(Bc1(Ac0))
+     *
+     * 0: Inherited from B (through bridge)
+     * 1: Inherited from B
+     */
+    public void test4() throws IOException, ReflectiveOperationException {
+        compileSpec("C(B(Ac0))");
+        assertLinkage("C", "A0", LINKAGE_ERROR);
+        recompileSpec("C(Bc1(Ac0))", "B");
+        assertLinkage("C", "B1", "B1");
+    }
+
+    /*
+     * C(B(A)) -> C(Bc1(Ac0))
+     *
+     * 0: Inherited from B (through bridge)
+     * 1: Inherited from B
+     */
+    public void test5() throws IOException, ReflectiveOperationException {
+        compileSpec("C(B(A))");
+        assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR);
+        recompileSpec("C(Bc1(Ac0))", "A", "B");
+        assertLinkage("C", "B1", "B1");
+    }
+
+    /*
+     * C(Ac1(I)) -> C(Ac1(Id0))
+     *
+     * 0*: Inherited default from I
+     * 1: Inherited from A
+     */
+    public void test6() throws IOException, ReflectiveOperationException {
+        compileSpec("C(Ac1(I))");
+        assertLinkage("C", LINKAGE_ERROR, "A1");
+        recompileSpec("C(Ac1(Id0))", "I");
+        assertLinkage("C", "I0", "A1");
+    }
+
+    /*
+     * C(A(Id0)) -> C(Ac1(Id0))
+     *
+     * 0: Inherited from A (through bridge)
+     * 1: Inherited from A
+     */
+    public void test7() throws IOException, ReflectiveOperationException {
+        compileSpec("C(A(Id0))");
+        assertLinkage("C", "I0", LINKAGE_ERROR);
+        recompileSpec("C(Ac1(Id0))", "A");
+        assertLinkage("C", "A1", "A1");
+    }
+
+    /*
+     * C(A(I)) -> C(Ac1(Id0))
+     *
+     * 0*: Inherited from A (through bridge)
+     * 1*: Inherited from A
+     */
+    public void test8() throws IOException, ReflectiveOperationException {
+        compileSpec("C(A(I))");
+        assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR);
+        recompileSpec("C(Ac1(Id0))", "A", "I");
+        assertLinkage("C", "A1", "A1");
+    }
+
+    /*
+     * C(Id1(J)) -> C(Id1(Jd0))
+     *
+     * 0*: Inherited default from J
+     * 1: Inherited default from I
+     */
+    public void test9() throws IOException, ReflectiveOperationException {
+        compileSpec("C(Id1(J))");
+        assertLinkage("C", LINKAGE_ERROR, "I1");
+        recompileSpec("C(Id1(Jd0))", "J");
+        assertLinkage("C", "J0", "I1");
+    }
+
+    /*
+     * C(I(Jd0)) -> C(Id1(Jd0))
+     *
+     * 0: Inherited default from I (through bridge)
+     * 1: Inherited default from I
+     */
+    public void test10() throws IOException, ReflectiveOperationException {
+        compileSpec("C(I(Jd0))");
+        assertLinkage("C", "J0", LINKAGE_ERROR);
+        recompileSpec("C(Id1(Jd0))", "I");
+        assertLinkage("C", "I1", "I1");
+    }
+
+    /*
+     * C(I(J)) -> C(Id1(Jd0))
+     *
+     * 0: Inherited default from I (through bridge)
+     * 1: Inherited default from I
+     */
+    public void test11() throws IOException, ReflectiveOperationException {
+        compileSpec("C(I(J))");
+        assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR);
+        recompileSpec("C(Id1(Jd0))", "I", "J");
+        assertLinkage("C", "I1", "I1");
+    }
+
+    /*
+     * Cc2(B(Ac0)) -> Cc2(Bc1(Ac0))
+     *
+     * 0: Declared in C (through bridge)
+     * 1*: Inherited from B
+     * 2: Declared in C
+     */
+    public void test12() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(B(Ac0))");
+        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
+        recompileSpec("Cc2(Bc1(Ac0))", "B");
+        assertLinkage("C", "C2", "B1", "C2");
+    }
+
+    /*
+     * Cc2(B(Aa0)) -> Cc2(Bc1(Aa0))
+     *
+     * 0: Bridge in C (through bridge)
+     * 1*: Inherited from B
+     * 2: Declared in C
+     */
+    public void test13() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(B(Aa0))");
+        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
+        recompileSpec("Cc2(Bc1(Aa0))", "B");
+        assertLinkage("C", "C2", "B1", "C2");
+    }
+
+    /*
+     * Cc2(Bc1(A)) -> Cc2(Bc1(Ac0))
+     *
+     * 0*: Inherited from A
+     * 1: Declared in C (through bridge)
+     * 2: Declared in C
+     */
+    public void test14() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(Bc1(A))");
+        assertLinkage("C", LINKAGE_ERROR, "C2", "C2");
+        recompileSpec("Cc2(Bc1(Ac0))", "A");
+        assertLinkage("C", "A0", "C2", "C2");
+    }
+
+    /*
+     * Cc2(Ba1(A)) -> Cc2(Ba1(Ac0))
+     *
+     * 0*: Inherited from A
+     * 1: Declared in C (through bridge)
+     * 2: Declared in C
+     */
+    public void test15() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(Ba1(A))");
+        assertLinkage("C", LINKAGE_ERROR, "C2", "C2");
+        recompileSpec("Cc2(Ba1(Ac0))", "A");
+        assertLinkage("C", "A0", "C2", "C2");
+    }
+
+    /*
+     * Cc2(B(A)) -> Cc2(Bc1(Ac0))
+     *
+     * 0*: Inherited from B (through bridge)
+     * 1*: Inherited from B
+     * 2: Declared in C
+     */
+    public void test16() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(B(A))");
+        assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR, "C2");
+        recompileSpec("Cc2(Bc1(Ac0))", "B", "A");
+        assertLinkage("C", "B1", "B1", "C2");
+    }
+
+    /*
+     * Cc2(A(Id0)) -> Cc2(Ac1(Id0))
+     *
+     * 0: Declared in C (through bridge)
+     * 1*: Inherited from A
+     * 2: Declared in C
+     */
+    public void test17() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(A(Id0))");
+        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
+        recompileSpec("Cc2(Ac1(Id0))", "A");
+        assertLinkage("C", "C2", "A1", "C2");
+    }
+
+    /*
+     * Cc2(A(Ia0)) -> Cc2(Ac1(Ia0))
+     *
+     * 0: Declared in C (through bridge)
+     * 1*: Inherited from A
+     * 2: Declared in C
+     */
+    public void test18() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(A(Ia0))");
+        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
+        recompileSpec("Cc2(Ac1(Ia0))", "A");
+        assertLinkage("C", "C2", "A1", "C2");
+    }
+
+    /*
+     * Cc2(Ac1(I)) -> Cc2(Ac1(Id0))
+     *
+     * 0*: Inherited from I
+     * 1: Declared in C (through bridge)
+     * 2: Declared in C
+     */
+    public void test19() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(Ac1(I))");
+        assertLinkage("C", LINKAGE_ERROR, "C2", "C2");
+        recompileSpec("Cc2(Ac1(Id0))", "I");
+        assertLinkage("C", "I0", "C2", "C2");
+    }
+
+    /*
+     * Cc2(Aa1(I)) -> Cc2(Aa1(Id0))
+     *
+     * 0*: Inherited from I
+     * 1: Declared in C (through bridge)
+     * 2: Declared in C
+     */
+    public void test20() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(Aa1(I))");
+        assertLinkage("C", LINKAGE_ERROR, "C2", "C2");
+        recompileSpec("Cc2(Aa1(Id0))", "I");
+        assertLinkage("C", "I0", "C2", "C2");
+    }
+
+    /*
+     * Cc2(A(I)) -> Cc2(Ac1(Id0))
+     *
+     * 0*: Inherited from A (through bridge)
+     * 1*: Inherited from A
+     * 2: Declared in C
+     */
+    public void test21() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(A(I))");
+        assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR, "C2");
+        recompileSpec("Cc2(Ac1(Id0))", "A", "I");
+        assertLinkage("C", "A1", "A1", "C2");
+    }
+
+    /*
+     * Cc2(J(Id0)) -> Cc2(Jd1(Id0))
+     *
+     * 0: Declared in C (through bridge)
+     * 1*: Inherited default from J
+     * 2: Declared in C
+     */
+    public void test22() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(J(Id0))");
+        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
+        recompileSpec("Cc2(Jd1(Id0))", "J");
+        assertLinkage("C", "C2", "J1", "C2");
+    }
+
+    /*
+     * Cc2(J(Ia0)) -> Cc2(Jd1(Ia0))
+     *
+     * 0: Declared in C (through bridge)
+     * 1*: Inherited default from J
+     * 2: Declared in C
+     */
+    public void test23() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(J(Ia0))");
+        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
+        recompileSpec("Cc2(Jd1(Ia0))", "J");
+        assertLinkage("C", "C2", "J1", "C2");
+    }
+
+    /*
+     * Cc2(Jd1(I)) -> Cc2(Jd1(Id0))
+     *
+     * 0*: Inherited default from I
+     * 1: Declared in C (through bridge)
+     * 2: Declared in C
+     */
+    public void test24() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(Jd1(I))");
+        assertLinkage("C", LINKAGE_ERROR, "C2", "C2");
+        recompileSpec("Cc2(Jd1(Id0))", "I");
+        assertLinkage("C", "I0", "C2", "C2");
+    }
+
+    /*
+     * Cc2(Ja1(I)) -> Cc2(Ja1(Id0))
+     *
+     * 0*: Inherited default from I
+     * 1: Declared in C (through bridge)
+     * 2: Declared in C
+     */
+    public void test25() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(Ja1(I))");
+        assertLinkage("C", LINKAGE_ERROR, "C2", "C2");
+        recompileSpec("Cc2(Ja1(Id0))", "I");
+        assertLinkage("C", "I0", "C2", "C2");
+    }
+
+    /*
+     * Cc2(J(I)) -> Cc2(Jd1(Id0))
+     *
+     * 0*: Inherited default from J (through bridge)
+     * 1*: Inherited default from J
+     * 2: Declared in C
+     */
+    public void test26() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(J(I))");
+        assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR, "C2");
+        recompileSpec("Cc2(Jd1(Id0))", "J", "I");
+        assertLinkage("C", "J1", "J1", "C2");
+    }
+
+    /*
+     * C(Ac1, I) -> C(Ac1, Id0)
+     *
+     * 0*: Inherited default from I
+     * 1: Inherited from A
+     */
+    public void test27() throws IOException, ReflectiveOperationException {
+        compileSpec("C(Ac1,I)");
+        assertLinkage("C", LINKAGE_ERROR, "A1");
+        recompileSpec("C(Ac1,Id0)", "I");
+        assertLinkage("C", "I0", "A1");
+    }
+
+    /*
+     * C(A, Id0) -> C(Ac1, Id0)
+     *
+     * 0*: Inherited default from I
+     * 1: Inherited from A
+     */
+    public void test28() throws IOException, ReflectiveOperationException {
+        compileSpec("C(A,Id0)");
+        assertLinkage("C", "I0", LINKAGE_ERROR);
+        recompileSpec("C(Ac1,Id0)", "A");
+        assertLinkage("C", "I0", "A1");
+    }
+
+    /*
+     * C(A, I) -> C(Ac1, Id0)
+     *
+     * 0*: Inherited default from I
+     * 1: Inherited from A
+     */
+    public void test29() throws IOException, ReflectiveOperationException {
+        compileSpec("C(A,I)");
+        assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR);
+        recompileSpec("C(Ac1,Id0)", "A", "I");
+        assertLinkage("C", "I0", "A1");
+    }
+
+    /*
+     * Cc2(Ac1, I) -> Cc2(Ac1, Id0)
+     *
+     * 0*: Inherited default from I
+     * 1: Declared in C (through bridge)
+     * 2: Declared in C
+     */
+    public void test30() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(Ac1,I)");
+        assertLinkage("C", LINKAGE_ERROR, "C2", "C2");
+        recompileSpec("Cc2(Ac1,Id0)", "I");
+        assertLinkage("C", "I0", "C2", "C2");
+    }
+
+    /*
+     * Cc2(Aa1, I) -> Cc2(Aa1, Id0)
+     *
+     * 0*: Inherited default from I
+     * 1: Declared in C (through bridge)
+     * 2: Declared in C
+     */
+    public void test31() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(Aa1,I)");
+        assertLinkage("C", LINKAGE_ERROR, "C2", "C2");
+        recompileSpec("Cc2(Aa1,Id0)", "I");
+        assertLinkage("C", "I0", "C2", "C2");
+    }
+
+    /*
+     * Cc2(A, Id0) -> Cc2(Ac1, Id0)
+     *
+     * 0: Declared in C (through bridge)
+     * 1*: Inherited from A
+     * 2: Declared in C
+     */
+    public void test32() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(A,Id0)");
+        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
+        recompileSpec("Cc2(Ac1,Id0)", "A");
+        assertLinkage("C", "C2", "A1", "C2");
+    }
+
+    /*
+     * Cc2(A, Ia0) -> Cc2(Ac1, Ia0)
+     *
+     * 0: Declared in C (through bridge)
+     * 1*: Inherited from A
+     * 2: Declared in C
+     */
+    public void test33() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(A,Ia0)");
+        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
+        recompileSpec("Cc2(Ac1,Ia0)", "A");
+        assertLinkage("C", "C2", "A1", "C2");
+    }
+
+    /*
+     * Cc2(A, I) -> Cc2(Ac1, Id0)
+     *
+     * 0*: Inherited from A
+     * 1*: Inherited default from I
+     * 2: Declared in C
+     */
+    public void test34() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(A,I)");
+        assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR, "C2");
+        recompileSpec("Cc2(Ac1,Id0)", "A", "I");
+        assertLinkage("C", "I0", "A1", "C2");
+    }
+
+    /*
+     * Cc2(Id0, J) -> Cc2(Id0, Jd1)
+     *
+     * 0: Declared in C (through bridge)
+     * 1*: Inherited default from J
+     * 2: Declared in C
+     */
+    public void test35() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(Id0,J)");
+        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
+        recompileSpec("Cc2(Id0,Jd1)", "J");
+        assertLinkage("C", "C2", "J1", "C2");
+    }
+
+    /*
+     * Cc2(Ia0, J) -> Cc2(Ia0, Jd1)
+     *
+     * 0: Declared in C (through bridge)
+     * 1*: Inherited default from J
+     * 2: Declared in C
+     */
+    public void test36() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(Ia0,J)");
+        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
+        recompileSpec("Cc2(Ia0,Jd1)", "J");
+        assertLinkage("C", "C2", "J1", "C2");
+    }
+
+    /*
+     * Cc2(I, J) -> Cc2(Id0, Jd1)
+     *
+     * 0*: Inherited default from I
+     * 1*: Inherited default from J
+     * 2: Declared in C
+     */
+    public void test37() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(I,J)");
+        assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR, "C2");
+        recompileSpec("Cc2(Id0,Jd1)", "I", "J");
+        assertLinkage("C", "I0", "J1", "C2");
+    }
+
+    /*
+     * C(A(Id0), J(Id0)) -> C(Ac1(Id0), J(Id0))
+     *
+     * 0: Inherited default from I
+     * 0*: Inherited from A (through bridge)
+     * 1*: Inherited from A
+     */
+    public void test38() throws IOException, ReflectiveOperationException {
+        compileSpec("C(A(Id0),J(Id0))");
+        assertLinkage("C", "I0", LINKAGE_ERROR);
+        recompileSpec("C(Ac1(Id0),J(Id0))", "A");
+        assertLinkage("C", "A1", "A1");
+    }
+
+    /*
+     * C(A(Id0), J(Id0)) -> C(A(Id0), Jd1(Id0))
+     *
+     * 0: Inherited default from I
+     * 0: Inherited default from J (through bridge)
+     * 1*: Inherited default from J
+     */
+    public void test39() throws IOException, ReflectiveOperationException {
+        compileSpec("C(A(Id0),J(Id0))");
+        assertLinkage("C", "I0", LINKAGE_ERROR);
+        recompileSpec("C(A(Id0),Jd1(Id0))", "J");
+        assertLinkage("C", "J1", "J1");
+    }
+
+    /*
+     * C(A(Id0), J(Id0)) -> C(Ac2(Id0), Jd1(Id0))
+     *
+     * 0: Inherited default from I
+     * 0*: Inherited from A (new bridge in A beats new bridge in J)
+     * 1*: Inherited default from J
+     * 2: Inherited from A
+     */
+    public void test40() throws IOException, ReflectiveOperationException {
+        compileSpec("C(A(Id0),J(Id0))");
+        assertLinkage("C", "I0", LINKAGE_ERROR);
+        recompileSpec("C(Ac2(Id0),Jd1(Id0))", "A", "J");
+        assertLinkage("C", "A2", "J1", "A2");
+    }
+
+    /*
+     * C(J(Id0), K(Id0)) -> C(Jd1(Id0), K(Id0))
+     *
+     * 0: Inherited from I
+     * 0*: Inherited default from J (through bridge)
+     * 1: Inherited default from J
+     */
+    public void test41() throws IOException, ReflectiveOperationException {
+        compileSpec("C(J(Id0),K(Id0))");
+        assertLinkage("C", "I0", LINKAGE_ERROR);
+        recompileSpec("C(Jd1(Id0),K(Id0))", "J");
+        assertLinkage("C", "J1", "J1");
+    }
+
+    /*
+     * C(Ac2(Id0), J(Id0)) -> C(Ac2(Id0), Jd1(Id0))
+     *
+     * 0: Inherited from A (bridge in A beats new bridge in J)
+     * 1*: Inherited default from J
+     * 2: Inherited from A
+     */
+    public void test42() throws IOException, ReflectiveOperationException {
+        compileSpec("C(Ac2(Id0),J(Id0))");
+        assertLinkage("C", "A2", LINKAGE_ERROR, "A2");
+        recompileSpec("C(Ac2(Id0),Jd1(Id0))", "J");
+        assertLinkage("C", "A2", "J1", "A2");
+    }
+
+    /*
+     * C(Ac2(Ia0), J(Ia0)) -> C(Ac2(Ia0), Jd1(Ia0))
+     *
+     * 0: Inherited from A (bridge in A beats new bridge in J)
+     * 1*: Inherited default from J
+     * 2: Inherited from A
+     */
+    public void test43() throws IOException, ReflectiveOperationException {
+        compileSpec("C(Ac2(Ia0),J(Ia0))");
+        assertLinkage("C", "A2", LINKAGE_ERROR, "A2");
+        recompileSpec("C(Ac2(Ia0),Jd1(Ia0))", "J");
+        assertLinkage("C", "A2", "J1", "A2");
+    }
+
+    /*
+     * C(A(Id0), Jd1(Id0)) -> C(Ac2(Id0), Jd1(Id0))
+     *
+     * 0: Inherited from J
+     * 0*: Inherited from A (new bridge in A beats bridge in J)
+     * 1: Inherited default from J
+     * 2*: Inherited from A
+     */
+    public void test44() throws IOException, ReflectiveOperationException {
+        compileSpec("C(A(Id0),Jd1(Id0))");
+        assertLinkage("C", "J1", "J1", LINKAGE_ERROR);
+        recompileSpec("C(Ac2(Id0),Jd1(Id0))", "A");
+        assertLinkage("C", "A2", "J1", "A2");
+    }
+
+    /*
+     * C(A(Ia0), Jd1(Ia0)) -> C(Ac2(Ia0), Jd1(Ia0))
+     *
+     * 0: Inherited from J
+     * 0*: Inherited from A (new bridge in A beats bridge in J)
+     * 1: Inherited default from J
+     * 2*: Inherited from A
+     */
+    public void test45() throws IOException, ReflectiveOperationException {
+        compileSpec("C(A(Ia0),Jd1(Ia0))");
+        assertLinkage("C", "J1", "J1", LINKAGE_ERROR);
+        recompileSpec("C(Ac2(Ia0),Jd1(Ia0))", "A");
+        assertLinkage("C", "A2", "J1", "A2");
+    }
+
+    /*
+     * Cc2(A(Id0), J(Id0)) -> Cc2(Ac1(Id0), J(Id0))
+     *
+     * 0: Declared in C (through bridge)
+     * 1*: Inherited from A
+     * 2: Declared in C
+     */
+    public void test46() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(A(Id0),J(Id0))");
+        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
+        recompileSpec("Cc2(Ac1(Id0),J(Id0))", "A");
+        assertLinkage("C", "C2", "A1", "C2");
+    }
+
+    /*
+     * Cc2(A(Ia0), J(Ia0)) -> Cc2(Ac1(Ia0), J(Ia0))
+     *
+     * 0: Declared in C (through bridge)
+     * 1*: Inherited from A
+     * 2: Declared in C
+     */
+    public void test47() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(A(Ia0),J(Ia0))");
+        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
+        recompileSpec("Cc2(Ac1(Ia0),J(Ia0))", "A");
+        assertLinkage("C", "C2", "A1", "C2");
+    }
+
+    /*
+     * Cc2(A(Id0), J(Id0)) -> Cc2(A(Id0), Jd1(Id0))
+     *
+     * 0: Declared in C (through bridge)
+     * 1*: Inherited default from J
+     * 2: Declared in C
+     */
+    public void test48() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(A(Id0),J(Id0))");
+        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
+        recompileSpec("Cc2(A(Id0),Jd1(Id0))", "J");
+        assertLinkage("C", "C2", "J1", "C2");
+    }
+
+    /*
+     * Cc2(A(Ia0), J(Ia0)) -> Cc2(A(Ia0), Jd1(Ia0))
+     *
+     * 0: Declared in C (through bridge)
+     * 1*: Inherited default from J
+     * 2: Declared in C
+     */
+    public void test49() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(A(Ia0),J(Ia0))");
+        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
+        recompileSpec("Cc2(A(Ia0),Jd1(Ia0))", "J");
+        assertLinkage("C", "C2", "J1", "C2");
+    }
+
+
+    /*
+     * Cc3(A(Id0), J(Id0)) -> Cc3(Ac1(Id0), Jd2(Id0))
+     *
+     * 0: Bridge in C
+     * 1*: Inherited from A
+     * 2*: Inherited default from J
+     * 3: Declared in C
+     */
+    public void test50() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc3(A(Id0),J(Id0))");
+        assertLinkage("C", "C3", LINKAGE_ERROR, LINKAGE_ERROR, "C3");
+        recompileSpec("Cc3(Ac1(Id0),Jd2(Id0))", "A", "J");
+        assertLinkage("C", "C3", "A1", "J2", "C3");
+    }
+
+    /*
+     * Cc3(A(Ia0), J(Ia0)) -> Cc3(Ac1(Ia0), Jd2(Ia0))
+     *
+     * 0: Bridge in C
+     * 1*: Inherited from A
+     * 2*: Inherited default from J
+     * 3: Declared in C
+     */
+    public void test51() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc3(A(Ia0),J(Ia0))");
+        assertLinkage("C", "C3", LINKAGE_ERROR, LINKAGE_ERROR, "C3");
+        recompileSpec("Cc3(Ac1(Ia0),Jd2(Ia0))", "A", "J");
+        assertLinkage("C", "C3", "A1", "J2", "C3");
+    }
+
+    /*
+     * Cc2(J(Id0), K(Id0)) -> Cc2(Jd1(Id0), K(Id0))
+     *
+     * 0: Declared in C (through bridge)
+     * 1*: Inherited default from J
+     * 2: Declared in C
+     */
+    public void test52() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(J(Id0),K(Id0))");
+        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
+        recompileSpec("Cc2(Jd1(Id0),K(Id0))", "J");
+        assertLinkage("C", "C2", "J1", "C2");
+    }
+
+    /*
+     * Cc2(J(Ia0), K(Ia0)) -> Cc2(Jd1(Ia0), K(Ia0))
+     *
+     * 0: Declared in C (through bridge)
+     * 1*: Inherited default from J
+     * 2: Declared in C
+     */
+    public void test53() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc2(J(Ia0),K(Ia0))");
+        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
+        recompileSpec("Cc2(Jd1(Ia0),K(Ia0))", "J");
+        assertLinkage("C", "C2", "J1", "C2");
+    }
+
+    /*
+     * Cc3(J(Id0), K(Id0)) -> Cc3(Jd1(Id0), Kd2(Id0))
+     *
+     * 0: Declared in C (through bridge)
+     * 1*: Inherited default from J
+     * 2*: Inherited default from K
+     * 3: Declared in C
+     */
+    public void test54() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc3(J(Id0),K(Id0))");
+        assertLinkage("C", "C3", LINKAGE_ERROR, LINKAGE_ERROR, "C3");
+        recompileSpec("Cc3(Jd1(Id0),Kd2(Id0))", "J", "K");
+        assertLinkage("C", "C3", "J1", "K2", "C3");
+    }
+
+    /*
+     * Cc3(J(Ia0), K(Ia0)) -> Cc3(Jd1(Ia0), Kd2(Ia0))
+     *
+     * 0: Declared in C (through bridge)
+     * 1*: Inherited default from J
+     * 2*: Inherited default from K
+     * 3: Declared in C
+     */
+    public void test55() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc3(J(Ia0),K(Ia0))");
+        assertLinkage("C", "C3", LINKAGE_ERROR, LINKAGE_ERROR, "C3");
+        recompileSpec("Cc3(Jd1(Ia0),Kd2(Ia0))", "J", "K");
+        assertLinkage("C", "C3", "J1", "K2", "C3");
+    }
+
+    /*
+     * Cc3(Ac1(Id0), J(Id0)) -> Cc3(Ac1(Id0), Jd2(Id0))
+     *
+     * 0: Declared in C (through bridge)
+     * 1: Declared in C (through bridge)
+     * 2*: Inherited default from J
+     * 3: Declared in C
+     */
+    public void test56() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc3(Ac1(Id0),J(Id0))");
+        assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3");
+        recompileSpec("Cc3(Ac1(Id0),Jd2(Id0))", "J");
+        assertLinkage("C", "C3", "C3", "J2", "C3");
+    }
+
+    /*
+     * Cc3(Ac1(Ia0), J(Ia0)) -> Cc3(Ac1(Ia0), Jd2(Ia0))
+     *
+     * 0: Declared in C (through bridge)
+     * 1: Declared in C (through bridge)
+     * 2*: Inherited default from J
+     * 3: Declared in C
+     */
+    public void test57() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc3(Ac1(Ia0),J(Ia0))");
+        assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3");
+        recompileSpec("Cc3(Ac1(Ia0),Jd2(Ia0))", "J");
+        assertLinkage("C", "C3", "C3", "J2", "C3");
+    }
+
+    /*
+     * Cc3(Aa1(Id0), J(Id0)) -> Cc3(Aa1(Id0), Jd2(Id0))
+     *
+     * 0: Declared in C (through bridge)
+     * 1: Declared in C (through bridge)
+     * 2*: Inherited default from J
+     * 3: Declared in C
+     */
+    public void test58() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc3(Aa1(Id0),J(Id0))");
+        assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3");
+        recompileSpec("Cc3(Aa1(Id0),Jd2(Id0))", "J");
+        assertLinkage("C", "C3", "C3", "J2", "C3");
+    }
+
+    /*
+     * Cc3(Aa1(Ia0), J(Ia0)) -> Cc3(Aa1(Ia0), Jd2(Ia0))
+     *
+     * 0: Declared in C (through bridge)
+     * 1: Declared in C (through bridge)
+     * 2*: Inherited default from J
+     * 3: Declared in C
+     */
+    public void test59() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc3(Aa1(Ia0),J(Ia0))");
+        assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3");
+        recompileSpec("Cc3(Aa1(Ia0),Jd2(Ia0))", "J");
+        assertLinkage("C", "C3", "C3", "J2", "C3");
+    }
+
+    /*
+     * Cc3(A(Id0), Jd2(Id0)) -> Cc3(Ac1(Id0), Jd2(Id0))
+     *
+     * 0: Declared in C (through bridge)
+     * 1*: Inherited from A
+     * 2: Declared in C (through bridge)
+     * 3: Declared in C
+     */
+    public void test60() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc3(A(Id0),Jd2(Id0))");
+        assertLinkage("C", "C3", LINKAGE_ERROR, "C3", "C3");
+        recompileSpec("Cc3(Ac1(Id0),Jd2(Id0))", "A");
+        assertLinkage("C", "C3", "A1", "C3", "C3");
+    }
+
+    /*
+     * Cc3(A(Im0), Jd2(Ia0)) -> Cc3(Ac1(Im0), Jd2(Ia0))
+     *
+     * 0: Declared in C (through bridge)
+     * 1*: Inherited from A
+     * 2: Declared in C (through bridge)
+     * 3: Declared in C
+     */
+    public void test61() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc3(A(Ia0),Jd2(Ia0))");
+        assertLinkage("C", "C3", LINKAGE_ERROR, "C3", "C3");
+        recompileSpec("Cc3(Ac1(Ia0),Jd2(Ia0))", "A");
+        assertLinkage("C", "C3", "A1", "C3", "C3");
+    }
+
+    /*
+     * Cc3(A(Im0), Ja2(Id0)) -> Cc3(Ac1(Id0), Ja2(Id0))
+     *
+     * 0: Declared in C (through bridge)
+     * 1*: Inherited from A
+     * 2: Declared in C (through bridge)
+     * 3: Declared in C
+     */
+    public void test62() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc3(A(Id0),Ja2(Id0))");
+        assertLinkage("C", "C3", LINKAGE_ERROR, "C3", "C3");
+        recompileSpec("Cc3(Ac1(Id0),Ja2(Id0))", "A");
+        assertLinkage("C", "C3", "A1", "C3", "C3");
+    }
+
+    /*
+     * Cc3(A(Im0), Ja2(Ia0)) -> Cc3(Ac1(Ia0), Ja2(Ia0))
+     *
+     * 0: Declared in C (through bridge)
+     * 1*: Inherited from A
+     * 2: Declared in C (through bridge)
+     * 3: Declared in C
+     */
+    public void test63() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc3(A(Ia0),Ja2(Ia0))");
+        assertLinkage("C", "C3", LINKAGE_ERROR, "C3", "C3");
+        recompileSpec("Cc3(Ac1(Ia0),Ja2(Ia0))", "A");
+        assertLinkage("C", "C3", "A1", "C3", "C3");
+    }
+
+    /*
+     * Cc3(Jd1(Id0), K(Id0)) -> Cc3(Jd1(Id0), Kd2(Id0))
+     *
+     * 0: Declared in C (through bridge)
+     * 1: Declared in C (through bridge)
+     * 2*: Inherited default from K
+     * 3: Declared in C
+     */
+    public void test64() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc3(Jd1(Id0),K(Id0))");
+        assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3");
+        recompileSpec("Cc3(Jd1(Id0),Kd2(Id0))", "K");
+        assertLinkage("C", "C3", "C3", "K2", "C3");
+    }
+
+    /*
+     * Cc3(Jd1(Ia0), K(Ia0)) -> Cc3(Jd1(Ia0), Kd2(Ia0))
+     *
+     * 0: Declared in C (through bridge)
+     * 1: Declared in C (through bridge)
+     * 2*: Inherited default from K
+     * 3: Declared in C
+     */
+    public void test65() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc3(Jd1(Ia0),K(Ia0))");
+        assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3");
+        recompileSpec("Cc3(Jd1(Ia0),Kd2(Ia0))", "K");
+        assertLinkage("C", "C3", "C3", "K2", "C3");
+    }
+
+    /*
+     * Cc3(Ja1(Id0), K(Id0)) -> Cc3(Ja1(Id0), Kd2(Id0))
+     *
+     * 0: Declared in C (through bridge)
+     * 1: Declared in C (through bridge)
+     * 2*: Inherited default from K
+     * 3: Declared in C
+     */
+    public void test66() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc3(Jd1(Id0),K(Id0))");
+        assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3");
+        recompileSpec("Cc3(Jd1(Id0),Kd2(Id0))", "K");
+        assertLinkage("C", "C3", "C3", "K2", "C3");
+    }
+
+    /*
+     * Cc3(Ja1(Ia0), K(Ia0)) -> Cc3(Ja1(Ia0), Kd2(Ia0))
+     *
+     * 0: Declared in C (through bridge)
+     * 1: Declared in C (through bridge)
+     * 2*: Inherited default from K
+     * 3: Declared in C
+     */
+    public void test67() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc3(Jd1(Ia0),K(Ia0))");
+        assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3");
+        recompileSpec("Cc3(Jd1(Ia0),Kd2(Ia0))", "K");
+        assertLinkage("C", "C3", "C3", "K2", "C3");
+    }
+
+    // Dan's set A
+    public void testA1() throws IOException, ReflectiveOperationException {
+        compileSpec("C(Id0)");
+        assertLinkage("C", "I0");
+    }
+
+    public void testA2() throws IOException, ReflectiveOperationException {
+        compileSpec("C(A(Id0))");
+        assertLinkage("C", "I0");
+    }
+
+    public void testA3() throws IOException, ReflectiveOperationException {
+        compileSpec("C(A(Id0),J)");
+        assertLinkage("C", "I0");
+    }
+
+    public void testA4() throws IOException, ReflectiveOperationException {
+        compileSpec("D(C(Id0),Jd0(Id0))");
+        assertLinkage("D", "J0");
+        assertLinkage("C", "I0");
+    }
+    /* Doesn't compile
+    public void testA5() throws IOException, ReflectiveOperationException {
+        compileSpec("C(A(Id0),Jd0)");
+        assertLinkage("C", "J0");
+        assertLinkage("A", "I0");
+    }
+    */
+    /* Doesn't compile
+    public void testA6() throws IOException, ReflectiveOperationException {
+        compileSpec("C(A(Id0,Jd0))");
+        assertLinkage("C", "J0");
+        assertLinkage("A", "I0");
+    }
+    */
+    /* Doesn't compile
+    public void testA7() throws IOException, ReflectiveOperationException {
+        compileSpec("C(A(I0,Jd0))");
+        assertLinkage("C", "J0");
+        assertLinkage("A", "I0");
+    }
+    */
+    public void testA8() throws IOException, ReflectiveOperationException {
+        compileSpec("C(Ac0(Id0))");
+        assertLinkage("C", "A0");
+    }
+
+    /* Doesn't compile
+    public void testA9() throws IOException, ReflectiveOperationException {
+        compileSpec("C(Ac0,Id0)");
+        assertLinkage("C", "A0");
+    }
+    */
+
+    // Dan's set B
+
+    /* B1 can't be done, needs a second concrete class D
+    public void testB1() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc1(Dc0)");
+        assertLinkage("C", "C1", "C1");
+        assertLinkage("D", "A0", LINKAGE_ERROR);
+    }
+    */
+
+    public void testB2() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc1(Ac0)");
+        assertLinkage("C", "C1", "C1");
+    }
+
+    //??? B3 seems to suggest that we should create an abstract class
+    //public void testB3() throws IOException, ReflectiveOperationException {
+    //    compileSpec("Ba1(Cc0)");
+    //    assertLinkage("B", "C0", "A1");
+    //}
+
+    // B4 needs too many classes
+
+    public void testB5() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc1(Aa1(Id0))");
+        assertLinkage("C", "C1", "C1");
+    }
+
+    public void testB6() throws IOException, ReflectiveOperationException {
+        compileSpec("C(Ac1(Id0))");
+        assertLinkage("C", "A1", "A1");
+    }
+
+    public void testB7() throws IOException, ReflectiveOperationException {
+        compileSpec("Cc1(Id0)");
+        assertLinkage("C", "C1", "C1");
+    }
+
+    public void testB8() throws IOException, ReflectiveOperationException {
+        compileSpec("C(Jd1(Id0))");
+        assertLinkage("C", "J1", "J1");
+    }
+
+    // B9 needs too many classes
+
+    // The rest of Dan's tests need generics
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/combo/ComboTestBase.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,273 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.combo;
+
+import com.sun.tools.javac.util.Pair;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.Test;
+
+import java.io.*;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.*;
+
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+/**
+ * ComboTestBase
+ *
+ * @author Brian Goetz
+ */
+public abstract class ComboTestBase<T extends ComboTestBase<T>> extends JavacTemplateTestBase {
+    private final static Map<Class, ComboTestMetadata> metadataMap = new HashMap<>();
+    private final static boolean DEBUG_PROPERTY_SET = !System.getProperty("combo.debug", "").equals("");
+    private final static long timestamp = System.currentTimeMillis();
+    private final static Map</* filename */ String,
+                             Map</* combo vars */ Map<String, String>, /* data */ Map<String, String>>> debugInfo
+            = new HashMap<>();
+
+    protected final ComboTestMetadata<T> metadata;
+    protected final Object[] comboArgs;
+    private boolean debugOnly = false;
+
+    // This class cannot have a constructor; it interferes with testng's ability to find the factory method
+    //in subclasses.  Anything that would be done by a constructor should insteady be done by init blocks
+    //or the pseudoConstructor() method.
+
+    /* init */ {
+        metadata = getMetadata((Class<T>) getClass());
+        comboArgs = new Object[metadata.dimensions.length];
+    }
+
+    /**
+     * This method is meant to be called from an @Factory method in the subclass, passing its own class literal
+     * as the clazz argument.  It will introspect over the provided class, find the dimension variables, and
+     * generate the combinatorial explosion of test cases.  (It consults shouldSkip() to determine if a particular
+     * combination should be skipped.)
+     */
+    public static<T extends ComboTestBase> Object[] factory(Class<T> clazz) throws ReflectiveOperationException {
+        int index = 0;
+        try {
+            ComboTestMetadata<T> md = getMetadata(clazz);
+            List<T> list = new ArrayList<>();
+            for (Object[] args : md.makeLoop()) {
+                T instance = md.makeInstance(args);
+                if (!instance.shouldSkip()) {
+                    instance.pseudoConstructor(args);
+                    list.add(instance);
+                    instance.templates.put("__INDEX__", instance.new StringTemplate(Integer.toString(index++)));
+                    if (DEBUG_PROPERTY_SET)
+                        ((ComboTestBase) instance).debugOnly = true;
+                }
+            }
+
+            return list.toArray();
+        } catch (Throwable t) {
+            // This is a needed annoyance; TestNG swallows exception data from exceptions thrown from @Factory methods
+            t.printStackTrace(System.err);
+            t.printStackTrace(System.out);
+            throw t;
+        }
+    }
+
+    /** For debugging of test cases -- sets tests into debug-only mode, where we print out the instantiations of
+     * the dimension variables and the templates.
+     */
+    public static<T extends ComboTestBase> Object[] debugFactory(Class<T> clazz) throws ReflectiveOperationException {
+        Object[] results = factory(clazz);
+        for (Object o : results)
+            ((ComboTestBase) o).debugOnly = true;
+        return results;
+    }
+
+    private static<T extends ComboTestBase<T>> ComboTestMetadata<T> getMetadata(Class<T> clazz) {
+        try {
+            ComboTestMetadata<T> md = metadataMap.get(clazz);
+            if (md == null) {
+                md = new ComboTestMetadata<T>(clazz);
+                metadataMap.put(clazz, md);
+            }
+            return md;
+        } catch (ReflectiveOperationException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    // Should be private, but can't be
+    void pseudoConstructor(Object[] args) throws ReflectiveOperationException {
+        System.arraycopy(args, 0, comboArgs, 0, args.length);
+    }
+
+    private void addTemplates() throws ReflectiveOperationException {
+        for (int i=0; i<comboArgs.length; i++)
+            addTemplate(metadata.dimensions[i].name, asTemplate(comboArgs[i]));
+
+        for (ComboTestMetadata.TemplateMember<TemplateVar, Field> m : metadata.templateFields)
+            addTemplate(m.name, asTemplate(m.member.get(this)));
+
+        for (ComboTestMetadata.TemplateMember<TemplateVar, Method> m : metadata.templateMethods)
+            addTemplate(m.name, asTemplate(m.member.invoke(this)));
+    }
+
+    private void addAllSourceFiles() throws ReflectiveOperationException {
+        for (ComboTestMetadata.TemplateMember<SourceFile, Field> m : metadata.sourceFields)
+            addSourceFile(m.name, asTemplate(m.member.get(this)));
+
+        for (ComboTestMetadata.TemplateMember<SourceFile, Method> m : metadata.sourceMethods)
+            addSourceFile(m.name, asTemplate(m.member.invoke(this)));
+    }
+
+    private void addSourceFiles(String group) throws ReflectiveOperationException {
+        for (ComboTestMetadata.TemplateMember<SourceFile, Field> m : metadata.sourceFields)
+            if (group.equals(m.annotation.group()))
+                addSourceFile(m.name, asTemplate(m.member.get(this)));
+
+        for (ComboTestMetadata.TemplateMember<SourceFile, Method> m : metadata.sourceMethods)
+            if (group.equals(m.annotation.group()))
+                addSourceFile(m.name, asTemplate(m.member.invoke(this)));
+    }
+
+    /**
+     * Should the current combination of inputs be skipped?  Default implementation returns false for
+     * all combinations (indicating all combinations are valid.)
+     */
+    protected boolean shouldSkip() {
+        return false;
+    }
+
+    protected boolean shouldRun() {
+        return false;
+    }
+
+    /**
+     * Called after test() compiles, allowing subclass an opportunity to examine diagonstics and assert
+     * their properties.  Default implementation calls assertCompileSucceeded().
+     * @param group
+     */
+    protected void postCompile(String group) {
+        assertCompileSucceeded();
+    }
+
+    protected String[] getCompileOptions(String group) {
+        return new String[0];
+    }
+
+    /**
+     * Called before test() compiles, allowing subclass an opportunity to set compilation options.
+     */
+    protected void preCompile(String group) {
+    }
+
+    @Test
+    public void test() throws Exception {
+        if (debugOnly) {
+            addTemplates();
+            addAllSourceFiles();
+            System.out.println("Test case : " + getTestCaseDescription());
+            for (Pair<String, Template> e : sourceFiles)
+                System.out.println("Source file " + e.fst + ": " + e.snd);
+
+            String testFile = getClass().getName();
+            Map<Map<String, String>, Map<String, String>> testCaseMap = debugInfo.get(testFile);
+            if (testCaseMap == null) {
+                testCaseMap = new HashMap<>();
+                debugInfo.put(testFile, testCaseMap);
+            }
+
+            Map<String, String> comboKeys = new HashMap<>();
+            for (int i=0; i<metadata.dimensions.length; i++)
+                comboKeys.put(metadata.dimensions[i].name, comboArgs[i].toString());
+            String compileOptions = Arrays.asList(getCompileOptions("")).toString();
+            Map<String, String> data = new HashMap<>();
+            int count = 0;
+            for (Pair<String, Template> e : sourceFiles) {
+                count++;
+                data.put("File." + count + ".FileName", e.fst);
+                data.put("File." + count + ".Source", e.snd.toString());
+                data.put("File." + count + ".Group", "");
+                data.put("File." + count + ".CompileOptions", compileOptions);
+            }
+            Object prev = testCaseMap.put(comboKeys, data);
+            if (prev != null)
+                fail(String.format("Duplicate key for file %s, keys %s", testFile, comboKeys.toString()));
+        }
+        else {
+            boolean generate = shouldRun();
+            boolean errors = false;
+            List<File> files = new ArrayList<>();
+            List<String> groupsReversed = new ArrayList<>(metadata.groups);
+            Collections.reverse(groupsReversed);
+            for (String g : groupsReversed) {
+                addTemplates();
+                addSourceFiles(g);
+                preCompile(g);
+                addCompileOptions(getCompileOptions(g));
+                for (File f : files)
+                    addClassPath(f);
+                files.add(0, compile(generate));
+                errors |= diags.errorsFound();
+                postCompile(g);
+                reset();
+            }
+
+            if (generate && !errors) {
+                run(loadClass("Main", files.toArray(new File[files.size()])));
+            }
+        }
+    }
+
+    @AfterSuite
+    public void dumpDebug() throws IOException {
+        if (DEBUG_PROPERTY_SET) {
+            for (Map.Entry<String, Map<Map<String, String>, Map<String, String>>> f : debugInfo.entrySet()) {
+                File out = new File(String.format("ComboLog-%s-%d.ser", f.getKey(), timestamp));
+                try (ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(out))) {
+                    os.writeObject(f.getValue());
+                }
+            }
+        }
+    }
+
+    protected void run(Class<?> clazz) throws ReflectiveOperationException {
+        assertTrue(clazz != null);
+    }
+
+    protected String getTestCaseDescription() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("ComboTest[").append(getClass().getName()).append(": ");
+        for (int i=0; i<metadata.dimensions.length; i++)
+            sb.append(metadata.dimensions[i].name).append(" = ").append(comboArgs[i]).append(", ");
+        sb.append("]");
+        return sb.toString();
+    }
+
+    protected boolean skipConstrained(int arity, Enum... enums) {
+        for (int i=arity; i<enums.length; i++)
+            if (enums[i].ordinal() != 0)
+                return true;
+        return false;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/combo/ComboTestDebug.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.combo;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ * ComboTestDebug -- utility program for dumping or comparing combo test debug logs.  Debug logs can be
+ * used for debugging combo tests, as they contain all the generated source files and options (but are
+ * primarily used for testing for regressions in the combo test framework when changes are made to the
+ * framework.)
+ *
+ * @author Brian Goetz
+ */
+public class ComboTestDebug {
+    public static List<String> files = new ArrayList<>();
+    public static boolean compare;
+
+    private static void compareFiles(String s1, String s2) throws IOException, ClassNotFoundException {
+        Map</* combo vars */ Map<String, String>,
+                /* data */ Map<String, String>> f1, f2;
+        try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(s1))) {
+            f1 = (Map<Map<String, String>, Map<String, String>>) ois.readObject();
+        }
+        try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(s2))) {
+            f2 = (Map<Map<String, String>, Map<String, String>>) ois.readObject();
+        }
+
+        if (f1.size() != f2.size())
+            System.out.printf("Number of test cases differ: %d, %d%n", f1.size(), f2.size());
+
+        if (!f1.keySet().equals(f2.keySet())) {
+            System.out.printf("Test cases differ%n");
+            for (Map<String, String> k : f1.keySet()) {
+                if (!f2.containsKey(k))
+                    System.out.printf("Only in file 1: test case %s%n", k);
+            }
+            for (Map<String, String> k : f2.keySet()) {
+                if (!f1.containsKey(k))
+                    System.out.printf("Only in file 2: test case %s%n", k);
+            }
+        }
+
+        for (Map<String, String> k : f1.keySet()) {
+            if (!f2.keySet().contains(k))
+                continue;
+            Map<String, String> d1 = f1.get(k);
+            Map<String, String> d2 = f2.get(k);
+            if (!d1.equals(d2)) {
+                System.out.printf("Test case %s%n", k);
+                for (String s : d1.keySet())
+                    if (!d2.containsKey(s))
+                        System.out.printf("  Only in file 1: key %s%n", s);
+                    else {
+                        if (!d1.get(s).equals(d2.get(s))) {
+                            System.out.printf("  Key values differ for key %s: [%s] [%s]%n", s, d1.get(s), d2.get(s));
+                        }
+                    }
+                for (String s : d2.keySet())
+                    if (!d1.containsKey(s))
+                        System.out.printf("  Only in file 2: key %s%n", s);
+                System.out.println();
+            }
+        }
+    }
+
+    private static void dumpFile(String s) throws IOException, ClassNotFoundException {
+        try (ObjectInputStream ois = new ObjectInputStream(new FileInputStream(s))) {
+            Map</* combo vars */ Map<String, String>,
+                /* data */ Map<String, String>> debugInfo;
+
+            debugInfo = (Map<Map<String, String>, Map<String, String>>) ois.readObject();
+            System.out.printf("%d test cases%n%n", debugInfo.size());
+            for (Map.Entry<Map<String, String>, Map<String, String>> e : debugInfo.entrySet()) {
+                System.out.println("Test case: " + e.getKey());
+                for (Map.Entry<String, String> de : new TreeMap<>(e.getValue()).entrySet())
+                    System.out.printf("  %s = %s%n", de.getKey(), de.getValue());
+                System.out.println();
+            }
+        }
+
+    }
+
+    public static void main(String[] args) throws IOException, ClassNotFoundException {
+        for (String a : args) {
+            if (a.equals("-c"))
+                compare = true;
+            else if (a.startsWith("-"))
+                usage();
+            else
+                files.add(a);
+        }
+
+        if (compare) {
+            if (files.size() != 2)
+                usage();
+            compareFiles(files.get(0), files.get(1));
+        }
+        else {
+            for (String f : files)
+                dumpFile(f);
+        }
+    }
+
+    public static void usage() {
+        System.out.println("Usage: ComboTestDebug [ -c ] files...");
+        System.exit(0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/combo/ComboTestMetadata.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,190 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.combo;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+import java.util.*;
+
+/**
+ * ComboTestMetadata
+ *
+ * @author Brian Goetz*/
+class ComboTestMetadata<T> {
+    public final Class<T> clazz;
+    public final Constructor<T> ctor;
+    public final List<TemplateMember<TemplateVar, Field>> templateFields = new ArrayList<>();
+    public final List<TemplateMember<TemplateVar, Method>> templateMethods = new ArrayList<>();
+    public final List<TemplateMember<SourceFile, Field>> sourceFields = new ArrayList<>();
+    public final List<TemplateMember<SourceFile, Method>> sourceMethods = new ArrayList<>();
+    public final Set<String> groups = new TreeSet<>();
+    public final Dimension[] dimensions;
+
+    public ComboTestMetadata(Class<T> clazz) throws ReflectiveOperationException {
+        this.clazz = clazz;
+        Constructor[] constructors = clazz.getConstructors();
+        ctor = (constructors.length == 1 && constructors[0].getParameterTypes().length > 0) ? constructors[0] : null;
+
+        Map<DimensionVar, Field> tmpDimFields = new LinkedHashMap<>();
+        for (Field f : clazz.getDeclaredFields()) {
+            TemplateVar template = f.getAnnotation(TemplateVar.class);
+            if (template != null) {
+                if (!Template.class.isAssignableFrom(f.getType()) && !String.class.isAssignableFrom(f.getType()))
+                    throw new AssertionError(String.format("Found @TemplateVar on field %s whose type is not Template or String", f));
+                f.setAccessible(true);
+                templateFields.add(new TemplateMember<>(template.value(), template, f));
+            }
+
+            SourceFile source = f.getAnnotation(SourceFile.class);
+            if (source != null) {
+                if (!Template.class.isAssignableFrom(f.getType()) && !String.class.isAssignableFrom(f.getType()))
+                    throw new AssertionError(String.format("Found @SourceFile on field %s whose type is not Template or String", f));
+                f.setAccessible(true);
+                sourceFields.add(new TemplateMember<>(source.value(), source, f));
+                groups.add(source.group());
+            }
+            
+            DimensionVar dim = f.getAnnotation(DimensionVar.class);
+            if (dim != null) 
+                tmpDimFields.put(dim, f);
+        }
+
+        for (Method m : clazz.getDeclaredMethods()) {
+            TemplateVar template = m.getAnnotation(TemplateVar.class);
+            if (template != null) {
+                if (!Template.class.isAssignableFrom(m.getReturnType()) && !String.class.isAssignableFrom(m.getReturnType()))
+                    throw new AssertionError(String.format("Found @TemplateVar on method %s whose return type is not Template or String", m));
+                m.setAccessible(true);
+                templateMethods.add(new TemplateMember<>(template.value(), template, m));
+            }
+
+            SourceFile source = m.getAnnotation(SourceFile.class);
+            if (source != null) {
+                if (!Template.class.isAssignableFrom(m.getReturnType()) && !String.class.isAssignableFrom(m.getReturnType()))
+                    throw new AssertionError(String.format("Found @SourceFile on method %s whose return type is not Template or String ", m));
+                sourceMethods.add(new TemplateMember<>(source.value(), source, m));
+                groups.add(source.group());
+            }
+        }
+
+        if (constructors.length > 1)
+            throw new AssertionError(String.format("Multiple constructors for class %s", clazz));
+        else if (ctor != null && !tmpDimFields.isEmpty())
+            throw new AssertionError(String.format("Class %s has both constructors and fields with @DimensionVar", clazz));
+        else if (constructors.length == 0 && tmpDimFields.isEmpty())
+            throw new AssertionError(String.format("Class %s has neither constructors nor fields with @DimensionVar", clazz));
+        else if (ctor != null) {
+            Class<?>[] argTypes = ctor.getParameterTypes();
+            Annotation[][] paramAnnotations = ctor.getParameterAnnotations();
+            dimensions = new Dimension[argTypes.length];
+            for (int i = 0, argTypesLength = argTypes.length; i < argTypesLength; i++) {
+                DimensionVar cd = null;
+                for (Annotation a : paramAnnotations[i])
+                    if (a instanceof DimensionVar) {
+                        cd = (DimensionVar) a;
+                        break;
+                    }
+                if (cd == null)
+                    throw new AssertionError(String.format("Parameter %d of constructor %s does not have @DimensionVar annotation", i, ctor));
+                dimensions[i] = new Dimension(cd, argTypes[i], String.format("Parameter %d of constructor %s", i, ctor));
+            }
+        }
+        else {
+            dimensions = new Dimension[tmpDimFields.size()];
+            int i = 0;
+            for (Map.Entry<DimensionVar, Field> e : tmpDimFields.entrySet())
+                dimensions[i++] = new Dimension(e.getKey(), e.getValue());
+        }
+    }
+
+    public T makeInstance(Object[] args) throws ReflectiveOperationException {
+        if (ctor != null)
+            return ctor.newInstance(args);
+        else {
+            T t = clazz.newInstance();
+            for (int i=0; i< dimensions.length; i++)
+                dimensions[i].field.set(t, args[i]);
+            return t;
+        }
+    }
+
+    public SyntheticLoop makeLoop() {
+        int n = dimensions.length;
+        Object[][] dimValues = new Object[n][];
+        for (int i=0; i<n; i++)
+            dimValues[i] = dimensions[i].values;
+        return new SyntheticLoop(dimValues);
+    }
+
+    static class Dimension {
+        public final Object[] values;
+        public final String name;
+        public final Field field;
+
+        public Dimension(DimensionVar dv, Field f) throws ReflectiveOperationException {
+            field = f;
+            field.setAccessible(true);
+            name = dv.value();
+            values = getValues(dv, f.getType(), String.format("Field %s", f.getName()));
+        }
+
+        public Dimension(DimensionVar dv, Class<?> paramType, String descr) throws ReflectiveOperationException {
+            field = null;
+            name = dv.value();
+            values = getValues(dv, paramType, descr);
+        }
+
+        private Object[] getValues(DimensionVar dv, Class<?> clazz, String descr) throws ReflectiveOperationException {
+            if (Enum.class.isAssignableFrom(clazz) && Template.class.isAssignableFrom(clazz)) {
+                Method m = clazz.getDeclaredMethod("values");
+                m.setAccessible(true);
+                return (Template[]) m.invoke(null);
+            }
+            else if (int.class.isAssignableFrom(clazz)) {
+                Object[] ts = new Object[dv.rangeUpper() - dv.rangeLower() + 1];
+                for (int i=dv.rangeLower(); i <= dv.rangeUpper(); i++)
+                    ts[i-dv.rangeLower()] = i;
+                return ts;
+            }
+            else
+                throw new AssertionError(String.format("Invalid type %s for %s", clazz.getName(), descr));
+        }
+    }
+
+    static class TemplateMember<A extends Annotation, M extends Member> {
+        public final String name;
+        public final A annotation;
+        public final M member;
+
+        TemplateMember(String name, A annotation, M member) {
+            this.name = name;
+            this.annotation = annotation;
+            this.member = member;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/combo/Diagnostics.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.combo;
+
+import javax.tools.Diagnostic;
+import javax.tools.JavaFileObject;
+import java.util.ArrayList;
+import java.util.List;
+
+import static java.util.stream.Collectors.toList;
+
+/**
+* A container for compiler diagnostics, separated into errors and warnings,
+ * used by JavacTemplateTestBase.
+ *
+ * @author Brian Goetz
+*/
+public class Diagnostics implements javax.tools.DiagnosticListener<JavaFileObject> {
+
+    protected List<Diagnostic<? extends JavaFileObject>> diags = new ArrayList<>();
+    protected boolean foundErrors = false;
+
+    public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+        diags.add(diagnostic);
+        foundErrors = foundErrors || diagnostic.getKind() == Diagnostic.Kind.ERROR;
+    }
+
+    /** Were there any errors found? */
+    public boolean errorsFound() {
+        return foundErrors;
+    }
+
+    /** Get all diagnostic keys */
+    public List<String> keys() {
+        return diags.stream()
+                    .map(Diagnostic::getCode)
+                    .collect(toList());
+    }
+
+    /** Do the diagnostics contain the specified error key? */
+    public boolean containsErrorKey(String key) {
+        return diags.stream()
+                    .filter(d -> d.getKind() == Diagnostic.Kind.ERROR)
+                    .anyMatch(d -> d.getCode().equals(key));
+    }
+
+    /** Get the error keys */
+    public List<String> errorKeys() {
+        return diags.stream()
+                    .filter(d -> d.getKind() == Diagnostic.Kind.ERROR)
+                    .map(Diagnostic::getCode)
+                    .collect(toList());
+    }
+
+    public String toString() { return keys().toString(); }
+
+    /** Clear all diagnostic state */
+    public void reset() {
+        diags.clear();
+        foundErrors = false;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/combo/DimensionVar.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.combo;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+* DimensionVar
+*/
+@Retention(RetentionPolicy.RUNTIME)
+@java.lang.annotation.Target({ElementType.PARAMETER, ElementType.FIELD})
+public @interface DimensionVar {
+    String value();
+    int rangeLower() default 0;
+    int rangeUpper() default 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/combo/JavacTemplateTestBase.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,364 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.combo;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.util.Pair;
+import org.testng.ITestResult;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.fail;
+
+/**
+ * Base class for template-driven TestNG javac tests that support on-the-fly
+ * source file generation, compilation, classloading, execution, and separate
+ * compilation.
+ *
+ * <p>Manages a set of templates (which have embedded tags of the form
+ * {@code #\{NAME\}}), source files (which are also templates), and compile
+ * options.  Test cases can register templates and source files, cause them to
+ * be compiled, validate whether the set of diagnostic messages output by the
+ * compiler is correct, and optionally load and run the compiled classes.
+ *
+ * @author Brian Goetz
+ */
+@Test
+public abstract class JavacTemplateTestBase {
+    private static final Set<String> suiteErrors = Collections.synchronizedSet(new HashSet<>());
+    private static final AtomicInteger counter = new AtomicInteger();
+    private static final File root = new File(System.getProperty("user.dir"), "gen");
+    private static final File nullDir = new File(System.getProperty("user.dir"), "empty");
+
+    protected final Map<String, Template> templates = new HashMap<>();
+    protected final Diagnostics diags = new Diagnostics();
+    protected final List<Pair<String, Template>> sourceFiles = new ArrayList<>();
+    protected final List<String> compileOptions = new ArrayList<>();
+    protected final List<File> classpaths = new ArrayList<>();
+    protected final Template.Resolver defaultResolver = new MapResolver(templates);
+
+    private Template.Resolver currentResolver = defaultResolver;
+
+    /** Add a template with a specified name */
+    protected void addTemplate(String name, Template t) {
+        templates.put(name, t);
+    }
+
+    /** Add a template with a specified name */
+    protected void addTemplate(String name, String s) {
+        templates.put(name, new StringTemplate(s));
+    }
+
+    /** Add a source file */
+    protected void addSourceFile(String name, Template t) {
+        sourceFiles.add(new Pair<>(name, t));
+    }
+
+    /** Add a File to the class path to be used when loading classes; File values
+     * will generally be the result of a previous call to {@link #compile()}.
+     * This enables testing of separate compilation scenarios if the class path
+     * is set up properly.
+     */
+    protected void addClassPath(File path) {
+        classpaths.add(path);
+    }
+
+    /**
+     * Add a set of compilation command-line options
+     */
+    protected void addCompileOptions(String... opts) {
+        Collections.addAll(compileOptions, opts);
+    }
+
+    /** Reset the compile options to the default (empty) value */
+    protected void resetCompileOptions() { compileOptions.clear(); }
+
+    /** Remove all templates */
+    protected void resetTemplates() { templates.clear(); }
+
+    /** Remove accumulated diagnostics */
+    protected void resetDiagnostics() { diags.reset(); }
+
+    /** Remove all source files */
+    protected void resetSourceFiles() { sourceFiles.clear(); }
+
+    /** Remove registered class paths */
+    protected void resetClassPaths() { classpaths.clear(); }
+
+    // Before each test method, reset everything
+    @BeforeMethod
+    public void reset() {
+        resetCompileOptions();
+        resetDiagnostics();
+        resetSourceFiles();
+        resetTemplates();
+        resetClassPaths();
+    }
+
+    // After each test method, if the test failed, capture source files and diagnostics and put them in the log
+    @AfterMethod
+    public void copyErrors(ITestResult result) {
+        if (!result.isSuccess()) {
+            suiteErrors.addAll(diags.errorKeys());
+
+            List<Object> list = new ArrayList<>();
+            Collections.addAll(list, result.getParameters());
+            list.add("Test case: " + getTestCaseDescription());
+            for (Pair<String, Template> e : sourceFiles)
+                list.add("Source file " + e.fst + ": " + e.snd);
+            if (diags.errorsFound())
+                list.add("Compile diagnostics: " + diags.toString());
+            result.setParameters(list.toArray(new Object[list.size()]));
+        }
+    }
+
+    @AfterSuite
+    // After the suite is done, dump any errors to output
+    public void dumpErrors() {
+        if (!suiteErrors.isEmpty())
+            System.err.println("Errors found in test suite: " + suiteErrors);
+    }
+
+    /**
+     * Get a description of this test case; since test cases may be combinatorially
+     * generated, this should include all information needed to describe the test case
+     */
+    protected String getTestCaseDescription() {
+        return this.toString();
+    }
+
+    /** Assert that all previous calls to compile() succeeded */
+    protected void assertCompileSucceeded() {
+        if (diags.errorsFound())
+            fail("Expected successful compilation");
+    }
+
+    /**
+     * If the provided boolean is true, assert all previous compiles succeeded,
+     * otherwise assert that a compile failed.
+     * */
+    protected void assertCompileSucceededIff(boolean b) {
+        if (b)
+            assertCompileSucceeded();
+        else
+            assertCompileFailed();
+    }
+
+    /** Assert that a previous call to compile() failed */
+    protected void assertCompileFailed() {
+        if (!diags.errorsFound())
+            fail("Expected failed compilation");
+    }
+
+    /** Assert that a previous call to compile() failed with a specific error key */
+    protected void assertCompileFailed(String message) {
+        if (!diags.errorsFound())
+            fail("Expected failed compilation: " + message);
+    }
+
+    /** Assert that a previous call to compile() failed with all of the specified error keys */
+    protected void assertCompileErrors(String... keys) {
+        if (!diags.errorsFound())
+            fail("Expected failed compilation");
+        for (String k : keys)
+            if (!diags.containsErrorKey(k))
+                fail("Expected compilation error " + k);
+    }
+
+    /** Convert an object, which may be a Template or a String, into a Template */
+    protected Template asTemplate(Object o) {
+        if (o instanceof Template)
+            return (Template) o;
+        else if (o instanceof String)
+            return new StringTemplate((String) o);
+        else
+            return new StringTemplate(o.toString());
+    }
+
+    /** Compile all registered source files */
+    protected void compile() throws IOException {
+        compile(false);
+    }
+
+    /** Compile all registered source files, optionally generating class files
+     * and returning a File describing the directory to which they were written */
+    protected File compile(boolean generate) throws IOException {
+        List<JavaFileObject> files = new ArrayList<>();
+        for (Pair<String, Template> e : sourceFiles)
+            files.add(new FileAdapter(e.fst, asTemplate(e.snd)));
+        return compile(classpaths, files, generate);
+    }
+
+    /** Compile all registered source files, using the provided list of class paths
+     * for finding required classfiles, optionally generating class files
+     * and returning a File describing the directory to which they were written */
+    protected File compile(List<File> classpaths, boolean generate) throws IOException {
+        List<JavaFileObject> files = new ArrayList<>();
+        for (Pair<String, Template> e : sourceFiles)
+            files.add(new FileAdapter(e.fst, asTemplate(e.snd)));
+        return compile(classpaths, files, generate);
+    }
+
+    private File compile(List<File> classpaths, List<JavaFileObject> files, boolean generate) throws IOException {
+        JavaCompiler systemJavaCompiler = ToolProvider.getSystemJavaCompiler();
+        StandardJavaFileManager fm = systemJavaCompiler.getStandardFileManager(null, null, null);
+        if (classpaths.size() > 0)
+            fm.setLocation(StandardLocation.CLASS_PATH, classpaths);
+        JavacTask ct = (JavacTask) systemJavaCompiler.getTask(null, fm, diags, compileOptions, null, files);
+        if (generate) {
+            File destDir = new File(root, Integer.toString(counter.incrementAndGet()));
+            // @@@ Assert that this directory didn't exist, or start counter at max+1
+            destDir.mkdirs();
+            fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(destDir));
+            ct.generate();
+            return destDir;
+        }
+        else {
+            ct.analyze();
+            return nullDir;
+        }
+    }
+
+    /** Load the given class using the provided list of class paths */
+    protected Class<?> loadClass(String className, File... destDirs) {
+        try {
+            List<URL> list = new ArrayList<>();
+            for (File f : destDirs)
+                list.add(new URL("file:" + f.toString().replace("\\", "/") + "/"));
+            return Class.forName(className, true, new URLClassLoader(list.toArray(new URL[list.size()])));
+        } catch (ClassNotFoundException | MalformedURLException e) {
+            throw new RuntimeException("Error loading class " + className, e);
+        }
+    }
+
+    /** An implementation of Template which is backed by a String */
+    protected class StringTemplate implements Template {
+        protected final String template;
+
+        public StringTemplate(String template) {
+            this.template = template;
+        }
+
+        public String expand(String selector) {
+            return Behavior.expandTemplate(template, currentResolver);
+        }
+
+        public String toString() {
+            return expand("");
+        }
+
+        public StringTemplate with(final String key, final String value) {
+            return new StringTemplateWithResolver(template, new KeyResolver(key, value));
+        }
+
+    }
+
+    /** An implementation of Template which is backed by a String and which
+     * encapsulates a Resolver for resolving embedded tags. */
+    protected class StringTemplateWithResolver extends StringTemplate {
+        private final Resolver localResolver;
+
+        public StringTemplateWithResolver(String template, Resolver localResolver) {
+            super(template);
+            this.localResolver = localResolver;
+        }
+
+        @Override
+        public String expand(String selector) {
+            Resolver saved = currentResolver;
+            currentResolver = new ChainedResolver(currentResolver, localResolver);
+            try {
+                return super.expand(selector);
+            }
+            finally {
+                currentResolver = saved;
+            }
+        }
+
+        @Override
+        public StringTemplate with(String key, String value) {
+            return new StringTemplateWithResolver(template, new ChainedResolver(localResolver, new KeyResolver(key, value)));
+        }
+    }
+
+    /** A Resolver which uses a Map to resolve tags */
+    private class KeyResolver implements Template.Resolver {
+        private final String key;
+        private final String value;
+
+        public KeyResolver(String key, String value) {
+            this.key = key;
+            this.value = value;
+        }
+
+        @Override
+        public Template lookup(String k) {
+            return key.equals(k) ? new StringTemplate(value) : null;
+        }
+    }
+
+    private class FileAdapter extends SimpleJavaFileObject {
+        private final String filename;
+        private final Template template;
+
+        public FileAdapter(String filename, Template template) {
+            super(URI.create("myfo:/" + filename), Kind.SOURCE);
+            this.template = template;
+            this.filename = filename;
+        }
+
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return toString();
+        }
+
+        public String toString() {
+            return Template.Behavior.expandTemplate(template.expand(filename), defaultResolver);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/combo/SeparateCompilationComboTest.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.combo;
+
+import org.testng.annotations.Factory;
+
+import java.lang.reflect.Method;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * SeparateCompilationComboTest
+ */
+public class SeparateCompilationComboTest extends ComboTestBase<SeparateCompilationComboTest> {
+    @Factory
+    public static Object[] testCombo() throws Exception {
+        return factory(SeparateCompilationComboTest.class);
+    }
+
+    @DimensionVar("FOO") Dummy dummy;
+
+    @SourceFile(value="Main.java", group="B") String a2 = "public class Main { public String main() { return Other.b(); } }";
+    @SourceFile(value="Other.java", group="B") String b2 = "public class Other { public static String b() { return \"1\"; } }";
+    @SourceFile(value="Other.java", group="A") String b1 = "public class Other { public static String b() { return \"2\"; } }";
+
+    @Override
+    protected boolean shouldRun() {
+        return true;
+    }
+
+    @Override
+    protected void run(Class<?> clazz) throws ReflectiveOperationException {
+        Object obj = clazz.newInstance();
+        Method m = clazz.getMethod("main");
+        String result = (String) m.invoke(obj);
+        assertEquals("2", result);
+    }
+
+    static enum Dummy implements Template {
+        A();
+
+        public String expand(String selector) { return toString(); }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/combo/SeparateCompilationComboTest2.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.combo;
+
+import org.testng.annotations.Factory;
+
+import java.lang.reflect.Method;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * SeparateCompilationComboTest2
+ */
+public class SeparateCompilationComboTest2 extends ComboTestBase<SeparateCompilationComboTest2> {
+    @Factory
+    public static Object[] testCombo() throws Exception {
+        return factory(SeparateCompilationComboTest2.class);
+    }
+
+    @DimensionVar("FOO") Dummy dummy;
+
+    @SourceFile(value="Main.java", group="A" )
+    String main = "public class Main { public String main() { return new B().x(); } }";
+    @SourceFile(value="B.java", group="B" )
+    String b = "public class B extends C { public String x() { return \"2\"; } }";
+    @SourceFile(value="C.java", group="C" )
+    String c = "public class C { public String x() { return \"1\"; } }";
+
+    @Override
+    protected boolean shouldRun() {
+        return true;
+    }
+
+    @Override
+    protected void run(Class<?> clazz) throws ReflectiveOperationException {
+        Object obj = clazz.newInstance();
+        Method m = clazz.getMethod("main");
+        String result = (String) m.invoke(obj);
+        assertEquals("2", result);
+    }
+
+    static enum Dummy implements Template {
+        A();
+
+        public String expand(String selector) { return toString(); }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/combo/SeparateCompilationTest.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,100 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.combo;
+
+import org.testng.annotations.Test;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Method;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+/**
+ * SeparateCompilationTest -- test of test framework to do separate compilation
+ */
+@Test
+public class SeparateCompilationTest extends JavacTemplateTestBase {
+
+    public void testCompletelySeparate() throws ReflectiveOperationException, IOException {
+        addSourceFile("A.java", new StringTemplate("public class A { public String a() throws Throwable { return Class.forName(\"B\").getName(); } }"));
+        File aFile = compile(true);
+        assertCompileSucceeded();
+        reset();
+
+        addSourceFile("B.java", new StringTemplate("public class B {  }"));
+        File bFile = compile(true);
+        assertCompileSucceeded();
+
+        Class clazz = loadClass("A", aFile, bFile);
+        Method m = clazz.getMethod("a");
+        Object instance = clazz.newInstance();
+        String x = (String) m.invoke(instance);
+        assertEquals("B", x);
+    }
+
+    public void testIdenticalRecompile() throws ReflectiveOperationException, IOException {
+        addSourceFile("A.java", new StringTemplate("public class A { public String a() { return B.b(); } }"));
+        addSourceFile("B.java", new StringTemplate("public class B { public static String b() { return \"1\"; } }"));
+        File aFile = compile(true);
+        assertCompileSucceeded();
+        // Deleting B.class is not generally needed for test cases that simply replace B, but here we're testing the framework's ability to find B elsewhere
+        File bClass = new File(aFile, "B.class");
+        assertTrue(bClass.exists());
+        boolean deleted = bClass.delete();
+        assertTrue(deleted);
+        reset();
+
+        addSourceFile("B.java", new StringTemplate("public class B { public static String b() { return \"1\"; } }"));
+        File bFile = compile(true);
+        assertCompileSucceeded();
+
+        Class clazz = loadClass("A", bFile, aFile);
+        Method m = clazz.getMethod("a");
+        Object instance = clazz.newInstance();
+        String x = (String) m.invoke(instance);
+        assertEquals("1", x);
+    }
+
+    public void testConsistentRecompile() throws ReflectiveOperationException, IOException {
+        addSourceFile("A.java", new StringTemplate("public class A { public String a() { return B.b(); } }"));
+        addSourceFile("B.java", new StringTemplate("public class B { public static String b() { return \"1\"; } }"));
+        File aFile = compile(true);
+        assertCompileSucceeded();
+        reset();
+
+        addSourceFile("B.java", new StringTemplate("public class B { public static String b() { return \"2\"; } }"));
+        File bFile = compile(true);
+        assertCompileSucceeded();
+
+        Class clazz = loadClass("A", bFile, aFile);
+        Method m = clazz.getMethod("a");
+        Object instance = clazz.newInstance();
+        String x = (String) m.invoke(instance);
+        assertEquals("2", x);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/combo/SourceFile.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.combo;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * SourceFile
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@java.lang.annotation.Target({ElementType.METHOD, ElementType.FIELD})
+public @interface SourceFile {
+    String value();
+    String group() default "";
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/combo/StackProcessingUtils.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package tools.javac.combo;
+
+/**
+ * Utility class for defining stack processing-like operations
+ *
+ * @author Maurizio Cimadamore
+ */
+public class StackProcessingUtils {
+
+    /**
+     * interface representing a stack item - each item has an arity ---
+     * if arity is > 0 - then the item is an operator
+     */
+    public interface StackItem<T extends StackItem<T>> {
+        int arity();
+    }
+
+    /**
+     * A reducer takes an element of the stack and produces a result of a given
+     * type by applying the stack item to zero or more operands
+     */
+    public interface StackReducer<I extends StackItem<I>, T, O> {
+        T reduce(I item, T[] operands, O o);
+        Class<T> resultToken();
+        O reducerArg(I item, int i);
+    }
+
+    static class StackResult<T> {
+        T result;
+        int nextPos;
+
+        StackResult(T result, int nextPos) {
+            this.result = result;
+            this.nextPos = nextPos;
+        }
+    }
+
+    public static <I extends StackItem<I>, T, O> T process(I[] elems, StackReducer<I, T, O> reducer, O o) {
+        StackResult<T> result = processInternal(0, elems, reducer, o);
+        assert result.nextPos == elems.length;
+        return result.result;
+    }
+
+    private static <I extends StackItem<I>, T, O> StackResult<T> processInternal(int start, I[] elems, StackReducer<I, T, O> reducer, O o) {
+        @SuppressWarnings("unchecked")
+        I head = elems[start];
+        T[] operands = (T[])java.lang.reflect.Array.newInstance(reducer.resultToken(), head.arity());
+        int nextPos = start + 1;
+        for (int i = 0 ; i < head.arity() ; i++) {
+            StackResult<T> partialResult = processInternal(nextPos, elems, reducer, reducer.reducerArg(head, i));
+            nextPos = partialResult.nextPos;
+            operands[i] = partialResult.result;
+        }
+        return new StackResult<T>(reducer.reduce(head, operands, o), nextPos);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/combo/StringTemplateTest.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.combo;
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * StringTemplateTest
+ */
+@Test
+public class StringTemplateTest extends JavacTemplateTestBase {
+    private void assertTemplate(String expected, Template template) {
+        String result = template.expand("");
+        assertEquals(result, expected, "for " + template);
+    }
+
+    public void testStringTemplate() {
+        assertTemplate("XYZ", new StringTemplate("XYZ"));
+        addTemplate("NONE", "SOME");
+        assertTemplate("SOME", new StringTemplate("#{NONE}"));
+
+        addTemplate("A", "#{B}");
+        addTemplate("B", "C");
+        assertTemplate("C", new StringTemplate("#{A}"));
+    }
+
+    public void testChainedTemplate() {
+        assertTemplate("A", new StringTemplate("#{A}").with("A", "A"));
+        assertTemplate("AB", new StringTemplate("#{A}#{B}").with("A", "A").with("B", "B"));
+        assertTemplate("TWO", new StringTemplate("#{A}").with("A", "ONE").with("A", "TWO"));
+        addTemplate("A", "BASE_A");
+        addTemplate("AA", "#{A}");
+        assertTemplate("FAKE_A", new StringTemplate("#{A}").with("A", "FAKE_A"));
+        assertTemplate("BASE_A", new StringTemplate("#{AA}"));
+        assertTemplate("FAKE_A", new StringTemplate("#{AA}").with("A", "FAKE_A"));
+
+        addTemplate("X", new StringTemplate("#{A}").with("A", "intercepted"));
+        assertTemplate("intercepted", new StringTemplate("#{B}").with("B", "#{X}"));
+        addTemplate("Y", new StringTemplate("#{A}"));
+        assertTemplate("again", new StringTemplate("#{B}").with("B", "#{Y}").with("A", "again"));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/combo/SyntheticLoop.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.combo;
+
+import java.util.Iterator;
+
+/**
+ * SyntheticLoop -- exhaustively generate a set of combinations of variables
+ *
+ * @author Brian Goetz
+ */
+public class SyntheticLoop implements Iterable<Object[]> {
+    final int dimensions;
+    final int[] maxs;
+    final Object[][] values;
+
+    /** Simple version -- generate the cartesian product of the provided sets of axis values */
+    public SyntheticLoop(Object[][] dimValues) {
+        dimensions = dimValues.length;
+        maxs = new int[dimensions];
+        values = new Object[dimensions][];
+        for (int i=0; i<dimensions; i++) {
+            values[i] = dimValues[i];
+            maxs[i] = values[i].length;
+        }
+    }
+
+//    /** Complex version -- allow the contents of some dimensions to depend on previous dimensions, such
+//     * as generating tuples (a,b) where foo(b) <= foo(a).  Of the two arrays provided, for each index i,
+//     * exactly one of dimValues[i], dimGenerators[i] must be non-null.
+//     */
+//    public SyntheticLoop(Object[][] dimValues, DimensionFactory[] dimGenerators) {
+//        @@@NYI
+//    }
+
+    public Iterator<Object[]> iterator() {
+        return new Iterator<Object[]>() {
+            final int[] idxs = new int[dimensions];
+            boolean hasNext = (dimensions > 0);
+
+            public boolean hasNext() {
+                return hasNext;
+            }
+
+            public Object[] next() {
+                Object[] ret = new Object[dimensions];
+                for (int i=0; i<dimensions; i++)
+                    ret[i] = values[i][idxs[i]];
+                hasNext = !advance(dimensions-1);
+                return ret;
+            }
+
+            public void remove() { throw new UnsupportedOperationException(); }
+
+            private boolean advance(int i) {
+                if (i < 0)
+                    return true;
+                if (++idxs[i] == maxs[i]) {
+                    idxs[i] = 0;
+                    return advance(i - 1);
+                }
+                return false;
+            }
+        };
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/combo/SyntheticLoopTest.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.combo;
+
+import org.testng.annotations.Test;
+
+import java.util.Iterator;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+/**
+ * SyntheticLoopTest
+ */
+@Test
+public class SyntheticLoopTest {
+    public void testEmpty() {
+        SyntheticLoop sl = new SyntheticLoop(new Object[0][]);
+        Iterator<Object[]> it = sl.iterator();
+        assertTrue(!it.hasNext());
+    }
+
+    private void assertSL(String expected, SyntheticLoop sl) {
+        StringBuilder sb = new StringBuilder();
+        for (Object[] row : sl) {
+            for (Object o : row) {
+                sb.append(o);
+            }
+            sb.append(" ");
+        }
+        assertEquals(sb.toString(), expected);
+    }
+
+    private void assertSL(int size, SyntheticLoop sl) {
+        int count = 0;
+        for (Object row : sl) {
+            ++count;
+        }
+        assertEquals(count, size);
+    }
+
+    public void testSimple() {
+        Object[] abc = {"A", "B", "C"};
+        assertSL("A B C ", new SyntheticLoop(new Object[][] {abc}));
+        assertSL("AA AB AC BA BB BC CA CB CC ", new SyntheticLoop(new Object[][] {abc, abc}));
+        assertSL(9, new SyntheticLoop(new Object[][] {abc, abc}));
+        assertSL(9, new SyntheticLoop(new Object[][] {abc, abc, new Object[] { "X" }}));
+        assertSL(27, new SyntheticLoop(new Object[][] {abc, abc, abc}));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/combo/Template.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.combo;
+
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * A template into which tags of the form {@code #\{KEY\}} or
+ * {@code #\{KEY.SUBKEY\}} can be expanded.
+ */
+public interface Template {
+    String expand(String selector);
+
+    interface Resolver {
+        public Template lookup(String key);
+    }
+
+    public static class Behavior {
+        /* Looks for expandable keys.  An expandable key can take the form:
+         *   #{MAJOR}
+         *   #{MAJOR.MINOR}
+         *   where MAJOR can be IDENTIFIER or IDENTIFIER[NUMERIC_INDEX]
+         *   and MINOR can be an identifier
+         */
+        private static final Pattern pattern = Pattern.compile("#\\{([A-Z_][A-Z0-9_]*(?:\\[\\d+\\])?)(?:\\.([A-Z0-9_]*))?\\}");
+
+        public static String expandTemplate(String template, final Map<String, Template> vars) {
+            return expandTemplate(template, new MapResolver(vars));
+        }
+
+        public static String expandTemplate(String template, Resolver res) {
+            CharSequence in = template;
+            StringBuffer out = new StringBuffer();
+            while (true) {
+                boolean more = false;
+                Matcher m = pattern.matcher(in);
+                while (m.find()) {
+                    String major = m.group(1);
+                    String minor = m.group(2);
+                    Template key = res.lookup(major);
+                    if (key == null)
+                        throw new IllegalStateException("Unknown major key " + major);
+
+                    String replacement = key.expand(minor == null ? "" : minor);
+                    more |= pattern.matcher(replacement).find();
+                    m.appendReplacement(out, replacement);
+                }
+                m.appendTail(out);
+                if (!more)
+                    return out.toString();
+                else {
+                    in = out;
+                    out = new StringBuffer();
+                }
+            }
+        }
+
+    }
+}
+
+class MapResolver implements Template.Resolver {
+    private final Map<String, Template> vars;
+
+    public MapResolver(Map<String, Template> vars) {this.vars = vars;}
+
+    public Template lookup(String key) {
+        return vars.get(key);
+    }
+}
+
+class ChainedResolver implements Template.Resolver {
+    private final Template.Resolver upstreamResolver, thisResolver;
+
+    public ChainedResolver(Template.Resolver upstreamResolver, Template.Resolver thisResolver) {
+        this.upstreamResolver = upstreamResolver;
+        this.thisResolver = thisResolver;
+    }
+
+    public Template.Resolver getUpstreamResolver() {
+        return upstreamResolver;
+    }
+
+    @Override
+    public Template lookup(String key) {
+        Template result = thisResolver.lookup(key);
+        if (result == null)
+            result = upstreamResolver.lookup(key);
+        return result;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/combo/TemplateTest.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.combo;
+
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * TemplateTest
+ */
+@Test
+public class TemplateTest {
+    Map<String, Template> vars = new HashMap<>();
+
+    @BeforeTest
+    void before() { vars.clear(); }
+
+    private void assertTemplate(String expected, String template) {
+        String result = Template.Behavior.expandTemplate(template, vars);
+        assertEquals(result, expected, "for " + template);
+    }
+
+    private String dotIf(String s) {
+        return s == null || s.isEmpty() ? "" : "." + s;
+    }
+
+    public void testTemplateExpansion() {
+        vars.put("A", s -> "a" + dotIf(s));
+        vars.put("B", s -> "b" + dotIf(s));
+        vars.put("C", s -> "#{A}#{B}");
+        vars.put("D", s -> "#{A" + dotIf(s) + "}#{B" + dotIf(s) + "}");
+        vars.put("_D", s -> "d");
+
+        assertTemplate("", "");
+        assertTemplate("foo", "foo");
+        assertTemplate("a", "#{A}");
+        assertTemplate("a", "#{A.}");
+        assertTemplate("a.FOO", "#{A.FOO}");
+        assertTemplate("aa", "#{A}#{A}");
+        assertTemplate("ab", "#{C}");
+        assertTemplate("ab", "#{C.FOO}");
+        assertTemplate("ab", "#{C.}");
+        assertTemplate("a.FOOb.FOO", "#{D.FOO}");
+        assertTemplate("ab", "#{D}");
+        assertTemplate("d", "#{_D}");
+        assertTemplate("#{A", "#{A");
+    }
+
+    public void testIndexedTemplate() {
+        vars.put("A[0]", s -> "a" );
+        vars.put("A[1]", s -> "b" );
+        vars.put("A[2]", s -> "c" );
+        vars.put("X", s -> "0");
+        assertTemplate("a", "#{A[0]}");
+        assertTemplate("b", "#{A[1]}");
+        assertTemplate("c", "#{A[2]}");
+    }
+
+    public void testAngleBrackets() {
+        vars.put("X", s -> "xyz");
+        assertTemplate("List<String> ls = xyz;", "List<String> ls = #{X};");
+    }
+
+    @Test(expectedExceptions = IllegalStateException.class )
+    public void testUnknownKey() {
+        assertTemplate("#{Q}", "#{Q}");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/combo/TemplateVar.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.combo;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * ComboTemplate
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@java.lang.annotation.Target({ElementType.METHOD, ElementType.FIELD})
+public @interface TemplateVar {
+    String value();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/lambda/ConditionalExpressionTest.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,271 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.lambda;
+
+import org.testng.annotations.Factory;
+import tools.javac.combo.ComboTestBase;
+import tools.javac.combo.DimensionVar;
+import tools.javac.combo.SourceFile;
+import tools.javac.combo.Template;
+import tools.javac.combo.TemplateVar;
+
+/**
+ * ConditionalExpressionTest
+ */
+public class ConditionalExpressionTest extends ComboTestBase<ConditionalExpressionTest> {
+    @Factory
+    public static Object[] testConditionalExpression() throws Exception {
+        return factory(ConditionalExpressionTest.class);
+    }
+
+    @DimensionVar("TYPE1") Type type1;
+    @DimensionVar("TYPE2") Type type2;
+    @DimensionVar("TARGET") Type target;
+    @DimensionVar("STMT") Statement stmt;
+
+    @SourceFile("Main.java")
+    String clientFile = "public class Main {\n"
+            + " #{STMT_DECL};\n"
+            + " #{DECL.1};\n"
+            + " #{DECL.2};\n"  
+            + " void test(boolean cond) { \n"
+            + "   #{STMT};"
+            + " }\n"
+            +"}";
+
+    @Override
+    protected void postCompile(String grp) {
+        CondResult res = Type.condType(type1, type2);
+        if (!res.check(type1, type2, target)) {
+            assertCompileFailed();
+        } else {
+            assertCompileSucceeded();
+        }
+    }
+
+    @Override
+    protected boolean shouldSkip() {
+        return target == Type.INT_CONST;
+    }
+
+    interface CondResult {
+        boolean check(Type op1, Type op2, Type target);
+    }
+
+    static CondResult ERR = new CondResult() {
+        public boolean check(Type op1, Type op2, Type target) { return false; }
+    };
+
+    static CondResult TARGET = new CondResult() {
+        public boolean check(Type op1, Type op2, Type target) {
+           return op1.compatibleWith(target) && op2.compatibleWith(target);
+        }
+    };
+
+    enum TypeKind {
+        NUMERIC,
+        BOOLEAN,
+        OTHER;
+    }
+
+    enum Type implements Template, CondResult {
+        BYTE("byte", "0", TypeKind.NUMERIC),
+        SHORT("short", "0", TypeKind.NUMERIC),
+        INT("int", "0", TypeKind.NUMERIC),
+        INT_CONST("int", "0", TypeKind.NUMERIC),
+        LONG("long", "0", TypeKind.NUMERIC),
+        FLOAT("float", "0", TypeKind.NUMERIC),
+        DOUBLE("double", "0", TypeKind.NUMERIC),
+        CHAR("char", "'0'", TypeKind.NUMERIC),
+        BOOLEAN("boolean", "false", TypeKind.BOOLEAN),
+        J_L_BYTE("Byte", "null", TypeKind.NUMERIC),
+        J_L_SHORT("Short", "null", TypeKind.NUMERIC),
+        J_L_INT("Integer", "null", TypeKind.NUMERIC),
+        J_L_LONG("Long", "null", TypeKind.NUMERIC),
+        J_L_FLOAT("Float", "null", TypeKind.NUMERIC),
+        J_L_DOUBLE("Double", "null", TypeKind.NUMERIC),
+        J_L_CHAR("Character", "null", TypeKind.NUMERIC),
+        J_L_BOOLEAN("Boolean", "null", TypeKind.BOOLEAN),
+        NUMBER("Number", "null", TypeKind.OTHER),
+        SERIAL("java.io.Serializable", "null", TypeKind.OTHER);
+
+        public boolean check(Type op1, Type op2, Type target) {
+            return compatibleWith(target);
+        }
+
+        public boolean isErroneous() {
+            return false;
+        }
+
+        public String expand(String qualifier) {
+            return typeStr;
+        }
+
+        boolean compatibleWith(Type that) {
+            return that.anyOf(compatibleWith[this.ordinal()]);
+        }
+
+        boolean anyOf(Type... ts) {
+            for (Type t : ts) {
+                if (t == this) return true;
+            }
+            return false;
+        }
+
+        Type unbox() {
+            switch (this) {
+                case BYTE:
+                case J_L_BYTE: return BYTE;
+                case SHORT:
+                case J_L_SHORT: return SHORT;
+                case INT:
+                case INT_CONST:
+                case J_L_INT: return INT;
+                case LONG:
+                case J_L_LONG: return LONG;
+                case FLOAT:
+                case J_L_FLOAT: return FLOAT;
+                case DOUBLE:
+                case J_L_DOUBLE: return DOUBLE;
+                case BOOLEAN:
+                case J_L_BOOLEAN: return BOOLEAN;
+                case CHAR:
+                case J_L_CHAR: return CHAR;                
+                default:
+                    return null;
+            }
+        }
+
+        String typeStr;
+        String defaultVal;
+        TypeKind kind;
+
+        Type(String typeStr, String defaultVal, TypeKind kind) {
+            this.typeStr = typeStr;
+            this.defaultVal = defaultVal;
+            this.kind = kind;
+        }
+
+        static CondResult condType(Type type1, Type type2) {
+            if (type1.kind == TypeKind.BOOLEAN && type2.kind == TypeKind.BOOLEAN) {
+                //boolean conditional
+                return BOOLEAN;
+            } else if (type1.kind == TypeKind.NUMERIC && type2.kind == TypeKind.NUMERIC) {                    
+                //numeric conditional
+                Type unbox1 = type1.unbox();
+                Type unbox2 = type2.unbox();
+                if (type1 == INT_CONST &&     
+                        unbox2.anyOf(CHAR, BYTE, SHORT)) {
+                    return unbox2;
+                }
+                if (type2 == INT_CONST &&     
+                        unbox1.anyOf(CHAR, BYTE, SHORT)) {
+                    return unbox1;
+                }
+                if (unbox1 == unbox2) {
+                    return unbox1;
+                }
+                if (unbox1 == CHAR) {
+                    return condType(INT, unbox2);
+                }
+                if (unbox2 == CHAR) {
+                    return condType(unbox1, INT);
+                }
+                if (unbox1.compatibleWith(unbox2)) {
+                    return unbox2;
+                } else if (unbox2.compatibleWith(unbox1)) {
+                    return unbox1;
+                } else {
+                    return ERR;
+                }
+            } else {
+                //reference conditional
+                return TARGET;
+            }
+        }
+
+        static Type[][] compatibleWith = new Type[][] {
+        /* BYTE */        { BYTE, SHORT, INT, LONG, FLOAT, DOUBLE, J_L_BYTE, NUMBER, SERIAL },
+        /* SHORT */       { SHORT, INT, LONG, FLOAT, DOUBLE, J_L_SHORT, NUMBER, SERIAL },
+        /* INT */         { INT, LONG, FLOAT, DOUBLE, J_L_INT, NUMBER, SERIAL },
+        /* INT_CONST */   { INT, LONG, FLOAT, DOUBLE, J_L_INT, NUMBER, SERIAL },
+        /* LONG */        { LONG, FLOAT, DOUBLE, J_L_LONG, NUMBER, SERIAL },
+        /* FLOAT */       { FLOAT, DOUBLE, J_L_FLOAT, NUMBER, SERIAL },
+        /* DOUBLE */      { DOUBLE, J_L_DOUBLE, NUMBER, SERIAL },
+        /* CHAR */        { CHAR, INT, LONG, FLOAT, DOUBLE, J_L_CHAR, SERIAL },
+        /* BOOLEAN */     { BOOLEAN, J_L_BOOLEAN, SERIAL },
+        /* J_L_BYTE */    { J_L_BYTE, BYTE, SHORT, INT, LONG, FLOAT, DOUBLE, NUMBER, SERIAL },
+        /* J_L_SHORT */   { J_L_SHORT, SHORT, INT, LONG, FLOAT, DOUBLE, NUMBER, SERIAL },
+        /* J_L_INT */     { J_L_INT, INT, LONG, FLOAT, DOUBLE, NUMBER, SERIAL },
+        /* J_L_LONG */    { J_L_LONG, LONG, FLOAT, DOUBLE, NUMBER, SERIAL },
+        /* J_L_FLOAT */   { J_L_FLOAT, FLOAT, DOUBLE, NUMBER, SERIAL },
+        /* J_L_DOUBLE */  { J_L_DOUBLE, DOUBLE, NUMBER, SERIAL },
+        /* J_L_CHAR */    { J_L_CHAR, CHAR, INT, LONG, FLOAT, DOUBLE, SERIAL },
+        /* J_L_BOOLEAN */ { J_L_BOOLEAN, BOOLEAN, SERIAL },
+        /* NUMBER */      { NUMBER, SERIAL },
+        /* SERIAL */      { SERIAL } };
+    }
+
+    enum Statement implements Template {
+        ASSIGN("#{TARGET} t = cond ? #{EXPR.1} : #{EXPR.2}"),
+        METHOD("m(cond ? #{EXPR.1} : #{EXPR.2})");
+
+        String stmtStr;
+
+        Statement(String stmtStr) {
+            this.stmtStr = stmtStr;
+        }
+
+        public String expand(String qual) {
+            return stmtStr;
+        }
+    }
+
+    @TemplateVar("STMT_DECL")
+    Template stmt_decl = new Template() {
+        public String expand(String selector) {            
+            return stmt == Statement.ASSIGN ? "" : "void m(#{TARGET} arg) { }";
+        }
+    };
+
+    @TemplateVar("DECL")
+    Template decl = new Template() {
+        public String expand(String selector) {
+            int sel = Integer.valueOf(selector);
+            Type t = sel == 1 ? type1 : type2;
+            return t == Type.INT_CONST ? "" : String.format("#{TYPE%d} m%d() { return %s; }", sel, sel, t.defaultVal);
+        }
+    };
+
+    @TemplateVar("EXPR")
+    Template expr = new Template() {
+        public String expand(String selector) {
+            int sel = Integer.valueOf(selector);
+            Type t = sel == 1 ? type1 : type2;
+            return t == Type.INT_CONST ? t.defaultVal : String.format("m%d()", sel);
+        }
+    };
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/lambda/DefaultMethodAddTest.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.lambda;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.testng.annotations.Factory;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import tools.javac.combo.*;
+
+/**
+ * DefaultMethodAddTest: Test default method by running bytecode compiled at different times
+ *                       where conflicting default methods are added or declared
+ */
+public class DefaultMethodAddTest extends ComboTestBase<DefaultMethodAddTest> {
+    @Factory
+    public static Object[] testDefaultMethodAdd() throws Exception {
+        return factory(DefaultMethodAddTest.class);
+    }
+    
+    @DimensionVar("SHAPE") CShapes shapeType;
+    
+    /**
+     * The separate-compilation operation to be performed, such as adding a default method, 
+     * adding an abstract itnerface method, redeclaring an inherited default method as 
+     * abstract interface method, etc
+     */     
+    @DimensionVar("ADD") AddType addType;
+        
+    @SourceFile(value="B.java", group="A")
+    String interfaceBModified = "interface B #{SHAPE.B_DECL} { #{ADD} }";
+    
+    @SourceFile(value="B.java", group="B")
+    String interfaceB =         "interface B #{SHAPE.B_DECL} {}";
+    
+    @SourceFile(value="A.java", group="B")
+    String interfaceA =         "interface A { default String m() { return \"A\"; } }";
+    
+    @SourceFile(value="C.java", group="B")
+    String classC = "#{SHAPE.C}";
+    
+    @SourceFile(value="Main.java", group="B")
+    String classMain = "public class Main {\n" +
+                       "    public String main() {\n" +
+                       "        return new C().m();\n" +                       
+                       "    }\n" +
+                       "}";    
+
+    @Override
+    protected boolean shouldRun() { return true; }
+    
+    @Override
+    protected void run(Class<?> clazz) throws ReflectiveOperationException {
+        Method m = clazz.getMethod("main");
+        Object obj = clazz.newInstance();
+        String result = null, output = null;
+        try {
+            result = (String) m.invoke(obj);
+        } catch (InvocationTargetException ex) {
+            output = ex.getCause().toString();
+        }        
+        if(shapeType == CShapes.C_B_A) {
+            if(addType == AddType.ADD) {
+                assertEquals(output, null);
+                assertEquals(result, "B");
+            }
+            else //redeclare
+                assertEquals(output, "java.lang.AbstractMethodError: Method B.m()Ljava/lang/String; is abstract");
+        }
+        else if(shapeType == CShapes.C_I_AB2) {
+            assertEquals(output, null);
+            assertEquals(result, "A");
+        }
+        else if(shapeType == CShapes.C_CI) {
+            assertEquals(output, null);
+            assertEquals(result, "D");
+        }
+        else if(shapeType == CShapes.C_I_AB3) {
+            assertEquals(output, null);
+            assertEquals(result, "AB");
+        }
+        else            
+            assertTrue(output.matches("java.lang.AbstractMethodError: Conflicting default methods: .+[.]m .+[.]m"));        
+    }
+    
+    enum CShapes implements Template { //shapes of class hirarchy
+        //class C implements interface A, B
+        C_AB("",            
+           "class C implements A, B {}"), 
+        //class C implments interface B, B extends interface A
+        C_B_A("extends A", 
+           "class C implements B {}"),
+        //class C implments interface AB, AB extends interface A, B
+        C_I_AB("", 
+           "interface AB extends A, B {  }\n" + 
+           "class C implements AB {}"),
+        //class C implments interface AB, AB extends interface A, B and explicitly inherits the default method in A
+        C_I_AB2("", 
+        "interface AB extends A, B { default String m() { return A.super.m(); } }\n" + 
+        "class C implements AB {}"),
+        //class C implments interface AB, AB extends interface A, B and overrides the default method inherited
+        C_I_AB3("", 
+        "interface AB extends A, B { default String m() { return \"AB\"; } }\n" + 
+        "class C implements AB {}"),
+        //class C extends Class D implements Interface B
+        C_CI("", 
+            "class D { public String m() { return \"D\"; } }\n" + 
+            "class C extends D implements B {}");
+        
+        private final String sB_DECL;
+        private final String sC;
+        
+        CShapes(String sB_DECL, String sC) {
+            this.sB_DECL = sB_DECL;
+            this.sC = sC;
+        }
+        
+        public String expand(String selector) {
+            switch(selector) {
+                case "B_DECL": return sB_DECL;
+                case "C": return sC;
+                default: return toString();
+            }            
+        }        
+    }
+    
+    enum AddType implements Template { // add by adding default method or abstract interface method
+        ADD("default String m() { return \"B\"; }"),
+        REDECLARE("String m();");
+        
+        final String newCode;
+        
+        AddType(String str) {
+            newCode = str;
+        }
+        
+        public String expand(String selector) {
+            return newCode;        
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/lambda/DefaultMethodRemoveTest.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,165 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.lambda;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.testng.annotations.Factory;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import tools.javac.combo.*;
+
+/**
+ * DefaultMethodRemoveTest: Test default method by running bytecode compiled at different times
+ *                          where default methods are removed or redeclared
+ */
+public class DefaultMethodRemoveTest extends ComboTestBase<DefaultMethodRemoveTest> {
+    @Factory
+    public static Object[] testDefalutMethodRemove() throws Exception {
+        return factory(DefaultMethodRemoveTest.class);
+    }
+    
+    @DimensionVar("SHAPE") CShapes shapeType;
+    
+    /**
+     * The separate-compilation operation to be performed, such as removing a default method, 
+     * redeclaring as abstract interface method, etc
+     */  
+    @DimensionVar("REMOVE") RemoveType removeType;
+    
+    @SourceFile(value="B.java", group="A")
+    String interfaceBModified = "interface B #{SHAPE.B_DECL} { #{REMOVE} }";
+      
+    @SourceFile(value="A.java", group="B")
+    String interfaceA = "interface A { default String m() { return \"A\"; } }";
+    
+    @SourceFile(value="B.java", group="B")
+    String interfaceB = "interface B #{SHAPE.B_DECL} { default String m() { return \"B\"; } }";
+        
+    @SourceFile(value="C.java", group="B")
+    String classC = "#{SHAPE.C}";
+    
+    @SourceFile(value="Main.java", group="B")
+    String classMain = "public class Main {\n" +
+                       "    public String main() {\n" +
+                       "        return new C().m();\n" +                       
+                       "    }\n" +
+                       "}";    
+
+    @Override
+    protected boolean shouldRun() { return true; }
+    
+    @Override
+    protected void postCompile(String group) {
+        if( group.equals("A") && shapeType == CShapes.C_B_AD && removeType == RemoveType.REMOVE )
+            assertCompileErrors("compiler.err.types.incompatible.unrelated.defaults");
+    }
+
+    @Override
+    protected void run(Class<?> clazz) throws ReflectiveOperationException {
+        Method m = clazz.getMethod("main");
+        Object obj = clazz.newInstance();
+        String result = null, output = null;
+        try {
+            result = (String) m.invoke(obj);
+        } catch (InvocationTargetException ex) {
+            output = ex.getCause().toString();            
+        }
+        if(shapeType == CShapes.C_B_A) {
+            if(removeType == RemoveType.REMOVE)
+                assertEquals(result, "A");
+            else
+                assertEquals(output, "java.lang.AbstractMethodError: Method B.m()Ljava/lang/String; is abstract");
+        }
+        else if(shapeType == CShapes.C_CI)
+            assertEquals(result, "D");
+        else if(shapeType == CShapes.C_B_AD) {
+            if(removeType == RemoveType.REMOVE)
+                assertEquals(output, "java.lang.AbstractMethodError: C.m()Ljava/lang/String;");
+            else    
+                assertEquals(output, "java.lang.AbstractMethodError: Method B.m()Ljava/lang/String; is abstract");
+        }
+        else { //C_B
+            if( removeType == RemoveType.REMOVE)
+                assertEquals(output, "java.lang.NoSuchMethodError: C.m()Ljava/lang/String;");
+            else
+                assertEquals(output, "java.lang.AbstractMethodError: C.m()Ljava/lang/String;");
+        }
+    }
+    
+    enum CShapes implements Template { //shapes of class hirarchy
+        //class C implements interface B
+        C_B("", 
+            "class C implements B {}"), 
+        //class C implments interface B, B extends interface A
+        C_B_A("extends A", 
+              "class C implements B {}"),
+        //class C implments interface B, B extends interface A, D
+        C_B_AD("extends A, D", 
+               "interface D { default String m() { return \"D\"; } }\n" + 
+               "class C implements B {}"),
+        //class C extends Class D implements Interface B
+        C_CI("", 
+             "class D { public String m() { return \"D\"; } }\n" + 
+             "class C extends D implements B {}");
+        
+        private final String sB_DECL;
+        private final String sC;
+        
+        CShapes(String sB_DECL, String sC) {
+            this.sB_DECL = sB_DECL;
+            this.sC = sC;            
+        }
+        
+        public String expand(String selector) {
+            switch(selector) {
+                case "B_DECL": return sB_DECL;
+                case "C": return sC;                
+                default: return toString();
+            }
+        }        
+    }
+    
+    enum RemoveType implements Template { //remove by removing default method code or redeclaring the interface method
+        REMOVE(""),
+        REDECLARE("String m();");
+        
+        final String newCode;
+        
+        RemoveType(String str) {
+            newCode = str;
+        }
+        
+        public String expand(String selector) {
+            return newCode;        
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/lambda/LambdaArgAdaptationTest.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.lambda;
+
+import org.testng.annotations.Factory;
+import tools.javac.combo.ComboTestBase;
+import tools.javac.combo.DimensionVar;
+import tools.javac.combo.SourceFile;
+import tools.javac.combo.Template;
+
+import java.lang.reflect.Method;
+import java.util.EnumMap;
+import java.util.EnumSet;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * LambdaArgAdaptationTest
+ */
+public class LambdaArgAdaptationTest extends ComboTestBase<LambdaArgAdaptationTest> {
+    @Factory
+    public static Object[] testArgAdaptation() throws Exception {
+        return factory(LambdaArgAdaptationTest.class);
+    }
+
+    @DimensionVar("FROM") Types fromType;
+    @DimensionVar("TO") Types toType;
+
+    @SourceFile("Sam.java")
+    String samFile = "public interface Sam { String m(#{FROM} arg); }";
+
+    @SourceFile("Main.java")
+    String clientFile = "public class Main {\n"
+                        +"  static String m(#{TO} arg) { \n"
+                        +"    return String.valueOf(arg);\n"
+                        +"  }\n"
+                        +"  public String main() { \n"
+                        + "   Sam s = Main::m;\n"
+                        + "   return s.m(#{FROM.ARG});\n"
+                        + " }\n"
+                        +"}";
+
+
+    @Override
+    protected String[] getCompileOptions(String group) {
+        return new String[] { "-XDlambdaToMethod" };
+    }
+
+    @Override
+    protected void postCompile(String group) {
+        if (fromType == Types.VOID || toType == Types.VOID)
+            assertCompileFailed();
+        else if (fromType.pr == PR.REF && toType.pr == PR.REF)
+            assertCompileSucceededIff(toType.clazz.isAssignableFrom(fromType.clazz));
+        else if (fromType.pr == PR.PRIM && toType.pr == PR.REF)
+            assertCompileSucceededIff(toType.clazz.isAssignableFrom(Types.boxMap.get(fromType).clazz));
+        else if (fromType.pr == PR.REF && toType.pr == PR.PRIM)
+            assertCompileSucceededIff(fromType.unboxed != null && Types.widenMap.get(fromType.unboxed).contains(toType));
+        else if (fromType.pr == PR.PRIM && toType.pr == PR.PRIM)
+            assertCompileSucceededIff(Types.widenMap.get(fromType).contains(toType));
+        else
+            assertCompileSucceeded();
+    }
+
+    @Override
+    protected boolean shouldRun() { return true; }
+
+    @Override
+    protected void run(Class<?> clazz) throws ReflectiveOperationException {
+        Method m = clazz.getMethod("main");
+        Object obj = clazz.newInstance();
+        String result = (String) m.invoke(obj);
+        String formatted = fromType.asObject.toString();
+        if (fromType == Types.CHAR || fromType == Types.BOXED_CHAR) {
+            result = result.replace("A", "65");
+            formatted = formatted.replace("A", "65");
+        }
+        assertEquals(result.replace(".0", ""), formatted.replace(".0", ""));
+    }
+}
+
+enum PR {PRIM, REF}
+
+enum Types implements Template {
+    BYTE(PR.PRIM, "byte", byte.class, "(byte) 1", (byte) 1),
+    SHORT(PR.PRIM, "short", short.class, "(short) 2", (short) 2),
+    CHAR(PR.PRIM, "char", char.class, "'A'", 'A'),
+    INT(PR.PRIM, "int", int.class, "3", 3),
+    LONG(PR.PRIM, "long", long.class, "4L", 4L),
+    FLOAT(PR.PRIM, "float", float.class, "5.0f", 5.0f),
+    DOUBLE(PR.PRIM, "double", double.class, "6.0", 6.0),
+    BOOLEAN(PR.PRIM, "boolean", boolean.class, "true", true),
+    VOID(PR.PRIM, "void", void.class, "null", null),
+    BOXED_BYTE(PR.REF, "Byte", Byte.class, "Byte.valueOf((byte) 1)", (byte) 1, BYTE),
+    BOXED_SHORT(PR.REF, "Short", Short.class, "Short.valueOf((short) 2)", (short) 2, SHORT),
+    BOXED_CHAR(PR.REF, "Character", Character.class, "Character.valueOf('A')", 'A', CHAR),
+    BOXED_INT(PR.REF, "Integer", Integer.class, "Integer.valueOf(3)", 3, INT),
+    BOXED_LONG(PR.REF, "Long", Long.class, "Long.valueOf(4)", (long) 4, LONG),
+    BOXED_FLOAT(PR.REF, "Float", Float.class, "Float.valueOf(5.0f)", 5.0f, FLOAT),
+    BOXED_DOUBLE(PR.REF, "Double", Double.class, "Double.valueOf(6.0)", 6.0, DOUBLE),
+    BOXED_BOOLEAN(PR.REF, "Boolean", Boolean.class, "Boolean.valueOf(true)", true, BOOLEAN),
+    NUMBER(PR.REF, "Number", Number.class, "9", 9),
+    OBJECT(PR.REF, "Object", Object.class, "10", 10),
+    STRING(PR.REF, "String", String.class, "\"foo\"", "foo");
+
+    public static EnumMap<Types, Types> boxMap = new EnumMap<>(Types.class);
+    public static EnumMap<Types, Types> unboxMap = new EnumMap<>(Types.class);
+    public static EnumMap<Types, EnumSet<Types>> widenMap = new EnumMap<>(Types.class);
+
+    static {
+        for (Types t : values()) {
+            if (t.unboxed != null) {
+                boxMap.put(t.unboxed, t);
+                unboxMap.put(t, t.unboxed);
+            }
+        }
+
+        widenMap.put(BYTE, EnumSet.of(BYTE, SHORT, INT, LONG, FLOAT, DOUBLE));
+        widenMap.put(SHORT, EnumSet.of(SHORT, INT, LONG, FLOAT, DOUBLE));
+        widenMap.put(CHAR, EnumSet.of(CHAR, INT, LONG, FLOAT, DOUBLE));
+        widenMap.put(INT, EnumSet.of(INT, LONG, FLOAT, DOUBLE));
+        widenMap.put(LONG, EnumSet.of(LONG, FLOAT, DOUBLE));
+        widenMap.put(FLOAT, EnumSet.of(FLOAT, DOUBLE));
+        widenMap.put(DOUBLE, EnumSet.of(DOUBLE));
+        widenMap.put(BOOLEAN, EnumSet.of(BOOLEAN));
+    }
+
+    final PR pr;
+    final String name;
+    final Class<?> clazz;
+    final String valueString;
+    final Object asObject;
+    final Types unboxed;
+
+    Types(PR pr, String name, Class<?> clazz, String valueString, Object asObject) {
+        this (pr, name, clazz, valueString, asObject, null);
+    }
+
+    Types(PR pr, String name, Class<?> clazz, String valueString, Object asObject, Types unboxed) {
+        this.pr = pr;
+        this.name = name;
+        this.clazz = clazz;
+        this.valueString = valueString;
+        this.asObject = asObject;
+        this.unboxed = unboxed;
+    }
+
+    public String expand(String selector) {
+        switch (selector) {
+            case "ARG": return valueString;
+            default: return name;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/lambda/LambdaCaptureTest.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,261 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.lambda;
+
+import org.testng.annotations.Factory;
+import org.testng.annotations.Test;
+import tools.javac.combo.*;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * LambdaCaptureTest
+ *
+ * @author Brian Goetz
+ */
+public class LambdaCaptureTest extends ComboTestBase<LambdaCaptureTest> {
+    @Factory
+    public static Object[] testCombo() throws Exception {
+        return factory(LambdaCaptureTest.class);
+    }
+
+    final int arity;
+    final ArgType[] argTypes;
+    final int capArity;
+    final CapType[] capTypes;
+    final boolean shouldSkip;
+
+    public LambdaCaptureTest(@DimensionVar(value = "ARITY", rangeLower = 0, rangeUpper = 2) int arity,
+                             @DimensionVar("ARGTYPE1") ArgType argType1,
+                             @DimensionVar("ARGTYPE2") ArgType argType2,
+                             @DimensionVar(value = "CAP_ARITY", rangeLower = 0, rangeUpper = 2) int capArity,
+                             @DimensionVar("CAPTYPE1") CapType capType1,
+                             @DimensionVar("CAPTYPE2") CapType capType2) {
+        this.arity = arity;
+        this.capArity = capArity;
+        this.argTypes = new ArgType[] { argType1, argType2 };
+        this.capTypes = new CapType[] { capType1, capType2 };
+        shouldSkip = skipConstrained(arity, argTypes) || skipConstrained(capArity, capTypes);
+    }
+
+    @Override
+    protected String[] getCompileOptions(String group) {
+        return new String[] { "-XDlambdaToMethod" };
+    }
+
+    @SourceFile("Main.java") String test
+            = "public class Main {\n"
+            + "  #{CAPTYPE1} f0 = #{CAPV.1};\n"
+            + "  #{CAPTYPE2} f1 = #{CAPV.2};\n"
+            + "  interface Target { String m(#{SAM_FORMALS}); }\n"
+            + "  public String convert() { #{CAPTYPE1} loc0 = #{CAPV.1};\n"
+            + "                            #{CAPTYPE2} loc1 = #{CAPV.2};\n"
+            + "                            Target lambda = (#{LAMBDA_FORMALS}) -> String.format(\"#{FORMAT_STRING}\" #{FORMAT_ARGS});\n"
+            + "                            return lambda.m(#{INVOKE_ARGS}); }\n"
+            + "}";
+
+    @TemplateVar("LAMBDA_FORMALS") Template formalArgs = new Template() {
+        public String expand(String selector) {
+            List<String> list = new ArrayList<>();
+            for (int i=0; i<arity; i++)
+                list.add(argTypes[i].typeName + " a" + i);
+            return intersperse(list, ", ");
+        }
+    };
+
+    @TemplateVar("SAM_FORMALS") Template samArgs = new Template() {
+        public String expand(String selector) {
+            List<String> list = new ArrayList<>();
+            for (int i=0; i<arity; i++)
+                list.add(argTypes[i].typeName + " a" + i);
+            return intersperse(list, ", ");
+        }
+    };
+
+    @TemplateVar("FORMAT_STRING") Template formatString = new Template() {
+        public String expand(String selector) {
+            List<String> list = new ArrayList<>();
+            for (int i=0; i<capArity; i++)
+                list.add(capTypes[i].argType.format);
+            for (int i=0; i<arity; i++)
+                list.add(argTypes[i].format);
+            return intersperse(list, " ");
+        }
+    };
+
+    @TemplateVar("FORMAT_ARGS") Template formatArgs = new Template() {
+        public String expand(String selector) {
+            List<String> list = new ArrayList<>();
+            for (int i=0; i<capArity; i++)
+                list.add((capTypes[i].lf == LF.LOCAL ? "loc" : "f") + i);
+            for (int i=0; i<arity; i++)
+                list.add("a" + i);
+            return ((list.size()) > 0 ? ", " : "") + intersperse(list, ", ");
+        }
+    };
+
+    @TemplateVar("INVOKE_ARGS") Template invokeArgs = new Template() {
+        public String expand(String selector) {
+            List<String> list = new ArrayList<>();
+            for (int i=0; i<arity; i++)
+                list.add(argTypes[i].formatValue(i+capArity));
+            return intersperse(list, ", ");
+        }
+    };
+
+    @TemplateVar("CAPV") Template capv = new Template() {
+        public String expand(String selector) {
+            int i = Integer.parseInt(selector) - 1;
+            return capTypes[i].argType.formatValue(i);
+        }
+    };
+
+    private String intersperse(List<String> list, String delim) {
+        StringBuilder sb = new StringBuilder();
+        boolean first = true;
+        for (String s : list) {
+            if (!first)
+                sb.append(delim);
+            first = false;
+            sb.append(s);
+        }
+        return sb.toString();
+    }
+
+    @Override
+    protected boolean shouldSkip() {
+        return shouldSkip;
+    }
+
+    @Override
+    protected boolean shouldRun() {
+        return true;
+    }
+
+    @Override
+    protected void run(Class<?> clazz) throws ReflectiveOperationException {
+        Object obj = clazz.newInstance();
+        Method m = clazz.getMethod("convert");
+        Object o = m.invoke(obj);
+
+        List<String> list = new ArrayList<>();
+        for (int i=0; i<capArity; i++)
+            list.add(capTypes[i].argType.formatResult(i));
+        for (int i=0; i<arity; i++)
+            list.add(argTypes[i].formatResult(i+capArity));
+        String result = intersperse(list, " ");
+        assertEquals(result, o);
+    }
+
+    static enum ArgType implements Template {
+        LONG("long", "Long", "J%d", null) {
+            String formatValue(int x) { return String.format("(long) %d", x); }
+            String formatResult(int x) { return "J" + Integer.toString(x); }
+        },
+        BYTE("byte", "Byte", "B%d", LONG) {
+            String formatValue(int x) { return String.format("(byte) %d", x); }
+            String formatResult(int x) { return "B" + Integer.toString(x); }
+        },
+        SHORT("short", "Short", "S%d", LONG) {
+            String formatValue(int x) { return String.format("(short) %d", x); }
+            String formatResult(int x) { return "S" + Integer.toString(x); }
+        },
+        CHAR("char", "Character", "C%c", LONG) {
+            String formatValue(int x) { return String.format("(char) (((int) 'A') + %d)", x); }
+            String formatResult(int x) { return "C" + (char) (((int) 'A') + x); }
+        },
+        INT("int", "Integer", "I%d", LONG) {
+            String formatValue(int x) { return String.format("%d", x); }
+            String formatResult(int x) { return "I" + Integer.toString(x); }
+        },
+        BOOLEAN("boolean", "Boolean", "Z%b", null) {
+            String formatValue(int x) { return String.format("%d %% 2 != 0", x); }
+            String formatResult(int x) { return "Z" + (x % 2 != 0); }
+        },
+        DOUBLE("double", "Double", "D%f", null) {
+            String formatValue(int x) { return String.format("(double) %d", x); }
+            String formatResult(int x) { return "D" + String.format("%f", (double) x); }
+        },
+        FLOAT("float", "Float", "F%f", DOUBLE) {
+            String formatValue(int x) { return String.format("(float) %d", x); }
+            String formatResult(int x) { return "F" + String.format("%f", (float) x); }
+        },
+        OBJECT("Object", "Object", "O%s", null) {
+            String formatValue(int x) { return String.format("Integer.toString(%d)", x); }
+            String formatResult(int x) { return "O" + Integer.toString(x); }
+        },
+        STRING("String", "String", "S%s", null) {
+            String formatValue(int x) { return String.format("Integer.toString(%d)", x); }
+            String formatResult(int x) { return "S" + Integer.toString(x); }
+        };
+
+        final String typeName, boxed, format;
+        final ArgType widened;
+
+        ArgType(String typeName, String boxed, String format, ArgType widened) {
+            this.typeName = typeName;
+            this.boxed = boxed;
+            this.format = format;
+            this.widened = widened;
+        }
+
+        abstract String formatValue(int x);
+        abstract String formatResult(int x);
+
+        public String expand(String selector) {
+            return typeName;
+        }
+    }
+
+    private static enum LF { LOCAL, FIELD }
+
+    static enum CapType implements Template {
+        LOCAL_INT(ArgType.INT, LF.LOCAL),
+        LOCAL_LONG(ArgType.LONG, LF.LOCAL),
+        LOCAL_STRING(ArgType.STRING, LF.LOCAL),
+        FIELD_INT(ArgType.INT, LF.FIELD),
+        FIELD_LONG(ArgType.LONG, LF.FIELD),
+        FIELD_STRING(ArgType.STRING, LF.FIELD);
+
+        final ArgType argType;
+        final LF lf;
+
+        CapType(ArgType argType, LF lf) {
+            this.argType = argType;
+            this.lf = lf;
+        }
+
+        public String expand(String selector) {
+            return argType.typeName;
+        }
+    }
+}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/lambda/LambdaConversionTest.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.lambda;
+
+import org.testng.annotations.Factory;
+import tools.javac.combo.*;
+
+/**
+ * LambdaConversionTestCase
+ *
+ * @author Maurizio Cimadamore
+ */
+public class LambdaConversionTest extends ComboTestBase<LambdaConversionTest> {
+
+    @Factory
+    public static Object[] testCombo() throws Exception {
+        return factory(LambdaConversionTest.class);
+    }
+
+    @DimensionVar("PACKAGE")  PackageKind  samPkg;
+    @DimensionVar("MODIFIER") ModifierKind modKind;
+    @DimensionVar("CLASS")    SamKind      samKind;
+    @DimensionVar("METH")     MethodKind   meth;
+    @DimensionVar("RET")      TypeKind     retType;
+    @DimensionVar("ARG")      TypeKind     argType;
+    @DimensionVar("THROWN")   TypeKind     thrownType;
+
+    @SourceFile("Sam.java")
+    String samSource = "#{PACKAGE.PACKAGE_DECL} \n #{CLASS}";
+
+    @SourceFile("PackageClass.java")
+    String packageSource = "#{PACKAGE.PACKAGE_DECL}\n #{MODIFIER} class PackageClass extends Exception { }";
+
+    @SourceFile("Client.java")
+    String clientSource = "#{PACKAGE.IMPORT_STATEMENT}\n class Client { Sam s = x -> null; }";
+
+    @Override
+    protected void postCompile(String group) {
+        if (samKind != SamKind.INTERFACE) {
+            assertCompileFailed("SAM type must be an interface");
+        } else if (meth != MethodKind.NON_GENERIC) {
+            assertCompileFailed("target method must be non-generic");
+        } else if (samPkg != PackageKind.NO_PKG &&
+                   modKind != ModifierKind.PUBLIC &&
+                   (retType == TypeKind.PKG_CLASS
+                           || argType == TypeKind.PKG_CLASS
+                           || thrownType == TypeKind.PKG_CLASS)) {
+            assertCompileFailed("target must not contain inaccessible types");
+        } else {
+            assertCompileSucceeded();
+        }
+    }
+
+    static enum PackageKind implements Template {
+        NO_PKG(""),
+        PKG_A("a");
+
+        String pkg;
+
+        PackageKind(String pkg) {
+            this.pkg = pkg;
+        }
+
+        public String expand(String selector) {
+            if (this == NO_PKG)
+                return "";
+            switch (selector) {
+                case "PACKAGE_DECL": return String.format("package %s;", pkg);
+                case "IMPORT_STATEMENT":  return String.format("import %s.*;", pkg);
+                default: throw new IllegalArgumentException(selector);
+            }
+        }
+    }
+
+    static enum SamKind implements Template {
+        CLASS("public class Sam {  }"),
+        ABSTRACT_CLASS("public abstract class Sam {  }"),
+        ANNOTATION("public @interface Sam {  }"),
+        ENUM("public enum Sam { }"),
+        INTERFACE("public interface Sam { \n #{METH}; \n }");
+
+        String template;
+
+        SamKind(String template) { this.template = template; }
+
+        public String expand(String selector) { return template; }
+    }
+
+    static enum ModifierKind implements Template {
+        PUBLIC("public"),
+        PACKAGE("");
+
+        String template;
+
+        ModifierKind(String template) { this.template = template; }
+
+        public String expand(String selector) { return template; }
+    }
+
+    static enum TypeKind implements Template {
+        EXCEPTION("Exception"),
+        PKG_CLASS("PackageClass");
+
+        String template;
+
+        private TypeKind(String template) { this.template = template; }
+
+        public String expand(String selector) { return template; }
+    }
+
+    static enum MethodKind implements Template {
+        NONE(""),
+        NON_GENERIC("public #{RET} m(#{ARG} s) throws #{THROWN};"),
+        GENERIC("public <X> #{RET} m(#{ARG} s) throws #{THROWN};");
+
+        String template;
+
+        private MethodKind(String template) { this.template = template; }
+
+        public String expand(String selector) { return template; }
+    }
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/lambda/LambdaExpressionTypeInferenceTest.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,423 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.lambda;
+
+import org.testng.annotations.Factory;
+import tools.javac.combo.ComboTestBase;
+import tools.javac.combo.DimensionVar;
+import tools.javac.combo.SourceFile;
+import tools.javac.combo.Template;
+
+import static tools.javac.combo.StackProcessingUtils.*;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+/**
+ * LambdaExpressionTypeInferenceTest
+ */
+public class LambdaExpressionTypeInferenceTest extends ComboTestBase<LambdaExpressionTypeInferenceTest> {
+    @Factory
+    public static Object[] testLambdaExpressionInference() throws Exception {
+        return factory(LambdaExpressionTypeInferenceTest.class);
+    }
+
+    @DimensionVar("FORMAL_SHAPE") FormalTypeShape formalShape;
+    @DimensionVar("TREE_SHAPE") TreeShape treeShape;
+    @DimensionVar("ARG_SHAPE_1") ArgTypeShape argShape1;
+    @DimensionVar("ARG_SHAPE_2") ArgTypeShape argShape2;
+    @DimensionVar("ARG_SHAPE_3") ArgTypeShape argShape3;
+
+    @SourceFile("SAM.java")
+    String samFile = "public interface SAM<X,Y> {\n"
+            +"  Y apply(X x);\n"
+            +"}";
+
+
+    @SourceFile("Main.java")
+    String clientFile = "import java.util.*;\n"
+            +"public class Main {\n"
+            +"  <A,R> void m(#{FORMAL_SHAPE} x) { }\n"
+            +"  void test() {\n"
+            +"     m(#{TREE_SHAPE});\n"
+            +"  }\n"
+            +"}";
+
+    @Override
+    protected void postCompile(String grp) {
+        if (treeShape.compute().typeCheck(formalShape.compute(), new Type[] { argShape1.compute(), argShape2.compute(), argShape3.compute() }).isErroneous()) {
+            assertCompileFailed();
+        } else {
+            assertCompileSucceeded();
+        }
+    }
+
+    @Override
+    protected boolean shouldSkip() {
+        return argShape2.ordinal() != 0 && treeShape.depth < 2 || argShape3.ordinal() != 0 && treeShape.depth < 3;
+    }
+
+    static class Tree {
+        TreeTag treeTag;
+        Tree[] subtrees;
+
+        Tree(TreeTag treeTag, Tree... subtrees) {
+            this.treeTag = treeTag;
+            this.subtrees = subtrees;
+        }
+
+        public String toString() {
+            Object[] substrings = new Object[subtrees.length];
+            for (int i = 0; i < subtrees.length; i++) {
+                substrings[i] = subtrees[i].toString();
+            }
+            return String.format(treeTag.treeStr, substrings);
+        }
+
+        Type typeCheck(Type target, Type[] argtypes) {
+            switch (treeTag) {
+                case INT:   
+                   Type type = new Type(TypeToken.INTEGER);
+                   return type.compatibleWith(target) ? type : errType;
+                case STRING:
+                   type = new Type(TypeToken.STRING);
+                   return type.compatibleWith(target) ? type : errType;
+                case EXPR_LAMBDA:
+                    Type restype = target.getReturnType();
+                    if (restype == null) {
+                        return errType;
+                    }
+                    Type argtype = target.getArgType();
+                    int idx = subtrees[0].treeTag.argIndex();
+                    if (idx >= 0 && !argtypes[idx].compatibleWith(argtype)) {
+                        //arg type mismatch
+                        return errType;
+                    }
+                    
+                    for (int i = 1; i < subtrees.length; i++) {
+                        if (subtrees[i].typeCheck(restype, argtypes).isErroneous()) {
+                            return errType;
+                        }
+                    }
+                    return target;
+                case COND:
+                    Type typeToCheck = target;
+                    if (subtrees[0].treeTag == TreeTag.INT && subtrees[1].treeTag == TreeTag.INT) {
+                        Type owntype = new Type(TypeToken.INTEGER);
+                        return owntype.compatibleWith(target) ? owntype : errType;
+                    } else {
+                        for (int i = 0; i < subtrees.length; i++) {
+                            if (subtrees[i].typeCheck(target, argtypes).isErroneous()) {
+                                return errType;
+                            }
+                        }
+                        return target;
+                    }
+                default:
+                    throw new AssertionError();
+            }
+        }
+    }
+
+    enum TreeTag implements StackItem<TreeTag> {
+        INT("1", 0),
+        STRING("\"\"", 0),
+        COND("true ? %s : %s", 2),
+        EXPR_LAMBDA("(%s)->%s", 2),
+        IMPLICIT_1("x1", 0),
+        IMPLICIT_2("x2", 0),
+        IMPLICIT_3("x3", 0),
+        EXPLICIT_1("#{ARG_SHAPE_1} x1", 0),
+        EXPLICIT_2("#{ARG_SHAPE_2} x2", 0),
+        EXPLICIT_3("#{ARG_SHAPE_3} x3", 0);
+
+        String treeStr;
+        int arity;
+
+        TreeTag(String treeStr, int arity) {
+            this.treeStr = treeStr;
+            this.arity = arity;
+        }
+
+        public int arity() {
+            return arity;
+        }
+
+        Tree apply(Tree... args) {
+            return new Tree(this, args);
+        }
+
+        int argIndex() {
+            switch (this) {
+                case EXPLICIT_1:
+                    return 0;
+                case EXPLICIT_2:
+                    return 1;
+                case EXPLICIT_3:
+                    return 2;
+                default:
+                    return -1;
+            }
+        }
+    }
+
+    enum TreeShape implements Template, StackReducer<TreeTag, Tree, Void> {
+        LAMBDA_INT(1, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_1, TreeTag.INT),
+        LAMBDA_STRING(1, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_1, TreeTag.STRING),
+        LAMBDA_COND_INT_INT(1, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_1, TreeTag.COND, TreeTag.INT, TreeTag.INT),
+        IMPL_LAMBDA_INT(1, TreeTag.EXPR_LAMBDA, TreeTag.IMPLICIT_1, TreeTag.INT),
+        IMPL_LAMBDA_STRING(1, TreeTag.EXPR_LAMBDA, TreeTag.IMPLICIT_1, TreeTag.STRING),
+        IMPL_LAMBDA_COND_INT_INT(1, TreeTag.EXPR_LAMBDA, TreeTag.IMPLICIT_1, TreeTag.COND, TreeTag.INT, TreeTag.INT),
+        LAMBDA_LAMBDA_INT(2, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_1, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_2, TreeTag.INT),
+        LAMBDA_LAMBDA_STRING(2, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_1, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_2, TreeTag.STRING),
+        LAMBDA_LAMBDA_COND_INT_INT(2, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_1, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_2, TreeTag.COND, TreeTag.INT, TreeTag.INT),
+        LAMBDA_IMPL_LAMBDA_INT(2, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_1, TreeTag.EXPR_LAMBDA, TreeTag.IMPLICIT_2, TreeTag.INT),
+        LAMBDA_IMPL_LAMBDA_STRING(2, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_1, TreeTag.EXPR_LAMBDA, TreeTag.IMPLICIT_2, TreeTag.STRING),
+        LAMBDA_IMPL_LAMBDA_COND_INT_INT(2, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_1, TreeTag.EXPR_LAMBDA, TreeTag.IMPLICIT_2, TreeTag.COND, TreeTag.INT, TreeTag.INT),
+        LAMBDA_COND_LAMBDA_INT_INT(2, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_1, TreeTag.COND, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_2, TreeTag.INT, TreeTag.INT),
+        LAMBDA_COND_LAMBDA_STRING_INT(2, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_1, TreeTag.COND, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_2, TreeTag.STRING, TreeTag.INT),
+        LAMBDA_COND_LAMBDA_COND_INT_INT_INT(2, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_1, TreeTag.COND, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_2, TreeTag.COND, TreeTag.INT, TreeTag.INT, TreeTag.INT),
+        LAMBDA_COND_IMPL_LAMBDA_INT_INT(2, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_1, TreeTag.COND, TreeTag.EXPR_LAMBDA, TreeTag.IMPLICIT_2, TreeTag.INT, TreeTag.INT),
+        LAMBDA_COND_IMPL_LAMBDA_STRING_INT(2, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_1, TreeTag.COND, TreeTag.EXPR_LAMBDA, TreeTag.IMPLICIT_2, TreeTag.STRING, TreeTag.INT),
+        LAMBDA_COND_IMPL_LAMBDA_COND_INT_INT_INT(2, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_1, TreeTag.COND, TreeTag.EXPR_LAMBDA, TreeTag.IMPLICIT_2, TreeTag.COND, TreeTag.INT, TreeTag.INT, TreeTag.INT),
+        LAMBDA_LAMBDA_LAMBDA_INT(3, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_1, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_2, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_3, TreeTag.INT),
+        LAMBDA_LAMBDA_LAMBDA_STRING(3, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_1, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_2, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_3, TreeTag.STRING),
+        LAMBDA_LAMBDA_LAMBDA_COND_INT_INT(3, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_1, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_2, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_3, TreeTag.COND, TreeTag.INT, TreeTag.INT),
+        LAMBDA_LAMBDA_IMPL_LAMBDA_INT(3, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_1, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_2, TreeTag.EXPR_LAMBDA, TreeTag.IMPLICIT_3, TreeTag.INT),
+        LAMBDA_LAMBDA_IMPL_LAMBDA_STRING(3, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_1, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_2, TreeTag.EXPR_LAMBDA, TreeTag.IMPLICIT_3, TreeTag.STRING),
+        LAMBDA_LAMBDA_IMPL_LAMBDA_COND_INT_INT(3, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_1, TreeTag.EXPR_LAMBDA, TreeTag.EXPLICIT_2, TreeTag.EXPR_LAMBDA, TreeTag.IMPLICIT_3, TreeTag.COND, TreeTag.INT, TreeTag.INT);
+
+        TreeTag[] treeTags;
+        int depth;
+
+        TreeShape(int depth, TreeTag... treeTags) {
+            this.depth = depth;
+            this.treeTags = treeTags;
+        }
+
+        Tree compute() {
+            return process(treeTags, this, null);
+        }
+
+        public String expand(String selector) {
+            return compute().toString();
+        }
+
+        public Tree reduce(TreeTag tag, Tree[] args, Void _unused) {
+            return new Tree(tag, args);
+        }
+
+        public Void reducerArg(TreeTag item, int i) { return null; }
+
+        public Class<Tree> resultToken() {
+            return Tree.class;
+        }
+    }
+
+    static class Type {
+        TypeToken typeToken;
+        Type[] typeargs;
+
+        Type(TypeToken typeToken, Type... typeargs) {
+            this.typeToken = typeToken;
+            this.typeargs = typeargs;
+        }
+
+        public String toString() {
+            Object[] typeargStrings = new Object[typeargs.length];
+            for (int i = 0; i < typeargs.length; i++) {
+                typeargStrings[i] = typeargs[i].toString();
+            }
+            return String.format(typeToken.tokenStr, typeargStrings);
+        }
+
+        boolean isErroneous() { return false; }
+
+        Type getReturnType() {
+            return typeToken == TypeToken.SAM ?
+                typeargs[1] : null;
+        }
+
+        Type getArgType() {
+            return typeToken == TypeToken.SAM ?
+                typeargs[0] : null;
+        }
+
+        boolean isFree() {
+            switch (typeToken) {
+                case A:
+                case R:
+                    return true;
+                default:
+                    for (Type t : typeargs) {
+                        if (t.isFree()) return true;
+                    }
+                    return false;    
+            }
+        }
+
+        boolean isFreeVar() {
+            switch (typeToken) {
+                case A:
+                case R:
+                    return true;
+                default:                    
+                    return false;    
+            }
+        }
+
+        boolean compatibleWith(Type that) {
+            if (that.isFreeVar()) {
+                return true;
+            } else {
+                if (typeToken != that.typeToken)
+                    return false;
+                if (typeargs.length != that.typeargs.length) {
+                    return false;
+                }
+                for (int i = 0; i < typeargs.length ; i++) {
+                    if (!typeargs[i].compatibleWith(that.typeargs[i]))
+                        return false;
+                }
+                return true;
+            }
+        }
+    }
+
+    static Type errType = new Type(null) {
+        boolean isErroneous() {
+            return true;
+        }
+    };
+
+    enum TypeToken implements StackItem<TypeToken> {
+        STRING("String", 0),
+        INTEGER("Integer", 0),
+        A("A", 0),
+        R("R", 0),
+        LIST("List<%s>", 1),
+        SAM("SAM<%s,%s>", 2);
+
+        int arity;
+        String tokenStr;
+
+        TypeToken(String tokenStr, int arity) {
+            this.tokenStr = tokenStr;
+            this.arity = arity;
+        }
+
+        public int arity() {
+            return arity;
+        }
+    }
+
+    enum ArgTypeShape implements Template, StackReducer<TypeToken, Type, Void> {
+        STRING(TypeToken.STRING),
+        INTEGER(TypeToken.INTEGER),
+        LIST_STRING(TypeToken.LIST, TypeToken.STRING),
+        LIST_INTEGER(TypeToken.LIST, TypeToken.INTEGER);
+
+        TypeToken[] tokens;
+
+        ArgTypeShape(TypeToken... tokens) {
+            this.tokens = tokens;
+        }
+
+        Type compute() {
+            return process(tokens, this, null);
+        }
+
+        public String expand(String selector) {
+            return compute().toString();
+        }
+
+        public Type reduce(TypeToken token, Type[] args, Void _unused) {
+            return new Type(token, args);
+        }
+
+        public Void reducerArg(TypeToken item, int i) { return null; }
+
+        public Class<Type> resultToken() {
+            return Type.class;
+        }
+    }
+
+    enum FormalTypeShape implements Template, StackReducer<TypeToken, Type, Void> {
+        SAM_String_String(TypeToken.SAM, TypeToken.STRING, TypeToken.STRING),
+        SAM_Integer_String(TypeToken.SAM, TypeToken.INTEGER, TypeToken.STRING),
+        SAM_List_String_String(TypeToken.SAM, TypeToken.LIST, TypeToken.STRING, TypeToken.STRING),
+        SAM_List_Integer_String(TypeToken.SAM, TypeToken.LIST, TypeToken.INTEGER, TypeToken.STRING),
+        SAM_A_String(TypeToken.SAM, TypeToken.A, TypeToken.STRING),
+        SAM_List_A_String(TypeToken.SAM, TypeToken.LIST, TypeToken.A, TypeToken.STRING),
+        SAM_String_R(TypeToken.SAM, TypeToken.STRING, TypeToken.R),
+        SAM_A_R(TypeToken.SAM, TypeToken.A, TypeToken.R),
+        SAM_List_A_R(TypeToken.SAM, TypeToken.LIST, TypeToken.A, TypeToken.R),
+        SAM_String_SAM_String_String(TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.STRING, TypeToken.STRING),
+        SAM_String_SAM_Integer_String(TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.INTEGER, TypeToken.STRING),
+        SAM_String_SAM_List_String_String(TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.LIST, TypeToken.STRING, TypeToken.STRING),
+        SAM_String_SAM_List_Integer_String(TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.LIST, TypeToken.INTEGER, TypeToken.STRING),
+        SAM_String_SAM_A_String(TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.A, TypeToken.STRING),
+        SAM_String_SAM_List_A_String(TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.LIST, TypeToken.A, TypeToken.STRING),
+        SAM_String_SAM_String_R(TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.STRING, TypeToken.R),
+        SAM_String_SAM_A_R(TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.A, TypeToken.R),
+        SAM_String_SAM_List_A_R(TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.LIST, TypeToken.A, TypeToken.R),
+        SAM_A_SAM_String_String(TypeToken.SAM, TypeToken.A, TypeToken.SAM, TypeToken.STRING, TypeToken.STRING),
+        SAM_String_SAM_String_SAM_String_String(TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.STRING, TypeToken.STRING),
+        SAM_String_SAM_String_SAM_Integer_String(TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.INTEGER, TypeToken.STRING),
+        SAM_String_SAM_String_SAM_List_String_String(TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.LIST, TypeToken.STRING, TypeToken.STRING),
+        SAM_String_SAM_String_SAM_List_Integer_String(TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.LIST, TypeToken.INTEGER, TypeToken.STRING),
+        SAM_String_SAM_String_SAM_A_String(TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.A, TypeToken.STRING),
+        SAM_String_SAM_String_SAM_List_A_String(TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.LIST, TypeToken.A, TypeToken.STRING),
+        SAM_String_SAM_String_SAM_String_R(TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.STRING, TypeToken.R),
+        SAM_String_SAM_String_SAM_A_R(TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.A, TypeToken.R),
+        SAM_String_SAM_String_SAM_List_A_R(TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.LIST, TypeToken.A, TypeToken.R),
+        SAM_String_SAM_A_SAM_String_String(TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.A, TypeToken.SAM, TypeToken.STRING, TypeToken.STRING),
+        SAM_String_SAM_A_SAM_String_R(TypeToken.SAM, TypeToken.STRING, TypeToken.SAM, TypeToken.A, TypeToken.SAM, TypeToken.STRING, TypeToken.R);
+
+        TypeToken[] tokens;
+
+        FormalTypeShape(TypeToken... tokens) {
+            this.tokens = tokens;
+        }
+
+        Type compute() {
+            return process(tokens, this, null);
+        }
+
+        public String expand(String selector) {
+            return compute().toString();
+        }
+
+        public Type reduce(TypeToken token, Type[] args, Void _unused) {
+            return new Type(token, args);
+        }
+
+        public Void reducerArg(TypeToken item, int i) { return null; }
+
+        public Class<Type> resultToken() {
+            return Type.class;
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/lambda/LambdaReturnAdaptationTest.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.lambda;
+
+import org.testng.annotations.Factory;
+import tools.javac.combo.*;
+
+import java.lang.reflect.Method;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+/**
+ * LambaReturnAdaptationTest
+ */
+public class LambdaReturnAdaptationTest extends ComboTestBase<LambdaReturnAdaptationTest> {
+    @Factory
+    public static Object[] testReturnAdaptation() throws Exception {
+        return factory(LambdaReturnAdaptationTest.class);
+    }
+
+    @DimensionVar("FROM") Types fromType;
+    @DimensionVar("TO") Types toType;
+
+    @SourceFile("Sam.java")
+    String samFile = "public interface Sam { #{TO} m(int arg); }";
+
+    @SourceFile("Main.java")
+    String clientFile = "public class Main {\n"
+                        +"  static #{FROM} m(int arg) { \n"
+                        +"    #{RET};\n"
+                        +"  }\n"
+                        +"  public #{TO} main() { \n"
+                        + "   Sam s = Main::m;\n"
+                        + "   #{RET_MAIN};\n"
+                        + " }\n"
+                        +"}";
+
+    @TemplateVar("RET")
+    Template retTemplate = new Template() {
+        public String expand(String selector) {
+            if (fromType == Types.VOID)
+                return "";
+            else if (fromType == Types.STRING)
+                return "return \"66\"";
+            else if (fromType == Types.BOOLEAN || fromType == Types.BOXED_BOOLEAN)
+                return "return true";
+            else if (fromType.unboxed != null)
+                return "return (" + fromType.unboxed.name + ") arg";
+            else
+                return "return (" + fromType.name + ") arg";
+        }
+    };
+
+    @TemplateVar("RET_MAIN")
+    Template retMainTemplate = new Template() {
+        public String expand(String selector) {
+            return toType == Types.VOID ? "s.m(66)" : "return s.m(66)";
+        }
+    };
+
+    @Override
+    protected String[] getCompileOptions(String group) {
+        return new String[] { "-XDlambdaToMethod" };
+    }
+
+    @Override
+    protected void postCompile(String group) {
+        if (fromType != Types.VOID && toType == Types.VOID)
+            assertCompileSucceeded();
+        else if (fromType == Types.VOID && toType != Types.VOID)
+            assertCompileFailed();
+        else if (fromType == Types.VOID && toType == Types.VOID)
+            assertCompileSucceeded();
+        else if (fromType.pr == PR.REF && toType.pr == PR.REF)
+            assertCompileSucceededIff(toType.clazz.isAssignableFrom(fromType.clazz));
+        else if (fromType.pr == PR.PRIM && toType.pr == PR.REF)
+            assertCompileSucceededIff(toType.clazz.isAssignableFrom(Types.boxMap.get(fromType).clazz));
+        else if (fromType.pr == PR.REF && toType.pr == PR.PRIM)
+            assertCompileSucceededIff(fromType.unboxed != null && Types.widenMap.get(fromType.unboxed).contains(toType));
+        else if (fromType.pr == PR.PRIM && toType.pr == PR.PRIM)
+            assertCompileSucceededIff(Types.widenMap.get(fromType).contains(toType));
+        else
+            assertCompileSucceeded();
+    }
+
+    @Override
+    protected boolean shouldRun() { return true; }
+
+    @Override
+    protected void run(Class<?> clazz) throws ReflectiveOperationException {
+        Method m = clazz.getMethod("main");
+        Object obj = clazz.newInstance();
+        Object in = 66;
+        Object out = m.invoke(obj);
+        if (toType == Types.VOID)
+            assertTrue(out == null);
+        else if (fromType == Types.BOOLEAN || fromType == Types.BOXED_BOOLEAN)
+            assertEquals("true", out.toString());
+        else
+            assertEquals(in.toString(), out.toString().replace("B", "66").replace(".0", ""));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/lambda/MethodRefCaptureTest.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,165 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.lambda;
+
+import org.testng.annotations.Factory;
+import tools.javac.combo.*;
+
+/**
+ * MethodRefCaptureTest
+ *
+ * @author Brian Goetz
+ */
+public class MethodRefCaptureTest extends ComboTestBase<MethodRefCaptureTest> {
+    @Factory
+    public static Object[] testCombo() throws Exception {
+        return factory(MethodRefCaptureTest.class);
+    }
+
+    @DimensionVar("VAR") ContextKind context;
+    @DimensionVar("LOCATION") LocationKind location;
+    @DimensionVar("ACC") AccessibilityKind accessibility;
+    @DimensionVar("METHOD") RefKind ref;
+
+    @TemplateVar("PACKAGE")
+    String makePackage() {
+        return location == LocationKind.OTHER_PACKAGE ? "package a;" : "";
+    }
+
+    // @@@ not yet used
+    @TemplateVar("MAIN") String main = "public static void main(String[] args) { #{METHOD.SAMTYPE} x = #{VAR.REF}";
+
+    @SourceFile("Sam1.java") String sam1 = "#{PACKAGE} \npublic interface Sam1 { public String get(String s); }";
+    @SourceFile("Sam2.java") String sam2 = "#{PACKAGE} \npublic interface Sam2<T> { public String get(T target, String s); }";
+    @SourceFile("Sam3.java") String sam3 = "#{PACKAGE} \npublic interface Sam3<T> { public T get(String s); }";
+    @SourceFile("A.java") String mainFile = "#{LOCATION.CAPTURING_CLASS}";
+    @SourceFile("Target.java") String extFile = "#{LOCATION.EXT_CLASS}";
+
+    @Override
+    protected String[] getCompileOptions(String group) {
+        return new String[] { "-XDlambdaToMethod" };
+    }
+
+    @Override
+    protected void postCompile(String group) {
+        if (location == LocationKind.OTHER_FILE && accessibility == AccessibilityKind.PRIVATE)
+            assertCompileFailed();
+        else if (location == LocationKind.OTHER_PACKAGE && accessibility != AccessibilityKind.PUBLIC)
+            assertCompileFailed();
+        else
+            assertCompileSucceeded();
+    }
+
+
+    static enum ContextKind implements Template {
+        STATIC_FIELD_INIT("static #{METHOD.SAMTYPE} var = #{METHOD.MREF};"),
+        STATIC_FIELD_CLINIT("static #{METHOD.SAMTYPE} var; static { var = #{METHOD.MREF}; };"),
+        INSTANCE_FIELD_INIT("#{METHOD.SAMTYPE} var = #{METHOD.MREF};"),
+        LOCAL_VAR("void m() { #{METHOD.SAMTYPE} var = #{METHOD.MREF}; };"),
+        METHOD_CALL("static void m(#{METHOD.SAMTYPE} s) { }; static void m() { m(#{METHOD.MREF}); };"),
+        RETURN("#{METHOD.SAMTYPE} m() { return #{METHOD.MREF}; };"),
+        ARRAY_INITIALIZER("#{METHOD.SAMTYPE}[] var = (#{METHOD.SAMTYPE}[]) new #{METHOD.ERASED_SAMTYPE}[] { (#{METHOD.SAMTYPE}) #{METHOD.MREF} };"),
+        CONDITIONAL("#{METHOD.SAMTYPE} var = new Object().equals(new Object()) ? #{METHOD.MREF} : #{METHOD.MREF};"),
+        CAST("#{METHOD.SAMTYPE} var = (#{METHOD.SAMTYPE}) #{METHOD.MREF};");
+
+        private final String t1;
+
+        ContextKind(String t1) { this.t1 = t1; }
+
+        public String expand(String selector) {
+            switch (selector) {
+                case "DECL": return t1;
+                default:     throw new IllegalArgumentException(selector);
+            }
+        }
+    }
+
+    static enum LocationKind implements Template {
+        SAME_CLASS("class Target { \n#{VAR.DECL} \n#{METHOD.DECL} }"),
+        ENCLOSING_CLASS("class Target { \n#{METHOD.DECL} \nstatic class Capturing { #{VAR.DECL} } }"),
+        SIBLING_INNER_CLASS("class Outer { \nstatic class Capturing { #{VAR.DECL} }  \nstatic class Target { #{METHOD.DECL} } }"),
+        NESTED_CLASS("class Capturing { \n#{VAR.DECL} \nstatic class Target { #{METHOD.DECL} } }"),
+        OTHER_FILE("class Capturing { \n#{VAR.DECL} }", "class Target { \n#{METHOD.DECL} }"),
+        OTHER_PACKAGE("package a; \nimport b.*; \nclass Capturing { \n#{VAR.DECL} }",
+                      "package b; \npublic class Target { \n#{METHOD.DECL} }");
+
+        private final String t1, t2;
+
+        LocationKind(String t1, String t2) {
+            this.t1 = t1;
+            this.t2 = t2;
+        }
+        LocationKind(String t1) { this(t1, "class Unused {}"); }
+
+        public String expand(String selector) {
+            switch (selector) {
+                case "CAPTURING_CLASS": return t1;
+                case "EXT_CLASS":       return t2;
+                default:                throw new IllegalArgumentException(selector);
+            }
+        }
+    }
+
+    static enum AccessibilityKind implements Template {
+        PUBLIC("public"),
+        PROTECTED("protected"),
+        PACKAGE(""),
+        PRIVATE("private");
+
+        private final String template;
+
+        AccessibilityKind(String template) { this.template = template; }
+
+        public String expand(String selector) { return template; }
+    }
+
+    static enum RefKind implements Template {
+        STATIC(0, "Target::staticMethod", "static #{ACC} String staticMethod(String s) { return \"1\"; }"),
+        UNBOUND_INSTANCE(1, "Target::instanceMethod", "#{ACC} String instanceMethod(String s) { return \"2\"; }"),
+        BOUND_INSTANCE(0, "(new Target())::instanceMethod", "#{ACC} String instanceMethod(String s) { return \"3\"; }"),
+        CTOR(2, "Target::new", "#{ACC} Target(String s) { }"),
+//    UNBOUND_INNER_CTOR,
+//    BOUND_INNER_CTOR
+//    , SUPER
+        ;
+
+        private static final String[] sams = { "Sam1", "Sam2<Target>", "Sam3<Target>" };
+        private final int samNo;
+        private final String t1, t2;
+
+        RefKind(int samNo, String t1, String t2) { this.samNo = samNo; this.t1 = t1; this.t2 = t2; }
+
+        public String expand(String selector) {
+            switch (selector) {
+                case "MREF": return t1;
+                case "DECL": return t2;
+                case "SAMTYPE": return sams[samNo];
+                case "ERASED_SAMTYPE": return sams[samNo].replaceAll("<Target>", "<?>");
+                default:   throw new IllegalArgumentException(selector);
+            }
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/lambda/NestedGenericMethodCallTest.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,410 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.lambda;
+
+import org.testng.annotations.Factory;
+import org.testng.annotations.Test;
+import tools.javac.combo.ComboTestBase;
+import tools.javac.combo.DimensionVar;
+import tools.javac.combo.SourceFile;
+import tools.javac.combo.Template;
+
+import static tools.javac.combo.StackProcessingUtils.*;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+/**
+ * NestedGenericMethodCallTest
+ */
+public class NestedGenericMethodCallTest extends ComboTestBase<NestedGenericMethodCallTest> {
+    @Factory
+    public static Object[] testNestedGenericMethodCallType() throws Exception {
+        return factory(NestedGenericMethodCallTest.class);
+    }
+
+    @Test(enabled=false)
+    public void test() throws Exception {
+        //disabled as the test has never been updated to support graph inference
+        super.test();
+    }
+
+    @DimensionVar("ID_METHOD") IdMethod idMethod;
+    @DimensionVar("NIL_METHOD") NilMethod nilMethod;
+    @DimensionVar("CONS_METHOD") ConsMethod consMethod;
+    @DimensionVar("SHAPE") Shape shape;
+    @DimensionVar("TARGET") Type target;
+
+    @SourceFile("Main.java")
+    String clientFile = "import java.util.*;\n"
+            +"public class Main {\n"
+            +"  #{ID_METHOD}\n"
+            +"  #{NIL_METHOD}\n"
+            +"  #{CONS_METHOD}\n"
+            +"  void test() { \n"
+            + "   #{TARGET} t = #{SHAPE};\n"
+            + " }\n"
+            +"}";
+
+    @Override
+    protected void postCompile(String grp) {
+        Type res = shape.compile(idMethod, nilMethod, consMethod, target);
+        if (res.asSubtypeOf(target).isError()) {
+            assertCompileFailed("Bad result = " + res);
+        } else {
+            assertCompileSucceeded();
+        }
+    }
+
+    @Override
+    protected boolean shouldSkip() {
+        return target.free || target == Type.ERROR;
+    }
+
+    enum Type implements Template {
+        Z("Z", true),
+        OBJECT("Object", false),
+        STRING("String", false),
+        LIST_Z("List<Z>", true),
+        LIST_OBJECT("List<Object>", false),
+        LIST_STRING("List<String>", false),
+        ERROR("<any>", false);
+
+        String typeStr;
+        boolean free;
+
+        Type(String typeStr, boolean free) {
+            this.typeStr = typeStr;
+            this.free = free;
+        }
+
+        boolean isError() {
+            return this == ERROR;
+        }
+
+        Type asSubtypeOf(Type that) {
+            return asSubtypeMap[this.ordinal()][that.ordinal()];
+        }
+ 
+        boolean isSubtypeOf(Type that) {
+            return !asSubtypeOf(that).isError();
+        }
+
+        public String expand(String selector) {
+            return typeStr;
+        }
+
+        enum ConstraintKind {
+            Z_EXT_OBJ(false, OBJECT),
+            Z_EXT_STRING(false, STRING),
+            Z_EXT_LIST_OBJECT(false, LIST_OBJECT),
+            Z_EXT_LIST_STRING(false, STRING),
+            Z_SUP_OBJECT(true, OBJECT),
+            Z_SUP_STRING(true, STRING),
+            Z_SUP_LIST_OBJECT(true, LIST_OBJECT),
+            Z_SUP_LIST_STRING(true, LIST_STRING),
+            ERROR(false, Type.ERROR);
+
+            boolean isSuper;
+            Type type;
+
+            ConstraintKind(boolean isSuper, Type type) {
+                this.isSuper = isSuper;
+                this.type = type;
+            }
+        }
+
+        static Type[][] asSubtypeMap = new Type[][] {
+                //                   Z           OBJECT      STRING       LIST_Z      LIST_OBJECT      LIST_STRING        ERROR
+                { /* Z           */  OBJECT     ,OBJECT     ,STRING      ,ERROR      ,LIST_OBJECT     ,LIST_STRING       ,ERROR        },
+                { /* OBJECT      */  OBJECT     ,OBJECT     ,ERROR       ,ERROR      ,ERROR           ,ERROR             ,ERROR        },
+                { /* STRING      */  STRING     ,STRING     ,STRING      ,ERROR      ,ERROR           ,ERROR             ,ERROR        },
+                { /* LIST_Z      */  LIST_OBJECT,LIST_OBJECT,ERROR       ,LIST_OBJECT,LIST_OBJECT     ,LIST_STRING       ,ERROR        },
+                { /* LIST_OBJECT */  LIST_OBJECT,LIST_OBJECT,ERROR       ,LIST_OBJECT,LIST_OBJECT     ,ERROR             ,ERROR        },
+                { /* LIST_STRING */  LIST_STRING,LIST_STRING,ERROR       ,LIST_STRING,ERROR           ,LIST_STRING       ,ERROR        },
+                { /* ERROR       */  ERROR      ,ERROR      ,ERROR       ,ERROR      ,ERROR           ,ERROR             ,ERROR        }};
+
+        static boolean isSubtypes(Type[] ts1, Type[] ts2) {
+            assertEquals(ts1.length, ts2.length);
+            for (int i = 0; i < ts1.length ; i++) {
+                if (!ts1[i].isSubtypeOf(ts2[i])) return false;
+            }
+            return true;
+        }
+
+        static Type listOf(Type t) {
+            switch (t) {
+                case OBJECT: return LIST_OBJECT;
+                case STRING: return LIST_STRING;
+                case Z: return LIST_Z;              
+                default: return ERROR;
+            }
+        }
+
+        static Type elemtype(Type t) {
+            switch (t) {
+                case LIST_OBJECT: return OBJECT;
+                case LIST_STRING: return STRING;
+                case LIST_Z: return Z;
+                default: return ERROR;
+            }
+        }   
+
+        static Type lub(Type t1, Type t2) {
+            if (!t1.asSubtypeOf(t2).isError()) {
+                return t2;
+            } else if (!t2.asSubtypeOf(t1).isError()) {
+                return t1;
+            } else {
+                return Type.ERROR;
+            }
+        }
+    }
+
+    interface MethodSig {
+        Type apply(Type target, Type... argTypes);
+        Type[] getFormals();
+    }
+
+    enum IdMethod implements Template, MethodSig {
+        NON_GENERIC_1("String id(String s) { return null; };", Type.STRING),
+        NON_GENERIC_2("List<String> id(List<String> s) { return null; };", Type.LIST_STRING),
+        GENERIC_1("<Z> Z id(Z z) { return null; };", Type.Z),
+        GENERIC_2("<Z> List<Z> id(List<Z> z) { return null; };", Type.LIST_Z);
+
+        String sig;
+        Type formal;
+
+        IdMethod(String sig, Type formal) {
+            this.sig = sig;
+            this.formal = formal;
+        }
+
+        public String expand(String selector) {
+            return sig;
+        }
+
+        public Type apply(Type target, Type... argTypes) {
+            return argTypes[0].asSubtypeOf(formal);
+        }
+
+        public Type[] getFormals() {
+            return new Type[] { formal };
+        }
+    }
+
+    enum NilMethod implements Template, MethodSig {
+        NON_GENERIC("List<String> nil() { return null; }", Type.LIST_STRING),
+        GENERIC("<Z> List<Z> nil() { return null; }", Type.LIST_Z);
+
+        String sig;
+        Type returnType;
+
+        NilMethod(String sig, Type returnType) {
+            this.sig = sig;
+            this.returnType = returnType;
+        }
+
+        public String expand(String selector) {
+            return sig;
+        }
+
+        public Type apply(Type target, Type... argTypes) {            
+            return this == NON_GENERIC ?
+                Type.LIST_STRING :
+                returnType.asSubtypeOf(target);
+        }
+
+        public Type[] getFormals() {
+            return null;
+        }
+    }
+
+    enum ConsMethod implements Template, MethodSig {
+        NON_GENERIC("List<String> cons(String s, List<String> ls) { return null; }", Type.STRING, Type.LIST_STRING) {
+            Type getReturnType(Type target, Type... argTypes) { return Type.LIST_STRING; }
+        },
+        GENERIC_1("<Z> List<Z> cons(Z z, List<String> ls) { return null; }", Type.Z, Type.LIST_STRING) {
+            Type getReturnType(Type target, Type... argTypes) { 
+                 switch (target) {
+                     case LIST_OBJECT:
+                     case LIST_STRING:
+                        return Type.LIST_Z.asSubtypeOf(target);
+                     default:
+                        return Type.listOf(argTypes[0].asSubtypeOf(Type.Z));
+                 }
+            }
+        },
+        GENERIC_2("<Z> List<Z> cons(String s, List<Z> lz) { return null; }", Type.STRING, Type.LIST_Z) {
+            Type getReturnType(Type target, Type... argTypes) { return Type.listOf(Type.elemtype(argTypes[1].asSubtypeOf(Type.LIST_Z))); }
+        },
+        GENERIC_3("<Z> List<Z> cons(Z z, List<Z> lz) { return null; }", Type.Z, Type.LIST_Z) {
+            Type getReturnType(Type target, Type... argTypes) {
+                Type lub = Type.lub(argTypes[0], Type.elemtype(argTypes[1].asSubtypeOf(Type.LIST_Z)));
+                return lub.isError() ? lub : Type.listOf(lub);
+            }
+        },
+        GENERIC_4("<U, V> List<U> cons(U z, List<V> lz) { return null; }", Type.Z, Type.LIST_Z) {
+            Type getReturnType(Type target, Type... argTypes) { 
+                switch (target) {
+                    case LIST_OBJECT:
+                    case LIST_STRING:
+                        return Type.LIST_Z.asSubtypeOf(target);
+                    default:
+                        return Type.listOf(argTypes[0].asSubtypeOf(Type.Z));
+                }
+            }
+        };
+
+        String sig;
+        Type[] formals;
+
+        ConsMethod(String sig, Type... formals) {
+            this.sig = sig;
+            this.formals = formals;
+        }
+
+        public String expand(String selector) {
+            return sig;
+        }
+
+        public Type apply(Type target, Type... argTypes) {
+            return Type.isSubtypes(argTypes, formals) ?
+                    getReturnType(target, argTypes) : Type.ERROR;
+        }
+
+        abstract Type getReturnType(Type target, Type... argTypes);
+
+        public Type[] getFormals() {
+            return formals;
+        }
+    }
+
+    enum Token implements StackItem<Token> {
+        NIL(0, "nil"),
+        DIAMOND(0, "new ArrayList<>"),
+        STRING(0, "\"\""),
+        ID(1, "id"),
+        CONS(2, "cons");
+
+        int arity;
+        String tokenStr;
+
+        Token(int arity, String tokenStr) {
+            this.arity = arity;
+            this.tokenStr = tokenStr;
+        }
+
+        public int arity() { return arity; }
+    }
+
+    enum Shape implements Template {
+        NIL(Token.NIL),
+        ID_NIL(Token.ID, Token.NIL),
+        ID_ID_NIL(Token.ID, Token.ID, Token.NIL),
+        CONS_STRING_NIL(Token.CONS, Token.STRING, Token.NIL),
+        CONS_STRING_ID_NIL(Token.CONS, Token.STRING, Token.ID, Token.NIL),
+        CONS_ID_STRING_NIL(Token.CONS, Token.ID, Token.STRING, Token.NIL),
+        CONS_ID_STRING_ID_NIL(Token.CONS, Token.ID, Token.STRING, Token.ID, Token.NIL),
+        CONS_ID_STRING_CONS_STRING_NIL(Token.CONS, Token.ID, Token.STRING, Token.CONS, Token.STRING, Token.NIL),
+        CONS_ID_STRING_CONS_ID_STRING_NIL(Token.CONS, Token.ID, Token.STRING, Token.CONS, Token.ID, Token.STRING, Token.NIL),
+        CONS_ID_STRING_CONS_STRING_ID_NIL(Token.CONS, Token.ID, Token.STRING, Token.CONS, Token.STRING, Token.ID, Token.NIL),
+        CONS_ID_STRING_CONS_ID_STRING_ID_NIL(Token.CONS, Token.ID, Token.STRING, Token.CONS, Token.ID, Token.STRING, Token.ID, Token.NIL),
+        CONS_ID_STRING_ID_CONS_ID_STRING_ID_NIL(Token.CONS, Token.ID, Token.STRING, Token.ID, Token.CONS, Token.ID, Token.STRING, Token.ID, Token.NIL),
+        ID_CONS_ID_STRING_ID_CONS_ID_STRING_ID_NIL(Token.ID, Token.CONS, Token.ID, Token.STRING, Token.ID, Token.CONS, Token.ID, Token.STRING, Token.ID, Token.NIL),
+        DIAMOND(Token.DIAMOND),
+        ID_DIAMOND(Token.ID, Token.DIAMOND),
+        CONS_STRING_DIAMOND(Token.CONS, Token.STRING, Token.DIAMOND),
+        CONS_STRING_ID_DIAMOND(Token.CONS, Token.STRING, Token.ID, Token.DIAMOND),
+        CONS_ID_STRING_DIAMOND(Token.CONS, Token.ID, Token.STRING, Token.DIAMOND),
+        CONS_ID_STRING_ID_DIAMOND(Token.CONS, Token.ID, Token.STRING, Token.ID, Token.DIAMOND),
+        CONS_ID_STRING_CONS_STRING_DIAMOND(Token.CONS, Token.ID, Token.STRING, Token.CONS, Token.STRING, Token.DIAMOND),
+        CONS_ID_STRING_CONS_ID_STRING_DIAMOND(Token.CONS, Token.ID, Token.STRING, Token.CONS, Token.ID, Token.STRING, Token.DIAMOND),
+        CONS_ID_STRING_CONS_STRING_ID_DIAMOND(Token.CONS, Token.ID, Token.STRING, Token.CONS, Token.STRING, Token.ID, Token.DIAMOND),
+        CONS_ID_STRING_CONS_ID_STRING_ID_DIAMOND(Token.CONS, Token.ID, Token.STRING, Token.CONS, Token.ID, Token.STRING, Token.ID, Token.DIAMOND),
+        CONS_ID_STRING_ID_CONS_ID_STRING_ID_DIAMOND(Token.CONS, Token.ID, Token.STRING, Token.ID, Token.CONS, Token.ID, Token.STRING, Token.ID, Token.DIAMOND),
+        ID_CONS_ID_STRING_ID_CONS_ID_STRING_ID_DIAMOND(Token.ID, Token.CONS, Token.ID, Token.STRING, Token.ID, Token.CONS, Token.ID, Token.STRING, Token.ID, Token.DIAMOND);
+
+        Token[] tokens;
+
+        Shape(Token... tokens) {
+            this.tokens = tokens;
+        }
+
+        Type compile(final IdMethod idMethod, final NilMethod nilMethod, final ConsMethod consMethod, Type target) {
+            return process(tokens, new StackReducer<Token, Type, Type>() {
+                public Type reduce(Token t, Type[] operands, Type target) {
+                    switch (t) {
+                        case DIAMOND: return Type.LIST_Z.asSubtypeOf(target);
+                        case NIL: return nilMethod.apply(target, operands);
+                        case STRING: return Type.STRING;
+                        case ID: return idMethod.apply(target, operands);
+                        case CONS: return consMethod.apply(target, operands);
+                        default: throw new AssertionError();
+                    }
+                }
+                public Class<Type> resultToken() { return Type.class; }
+                public Type reducerArg(Token item, int i) {
+                    switch (item) {
+                        case ID:
+                            return idMethod.getFormals()[i];
+                        case CONS:
+                            return consMethod.getFormals()[i];
+                        default: return Type.OBJECT;
+                    }
+                }
+            }, target);
+        }
+
+        public String expand(String selector) {
+            return process(tokens, new StackReducer<Token, String, Void>() {
+                public String reduce(Token t, String[] operands, Void _unused) {
+                    switch (t) {
+                        case DIAMOND:
+                        case NIL:
+                        case ID:
+                        case CONS:
+                            StringBuilder buf = new StringBuilder();
+                            String sep = "";
+                            for (int i = 0; i < t.arity; i ++) {
+                                buf.append(sep);
+                                buf.append(operands[i]);
+                                sep = ",";
+                            }
+                            buf.insert(0, "(");
+                            buf.insert(0, t.tokenStr);
+                            buf.append(")");
+                            return buf.toString();
+                        case STRING:
+                            return t.tokenStr;
+                        default: throw new AssertionError();
+                    }
+                }
+                public Class<String> resultToken() { return String.class; }
+                public Void reducerArg(Token item, int i) { return null; }
+            }, null);
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/lambda/SourceTargetVersionTest.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.lambda;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.testng.annotations.Factory;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import tools.javac.combo.*;
+
+/**
+ * SourceTargetVersionTest: 
+ * Test source and class file compatibility by compiling and running lambda specific code 
+ * against some class files compiled separately with different source and target option 
+ * (1.5, 1.6, and 1.7).
+ * The goal is achieved by putting source files in different groups (A, B, C..,), each group 
+ * is set with its own compile options, and we compile in the reverse alphebetic order for the 
+ * groups (..., C, B, A) to set a previously compiled group of files as classpath for the next group. 
+ * And when executing, we Run class Main with classpath A:B:C... in the order. 
+ * 
+ */
+public class SourceTargetVersionTest extends ComboTestBase<SourceTargetVersionTest> {
+    @Factory
+    public static Object[] testSourceTarget() throws Exception {
+        return factory(SourceTargetVersionTest.class);
+    }
+   
+    @DimensionVar("SHAPE") CShapes shapeType;
+    @DimensionVar("CLIENT_CODE") ClientType clientType;
+    @DimensionVar("RELEASE") ReleaseVersion rv;
+    
+    @SourceFile(value="A.java", group="B")
+    String interfaceA = "interface A { #{SHAPE.METHOD} }";    
+    
+    @SourceFile(value="B.java", group="A")
+    String interfaceB = "interface B #{SHAPE.EXTEND} { default String m() { return \"B\"; } }";
+    
+    @SourceFile(value="C.java", group="A")
+    String classC = "class C #{SHAPE.IMPLEMENT} {\n" +
+                    "    #{CLIENT_CODE}\n" +
+                    "}";
+    
+    @SourceFile(value="Main.java", group="A")
+    String classMain = "public class Main {\n" +
+                       "    public String main() {\n" +
+                       "        return new C().m();\n" +                       
+                       "    }\n" +
+                       "}";
+    
+    @TemplateVar("LAMBDA_EXP") String le = "public String m() {\n" +
+                                           "    A a = () -> \"A\";\n" +
+                                           "    return a.m();\n" +
+                                           "}";
+    @TemplateVar("METHOD_REF") String mr = "String foo() {\n" +
+                                           "    return \"foo\";\n" +
+                                           "}\n\n" +
+                                           
+                                           "public String m() {\n" +
+                                           "    A a = this::foo;\n" +
+                                           "    return a.m();\n" +
+                                           "}";
+    
+    @Override
+    protected boolean shouldSkip() {
+        return (shapeType == CShapes.C_AB && clientType != ClientType.DEF_MED) ||
+               (shapeType == CShapes.C && clientType == ClientType.DEF_MED);
+    }
+
+    @Override
+    protected boolean shouldRun() { return true; }
+
+    @Override
+    protected void run(Class<?> clazz) throws ReflectiveOperationException {
+        Method m = clazz.getMethod("main");
+        Object obj = clazz.newInstance();
+        String result = (String) m.invoke(obj);
+        String expected = clientType.returnValue;
+        assertEquals(result, expected);
+    }
+    
+    @Override
+    protected String[] getCompileOptions(String group) {
+        switch(group) {
+            case "B": return new String[]{"-source", rv.versionStr, "-target", rv.versionStr};
+            default: return new String[0];
+        }
+    }
+       
+    enum CShapes implements Template { //shapes of class hirarchy
+        //class C implements interface A, B
+        C_AB("", "", "implements A, B"), 
+        //class C implments interface B, B extends interface A
+        C_B_A("String m();", "extends A", "implements B"), 
+        //class C
+        C("String m();", "", ""); 
+        
+        private final String absMethod;
+        private final String extend;
+        private final String implement;
+        
+        CShapes(String absMethod, String extend, String implement) {
+            this.absMethod = absMethod;
+            this.extend = extend;
+            this.implement = implement;
+        }
+                
+        public String expand(String selector) {
+            switch(selector) {
+                case "METHOD": return absMethod;
+                case "EXTEND": return extend;
+                case "IMPLEMENT": return implement;
+                default: return toString();
+            }
+        }        
+    }
+    
+    enum ClientType implements Template { // jdk8 specific code in client program
+        LAMBDA_EXP("#{LAMBDA_EXP}", "A"), // lambda expressions
+        METHOD_REF("#{METHOD_REF}", "foo"), // method references
+        DEF_MED("", "B"); // default method inheritance
+        
+        private final String clientCode;
+        private final String returnValue;
+        
+        ClientType(String str, String ret) {
+            clientCode = str;
+            returnValue = ret;
+        }
+        
+        public String expand(String selector) {
+            return clientCode;        
+        }
+    }
+    
+    enum ReleaseVersion implements Template {
+        FIVE("1.5"),
+        SIX("1.6"),
+        SEVEN("1.7");
+        
+        final String versionStr;
+        
+        ReleaseVersion(String vstr) {
+            versionStr = vstr;
+        }
+        
+        public String expand(String selector) {
+            return toString();        
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/combo-tests/tests/tools/javac/lambda/StaticMethodTest.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,155 @@
+/*
+ * Copyright (c) 2013, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package tools.javac.lambda;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.testng.annotations.Factory;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import tools.javac.combo.*;
+
+/**
+ * StaticMethodTest: Test static methods in interfaces by running bytecode 
+ *                   compiled at different times; where a static method is added/declared
+ *                   in one interface and only that interface is recompiled.
+ *
+ *                   Static methods in interface are not inherited and 
+ *                   are not visible to any implementing (extending) classes (interfaces).
+ * @bug    8005968
+ * @author sogoel
+ * 
+ */
+public class StaticMethodTest extends ComboTestBase<StaticMethodTest> {
+    @Factory
+    public static Object[] testStaticMethod() throws Exception {
+        return factory(StaticMethodTest.class);
+    }
+    
+    @DimensionVar("SHAPE") CShapes shapeType;
+    
+    @DimensionVar("ADD") AddType addType;
+        
+    @SourceFile(value="B.java", group="A")
+    String interfaceBModified = "interface B #{SHAPE.B_DECL} { #{ADD} }";
+    
+    @SourceFile(value="B.java", group="B")
+    String interfaceB =         "interface B #{SHAPE.B_DECL} {}";
+    
+    @SourceFile(value="A.java", group="B")
+    String interfaceA =         "interface A { static String m() { return \"A\"; } }";
+    
+    @SourceFile(value="C.java", group="B")
+    String classC = "#{SHAPE.C}";
+    
+    @SourceFile(value="Main.java", group="B")
+    String classMain = "public class Main {\n" +
+                       "    public String main() {\n" +
+                       "        return new C().m();\n" +
+                       "    }\n" +
+                       "}";
+
+    @Override
+    protected boolean shouldRun() { return true; }
+
+    @Override
+    protected void run(Class<?> clazz) throws ReflectiveOperationException {
+        Method m = clazz.getMethod("main");
+        Object obj = clazz.newInstance();
+        String result = null, output = null;
+        try {
+            result = (String) m.invoke(obj);
+        } catch (InvocationTargetException ex) {
+            output = ex.getCause().toString();
+        }
+        assertEquals(output, null);
+        assertEquals(result, "C");
+    }
+
+    /*
+     * In order for class Main to compile in group B, object of class C should have
+     * access to a method m(). Therefore, a method m() is needed in class C.
+     * static m() in interfaces A, B is not visible to C.
+     */
+    static String methodSig = "public String m () { return \"C\"; }"; 
+    enum CShapes implements Template { //shapes of class hierarchy
+        //class C implements interface A, B
+        C_AB("",
+           "class C implements A, B { " + methodSig + " }"), 
+        //class C implements interface B, B extends interface A
+        C_B_A("extends A",
+           "class C implements B { " + methodSig + " }"),
+        //class C implements interface AB, AB extends interface A, B
+        C_I_AB("",
+           "interface AB extends A, B {  }\n" +
+           "class C implements AB { " + methodSig + " }"),
+        //class C implements interface AB, AB extends interface A, B and defines its own static method 
+        C_I_AB2("",
+        "interface AB extends A, B { static String m() { return \"AB\"; } }\n" +
+        "class C implements AB { " + methodSig + " }"),
+        //class C extends Class D implements Interface B
+        C_CI("",
+            "class D { public String m() { return \"D\"; } }\n" +
+            "class C extends D implements B { " + methodSig + " }");
+
+        private final String sB_DECL;
+        private final String sC;
+
+        CShapes(String sB_DECL, String sC) {
+            this.sB_DECL = sB_DECL;
+            this.sC = sC;
+        }
+
+        public String expand(String selector) {
+            switch(selector) {
+                case "B_DECL": return sB_DECL;
+                case "C": return sC;
+                default: return toString();
+            }
+        }
+    }
+
+    enum AddType implements Template { // add by adding static method or abstract interface method
+        ADD("static String m() { return \"B\"; }"),
+        REDECLARE("String m();");
+
+        final String newCode;
+
+        AddType(String str) {
+            newCode = str;
+        }
+
+        public String expand(String selector) {
+            return newCode;
+        }
+    }
+}
+
--- a/make/common/internal/Defs-langtools.gmk	Thu Oct 31 16:44:18 2013 -0700
+++ b/make/common/internal/Defs-langtools.gmk	Mon Nov 11 23:17:30 2013 -0800
@@ -28,7 +28,8 @@
 IMPORT_RT_PACKAGES +=               \
       javax/annotation/processing   \
       javax/lang/model              \
-      javax/tools
+      javax/tools                   \
+      com/sun/runtime
 
 IMPORT_TOOLS_PACKAGES +=            \
       com/sun/javadoc               \
--- a/make/docs/NON_CORE_PKGS.gmk	Thu Oct 31 16:44:18 2013 -0700
+++ b/make/docs/NON_CORE_PKGS.gmk	Mon Nov 11 23:17:30 2013 -0800
@@ -84,6 +84,8 @@
 
 SCTPAPI_PKGS     = com.sun.nio.sctp
 
+LAMBDA_RTAPI     = com.sun.runtime
+
 ifeq ($(PLATFORM), macosx)
 APPLE_EXT_PKGS   = com.apple.concurrent   \
                    com.apple.eawt         \
@@ -101,5 +103,6 @@
                    $(HTTPSERVER_PKGS) \
                    $(SMARTCARDIO_PKGS) \
                    $(SCTPAPI_PKGS) \
+                   $(LAMBDA_RTAPI) \
                    $(APPLE_EXT_PKGS)
 
--- a/make/java/java/FILES_java.gmk	Thu Oct 31 16:44:18 2013 -0700
+++ b/make/java/java/FILES_java.gmk	Mon Nov 11 23:17:30 2013 -0800
@@ -300,12 +300,20 @@
 	java/util/EnumMap.java \
     java/util/Arrays.java \
     java/util/ArraysParallelSortHelpers.java \
+    java/util/ArrayPrefixHelpers.java \
+    java/util/ArraySortHelpers.java \
     java/util/DualPivotQuicksort.java \
     java/util/TimSort.java \
     java/util/ComparableTimSort.java \
+    java/util/Comparators.java \
     java/util/ConcurrentModificationException.java \
+    java/util/OptionalDouble.java \
+    java/util/OptionalInt.java \
+    java/util/Optional.java \
+    java/util/OptionalLong.java \
     java/util/ServiceLoader.java \
     java/util/ServiceConfigurationError.java \
+    java/util/StringJoiner.java \
     java/util/Timer.java \
     java/util/TimerTask.java \
     java/util/Objects.java \
@@ -334,6 +342,8 @@
     java/util/concurrent/CyclicBarrier.java \
     java/util/concurrent/DelayQueue.java \
     java/util/concurrent/Delayed.java \
+    java/util/concurrent/DoubleAdder.java \
+    java/util/concurrent/DoubleMaxUpdater.java \
     java/util/concurrent/Exchanger.java \
     java/util/concurrent/ExecutionException.java \
     java/util/concurrent/Executor.java \
@@ -348,6 +358,10 @@
     java/util/concurrent/LinkedBlockingDeque.java \
     java/util/concurrent/LinkedBlockingQueue.java \
     java/util/concurrent/LinkedTransferQueue.java \
+    java/util/concurrent/LongAdder.java \
+    java/util/concurrent/LongAdderTable.java \
+    java/util/concurrent/LongMaxUpdater.java \
+    java/util/concurrent/package-info.java \
     java/util/concurrent/Phaser.java \
     java/util/concurrent/PriorityBlockingQueue.java \
     java/util/concurrent/RecursiveAction.java \
@@ -360,6 +374,8 @@
     java/util/concurrent/ScheduledFuture.java \
     java/util/concurrent/ScheduledThreadPoolExecutor.java \
     java/util/concurrent/Semaphore.java \
+    java/util/concurrent/SequenceLock.java \
+    java/util/concurrent/Striped64.java \
     java/util/concurrent/SynchronousQueue.java \
     java/util/concurrent/ThreadFactory.java \
     java/util/concurrent/ThreadLocalRandom.java \
@@ -379,18 +395,17 @@
     java/util/concurrent/atomic/AtomicReferenceArray.java \
     java/util/concurrent/atomic/AtomicReferenceFieldUpdater.java \
     java/util/concurrent/atomic/AtomicStampedReference.java \
-    java/util/concurrent/atomic/DoubleAccumulator.java \
-    java/util/concurrent/atomic/DoubleAdder.java \
-    java/util/concurrent/atomic/LongAccumulator.java \
-    java/util/concurrent/atomic/LongAdder.java \
-    java/util/concurrent/atomic/Striped64.java \
+    java/util/concurrent/atomic/package-info.java \
+    java/util/concurrent/extra/AtomicDoubleArray.java \
+    java/util/concurrent/extra/AtomicDouble.java \
+    java/util/concurrent/extra/ReadMostlyVector.java \
     java/util/concurrent/locks/AbstractOwnableSynchronizer.java \
     java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java \
     java/util/concurrent/locks/AbstractQueuedSynchronizer.java \
-    java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java \
     java/util/concurrent/locks/Condition.java \
     java/util/concurrent/locks/Lock.java \
     java/util/concurrent/locks/LockSupport.java \
+    java/util/concurrent/locks/package-info.java \
     java/util/concurrent/locks/ReadWriteLock.java \
     java/util/concurrent/locks/ReentrantLock.java \
     java/util/concurrent/locks/ReentrantReadWriteLock.java \
--- a/make/java/java/Makefile	Thu Oct 31 16:44:18 2013 -0700
+++ b/make/java/java/Makefile	Mon Nov 11 23:17:30 2013 -0800
@@ -37,7 +37,7 @@
 JAVAC_MAX_WARNINGS=true
 include $(BUILDDIR)/common/Defs.gmk
 
-AUTO_FILES_JAVA_DIRS = java/util/function
+AUTO_FILES_JAVA_DIRS = java/util/concurrent java/util/function java/util/stream
 
 # windows compiler flags
 ifeq ($(PLATFORM),windows)
@@ -51,7 +51,7 @@
 OTHER_CFLAGS += -DJDK_MAJOR_VERSION='"$(JDK_MAJOR_VERSION)"' \
                 -DJDK_MINOR_VERSION='"$(JDK_MINOR_VERSION)"' \
                 -DJDK_MICRO_VERSION='"$(JDK_MICRO_VERSION)"' \
-                -DJDK_BUILD_NUMBER='"$(JDK_BUILD_NUMBER)"' 
+                -DJDK_BUILD_NUMBER='"$(JDK_BUILD_NUMBER)"'
 
 ifdef JDK_UPDATE_VERSION
 OTHER_CFLAGS += -DJDK_UPDATE_VERSION='"$(JDK_UPDATE_VERSION)"'
@@ -281,7 +281,7 @@
 $(GENSRCDIR)/java/lang/UNIXProcess.java: $(PLATFORM_UNIX_PROCESS)
 	$(install-file)
 
-clean:: 
+clean::
 	$(RM) $(GENSRCDIR)/java/lang/UNIXProcess.java
 
 endif
@@ -295,10 +295,10 @@
 #
 # Special rules.
 #
-clean:: 
+clean::
 	$(RM) -r $(CLASSHDRDIR)
 
-clobber:: 
+clobber::
 	$(RM) -r $(CLASSBINDIR)/java/io $(CLASSBINDIR)/java/lang \
 		$(CLASSBINDIR)/java/security $(CLASSBINDIR)/java/util \
 		$(CLASSBINDIR)/sun/misc
@@ -315,12 +315,6 @@
 CAL_PROPS = calendars.properties
 
 #
-# Rule to copy Hijrah-umalqura calendar properties file.
-#
-HIJRAH_UMALQURA_PROPS = hijrah-config-umalqura.properties
-
-
-#
 # Rule to copy tzmappings file on Windows
 #
 ifeq ($(PLATFORM), windows)
@@ -332,7 +326,7 @@
 	$(call chmod-file, 444)
 endif
 
-build: $(LIBDIR)/$(PROPS) $(LIBDIR)/$(CAL_PROPS) $(LIBDIR)/$(HIJRAH_UMALQURA_PROPS) $(TZMAP)
+build: $(LIBDIR)/$(PROPS) $(LIBDIR)/$(CAL_PROPS) $(TZMAP)
 
 $(LIBDIR)/$(PROPS): $(PLATFORM_SRC)/lib/$(PROPS)
 	$(install-file)
@@ -340,10 +334,7 @@
 $(LIBDIR)/$(CAL_PROPS): $(SHARE_SRC)/lib/$(CAL_PROPS)
 	$(install-file)
 
-$(LIBDIR)/$(HIJRAH_UMALQURA_PROPS): $(SHARE_SRC)/lib/$(HIJRAH_UMALQURA_PROPS)
-	$(install-file)
-
-clean:: 
+clean::
 	$(RM) -r $(LIBDIR)/$(PROPS) $(TZMAP)
 
 #
@@ -364,12 +355,12 @@
 	$(MV) $@.temp $@
 	$(call chmod-file, 444)
 
-clean:: 
+clean::
 	$(RM) $(CURDATA)
 
 
 #
-# Rules to create $(GENSRCDIR)/sun/lang/CharacterData*.java 
+# Rules to create $(GENSRCDIR)/sun/lang/CharacterData*.java
 #
 CHARACTERDATA = $(BUILDDIR)/tools/GenerateCharacter
 UNICODEDATA   = $(BUILDDIR)/tools/UnicodeData
@@ -424,12 +415,12 @@
 	$(install-file)
 
 clean::
-	$(RM) $(GENSRCDIR)/java/lang/CharacterDataLatin1.java 
+	$(RM) $(GENSRCDIR)/java/lang/CharacterDataLatin1.java
 	$(RM) $(GENSRCDIR)/java/lang/CharacterData00.java
-	$(RM) $(GENSRCDIR)/java/lang/CharacterData01.java 
+	$(RM) $(GENSRCDIR)/java/lang/CharacterData01.java
 	$(RM) $(GENSRCDIR)/java/lang/CharacterData02.java
 	$(RM) $(GENSRCDIR)/java/lang/CharacterData0E.java
-	$(RM) $(GENSRCDIR)/java/lang/CharacterDataUndefined.java 
+	$(RM) $(GENSRCDIR)/java/lang/CharacterDataUndefined.java
 	$(RM) $(GENSRCDIR)/java/lang/CharacterDataPrivateUse.java
 
 #
@@ -450,7 +441,7 @@
 	build.tools.generatecharacter.CharacterName \
 		$(UNICODEDATA)/UnicodeData.txt $(UNINAME)
 
-clean:: 
+clean::
 	$(RM) $(UNINAME)
 
 #
@@ -458,15 +449,15 @@
 #
 
 #
-# Rule to precompile CoreResourceBundleControl.java 
+# Rule to precompile CoreResourceBundleControl.java
 #
 LOCALES_GEN_SH = localelist.sh
 
 $(GENSRCDIR)/sun/util/CoreResourceBundleControl.java: \
 	$(SHARE_SRC)/classes/sun/util/CoreResourceBundleControl-XLocales.java.template $(LOCALES_GEN_SH)
-	@$(prep-target) 
+	@$(prep-target)
 	NAWK="$(NAWK)" SED="$(SED)" $(SH) $(LOCALES_GEN_SH) "$(JRE_NONEXIST_LOCALES)" \
-		$< $@ 
+		$< $@
 clean::
 	$(RM) $(GENSRCDIR)/sun/util/CoreResourceBundleControl.java
 
--- a/make/netbeans/common/shared.xml	Thu Oct 31 16:44:18 2013 -0700
+++ b/make/netbeans/common/shared.xml	Mon Nov 11 23:17:30 2013 -0800
@@ -77,10 +77,10 @@
         <echo level="verbose">System configuration claims architecture is ${platform}-${arch}</echo>
         <property name="build.dir" location="${root}/build/${platform}-${arch}"/>
         <property name="bin.dir" location="${build.dir}/bin"/>
-        <property name="make.dir" location="${root}/make"/> <!-- this is old build make files! -->
+        <property name="make.dir" location="${root}/makefiles"/>
         <property name="gensrc.dir" location="${build.dir}/gensrc"/>
         <property name="classes.dir" location="${build.dir}/classes"/>
-        <property name="jtreg.dir" location="${build.dir}/jtreg/${ant.project.name}"/>
+        <property name="jtreg.dir" location="${build.dir}/testoutput"/>
         <property name="dist.dir" value="${root}/dist"/>
         <property name="includes" value="(nothing)"/>
         <property name="excludes" value=""/>
--- a/make/org/Makefile	Thu Oct 31 16:44:18 2013 -0700
+++ b/make/org/Makefile	Mon Nov 11 23:17:30 2013 -0800
@@ -31,7 +31,7 @@
 PRODUCT = org
 include $(BUILDDIR)/common/Defs.gmk
 
-SUBDIRS = ietf jcp
+SUBDIRS = asm ietf jcp
 include $(BUILDDIR)/common/Subdirs.gmk
 
 all build clean clobber::
--- a/src/share/classes/sun/reflect/NativeConstructorAccessorImpl.java	Thu Oct 31 16:44:18 2013 -0700
+++ b/src/share/classes/sun/reflect/NativeConstructorAccessorImpl.java	Mon Nov 11 23:17:30 2013 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2013, 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
@@ -26,6 +26,7 @@
 package sun.reflect;
 
 import java.lang.reflect.*;
+import sun.reflect.misc.ReflectUtil;
 
 /** Used only for the first few invocations of a Constructor;
     afterward, switches to bytecode-based implementation */
@@ -44,7 +45,11 @@
                IllegalArgumentException,
                InvocationTargetException
     {
-        if (++numInvocations > ReflectionFactory.inflationThreshold()) {
+        // We can't inflate a constructor belonging to a vm-anonymous class
+        // because that kind of class can't be referred to by name, hence can't
+        // be found from the generated bytecode.
+        if (++numInvocations > ReflectionFactory.inflationThreshold()
+                && !ReflectUtil.isVMAnonymousClass(c.getDeclaringClass())) {
             ConstructorAccessorImpl acc = (ConstructorAccessorImpl)
                 new MethodAccessorGenerator().
                     generateConstructor(c.getDeclaringClass(),
--- a/src/share/classes/sun/reflect/NativeMethodAccessorImpl.java	Thu Oct 31 16:44:18 2013 -0700
+++ b/src/share/classes/sun/reflect/NativeMethodAccessorImpl.java	Mon Nov 11 23:17:30 2013 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2013, 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
@@ -26,6 +26,7 @@
 package sun.reflect;
 
 import java.lang.reflect.*;
+import sun.reflect.misc.ReflectUtil;
 
 /** Used only for the first few invocations of a Method; afterward,
     switches to bytecode-based implementation */
@@ -42,7 +43,11 @@
     public Object invoke(Object obj, Object[] args)
         throws IllegalArgumentException, InvocationTargetException
     {
-        if (++numInvocations > ReflectionFactory.inflationThreshold()) {
+        // We can't inflate methods belonging to vm-anonymous classes because
+        // that kind of class can't be referred to by name, hence can't be
+        // found from the generated bytecode.
+        if (++numInvocations > ReflectionFactory.inflationThreshold()
+                && !ReflectUtil.isVMAnonymousClass(method.getDeclaringClass())) {
             MethodAccessorImpl acc = (MethodAccessorImpl)
                 new MethodAccessorGenerator().
                     generateMethod(method.getDeclaringClass(),
--- a/src/share/classes/sun/reflect/misc/ReflectUtil.java	Thu Oct 31 16:44:18 2013 -0700
+++ b/src/share/classes/sun/reflect/misc/ReflectUtil.java	Mon Nov 11 23:17:30 2013 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2013, 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
@@ -298,4 +298,13 @@
         }
         return false;
     }
+
+    /**
+     * Checks if {@code Class cls} is a VM-anonymous class
+     * as defined by {@link sun.misc.Unsafe#defineAnonymousClass}
+     * (not to be confused with a Java Language anonymous inner class).
+     */
+    public static boolean isVMAnonymousClass(Class<?> cls) {
+        return cls.getSimpleName().contains("/");
+    }
 }
--- a/src/share/lib/security/java.security-linux	Thu Oct 31 16:44:18 2013 -0700
+++ b/src/share/lib/security/java.security-linux	Mon Nov 11 23:17:30 2013 -0800
@@ -199,14 +199,12 @@
                com.sun.org.apache.xalan.internal.xsltc.trax.,\
                com.sun.org.apache.xalan.internal.xsltc.util.,\
                com.sun.org.apache.xml.internal.res.,\
-               com.sun.org.apache.xml.internal.security.,\
                com.sun.org.apache.xml.internal.serializer.utils.,\
                com.sun.org.apache.xml.internal.utils.,\
                com.sun.org.glassfish.,\
                com.oracle.xmlns.internal.,\
                com.oracle.webservices.internal.,\
 	       oracle.jrockit.jfr.,\
-               org.jcp.xml.dsig.internal.,\
                jdk.internal.,\
                jdk.nashorn.internal.,\
                jdk.nashorn.tools.
@@ -245,14 +243,12 @@
                    com.sun.org.apache.xalan.internal.xsltc.trax.,\
                    com.sun.org.apache.xalan.internal.xsltc.util.,\
                    com.sun.org.apache.xml.internal.res.,\
-                   com.sun.org.apache.xml.internal.security.,\
                    com.sun.org.apache.xml.internal.serializer.utils.,\
                    com.sun.org.apache.xml.internal.utils.,\
                    com.sun.org.glassfish.,\
                    com.oracle.xmlns.internal.,\
                    com.oracle.webservices.internal.,\
 		   oracle.jrockit.jfr.,\
-                   org.jcp.xml.dsig.internal.,\
                    jdk.internal.,\
                    jdk.nashorn.internal.,\
                    jdk.nashorn.tools.
--- a/src/share/native/common/check_code.c	Thu Oct 31 16:44:18 2013 -0700
+++ b/src/share/native/common/check_code.c	Mon Nov 11 23:17:30 2013 -0800
@@ -1307,7 +1307,10 @@
                    && clazz_info != context->currentclass_info
                    && clazz_info != context->superclass_info) {
                 int not_found = 1;
-
+                jclass cb = object_fullinfo_to_classclass(context, clazz_info);
+                int is_interface = cb && JVM_IsInterface(env, cb);
+
+                if (!is_interface) {
                 jclass super = (*env)->GetSuperclass(env, context->class);
                 while(super != 0) {
                     jclass tmp_cb;
@@ -1335,6 +1338,7 @@
                 }
             }
         }
+        }
         if (opcode == JVM_OPC_invokeinterface) {
             unsigned int args1;
             unsigned int args2;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/README	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,20 @@
+Running the TestNG based unit tests requires downloading the TestNG
+library and placing its jar file into the lib subdirectory:
+
+   # download and install TestNG
+   wget http://testng.org/testng-x.y.z.zip
+   unzip testng-x.y.z.zip
+   mkdir lib
+   cp testng-x.y.z/testng.jar lib
+
+   # run tests
+   ant test
+
+This will fail with a message like
+
+    taskdef class org.testng.TestNGAntTask cannot be found
+
+if the TestNG jar file is not installed properly or if the wrong
+version is present. (Check build.xml to find the version of TestNG
+that is required.)  Only the jar file is necessary. The unzipped
+hierarchy can be removed.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/agent/Readme	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,118 @@
+To run this:
+   1.  unzip the bundle to a dir called agent (you should have already done 
+       so, to be reading this)
+   2.  have the latest version of lambda repo built fully and in your PATH
+   3.  you can use the pre-built dist/SerializationInjector.jar if not you
+       can build it with "ant -f agent/make/build.xml dist"
+   4.  before running this modify the conf/agent.props if required, but not
+       necessary.
+   5.  At the time of this writing only test-ng's test-libs are supported.
+
+       make the following changes in the lambda/jdk/test-ng/build.xml
+       for the test-libs target, you might want to bump the heap from 2g
+       to 4g if your choice of platform and the JVM allows.
+
+       <jvmarg value="-javaagent:/YOUR_PATH/agent/dist/SerializationInjectorAgent.jar=/YOUR_PATH/agent/conf/agent.props"/>
+
+       actual patch shown in appendix
+
+   6.  to run simply run the test-ng test as "ant test-libs"
+       Note: make sure are running with the very latest lambda build
+   7.  what you expect to see is in the Appendix.
+       Note: you will see on failure which is a serialization negative test
+
+Details:
+Directory structure:
+    src   - containing the sources
+    build - intermediate classes
+    dist  - jar used as an agent
+    make  - build.xml and an nbproject, feel free to modify it
+            requires jdk8 with asm that recognizes v52.0 classfiles
+    conf  - config files
+
+Description of sources:
+    Agent.java: installs an agent.
+    SerializationInjector: does the following
+       * parses properties and initializes the output
+       * initialize and install the VM shutdown hook, to print the test
+         statistics.
+       * using asm interrogates the target class, upon encountering an
+         indy, will save the params, invokes the indy, and restores the
+         original args to the indy 
+       * invoke the indy
+       * invoke the SerializeAndDeserializeTest (SAND).
+         with the lambdaObject returned by the indy and the
+         non-primitive parameters and these will be passed to SAND.
+	     Primitives are excluded
+     TestLambdaSerialization:
+       * the SAND will check the arguments if they are Serializable, if so,
+         then the LamdbaObject will be Serialized and Deserialized, and the 
+         deserialized LambdaObject will be returned, otherwise the original
+         LambdaObject will be returned,  the outcome and exception if any 
+         will be recorded.
+         
+         The final report will be printed out when the JVM terminates.
+     
+Running the agent:
+java -jar path_to/jtreg.jar \
+     -javaoption:"-javaagent:path_to/agent/dist/SerializationInjectorAgent.jar=/w/ksrini/Lambda/agent.props" \
+     test/foo/Lambda2.java
+
+agent.props is a property file by which one can specify
+   * a regular expression to exclude classes
+   * specify an output file to log details
+   * specifiy debugging if required
+
+ex:
+com.oracle.lambda.exclude.files=^java.*|^sun.misc.*|^javax.*
+com.oracle.lambda.log.file=some_path/agent.log
+com.oracle.lambda.debug=true
+
+A note about logfiles, the agent is installed into jtreg, however jtreg
+may invoke a test in a different VM as specified by the test and/or command
+line. 
+
+Thus if a file exists the agent will create a unique file in the specified 
+directory. Therefore it is recommended that the desired output directory is
+clean before starting a new test.
+
+
+Appendix:
+
+1. Patch to install the agent into test-ng
+diff --git a/test-ng/build.xml b/test-ng/build.xml
+--- a/test-ng/build.xml
++++ b/test-ng/build.xml
+@@ -55,6 +56,7 @@
+             <jvmarg value="-esa" />
+             <jvmarg value="-Xverify:all" />
+             <jvmarg value="-Xmx2g" />
++            <jvmarg value="-javaagent:/YOUR_PATH/agent/dist/SerializationInjectorAgent.jar=/YOUR_PATH/agent/conf/agent.props"/>
+         </testng>
+     </target>
+
+
+2. sample log
+[testng] [TestNG] Running:
+   [testng]   Ant suite
+   [testng]
+   [testng]
+   [testng] ===============================================
+   [testng] Ant suite
+   [testng] Total tests run: 7338, Failures: 1, Skips: 0
+   [testng] ===============================================
+   [testng]
+   [testng] Lambda Serialization Test Status:
+   [testng]   success: 2432727
+   [testng]   failed : 1099035
+   [testng] Non Serializable Class(es):
+   [testng]   NonSerializableObject: java.util.stream.op.Nodes$ArrayNode [92]
+   [testng] Throwable:
+   [testng]   null
+   [testng]
+   [testng]   NonSerializableObject: java.util.stream.op.Nodes$ConcNode [71]
+   [testng] Throwable:
+   [testng]   null
+   [testng]
+   [testng]   NonSerializableObject: org.openjdk.tests.java.util.stream.op.Group
+........
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/agent/conf/agent.props	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,6 @@
+#com.oracle.lambda.exclude.files=java..*|sun.*|javax.*|org.testng.*|com.google.*|com.sun.tools.javac.*|.*javatest.*|com.sun.tools.classfile.*|com.beust.*|.*TTShape.*|.*TestHarness.*
+#com.oracle.lambda.log.file=/tmp/agent_log/agent.log
+#com.oracle.lambda.debug=true
+#com.oracle.lambda.serialize.file=$CUSTOM/serialize.list
+com.oracle.lambda.storeStackTraces=true
+#com.oracle.lambda.deserialization.workaround=true
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/agent/conf/serialize.list	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,59 @@
+java/lang/invoke/MagicLambdaImpl
+java/util/Optional
+java/util/OptionalDouble
+java/util/OptionalLong
+java/util/OptionalInt
+java/util/Spliterator
+java/util/ArrayList\$SubList
+java/util/SubList
+java/util/RandomAccessSubList
+java/util/HashMap\$.*Spliterator
+java/util/TreeMap\$.*Spliterator
+java/util/function/Function\$\$Lambda.*
+java/util/function/Functions\$\$Lambda.*
+java/util/stream/Collectors.*
+java/util/stream/LambdaTestHelpers\$\$Lambda.*
+java/util/stream/Nodes.*NodeBuilder
+java/util/stream/Nodes\$.*Node
+java/util/stream/AbstractSpinedBuffer
+java/util/stream/SpinedBuffer
+java/util/stream/.*Pipeline
+java/util/stream/AbstractPipeline\$.*
+java/util/stream/IntermediateOp
+java/util/stream/.*StreamTestData\$.*
+java/util/stream/.*NodeTest
+java/util/stream/TestData\$AbstractTestData.*
+org/openjdk/tests/java/util/stream/OpTestCase\$TestData
+org/openjdk/tests/java/util/stream/OpTestCase\$ExerciseDataStreamBuilder
+org/openjdk/tests/java/util/stream/OpTestCase\$ExerciseDataTerminalBuilder
+org/openjdk/tests/java/util/stream/IntNodeTest
+org/openjdk/tests/java/util/stream/UnorderedStreamTest
+org/openjdk/tests/java/util/stream/GroupByOpTest
+org/openjdk/tests/java/util/stream/TabulatorsTest
+org/openjdk/tests/java/util/stream/TabulatorsTest\$.*Assertion
+org/openjdk/tests/java/util/stream/StreamLinkTest
+org.openjdk.tests.java.util.stream.SpliteratorLateBindingFailFastTest\$SpliteratorDataBuilder.*
+org.openjdk.tests.java.util.stream.SpliteratorTraversingAndSplittingTest\$SpliteratorDataBuilder.*
+org.openjdk.tests.java.util.stream.SliceOpTest.*
+org.openjdk.tests.java.util.stream.MatchOpTest.*
+org.openjdk.tests.java.util.stream.InfiniteStreamWithLimitOpTest.*
+java.util.HashMap\$Values
+java.util.LinkedHashMap\$KeyIterator
+java.util.HashMap\$Entry
+java.util.LinkedList\$Node
+java.util.TreeMap\$Entry
+java.util.HashMap\$EntrySet
+java.util.HashMap\$KeySet 
+java.util.IdentityHashMap\$KeySet
+java.util.LinkedHashMap\$ValueIterator
+java.util.TreeMap\$KeySet
+java.util.TreeMap\$EntrySet
+java.util.TreeMap\$Values
+java.util.WeakHashMap
+java.util.WeakHashMap\$EntrySet
+java.util.WeakHashMap\$KeySet
+java.util.WeakHashMap\$Values
+java.util.LinkedHashMap\$EntryIterator
+java.util.IdentityHashMap\$EntrySet
+java.util.IdentityHashMap\$Values
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/agent/make/build.xml	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,75 @@
+<project name="SerializationInjectorAgent" default="dist" basedir="..">
+  <!-- Requires ant 1.6.1+ and Lambda (NOT TL)+-->
+
+  <!-- set global properties for this build -->
+  <property name="build.sysclasspath" value="ignore"/>
+  <property name="build.dir" value="../../../build/test-ng/agent" />
+  <property name="src"      value="${basedir}/src"/>
+  <property name="make"     value="${basedir}/make"/>
+  <property name="conf"     value="${basedir}/conf"/>
+  <property name="classes"  value="${build.dir}/classes"/>
+  <property name="dist"     value="${build.dir}/dist"/>
+
+  <target name="init">
+    <!-- Create the time stamp -->
+    <tstamp/>
+    <!-- Create the build directory structure used by compile -->
+    <mkdir dir="${build.dir}"/>
+    <mkdir dir="${dist}"/>
+    <mkdir dir="${classes}"/>
+    <echo message="${java.home}"/>
+  </target>
+
+  <target name="compile" depends="init">
+    <!-- Compile the java code from ${src} into ${build} -->
+    <javac 
+	source="1.7"
+	srcdir="${src}"
+	destdir="${build.dir}/classes"
+	verbose="no"
+	debug="on"
+    >
+    <compilerarg value="-XDignore.symbol.file=true"/>
+    </javac>
+  </target>
+  <target name="dist" depends="compile">
+    <!-- Put everything in jar file -->
+    <jar destfile="${dist}/SerializationInjectorAgent.jar">
+	<manifest>
+	   <attribute name="Main-Class" value="com.oracle.lambda.Main"/>
+           <attribute name="PreMain-Class" value="com.oracle.lambda.Agent"/>
+	</manifest>
+	<fileset dir="${classes}"/>
+    </jar>
+  </target>
+  <target name="run" depends="dist">
+    <condition property="run.arg" value="-o /tmp/ksrini/XX.jar -f /w/ksrini/JDK/hg-lambda/jdk8/jdk/test-ng/serialize.list /tmp/ksrini/rt.jar">
+        <not>
+            <isset property="run.arg"/>
+        </not> 
+    </condition>
+    <java jar="${dist}/SerializationInjectorAgent.jar"
+        dir="."
+        fork="true"  
+    >
+   <jvmarg value="-Dcom.oracle.lambda.debug=true"/>
+   <arg value="${run.arg}"/>
+    </java>
+  </target>
+  <target name="clean">
+    <!-- Delete the ${build} and ${dist} directory trees -->
+    <delete dir="${build}"/>
+    <delete dir="${dist}"/>
+  </target>
+  <target name="bundle" depends="clean, dist">
+      <zip destfile="${dist}/bundle.zip">
+          <zipfileset dir="${src}"/>
+          <zipfileset file="${dist}/SerializationInjectorAgent.jar"/>
+          <zipfileset dir="${make}" excludes="**/netbeans/**"/>
+          <zipfileset dir="${conf}"/>
+          <zipfileset file="Readme"/>
+      </zip>
+      
+  </target>
+
+</project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/agent/src/com/oracle/lambda/Agent.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2012, 2013, 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
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.lambda;
+
+import java.io.IOException;
+import java.lang.instrument.ClassFileTransformer;
+import java.lang.instrument.IllegalClassFormatException;
+import java.lang.instrument.Instrumentation;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.security.ProtectionDomain;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.TreeSet;
+
+public class Agent {
+    public static void premain(String agentArgs, Instrumentation instrumentation)
+            throws IOException, NoSuchFieldException, IllegalAccessException {
+        // If run without a config file, all we do is set up the shutdown hook
+        if (agentArgs != null) {
+            final SerializationInjector si = new SerializationInjector();
+            instrumentation.addTransformer(new ClassFileTransformer() {
+                @Override
+                public byte[] transform(final ClassLoader cl, String string,
+                                        Class<?> type, ProtectionDomain pd,
+                                        byte[] bytes) throws IllegalClassFormatException {
+                    return si.transformClass(cl, bytes, EnumSet.noneOf(SerializationInjector.Options.class));
+                }
+            });
+        }
+        else {
+            // Horrible horrible hack.
+            // TreeSet/HashSet are based off of HashSet/HashMap, and serializing their spliterators
+            // tries to serialize the underlying map, which uses a non-serializable sentinel object.
+            // This hack swaps that out for a serializable sentinel
+            Field f = HashSet.class.getDeclaredField("PRESENT");
+            f.setAccessible(true);
+            Field modifiersField = Field.class.getDeclaredField("modifiers");
+            modifiersField.setAccessible(true);
+            modifiersField.setInt(f, f.getModifiers() & ~Modifier.FINAL);
+            f.set(null, Boolean.TRUE);
+
+            f = TreeSet.class.getDeclaredField("PRESENT");
+            f.setAccessible(true);
+            modifiersField.setInt(f, f.getModifiers() & ~Modifier.FINAL);
+            f.set(null, Boolean.TRUE);
+
+            TestLambdaSerialization.initializeShutDownHook();
+        }
+    }
+ }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/agent/src/com/oracle/lambda/Main.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,196 @@
+/*
+ * Copyright (c) 2012, 2013, 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
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.lambda;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.file.DirectoryStream;
+import java.nio.file.FileSystem;
+import java.nio.file.FileSystems;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.attribute.FileAttribute;
+import java.nio.file.attribute.PosixFilePermission;
+import java.nio.file.attribute.PosixFilePermissions;
+import java.util.Collections;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.regex.Pattern;
+
+import jdk.internal.org.objectweb.asm.ClassReader;
+import static java.nio.file.StandardOpenOption.*;
+import static java.nio.file.StandardCopyOption.*;
+
+/**
+ *
+ * @author kumasrin
+ */
+public class Main {
+
+    static void usage() {
+        System.out.println("usage: -o output_dir path_to/SomeClass.class");
+        System.out.println("usage: -o output_dir path_to_classes");
+        System.out.println("usage: -o output_dir -s path_to_jar");
+        System.exit(1);
+    }
+
+    /*
+     * a standalone tester for this
+     */
+    public static void main(String... inargs) throws Exception {
+        String[] args = inargs;
+        if (inargs != null && inargs.length == 1) {
+            args = inargs[0].split("\\s");
+        }
+        if (args == null || args.length < 3) {
+            usage();
+        }
+        File outDir = null;
+        File inFile = null;
+        boolean serializeOnly = false;
+        for (int i = 0 ; i < args.length ; i++) {
+            switch (args[i]) {
+                case "-o":
+                    i++;
+                    outDir = new File(args[i]);
+                    break;
+                case "-s":
+                    serializeOnly = true;
+                    break;
+                default:
+                    inFile = new File(args[i]);
+            }
+        }
+        if (inFile.isDirectory()) {
+            if (outDir.exists()) {
+                outDir.mkdirs();
+            }
+            URL[] urls = {inFile.toURI().toURL()};
+            ClassLoader cl = new URLClassLoader(urls, ClassLoader.getSystemClassLoader());
+            try (DirectoryStream<Path> paths =
+                    Files.newDirectoryStream(inFile.toPath(), "*")) {
+                for (Path p : paths) {
+                    doFile(inFile, outDir, p.toFile(), cl);
+                }
+            }
+        } else if (inFile.getName().endsWith(".jar")) {
+            if (outDir.exists()) {
+                outDir.mkdirs();
+            }
+            URL[] urls = {inFile.toURI().toURL()};
+            ClassLoader cl = new URLClassLoader(urls, ClassLoader.getSystemClassLoader());
+            Pattern pattern = Pattern.compile(".*");
+            EnumSet<SerializationInjector.Options> options
+                    = serializeOnly ? EnumSet.of(SerializationInjector.Options.SERIALIZE_ONLY) : EnumSet.noneOf(SerializationInjector.Options.class);
+            doJar(inFile, outDir, cl, pattern, options);
+        } else {
+            outDir.mkdirs();
+            URL[] urls = {inFile.getParentFile().toURI().toURL()};
+            ClassLoader cl = new URLClassLoader(urls, ClassLoader.getSystemClassLoader());
+            doFile(null, outDir, inFile, cl);
+        }
+    }
+    static void copyStream(InputStream in, OutputStream out) throws IOException {
+        byte[] buf = new byte[8192];
+        int n = in.read(buf);
+        while (n > 0) {
+            out.write(buf, 0, n);
+            n = in.read(buf);
+        }
+    }
+
+    static byte[] readFully(InputStream is) throws IOException {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        copyStream(is, baos);
+        return baos.toByteArray();
+    }
+
+    static void doJar(File inFile, File outDir, ClassLoader cl, Pattern pattern,
+                      EnumSet<SerializationInjector.Options> options) throws IOException {
+        JarFile jf = new JarFile(inFile);
+        byte[] buffer;
+        SerializationInjector si = new SerializationInjector();
+        FileSystem fs = null;
+        boolean jarOut = outDir.getName().endsWith(".jar");
+        Set<PosixFilePermission> perms = PosixFilePermissions.fromString("rwxrwxrwx");
+        FileAttribute<Set<PosixFilePermission>> attr =
+                PosixFilePermissions.asFileAttribute(perms);
+        Map<String, String> env = new HashMap<>();
+        env.put("create", "true");
+        if (jarOut) {
+            URI uri = URI.create("jar:file:" + outDir.getAbsolutePath());
+            if (outDir.exists())
+                outDir.delete();
+            fs = FileSystems.newFileSystem(uri, env);
+        } else {
+            fs = FileSystems.getDefault();
+        }
+        for (JarEntry je : Collections.list(jf.entries())) {
+            String fname = je.getName();
+            if (fname.endsWith("/")) continue;
+            if (pattern.matcher(fname).matches()) {
+                buffer = readFully(jf.getInputStream(je));
+                if (fname.endsWith(".class"))
+                    buffer = si.transformClass(cl, buffer, options);
+                Path opath = jarOut ? fs.getPath(fname) : fs.getPath(outDir.getAbsolutePath(), fname);
+                Files.createDirectories(opath.getParent(), attr);
+                Files.write(opath, buffer, CREATE, TRUNCATE_EXISTING);
+            }
+        }
+        if (jarOut)
+            fs.close();
+    }
+
+    static String getRelativePath(File baseDir, File inFile) {
+        String bname = baseDir.getAbsolutePath();
+        String fname = inFile.getAbsolutePath();
+        return fname.substring(bname.length() + 1);
+    }
+
+    static void doFile(File inDir, File outDir, File iFile, ClassLoader cl) throws Exception {
+        if (!iFile.getName().endsWith(".class")) {
+            Path p = new File(getRelativePath(inDir, iFile)).toPath();
+            Files.copy(iFile.toPath(), p, COPY_ATTRIBUTES, REPLACE_EXISTING);
+            return;
+        }
+        byte[] classBuffer = Files.readAllBytes(iFile.toPath());
+        ClassReader cr = new ClassReader(classBuffer);
+        File oFile = new File(outDir, cr.getClassName() + ".class");
+        SerializationInjector si = new SerializationInjector();
+        System.err.print("Transforming: " + iFile.getAbsolutePath());
+        System.err.println(" to: " + oFile.getAbsolutePath());
+        oFile.getParentFile().mkdirs();
+        Files.write(oFile.toPath(),
+                si.transformClass(cl, classBuffer, EnumSet.noneOf(SerializationInjector.Options.class)), CREATE, TRUNCATE_EXISTING);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/agent/src/com/oracle/lambda/SerializationInjector.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,399 @@
+/*
+ * Copyright (c) 2012, 2013, 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
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.lambda;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.regex.Pattern;
+
+import jdk.internal.org.objectweb.asm.ClassReader;
+import jdk.internal.org.objectweb.asm.ClassVisitor;
+import jdk.internal.org.objectweb.asm.ClassWriter;
+import jdk.internal.org.objectweb.asm.Handle;
+import jdk.internal.org.objectweb.asm.MethodVisitor;
+import static jdk.internal.org.objectweb.asm.Opcodes.*;
+import jdk.internal.org.objectweb.asm.Type;
+
+import static java.nio.file.StandardOpenOption.*;
+
+
+public class SerializationInjector {
+    static final String PREFIX = "com.oracle.lambda";
+    static final String INCLUDES = "java.util.*|org.openjdk.tests.java.*"; // also should include java.util...
+    static final String SERIALIZE = "";
+
+    // properties that can be set
+    static final String INCLUDE_FILES  = PREFIX + ".include.files";
+    static final String SERIALIZE_FILE = PREFIX + ".serialize.file";
+    static final String STORE_FRAMES   = PREFIX + ".store.frames";
+    static final String LOGFILE        = PREFIX + ".log.file";
+    static final String DEBUG          = PREFIX + ".debug";
+    static final String NROUNDS        = PREFIX + ".nrounds";
+
+    static boolean storeFrames = true;
+    static boolean deserializationWorkaround;
+
+    final DebugPrint debug;
+    final Pattern includePattern;
+    final Pattern serializePattern;
+    final boolean serializeOnly;
+
+    public enum Options { SERIALIZE_ONLY, FORCE_SERIALIZE }
+
+    public SerializationInjector() throws IOException {
+        includePattern   = propToPattern(INCLUDE_FILES, INCLUDES);
+        serializePattern = fileToPattern(SERIALIZE_FILE, SERIALIZE);
+        debug = new DebugPrint();
+        TestLambdaSerialization.initializeShutDownHook();
+        storeFrames = Boolean.getBoolean(STORE_FRAMES);
+        deserializationWorkaround = false;
+        serializeOnly = false;
+    }
+    final Pattern propToPattern(String propKey, String defValue) {
+        return Pattern.compile(System.getProperty(propKey, defValue));
+    }
+    final Pattern fileToPattern(String propKey, String defValue) throws IOException {
+        String fname = System.getProperty(propKey, null);
+        if (fname != null) {
+            File pFile = new File(fname);
+            if (pFile.canRead()) {
+                return fileToPattern(pFile);
+            }
+        }
+        return Pattern.compile(defValue);
+    }
+    final Pattern fileToPattern(File inFile) throws IOException {
+        List<String> serList = Files.readAllLines(inFile.toPath(),
+                Charset.defaultCharset());
+        String regStr = "";
+        boolean first = true;
+        for (String s : serList) {
+            String x = s.trim();
+            if (x.startsWith("#")) {
+                continue;
+            }
+            regStr = regStr.concat((first ? "" : "|") + x);
+            first = false;
+        }
+        System.out.println("serialization: " + regStr);
+        return Pattern.compile(regStr);
+    }
+
+    byte[] transformClass(ClassLoader cl, byte[] classBuffer, EnumSet<Options> options) {
+        byte[] xBuffer = classBuffer;
+        ClassReader classReader = new ClassReader(xBuffer);
+        String cname = classReader.getClassName();
+
+        if (options.contains(Options.FORCE_SERIALIZE) || serializePattern.matcher(cname).matches()) {
+            debug.println("Implementing Serialization: " + cname);
+            xBuffer = injectSerialization(xBuffer, cl);
+        }
+        if (serializeOnly || options.contains(Options.SERIALIZE_ONLY)) {
+            return xBuffer;
+        }
+        if (!includePattern.matcher(cname).matches()) {
+            debug.println("Excluding SAND: " + cname);
+            return xBuffer;
+        }
+        debug.println("Visiting: " + cname);
+        return injectSAND(xBuffer, cl);
+    }
+
+    byte[] injectSAND(byte[] classBuffer, ClassLoader cl) {
+        Map<String, Integer> locals = getLocals(classBuffer);
+        ClassReader classReader = new ClassReader(classBuffer);
+        ClassWriter classWriter = new ClassWriter(classReader,
+                ClassWriter.COMPUTE_MAXS /*| ClassWriter.COMPUTE_FRAMES*/);
+        classReader.accept(makeSANDVisitor(classWriter, locals), 0);
+        byte[] byteArray = classWriter.toByteArray();
+//        CheckClassAdapter.verify(new ClassReader(byteArray), cl, false,
+//                                 new PrintWriter(System.err));
+        return byteArray;
+    }
+
+    Map<String, Integer> getLocals(byte[] classBuffer) {
+        ClassReader cr = new ClassReader(classBuffer);
+        final Map<String, Integer> locals = new HashMap<>();
+        cr.accept(new ClassVisitor(ASM4, null) {
+            String cname;
+            @Override
+            public void visit(int version, int access, String name,
+                    String signature, String superName,
+                    String[] interfaces) {
+                cname = name;
+                super.visit(version, access, name, signature, superName, interfaces);
+            }
+            @Override
+            public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
+                final String mid = cname + "+" + name + "+" + desc + "+" + signature;
+                return new MethodVisitor(ASM4,
+                        super.visitMethod(access, name, desc, signature, exceptions)) {
+                    @Override
+                    public void visitMaxs(int maxStack, int maxLocals) {
+                        super.visitEnd();
+                        super.visitMaxs(maxStack, maxLocals);
+                        //debug.println("Pre-Visiting:" + mid + ", stack=" + maxLocals);
+                        locals.put(mid, maxLocals);
+                    }
+                };
+            }
+        }, 0);
+
+        return locals;
+    }
+
+    ClassVisitor makeSANDVisitor(ClassWriter cw, final Map<String, Integer>methodLocals) {
+        return new ClassVisitor(ASM4, cw) {
+            String cname = null;
+            @Override
+            public void visit(int version, int access, String name,
+                              String signature, String superName,
+                              String[] interfaces) {
+                cname = name;
+                super.visit(version, access, name, signature, superName, interfaces);
+            }
+            @Override
+            public MethodVisitor visitMethod(int access, final String name,
+                                             final String desc, final String signature,
+                                             String[] exceptions) {
+                if (name.equals("$deserializeLambda$")) {
+                    return super.visitMethod(access, name, desc, signature, exceptions);
+                }
+                return new MethodVisitor(ASM4,
+                        super.visitMethod(access, name, desc, signature, exceptions)) {
+                    final String mid = cname + "+" + name + "+" + desc + "+" + signature;
+                    int locals = methodLocals.containsKey(mid) ? methodLocals.get(mid) : 0;
+
+                    int saveArgs(Type[] types) {
+                        final int n = locals + 1;
+                        final int tlen = types.length;
+                        int count = 0;
+                        // store in LIFO order
+                        for (int i = 0; i < tlen; i++) {
+                            int pos = tlen - 1 - i;
+                            super.visitVarInsn(types[pos].getOpcode(ISTORE), n + pos);
+                        }
+                        // restore back in  FIFO order
+                        for (int i = 0 ; i < tlen; i++) {
+                            if (isNotPrimitive(types[i])) {
+                                count++;
+                            }
+                            super.visitVarInsn(types[i].getOpcode(ILOAD), n + i);
+                        }
+                        return count;
+                    }
+                    boolean isNotPrimitive(Type t) {
+                        int i = t.getSort();
+                        return i == Type.OBJECT || i == Type.ARRAY;
+                    }
+                    void restoreArgs(Type[] types, int count) {
+                        final int n = locals + 1;
+                        final int tlen = types.length;
+                        // create the array
+                        visitIntInsn(BIPUSH, count);
+                        visitTypeInsn(ANEWARRAY, "java/lang/Object");
+                        int ncount = 0;
+                        for (int i = 0 ; i < tlen ; i++ ) {
+                            Type t = types[i];
+                            if (isNotPrimitive(t)) {
+                                debug.println("injecting:" + t);
+                                super.visitInsn(DUP);
+                                super.visitIntInsn(BIPUSH, ncount);
+                                super.visitVarInsn(t.getOpcode(ILOAD), n + i);
+                                super.visitInsn(AASTORE);
+                                ncount++;
+                            }
+                        }
+                    }
+                    @Override
+                    public void visitInvokeDynamicInsn(String callsite,
+                            String sig, Handle handle, Object... bsmArgs) {
+                        // instrument  only! lambda objects
+                        final boolean needsTransform = handle.getName().equals("metafactory");
+                        final boolean injectSand = needsTransform ||
+                                handle.getName().equals("altMetafactory");
+                        if (!injectSand) {
+                            super.visitInvokeDynamicInsn(callsite, sig, handle, bsmArgs);
+                            return;
+                        }
+                        debug.println("indy:" + mid + ", locals = " + locals);
+                        debug.println("  fixing: " + callsite + ":" + sig);
+                        Handle nHandle = handle;
+                        Object[] nbsmArgs = bsmArgs;
+                        if (needsTransform) {
+                            String ndesc = "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite;";
+                            nHandle =  new Handle(handle.getTag(), handle.getOwner(),
+                                    "altMetafactory", ndesc);
+
+                            ArrayList<Object> largs = new ArrayList<>(Arrays.asList(bsmArgs));
+                            largs.add(1);
+                            largs.add(Type.getType(java.io.Serializable.class));
+                            nbsmArgs = new Object[largs.size()];
+                            largs.toArray(nbsmArgs);
+                            debug.println("old: " + handle.toString());
+                            debug.println("new: " + nHandle.toString());
+                        }
+                        Type[] types = Type.getArgumentTypes(sig);
+                        int count = saveArgs(types);
+                        super.visitInvokeDynamicInsn(callsite, sig, nHandle, nbsmArgs);
+                        restoreArgs(types, count);
+                        super.visitMethodInsn(INVOKESTATIC,
+                                              "com/oracle/lambda/TestLambdaSerialization",
+                                              (needsTransform && deserializationWorkaround)
+                                                    ? "serializeOnly"
+                                                    : "serializeAndDeserialize",
+                                              "(Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;");
+                    }
+                };
+            }
+        };
+    }
+
+    void dumpClass(byte[] array, String prefix) {
+        try {
+            Path f = Files.createTempFile(new File("/tmp").toPath(),
+                                          prefix, ".class");
+            System.out.println("dumping to:" + f.toString());
+            Files.write(f, array, CREATE, TRUNCATE_EXISTING);
+        } catch (IOException ex) {
+            Logger.getLogger(SerializationInjector.class.getName()).log(Level.SEVERE, null, ex);
+        }
+    }
+
+    private byte[] injectSerialization(byte[] classBuffer, ClassLoader cl) {
+        ClassReader classReader = new ClassReader(classBuffer);
+        ClassWriter classWriter = new ClassWriter(classReader,
+                ClassWriter.COMPUTE_MAXS /*| ClassWriter.COMPUTE_FRAMES*/);
+        boolean hasNoArgCtor = hasNoArgCtor(classBuffer);
+        classReader.accept(makeSerializationVisitor(classWriter, !hasNoArgCtor), 0);
+        byte[] byteArray = classWriter.toByteArray();
+        // Needed to comment this out because some classes are actually loaded during this verification
+        // and they fail the package name test (java.*)
+//        CheckClassAdapter.verify(new ClassReader(byteArray), cl, false,
+//                new PrintWriter(System.err));
+
+//        dumpClass(classBuffer, "pre-serialization");
+//        dumpClass(byteArray, "post-serialization");
+        return byteArray;
+    }
+
+    private boolean hasNoArgCtor(byte[] buffer) {
+        final AtomicBoolean foundNoArg = new AtomicBoolean();
+        new ClassReader(buffer).accept(new ClassVisitor(ASM4, null) {
+            @Override
+            public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
+                if (name.equals("<init>") && desc.equals("()V"))
+                    foundNoArg.set(true);
+                return super.visitMethod(access, name, desc, signature, exceptions);
+            }
+        }, 0);
+        return foundNoArg.get();
+    }
+
+    ClassVisitor makeSerializationVisitor(final ClassWriter cw, final boolean injectNoArg) {
+        return new ClassVisitor(ASM4, cw) {
+            @Override
+            public void visit(int version, int access, String name,
+                              String signature, String superName,
+                              String[] interfaces) {
+                String sername = java.io.Serializable.class.getName().replace('.', '/');
+                boolean foundSer = false;
+                for (String x : interfaces) {
+                    foundSer = foundSer || x.contains(sername);
+                }
+                if (!foundSer) {
+                    debug.println("Injecting serialization: " + name);
+                    int n = interfaces.length;
+                    interfaces = Arrays.copyOf(interfaces, n + 1);
+                    interfaces[n] = sername;
+                    if (signature != null)
+                        signature += "L" + sername + ";";
+                }
+                super.visit(version, access, name, signature, superName, interfaces);
+                if (injectNoArg && (access & ACC_INTERFACE) == 0) {
+                    debug.println("Injecting <init>: " + name);
+                    MethodVisitor ctor = visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
+                    ctor.visitCode();
+                    ctor.visitVarInsn(ALOAD, 0);
+                    ctor.visitMethodInsn(INVOKESPECIAL, superName, "<init>", "()V");
+                    ctor.visitInsn(RETURN);
+                    ctor.visitMaxs(-1, -1);
+                    ctor.visitEnd();
+                }
+            }
+        };
+    }
+}
+class DebugPrint {
+    final PrintStream out;
+    final boolean mustPrint;
+    final boolean shouldClose;
+
+    DebugPrint() throws IOException {
+        mustPrint = Boolean.getBoolean(SerializationInjector.DEBUG);
+        String output = System.getProperty(SerializationInjector.LOGFILE, "out");
+        switch (output) {
+            case "out":
+                out = System.out;
+                shouldClose = false;
+                break;
+            case "err":
+                out = System.err;
+                shouldClose = false;
+                break;
+            default:
+                File f = new File(output);
+                if (f.exists()) {
+                    File dir = f.getParentFile();
+                    f = File.createTempFile("agent", ".log", dir);
+                }
+                FileOutputStream fos = new FileOutputStream(f);
+                out = new PrintStream(new BufferedOutputStream(fos));
+                shouldClose = true;
+        }
+    }
+
+    void println(String s) {
+        if (mustPrint)
+            out.println(s);
+    }
+    void print(String s) {
+        if (mustPrint)
+            out.print(s);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/agent/src/com/oracle/lambda/TestLambdaSerialization.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,253 @@
+/*
+ * Copyright (c) 2012, 2013, 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
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package com.oracle.lambda;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class TestLambdaSerialization {
+
+    private static final Map<String, SerializableStatus> nonSerializableClasses =
+            Collections.synchronizedMap(new HashMap<String, SerializableStatus>());
+    private static final Map<String, SerializableStatus> serializableButFailedClasses =
+            Collections.synchronizedMap(new HashMap<String, SerializableStatus>());
+    private static final Map<String, SerializableStatus> deserFailures =
+            Collections.synchronizedMap(new HashMap<String, SerializableStatus>());
+    private static final CounterSet serCounters = new CounterSet();
+    private static final CounterSet deserCounters = new CounterSet();
+    private static final int nRounds =
+            Integer.parseInt(System.getProperty(SerializationInjector.NROUNDS, "1"));
+
+    public static void printStats() {
+        PrintStream rpt = System.out;
+        try {
+            rpt.println("Lambda Serialization Test Status:");
+            rpt.println("  serializations attempted:       " + serCounters.attempted);
+            rpt.println("  serializations succeeded:       " + serCounters.succeeded);
+            rpt.println("  serializations failed:          " + serCounters.failed);
+            rpt.println("  serializations not attempted:   " + serCounters.notAttempted);
+            rpt.println("  deserializations attempted:     " + deserCounters.attempted);
+            rpt.println("  deserializations succeeded:     " + deserCounters.succeeded);
+            rpt.println("  deserializations failed:        " + deserCounters.failed);
+            rpt.println("  deserializations not attempted: " + deserCounters.notAttempted);
+            if (nonSerializableClasses.size() > 0) {
+                rpt.println("Non Serializable Class(es):");
+                for (Entry<String, SerializableStatus> e : nonSerializableClasses.entrySet()) {
+                    rpt.println("  " + e.getValue());
+                }
+            }
+            if (serializableButFailedClasses.size() > 0) {
+                rpt.println("Serializable class(es) but failed serialization:");
+                for (Entry<String, SerializableStatus> e : serializableButFailedClasses.entrySet()) {
+                    rpt.println("  " + e.getValue());
+                }
+            }
+            if (deserFailures.size() > 0) {
+                rpt.println("Failed deserialization:");
+                for (Entry<String, SerializableStatus> e : deserFailures.entrySet()) {
+                    rpt.println("  " + e.getValue());
+                }
+            }
+        } finally {
+            rpt.flush();
+        }
+    }
+
+    public static Object serializeOnly(Object lambdaObj, Object... args) {
+        Object lObj = lambdaObj;
+        for (int i = 0 ; i < nRounds; i++)
+            lObj = serializeAndDeserialize0(true, lObj, args);
+        return lObj;
+    }
+
+    public static Object serializeAndDeserialize(Object lambdaObj, Object... args) {
+        Object lObj = lambdaObj;
+        for (int i = 0; i < nRounds; i++)
+            lObj = serializeAndDeserialize0(false, lObj, args);
+        return lObj;
+    }
+
+    private static Object serializeAndDeserialize0(boolean serializeonly,
+            Object lambdaObj, Object... args) {
+        boolean argsSerializable = true;
+        for (Object a : args) {
+            if (!(a instanceof java.io.Serializable)) {
+                argsSerializable = false;
+                String name = a.getClass().getName();
+                SerializableStatus s = nonSerializableClasses.get(name);
+                if (s == null) {
+                    s = new SerializableStatus("NonSerializableObject", name,
+                            SerializationInjector.storeFrames
+                                ? new Exception(name) : null);
+                    nonSerializableClasses.put(name, s);
+
+                } else {
+                    s.incrementCount();
+                }
+            }
+        }
+
+        byte[] serBytes;
+        if (argsSerializable) {
+            try {
+                serCounters.attempted.incrementAndGet();
+                ByteArrayOutputStream bos = new ByteArrayOutputStream();
+                ObjectOutputStream oos = new ObjectOutputStream(bos);
+                oos.writeObject(lambdaObj);
+                oos.close();
+                serBytes = bos.toByteArray();
+                serCounters.succeeded.incrementAndGet();
+            } catch (java.io.NotSerializableException e) {
+                serCounters.failed.incrementAndGet();
+                String name = e.getMessage();
+                SerializableStatus s = nonSerializableClasses.get(name);
+                if (s == null) {
+                    s = new SerializableStatus("NonSerializableObject", name,
+                                               SerializationInjector.storeFrames ? e : null);
+                    nonSerializableClasses.put(name, s);
+                } else {
+                    s.incrementCount();
+                }
+                return lambdaObj;
+            } catch (RuntimeException | IOException | Error e) {
+                serCounters.failed.incrementAndGet();
+                String cname = lambdaObj.getClass().getName();
+                SerializableStatus s = serializableButFailedClasses.get(cname);
+                if (s == null) {
+                    serializableButFailedClasses.put(cname, new SerializableStatus("LambdaObject",
+                            lambdaObj, SerializationInjector.storeFrames ? e : null));
+                } else {
+                    s.incrementCount();
+                }
+                return lambdaObj;
+            }
+        } else {
+            serCounters.notAttempted.incrementAndGet();
+            return lambdaObj;
+        }
+
+        if (serializeonly) {
+            deserCounters.notAttempted.incrementAndGet();
+            return lambdaObj;
+        }
+
+        deserCounters.attempted.incrementAndGet();
+        try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(serBytes))) {
+            Object nlambdaObj = ois.readObject();
+            deserCounters.succeeded.incrementAndGet();
+            return nlambdaObj;
+        } catch (Exception e) {
+            deserCounters.failed.incrementAndGet();
+            String cname = lambdaObj.getClass().getName();
+            SerializableStatus s = deserFailures.get(cname);
+            if (s == null) {
+                deserFailures.put(cname, new SerializableStatus("NonDeserializableObject",
+                        lambdaObj, SerializationInjector.storeFrames ? e : null));
+            } else {
+                s.incrementCount();
+            }
+            return lambdaObj;
+        }
+    }
+
+    /*
+     * a unit tester for this class
+     */
+
+    public static void main(String... args) {
+        String s = "Lambda";
+        Object o = new Object();
+        Object[] array = {
+            "one",
+            "two",
+            "three"
+        };
+        serializeAndDeserialize(s, "Hi", array);
+        serializeAndDeserialize(s, "Bye", array);
+    }
+
+    static AtomicBoolean initialized = new AtomicBoolean();
+    static {
+        initializeShutDownHook();
+    }
+
+    static void initializeShutDownHook() {
+        if (initialized.compareAndSet(false, true)) {
+            Runtime.getRuntime().addShutdownHook(
+                    new Thread() {
+                        @Override
+                        public void run() {
+                            printStats();
+                        }
+                    }
+            );
+        }
+    }
+}
+
+class CounterSet {
+    AtomicInteger notAttempted = new AtomicInteger(0);
+    AtomicInteger attempted = new AtomicInteger(0);
+    AtomicInteger succeeded = new AtomicInteger(0);
+    AtomicInteger failed = new AtomicInteger(0);
+}
+
+class SerializableStatus {
+    String type;
+    Object obj;
+    Throwable exception;
+    AtomicInteger count = new AtomicInteger(1);
+
+    public SerializableStatus(String type, Object obj, Throwable exception) {
+        this.type = type;
+        this.obj = obj;
+        this.exception = exception;
+    }
+
+    public void incrementCount() {
+        count.incrementAndGet();
+    }
+
+    public String toString() {
+        StringWriter sw = new StringWriter();
+        PrintWriter pw = new PrintWriter(sw);
+        pw.printf("%s: %s [ %d ]%n", type, obj, count.get());
+        if (exception != null) {
+            pw.printf("    Throwable: %s", exception);
+            exception.printStackTrace(pw);
+        }
+        return sw.toString();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/build.xml	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,294 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+        * Copyright (c) 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
+        * under the terms of the GNU General Public License version 2 only, as
+        * published by the Free Software Foundation.  Oracle designates this
+        * particular file as subject to the "Classpath" exception as provided
+        * by Oracle in the LICENSE file that accompanied this code.
+        *
+        * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+        * or visit www.oracle.com if you need additional information or have any
+        * questions.
+-->
+
+<project name="jdk" default="test">
+
+    <property name="build.dir" value="../../build/test-ng" />
+    <property name="tests.classes.dir" value="${build.dir}/test-classes"/>
+    <property name="mangled.jdk.dir" value="${build.dir}/mangled-jdk"/>
+    <property name="mangled.bootlib.dir" value="${build.dir}/mangled-bootlib"/>
+    <property name="mangled.boottests.dir" value="${build.dir}/mangled-boottests"/>
+    <property name="mangled.tests.dir" value="${build.dir}/mangled-testclasses"/>
+    <property name="boottests.classes.dir" value="${build.dir}/boottest-classes"/>
+    <property name="bootlib.classes.dir" value="${build.dir}/test-bootlib"/>
+    <property name="test.reports.dir" value="${build.dir}/test-reports"/>
+    <property name="lambda.test.dir" value="../test/jdk/lambda" />
+    <property name="spliterator.test.dir" value="../test/java/util/Spliterator" />
+    <property name="tests.src.dir" value="../test/java/util/stream/test"/>
+    <property name="boottests.src.dir" value="../test/java/util/stream/boottest"/>
+    <property name="bootlib.src.dir" value="../test/java/util/stream/bootlib"/>
+    <property name="lib.dir" location="lib" />
+    <property name="test.pattern" value="*" />
+    <property name="lambda.metafactory" value="" />
+    <property name="generated.dir" value="gen-separate"/>
+    <property name="agent.dir"       location="${basedir}/agent"/>
+    <property name="agent.jar"       value="${build.dir}/agent/dist/SerializationInjectorAgent.jar" />
+    <property name="agent.serial.file" value="${agent.dir}/conf/serialize.list" />
+    <property name="agent.rt.jar"    value="${java.home}/lib/rt.jar" />
+    <property name="agent.heap.size" value="-Xmx4g"/>
+    <property name="parallel.mode"    value="classes" />
+    <property name="parallel.suitePool"    value="1" />
+    <property name="parallel.providerPool"    value="1" />
+
+    <property name="lib.testng.jar" value="${lib.dir}/testng.jar"/>
+    <property name="lib.tools.jar" value="${java.home}/../lib/tools.jar"/>
+
+    <path id="compile.class.path">
+        <pathelement location="${bootlib.classes.dir}" />
+        <pathelement location="${tests.classes.dir}" />
+        <pathelement location="${lib.testng.jar}"/>
+        <pathelement location="${lib.tools.jar}"/>
+    </path>
+
+    <path id="test.class.path">
+        <pathelement location="${tests.classes.dir}" />
+        <pathelement location="${lib.testng.jar}"/>
+        <pathelement location="${lib.tools.jar}"/>
+    </path>
+
+    <path id="mangled.class.path">
+        <pathelement location="${mangled.tests.dir}" />
+        <pathelement location="${lib.testng.jar}"/>
+        <pathelement location="${lib.tools.jar}"/>
+    </path>
+
+    <taskdef name="testng" classpathref="test.class.path" classname="org.testng.TestNGAntTask" />
+
+    <target name="prepare">
+        <mkdir dir="${build.dir}"/>
+        <mkdir dir="${mangled.jdk.dir}"/>
+        <mkdir dir="${tests.classes.dir}"/>
+        <mkdir dir="${boottests.classes.dir}"/>
+        <mkdir dir="${bootlib.classes.dir}"/>
+        <mkdir dir="${test.reports.dir}"/>
+    </target>
+
+    <target name="test-compile" depends="prepare">
+        <javac destdir="${bootlib.classes.dir}" debug="on" srcdir="${bootlib.src.dir}" fork="true"
+               classpathref="compile.class.path">
+            <compilerarg value="-Xlint:all"/>
+            <compilerarg value="-XDignore.symbol.file"/>
+        </javac>
+        <javac destdir="${tests.classes.dir}" debug="on" srcdir="${tests.src.dir}:${lambda.test.dir}:${spliterator.test.dir}" fork="true"
+               classpathref="compile.class.path">
+            <compilerarg value="-Xlint:all"/>
+            <compilerarg value="-XDignore.symbol.file"/>
+        </javac>
+        <javac destdir="${boottests.classes.dir}" debug="on" srcdir="${boottests.src.dir}" fork="true"
+               classpathref="compile.class.path">
+            <compilerarg value="-Xlint:all"/>
+            <compilerarg value="-XDignore.symbol.file"/>
+        </javac>
+   </target>
+
+   <target name="test" depends="test-compile" >
+        <echo>Results at: file:${test.reports.dir}/index.html</echo>
+        <delete dir="tmp" />
+        <testng classpathref="test.class.path" outputdir="${test.reports.dir}"
+                listener="org.testng.reporters.DotTestListener, org.testng.reporters.XMLReporter" useDefaultListeners="false">
+            <classfileset dir="${tests.classes.dir}" includes="**/${test.pattern}.class"/>
+            <classfileset dir="${boottests.classes.dir}" includes="**/${test.pattern}.class"/>
+            <jvmarg value="-Xbootclasspath/p:${boottests.classes.dir}"/>
+            <jvmarg value="-Xbootclasspath/p:${bootlib.classes.dir}"/>
+            <jvmarg value="-Xbootclasspath/p:${lib.testng.jar}"/>
+            <jvmarg value="-ea"/>
+            <jvmarg value="-esa"/>
+            <jvmarg value="-Xverify:all"/>
+            <jvmarg value="-Xmx2g"/>
+            <sysproperty key="org.openjdk.java.util.stream.tripwire" value="true"/>
+        </testng>
+    </target>
+
+    <target name="test-libs" depends="test-compile" >
+        <echo>Results at: file:${test.reports.dir}/index.html</echo>
+        <delete dir="tmp" />
+        <testng classpathref="test.class.path" outputdir="${test.reports.dir}"
+                listener="org.testng.reporters.XMLReporter" useDefaultListeners="false"
+                parallel="${parallel.mode}" suiteThreadPoolSize="${parallel.suitePool}" dataProviderThreadCount="${parallel.providerPool}">
+            <classfileset dir="${tests.classes.dir}" includes="org/openjdk/tests/java/**/*.class"/>
+            <classfileset dir="${boottests.classes.dir}" includes="java/**/*.class"/>
+            <jvmarg value="-Xbootclasspath/p:${boottests.classes.dir}"/>
+            <jvmarg value="-Xbootclasspath/p:${bootlib.classes.dir}"/>
+            <jvmarg value="-Xbootclasspath/p:${lib.testng.jar}"/>
+            <jvmarg value="-ea" />
+            <jvmarg value="-esa" />
+            <jvmarg value="-Xverify:all" />
+            <jvmarg value="-Xmx2500m" />
+            <sysproperty key="org.openjdk.java.util.stream.tripwire" value="true"/>
+        </testng>
+    </target>
+
+    <target name="test-notlibs" depends="test-compile" >
+        <echo>Results at: file:${test.reports.dir}/index.html</echo>
+        <delete dir="tmp" />
+        <testng classpathref="test.class.path" outputdir="${test.reports.dir}"
+                listener="org.testng.reporters.XMLReporter" useDefaultListeners="false"
+                parallel="${parallel.mode}" suiteThreadPoolSize="${parallel.suitePool}" dataProviderThreadCount="${parallel.providerPool}" >
+            <classfileset dir="${tests.classes.dir}" excludes="org/openjdk/tests/java/**/*.class"/>
+            <jvmarg value="-Xbootclasspath/p:${boottests.classes.dir}"/>
+            <jvmarg value="-Xbootclasspath/p:${bootlib.classes.dir}"/>
+            <jvmarg value="-Xbootclasspath/p:${lib.testng.jar}"/>
+            <jvmarg value="-ea" />
+            <jvmarg value="-esa" />
+            <jvmarg value="-Xverify:all" />
+            <jvmarg value="-Xmx2500m" />
+            <sysproperty key="org.openjdk.java.util.stream.tripwire" value="true"/>
+        </testng>
+    </target>
+
+    <target name="clean" depends="clean-mangler">
+        <delete includeEmptyDirs="true" failonerror="false">
+            <fileset dir="${build.dir}" />
+            <fileset dir="${generated.dir}" />
+        </delete>
+    </target>
+
+    <!-- mangler related start -->
+    <target name="clean-mangler">
+        <ant antfile="${agent.dir}/make/build.xml" inheritAll="false"
+             target="clean">
+        </ant>
+    </target>
+
+    <target name="build-mangler">
+        <ant antfile="${agent.dir}/make/build.xml" inheritAll="false"
+             target="dist">
+        </ant>
+    </target>
+
+    <target name="mangler-sanity">
+        <condition property="agent.rt.jar.available">
+            <available file="${agent.rt.jar}"/>
+        </condition>
+        <echo message="java.home        : ${java.home}"/>
+        <echo message="agent.rt.jar     : ${agent.rt.jar}"/>
+        <echo message="agent.heap.size  : ${agent.heap.size}"/>
+        <fail message="agent.rt.jar was not found, please set it to a valid rt.jar"
+              unless="agent.rt.jar.available"/>
+    </target>
+
+    <target name="premangle" depends="mangler-sanity, clean, build-mangler, test-compile">
+        <!-- Mangle JDK to mangled.jdk.dir (serialization injection only, no SAND) -->
+        <delete dir="${mangled.jdk.dir}" />
+        <mkdir dir="${mangled.jdk.dir}" />
+        <java jar="${agent.jar}" fork="true" >
+            <jvmarg value="-Dcom.oracle.lambda.serialize.file=${agent.serial.file}"/>
+            <arg value="-s"/>
+            <arg value="-o"/>
+            <arg value="${mangled.jdk.dir}" />
+            <arg value="-s"/>
+            <arg value="${agent.rt.jar}"/>
+        </java>
+        <!-- Mangle boot test classes to mangled.boottests.dir -->
+        <delete dir="${mangled.boottests.dir}" />
+        <mkdir dir="${mangled.boottests.dir}" />
+        <jar destfile="${build.dir}/tmpA.jar" basedir="${boottests.classes.dir}"/>
+        <java jar="${agent.jar}" fork="true" >
+            <jvmarg value="-Dcom.oracle.lambda.serialize.file=${agent.serial.file}"/>
+            <arg value="-o"/>
+            <arg value="${mangled.boottests.dir}" />
+            <arg value="-s"/>
+            <arg value="${build.dir}/tmpA.jar"/>
+        </java>
+        <!-- Mangle boot test classes to mangled.bootlib.dir (serialization injection only, no SAND) -->
+        <delete dir="${mangled.bootlib.dir}" />
+        <mkdir dir="${mangled.bootlib.dir}" />
+        <jar destfile="${build.dir}/tmpB.jar" basedir="${bootlib.classes.dir}"/>
+        <java jar="${agent.jar}" fork="true" >
+            <jvmarg value="-Dcom.oracle.lambda.serialize.file=${agent.serial.file}"/>
+            <arg value="-s"/>
+            <arg value="-o"/>
+            <arg value="${mangled.bootlib.dir}" />
+            <arg value="${build.dir}/tmpB.jar"/>
+        </java>
+        <!-- Mangle test classes to mangled.testdir -->
+        <delete dir="${mangled.tests.dir}" />
+        <mkdir dir="${mangled.tests.dir}" />
+        <jar destfile="${build.dir}/tmpC.jar" basedir="${tests.classes.dir}"/>
+        <java jar="${agent.jar}" fork="true" >
+            <jvmarg value="-Dcom.oracle.lambda.serialize.file=${agent.serial.file}"/>
+            <arg value="-o"/>
+            <arg value="${mangled.tests.dir}" />
+            <arg value="${build.dir}/tmpC.jar"/>
+        </java>
+    </target>
+
+    <!--
+        Some tests are hostile to our serialization testing strategy; these are those where lambdas
+        have side-effects on captured arguments, and then we test properties of the captured arguments
+        separately.  This is because serialization/deserialization severs the aliasing that this test
+        strategy depends on.  So we mark and exclude these classes.
+    -->
+    <target name="test-mangled" depends="mangler-sanity, test-compile, build-mangler" >
+        <delete dir="tmp" />
+        <testng classpathref="mangled.class.path" outputdir="${test.reports.dir}"
+                excludedgroups="serialization-hostile">
+            <classfileset dir="${mangled.tests.dir}" includes="org/openjdk/tests/java/**/*.class"
+                          excludes="**/SerializedLambdaTest.class"/>
+            <classfileset dir="${mangled.boottests.dir}" includes="**/*.class"/>
+            <jvmarg value="-Xbootclasspath/p:${agent.jar}"/>
+            <jvmarg value="-Xbootclasspath/p:${mangled.jdk.dir}"/>
+            <jvmarg value="-Xbootclasspath/p:${mangled.bootlib.dir}"/>
+            <jvmarg value="-Xbootclasspath/p:${mangled.boottests.dir}"/>
+            <jvmarg value="-Xbootclasspath/p:${lib.testng.jar}"/>
+            <!--<jvmarg value="-Dsun.io.serialization.extendedDebugInfo=true" />-->
+            <jvmarg value="-ea" />
+            <jvmarg value="-esa" />
+            <jvmarg value="-Xverify:none" />
+            <jvmarg value="${agent.heap.size}"/>
+            <sysproperty key="org.openjdk.java.util.stream.tripwire" value="true"/>
+            <sysproperty key="org.openjdk.java.util.stream.sand.mode" value="true"/>
+            <!-- properties specific to agent config -->
+            <jvmarg value="-Dcom.oracle.lambda.store.frames=false"/>
+            <jvmarg value="-Dcom.oracle.lambda.nrounds=1"/>
+            <jvmarg value="-javaagent:${agent.jar}"/>
+        </testng>
+    </target>
+
+    <target name="test-mangledp" depends="test-compile, build-mangler" >
+        <delete dir="tmp" />
+        <testng classpathref="mangled.class.path" outputdir="${test.reports.dir}"
+                excludedgroups="serialization-hostile">
+            <classfileset dir="${mangled.tests.dir}" includes="**/${test.pattern}.class"/>
+            <classfileset dir="${mangled.boottests.dir}" includes="**/${test.pattern}.class"/>
+            <jvmarg value="-Xbootclasspath/p:${agent.jar}"/>
+            <jvmarg value="-Xbootclasspath/p:${mangled.jdk.dir}"/>
+            <jvmarg value="-Xbootclasspath/p:${mangled.bootlib.dir}"/>
+            <jvmarg value="-Xbootclasspath/p:${mangled.boottests.dir}"/>
+            <jvmarg value="-Xbootclasspath/p:${lib.testng.jar}"/>
+            <!--<jvmarg value="-Dsun.io.serialization.extendedDebugInfo=true" />-->
+            <jvmarg value="-ea" />
+            <jvmarg value="-esa" />
+            <jvmarg value="-Xverify:none" />
+            <jvmarg value="-Xmx2500m" />
+            <sysproperty key="org.openjdk.java.util.stream.tripwire" value="true"/>
+            <sysproperty key="org.openjdk.java.util.stream.sand.mode" value="true"/>
+            <jvmarg value="-javaagent:${agent.jar}"/>
+        </testng>
+    </target>
+    <!-- mangler related,  end -->
+</project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-ng/tests/lambda/TestInterfaceBridges.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package lambda;
+
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertEquals;
+
+/**
+ * TestInterfaceBridges
+ *
+ * @author Brian Goetz
+ */
+@Test
+public class TestInterfaceBridges {
+    public void testCovariantOverrideLambda() {
+        B b = () -> "Foo";
+        assertEquals("Foo", b.make());
+        assertEquals("Foo", ((A) b).make());
+    }
+
+    public void testCovariantOverrideIC() {
+        B b = new B() {
+            @Override
+            public String make() {
+                return "Foo";
+            }
+        };
+        assertEquals("Foo", b.make());
+        assertEquals("Foo", ((A) b).make());
+    }
+
+    public static interface A {
+        Object make();
+    }
+
+    public static interface B extends A {
+        String make();
+    }
+
+    public void testCovariantMerge() {
+        D d = () -> "Foo";
+        assertEquals("Foo", d.make());
+        assertEquals("Foo", ((A) d).make());
+        assertEquals("Foo", ((C) d).make());
+    }
+
+    public static interface C {
+        String make();
+    }
+
+    public static interface D extends A, C {
+    }
+}
--- a/test/ProblemList.txt	Thu Oct 31 16:44:18 2013 -0700
+++ b/test/ProblemList.txt	Mon Nov 11 23:17:30 2013 -0800
@@ -206,6 +206,10 @@
 # 8014719
 sun/net/www/http/HttpClient/ProxyTest.java                       generic-all
 
+# 7150552
+sun/net/www/protocol/http/B6299712.java                         macosx-all
+java/net/CookieHandler/CookieManagerTest.java                   macosx-all
+
 ############################################################################
 
 # jdk_nio
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/io/Serializable/defaultSVID/Child.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 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
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+class Child implements Parent, java.io.Serializable { }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/io/Serializable/defaultSVID/DefaultSVID.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 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
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @summary Test default serial version id creation
+ *
+ * @compile ParentA.java Child.java
+ * @run main DefaultSVID moveParentA
+ * @compile ParentB.java
+ * @run main DefaultSVID
+ */
+
+import java.io.IOException;
+import java.io.ObjectStreamClass;
+import java.nio.file.*;
+import static java.nio.file.StandardCopyOption.*;
+
+public class DefaultSVID {
+
+    static String testClasses = System.getProperty("test.classes");
+
+    public static class MyClassLoader extends ClassLoader {
+        final String suffix;
+
+        public MyClassLoader(String suffix) {
+            super(null);
+            this.suffix = suffix;
+        }
+
+        public Class<?> defineAndResolve(String name) {
+            try {
+                String file;
+                if ("Parent".equals(name)) {
+                    file = name + suffix;
+                } else {
+                    file = name;
+                }
+                byte[] classBytes = Files.readAllBytes(Paths.get(testClasses, file + ".class"));
+                Class<?> ret = defineClass(name, classBytes, 0, classBytes.length);
+                resolveClass(ret);
+                return ret;
+            } catch (IOException ioe) {
+                throw new RuntimeException(ioe);
+            }
+        }
+    }
+
+    public static void main(String args[]) throws Exception {
+        if (args.length > 0) {
+            Files.move(Paths.get(testClasses, "Parent.class"),
+                       Paths.get(testClasses, "ParentA.class"),
+                       REPLACE_EXISTING);
+            return;
+        }
+
+        Files.move(Paths.get(testClasses, "Parent.class"),
+                   Paths.get(testClasses, "ParentB.class"),
+                   REPLACE_EXISTING);
+
+        MyClassLoader cl_nodefault = new MyClassLoader("A");
+        MyClassLoader cl_default = new MyClassLoader("B");
+
+        cl_nodefault.defineAndResolve("Parent");
+        cl_default.defineAndResolve("Parent");
+
+        Class<?> child_nodefault = cl_nodefault.defineAndResolve("Child");
+        Class<?> child_default = cl_default.defineAndResolve("Child");
+
+        ObjectStreamClass osc_child_nodefault = ObjectStreamClass.lookup(child_nodefault);
+        ObjectStreamClass osc_child_default = ObjectStreamClass.lookup(child_default);
+        
+        long svid_nodefault = osc_child_nodefault.getSerialVersionUID();
+        long svid_default = osc_child_default.getSerialVersionUID();
+
+        System.out.printf("svid_nodefault : %016X \n  svid_default : %016X\n",
+                          svid_nodefault, svid_default);
+
+        if (svid_nodefault != svid_default) {
+            throw new AssertionError("serial version IDs differ");
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/io/Serializable/defaultSVID/ParentA.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 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
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+interface Parent {
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/io/Serializable/defaultSVID/ParentB.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 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
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+interface Parent {
+    default void parent() { }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Double/DoubleReducersTest.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 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
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary
+ * @(#) DoubleReducersTest.java
+ * @author Tristan Yan
+ * @run testng DoubleReducersTest
+ */
+
+import java.util.Random;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+
+public class DoubleReducersTest {
+    private final static int LOOP = 1 << 20;
+
+    private final static Random rand = new Random(System.currentTimeMillis());
+
+    @Test
+    public void testMax() {
+        for(int index = 0; index < LOOP; index++){
+            double d1 = rand.nextDouble();
+            double d2 = rand.nextDouble();
+            double expected = d1 > d2 ? d1 : d2;
+            assertEquals(Double.max(d1, d2), expected);
+        }
+    }
+
+    @Test
+    public void testMin() {
+        for(int index = 0; index < LOOP; index++){
+            double d1 = rand.nextDouble();
+            double d2 = rand.nextDouble();
+            double expected = d1 < d2 ? d1 : d2;
+            assertEquals(Double.min(d1, d2), expected);
+        }
+    }
+
+    @Test
+    public void testSum() {
+        for(int index = 0; index < LOOP; index++){
+            double d1 = rand.nextDouble();
+            double d2 = rand.nextDouble();
+            double expected = d1 + d2;
+            assertEquals(Double.sum(d1, d2), expected);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Integer/IntegerReducersTest.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 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
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary
+ * @(#) IntegerReducersTest.java
+ * @author Tristan Yan
+ * @run testng IntegerReducersTest
+ */
+
+import java.util.Random;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+
+public class IntegerReducersTest {
+    private final static int LOOP = 1 << 20;
+
+    private final static Random rand = new Random(System.currentTimeMillis());
+
+    @Test
+    public void testMax() {
+        for(int index = 0; index < LOOP; index++){
+            int i1 = rand.nextInt();
+            int i2 = rand.nextInt();
+            int expected = i1 > i2 ? i1 : i2;
+            assertEquals(Integer.max(i1, i2), expected);
+        }
+    }
+
+    @Test
+    public void testMin() {
+        for(int index = 0; index < LOOP; index++){
+            int i1 = rand.nextInt();
+            int i2 = rand.nextInt();
+            int expected = i1 < i2 ? i1 : i2;
+            assertEquals(Integer.min(i1, i2), expected);
+        }
+    }
+
+    @Test
+    public void testSum() {
+        for(int index = 0; index < LOOP; index++){
+            int i1 = rand.nextInt();
+            int i2 = rand.nextInt();
+            int expected = i1 + i2;
+            assertEquals(Integer.sum(i1, i2), expected);
+        }
+    }
+
+    @Test
+    public void testUnsignedWithoutRadix(){
+        for(int index = 0; index < LOOP; index++){
+            int i = rand.nextInt();
+            assertEquals(Integer.parseUnsignedInt(Integer.toUnsignedString(i)), i);
+            assertEquals(Integer.toUnsignedString(i, 10), Integer.toUnsignedString(i));
+            if(i >= 0)
+                assertEquals(Integer.toUnsignedString(i), Integer.toString(i));
+        }
+    }
+
+    @Test
+    public void testUnsignedWithRadix(){
+        for(int index = 0; index < LOOP; index++){
+            int i = rand.nextInt();
+            int radix = Character.MIN_RADIX + rand.nextInt(Character.MAX_RADIX - Character.MIN_RADIX + 1);
+            assertEquals(Integer.parseUnsignedInt(Integer.toUnsignedString(i, radix), radix), i);
+            if(i >= 0)
+                assertEquals(Integer.toUnsignedString(i, radix), Integer.toString(i, radix));
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/Long/LongReducersTest.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 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
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary
+ * @author Tristan Yan
+ * @run testng LongReducersTest
+ */
+
+import java.util.Random;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+
+public class LongReducersTest {
+    private final static int LOOP = 1 << 20;
+
+    private final static Random rand = new Random(System.currentTimeMillis());
+
+    @Test
+    public void testMax() {
+        for(int index = 0; index < LOOP; index++){
+            long l1 = rand.nextLong();
+            long l2 = rand.nextLong();
+            long expected = l1 > l2 ? l1 : l2;
+            assertEquals(Long.max(l1, l2), expected);
+        }
+    }
+
+    @Test
+    public void testMin() {
+        for(int index = 0; index < LOOP; index++){
+            long l1 = rand.nextLong();
+            long l2 = rand.nextLong();
+            long expected = l1 < l2 ? l1 : l2;
+            assertEquals(Long.min(l1, l2), expected);
+        }
+    }
+
+    @Test
+    public void testSum() {
+        for(int index = 0; index < LOOP; index++){
+            long l1 = rand.nextLong();
+            long l2 = rand.nextLong();
+            long expected = l1 + l2;
+            assertEquals(Long.sum(l1, l2), expected);
+        }
+    }
+
+    @Test
+    public void testUnsignedWithoutRadix(){
+        for(int index = 0; index < LOOP; index++){
+            long l = rand.nextLong();
+            assertEquals(Long.parseUnsignedLong(Long.toUnsignedString(l)), l);
+            assertEquals(Long.toUnsignedString(l, 10), Long.toUnsignedString(l));
+            if(l >= 0)
+                assertEquals(Long.toUnsignedString(l), Long.toString(l));
+        }
+    }
+
+    @Test
+    public void testUnsignedWithRadix(){
+        for(int index = 0; index < LOOP; index++){
+            long l = rand.nextLong();
+            int radix = Character.MIN_RADIX + rand.nextInt(Character.MAX_RADIX - Character.MIN_RADIX + 1);
+            assertEquals(Long.parseUnsignedLong(Long.toUnsignedString(l, radix), radix), l);
+            if(l >= 0)
+                assertEquals(Long.toUnsignedString(l, radix), Long.toString(l, radix));
+        }
+    }
+
+    @Test
+    public void testCompareUnsigned() {
+        for(int index = 0; index < LOOP; index++){
+            long l1 = rand.nextLong();
+            long l2 = rand.nextLong();
+            assertEquals(Long.compareUnsigned(l1, l2),
+                Long.compare(Long.MAX_VALUE + l1, Long.MAX_VALUE + l2));
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/String/JoinTest.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 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
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary test for String.join(CharSequence , CharSequence...) and
+ *          String.join(CharSequence , Iterable<? extends CharSequence>).
+ * @(#) JoinTest.java
+ * @author Tristan Yan
+ * @run testng JoinTest
+ */
+
+import java.util.*;
+import static org.testng.Assert.*;
+import org.testng.annotations.Test;
+
+public class JoinTest {
+    private final String[] LANGUAGES = { "ABAP", "ALGOL", "ActionScript",
+        "AppleScript","AspectJ", "Assembly language", "AutoLISP", "AWK", "Bash",
+        "C", "C Shell", "CICS", "COBOL", "Cool", "CSH", "DCL", "Delphi",
+        "Eiffel", "F#", "Formula", "Fortran", "FoxBase", "FoxPro", "Groovy",
+        "Haskell", "J#", "JCL", "JavaScript", "Ksh", "LINC", "Lisp", "Logo",
+        "MASM", "MATLAB", "NASM", "XML", "Objective-C", "Pascal", "Perl",
+        "PL/I", "PostScript", "PowerBuilder", "PowerShell", "Prolog", "Pro*C",
+        "Python", "QBasic", "REBOL", "Ruby", "Scheme", "Sed", "Smalltalk",
+        "SQL", "VBScript" };
+
+
+    private final String[] DELIMETERS = {"`", "~", "!", "@", "#", "$", "%", "^",
+        "&", "*", "(", ")", "-", "_", "+", "=", "\\", "|", ",", ".", "/", ":",
+        ";", "\"", "\"", "\n", "\t", " ", "\t"};
+
+    @Test
+    public void testJoin() {
+        //HashSet sort data with hashCode(), iterator order by hashCode()
+        List<String> lanugageList = Arrays.asList(LANGUAGES);
+        Set<String> lanugageSet = new HashSet<>(lanugageList);
+        Random rnd = new Random();
+        String delimeter = DELIMETERS[rnd.nextInt(DELIMETERS.length)];
+        StringBuilder sb = new StringBuilder();
+        Iterator<String> it = lanugageSet.iterator();
+        int pos = 0;
+        while(it.hasNext()) {
+            sb.append(it.next());
+            if(++pos < lanugageSet.size())
+                sb.append(delimeter);
+        }
+        String result2 = String.join(delimeter, lanugageSet);
+        String result1 = sb.toString();
+        assertEquals(result2, result1);
+
+        Collections.shuffle(lanugageList, new Random(rnd.nextInt()));
+        String[] shuffledArray = new String[lanugageList.size()];
+        lanugageList.toArray(shuffledArray);
+        result1 = String.join(delimeter, shuffledArray);
+        result2 = String.join(delimeter, lanugageList);
+        StringBuilder expectedSB = new StringBuilder();
+        for(int index = 0; index < lanugageList.size() - 1; index++)
+            expectedSB.append(lanugageList.get(index)).append(delimeter);
+        expectedSB.append(lanugageList.get(lanugageList.size() - 1));
+        assertEquals(expectedSB.toString(), result1);
+        assertEquals(result2, result1);
+
+        String single = LANGUAGES[rnd.nextInt(LANGUAGES.length)];
+        assertEquals(String.join(delimeter, new String[]{single}), single);
+        assertEquals(String.join(delimeter, new String[]{single}), single);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/StringBuilder/AddAllTest.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 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
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary test for StringBuilde/StringBuffer.addAll()
+ * @library /sqeutil
+ * @author Tristan Yan
+ * @run testng AddAllTest
+ */
+
+import java.util.*;
+import java.util.stream.*;
+import static org.testng.Assert.*;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+public class AddAllTest {
+    private final static int LINE_NUM = 1 << 8;
+
+    private final static int LINE_MIN_CHARACTER_LEN = 2;
+
+    private final static int LINE_MAX_CHARACTER_LEN = 80;
+
+    @Test(dataProvider = "generateData")
+    public void builderAddAll(String[] buff){
+        String str = Arrays.stream(buff).collect(Collectors.joining());
+        int start = 0;
+        for(int index = 0; index < buff.length; index++){
+            assert(start + buff[index].length() <= str.length());
+            assertEquals(str.substring(start, start + buff[index].length()), buff[index]);
+            start += buff[index].length();
+        }
+    }
+
+    @Test(dataProvider = "generateData")
+    public void bufferAddAll(String[] buff){
+        StringBuffer sb = Arrays.stream(buff).collect(StringBuffer::new, StringBuffer::append, (s, o) -> s.append(o));
+        String str = sb.toString();
+        int start = 0;
+        for(int index = 0; index < buff.length; index++){
+            assert(start + buff[index].length() <= str.length());
+            assertEquals(str.substring(start, start + buff[index].length()), buff[index]);
+            start += buff[index].length();
+        }
+    }
+
+    @DataProvider
+    public Object[][] generateData(){
+        Object[][] data = new Object[LINE_NUM][];
+        for(int line = 0; line < LINE_NUM; line++) {
+            List<Object> l = new ArrayList<>();
+            String[] buffer = new String[line];
+            for(int row = 0; row < line; row++)
+                buffer[row] = StringUtilities.randomString(LINE_MAX_CHARACTER_LEN,
+                    0);
+            data[line] = new Object[]{buffer};
+        }
+        return data;
+    }
+}
--- a/test/java/lang/ThreadLocal/Basic.java	Thu Oct 31 16:44:18 2013 -0700
+++ b/test/java/lang/ThreadLocal/Basic.java	Mon Nov 11 23:17:30 2013 -0800
@@ -30,6 +30,7 @@
 public class Basic {
     static ThreadLocal n = new ThreadLocal() {
         int i = 0;
+        @Override
         protected synchronized Object initialValue() {
             return new Integer(i++);
         }
@@ -43,11 +44,12 @@
         // Start the threads
         for(int i=0; i<threadCount; i++) {
             th[i] = new Thread() {
+                @Override
                 public void run() {
                     int threadId = ((Integer)(n.get())).intValue();
                     for (int j=0; j<threadId; j++) {
                         x[threadId]++;
-                        Thread.currentThread().yield();
+                        Thread.yield();
                     }
                 }
             };
--- a/test/java/lang/ThreadLocal/ImmutableLocal.java	Thu Oct 31 16:44:18 2013 -0700
+++ b/test/java/lang/ThreadLocal/ImmutableLocal.java	Mon Nov 11 23:17:30 2013 -0800
@@ -33,15 +33,18 @@
      * {@link ThreadLocal} guaranteed to always return the same reference.
      */
     abstract public static class ImmutableThreadLocal extends ThreadLocal {
+        @Override
         public void set(final Object value) {
             throw new RuntimeException("ImmutableThreadLocal set called");
         }
 
         // force override
+        @Override
         abstract protected Object initialValue();
     }
 
     private static final ThreadLocal cache = new ImmutableThreadLocal() {
+        @Override
         public Object initialValue() {
             return Thread.currentThread().getName();
         }
--- a/test/java/lang/ThreadLocal/InitialValue.java	Thu Oct 31 16:44:18 2013 -0700
+++ b/test/java/lang/ThreadLocal/InitialValue.java	Mon Nov 11 23:17:30 2013 -0800
@@ -34,8 +34,9 @@
 
     public class MyLocal extends ThreadLocal<String> {
         String val;
+        @Override
         protected String initialValue() {
-            other = new ThreadLocal<String>();
+            other = new ThreadLocal<>();
             // This should reuse the map that the containing get() created
             // or visa versa (i.e. instead of a second map being created).
             other.set("Other");
@@ -43,6 +44,7 @@
         }
     }
 
+    @Override
     public void run() {
         MyLocal l = new MyLocal();
         // This should pick up the initial value
--- a/test/java/lang/ThreadLocal/TLRemoveTest.java	Thu Oct 31 16:44:18 2013 -0700
+++ b/test/java/lang/ThreadLocal/TLRemoveTest.java	Mon Nov 11 23:17:30 2013 -0800
@@ -32,6 +32,7 @@
     private static final int REMOVE_SET_VALUE = 102;
 
     static ThreadLocal<Integer> n = new ThreadLocal<Integer>() {
+        @Override
         protected synchronized Integer initialValue() {
             return INITIAL_VALUE;
         }
@@ -51,11 +52,12 @@
         for(int i = 0; i<threadCount; i++) {
             final int threadId = i;
             th[i] = new Thread() {
+                @Override
                 public void run() {
                     try{
                         n.set(threadId); // Sets threadId as threadlocal value...
                         for (int j = 0; j<threadId; j++)
-                            Thread.currentThread().yield();
+                            Thread.yield();
 
                         // To remove the ThreadLocal ....
                         for(int removeId  : removeNode)
--- a/test/java/lang/ThreadLocal/TestThreadId.java	Thu Oct 31 16:44:18 2013 -0700
+++ b/test/java/lang/ThreadLocal/TestThreadId.java	Mon Nov 11 23:17:30 2013 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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
@@ -49,8 +49,9 @@
     }
 
     // Each child thread just publishes its id value for validation
+    @Override
     public void run() {
-        value = id.get();
+        value = ThreadId.get();
     }
 
     public static void main(String args[]) throws Throwable {
--- a/test/java/lang/invoke/lambda/LambdaAccessControlTest.java	Thu Oct 31 16:44:18 2013 -0700
+++ b/test/java/lang/invoke/lambda/LambdaAccessControlTest.java	Mon Nov 11 23:17:30 2013 -0800
@@ -25,11 +25,12 @@
  * @test
  * @bug 8003881
  * @summary tests Lambda expression with a a security manager at top level
- * @compile -XDignore.symbol.file LambdaAccessControlTest.java LUtils.java
+ * @compile -XDignore.symbol.file LambdaAccessControlDoPrivilegedTest.java LambdaAccessControlTest.java
  *
  * @run main/othervm LambdaAccessControlTest
  */
 
+
 public class LambdaAccessControlTest extends LUtils {
     public static void main(String... args) {
         System.setSecurityManager(new SecurityManager());
--- a/test/java/lang/invoke/lambda/LambdaSerialization.java	Thu Oct 31 16:44:18 2013 -0700
+++ b/test/java/lang/invoke/lambda/LambdaSerialization.java	Mon Nov 11 23:17:30 2013 -0800
@@ -25,6 +25,7 @@
 @test
 @bug 8004970
 @summary Lambda serialization
+
 */
 
 import java.io.*;
@@ -65,11 +66,11 @@
         }
         assertTrue(assertionCount == 3);
     }
-
+    
     static void write(ObjectOutput out, LSI lamb) throws IOException {
         out.writeObject(lamb);
     }
-
+    
     static void readAssert(ObjectInputStream in, String expected)  throws IOException, ClassNotFoundException {
         LSI ls = (LSI) in.readObject();
         String result = ls.convert("X");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/invoke/lambda/MethodReferenceCallerSensitive.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2013, 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
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+@test
+@bug 8020816
+@summary Metafactory crashes on code with method reference
+*/
+
+import java.lang.reflect.Field;
+import java.util.function.Function;
+
+public class MethodReferenceCallerSensitive { 
+    private static <T> void test(T arg) { 
+        Function<Class<T>,Field[]> firstFunction = Class<T>::getFields; 
+    } 
+    public static void main(String[] args) { 
+        test("Hello World"); 
+    } 
+} 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/lang/invoke/lambda/RepetitiveLambdaSerialization.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2013, 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
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8027681
+ * @summary Lambda serialization fails once reflection proxy generation kicks in
+ * @author  Robert Field
+ * @run main/othervm RepetitiveLambdaSerialization
+ */
+
+import java.io.*;
+
+public class RepetitiveLambdaSerialization {
+
+    static final int REPS = 20;
+
+    public static void main(String[] args) throws Exception {
+        LSI ls = z -> "[" + z + "]";
+        for (int i = 0; i < REPS; ++i) {
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            ObjectOutput out = new ObjectOutputStream(baos);
+            out.writeObject(ls);
+            out.flush();
+            out.close();
+        }
+        System.out.println("Passed.");
+    }
+}
+
+interface LSI extends Serializable {
+    String convert(String x);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/java/nio/Files/FilesLambdaTest.java	Mon Nov 11 23:17:30 2013 -0800
@@ -0,0 +1,336 @@
+/*
+ * Copyright (c) 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
+ * 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @summary function test for Files.list()/find()/walk()/lines()
+ * @library /sqeutil
+ * @(#) FilesLambdaTest.java
+ * @author Tristan Yan
+ * @run testng/othervm FilesLambdaTest
+ */
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.nio.charset.Charset;