8015322: Javac template test framework

Mon, 09 Sep 2013 17:11:55 -0400

author
emc
date
Mon, 09 Sep 2013 17:11:55 -0400
changeset 2017
67c5110c60fe
parent 2016
f4efd6ef6e80
child 2018
7439356a7dc5

8015322: Javac template test framework
Summary: Putback of the javac template test framework from the Lambda repository
Reviewed-by: jjg
Contributed-by: brian.goetz@oracle.com

README file | annotate | diff | comparison | revisions
test/lib/combo/TEST.properties file | annotate | diff | comparison | revisions
test/lib/combo/tools/javac/combo/Diagnostics.java file | annotate | diff | comparison | revisions
test/lib/combo/tools/javac/combo/JavacTemplateTestBase.java file | annotate | diff | comparison | revisions
test/lib/combo/tools/javac/combo/Template.java file | annotate | diff | comparison | revisions
test/lib/combo/tools/javac/combo/TemplateTest.java file | annotate | diff | comparison | revisions
test/tools/javac/lambda/bridge/template_tests/BridgeMethodTestCase.java file | annotate | diff | comparison | revisions
test/tools/javac/lambda/bridge/template_tests/BridgeMethodsTemplateTest.java file | annotate | diff | comparison | revisions
test/tools/javac/lambda/bridge/template_tests/TEST.properties file | annotate | diff | comparison | revisions
     1.1 --- a/README	Mon Sep 09 16:26:55 2013 -0400
     1.2 +++ b/README	Mon Sep 09 17:11:55 2013 -0400
     1.3 @@ -32,7 +32,7 @@
     1.4  JLS and JVMS.
     1.5  
     1.6  In addition, there is a substantial collection of regression and unit
     1.7 -tests for all the tools in the maain langtools test/ directory.
     1.8 +tests for all the tools in the main langtools test/ directory.
     1.9  
    1.10  Finally, there is a small set of tests to do basic validation of a build
    1.11  of the langtools workspace for use by JDK. These tests check the contents
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/test/lib/combo/TEST.properties	Mon Sep 09 17:11:55 2013 -0400
     2.3 @@ -0,0 +1,4 @@
     2.4 +# This file identifies root(s) of the test-ng hierarchy.
     2.5 +
     2.6 +
     2.7 +TestNG.dirs = .
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/test/lib/combo/tools/javac/combo/Diagnostics.java	Mon Sep 09 17:11:55 2013 -0400
     3.3 @@ -0,0 +1,82 @@
     3.4 +/*
     3.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     3.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3.7 + *
     3.8 + * This code is free software; you can redistribute it and/or modify it
     3.9 + * under the terms of the GNU General Public License version 2 only, as
    3.10 + * published by the Free Software Foundation.
    3.11 + *
    3.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    3.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    3.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    3.15 + * version 2 for more details (a copy is included in the LICENSE file that
    3.16 + * accompanied this code).
    3.17 + *
    3.18 + * You should have received a copy of the GNU General Public License version
    3.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    3.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    3.21 + *
    3.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    3.23 + * or visit www.oracle.com if you need additional information or have any
    3.24 + * questions.
    3.25 + */
    3.26 +package tools.javac.combo;
    3.27 +
    3.28 +import javax.tools.Diagnostic;
    3.29 +import javax.tools.JavaFileObject;
    3.30 +import java.util.ArrayList;
    3.31 +import java.util.List;
    3.32 +
    3.33 +import static java.util.stream.Collectors.toList;
    3.34 +
    3.35 +/**
    3.36 +* A container for compiler diagnostics, separated into errors and warnings,
    3.37 + * used by JavacTemplateTestBase.
    3.38 + *
    3.39 + * @author Brian Goetz
    3.40 +*/
    3.41 +public class Diagnostics implements javax.tools.DiagnosticListener<JavaFileObject> {
    3.42 +
    3.43 +    protected List<Diagnostic<? extends JavaFileObject>> diags = new ArrayList<>();
    3.44 +    protected boolean foundErrors = false;
    3.45 +
    3.46 +    public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
    3.47 +        diags.add(diagnostic);
    3.48 +        foundErrors = foundErrors || diagnostic.getKind() == Diagnostic.Kind.ERROR;
    3.49 +    }
    3.50 +
    3.51 +    /** Were there any errors found? */
    3.52 +    public boolean errorsFound() {
    3.53 +        return foundErrors;
    3.54 +    }
    3.55 +
    3.56 +    /** Get all diagnostic keys */
    3.57 +    public List<String> keys() {
    3.58 +        return diags.stream()
    3.59 +                    .map(Diagnostic::getCode)
    3.60 +                    .collect(toList());
    3.61 +    }
    3.62 +
    3.63 +    /** Do the diagnostics contain the specified error key? */
    3.64 +    public boolean containsErrorKey(String key) {
    3.65 +        return diags.stream()
    3.66 +                    .filter(d -> d.getKind() == Diagnostic.Kind.ERROR)
    3.67 +                    .anyMatch(d -> d.getCode().equals(key));
    3.68 +    }
    3.69 +
    3.70 +    /** Get the error keys */
    3.71 +    public List<String> errorKeys() {
    3.72 +        return diags.stream()
    3.73 +                    .filter(d -> d.getKind() == Diagnostic.Kind.ERROR)
    3.74 +                    .map(Diagnostic::getCode)
    3.75 +                    .collect(toList());
    3.76 +    }
    3.77 +
    3.78 +    public String toString() { return keys().toString(); }
    3.79 +
    3.80 +    /** Clear all diagnostic state */
    3.81 +    public void reset() {
    3.82 +        diags.clear();
    3.83 +        foundErrors = false;
    3.84 +    }
    3.85 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/test/lib/combo/tools/javac/combo/JavacTemplateTestBase.java	Mon Sep 09 17:11:55 2013 -0400
     4.3 @@ -0,0 +1,362 @@
     4.4 +/*
     4.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     4.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4.7 + *
     4.8 + * This code is free software; you can redistribute it and/or modify it
     4.9 + * under the terms of the GNU General Public License version 2 only, as
    4.10 + * published by the Free Software Foundation.
    4.11 + *
    4.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    4.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    4.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    4.15 + * version 2 for more details (a copy is included in the LICENSE file that
    4.16 + * accompanied this code).
    4.17 + *
    4.18 + * You should have received a copy of the GNU General Public License version
    4.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    4.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    4.21 + *
    4.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    4.23 + * or visit www.oracle.com if you need additional information or have any
    4.24 + * questions.
    4.25 + */
    4.26 +package tools.javac.combo;
    4.27 +
    4.28 +import java.io.File;
    4.29 +import java.io.IOException;
    4.30 +import java.net.MalformedURLException;
    4.31 +import java.net.URI;
    4.32 +import java.net.URL;
    4.33 +import java.net.URLClassLoader;
    4.34 +import java.util.ArrayList;
    4.35 +import java.util.Arrays;
    4.36 +import java.util.Collections;
    4.37 +import java.util.HashMap;
    4.38 +import java.util.HashSet;
    4.39 +import java.util.List;
    4.40 +import java.util.Map;
    4.41 +import java.util.Set;
    4.42 +import java.util.concurrent.atomic.AtomicInteger;
    4.43 +import javax.tools.JavaCompiler;
    4.44 +import javax.tools.JavaFileObject;
    4.45 +import javax.tools.SimpleJavaFileObject;
    4.46 +import javax.tools.StandardJavaFileManager;
    4.47 +import javax.tools.StandardLocation;
    4.48 +import javax.tools.ToolProvider;
    4.49 +
    4.50 +import com.sun.source.util.JavacTask;
    4.51 +import com.sun.tools.javac.util.Pair;
    4.52 +import org.testng.ITestResult;
    4.53 +import org.testng.annotations.AfterMethod;
    4.54 +import org.testng.annotations.AfterSuite;
    4.55 +import org.testng.annotations.BeforeMethod;
    4.56 +import org.testng.annotations.Test;
    4.57 +
    4.58 +import static org.testng.Assert.fail;
    4.59 +
    4.60 +/**
    4.61 + * Base class for template-driven TestNG javac tests that support on-the-fly
    4.62 + * source file generation, compilation, classloading, execution, and separate
    4.63 + * compilation.
    4.64 + *
    4.65 + * <p>Manages a set of templates (which have embedded tags of the form
    4.66 + * {@code #\{NAME\}}), source files (which are also templates), and compile
    4.67 + * options.  Test cases can register templates and source files, cause them to
    4.68 + * be compiled, validate whether the set of diagnostic messages output by the
    4.69 + * compiler is correct, and optionally load and run the compiled classes.
    4.70 + *
    4.71 + * @author Brian Goetz
    4.72 + */
    4.73 +@Test
    4.74 +public abstract class JavacTemplateTestBase {
    4.75 +    private static final Set<String> suiteErrors = Collections.synchronizedSet(new HashSet<>());
    4.76 +    private static final AtomicInteger counter = new AtomicInteger();
    4.77 +    private static final File root = new File("gen");
    4.78 +    private static final File nullDir = new File("empty");
    4.79 +
    4.80 +    protected final Map<String, Template> templates = new HashMap<>();
    4.81 +    protected final Diagnostics diags = new Diagnostics();
    4.82 +    protected final List<Pair<String, Template>> sourceFiles = new ArrayList<>();
    4.83 +    protected final List<String> compileOptions = new ArrayList<>();
    4.84 +    protected final List<File> classpaths = new ArrayList<>();
    4.85 +    protected final Template.Resolver defaultResolver = new MapResolver(templates);
    4.86 +
    4.87 +    private Template.Resolver currentResolver = defaultResolver;
    4.88 +
    4.89 +    /** Add a template with a specified name */
    4.90 +    protected void addTemplate(String name, Template t) {
    4.91 +        templates.put(name, t);
    4.92 +    }
    4.93 +
    4.94 +    /** Add a template with a specified name */
    4.95 +    protected void addTemplate(String name, String s) {
    4.96 +        templates.put(name, new StringTemplate(s));
    4.97 +    }
    4.98 +
    4.99 +    /** Add a source file */
   4.100 +    protected void addSourceFile(String name, Template t) {
   4.101 +        sourceFiles.add(new Pair<>(name, t));
   4.102 +    }
   4.103 +
   4.104 +    /** Add a File to the class path to be used when loading classes; File values
   4.105 +     * will generally be the result of a previous call to {@link #compile()}.
   4.106 +     * This enables testing of separate compilation scenarios if the class path
   4.107 +     * is set up properly.
   4.108 +     */
   4.109 +    protected void addClassPath(File path) {
   4.110 +        classpaths.add(path);
   4.111 +    }
   4.112 +
   4.113 +    /**
   4.114 +     * Add a set of compilation command-line options
   4.115 +     */
   4.116 +    protected void addCompileOptions(String... opts) {
   4.117 +        Collections.addAll(compileOptions, opts);
   4.118 +    }
   4.119 +
   4.120 +    /** Reset the compile options to the default (empty) value */
   4.121 +    protected void resetCompileOptions() { compileOptions.clear(); }
   4.122 +
   4.123 +    /** Remove all templates */
   4.124 +    protected void resetTemplates() { templates.clear(); }
   4.125 +
   4.126 +    /** Remove accumulated diagnostics */
   4.127 +    protected void resetDiagnostics() { diags.reset(); }
   4.128 +
   4.129 +    /** Remove all source files */
   4.130 +    protected void resetSourceFiles() { sourceFiles.clear(); }
   4.131 +
   4.132 +    /** Remove registered class paths */
   4.133 +    protected void resetClassPaths() { classpaths.clear(); }
   4.134 +
   4.135 +    // Before each test method, reset everything
   4.136 +    @BeforeMethod
   4.137 +    public void reset() {
   4.138 +        resetCompileOptions();
   4.139 +        resetDiagnostics();
   4.140 +        resetSourceFiles();
   4.141 +        resetTemplates();
   4.142 +        resetClassPaths();
   4.143 +    }
   4.144 +
   4.145 +    // After each test method, if the test failed, capture source files and diagnostics and put them in the log
   4.146 +    @AfterMethod
   4.147 +    public void copyErrors(ITestResult result) {
   4.148 +        if (!result.isSuccess()) {
   4.149 +            suiteErrors.addAll(diags.errorKeys());
   4.150 +
   4.151 +            List<Object> list = new ArrayList<>();
   4.152 +            Collections.addAll(list, result.getParameters());
   4.153 +            list.add("Test case: " + getTestCaseDescription());
   4.154 +            for (Pair<String, Template> e : sourceFiles)
   4.155 +                list.add("Source file " + e.fst + ": " + e.snd);
   4.156 +            if (diags.errorsFound())
   4.157 +                list.add("Compile diagnostics: " + diags.toString());
   4.158 +            result.setParameters(list.toArray(new Object[list.size()]));
   4.159 +        }
   4.160 +    }
   4.161 +
   4.162 +    @AfterSuite
   4.163 +    // After the suite is done, dump any errors to output
   4.164 +    public void dumpErrors() {
   4.165 +        if (!suiteErrors.isEmpty())
   4.166 +            System.err.println("Errors found in test suite: " + suiteErrors);
   4.167 +    }
   4.168 +
   4.169 +    /**
   4.170 +     * Get a description of this test case; since test cases may be combinatorially
   4.171 +     * generated, this should include all information needed to describe the test case
   4.172 +     */
   4.173 +    protected String getTestCaseDescription() {
   4.174 +        return this.toString();
   4.175 +    }
   4.176 +
   4.177 +    /** Assert that all previous calls to compile() succeeded */
   4.178 +    protected void assertCompileSucceeded() {
   4.179 +        if (diags.errorsFound())
   4.180 +            fail("Expected successful compilation");
   4.181 +    }
   4.182 +
   4.183 +    /**
   4.184 +     * If the provided boolean is true, assert all previous compiles succeeded,
   4.185 +     * otherwise assert that a compile failed.
   4.186 +     * */
   4.187 +    protected void assertCompileSucceededIff(boolean b) {
   4.188 +        if (b)
   4.189 +            assertCompileSucceeded();
   4.190 +        else
   4.191 +            assertCompileFailed();
   4.192 +    }
   4.193 +
   4.194 +    /** Assert that a previous call to compile() failed */
   4.195 +    protected void assertCompileFailed() {
   4.196 +        if (!diags.errorsFound())
   4.197 +            fail("Expected failed compilation");
   4.198 +    }
   4.199 +
   4.200 +    /** Assert that a previous call to compile() failed with a specific error key */
   4.201 +    protected void assertCompileFailed(String message) {
   4.202 +        if (!diags.errorsFound())
   4.203 +            fail("Expected failed compilation: " + message);
   4.204 +    }
   4.205 +
   4.206 +    /** Assert that a previous call to compile() failed with all of the specified error keys */
   4.207 +    protected void assertCompileErrors(String... keys) {
   4.208 +        if (!diags.errorsFound())
   4.209 +            fail("Expected failed compilation");
   4.210 +        for (String k : keys)
   4.211 +            if (!diags.containsErrorKey(k))
   4.212 +                fail("Expected compilation error " + k);
   4.213 +    }
   4.214 +
   4.215 +    /** Convert an object, which may be a Template or a String, into a Template */
   4.216 +    protected Template asTemplate(Object o) {
   4.217 +        if (o instanceof Template)
   4.218 +            return (Template) o;
   4.219 +        else if (o instanceof String)
   4.220 +            return new StringTemplate((String) o);
   4.221 +        else
   4.222 +            return new StringTemplate(o.toString());
   4.223 +    }
   4.224 +
   4.225 +    /** Compile all registered source files */
   4.226 +    protected void compile() throws IOException {
   4.227 +        compile(false);
   4.228 +    }
   4.229 +
   4.230 +    /** Compile all registered source files, optionally generating class files
   4.231 +     * and returning a File describing the directory to which they were written */
   4.232 +    protected File compile(boolean generate) throws IOException {
   4.233 +        List<JavaFileObject> files = new ArrayList<>();
   4.234 +        for (Pair<String, Template> e : sourceFiles)
   4.235 +            files.add(new FileAdapter(e.fst, asTemplate(e.snd)));
   4.236 +        return compile(classpaths, files, generate);
   4.237 +    }
   4.238 +
   4.239 +    /** Compile all registered source files, using the provided list of class paths
   4.240 +     * for finding required classfiles, optionally generating class files
   4.241 +     * and returning a File describing the directory to which they were written */
   4.242 +    protected File compile(List<File> classpaths, boolean generate) throws IOException {
   4.243 +        List<JavaFileObject> files = new ArrayList<>();
   4.244 +        for (Pair<String, Template> e : sourceFiles)
   4.245 +            files.add(new FileAdapter(e.fst, asTemplate(e.snd)));
   4.246 +        return compile(classpaths, files, generate);
   4.247 +    }
   4.248 +
   4.249 +    private File compile(List<File> classpaths, List<JavaFileObject> files, boolean generate) throws IOException {
   4.250 +        JavaCompiler systemJavaCompiler = ToolProvider.getSystemJavaCompiler();
   4.251 +        StandardJavaFileManager fm = systemJavaCompiler.getStandardFileManager(null, null, null);
   4.252 +        if (classpaths.size() > 0)
   4.253 +            fm.setLocation(StandardLocation.CLASS_PATH, classpaths);
   4.254 +        JavacTask ct = (JavacTask) systemJavaCompiler.getTask(null, fm, diags, compileOptions, null, files);
   4.255 +        if (generate) {
   4.256 +            File destDir = new File(root, Integer.toString(counter.incrementAndGet()));
   4.257 +            // @@@ Assert that this directory didn't exist, or start counter at max+1
   4.258 +            destDir.mkdirs();
   4.259 +            fm.setLocation(StandardLocation.CLASS_OUTPUT, Arrays.asList(destDir));
   4.260 +            ct.generate();
   4.261 +            return destDir;
   4.262 +        }
   4.263 +        else {
   4.264 +            ct.analyze();
   4.265 +            return nullDir;
   4.266 +        }
   4.267 +    }
   4.268 +
   4.269 +    /** Load the given class using the provided list of class paths */
   4.270 +    protected Class<?> loadClass(String className, File... destDirs) {
   4.271 +        try {
   4.272 +            List<URL> list = new ArrayList<>();
   4.273 +            for (File f : destDirs)
   4.274 +                list.add(new URL("file:" + f.toString().replace("\\", "/") + "/"));
   4.275 +            return Class.forName(className, true, new URLClassLoader(list.toArray(new URL[list.size()])));
   4.276 +        } catch (ClassNotFoundException | MalformedURLException e) {
   4.277 +            throw new RuntimeException("Error loading class " + className, e);
   4.278 +        }
   4.279 +    }
   4.280 +
   4.281 +    /** An implementation of Template which is backed by a String */
   4.282 +    protected class StringTemplate implements Template {
   4.283 +        protected final String template;
   4.284 +
   4.285 +        public StringTemplate(String template) {
   4.286 +            this.template = template;
   4.287 +        }
   4.288 +
   4.289 +        public String expand(String selector) {
   4.290 +            return Behavior.expandTemplate(template, currentResolver);
   4.291 +        }
   4.292 +
   4.293 +        public String toString() {
   4.294 +            return expand("");
   4.295 +        }
   4.296 +
   4.297 +        public StringTemplate with(final String key, final String value) {
   4.298 +            return new StringTemplateWithResolver(template, new KeyResolver(key, value));
   4.299 +        }
   4.300 +
   4.301 +    }
   4.302 +
   4.303 +    /** An implementation of Template which is backed by a String and which
   4.304 +     * encapsulates a Resolver for resolving embedded tags. */
   4.305 +    protected class StringTemplateWithResolver extends StringTemplate {
   4.306 +        private final Resolver localResolver;
   4.307 +
   4.308 +        public StringTemplateWithResolver(String template, Resolver localResolver) {
   4.309 +            super(template);
   4.310 +            this.localResolver = localResolver;
   4.311 +        }
   4.312 +
   4.313 +        @Override
   4.314 +        public String expand(String selector) {
   4.315 +            Resolver saved = currentResolver;
   4.316 +            currentResolver = new ChainedResolver(currentResolver, localResolver);
   4.317 +            try {
   4.318 +                return super.expand(selector);
   4.319 +            }
   4.320 +            finally {
   4.321 +                currentResolver = saved;
   4.322 +            }
   4.323 +        }
   4.324 +
   4.325 +        @Override
   4.326 +        public StringTemplate with(String key, String value) {
   4.327 +            return new StringTemplateWithResolver(template, new ChainedResolver(localResolver, new KeyResolver(key, value)));
   4.328 +        }
   4.329 +    }
   4.330 +
   4.331 +    /** A Resolver which uses a Map to resolve tags */
   4.332 +    private class KeyResolver implements Template.Resolver {
   4.333 +        private final String key;
   4.334 +        private final String value;
   4.335 +
   4.336 +        public KeyResolver(String key, String value) {
   4.337 +            this.key = key;
   4.338 +            this.value = value;
   4.339 +        }
   4.340 +
   4.341 +        @Override
   4.342 +        public Template lookup(String k) {
   4.343 +            return key.equals(k) ? new StringTemplate(value) : null;
   4.344 +        }
   4.345 +    }
   4.346 +
   4.347 +    private class FileAdapter extends SimpleJavaFileObject {
   4.348 +        private final String filename;
   4.349 +        private final Template template;
   4.350 +
   4.351 +        public FileAdapter(String filename, Template template) {
   4.352 +            super(URI.create("myfo:/" + filename), Kind.SOURCE);
   4.353 +            this.template = template;
   4.354 +            this.filename = filename;
   4.355 +        }
   4.356 +
   4.357 +        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
   4.358 +            return toString();
   4.359 +        }
   4.360 +
   4.361 +        public String toString() {
   4.362 +            return Template.Behavior.expandTemplate(template.expand(filename), defaultResolver);
   4.363 +        }
   4.364 +    }
   4.365 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/test/lib/combo/tools/javac/combo/Template.java	Mon Sep 09 17:11:55 2013 -0400
     5.3 @@ -0,0 +1,112 @@
     5.4 +/*
     5.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     5.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5.7 + *
     5.8 + * This code is free software; you can redistribute it and/or modify it
     5.9 + * under the terms of the GNU General Public License version 2 only, as
    5.10 + * published by the Free Software Foundation.
    5.11 + *
    5.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    5.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    5.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    5.15 + * version 2 for more details (a copy is included in the LICENSE file that
    5.16 + * accompanied this code).
    5.17 + *
    5.18 + * You should have received a copy of the GNU General Public License version
    5.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    5.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    5.21 + *
    5.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    5.23 + * or visit www.oracle.com if you need additional information or have any
    5.24 + * questions.
    5.25 + */
    5.26 +package tools.javac.combo;
    5.27 +
    5.28 +import java.util.Map;
    5.29 +import java.util.regex.Matcher;
    5.30 +import java.util.regex.Pattern;
    5.31 +
    5.32 +/**
    5.33 + * A template into which tags of the form {@code #\{KEY\}} or
    5.34 + * {@code #\{KEY.SUBKEY\}} can be expanded.
    5.35 + */
    5.36 +public interface Template {
    5.37 +    String expand(String selector);
    5.38 +
    5.39 +    interface Resolver {
    5.40 +        public Template lookup(String key);
    5.41 +    }
    5.42 +
    5.43 +    public static class Behavior {
    5.44 +        /* Looks for expandable keys.  An expandable key can take the form:
    5.45 +         *   #{MAJOR}
    5.46 +         *   #{MAJOR.MINOR}
    5.47 +         *   where MAJOR can be IDENTIFIER or IDENTIFIER[NUMERIC_INDEX]
    5.48 +         *   and MINOR can be an identifier
    5.49 +         */
    5.50 +        private static final Pattern pattern = Pattern.compile("#\\{([A-Z_][A-Z0-9_]*(?:\\[\\d+\\])?)(?:\\.([A-Z_][A-Z0-9_]*))?\\}");
    5.51 +
    5.52 +        public static String expandTemplate(String template, final Map<String, Template> vars) {
    5.53 +            return expandTemplate(template, new MapResolver(vars));
    5.54 +        }
    5.55 +
    5.56 +        public static String expandTemplate(String template, Resolver res) {
    5.57 +            CharSequence in = template;
    5.58 +            StringBuffer out = new StringBuffer();
    5.59 +            while (true) {
    5.60 +                boolean more = false;
    5.61 +                Matcher m = pattern.matcher(in);
    5.62 +                while (m.find()) {
    5.63 +                    String major = m.group(1);
    5.64 +                    String minor = m.group(2);
    5.65 +                    Template key = res.lookup(major);
    5.66 +                    if (key == null)
    5.67 +                        throw new IllegalStateException("Unknown major key " + major);
    5.68 +
    5.69 +                    String replacement = key.expand(minor == null ? "" : minor);
    5.70 +                    more |= pattern.matcher(replacement).find();
    5.71 +                    m.appendReplacement(out, replacement);
    5.72 +                }
    5.73 +                m.appendTail(out);
    5.74 +                if (!more)
    5.75 +                    return out.toString();
    5.76 +                else {
    5.77 +                    in = out;
    5.78 +                    out = new StringBuffer();
    5.79 +                }
    5.80 +            }
    5.81 +        }
    5.82 +
    5.83 +    }
    5.84 +}
    5.85 +
    5.86 +class MapResolver implements Template.Resolver {
    5.87 +    private final Map<String, Template> vars;
    5.88 +
    5.89 +    public MapResolver(Map<String, Template> vars) {this.vars = vars;}
    5.90 +
    5.91 +    public Template lookup(String key) {
    5.92 +        return vars.get(key);
    5.93 +    }
    5.94 +}
    5.95 +
    5.96 +class ChainedResolver implements Template.Resolver {
    5.97 +    private final Template.Resolver upstreamResolver, thisResolver;
    5.98 +
    5.99 +    public ChainedResolver(Template.Resolver upstreamResolver, Template.Resolver thisResolver) {
   5.100 +        this.upstreamResolver = upstreamResolver;
   5.101 +        this.thisResolver = thisResolver;
   5.102 +    }
   5.103 +
   5.104 +    public Template.Resolver getUpstreamResolver() {
   5.105 +        return upstreamResolver;
   5.106 +    }
   5.107 +
   5.108 +    @Override
   5.109 +    public Template lookup(String key) {
   5.110 +        Template result = thisResolver.lookup(key);
   5.111 +        if (result == null)
   5.112 +            result = upstreamResolver.lookup(key);
   5.113 +        return result;
   5.114 +    }
   5.115 +}
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/test/lib/combo/tools/javac/combo/TemplateTest.java	Mon Sep 09 17:11:55 2013 -0400
     6.3 @@ -0,0 +1,94 @@
     6.4 +/*
     6.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     6.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.7 + *
     6.8 + * This code is free software; you can redistribute it and/or modify it
     6.9 + * under the terms of the GNU General Public License version 2 only, as
    6.10 + * published by the Free Software Foundation.
    6.11 + *
    6.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    6.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    6.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    6.15 + * version 2 for more details (a copy is included in the LICENSE file that
    6.16 + * accompanied this code).
    6.17 + *
    6.18 + * You should have received a copy of the GNU General Public License version
    6.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    6.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    6.21 + *
    6.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    6.23 + * or visit www.oracle.com if you need additional information or have any
    6.24 + * questions.
    6.25 + *
    6.26 + */
    6.27 +package tools.javac.combo;
    6.28 +
    6.29 +import org.testng.annotations.BeforeTest;
    6.30 +import org.testng.annotations.Test;
    6.31 +
    6.32 +import java.util.HashMap;
    6.33 +import java.util.Map;
    6.34 +
    6.35 +import static org.testng.Assert.assertEquals;
    6.36 +
    6.37 +/**
    6.38 + * TemplateTest
    6.39 + */
    6.40 +@Test
    6.41 +public class TemplateTest {
    6.42 +    Map<String, Template> vars = new HashMap<>();
    6.43 +
    6.44 +    @BeforeTest
    6.45 +    void before() { vars.clear(); }
    6.46 +
    6.47 +    private void assertTemplate(String expected, String template) {
    6.48 +        String result = Template.Behavior.expandTemplate(template, vars);
    6.49 +        assertEquals(result, expected, "for " + template);
    6.50 +    }
    6.51 +
    6.52 +    private String dotIf(String s) {
    6.53 +        return s == null || s.isEmpty() ? "" : "." + s;
    6.54 +    }
    6.55 +
    6.56 +    public void testTemplateExpansion() {
    6.57 +        vars.put("A", s -> "a" + dotIf(s));
    6.58 +        vars.put("B", s -> "b" + dotIf(s));
    6.59 +        vars.put("C", s -> "#{A}#{B}");
    6.60 +        vars.put("D", s -> "#{A" + dotIf(s) + "}#{B" + dotIf(s) + "}");
    6.61 +        vars.put("_D", s -> "d");
    6.62 +
    6.63 +        assertTemplate("", "");
    6.64 +        assertTemplate("foo", "foo");
    6.65 +        assertTemplate("a", "#{A}");
    6.66 +        assertTemplate("a", "#{A.}");
    6.67 +        assertTemplate("a.FOO", "#{A.FOO}");
    6.68 +        assertTemplate("aa", "#{A}#{A}");
    6.69 +        assertTemplate("ab", "#{C}");
    6.70 +        assertTemplate("ab", "#{C.FOO}");
    6.71 +        assertTemplate("ab", "#{C.}");
    6.72 +        assertTemplate("a.FOOb.FOO", "#{D.FOO}");
    6.73 +        assertTemplate("ab", "#{D}");
    6.74 +        assertTemplate("d", "#{_D}");
    6.75 +        assertTemplate("#{A", "#{A");
    6.76 +    }
    6.77 +
    6.78 +    public void testIndexedTemplate() {
    6.79 +        vars.put("A[0]", s -> "a" );
    6.80 +        vars.put("A[1]", s -> "b" );
    6.81 +        vars.put("A[2]", s -> "c" );
    6.82 +        vars.put("X", s -> "0");
    6.83 +        assertTemplate("a", "#{A[0]}");
    6.84 +        assertTemplate("b", "#{A[1]}");
    6.85 +        assertTemplate("c", "#{A[2]}");
    6.86 +    }
    6.87 +
    6.88 +    public void testAngleBrackets() {
    6.89 +        vars.put("X", s -> "xyz");
    6.90 +        assertTemplate("List<String> ls = xyz;", "List<String> ls = #{X};");
    6.91 +    }
    6.92 +
    6.93 +    @Test(expectedExceptions = IllegalStateException.class )
    6.94 +    public void testUnknownKey() {
    6.95 +        assertTemplate("#{Q}", "#{Q}");
    6.96 +    }
    6.97 +}
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/test/tools/javac/lambda/bridge/template_tests/BridgeMethodTestCase.java	Mon Sep 09 17:11:55 2013 -0400
     7.3 @@ -0,0 +1,421 @@
     7.4 +/*
     7.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     7.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     7.7 + *
     7.8 + * This code is free software; you can redistribute it and/or modify it
     7.9 + * under the terms of the GNU General Public License version 2 only, as
    7.10 + * published by the Free Software Foundation.
    7.11 + *
    7.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    7.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    7.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    7.15 + * version 2 for more details (a copy is included in the LICENSE file that
    7.16 + * accompanied this code).
    7.17 + *
    7.18 + * You should have received a copy of the GNU General Public License version
    7.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    7.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    7.21 + *
    7.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    7.23 + * or visit www.oracle.com if you need additional information or have any
    7.24 + * questions.
    7.25 + *
    7.26 + */
    7.27 +import java.io.File;
    7.28 +import java.io.IOException;
    7.29 +import java.lang.reflect.Method;
    7.30 +import java.util.ArrayList;
    7.31 +import java.util.Arrays;
    7.32 +import java.util.HashMap;
    7.33 +import java.util.List;
    7.34 +import java.util.Map;
    7.35 +import java.util.StringJoiner;
    7.36 +
    7.37 +import org.testng.annotations.BeforeMethod;
    7.38 +import org.testng.annotations.Test;
    7.39 +
    7.40 +import tools.javac.combo.*;
    7.41 +
    7.42 +import static org.testng.Assert.fail;
    7.43 +
    7.44 +/**
    7.45 + * BridgeMethodTestCase -- used for asserting linkage to bridges under separate compilation.
    7.46 + *
    7.47 + * Example test case:
    7.48 + *     public void test1() throws IOException, ReflectiveOperationException {
    7.49 + *         compileSpec("C(Bc1(A))");
    7.50 + *         assertLinkage("C", LINKAGE_ERROR, "B1");
    7.51 + *         recompileSpec("C(Bc1(Ac0))", "A");
    7.52 + *          assertLinkage("C", "A0", "B1");
    7.53 + *     }
    7.54 + *
    7.55 + * This compiles A, B, and C, asserts that C.m()Object does not exist, asserts
    7.56 + * that C.m()Number eventually invokes B.m()Number, recompiles B, and then asserts
    7.57 + * that the result of calling C.m()Object now arrives at A.
    7.58 + *
    7.59 + * @author Brian Goetz
    7.60 + */
    7.61 +
    7.62 +@Test
    7.63 +public abstract class BridgeMethodTestCase extends JavacTemplateTestBase {
    7.64 +
    7.65 +    private static final String TYPE_LETTERS = "ABCDIJK";
    7.66 +
    7.67 +    private static final String BASE_INDEX_CLASS = "class C0 {\n" +
    7.68 +                                                   "    int val;\n" +
    7.69 +                                                   "    C0(int val) { this.val = val; }\n" +
    7.70 +                                                   "    public int getVal() { return val; }\n" +
    7.71 +                                                   "}\n";
    7.72 +    private static final String INDEX_CLASS_TEMPLATE = "class C#ID extends C#PREV {\n" +
    7.73 +                                                       "    C#ID(int val) { super(val); }\n" +
    7.74 +                                                       "}\n";
    7.75 +
    7.76 +
    7.77 +
    7.78 +    protected static String LINKAGE_ERROR = "-1";
    7.79 +
    7.80 +    private List<File> compileDirs = new ArrayList<>();
    7.81 +
    7.82 +    /**
    7.83 +     * Compile all the classes in a class spec, and put them on the classpath.
    7.84 +     *
    7.85 +     * The spec is the specification for a nest of classes, using the following notation
    7.86 +     * A, B represent abstract classes
    7.87 +     * C represents a concrete class
    7.88 +     * I, J, K represent interfaces
    7.89 +     * Lowercase 'c' following a class means that the method m() is concrete
    7.90 +     * Lowercase 'a' following a class or interface means that the method m() is abstract
    7.91 +     * Lowercase 'd' following an interface means that the method m() is default
    7.92 +     * A number 0, 1, or 2 following the lowercase letter indicates the return type of that method
    7.93 +     * 0 = Object, 1 = Number, 2 = Integer (these form an inheritance chain so bridges are generated)
    7.94 +     * A classes supertypes follow its method spec, in parentheses
    7.95 +     * Examples:
    7.96 +     *   C(Ia0, Jd0) -- C extends I and J, I has abstract m()Object, J has default m()Object
    7.97 +     *   Cc1(Ia0) -- C has concrete m()Number, extends I with abstract m()Object
    7.98 +     * If a type must appear multiple times, its full spec must be in the first occurrence
    7.99 +     * Example:
   7.100 +     *   C(I(Kd0), J(K))
   7.101 +     */
   7.102 +   protected void compileSpec(String spec) throws IOException {
   7.103 +        compileSpec(spec, false);
   7.104 +    }
   7.105 +
   7.106 +    /**
   7.107 +     * Compile all the classes in a class spec, and assert that there were compilation errors.
   7.108 +     */
   7.109 +    protected void compileSpec(String spec, String... errorKeys) throws IOException {
   7.110 +        compileSpec(spec, false, errorKeys);
   7.111 +    }
   7.112 +
   7.113 +    protected void compileSpec(String spec, boolean debug, String... errorKeys) throws IOException {
   7.114 +        ClassModel cm = new Parser(spec).parseClassModel();
   7.115 +        for (int i = 0; i <= cm.maxIndex() ; i++) {
   7.116 +            if (debug) System.out.println(indexClass(i));
   7.117 +            addSourceFile(String.format("C%d.java", i), new StringTemplate(indexClass(i)));
   7.118 +        }
   7.119 +        for (Map.Entry<String, ClassModel> e : classes(cm).entrySet()) {
   7.120 +            if (debug) System.out.println(e.getValue().toSource());
   7.121 +            addSourceFile(e.getKey() + ".java", new StringTemplate(e.getValue().toSource()));
   7.122 +        }
   7.123 +        compileDirs.add(compile(true));
   7.124 +        resetSourceFiles();
   7.125 +        if (errorKeys.length == 0)
   7.126 +            assertCompileSucceeded();
   7.127 +        else
   7.128 +            assertCompileErrors(errorKeys);
   7.129 +    }
   7.130 +
   7.131 +    /**
   7.132 +     * Recompile only a subset of classes in the class spec, as named by names,
   7.133 +     * and put them on the classpath such that they shadow earlier versions of that class.
   7.134 +     */
   7.135 +    protected void recompileSpec(String spec, String... names) throws IOException {
   7.136 +        List<String> nameList = Arrays.asList(names);
   7.137 +        ClassModel cm = new Parser(spec).parseClassModel();
   7.138 +        for (int i = 0; i <= cm.maxIndex() ; i++) {
   7.139 +            addSourceFile(String.format("C%d.java", i), new StringTemplate(indexClass(i)));
   7.140 +        }
   7.141 +        for (Map.Entry<String, ClassModel> e : classes(cm).entrySet())
   7.142 +            if (nameList.contains(e.getKey()))
   7.143 +                addSourceFile(e.getKey() + ".java", new StringTemplate(e.getValue().toSource()));
   7.144 +        compileDirs.add(compile(Arrays.asList(classPaths()), true));
   7.145 +        resetSourceFiles();
   7.146 +        assertCompileSucceeded();
   7.147 +    }
   7.148 +
   7.149 +    protected void assertLinkage(String name, String... expected) throws ReflectiveOperationException {
   7.150 +        for (int i=0; i<expected.length; i++) {
   7.151 +            String e = expected[i];
   7.152 +            if (e.equals(LINKAGE_ERROR)) {
   7.153 +                try {
   7.154 +                    int actual = invoke(name, i);
   7.155 +                    fail("Expected linkage error, got" + fromNum(actual));
   7.156 +                }
   7.157 +                catch (LinkageError x) {
   7.158 +                    // success
   7.159 +                }
   7.160 +            }
   7.161 +            else {
   7.162 +                if (e.length() == 1)
   7.163 +                    e += "0";
   7.164 +                int expectedInt = toNum(e);
   7.165 +                int actual = invoke(name, i);
   7.166 +                if (expectedInt != actual)
   7.167 +                    fail(String.format("Expected %s but found %s for %s.m()%d", fromNum(expectedInt), fromNum(actual), name, i));
   7.168 +            }
   7.169 +        }
   7.170 +    }
   7.171 +
   7.172 +    private Map<String, ClassModel> classes(ClassModel cm) {
   7.173 +        HashMap<String, ClassModel> m = new HashMap<>();
   7.174 +        classesHelper(cm, m);
   7.175 +        return m;
   7.176 +    }
   7.177 +
   7.178 +    private String indexClass(int index) {
   7.179 +        if (index == 0) {
   7.180 +            return BASE_INDEX_CLASS;
   7.181 +        } else {
   7.182 +            return INDEX_CLASS_TEMPLATE
   7.183 +                    .replace("#ID", String.valueOf(index))
   7.184 +                    .replace("#PREV", String.valueOf(index - 1));
   7.185 +        }
   7.186 +    }
   7.187 +
   7.188 +    private static String overrideName(int index) {
   7.189 +        return "C" + index;
   7.190 +    }
   7.191 +
   7.192 +    private void classesHelper(ClassModel cm, Map<String, ClassModel> m) {
   7.193 +        if (!m.containsKey(cm.name))
   7.194 +            m.put(cm.name, cm);
   7.195 +        for (ClassModel s : cm.supertypes)
   7.196 +            classesHelper(s, m);
   7.197 +    }
   7.198 +
   7.199 +    private static String fromNum(int num) {
   7.200 +        return String.format("%c%d", TYPE_LETTERS.charAt(num / 10), num % 10);
   7.201 +    }
   7.202 +
   7.203 +    private static int toNum(String name, int index) {
   7.204 +        return 10*(TYPE_LETTERS.indexOf(name.charAt(0))) + index;
   7.205 +    }
   7.206 +
   7.207 +    private static int toNum(String string) {
   7.208 +        return 10*(TYPE_LETTERS.indexOf(string.charAt(0))) + Integer.parseInt(string.substring(1, 2));
   7.209 +    }
   7.210 +
   7.211 +    private int invoke(String name, int index) throws ReflectiveOperationException {
   7.212 +        File[] files = classPaths();
   7.213 +        Class clazz = loadClass(name, files);
   7.214 +        Method[] ms = clazz.getMethods();
   7.215 +        for (Method m : ms) {
   7.216 +            if (m.getName().equals("m") && m.getReturnType().getName().equals(overrideName(index))) {
   7.217 +                m.setAccessible(true);
   7.218 +                Object instance = clazz.newInstance();
   7.219 +                Object c0 = m.invoke(instance);
   7.220 +                Method getVal = c0.getClass().getMethod("getVal");
   7.221 +                getVal.setAccessible(true);
   7.222 +                return (int)getVal.invoke(c0);
   7.223 +            }
   7.224 +        }
   7.225 +        throw new NoSuchMethodError("cannot find method m()" + index + " in class " + name);
   7.226 +    }
   7.227 +
   7.228 +    private File[] classPaths() {
   7.229 +        File[] files = new File[compileDirs.size()];
   7.230 +        for (int i=0; i<files.length; i++)
   7.231 +            files[files.length - i - 1] = compileDirs.get(i);
   7.232 +        return files;
   7.233 +    }
   7.234 +
   7.235 +    @BeforeMethod
   7.236 +    @Override
   7.237 +    public void reset() {
   7.238 +        compileDirs.clear();
   7.239 +        super.reset();
   7.240 +    }
   7.241 +
   7.242 +    private static class ClassModel {
   7.243 +
   7.244 +        enum MethodType {
   7.245 +            ABSTRACT('a'), CONCRETE('c'), DEFAULT('d');
   7.246 +
   7.247 +            public final char designator;
   7.248 +
   7.249 +            MethodType(char designator) {
   7.250 +                this.designator = designator;
   7.251 +            }
   7.252 +
   7.253 +            public static MethodType find(char c) {
   7.254 +                for (MethodType m : values())
   7.255 +                    if (m.designator == c)
   7.256 +                        return m;
   7.257 +                throw new IllegalArgumentException();
   7.258 +            }
   7.259 +        }
   7.260 +
   7.261 +        private final String name;
   7.262 +        private final boolean isInterface;
   7.263 +        private final List<ClassModel> supertypes;
   7.264 +        private final MethodType methodType;
   7.265 +        private final int methodIndex;
   7.266 +
   7.267 +        private ClassModel(String name,
   7.268 +                           boolean anInterface,
   7.269 +                           List<ClassModel> supertypes,
   7.270 +                           MethodType methodType,
   7.271 +                           int methodIndex) {
   7.272 +            this.name = name;
   7.273 +            isInterface = anInterface;
   7.274 +            this.supertypes = supertypes;
   7.275 +            this.methodType = methodType;
   7.276 +            this.methodIndex = methodIndex;
   7.277 +        }
   7.278 +
   7.279 +        @Override
   7.280 +        public String toString() {
   7.281 +            StringBuilder sb = new StringBuilder();
   7.282 +            sb.append(name);
   7.283 +            if (methodType != null) {
   7.284 +                sb.append(methodType.designator);
   7.285 +                sb.append(methodIndex);
   7.286 +            }
   7.287 +            if (!supertypes.isEmpty()) {
   7.288 +                sb.append("(");
   7.289 +                for (int i=0; i<supertypes.size(); i++) {
   7.290 +                    if (i > 0)
   7.291 +                        sb.append(",");
   7.292 +                    sb.append(supertypes.get(i).toString());
   7.293 +                }
   7.294 +                sb.append(")");
   7.295 +            }
   7.296 +            return sb.toString();
   7.297 +        }
   7.298 +
   7.299 +        int maxIndex() {
   7.300 +            int maxSoFar = methodIndex;
   7.301 +            for (ClassModel cm : supertypes) {
   7.302 +                maxSoFar = Math.max(cm.maxIndex(), maxSoFar);
   7.303 +            }
   7.304 +            return maxSoFar;
   7.305 +        }
   7.306 +
   7.307 +        public String toSource() {
   7.308 +            String extendsClause = "";
   7.309 +            String implementsClause = "";
   7.310 +            String methodBody = "";
   7.311 +            boolean isAbstract = "AB".contains(name);
   7.312 +
   7.313 +            for (ClassModel s : supertypes) {
   7.314 +                if (!s.isInterface) {
   7.315 +                    extendsClause = String.format("extends %s", s.name);
   7.316 +                    break;
   7.317 +                }
   7.318 +            }
   7.319 +
   7.320 +            StringJoiner sj = new StringJoiner(", ");
   7.321 +            for (ClassModel s : supertypes)
   7.322 +                if (s.isInterface)
   7.323 +                    sj.add(s.name);
   7.324 +            if (sj.length() > 0) {
   7.325 +                if (isInterface)
   7.326 +                    implementsClause = "extends " + sj.toString();
   7.327 +                else
   7.328 +                implementsClause = "implements " + sj.toString();
   7.329 +            }
   7.330 +            if (methodType != null) {
   7.331 +                switch (methodType) {
   7.332 +                    case ABSTRACT:
   7.333 +                        methodBody = String.format("public abstract %s m();", overrideName(methodIndex));
   7.334 +                        break;
   7.335 +                    case CONCRETE:
   7.336 +                        methodBody = String.format("public %s m() { return new %s(%d); };",
   7.337 +                                overrideName(methodIndex), overrideName(methodIndex), toNum(name, methodIndex));
   7.338 +                        break;
   7.339 +                    case DEFAULT:
   7.340 +                        methodBody = String.format("public default %s m() { return new %s(%d); };",
   7.341 +                                overrideName(methodIndex), overrideName(methodIndex), toNum(name, methodIndex));
   7.342 +                        break;
   7.343 +
   7.344 +                }
   7.345 +            }
   7.346 +
   7.347 +            return String.format("public %s %s %s %s %s {  %s }", isAbstract ? "abstract" : "",
   7.348 +                                 isInterface ? "interface" : "class",
   7.349 +                                 name, extendsClause, implementsClause, methodBody);
   7.350 +        }
   7.351 +    }
   7.352 +
   7.353 +    private static class Parser {
   7.354 +        private final String input;
   7.355 +        private final char[] chars;
   7.356 +        private int index;
   7.357 +
   7.358 +        private Parser(String s) {
   7.359 +            input = s;
   7.360 +            chars = s.toCharArray();
   7.361 +        }
   7.362 +
   7.363 +        private char peek() {
   7.364 +            return index < chars.length ? chars[index] : 0;
   7.365 +        }
   7.366 +
   7.367 +        private boolean peek(String validChars) {
   7.368 +            return validChars.indexOf(peek()) >= 0;
   7.369 +        }
   7.370 +
   7.371 +        private char advanceIf(String validChars) {
   7.372 +            if (peek(validChars))
   7.373 +                return chars[index++];
   7.374 +            else
   7.375 +                return 0;
   7.376 +        }
   7.377 +
   7.378 +        private char advanceIfDigit() {
   7.379 +            return advanceIf("0123456789");
   7.380 +        }
   7.381 +
   7.382 +        private int index() {
   7.383 +            StringBuilder buf = new StringBuilder();
   7.384 +            char c = advanceIfDigit();
   7.385 +            while (c != 0) {
   7.386 +                buf.append(c);
   7.387 +                c = advanceIfDigit();
   7.388 +            }
   7.389 +            return Integer.valueOf(buf.toString());
   7.390 +        }
   7.391 +
   7.392 +        private char advance() {
   7.393 +            return chars[index++];
   7.394 +        }
   7.395 +
   7.396 +        private char expect(String validChars) {
   7.397 +            char c = advanceIf(validChars);
   7.398 +            if (c == 0)
   7.399 +                throw new IllegalArgumentException(String.format("Expecting %s at position %d of %s", validChars, index, input));
   7.400 +            return c;
   7.401 +        }
   7.402 +
   7.403 +        public ClassModel parseClassModel() {
   7.404 +            List<ClassModel> supers = new ArrayList<>();
   7.405 +            char name = expect(TYPE_LETTERS);
   7.406 +            boolean isInterface = "IJK".indexOf(name) >= 0;
   7.407 +            ClassModel.MethodType methodType = peek(isInterface ? "ad" : "ac") ? ClassModel.MethodType.find(advance()) : null;
   7.408 +            int methodIndex = 0;
   7.409 +            if (methodType != null) {
   7.410 +                methodIndex = index();
   7.411 +            }
   7.412 +            if (peek() == '(') {
   7.413 +                advance();
   7.414 +                supers.add(parseClassModel());
   7.415 +                while (peek() == ',') {
   7.416 +                    advance();
   7.417 +                    supers.add(parseClassModel());
   7.418 +                }
   7.419 +                expect(")");
   7.420 +            }
   7.421 +            return new ClassModel(new String(new char[]{ name }), isInterface, supers, methodType, methodIndex);
   7.422 +        }
   7.423 +    }
   7.424 +}
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/test/tools/javac/lambda/bridge/template_tests/BridgeMethodsTemplateTest.java	Mon Sep 09 17:11:55 2013 -0400
     8.3 @@ -0,0 +1,1082 @@
     8.4 +/*
     8.5 + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
     8.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     8.7 + *
     8.8 + * This code is free software; you can redistribute it and/or modify it
     8.9 + * under the terms of the GNU General Public License version 2 only, as
    8.10 + * published by the Free Software Foundation.
    8.11 + *
    8.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    8.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    8.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    8.15 + * version 2 for more details (a copy is included in the LICENSE file that
    8.16 + * accompanied this code).
    8.17 + *
    8.18 + * You should have received a copy of the GNU General Public License version
    8.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    8.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    8.21 + *
    8.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    8.23 + * or visit www.oracle.com if you need additional information or have any
    8.24 + * questions.
    8.25 + *
    8.26 + */
    8.27 +import java.io.IOException;
    8.28 +
    8.29 +import org.testng.annotations.Test;
    8.30 +
    8.31 +/**
    8.32 + * BridgeMethodsTemplateTest
    8.33 + *
    8.34 + * @author Brian Goetz
    8.35 + */
    8.36 +@Test
    8.37 +public class BridgeMethodsTemplateTest extends BridgeMethodTestCase {
    8.38 +
    8.39 +    /*
    8.40 +     * Cc1(A) -> Cc1(Ac0)
    8.41 +     *
    8.42 +     * 0*: Inherited from A
    8.43 +     * 1: Declared in C
    8.44 +     */
    8.45 +    public void test1() throws IOException, ReflectiveOperationException {
    8.46 +        compileSpec("Cc1(A)");
    8.47 +        assertLinkage("C", LINKAGE_ERROR, "C1");
    8.48 +        recompileSpec("Cc1(Ac0)", "A");
    8.49 +        assertLinkage("C", "A0", "C1");
    8.50 +    }
    8.51 +
    8.52 +    /*
    8.53 +     * Cc1(I) -> Cc1(Id0)
    8.54 +     *
    8.55 +     * 0*: Inherited default from I
    8.56 +     * 1: Declared in C
    8.57 +     */
    8.58 +    public void test2() throws IOException, ReflectiveOperationException {
    8.59 +        compileSpec("Cc1(I)");
    8.60 +        assertLinkage("C", LINKAGE_ERROR, "C1");
    8.61 +        recompileSpec("Cc1(Id0)", "I");
    8.62 +        assertLinkage("C", "I0", "C1");
    8.63 +    }
    8.64 +
    8.65 +    /*
    8.66 +     * C(Bc1(A)) -> C(Bc1(Ac0))
    8.67 +     *
    8.68 +     * 0*: Inherited from A
    8.69 +     * 1: Inherited from B
    8.70 +     */
    8.71 +    public void test3() throws IOException, ReflectiveOperationException {
    8.72 +        compileSpec("C(Bc1(A))");
    8.73 +        assertLinkage("C", LINKAGE_ERROR, "B1");
    8.74 +        recompileSpec("C(Bc1(Ac0))", "A");
    8.75 +        assertLinkage("C", "A0", "B1");
    8.76 +    }
    8.77 +
    8.78 +    /*
    8.79 +     * C(B(Ac0)) -> C(Bc1(Ac0))
    8.80 +     *
    8.81 +     * 0: Inherited from B (through bridge)
    8.82 +     * 1: Inherited from B
    8.83 +     */
    8.84 +    public void test4() throws IOException, ReflectiveOperationException {
    8.85 +        compileSpec("C(B(Ac0))");
    8.86 +        assertLinkage("C", "A0", LINKAGE_ERROR);
    8.87 +        recompileSpec("C(Bc1(Ac0))", "B");
    8.88 +        assertLinkage("C", "B1", "B1");
    8.89 +    }
    8.90 +
    8.91 +    /*
    8.92 +     * C(B(A)) -> C(Bc1(Ac0))
    8.93 +     *
    8.94 +     * 0: Inherited from B (through bridge)
    8.95 +     * 1: Inherited from B
    8.96 +     */
    8.97 +    public void test5() throws IOException, ReflectiveOperationException {
    8.98 +        compileSpec("C(B(A))");
    8.99 +        assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR);
   8.100 +        recompileSpec("C(Bc1(Ac0))", "A", "B");
   8.101 +        assertLinkage("C", "B1", "B1");
   8.102 +    }
   8.103 +
   8.104 +    /*
   8.105 +     * C(Ac1(I)) -> C(Ac1(Id0))
   8.106 +     *
   8.107 +     * 0*: Inherited default from I
   8.108 +     * 1: Inherited from A
   8.109 +     */
   8.110 +    public void test6() throws IOException, ReflectiveOperationException {
   8.111 +        compileSpec("C(Ac1(I))");
   8.112 +        assertLinkage("C", LINKAGE_ERROR, "A1");
   8.113 +        recompileSpec("C(Ac1(Id0))", "I");
   8.114 +        assertLinkage("C", "I0", "A1");
   8.115 +    }
   8.116 +
   8.117 +    /*
   8.118 +     * C(A(Id0)) -> C(Ac1(Id0))
   8.119 +     *
   8.120 +     * 0: Inherited from A (through bridge)
   8.121 +     * 1: Inherited from A
   8.122 +     */
   8.123 +    public void test7() throws IOException, ReflectiveOperationException {
   8.124 +        compileSpec("C(A(Id0))");
   8.125 +        assertLinkage("C", "I0", LINKAGE_ERROR);
   8.126 +        recompileSpec("C(Ac1(Id0))", "A");
   8.127 +        assertLinkage("C", "A1", "A1");
   8.128 +    }
   8.129 +
   8.130 +    /*
   8.131 +     * C(A(I)) -> C(Ac1(Id0))
   8.132 +     *
   8.133 +     * 0*: Inherited from A (through bridge)
   8.134 +     * 1*: Inherited from A
   8.135 +     */
   8.136 +    public void test8() throws IOException, ReflectiveOperationException {
   8.137 +        compileSpec("C(A(I))");
   8.138 +        assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR);
   8.139 +        recompileSpec("C(Ac1(Id0))", "A", "I");
   8.140 +        assertLinkage("C", "A1", "A1");
   8.141 +    }
   8.142 +
   8.143 +    /*
   8.144 +     * C(Id1(J)) -> C(Id1(Jd0))
   8.145 +     *
   8.146 +     * 0*: Inherited default from J
   8.147 +     * 1: Inherited default from I
   8.148 +     */
   8.149 +    public void test9() throws IOException, ReflectiveOperationException {
   8.150 +        compileSpec("C(Id1(J))");
   8.151 +        assertLinkage("C", LINKAGE_ERROR, "I1");
   8.152 +        recompileSpec("C(Id1(Jd0))", "J");
   8.153 +        assertLinkage("C", "J0", "I1");
   8.154 +    }
   8.155 +
   8.156 +    /*
   8.157 +     * C(I(Jd0)) -> C(Id1(Jd0))
   8.158 +     *
   8.159 +     * 0: Inherited default from I (through bridge)
   8.160 +     * 1: Inherited default from I
   8.161 +     */
   8.162 +    public void test10() throws IOException, ReflectiveOperationException {
   8.163 +        compileSpec("C(I(Jd0))");
   8.164 +        assertLinkage("C", "J0", LINKAGE_ERROR);
   8.165 +        recompileSpec("C(Id1(Jd0))", "I");
   8.166 +        assertLinkage("C", "I1", "I1");
   8.167 +    }
   8.168 +
   8.169 +    /*
   8.170 +     * C(I(J)) -> C(Id1(Jd0))
   8.171 +     *
   8.172 +     * 0: Inherited default from I (through bridge)
   8.173 +     * 1: Inherited default from I
   8.174 +     */
   8.175 +    public void test11() throws IOException, ReflectiveOperationException {
   8.176 +        compileSpec("C(I(J))");
   8.177 +        assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR);
   8.178 +        recompileSpec("C(Id1(Jd0))", "I", "J");
   8.179 +        assertLinkage("C", "I1", "I1");
   8.180 +    }
   8.181 +
   8.182 +    /*
   8.183 +     * Cc2(B(Ac0)) -> Cc2(Bc1(Ac0))
   8.184 +     *
   8.185 +     * 0: Declared in C (through bridge)
   8.186 +     * 1*: Inherited from B
   8.187 +     * 2: Declared in C
   8.188 +     */
   8.189 +    public void test12() throws IOException, ReflectiveOperationException {
   8.190 +        compileSpec("Cc2(B(Ac0))");
   8.191 +        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
   8.192 +        recompileSpec("Cc2(Bc1(Ac0))", "B");
   8.193 +        assertLinkage("C", "C2", "B1", "C2");
   8.194 +    }
   8.195 +
   8.196 +    /*
   8.197 +     * Cc2(B(Aa0)) -> Cc2(Bc1(Aa0))
   8.198 +     *
   8.199 +     * 0: Bridge in C (through bridge)
   8.200 +     * 1*: Inherited from B
   8.201 +     * 2: Declared in C
   8.202 +     */
   8.203 +    public void test13() throws IOException, ReflectiveOperationException {
   8.204 +        compileSpec("Cc2(B(Aa0))");
   8.205 +        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
   8.206 +        recompileSpec("Cc2(Bc1(Aa0))", "B");
   8.207 +        assertLinkage("C", "C2", "B1", "C2");
   8.208 +    }
   8.209 +
   8.210 +    /*
   8.211 +     * Cc2(Bc1(A)) -> Cc2(Bc1(Ac0))
   8.212 +     *
   8.213 +     * 0*: Inherited from A
   8.214 +     * 1: Declared in C (through bridge)
   8.215 +     * 2: Declared in C
   8.216 +     */
   8.217 +    public void test14() throws IOException, ReflectiveOperationException {
   8.218 +        compileSpec("Cc2(Bc1(A))");
   8.219 +        assertLinkage("C", LINKAGE_ERROR, "C2", "C2");
   8.220 +        recompileSpec("Cc2(Bc1(Ac0))", "A");
   8.221 +        assertLinkage("C", "A0", "C2", "C2");
   8.222 +    }
   8.223 +
   8.224 +    /*
   8.225 +     * Cc2(Ba1(A)) -> Cc2(Ba1(Ac0))
   8.226 +     *
   8.227 +     * 0*: Inherited from A
   8.228 +     * 1: Declared in C (through bridge)
   8.229 +     * 2: Declared in C
   8.230 +     */
   8.231 +    public void test15() throws IOException, ReflectiveOperationException {
   8.232 +        compileSpec("Cc2(Ba1(A))");
   8.233 +        assertLinkage("C", LINKAGE_ERROR, "C2", "C2");
   8.234 +        recompileSpec("Cc2(Ba1(Ac0))", "A");
   8.235 +        assertLinkage("C", "A0", "C2", "C2");
   8.236 +    }
   8.237 +
   8.238 +    /*
   8.239 +     * Cc2(B(A)) -> Cc2(Bc1(Ac0))
   8.240 +     *
   8.241 +     * 0*: Inherited from B (through bridge)
   8.242 +     * 1*: Inherited from B
   8.243 +     * 2: Declared in C
   8.244 +     */
   8.245 +    public void test16() throws IOException, ReflectiveOperationException {
   8.246 +        compileSpec("Cc2(B(A))");
   8.247 +        assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR, "C2");
   8.248 +        recompileSpec("Cc2(Bc1(Ac0))", "B", "A");
   8.249 +        assertLinkage("C", "B1", "B1", "C2");
   8.250 +    }
   8.251 +
   8.252 +    /*
   8.253 +     * Cc2(A(Id0)) -> Cc2(Ac1(Id0))
   8.254 +     *
   8.255 +     * 0: Declared in C (through bridge)
   8.256 +     * 1*: Inherited from A
   8.257 +     * 2: Declared in C
   8.258 +     */
   8.259 +    public void test17() throws IOException, ReflectiveOperationException {
   8.260 +        compileSpec("Cc2(A(Id0))");
   8.261 +        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
   8.262 +        recompileSpec("Cc2(Ac1(Id0))", "A");
   8.263 +        assertLinkage("C", "C2", "A1", "C2");
   8.264 +    }
   8.265 +
   8.266 +    /*
   8.267 +     * Cc2(A(Ia0)) -> Cc2(Ac1(Ia0))
   8.268 +     *
   8.269 +     * 0: Declared in C (through bridge)
   8.270 +     * 1*: Inherited from A
   8.271 +     * 2: Declared in C
   8.272 +     */
   8.273 +    public void test18() throws IOException, ReflectiveOperationException {
   8.274 +        compileSpec("Cc2(A(Ia0))");
   8.275 +        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
   8.276 +        recompileSpec("Cc2(Ac1(Ia0))", "A");
   8.277 +        assertLinkage("C", "C2", "A1", "C2");
   8.278 +    }
   8.279 +
   8.280 +    /*
   8.281 +     * Cc2(Ac1(I)) -> Cc2(Ac1(Id0))
   8.282 +     *
   8.283 +     * 0*: Inherited from I
   8.284 +     * 1: Declared in C (through bridge)
   8.285 +     * 2: Declared in C
   8.286 +     */
   8.287 +    public void test19() throws IOException, ReflectiveOperationException {
   8.288 +        compileSpec("Cc2(Ac1(I))");
   8.289 +        assertLinkage("C", LINKAGE_ERROR, "C2", "C2");
   8.290 +        recompileSpec("Cc2(Ac1(Id0))", "I");
   8.291 +        assertLinkage("C", "I0", "C2", "C2");
   8.292 +    }
   8.293 +
   8.294 +    /*
   8.295 +     * Cc2(Aa1(I)) -> Cc2(Aa1(Id0))
   8.296 +     *
   8.297 +     * 0*: Inherited from I
   8.298 +     * 1: Declared in C (through bridge)
   8.299 +     * 2: Declared in C
   8.300 +     */
   8.301 +    public void test20() throws IOException, ReflectiveOperationException {
   8.302 +        compileSpec("Cc2(Aa1(I))");
   8.303 +        assertLinkage("C", LINKAGE_ERROR, "C2", "C2");
   8.304 +        recompileSpec("Cc2(Aa1(Id0))", "I");
   8.305 +        assertLinkage("C", "I0", "C2", "C2");
   8.306 +    }
   8.307 +
   8.308 +    /*
   8.309 +     * Cc2(A(I)) -> Cc2(Ac1(Id0))
   8.310 +     *
   8.311 +     * 0*: Inherited from A (through bridge)
   8.312 +     * 1*: Inherited from A
   8.313 +     * 2: Declared in C
   8.314 +     */
   8.315 +    public void test21() throws IOException, ReflectiveOperationException {
   8.316 +        compileSpec("Cc2(A(I))");
   8.317 +        assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR, "C2");
   8.318 +        recompileSpec("Cc2(Ac1(Id0))", "A", "I");
   8.319 +        assertLinkage("C", "A1", "A1", "C2");
   8.320 +    }
   8.321 +
   8.322 +    /*
   8.323 +     * Cc2(J(Id0)) -> Cc2(Jd1(Id0))
   8.324 +     *
   8.325 +     * 0: Declared in C (through bridge)
   8.326 +     * 1*: Inherited default from J
   8.327 +     * 2: Declared in C
   8.328 +     */
   8.329 +    public void test22() throws IOException, ReflectiveOperationException {
   8.330 +        compileSpec("Cc2(J(Id0))");
   8.331 +        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
   8.332 +        recompileSpec("Cc2(Jd1(Id0))", "J");
   8.333 +        assertLinkage("C", "C2", "J1", "C2");
   8.334 +    }
   8.335 +
   8.336 +    /*
   8.337 +     * Cc2(J(Ia0)) -> Cc2(Jd1(Ia0))
   8.338 +     *
   8.339 +     * 0: Declared in C (through bridge)
   8.340 +     * 1*: Inherited default from J
   8.341 +     * 2: Declared in C
   8.342 +     */
   8.343 +    public void test23() throws IOException, ReflectiveOperationException {
   8.344 +        compileSpec("Cc2(J(Ia0))");
   8.345 +        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
   8.346 +        recompileSpec("Cc2(Jd1(Ia0))", "J");
   8.347 +        assertLinkage("C", "C2", "J1", "C2");
   8.348 +    }
   8.349 +
   8.350 +    /*
   8.351 +     * Cc2(Jd1(I)) -> Cc2(Jd1(Id0))
   8.352 +     *
   8.353 +     * 0*: Inherited default from I
   8.354 +     * 1: Declared in C (through bridge)
   8.355 +     * 2: Declared in C
   8.356 +     */
   8.357 +    public void test24() throws IOException, ReflectiveOperationException {
   8.358 +        compileSpec("Cc2(Jd1(I))");
   8.359 +        assertLinkage("C", LINKAGE_ERROR, "C2", "C2");
   8.360 +        recompileSpec("Cc2(Jd1(Id0))", "I");
   8.361 +        assertLinkage("C", "I0", "C2", "C2");
   8.362 +    }
   8.363 +
   8.364 +    /*
   8.365 +     * Cc2(Ja1(I)) -> Cc2(Ja1(Id0))
   8.366 +     *
   8.367 +     * 0*: Inherited default from I
   8.368 +     * 1: Declared in C (through bridge)
   8.369 +     * 2: Declared in C
   8.370 +     */
   8.371 +    public void test25() throws IOException, ReflectiveOperationException {
   8.372 +        compileSpec("Cc2(Ja1(I))");
   8.373 +        assertLinkage("C", LINKAGE_ERROR, "C2", "C2");
   8.374 +        recompileSpec("Cc2(Ja1(Id0))", "I");
   8.375 +        assertLinkage("C", "I0", "C2", "C2");
   8.376 +    }
   8.377 +
   8.378 +    /*
   8.379 +     * Cc2(J(I)) -> Cc2(Jd1(Id0))
   8.380 +     *
   8.381 +     * 0*: Inherited default from J (through bridge)
   8.382 +     * 1*: Inherited default from J
   8.383 +     * 2: Declared in C
   8.384 +     */
   8.385 +    public void test26() throws IOException, ReflectiveOperationException {
   8.386 +        compileSpec("Cc2(J(I))");
   8.387 +        assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR, "C2");
   8.388 +        recompileSpec("Cc2(Jd1(Id0))", "J", "I");
   8.389 +        assertLinkage("C", "J1", "J1", "C2");
   8.390 +    }
   8.391 +
   8.392 +    /*
   8.393 +     * C(Ac1, I) -> C(Ac1, Id0)
   8.394 +     *
   8.395 +     * 0*: Inherited default from I
   8.396 +     * 1: Inherited from A
   8.397 +     */
   8.398 +    public void test27() throws IOException, ReflectiveOperationException {
   8.399 +        compileSpec("C(Ac1,I)");
   8.400 +        assertLinkage("C", LINKAGE_ERROR, "A1");
   8.401 +        recompileSpec("C(Ac1,Id0)", "I");
   8.402 +        assertLinkage("C", "I0", "A1");
   8.403 +    }
   8.404 +
   8.405 +    /*
   8.406 +     * C(A, Id0) -> C(Ac1, Id0)
   8.407 +     *
   8.408 +     * 0*: Inherited default from I
   8.409 +     * 1: Inherited from A
   8.410 +     */
   8.411 +    public void test28() throws IOException, ReflectiveOperationException {
   8.412 +        compileSpec("C(A,Id0)");
   8.413 +        assertLinkage("C", "I0", LINKAGE_ERROR);
   8.414 +        recompileSpec("C(Ac1,Id0)", "A");
   8.415 +        assertLinkage("C", "I0", "A1");
   8.416 +    }
   8.417 +
   8.418 +    /*
   8.419 +     * C(A, I) -> C(Ac1, Id0)
   8.420 +     *
   8.421 +     * 0*: Inherited default from I
   8.422 +     * 1: Inherited from A
   8.423 +     */
   8.424 +    public void test29() throws IOException, ReflectiveOperationException {
   8.425 +        compileSpec("C(A,I)");
   8.426 +        assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR);
   8.427 +        recompileSpec("C(Ac1,Id0)", "A", "I");
   8.428 +        assertLinkage("C", "I0", "A1");
   8.429 +    }
   8.430 +
   8.431 +    /*
   8.432 +     * Cc2(Ac1, I) -> Cc2(Ac1, Id0)
   8.433 +     *
   8.434 +     * 0*: Inherited default from I
   8.435 +     * 1: Declared in C (through bridge)
   8.436 +     * 2: Declared in C
   8.437 +     */
   8.438 +    public void test30() throws IOException, ReflectiveOperationException {
   8.439 +        compileSpec("Cc2(Ac1,I)");
   8.440 +        assertLinkage("C", LINKAGE_ERROR, "C2", "C2");
   8.441 +        recompileSpec("Cc2(Ac1,Id0)", "I");
   8.442 +        assertLinkage("C", "I0", "C2", "C2");
   8.443 +    }
   8.444 +
   8.445 +    /*
   8.446 +     * Cc2(Aa1, I) -> Cc2(Aa1, Id0)
   8.447 +     *
   8.448 +     * 0*: Inherited default from I
   8.449 +     * 1: Declared in C (through bridge)
   8.450 +     * 2: Declared in C
   8.451 +     */
   8.452 +    public void test31() throws IOException, ReflectiveOperationException {
   8.453 +        compileSpec("Cc2(Aa1,I)");
   8.454 +        assertLinkage("C", LINKAGE_ERROR, "C2", "C2");
   8.455 +        recompileSpec("Cc2(Aa1,Id0)", "I");
   8.456 +        assertLinkage("C", "I0", "C2", "C2");
   8.457 +    }
   8.458 +
   8.459 +    /*
   8.460 +     * Cc2(A, Id0) -> Cc2(Ac1, Id0)
   8.461 +     *
   8.462 +     * 0: Declared in C (through bridge)
   8.463 +     * 1*: Inherited from A
   8.464 +     * 2: Declared in C
   8.465 +     */
   8.466 +    public void test32() throws IOException, ReflectiveOperationException {
   8.467 +        compileSpec("Cc2(A,Id0)");
   8.468 +        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
   8.469 +        recompileSpec("Cc2(Ac1,Id0)", "A");
   8.470 +        assertLinkage("C", "C2", "A1", "C2");
   8.471 +    }
   8.472 +
   8.473 +    /*
   8.474 +     * Cc2(A, Ia0) -> Cc2(Ac1, Ia0)
   8.475 +     *
   8.476 +     * 0: Declared in C (through bridge)
   8.477 +     * 1*: Inherited from A
   8.478 +     * 2: Declared in C
   8.479 +     */
   8.480 +    public void test33() throws IOException, ReflectiveOperationException {
   8.481 +        compileSpec("Cc2(A,Ia0)");
   8.482 +        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
   8.483 +        recompileSpec("Cc2(Ac1,Ia0)", "A");
   8.484 +        assertLinkage("C", "C2", "A1", "C2");
   8.485 +    }
   8.486 +
   8.487 +    /*
   8.488 +     * Cc2(A, I) -> Cc2(Ac1, Id0)
   8.489 +     *
   8.490 +     * 0*: Inherited from A
   8.491 +     * 1*: Inherited default from I
   8.492 +     * 2: Declared in C
   8.493 +     */
   8.494 +    public void test34() throws IOException, ReflectiveOperationException {
   8.495 +        compileSpec("Cc2(A,I)");
   8.496 +        assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR, "C2");
   8.497 +        recompileSpec("Cc2(Ac1,Id0)", "A", "I");
   8.498 +        assertLinkage("C", "I0", "A1", "C2");
   8.499 +    }
   8.500 +
   8.501 +    /*
   8.502 +     * Cc2(Id0, J) -> Cc2(Id0, Jd1)
   8.503 +     *
   8.504 +     * 0: Declared in C (through bridge)
   8.505 +     * 1*: Inherited default from J
   8.506 +     * 2: Declared in C
   8.507 +     */
   8.508 +    public void test35() throws IOException, ReflectiveOperationException {
   8.509 +        compileSpec("Cc2(Id0,J)");
   8.510 +        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
   8.511 +        recompileSpec("Cc2(Id0,Jd1)", "J");
   8.512 +        assertLinkage("C", "C2", "J1", "C2");
   8.513 +    }
   8.514 +
   8.515 +    /*
   8.516 +     * Cc2(Ia0, J) -> Cc2(Ia0, Jd1)
   8.517 +     *
   8.518 +     * 0: Declared in C (through bridge)
   8.519 +     * 1*: Inherited default from J
   8.520 +     * 2: Declared in C
   8.521 +     */
   8.522 +    public void test36() throws IOException, ReflectiveOperationException {
   8.523 +        compileSpec("Cc2(Ia0,J)");
   8.524 +        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
   8.525 +        recompileSpec("Cc2(Ia0,Jd1)", "J");
   8.526 +        assertLinkage("C", "C2", "J1", "C2");
   8.527 +    }
   8.528 +
   8.529 +    /*
   8.530 +     * Cc2(I, J) -> Cc2(Id0, Jd1)
   8.531 +     *
   8.532 +     * 0*: Inherited default from I
   8.533 +     * 1*: Inherited default from J
   8.534 +     * 2: Declared in C
   8.535 +     */
   8.536 +    public void test37() throws IOException, ReflectiveOperationException {
   8.537 +        compileSpec("Cc2(I,J)");
   8.538 +        assertLinkage("C", LINKAGE_ERROR, LINKAGE_ERROR, "C2");
   8.539 +        recompileSpec("Cc2(Id0,Jd1)", "I", "J");
   8.540 +        assertLinkage("C", "I0", "J1", "C2");
   8.541 +    }
   8.542 +
   8.543 +    /*
   8.544 +     * C(A(Id0), J(Id0)) -> C(Ac1(Id0), J(Id0))
   8.545 +     *
   8.546 +     * 0: Inherited default from I
   8.547 +     * 0*: Inherited from A (through bridge)
   8.548 +     * 1*: Inherited from A
   8.549 +     */
   8.550 +    public void test38() throws IOException, ReflectiveOperationException {
   8.551 +        compileSpec("C(A(Id0),J(Id0))");
   8.552 +        assertLinkage("C", "I0", LINKAGE_ERROR);
   8.553 +        recompileSpec("C(Ac1(Id0),J(Id0))", "A");
   8.554 +        assertLinkage("C", "A1", "A1");
   8.555 +    }
   8.556 +
   8.557 +    /*
   8.558 +     * C(A(Id0), J(Id0)) -> C(A(Id0), Jd1(Id0))
   8.559 +     *
   8.560 +     * 0: Inherited default from I
   8.561 +     * 0: Inherited default from J (through bridge)
   8.562 +     * 1*: Inherited default from J
   8.563 +     */
   8.564 +    public void test39() throws IOException, ReflectiveOperationException {
   8.565 +        compileSpec("C(A(Id0),J(Id0))");
   8.566 +        assertLinkage("C", "I0", LINKAGE_ERROR);
   8.567 +        recompileSpec("C(A(Id0),Jd1(Id0))", "J");
   8.568 +        assertLinkage("C", "J1", "J1");
   8.569 +    }
   8.570 +
   8.571 +    /*
   8.572 +     * C(A(Id0), J(Id0)) -> C(Ac2(Id0), Jd1(Id0))
   8.573 +     *
   8.574 +     * 0: Inherited default from I
   8.575 +     * 0*: Inherited from A (new bridge in A beats new bridge in J)
   8.576 +     * 1*: Inherited default from J
   8.577 +     * 2: Inherited from A
   8.578 +     */
   8.579 +    public void test40() throws IOException, ReflectiveOperationException {
   8.580 +        compileSpec("C(A(Id0),J(Id0))");
   8.581 +        assertLinkage("C", "I0", LINKAGE_ERROR);
   8.582 +        recompileSpec("C(Ac2(Id0),Jd1(Id0))", "A", "J");
   8.583 +        assertLinkage("C", "A2", "J1", "A2");
   8.584 +    }
   8.585 +
   8.586 +    /*
   8.587 +     * C(J(Id0), K(Id0)) -> C(Jd1(Id0), K(Id0))
   8.588 +     *
   8.589 +     * 0: Inherited from I
   8.590 +     * 0*: Inherited default from J (through bridge)
   8.591 +     * 1: Inherited default from J
   8.592 +     */
   8.593 +    public void test41() throws IOException, ReflectiveOperationException {
   8.594 +        compileSpec("C(J(Id0),K(Id0))");
   8.595 +        assertLinkage("C", "I0", LINKAGE_ERROR);
   8.596 +        recompileSpec("C(Jd1(Id0),K(Id0))", "J");
   8.597 +        assertLinkage("C", "J1", "J1");
   8.598 +    }
   8.599 +
   8.600 +    /*
   8.601 +     * C(Ac2(Id0), J(Id0)) -> C(Ac2(Id0), Jd1(Id0))
   8.602 +     *
   8.603 +     * 0: Inherited from A (bridge in A beats new bridge in J)
   8.604 +     * 1*: Inherited default from J
   8.605 +     * 2: Inherited from A
   8.606 +     */
   8.607 +    public void test42() throws IOException, ReflectiveOperationException {
   8.608 +        compileSpec("C(Ac2(Id0),J(Id0))");
   8.609 +        assertLinkage("C", "A2", LINKAGE_ERROR, "A2");
   8.610 +        recompileSpec("C(Ac2(Id0),Jd1(Id0))", "J");
   8.611 +        assertLinkage("C", "A2", "J1", "A2");
   8.612 +    }
   8.613 +
   8.614 +    /*
   8.615 +     * C(Ac2(Ia0), J(Ia0)) -> C(Ac2(Ia0), Jd1(Ia0))
   8.616 +     *
   8.617 +     * 0: Inherited from A (bridge in A beats new bridge in J)
   8.618 +     * 1*: Inherited default from J
   8.619 +     * 2: Inherited from A
   8.620 +     */
   8.621 +    public void test43() throws IOException, ReflectiveOperationException {
   8.622 +        compileSpec("C(Ac2(Ia0),J(Ia0))");
   8.623 +        assertLinkage("C", "A2", LINKAGE_ERROR, "A2");
   8.624 +        recompileSpec("C(Ac2(Ia0),Jd1(Ia0))", "J");
   8.625 +        assertLinkage("C", "A2", "J1", "A2");
   8.626 +    }
   8.627 +
   8.628 +    /*
   8.629 +     * C(A(Id0), Jd1(Id0)) -> C(Ac2(Id0), Jd1(Id0))
   8.630 +     *
   8.631 +     * 0: Inherited from J
   8.632 +     * 0*: Inherited from A (new bridge in A beats bridge in J)
   8.633 +     * 1: Inherited default from J
   8.634 +     * 2*: Inherited from A
   8.635 +     */
   8.636 +    public void test44() throws IOException, ReflectiveOperationException {
   8.637 +        compileSpec("C(A(Id0),Jd1(Id0))");
   8.638 +        assertLinkage("C", "J1", "J1", LINKAGE_ERROR);
   8.639 +        recompileSpec("C(Ac2(Id0),Jd1(Id0))", "A");
   8.640 +        assertLinkage("C", "A2", "J1", "A2");
   8.641 +    }
   8.642 +
   8.643 +    /*
   8.644 +     * C(A(Ia0), Jd1(Ia0)) -> C(Ac2(Ia0), Jd1(Ia0))
   8.645 +     *
   8.646 +     * 0: Inherited from J
   8.647 +     * 0*: Inherited from A (new bridge in A beats bridge in J)
   8.648 +     * 1: Inherited default from J
   8.649 +     * 2*: Inherited from A
   8.650 +     */
   8.651 +    public void test45() throws IOException, ReflectiveOperationException {
   8.652 +        compileSpec("C(A(Ia0),Jd1(Ia0))");
   8.653 +        assertLinkage("C", "J1", "J1", LINKAGE_ERROR);
   8.654 +        recompileSpec("C(Ac2(Ia0),Jd1(Ia0))", "A");
   8.655 +        assertLinkage("C", "A2", "J1", "A2");
   8.656 +    }
   8.657 +
   8.658 +    /*
   8.659 +     * Cc2(A(Id0), J(Id0)) -> Cc2(Ac1(Id0), J(Id0))
   8.660 +     *
   8.661 +     * 0: Declared in C (through bridge)
   8.662 +     * 1*: Inherited from A
   8.663 +     * 2: Declared in C
   8.664 +     */
   8.665 +    public void test46() throws IOException, ReflectiveOperationException {
   8.666 +        compileSpec("Cc2(A(Id0),J(Id0))");
   8.667 +        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
   8.668 +        recompileSpec("Cc2(Ac1(Id0),J(Id0))", "A");
   8.669 +        assertLinkage("C", "C2", "A1", "C2");
   8.670 +    }
   8.671 +
   8.672 +    /*
   8.673 +     * Cc2(A(Ia0), J(Ia0)) -> Cc2(Ac1(Ia0), J(Ia0))
   8.674 +     *
   8.675 +     * 0: Declared in C (through bridge)
   8.676 +     * 1*: Inherited from A
   8.677 +     * 2: Declared in C
   8.678 +     */
   8.679 +    public void test47() throws IOException, ReflectiveOperationException {
   8.680 +        compileSpec("Cc2(A(Ia0),J(Ia0))");
   8.681 +        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
   8.682 +        recompileSpec("Cc2(Ac1(Ia0),J(Ia0))", "A");
   8.683 +        assertLinkage("C", "C2", "A1", "C2");
   8.684 +    }
   8.685 +
   8.686 +    /*
   8.687 +     * Cc2(A(Id0), J(Id0)) -> Cc2(A(Id0), Jd1(Id0))
   8.688 +     *
   8.689 +     * 0: Declared in C (through bridge)
   8.690 +     * 1*: Inherited default from J
   8.691 +     * 2: Declared in C
   8.692 +     */
   8.693 +    public void test48() throws IOException, ReflectiveOperationException {
   8.694 +        compileSpec("Cc2(A(Id0),J(Id0))");
   8.695 +        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
   8.696 +        recompileSpec("Cc2(A(Id0),Jd1(Id0))", "J");
   8.697 +        assertLinkage("C", "C2", "J1", "C2");
   8.698 +    }
   8.699 +
   8.700 +    /*
   8.701 +     * Cc2(A(Ia0), J(Ia0)) -> Cc2(A(Ia0), Jd1(Ia0))
   8.702 +     *
   8.703 +     * 0: Declared in C (through bridge)
   8.704 +     * 1*: Inherited default from J
   8.705 +     * 2: Declared in C
   8.706 +     */
   8.707 +    public void test49() throws IOException, ReflectiveOperationException {
   8.708 +        compileSpec("Cc2(A(Ia0),J(Ia0))");
   8.709 +        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
   8.710 +        recompileSpec("Cc2(A(Ia0),Jd1(Ia0))", "J");
   8.711 +        assertLinkage("C", "C2", "J1", "C2");
   8.712 +    }
   8.713 +
   8.714 +
   8.715 +    /*
   8.716 +     * Cc3(A(Id0), J(Id0)) -> Cc3(Ac1(Id0), Jd2(Id0))
   8.717 +     *
   8.718 +     * 0: Bridge in C
   8.719 +     * 1*: Inherited from A
   8.720 +     * 2*: Inherited default from J
   8.721 +     * 3: Declared in C
   8.722 +     */
   8.723 +    public void test50() throws IOException, ReflectiveOperationException {
   8.724 +        compileSpec("Cc3(A(Id0),J(Id0))");
   8.725 +        assertLinkage("C", "C3", LINKAGE_ERROR, LINKAGE_ERROR, "C3");
   8.726 +        recompileSpec("Cc3(Ac1(Id0),Jd2(Id0))", "A", "J");
   8.727 +        assertLinkage("C", "C3", "A1", "J2", "C3");
   8.728 +    }
   8.729 +
   8.730 +    /*
   8.731 +     * Cc3(A(Ia0), J(Ia0)) -> Cc3(Ac1(Ia0), Jd2(Ia0))
   8.732 +     *
   8.733 +     * 0: Bridge in C
   8.734 +     * 1*: Inherited from A
   8.735 +     * 2*: Inherited default from J
   8.736 +     * 3: Declared in C
   8.737 +     */
   8.738 +    public void test51() throws IOException, ReflectiveOperationException {
   8.739 +        compileSpec("Cc3(A(Ia0),J(Ia0))");
   8.740 +        assertLinkage("C", "C3", LINKAGE_ERROR, LINKAGE_ERROR, "C3");
   8.741 +        recompileSpec("Cc3(Ac1(Ia0),Jd2(Ia0))", "A", "J");
   8.742 +        assertLinkage("C", "C3", "A1", "J2", "C3");
   8.743 +    }
   8.744 +
   8.745 +    /*
   8.746 +     * Cc2(J(Id0), K(Id0)) -> Cc2(Jd1(Id0), K(Id0))
   8.747 +     *
   8.748 +     * 0: Declared in C (through bridge)
   8.749 +     * 1*: Inherited default from J
   8.750 +     * 2: Declared in C
   8.751 +     */
   8.752 +    public void test52() throws IOException, ReflectiveOperationException {
   8.753 +        compileSpec("Cc2(J(Id0),K(Id0))");
   8.754 +        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
   8.755 +        recompileSpec("Cc2(Jd1(Id0),K(Id0))", "J");
   8.756 +        assertLinkage("C", "C2", "J1", "C2");
   8.757 +    }
   8.758 +
   8.759 +    /*
   8.760 +     * Cc2(J(Ia0), K(Ia0)) -> Cc2(Jd1(Ia0), K(Ia0))
   8.761 +     *
   8.762 +     * 0: Declared in C (through bridge)
   8.763 +     * 1*: Inherited default from J
   8.764 +     * 2: Declared in C
   8.765 +     */
   8.766 +    public void test53() throws IOException, ReflectiveOperationException {
   8.767 +        compileSpec("Cc2(J(Ia0),K(Ia0))");
   8.768 +        assertLinkage("C", "C2", LINKAGE_ERROR, "C2");
   8.769 +        recompileSpec("Cc2(Jd1(Ia0),K(Ia0))", "J");
   8.770 +        assertLinkage("C", "C2", "J1", "C2");
   8.771 +    }
   8.772 +
   8.773 +    /*
   8.774 +     * Cc3(J(Id0), K(Id0)) -> Cc3(Jd1(Id0), Kd2(Id0))
   8.775 +     *
   8.776 +     * 0: Declared in C (through bridge)
   8.777 +     * 1*: Inherited default from J
   8.778 +     * 2*: Inherited default from K
   8.779 +     * 3: Declared in C
   8.780 +     */
   8.781 +    public void test54() throws IOException, ReflectiveOperationException {
   8.782 +        compileSpec("Cc3(J(Id0),K(Id0))");
   8.783 +        assertLinkage("C", "C3", LINKAGE_ERROR, LINKAGE_ERROR, "C3");
   8.784 +        recompileSpec("Cc3(Jd1(Id0),Kd2(Id0))", "J", "K");
   8.785 +        assertLinkage("C", "C3", "J1", "K2", "C3");
   8.786 +    }
   8.787 +
   8.788 +    /*
   8.789 +     * Cc3(J(Ia0), K(Ia0)) -> Cc3(Jd1(Ia0), Kd2(Ia0))
   8.790 +     *
   8.791 +     * 0: Declared in C (through bridge)
   8.792 +     * 1*: Inherited default from J
   8.793 +     * 2*: Inherited default from K
   8.794 +     * 3: Declared in C
   8.795 +     */
   8.796 +    public void test55() throws IOException, ReflectiveOperationException {
   8.797 +        compileSpec("Cc3(J(Ia0),K(Ia0))");
   8.798 +        assertLinkage("C", "C3", LINKAGE_ERROR, LINKAGE_ERROR, "C3");
   8.799 +        recompileSpec("Cc3(Jd1(Ia0),Kd2(Ia0))", "J", "K");
   8.800 +        assertLinkage("C", "C3", "J1", "K2", "C3");
   8.801 +    }
   8.802 +
   8.803 +    /*
   8.804 +     * Cc3(Ac1(Id0), J(Id0)) -> Cc3(Ac1(Id0), Jd2(Id0))
   8.805 +     *
   8.806 +     * 0: Declared in C (through bridge)
   8.807 +     * 1: Declared in C (through bridge)
   8.808 +     * 2*: Inherited default from J
   8.809 +     * 3: Declared in C
   8.810 +     */
   8.811 +    public void test56() throws IOException, ReflectiveOperationException {
   8.812 +        compileSpec("Cc3(Ac1(Id0),J(Id0))");
   8.813 +        assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3");
   8.814 +        recompileSpec("Cc3(Ac1(Id0),Jd2(Id0))", "J");
   8.815 +        assertLinkage("C", "C3", "C3", "J2", "C3");
   8.816 +    }
   8.817 +
   8.818 +    /*
   8.819 +     * Cc3(Ac1(Ia0), J(Ia0)) -> Cc3(Ac1(Ia0), Jd2(Ia0))
   8.820 +     *
   8.821 +     * 0: Declared in C (through bridge)
   8.822 +     * 1: Declared in C (through bridge)
   8.823 +     * 2*: Inherited default from J
   8.824 +     * 3: Declared in C
   8.825 +     */
   8.826 +    public void test57() throws IOException, ReflectiveOperationException {
   8.827 +        compileSpec("Cc3(Ac1(Ia0),J(Ia0))");
   8.828 +        assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3");
   8.829 +        recompileSpec("Cc3(Ac1(Ia0),Jd2(Ia0))", "J");
   8.830 +        assertLinkage("C", "C3", "C3", "J2", "C3");
   8.831 +    }
   8.832 +
   8.833 +    /*
   8.834 +     * Cc3(Aa1(Id0), J(Id0)) -> Cc3(Aa1(Id0), Jd2(Id0))
   8.835 +     *
   8.836 +     * 0: Declared in C (through bridge)
   8.837 +     * 1: Declared in C (through bridge)
   8.838 +     * 2*: Inherited default from J
   8.839 +     * 3: Declared in C
   8.840 +     */
   8.841 +    public void test58() throws IOException, ReflectiveOperationException {
   8.842 +        compileSpec("Cc3(Aa1(Id0),J(Id0))");
   8.843 +        assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3");
   8.844 +        recompileSpec("Cc3(Aa1(Id0),Jd2(Id0))", "J");
   8.845 +        assertLinkage("C", "C3", "C3", "J2", "C3");
   8.846 +    }
   8.847 +
   8.848 +    /*
   8.849 +     * Cc3(Aa1(Ia0), J(Ia0)) -> Cc3(Aa1(Ia0), Jd2(Ia0))
   8.850 +     *
   8.851 +     * 0: Declared in C (through bridge)
   8.852 +     * 1: Declared in C (through bridge)
   8.853 +     * 2*: Inherited default from J
   8.854 +     * 3: Declared in C
   8.855 +     */
   8.856 +    public void test59() throws IOException, ReflectiveOperationException {
   8.857 +        compileSpec("Cc3(Aa1(Ia0),J(Ia0))");
   8.858 +        assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3");
   8.859 +        recompileSpec("Cc3(Aa1(Ia0),Jd2(Ia0))", "J");
   8.860 +        assertLinkage("C", "C3", "C3", "J2", "C3");
   8.861 +    }
   8.862 +
   8.863 +    /*
   8.864 +     * Cc3(A(Id0), Jd2(Id0)) -> Cc3(Ac1(Id0), Jd2(Id0))
   8.865 +     *
   8.866 +     * 0: Declared in C (through bridge)
   8.867 +     * 1*: Inherited from A
   8.868 +     * 2: Declared in C (through bridge)
   8.869 +     * 3: Declared in C
   8.870 +     */
   8.871 +    public void test60() throws IOException, ReflectiveOperationException {
   8.872 +        compileSpec("Cc3(A(Id0),Jd2(Id0))");
   8.873 +        assertLinkage("C", "C3", LINKAGE_ERROR, "C3", "C3");
   8.874 +        recompileSpec("Cc3(Ac1(Id0),Jd2(Id0))", "A");
   8.875 +        assertLinkage("C", "C3", "A1", "C3", "C3");
   8.876 +    }
   8.877 +
   8.878 +    /*
   8.879 +     * Cc3(A(Im0), Jd2(Ia0)) -> Cc3(Ac1(Im0), Jd2(Ia0))
   8.880 +     *
   8.881 +     * 0: Declared in C (through bridge)
   8.882 +     * 1*: Inherited from A
   8.883 +     * 2: Declared in C (through bridge)
   8.884 +     * 3: Declared in C
   8.885 +     */
   8.886 +    public void test61() throws IOException, ReflectiveOperationException {
   8.887 +        compileSpec("Cc3(A(Ia0),Jd2(Ia0))");
   8.888 +        assertLinkage("C", "C3", LINKAGE_ERROR, "C3", "C3");
   8.889 +        recompileSpec("Cc3(Ac1(Ia0),Jd2(Ia0))", "A");
   8.890 +        assertLinkage("C", "C3", "A1", "C3", "C3");
   8.891 +    }
   8.892 +
   8.893 +    /*
   8.894 +     * Cc3(A(Im0), Ja2(Id0)) -> Cc3(Ac1(Id0), Ja2(Id0))
   8.895 +     *
   8.896 +     * 0: Declared in C (through bridge)
   8.897 +     * 1*: Inherited from A
   8.898 +     * 2: Declared in C (through bridge)
   8.899 +     * 3: Declared in C
   8.900 +     */
   8.901 +    public void test62() throws IOException, ReflectiveOperationException {
   8.902 +        compileSpec("Cc3(A(Id0),Ja2(Id0))");
   8.903 +        assertLinkage("C", "C3", LINKAGE_ERROR, "C3", "C3");
   8.904 +        recompileSpec("Cc3(Ac1(Id0),Ja2(Id0))", "A");
   8.905 +        assertLinkage("C", "C3", "A1", "C3", "C3");
   8.906 +    }
   8.907 +
   8.908 +    /*
   8.909 +     * Cc3(A(Im0), Ja2(Ia0)) -> Cc3(Ac1(Ia0), Ja2(Ia0))
   8.910 +     *
   8.911 +     * 0: Declared in C (through bridge)
   8.912 +     * 1*: Inherited from A
   8.913 +     * 2: Declared in C (through bridge)
   8.914 +     * 3: Declared in C
   8.915 +     */
   8.916 +    public void test63() throws IOException, ReflectiveOperationException {
   8.917 +        compileSpec("Cc3(A(Ia0),Ja2(Ia0))");
   8.918 +        assertLinkage("C", "C3", LINKAGE_ERROR, "C3", "C3");
   8.919 +        recompileSpec("Cc3(Ac1(Ia0),Ja2(Ia0))", "A");
   8.920 +        assertLinkage("C", "C3", "A1", "C3", "C3");
   8.921 +    }
   8.922 +
   8.923 +    /*
   8.924 +     * Cc3(Jd1(Id0), K(Id0)) -> Cc3(Jd1(Id0), Kd2(Id0))
   8.925 +     *
   8.926 +     * 0: Declared in C (through bridge)
   8.927 +     * 1: Declared in C (through bridge)
   8.928 +     * 2*: Inherited default from K
   8.929 +     * 3: Declared in C
   8.930 +     */
   8.931 +    public void test64() throws IOException, ReflectiveOperationException {
   8.932 +        compileSpec("Cc3(Jd1(Id0),K(Id0))");
   8.933 +        assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3");
   8.934 +        recompileSpec("Cc3(Jd1(Id0),Kd2(Id0))", "K");
   8.935 +        assertLinkage("C", "C3", "C3", "K2", "C3");
   8.936 +    }
   8.937 +
   8.938 +    /*
   8.939 +     * Cc3(Jd1(Ia0), K(Ia0)) -> Cc3(Jd1(Ia0), Kd2(Ia0))
   8.940 +     *
   8.941 +     * 0: Declared in C (through bridge)
   8.942 +     * 1: Declared in C (through bridge)
   8.943 +     * 2*: Inherited default from K
   8.944 +     * 3: Declared in C
   8.945 +     */
   8.946 +    public void test65() throws IOException, ReflectiveOperationException {
   8.947 +        compileSpec("Cc3(Jd1(Ia0),K(Ia0))");
   8.948 +        assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3");
   8.949 +        recompileSpec("Cc3(Jd1(Ia0),Kd2(Ia0))", "K");
   8.950 +        assertLinkage("C", "C3", "C3", "K2", "C3");
   8.951 +    }
   8.952 +
   8.953 +    /*
   8.954 +     * Cc3(Ja1(Id0), K(Id0)) -> Cc3(Ja1(Id0), Kd2(Id0))
   8.955 +     *
   8.956 +     * 0: Declared in C (through bridge)
   8.957 +     * 1: Declared in C (through bridge)
   8.958 +     * 2*: Inherited default from K
   8.959 +     * 3: Declared in C
   8.960 +     */
   8.961 +    public void test66() throws IOException, ReflectiveOperationException {
   8.962 +        compileSpec("Cc3(Jd1(Id0),K(Id0))");
   8.963 +        assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3");
   8.964 +        recompileSpec("Cc3(Jd1(Id0),Kd2(Id0))", "K");
   8.965 +        assertLinkage("C", "C3", "C3", "K2", "C3");
   8.966 +    }
   8.967 +
   8.968 +    /*
   8.969 +     * Cc3(Ja1(Ia0), K(Ia0)) -> Cc3(Ja1(Ia0), Kd2(Ia0))
   8.970 +     *
   8.971 +     * 0: Declared in C (through bridge)
   8.972 +     * 1: Declared in C (through bridge)
   8.973 +     * 2*: Inherited default from K
   8.974 +     * 3: Declared in C
   8.975 +     */
   8.976 +    public void test67() throws IOException, ReflectiveOperationException {
   8.977 +        compileSpec("Cc3(Jd1(Ia0),K(Ia0))");
   8.978 +        assertLinkage("C", "C3", "C3", LINKAGE_ERROR, "C3");
   8.979 +        recompileSpec("Cc3(Jd1(Ia0),Kd2(Ia0))", "K");
   8.980 +        assertLinkage("C", "C3", "C3", "K2", "C3");
   8.981 +    }
   8.982 +
   8.983 +    // Dan's set A
   8.984 +    public void testA1() throws IOException, ReflectiveOperationException {
   8.985 +        compileSpec("C(Id0)");
   8.986 +        assertLinkage("C", "I0");
   8.987 +    }
   8.988 +
   8.989 +    public void testA2() throws IOException, ReflectiveOperationException {
   8.990 +        compileSpec("C(A(Id0))");
   8.991 +        assertLinkage("C", "I0");
   8.992 +    }
   8.993 +
   8.994 +    public void testA3() throws IOException, ReflectiveOperationException {
   8.995 +        compileSpec("C(A(Id0),J)");
   8.996 +        assertLinkage("C", "I0");
   8.997 +    }
   8.998 +
   8.999 +    public void testA4() throws IOException, ReflectiveOperationException {
  8.1000 +        compileSpec("D(C(Id0),Jd0(Id0))");
  8.1001 +        assertLinkage("D", "J0");
  8.1002 +        assertLinkage("C", "I0");
  8.1003 +    }
  8.1004 +
  8.1005 +    public void testA5() throws IOException, ReflectiveOperationException {
  8.1006 +        compileSpec("C(A(Id0),Jd0)",
  8.1007 +                    "compiler.err.types.incompatible.unrelated.defaults");
  8.1008 +    }
  8.1009 +
  8.1010 +    public void testA6() throws IOException, ReflectiveOperationException {
  8.1011 +        compileSpec("C(A(Ia0,Jd0))",
  8.1012 +                    "compiler.err.does.not.override.abstract",
  8.1013 +                    "compiler.err.types.incompatible.abstract.default");
  8.1014 +    }
  8.1015 +
  8.1016 +    public void testA7() throws IOException, ReflectiveOperationException {
  8.1017 +        compileSpec("C(A(Id0,Jd0))",
  8.1018 +                    "compiler.err.types.incompatible.unrelated.defaults");
  8.1019 +    }
  8.1020 +
  8.1021 +    public void testA8() throws IOException, ReflectiveOperationException {
  8.1022 +        compileSpec("C(A(Ia0),J)", "compiler.err.does.not.override.abstract");
  8.1023 +    }
  8.1024 +
  8.1025 +    public void testA9() throws IOException, ReflectiveOperationException {
  8.1026 +        compileSpec("C(Ac0(Id0))");
  8.1027 +        assertLinkage("C", "A0");
  8.1028 +    }
  8.1029 +
  8.1030 +    public void testA10() throws IOException, ReflectiveOperationException {
  8.1031 +        compileSpec("C(Aa0,I)", "compiler.err.does.not.override.abstract");
  8.1032 +    }
  8.1033 +
  8.1034 +    public void testA11() throws IOException, ReflectiveOperationException {
  8.1035 +        compileSpec("C(Ac0,Id0)");
  8.1036 +        assertLinkage("C", "A0");
  8.1037 +    }
  8.1038 +
  8.1039 +    // Dan's set B
  8.1040 +
  8.1041 +    /* B1 can't be done, needs a second concrete class D
  8.1042 +    public void testB1() throws IOException, ReflectiveOperationException {
  8.1043 +        compileSpec("Cc1(Dc0)");
  8.1044 +        assertLinkage("C", "C1", "C1");
  8.1045 +        assertLinkage("D", "A0", LINKAGE_ERROR);
  8.1046 +    }
  8.1047 +    */
  8.1048 +
  8.1049 +    public void testB2() throws IOException, ReflectiveOperationException {
  8.1050 +        compileSpec("Cc1(Ac0)");
  8.1051 +        assertLinkage("C", "C1", "C1");
  8.1052 +    }
  8.1053 +
  8.1054 +    //??? B3 seems to suggest that we should create an abstract class
  8.1055 +    //public void testB3() throws IOException, ReflectiveOperationException {
  8.1056 +    //    compileSpec("Ba1(Cc0)");
  8.1057 +    //    assertLinkage("B", "C0", "A1");
  8.1058 +    //}
  8.1059 +
  8.1060 +    // B4 needs too many classes
  8.1061 +
  8.1062 +    public void testB5() throws IOException, ReflectiveOperationException {
  8.1063 +        compileSpec("Cc1(Aa1(Id0))");
  8.1064 +        assertLinkage("C", "C1", "C1");
  8.1065 +    }
  8.1066 +
  8.1067 +    public void testB6() throws IOException, ReflectiveOperationException {
  8.1068 +        compileSpec("C(Ac1(Id0))");
  8.1069 +        assertLinkage("C", "A1", "A1");
  8.1070 +    }
  8.1071 +
  8.1072 +    public void testB7() throws IOException, ReflectiveOperationException {
  8.1073 +        compileSpec("Cc1(Id0)");
  8.1074 +        assertLinkage("C", "C1", "C1");
  8.1075 +    }
  8.1076 +
  8.1077 +    public void testB8() throws IOException, ReflectiveOperationException {
  8.1078 +        compileSpec("C(Jd1(Id0))");
  8.1079 +        assertLinkage("C", "J1", "J1");
  8.1080 +    }
  8.1081 +
  8.1082 +    // B9 needs too many classes
  8.1083 +
  8.1084 +    // The rest of Dan's tests need generics
  8.1085 +}
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/test/tools/javac/lambda/bridge/template_tests/TEST.properties	Mon Sep 09 17:11:55 2013 -0400
     9.3 @@ -0,0 +1,7 @@
     9.4 +# This file identifies root(s) of the test-ng hierarchy.
     9.5 +
     9.6 +
     9.7 +
     9.8 +TestNG.dirs = .
     9.9 +
    9.10 +lib.dirs = /lib/combo

mercurial