author | alanb |
Fri, 07 Apr 2017 08:05:54 +0000 | |
changeset 44545 | 83b611b88ac8 |
parent 40681 | 87d3f0e6a51f |
permissions | -rw-r--r-- |
36757
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
1 |
/* |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
4 |
* |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
8 |
* |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
13 |
* accompanied this code). |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
14 |
* |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
18 |
* |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
21 |
* questions. |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
22 |
*/ |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
23 |
|
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
24 |
import java.nio.file.Path; |
40681
87d3f0e6a51f
8164858: Enable build-time use of java.lang.invoke resolve tracing
redestad
parents:
40562
diff
changeset
|
25 |
import java.util.Collection; |
36757
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
26 |
import java.util.List; |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
27 |
import java.util.stream.Collectors; |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
28 |
|
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
29 |
import jdk.tools.jlink.internal.plugins.GenerateJLIClassesPlugin; |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
30 |
|
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
31 |
import tests.Helper; |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
32 |
import tests.JImageGenerator; |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
33 |
import tests.JImageValidator; |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
34 |
import tests.Result; |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
35 |
|
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
36 |
/* |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
37 |
* @test |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
38 |
* @library ../../lib |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
39 |
* @summary Test --generate-jli-classes plugin |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
40 |
* @modules java.base/jdk.internal.jimage |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
41 |
* jdk.jdeps/com.sun.tools.classfile |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
42 |
* jdk.jlink/jdk.tools.jlink.internal |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
43 |
* jdk.jlink/jdk.tools.jlink.internal.plugins |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
44 |
* jdk.jlink/jdk.tools.jmod |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
45 |
* jdk.jlink/jdk.tools.jimage |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
46 |
* @build tests.* |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
47 |
* @run main/othervm GenerateJLIClassesPluginTest |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
48 |
*/ |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
49 |
public class GenerateJLIClassesPluginTest { |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
50 |
|
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
51 |
private static Helper helper; |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
52 |
|
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
53 |
public static void main(String[] args) throws Exception { |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
54 |
helper = Helper.newHelper(); |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
55 |
if (helper == null) { |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
56 |
System.err.println("Test not run"); |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
57 |
return; |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
58 |
} |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
59 |
|
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
60 |
helper.generateDefaultModules(); |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
61 |
|
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
62 |
|
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
63 |
// Test that generate-jli is enabled by default |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
64 |
Result result = JImageGenerator.getJLinkTask() |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
65 |
.modulePath(helper.defaultModulePath()) |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
66 |
.output(helper.createNewImageDir("generate-jli")) |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
67 |
.addMods("java.base") |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
68 |
.call(); |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
69 |
|
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
70 |
Path image = result.assertSuccess(); |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
71 |
|
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
72 |
JImageValidator.validate( |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
73 |
image.resolve("lib").resolve("modules"), |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
74 |
classFilesForSpecies(GenerateJLIClassesPlugin.defaultSpecies()), |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
75 |
List.of()); |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
76 |
|
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
77 |
} |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
78 |
|
40681
87d3f0e6a51f
8164858: Enable build-time use of java.lang.invoke resolve tracing
redestad
parents:
40562
diff
changeset
|
79 |
private static List<String> classFilesForSpecies(Collection<String> species) { |
36757
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
80 |
return species.stream() |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
81 |
.map(s -> "/java.base/java/lang/invoke/BoundMethodHandle$Species_" + s + ".class") |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
82 |
.collect(Collectors.toList()); |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
83 |
} |
c859c6feee56
8152641: Plugin to generate BMH$Species classes ahead-of-time
redestad
parents:
diff
changeset
|
84 |
} |