diff options
author | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2008-03-09 13:07:12 +0000 |
---|---|---|
committer | chiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3> | 2008-03-09 13:07:12 +0000 |
commit | 18869e66d2b785411f35e409a8b43e233ead6831 (patch) | |
tree | da78a7382fe1a05e55c26af73f56d61a20401d7f /src/main/javassist/util/proxy | |
parent | 78b56629509b8275eade44ca552d3b959ecedde3 (diff) | |
download | javassist-18869e66d2b785411f35e409a8b43e233ead6831.tar.gz javassist-18869e66d2b785411f35e409a8b43e233ead6831.zip |
preparation for 3.7.1 release
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@421 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main/javassist/util/proxy')
-rwxr-xr-x | src/main/javassist/util/proxy/SecurityActions.java | 225 |
1 files changed, 98 insertions, 127 deletions
diff --git a/src/main/javassist/util/proxy/SecurityActions.java b/src/main/javassist/util/proxy/SecurityActions.java index e7784b89..40741e40 100755 --- a/src/main/javassist/util/proxy/SecurityActions.java +++ b/src/main/javassist/util/proxy/SecurityActions.java @@ -23,142 +23,113 @@ import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; -class SecurityActions -{ - static Method[] getDeclaredMethods(final Class clazz) - { - if (System.getSecurityManager() == null) - { - return clazz.getDeclaredMethods(); - } - else - { - return (Method[])AccessController.doPrivileged(new PrivilegedAction() { - - public Object run() - { - return clazz.getDeclaredMethods(); - }}); - } +class SecurityActions { + static Method[] getDeclaredMethods(final Class clazz) { + if (System.getSecurityManager() == null) + return clazz.getDeclaredMethods(); + else { + return (Method[]) AccessController + .doPrivileged(new PrivilegedAction() { + public Object run() { + return clazz.getDeclaredMethods(); + } + }); + } } - - static Constructor[] getDeclaredConstructors(final Class clazz) - { - if (System.getSecurityManager() == null) - { - return clazz.getDeclaredConstructors(); - } - else - { - return (Constructor[])AccessController.doPrivileged(new PrivilegedAction() { - public Object run() - { - return clazz.getDeclaredConstructors(); - }}); - } + static Constructor[] getDeclaredConstructors(final Class clazz) { + if (System.getSecurityManager() == null) + return clazz.getDeclaredConstructors(); + else { + return (Constructor[]) AccessController + .doPrivileged(new PrivilegedAction() { + public Object run() { + return clazz.getDeclaredConstructors(); + } + }); + } } - - static Method getDeclaredMethod(final Class clazz, final String name, final Class[] types) throws NoSuchMethodException - { - if (System.getSecurityManager() == null) - { - return clazz.getDeclaredMethod(name, types); - } - else - { - try - { - return (Method)AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run()throws Exception - { - return clazz.getDeclaredMethod(name, types); - }}); - } - catch(PrivilegedActionException e) - { - if (e.getCause() instanceof NoSuchMethodException) - { - throw (NoSuchMethodException)e.getCause(); - } - throw new RuntimeException(e.getCause()); - } - } + static Method getDeclaredMethod(final Class clazz, final String name, + final Class[] types) throws NoSuchMethodException { + if (System.getSecurityManager() == null) + return clazz.getDeclaredMethod(name, types); + else { + try { + return (Method) AccessController + .doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { + return clazz.getDeclaredMethod(name, types); + } + }); + } + catch (PrivilegedActionException e) { + if (e.getCause() instanceof NoSuchMethodException) + throw (NoSuchMethodException) e.getCause(); + + throw new RuntimeException(e.getCause()); + } + } } - - static Constructor getDeclaredConstructor(final Class clazz, final Class[] types) throws NoSuchMethodException + + static Constructor getDeclaredConstructor(final Class clazz, + final Class[] types) + throws NoSuchMethodException { - if (System.getSecurityManager() == null) - { - return clazz.getDeclaredConstructor(types); - } - else - { - try - { - return (Constructor)AccessController.doPrivileged(new PrivilegedExceptionAction() { + if (System.getSecurityManager() == null) + return clazz.getDeclaredConstructor(types); + else { + try { + return (Constructor) AccessController + .doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { + return clazz.getDeclaredConstructor(types); + } + }); + } + catch (PrivilegedActionException e) { + if (e.getCause() instanceof NoSuchMethodException) + throw (NoSuchMethodException) e.getCause(); - public Object run() throws Exception - { - return clazz.getDeclaredConstructor(types); - }}); - } - catch (PrivilegedActionException e) - { - if (e.getCause() instanceof NoSuchMethodException) - { - throw (NoSuchMethodException)e.getCause(); + throw new RuntimeException(e.getCause()); } - throw new RuntimeException(e.getCause()); - } - } - } - - static void setAccessible(final AccessibleObject ao, final boolean accessible) - { - if (System.getSecurityManager() == null) - { - ao.setAccessible(accessible); - } - else - { - AccessController.doPrivileged(new PrivilegedAction() { + } + } - public Object run() - { - ao.setAccessible(accessible); - return null; - }}); - } - } - - static void set(final Field fld, final Object target, final Object value) throws IllegalAccessException + static void setAccessible(final AccessibleObject ao, + final boolean accessible) { + if (System.getSecurityManager() == null) + ao.setAccessible(accessible); + else { + AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + ao.setAccessible(accessible); + return null; + } + }); + } + } + + static void set(final Field fld, final Object target, final Object value) + throws IllegalAccessException { - if (System.getSecurityManager() == null) - { - fld.set(target, value); - } - else - { - try - { - AccessController.doPrivileged(new PrivilegedExceptionAction() { + if (System.getSecurityManager() == null) + fld.set(target, value); + else { + try { + AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { + fld.set(target, value); + return null; + } + }); + } + catch (PrivilegedActionException e) { + if (e.getCause() instanceof NoSuchMethodException) + throw (IllegalAccessException) e.getCause(); - public Object run() throws Exception - { - fld.set(target, value); - return null; - }}); - } - catch (PrivilegedActionException e) - { - if (e.getCause() instanceof NoSuchMethodException) - { - throw (IllegalAccessException)e.getCause(); + throw new RuntimeException(e.getCause()); } - throw new RuntimeException(e.getCause()); - } - } - } -}
\ No newline at end of file + } + } +} |