8172288: Fix Jigsaw related module/package error messages and throw correct exceptions
authorhseigel
Fri, 13 Jan 2017 10:45:53 -0500
changeset 43529 d6c3cdeedf6d
parent 43528 977dab1b9ce9
child 43531 c31f3ca41bd8
8172288: Fix Jigsaw related module/package error messages and throw correct exceptions Summary: Reword error messages and throw IllegalStateExceptions where appropriate Reviewed-by: alanb, acorn, lfoltan, gtriantafill
jdk/src/java.base/share/classes/java/lang/reflect/Layer.java
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Layer.java	Mon Jan 09 15:10:25 2017 +0100
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Layer.java	Fri Jan 13 10:45:53 2017 -0500
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2017, 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
@@ -458,7 +458,7 @@
             loader.initRemotePackageMap(cf, parents);
             Layer layer =  new Layer(cf, parents, mn -> loader);
             return new Controller(layer);
-        } catch (IllegalArgumentException e) {
+        } catch (IllegalArgumentException | IllegalStateException e) {
             throw new LayerInstantiationException(e.getMessage());
         }
     }
@@ -526,7 +526,7 @@
         try {
             Layer layer = new Layer(cf, parents, pool::loaderFor);
             return new Controller(layer);
-        } catch (IllegalArgumentException e) {
+        } catch (IllegalArgumentException | IllegalStateException e) {
             throw new LayerInstantiationException(e.getMessage());
         }
     }
@@ -610,9 +610,8 @@
         try {
             Layer layer = new Layer(cf, parents, clf);
             return new Controller(layer);
-        } catch (IllegalArgumentException iae) {
-            // IAE is thrown by VM when defining the module fails
-            throw new LayerInstantiationException(iae.getMessage());
+        } catch (IllegalArgumentException | IllegalStateException e) {
+            throw new LayerInstantiationException(e.getMessage());
         }
     }