changeset 4271:82914aba2ab3

update test infra for updated directives
author jjg
date Tue, 23 Aug 2016 18:43:29 -0700
parents 7dc08febda0a
children 3c440892cf45
files test/tools/javac/classfiles/attributes/Module/ModuleTestBase.java test/tools/lib/toolbox/ModuleBuilder.java
diffstat 2 files changed, 105 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/test/tools/javac/classfiles/attributes/Module/ModuleTestBase.java	Tue Aug 23 17:12:21 2016 -0700
+++ b/test/tools/javac/classfiles/attributes/Module/ModuleTestBase.java	Tue Aug 23 18:43:29 2016 -0700
@@ -170,7 +170,8 @@
     }
 
     enum ExportFlag implements Mask {
-        DYNAMIC("dynamic", Module_attribute.ACC_DYNAMIC_PHASE);
+        DYNAMIC("dynamic", Module_attribute.ACC_DYNAMIC_PHASE),
+        PRIVATE("private", Module_attribute.ACC_PRIVATE_REFLECTION);
 
         private final String token;
         private final int mask;
--- a/test/tools/lib/toolbox/ModuleBuilder.java	Tue Aug 23 17:12:21 2016 -0700
+++ b/test/tools/lib/toolbox/ModuleBuilder.java	Tue Aug 23 18:43:29 2016 -0700
@@ -72,50 +72,132 @@
     }
 
     /**
-     * Adds a "requires transitive" directive to the declaration.
-     * @param requires the name of the module that is required
+     * Adds a "requires" directive to the declaration.
+     * @param module the name of the module that is required
+     * @param modulePath a path in while to locate the modules
+     *    if the declaration is compiled
+     * @return this builder
+     */
+    public ModuleBuilder requires(String module, Path... modulePath) {
+        addDirective(requires, "requires " + module + ";");
+        this.modulePath.addAll(Arrays.asList(modulePath));
+        return this;
+
+    }
+
+    /**
+     * Adds a "requires static" directive to the declaration.
+     * @param module the name of the module that is required
      * @param modulePath a path in which to locate the modules
      *    if the declaration is compiled
      * @return this builder
      */
-    public ModuleBuilder requiresTransitive(String requires, Path... modulePath) {
-        this.requires.add("requires transitive " + requires + ";");
+    public ModuleBuilder requiresStatic(String module, Path... modulePath) {
+        addDirective(requires, "requires static " + module + ";");
         this.modulePath.addAll(Arrays.asList(modulePath));
         return this;
     }
 
     /**
-     * Adds a "requires" directive to the declaration.
-     * @param requires the name of the module that is required
-     * @param modulePath a path in while to locate the modules
+     * Adds a "requires transitive" directive to the declaration.
+     * @param module the name of the module that is required
+     * @param modulePath a path in which to locate the modules
      *    if the declaration is compiled
      * @return this builder
      */
-    public ModuleBuilder requires(String requires, Path... modulePath) {
-        this.requires.add("requires " + requires + ";");
+    public ModuleBuilder requiresTransitive(String module, Path... modulePath) {
+        addDirective(requires, "requires transitive " + module + ";");
         this.modulePath.addAll(Arrays.asList(modulePath));
         return this;
     }
 
     /**
+     * Adds a "requires static transitive" directive to the declaration.
+     * @param module the name of the module that is required
+     * @param modulePath a path in which to locate the modules
+     *    if the declaration is compiled
+     * @return this builder
+     */
+    public ModuleBuilder requiresStaticTransitive(String module, Path... modulePath) {
+        addDirective(requires, "requires static transitive " + module + ";");
+        this.modulePath.addAll(Arrays.asList(modulePath));
+        return this;
+    }
+
+    /**
+     * Adds an unqualified "exports" directive to the declaration.
+     * @param pkg the name of the package to be exported
+     * @return this builder
+     */
+    public ModuleBuilder exports(String pkg) {
+        return addDirective(exports, "exports " + pkg + ";");
+    }
+
+    /**
+     * Adds an unqualified "exports dynamic" directive to the declaration.
+     * @param pkg the name of the package to be exported
+     * @return this builder
+     */
+    public ModuleBuilder exportsDynamic(String pkg) {
+        return addDirective(exports, "exports dynamic " + pkg + ";");
+    }
+
+    /**
+     * Adds an unqualified "exports private" directive to the declaration.
+     * @param pkg the name of the package to be exported
+     * @return this builder
+     */
+    public ModuleBuilder exportsPrivate(String pkg) {
+        return addDirective(exports, "exports private " + pkg + ";");
+    }
+
+    /**
+     * Adds an unqualified "exports dynamic private" directive to the declaration.
+     * @param pkg the name of the package to be exported
+     * @return this builder
+     */
+    public ModuleBuilder exportsDynamicPrivate(String pkg) {
+        return addDirective(exports, "exports dynamic private " + pkg + ";");
+    }
+
+    /**
      * Adds a qualified "exports" directive to the declaration.
      * @param pkg the name of the package to be exported
      * @param module the name of the module to which it is to be exported
      * @return this builder
      */
     public ModuleBuilder exportsTo(String pkg, String module) {
-        this.exports.add("exports " + pkg + " to " + module + ";");
-        return this;
+        return addDirective(exports, "exports " + pkg + " to " + module + ";");
     }
 
     /**
-     * Adds an unqualified "exports" directive to the declaration.
+     * Adds a qualified "exports dynamic" directive to the declaration.
      * @param pkg the name of the package to be exported
+     * @param module the name of the module to which it is to be exported
      * @return this builder
      */
-    public ModuleBuilder exports(String pkg) {
-        this.exports.add("exports " + pkg + ";");
-        return this;
+    public ModuleBuilder exportsDynamicTo(String pkg, String module) {
+        return addDirective(exports, "exports dynamic " + pkg + " to " + module + ";");
+    }
+
+    /**
+     * Adds a qualified "exports private" directive to the declaration.
+     * @param pkg the name of the package to be exported
+     * @param module the name of the module to which it is to be exported
+     * @return this builder
+     */
+    public ModuleBuilder exportsPrivateTo(String pkg, String module) {
+        return addDirective(exports, "exports private " + pkg + " to " + module + ";");
+    }
+
+    /**
+     * Adds a qualified "exports dynamic private" directive to the declaration.
+     * @param pkg the name of the package to be exported
+     * @param module the name of the module to which it is to be exported
+     * @return this builder
+     */
+    public ModuleBuilder exportsDynamicPrivateTo(String pkg, String module) {
+        return addDirective(exports, "exports dynamic private " + pkg + " to " + module + ";");
     }
 
     /**
@@ -124,8 +206,7 @@
      * @return this builder
      */
     public ModuleBuilder uses(String service) {
-        this.uses.add("uses " + service + ";");
-        return this;
+        return addDirective(uses, "uses " + service + ";");
     }
 
     /**
@@ -135,7 +216,11 @@
      * @return this builder
      */
     public ModuleBuilder provides(String service, String implementation) {
-        this.provides.add("provides " + service + " with " + implementation + ";");
+        return addDirective(provides, "provides " + service + " with " + implementation + ";");
+    }
+
+    private ModuleBuilder addDirective(List<String> directives, String directive) {
+        directives.add(directive);
         return this;
     }