mirror of
https://github.com/EsotericSoftware/reflectasm.git
synced 2025-03-15 11:50:21 +08:00
Update AccessClassLoader.java
Minor performance optimization (avoid call to SecurityManager.checkPermission() inside Method.setAccessible() if the Methos is already accesible)
This commit is contained in:
parent
cc419d9624
commit
395008a0b8
@ -1,4 +1,3 @@
|
||||
|
||||
package com.esotericsoftware.reflectasm;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
@ -49,7 +48,7 @@ class AccessClassLoader extends ClassLoader {
|
||||
// Attempt to load the access class in the same loader, which makes protected and default access members accessible.
|
||||
Method method = ClassLoader.class.getDeclaredMethod("defineClass", new Class[] {String.class, byte[].class, int.class,
|
||||
int.class, ProtectionDomain.class});
|
||||
method.setAccessible(true);
|
||||
if (!method.isAccessible()) method.setAccessible(true);
|
||||
return (Class)method.invoke(getParent(), new Object[] {name, bytes, Integer.valueOf(0), Integer.valueOf(bytes.length),
|
||||
getClass().getProtectionDomain()});
|
||||
} catch (Exception ignored) {
|
||||
|
Loading…
Reference in New Issue
Block a user