jdk/test/java/lang/Package/annotation/PackageInfoTest.java
author alanb
Thu, 17 Mar 2016 19:04:16 +0000
changeset 36511 9d0388c6b336
child 44358 d1d1a888d492
permissions -rw-r--r--
8142968: Module System implementation Summary: Initial integration of JEP 200, JEP 260, JEP 261, and JEP 282 Reviewed-by: alanb, mchung, naoto, rriggs, psandoz, plevart, mullan, ascarpino, vinnie, prr, sherman, dfuchs, mhaupt Contributed-by: alan.bateman@oracle.com, alex.buckley@oracle.com, jonathan.gibbons@oracle.com, karen.kinnear@oracle.com, mandy.chung@oracle.com, mark.reinhold@oracle.com, chris.hegarty@oracle.com, alexandr.scherbatiy@oracle.com, amy.lu@oracle.com, calvin.cheung@oracle.com, daniel.fuchs@oracle.com, erik.joelsson@oracle.com, harold.seigel@oracle.com, jaroslav.bachorik@oracle.com, jean-francois.denise@oracle.com, jan.lahoda@oracle.com, james.laskey@oracle.com, lois.foltan@oracle.com, miroslav.kos@oracle.com, huaming.li@oracle.com, sean.mullan@oracle.com, naoto.sato@oracle.com, masayoshi.okutsu@oracle.com, peter.levart@gmail.com, philip.race@oracle.com, claes.redestad@oracle.com, sergey.bylokhov@oracle.com, alexandre.iline@oracle.com, volker.simonis@gmail.com, staffan.larsen@oracle.com, stuart.marks@oracle.com, semyon.sadetsky@oracle.com, serguei.spitsyn@oracle.com, sundararajan.athijegannathan@oracle.com, valerie.peng@oracle.com, vincent.x.ryan@oracle.com, weijun.wang@oracle.com, yuri.nesterenko@oracle.com, yekaterina.kantserova@oracle.com, alexander.kulyakhtin@oracle.com, felix.yang@oracle.com, andrei.eremeev@oracle.com, frank.yuan@oracle.com, sergei.pikalev@oracle.com, sibabrata.sahoo@oracle.com, tiantian.du@oracle.com, sha.jiang@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36511
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     1
/*
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     4
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     8
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    13
 * accompanied this code).
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    14
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    18
 *
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    21
 * questions.
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    22
 */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    23
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    24
/*
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    25
 * @test
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    26
 * @summary Basic test of package-info in named module and duplicate
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    27
 *          package-info in unnamed module
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    28
 * @modules java.compiler
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    29
 *          java.desktop
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    30
 *          jdk.compiler
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    31
 *          jdk.xml.dom
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    32
 * @build jdk.xml.dom/org.w3c.dom.css.Fake
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    33
 *        jdk.xml.dom/org.w3c.dom.css.FakePackage
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    34
 * @compile/module=jdk.xml.dom org/w3c/dom/css/package-info.java
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    35
 * @compile package-info.java PackageInfoTest.java
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    36
 * @run testng p.PackageInfoTest
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    37
 */
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    38
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    39
package p;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    40
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    41
import java.io.IOException;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    42
import java.io.UncheckedIOException;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    43
import java.lang.annotation.Annotation;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    44
import java.net.URL;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    45
import java.net.URLClassLoader;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    46
import java.nio.file.Files;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    47
import java.nio.file.Path;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    48
import java.nio.file.Paths;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    49
import java.util.ArrayList;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    50
import java.util.Arrays;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    51
import java.util.List;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    52
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    53
import org.testng.annotations.DataProvider;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    54
import org.testng.annotations.Test;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    55
import org.w3c.dom.css.CSSRule;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    56
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    57
import javax.tools.JavaCompiler;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    58
import javax.tools.JavaFileObject;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    59
import javax.tools.StandardJavaFileManager;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    60
import javax.tools.ToolProvider;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    61
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    62
import static org.testng.Assert.*;
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    63
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    64
public class PackageInfoTest {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    65
    @DataProvider(name = "jdkClasses")
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    66
    public Object[][] jdkClasses() {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    67
        return new Object[][] {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    68
            { java.awt.Button.class,             null },
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    69
            { java.lang.Object.class,            null },
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    70
            { org.w3c.dom.css.CSSRule.class,     null },
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    71
            { loadClass("org.w3c.dom.css.Fake"), loadClass("org.w3c.dom.css.FakePackage") },
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    72
        };
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    73
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    74
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    75
    @Test(dataProvider = "jdkClasses")
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    76
    public void testPackageInfo(Class<?> type, Class<? extends Annotation> annType) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    77
        Package pkg = type.getPackage();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    78
        assertTrue(pkg.isSealed());
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    79
        assertTrue(annType == null || pkg.getDeclaredAnnotations().length != 0);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    80
        if (annType != null) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    81
            assertTrue(pkg.isAnnotationPresent(annType));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    82
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    83
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    84
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    85
    private Class<?> loadClass(String name) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    86
        return Class.forName(CSSRule.class.getModule(), name);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    87
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    88
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    89
    @DataProvider(name = "classpathClasses")
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    90
    public Object[][] cpClasses() throws IOException, ClassNotFoundException {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    91
        // these classes will be loaded from classpath in unnamed module
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    92
        return new Object[][]{
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    93
                { p.PackageInfoTest.class, Deprecated.class }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    94
        };
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    95
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    96
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    97
    @Test(dataProvider = "classpathClasses")
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    98
    public void testClassPathPackage(Class<?> type, Class<? extends Annotation> annType) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
    99
        Package pkg = type.getPackage();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   100
        assertTrue(pkg.isSealed() == false);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   101
        assertTrue(pkg.isAnnotationPresent(annType));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   102
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   103
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   104
    static final String[] otherClasses = new String[] {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   105
            "p/package-info.class",
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   106
            "p/Duplicate.class",
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   107
            "p/Bar.class"
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   108
    };
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   109
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   110
    @Test
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   111
    public void testDuplicatePackage() throws Exception {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   112
        // a custom class loader loading another package p annotated with @Duplicate
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   113
        Path classes = Paths.get(System.getProperty("test.classes", "."), "tmp");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   114
        Files.createDirectories(classes);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   115
        URLClassLoader loader = new URLClassLoader(new URL[] { classes.toUri().toURL() });
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   116
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   117
        // clean up before compiling classes
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   118
        Arrays.stream(otherClasses)
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   119
                .forEach(c -> {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   120
                    try {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   121
                        Files.deleteIfExists(classes.resolve(c));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   122
                    } catch (IOException e) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   123
                        throw new UncheckedIOException(e);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   124
                    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   125
                });
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   126
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   127
        Path src = Paths.get(System.getProperty("test.src", "."), "src", "p");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   128
        compile(classes,
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   129
                src.resolve("package-info.java"),
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   130
                src.resolve("Duplicate.java"),
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   131
                src.resolve("Bar.java"));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   132
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   133
        // verify if classes are present
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   134
        Arrays.stream(otherClasses)
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   135
              .forEach(c -> {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   136
                  if (Files.notExists(classes.resolve(c))) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   137
                      throw new RuntimeException(c + " not exist");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   138
                  }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   139
        });
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   140
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   141
        Class<?> c = Class.forName("p.Bar", true, loader);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   142
        assertTrue(c.getClassLoader() == loader);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   143
        assertTrue(this.getClass().getClassLoader() != loader);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   144
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   145
        // package p defined by the custom class loader
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   146
        Package pkg = c.getPackage();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   147
        assertTrue(pkg.getName().equals("p"));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   148
        assertTrue(pkg.isSealed() == false);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   149
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   150
        // package p defined by the application class loader
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   151
        Package p = this.getClass().getPackage();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   152
        assertTrue(p.getName().equals("p"));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   153
        assertTrue(p != pkg);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   154
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   155
        Arrays.stream(pkg.getDeclaredAnnotations())
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   156
              .forEach(ann -> System.out.format("%s @%s%n", pkg.getName(), ann));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   157
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   158
        Arrays.stream(p.getDeclaredAnnotations())
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   159
              .forEach(ann -> System.out.format("%s @%s%n", p.getName(), ann));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   160
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   161
        // local package p defined by loader
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   162
        Class<? extends Annotation> ann =
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   163
            (Class<? extends Annotation>)Class.forName("p.Duplicate", false, loader);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   164
        assertTrue(pkg.isAnnotationPresent(ann));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   165
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   166
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   167
    private void compile(Path destDir, Path... files) throws IOException {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   168
        compile(null, destDir, files);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   169
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   170
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   171
    private void compile(String option, Path destDir, Path... files)
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   172
            throws IOException
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   173
    {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   174
        System.err.println("compile...");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   175
        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   176
        try (StandardJavaFileManager fm = compiler.getStandardFileManager(null, null, null)) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   177
            Iterable<? extends JavaFileObject> fileObjects =
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   178
                fm.getJavaFileObjectsFromPaths(Arrays.asList(files));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   179
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   180
            List<String> options = new ArrayList<>();
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   181
            if (option != null) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   182
                options.add(option);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   183
            }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   184
            if (destDir != null) {
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   185
                options.add("-d");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   186
                options.add(destDir.toString());
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   187
            }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   188
            options.add("-cp");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   189
            options.add(System.getProperty("test.classes", "."));
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   190
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   191
            JavaCompiler.CompilationTask task =
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   192
                compiler.getTask(null, fm, null, options, null, fileObjects);
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   193
            if (!task.call())
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   194
                throw new AssertionError("compilation failed");
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   195
        }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   196
    }
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   197
9d0388c6b336 8142968: Module System implementation
alanb
parents:
diff changeset
   198
}