changeset 319:f79ef1ecc483

always generate --add-modules for all unique modules in @modules
author jjg
date Thu, 01 Dec 2016 17:17:46 -0800
parents 7605d042afbc
children 312be909d147
files src/share/classes/com/sun/javatest/regtest/exec/Action.java src/share/test/javatest/regtest/data/addmods/TEST.ROOT src/share/test/javatest/regtest/data/addmods/TestNonDefaultCompiler.java src/share/test/javatest/regtest/data/addmods/TestNonDefaultRuntime.java
diffstat 3 files changed, 86 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/com/sun/javatest/regtest/exec/Action.java	Wed Nov 30 15:46:57 2016 -0800
+++ b/src/share/classes/com/sun/javatest/regtest/exec/Action.java	Thu Dec 01 17:17:46 2016 -0800
@@ -515,21 +515,16 @@
         Modules modules = script.getModules();
 
         boolean needAddExports = false;
-        StringBuilder addModules = null;
+        Set<String> addModules = null;
         for (Modules.Entry e: modules) {
             String m = e.moduleName;
             if (e.needAddExports(phase)) {
                 needAddExports = true;
             }
-            if (!script.defaultModules.contains(m)) {
-                if (addModules == null) {
-                    addModules = new StringBuilder();
-                } else {
-                    addModules.append(",");
-                }
-                addModules.append(m);
+            if (addModules == null) {
+                addModules = new LinkedHashSet<>();
             }
-
+            addModules.add(m);
         }
         if (!needAddExports && addModules == null) {
             return Collections.<String>emptyList();
@@ -538,7 +533,7 @@
         List<String> list = new ArrayList<>();
         if (addModules != null) {
             list.add("--add-modules");
-            list.add(addModules.toString());
+            list.add(StringUtils.join(addModules, ","));
         }
 
         for (Modules.Entry e: modules) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/test/javatest/regtest/data/addmods/TestNonDefaultCompiler.java	Thu Dec 01 17:17:46 2016 -0800
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @modules jdk.charsets/sun.nio.cs.ext
+ */
+
+// jdk.charsets module will be resolved by default at runtime
+// (because it provides a service) but will not be resolved
+// at compile time (because it does not export API.)
+// The implicit test is whether jtreg will use --add-modules
+// because of the @modules directive in the test description.
+
+import sun.nio.cs.ext.ExtendedCharsets;
+
+public class TestNonDefaultCompiler {
+    public static void main(String... args) {
+        ExtendedCharsets e;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/test/javatest/regtest/data/addmods/TestNonDefaultRuntime.java	Thu Dec 01 17:17:46 2016 -0800
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @modules java.annotations.common
+ */
+
+// java.annotations.common module will not be resolved by default
+// at runtime (because it is one of the EE APIs in Java SE.)
+// The implicit test is whether jtreg will use --add-modules
+// because of the @modules directive in the test description.
+
+import javax.annotation.Generated;
+
+public class TestNonDefaultRuntime {
+    public static void main(String... args) {
+        Generated g;
+    }
+}