1 35 package org.codehaus.groovy.runtime; 36 37 import groovy.lang.MetaMethod; 38 39 import java.lang.reflect.Method ; 40 import java.security.AccessController ; 41 import java.security.PrivilegedAction ; 42 43 public class ReflectionMetaMethod extends MetaMethod { 44 private Method method; 45 boolean alreadySetAccessible; 46 47 public ReflectionMetaMethod(Method method) { 48 super(method); 49 this.method = method; 50 } 51 52 public Object invoke(Object object, Object [] arguments) throws Exception { 53 if ( !alreadySetAccessible ) { 54 AccessController.doPrivileged(new PrivilegedAction () { 55 public Object run() { 56 method.setAccessible(true); 57 return null; 58 } 59 }); 60 alreadySetAccessible = true; 61 } 62 63 67 return method.invoke(object, arguments); 68 } 69 } 70 | Popular Tags |