author | prr |
Fri, 25 May 2018 12:12:24 -0700 | |
changeset 50347 | b2f046ae8eb6 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
36511 | 1 |
/* |
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
import java.util.ArrayList; |
|
24 |
import java.util.List; |
|
25 |
import java.util.Map; |
|
26 |
import java.util.Set; |
|
39834
53a6fb443c20
8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents:
39321
diff
changeset
|
27 |
import jdk.tools.jlink.plugin.ResourcePool; |
53a6fb443c20
8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents:
39321
diff
changeset
|
28 |
import jdk.tools.jlink.plugin.ResourcePoolBuilder; |
36511 | 29 |
import jdk.tools.jlink.internal.PluginRepository; |
39321
c60f34e8c057
8160641: PostProcessingPlugin and ExecutableImage should not be part of plugin API
sundar
parents:
38320
diff
changeset
|
30 |
import jdk.tools.jlink.plugin.Plugin; |
36511 | 31 |
|
32 |
import tests.Helper; |
|
33 |
||
34 |
/* |
|
35 |
* @test |
|
36 |
* @summary Test jlink options |
|
37 |
* @author Jean-Francois Denise |
|
38 |
* @library ../lib |
|
39 |
* @modules java.base/jdk.internal.jimage |
|
40 |
* jdk.jdeps/com.sun.tools.classfile |
|
41 |
* jdk.jlink/jdk.tools.jlink.internal |
|
43185 | 42 |
* jdk.jlink/jdk.tools.jlink.plugin |
36511 | 43 |
* jdk.jlink/jdk.tools.jmod |
44 |
* jdk.jlink/jdk.tools.jimage |
|
45 |
* jdk.compiler |
|
46 |
* @build tests.* |
|
47 |
* @run main JLinkOptionsTest |
|
48 |
*/ |
|
49 |
public class JLinkOptionsTest { |
|
50 |
||
39321
c60f34e8c057
8160641: PostProcessingPlugin and ExecutableImage should not be part of plugin API
sundar
parents:
38320
diff
changeset
|
51 |
private static class TestPlugin implements Plugin { |
36511 | 52 |
private final String name; |
53 |
private final String option; |
|
54 |
||
55 |
private TestPlugin(String name, String option) { |
|
56 |
this.name = name; |
|
57 |
this.option = option; |
|
58 |
} |
|
59 |
||
60 |
||
61 |
@Override |
|
62 |
public String getOption() { |
|
63 |
return option; |
|
64 |
} |
|
65 |
||
66 |
@Override |
|
39834
53a6fb443c20
8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents:
39321
diff
changeset
|
67 |
public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) { |
53a6fb443c20
8162538: plugin API should avoid read only pool, have module view separated from resource view and have pool builder to modify
sundar
parents:
39321
diff
changeset
|
68 |
return out.build(); |
36511 | 69 |
} |
70 |
||
71 |
@Override |
|
72 |
public String getName() { |
|
73 |
return name; |
|
74 |
} |
|
75 |
||
76 |
@Override |
|
77 |
public String getDescription() { |
|
78 |
return name; |
|
79 |
} |
|
80 |
} |
|
81 |
||
82 |
public static void main(String[] args) throws Exception { |
|
83 |
Helper helper = Helper.newHelper(); |
|
84 |
if (helper == null) { |
|
85 |
System.err.println("Test not run"); |
|
86 |
return; |
|
87 |
} |
|
88 |
helper.generateDefaultModules(); |
|
89 |
{ |
|
90 |
// multiple plugins with same option |
|
91 |
||
92 |
PluginRepository. |
|
93 |
registerPlugin(new TestPlugin("test1", "test1")); |
|
94 |
PluginRepository. |
|
95 |
registerPlugin(new TestPlugin("test2", "test1")); |
|
96 |
helper.generateDefaultImage("composite2").assertFailure("Error: More than one plugin enabled by test1 option"); |
|
97 |
PluginRepository.unregisterPlugin("test1"); |
|
98 |
PluginRepository.unregisterPlugin("test2"); |
|
99 |
} |
|
100 |
} |
|
101 |
} |