Class ClassReflection
- java.lang.Object
-
- com.newrelic.agent.bridge.reflect.ClassReflection
-
public class ClassReflection extends java.lang.ObjectWhen we try to access methods through reflection in a JVM that uses aSecurityManager(when we're running in WebSphere, for example), we get access exceptions when calling the reflection apis from most of the agent code. This class is loaded on the bootstrap classloader and has permission to call these apis. Note that it still fails when trying to invokeMethod.setAccessible(boolean). Don't delete methods off of this class. While the IDE might not find direct callers, many methods are invoked through rewritten instructions in weaved classes.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.Objectget(java.lang.reflect.Field field, java.lang.Object instance)static java.lang.ClassLoadergetClassLoader(java.lang.Class<?> clazz)static java.lang.reflect.Constructor<?>[]getDeclaredConstructors(java.lang.Class<?> clazz)static java.lang.reflect.FieldgetDeclaredField(java.lang.Class<?> clazz, java.lang.String name)static java.lang.reflect.Field[]getDeclaredFields(java.lang.Class<?> clazz)static java.lang.reflect.MethodgetDeclaredMethod(java.lang.Class<?> clazz, java.lang.String name, java.lang.Class<?>... parameterTypes)static java.lang.reflect.Method[]getDeclaredMethods(java.lang.Class<?> clazz)static java.lang.reflect.Method[]getMethods(java.lang.Class<?> clazz)static java.lang.Class<?>loadClass(java.lang.ClassLoader classLoader, java.lang.String name)static voidsetAccessible(java.lang.reflect.Field field, boolean flag)static voidsetAccessible(java.lang.reflect.Method method, boolean flag)
-
-
-
Method Detail
-
getClassLoader
public static java.lang.ClassLoader getClassLoader(java.lang.Class<?> clazz)
-
loadClass
public static java.lang.Class<?> loadClass(java.lang.ClassLoader classLoader, java.lang.String name) throws java.lang.ClassNotFoundException- Throws:
java.lang.ClassNotFoundException
-
getDeclaredMethods
public static java.lang.reflect.Method[] getDeclaredMethods(java.lang.Class<?> clazz)
- See Also:
Class.getDeclaredMethods()
-
getDeclaredMethod
public static java.lang.reflect.Method getDeclaredMethod(java.lang.Class<?> clazz, java.lang.String name, java.lang.Class<?>... parameterTypes) throws java.lang.NoSuchMethodException, java.lang.SecurityException- Throws:
java.lang.NoSuchMethodExceptionjava.lang.SecurityException- See Also:
Class.getDeclaredMethod(String, Class...)
-
getMethods
public static java.lang.reflect.Method[] getMethods(java.lang.Class<?> clazz)
- See Also:
Class.getMethods()
-
getDeclaredConstructors
public static java.lang.reflect.Constructor<?>[] getDeclaredConstructors(java.lang.Class<?> clazz)
- See Also:
Class.getDeclaredConstructors()
-
getDeclaredFields
public static java.lang.reflect.Field[] getDeclaredFields(java.lang.Class<?> clazz)
- See Also:
Class.getDeclaredFields()
-
getDeclaredField
public static java.lang.reflect.Field getDeclaredField(java.lang.Class<?> clazz, java.lang.String name) throws java.lang.NoSuchFieldException, java.lang.SecurityException- Throws:
java.lang.NoSuchFieldExceptionjava.lang.SecurityException
-
get
public static java.lang.Object get(java.lang.reflect.Field field, java.lang.Object instance) throws java.lang.IllegalArgumentException, java.lang.IllegalAccessException- Throws:
java.lang.IllegalArgumentExceptionjava.lang.IllegalAccessException
-
setAccessible
public static void setAccessible(java.lang.reflect.Field field, boolean flag) throws java.lang.IllegalArgumentException, java.lang.IllegalAccessException- Throws:
java.lang.IllegalArgumentExceptionjava.lang.IllegalAccessException
-
setAccessible
public static void setAccessible(java.lang.reflect.Method method, boolean flag) throws java.lang.IllegalArgumentException, java.lang.IllegalAccessException- Throws:
java.lang.IllegalArgumentExceptionjava.lang.IllegalAccessException
-
-