diff options
author | nickl- <github@jigsoft.co.za> | 2017-10-27 06:50:16 +0200 |
---|---|---|
committer | nickl- <github@jigsoft.co.za> | 2017-11-12 23:49:21 +0200 |
commit | f52402c2410158bdf0ab53b3852d075fa5320565 (patch) | |
tree | a0737d8b511bb3a6af419002c764a3183740faae /src/main/javassist/util | |
parent | 31b7faa0bc15d62d5c390096a02cebed344a620d (diff) | |
download | javassist-f52402c2410158bdf0ab53b3852d075fa5320565.tar.gz javassist-f52402c2410158bdf0ab53b3852d075fa5320565.zip |
Type check and paramatized rawtypes for SecurityActions.
Some whitespace got shunted around a bit too.
Diffstat (limited to 'src/main/javassist/util')
-rwxr-xr-x | src/main/javassist/util/proxy/SecurityActions.java | 79 |
1 files changed, 41 insertions, 38 deletions
diff --git a/src/main/javassist/util/proxy/SecurityActions.java b/src/main/javassist/util/proxy/SecurityActions.java index 272ccfec..ca0de912 100755 --- a/src/main/javassist/util/proxy/SecurityActions.java +++ b/src/main/javassist/util/proxy/SecurityActions.java @@ -27,29 +27,31 @@ import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; class SecurityActions { - static Method[] getDeclaredMethods(final Class clazz) { + 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(); - } - }); + return AccessController.doPrivileged( + new PrivilegedAction<Method[]>() { + public Method[] run() { + return clazz.getDeclaredMethods(); + } + }); } } - static Constructor[] getDeclaredConstructors(final Class clazz) { + 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(); - } - }); + return AccessController.doPrivileged( + new PrivilegedAction<Constructor<?>[]>() { + public Constructor<?>[] run() { + return clazz.getDeclaredConstructors(); + } + }); } } @@ -83,12 +85,12 @@ class SecurityActions { return clazz.getDeclaredMethod(name, types); else { try { - return (Method) AccessController - .doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws Exception { - return clazz.getDeclaredMethod(name, types); - } - }); + return AccessController.doPrivileged( + new PrivilegedExceptionAction<Method>() { + public Method run() throws Exception { + return clazz.getDeclaredMethod(name, types); + } + }); } catch (PrivilegedActionException e) { if (e.getCause() instanceof NoSuchMethodException) @@ -99,20 +101,20 @@ class SecurityActions { } } - static Constructor getDeclaredConstructor(final Class clazz, - final Class[] types) + 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() { - public Object run() throws Exception { - return clazz.getDeclaredConstructor(types); - } - }); + return AccessController.doPrivileged( + new PrivilegedExceptionAction<Constructor<?>>() { + public Constructor<?> run() throws Exception { + return clazz.getDeclaredConstructor(types); + } + }); } catch (PrivilegedActionException e) { if (e.getCause() instanceof NoSuchMethodException) @@ -124,12 +126,13 @@ class SecurityActions { } static void setAccessible(final AccessibleObject ao, - final boolean accessible) { + final boolean accessible) + { if (System.getSecurityManager() == null) ao.setAccessible(accessible); else { - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction<Void>() { + public Void run() { ao.setAccessible(accessible); return null; } @@ -144,17 +147,17 @@ class SecurityActions { fld.set(target, value); else { try { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws Exception { - fld.set(target, value); - return null; - } - }); + AccessController.doPrivileged( + new PrivilegedExceptionAction<Void>() { + public Void 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()); } } |