test/runtime/modules/ModuleOptionsTest.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File bug_8165634.hs Sdiff test/runtime/modules

test/runtime/modules/ModuleOptionsTest.java

Print this page




  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8136930
  27  * @summary Test that the VM only recognizes the last specified --add-modules
  28  *          and --list-modules options
  29  * @modules java.base/jdk.internal.misc
  30  * @library /test/lib
  31  */
  32 
  33 import jdk.test.lib.process.OutputAnalyzer;
  34 import jdk.test.lib.process.ProcessTools;
  35 
  36 // Test that the VM behaves correctly when processing module related options.
  37 public class ModuleOptionsTest {
  38 
  39     public static void main(String[] args) throws Exception {
  40 
  41         // Test that last --add-modules is the only one recognized.  No exception
  42         // should be thrown.
  43         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  44             "--add-modules=i_dont_exist", "--add-modules=java.base", "-version");
  45         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  46         output.shouldHaveExitValue(0);


  47 
  48         // Test that last --limit-modules is the only one recognized.  No exception
  49         // should be thrown.
  50         pb = ProcessTools.createJavaProcessBuilder(
  51             "--limit-modules=i_dont_exist", "--limit-modules=java.base", "-version");
  52         output = new OutputAnalyzer(pb.start());
  53         output.shouldHaveExitValue(0);
  54     }
  55 }


  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8136930
  27  * @summary Test that the VM only recognizes the last specified --add-modules
  28  *          and --list-modules options
  29  * @modules java.base/jdk.internal.misc
  30  * @library /test/lib
  31  */
  32 
  33 import jdk.test.lib.process.OutputAnalyzer;
  34 import jdk.test.lib.process.ProcessTools;
  35 
  36 // Test that the VM behaves correctly when processing module related options.
  37 public class ModuleOptionsTest {
  38 
  39     public static void main(String[] args) throws Exception {
  40 
  41         // Test that multiple --add-modules options are cumulative, not last one wins.
  42         // An exception should be thrown because module i_dont_exist doesn't exist.
  43         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
  44             "--add-modules=i_dont_exist", "--add-modules=java.base", "-version");
  45         OutputAnalyzer output = new OutputAnalyzer(pb.start());
  46         output.shouldContain("ResolutionException");
  47         output.shouldContain("i_dont_exist");
  48         output.shouldHaveExitValue(1);
  49 
  50         // Test that the last --limit-modules is the only one recognized.  No exception
  51         // should be thrown.
  52         pb = ProcessTools.createJavaProcessBuilder(
  53             "--limit-modules=i_dont_exist", "--limit-modules=java.base", "-version");
  54         output = new OutputAnalyzer(pb.start());
  55         output.shouldHaveExitValue(0);
  56     }
  57 }
test/runtime/modules/ModuleOptionsTest.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File