8157877: Clean up StackWalker permission checks
authormchung
Wed, 25 May 2016 14:05:51 -0700
changeset 38569 0321fb06a8c5
parent 38568 f992c34c85b3
child 38570 97bcc3a1be3f
8157877: Clean up StackWalker permission checks Reviewed-by: lancea, ahgross
jdk/src/java.base/share/classes/java/lang/StackWalker.java
--- a/jdk/src/java.base/share/classes/java/lang/StackWalker.java	Wed May 25 13:53:03 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/StackWalker.java	Wed May 25 14:05:51 2016 -0700
@@ -306,8 +306,9 @@
             return DEFAULT_WALKER;
         }
 
-        checkPermission(options);
-        return new StackWalker(toEnumSet(options));
+        EnumSet<Option> optionSet = toEnumSet(options);
+        checkPermission(optionSet);
+        return new StackWalker(optionSet);
     }
 
     /**
@@ -341,8 +342,9 @@
         if (estimateDepth <= 0) {
             throw new IllegalArgumentException("estimateDepth must be > 0");
         }
-        checkPermission(options);
-        return new StackWalker(toEnumSet(options), estimateDepth);
+        EnumSet<Option> optionSet = toEnumSet(options);
+        checkPermission(optionSet);
+        return new StackWalker(optionSet, estimateDepth);
     }
 
     // ----- private constructors ------
@@ -540,13 +542,11 @@
     }
 
     // ---- package access ----
-    static StackWalker newInstanceNoCheck(EnumSet<Option> options) {
-        return new StackWalker(options, 0, null);
-    }
 
     static StackWalker newInstance(Set<Option> options, ExtendedOption extendedOption) {
-        checkPermission(options);
-        return new StackWalker(toEnumSet(options), 0, extendedOption);
+        EnumSet<Option> optionSet = toEnumSet(options);
+        checkPermission(optionSet);
+        return new StackWalker(optionSet, 0, extendedOption);
     }
 
     int estimateDepth() {