52 throw new RuntimeException( 53 "Unexpected non-null value for property " + prop); 54 } 55 } 56 57 // For options of the form "option=value", check that an exception gets thrown for 58 // the illegal value and then check that its corresponding property is handled 59 // correctly. 60 public static void testOption(String option, String value, 61 String prop, String result) throws Exception { 62 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( 63 option + "=" + value, "-version"); 64 OutputAnalyzer output = new OutputAnalyzer(pb.start()); 65 output.shouldContain(result); 66 testProperty(prop, value); 67 } 68 69 public static void main(String[] args) throws Exception { 70 testOption("--add-modules", "java.sqlx", "jdk.module.addmods", "java.lang.module.ResolutionException"); 71 testOption("--limit-modules", "java.sqlx", "jdk.module.limitmods", "java.lang.module.ResolutionException"); 72 testOption("--add-reads", "xyzz=yyzd", "jdk.module.addreads.0", "java.lang.RuntimeException"); 73 testOption("--add-exports", "java.base/xyzz=yyzd", "jdk.module.addexports.0", "java.lang.RuntimeException"); 74 testOption("--patch-module", "=d", "jdk.module.patch.0", "IllegalArgumentException"); 75 } 76 } | 52 throw new RuntimeException( 53 "Unexpected non-null value for property " + prop); 54 } 55 } 56 57 // For options of the form "option=value", check that an exception gets thrown for 58 // the illegal value and then check that its corresponding property is handled 59 // correctly. 60 public static void testOption(String option, String value, 61 String prop, String result) throws Exception { 62 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( 63 option + "=" + value, "-version"); 64 OutputAnalyzer output = new OutputAnalyzer(pb.start()); 65 output.shouldContain(result); 66 testProperty(prop, value); 67 } 68 69 public static void main(String[] args) throws Exception { 70 testOption("--add-modules", "java.sqlx", "jdk.module.addmods", "java.lang.module.ResolutionException"); 71 testOption("--limit-modules", "java.sqlx", "jdk.module.limitmods", "java.lang.module.ResolutionException"); 72 testOption("--add-reads", "xyzz=yyzd", "jdk.module.addreads.0", "WARNING: Unknown module: xyzz"); 73 testOption("--add-exports", "java.base/xyzz=yyzd", "jdk.module.addexports.0", 74 "WARNING: package xyzz not in java.base"); 75 testOption("--patch-module", "=d", "jdk.module.patch.0", "IllegalArgumentException"); 76 } 77 } |