Author: ron.sigal(a)jboss.com
Date: 2009-04-14 06:33:39 -0400 (Tue, 14 Apr 2009)
New Revision: 5030
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java
Log:
JBREM-1116: Eliminated dependence on SecurityUtility.
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java
===================================================================
---
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java 2009-04-14
10:31:53 UTC (rev 5029)
+++
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java 2009-04-14
10:33:39 UTC (rev 5030)
@@ -24,6 +24,9 @@
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.InetAddress;
+import java.security.AccessController;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
@@ -94,7 +97,7 @@
try
{
- SecurityUtility.getDeclaredMethod(Timer.class, "purge", new
Class[]{});
+ getDeclaredMethod(Timer.class, "purge", new Class[]{});
purgeMethodAvailable = true;
}
catch (Exception e)
@@ -340,4 +343,32 @@
log.info("received callback");
}
}
+
+ static private Method getDeclaredMethod(final Class c, final String name, final
Class[] parameterTypes)
+ throws NoSuchMethodException
+ {
+ if (SecurityUtility.skipAccessControl())
+ {
+ Method m = c.getDeclaredMethod(name, parameterTypes);
+ m.setAccessible(true);
+ return m;
+ }
+
+ try
+ {
+ return (Method) AccessController.doPrivileged( new PrivilegedExceptionAction()
+ {
+ public Object run() throws NoSuchMethodException
+ {
+ Method m = c.getDeclaredMethod(name, parameterTypes);
+ m.setAccessible(true);
+ return m;
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (NoSuchMethodException) e.getCause();
+ }
+ }
}
\ No newline at end of file
Show replies by date