changeset 18598:7224d3b718ed

DEBUG_ADD_OPENS: Anonymize the WARNING exception class
author mr
date Thu, 15 Dec 2016 07:15:53 -0800
parents eb56db7b3aaa
children 9db6639ded4c
files src/java.base/share/classes/java/lang/reflect/AccessibleObject.java
diffstat 1 files changed, 10 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java	Thu Dec 15 14:10:16 2016 +0000
+++ b/src/java.base/share/classes/java/lang/reflect/AccessibleObject.java	Thu Dec 15 07:15:53 2016 -0800
@@ -223,31 +223,24 @@
         printStackTraceIfExposedReflectively(module, pn, other, false);
     }
 
-    private static class WARNING extends Exception {
-
-        private static final long serialVersionUID = 42L;
-
-        private WARNING(String msg) {
-            super(msg);
-        }
-
-        public String toString() {
-            return "WARNING: " + getMessage();
-        }
-
-    }
-
     private void printStackTraceIfExposedReflectively(Module module,
                                                       String pn,
                                                       Module other,
-                                                      boolean open) {
+                                                      boolean open)
+    {
         if (Reflection.printStackTraceWhenAccessSucceeds()
-                && !module.isStaticallyExportedOrOpen(pn, other, open)) {
+            && !module.isStaticallyExportedOrOpen(pn, other, open))
+        {
             String msg = other + " allowed to invoke setAccessible on ";
             if (this instanceof Field)
                 msg += "field ";
             msg += this;
-            new WARNING(msg).printStackTrace(System.err);
+            new Exception(msg) {
+                private static final long serialVersionUID = 42L;
+                public String toString() {
+                    return "WARNING: " + getMessage();
+                }
+            }.printStackTrace(System.err);
         }
     }