< prev index next >

test/src/jdk/nashorn/test/models/Reflector.java

Print this page

        

@@ -40,10 +40,34 @@
  */
 public final class Reflector {
     private Reflector() {}
     private static final Module NASHORN_MOD = Context.class.getModule();
 
+    public static void setAccessible(Constructor c) {
+        if (c.getDeclaringClass().getModule() != NASHORN_MOD) {
+            throw new RuntimeException(c + " is not from Nashorn module");
+        }
+
+        c.setAccessible(true);
+    }
+
+    public static void setAccessible(Field f) {
+        if (f.getDeclaringClass().getModule() != NASHORN_MOD) {
+            throw new RuntimeException(f + " is not from Nashorn module");
+        }
+
+        f.setAccessible(true);
+    }
+
+    public static void setAccessible(Method m) {
+        if (m.getDeclaringClass().getModule() != NASHORN_MOD) {
+            throw new RuntimeException(m + " is not from Nashorn module");
+        }
+
+        m.setAccessible(true);
+    }
+
     public static Object invoke(final Method m, final Object self, final Object...args) {
         if (m.getDeclaringClass().getModule() != NASHORN_MOD) {
             throw new RuntimeException(m + " is not from Nashorn module");
         }
 
< prev index next >