Class ReflectUtil
java.lang.Object
com.amazonaws.services.lambda.runtime.serialization.util.ReflectUtil
Class with reflection utilities
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic <C,R> Functions.R0 <R> bindInstanceR0(C instance, String name, boolean setAccessible, Class<? extends R> rType) load an instance method that takes no parameters and return type Rstatic <A1,C, R> Functions.R1 <R, A1> bindInstanceR1(C instance, String name, boolean setAccessible, Class<? extends R> rType, Class<? super A1> a1Type) load an instance method that takes 1 parameter and returns type Rstatic <A1,C> Functions.V1 <A1> bindInstanceV1(C instance, String name, boolean setAccessible, Class<? super A1> a1Type) * load an instance method that takes 1 parameter and returns nothingstatic <A1,A2, C> Functions.V2 <A1, A2> bindInstanceV2(C instance, String name, boolean setAccessible, Class<? super A1> a1Type, Class<? super A2> a2Type) load an instance method that takes 2 parameter and returns nothingstatic Class<?> copyClass(Class<?> clazz, ClassLoader cl) Copy a class from one class loader to another.static Class<?> getRawClass(Type type) static <T> TgetStaticField(Class<?> clazz, String name, Class<? extends T> type) static Class<?> loadClass(ClassLoader cl, String name) static <C> Functions.R0<C> loadConstructor0(Class<? extends C> clazz, boolean setAccessible) load default constructorstatic <A1,C> Functions.R1 <C, A1> loadConstructor1(Class<? extends C> clazz, boolean setAccessible, Class<? super A1> a1Type) load constructor that takes 1 parameterstatic <A1,A2, C> Functions.R2 <C, A1, A2> loadConstructor2(Class<? extends C> clazz, boolean setAccessible, Class<? super A1> a1Type, Class<? super A2> a2Type) load constructor that takes 2 parametersstatic <C,A1, A2, A3>
Functions.R3<C, A1, A2, A3> loadConstuctor3(Class<? extends C> clazz, boolean setAccessible, Class<? super A1> a1Type, Class<? super A2> a2Type, Class<? super A3> a3Type) load constuctor that takes 3 parametersstatic <C,A1, A2, A3, A4>
Functions.R4<C, A1, A2, A3, A4> loadConstuctor4(Class<? extends C> clazz, boolean setAccessible, Class<? super A1> a1Type, Class<? super A2> a2Type, Class<? super A3> a3Type, Class<? super A4> a4Type) loads constructor that takes 4 parametersstatic <C,A1, A2, A3, A4, A5>
Functions.R5<C, A1, A2, A3, A4, A5> loadConstuctor5(Class<? extends C> clazz, boolean setAccessible, Class<? super A1> a1Type, Class<? super A2> a2Type, Class<? super A3> a3Type, Class<? super A4> a4Type, Class<? super A5> a5Type) loads constructor that takes 5 paramtersstatic <C,A1, A2, A3, A4, A5, A6, A7, A8, A9>
Functions.R9<C, A1, A2, A3, A4, A5, A6, A7, A8, A9> loadConstuctor9(Class<? extends C> clazz, boolean setAccessible, Class<? super A1> a1Type, Class<? super A2> a2Type, Class<? super A3> a3Type, Class<? super A4> a4Type, Class<? super A5> a5Type, Class<? super A6> a6Type, Class<? super A7> a7Type, Class<? super A8> a8Type, Class<? super A9> a9type) load constuctor that takes 9 parametersstatic <C,R> Functions.R1 <R, C> loadInstanceR0(Class<? super C> clazz, String name, boolean setAccessible, Class<? extends R> rType) load instance method that takes no parameters and returns type Rstatic <A1,A2, A3, A4, C, R>
Functions.R5<R, C, A1, A2, A3, A4> loadInstanceR4(Class<? super C> clazz, String name, boolean setAccessible, Class<? extends R> rType, Class<? super A1> a1Type, Class<? super A2> a2Type, Class<? super A3> a3Type, Class<? super A4> a4Type) load instance method that takes 4 parameters and return type Rstatic <A1,C> Functions.V2 <C, A1> loadInstanceV1(Class<? super C> clazz, String name, boolean setAccessible, Class<? super A1> a1Type) load an instance method that take 1 parameter and does not return anythingstatic <R> Functions.R0<R> loadStaticR0(Class<?> clazz, String name, boolean setAccessible, Class<? extends R> rType) load static method that takes no parameters and returns type Rstatic <A1,R> Functions.R1 <R, A1> loadStaticR1(Class<?> clazz, String name, boolean setAccessible, Class<? extends R> rType, Class<? super A1> a1Type) load static method that takes one parameter and returns type Rstatic <A1,A2> Functions.V2 <A1, A2> loadStaticV2(Class<?> clazz, String name, boolean setAccessible, Class<? super A1> a1Type, Class<? super A2> a2Type) load static method that takes two parameters and return nothingstatic <T> Functions.R1<T, Object> makeCaster(Class<? extends T> clazz) static Functions.R1<Object, Object> makeCaster(Type type) static voidsetStaticField(Class<?> clazz, String name, boolean setAccessible, Object value)
-
Method Details
-
copyClass
Copy a class from one class loader to another. Was previously used in AwsJackson class to do some crazy passing of classes from class loader to class loader. When that class was removed due to excessive complexity, this method was retained for potential future use.- Parameters:
clazz- class to copycl- class loader to copy class to- Returns:
- Class inside new classloader
- Throws:
UncheckedIOException- if class cannot be copiedReflectUtil.ReflectException- if class cannot be read after copying
-
loadClass
-
getRawClass
-
makeCaster
-
makeCaster
-
loadInstanceR0
public static <C,R> Functions.R1<R,C> loadInstanceR0(Class<? super C> clazz, String name, boolean setAccessible, Class<? extends R> rType) load instance method that takes no parameters and returns type R- Type Parameters:
C- instance class typeR- return type- Parameters:
clazz- Class of instancename- name of methodsetAccessible- whether method is accessible (public vs private)rType- class of return type- Returns:
- function handle
-
loadInstanceR4
public static <A1,A2, Functions.R5<R,A3, A4, C, R> C, loadInstanceR4A1, A2, A3, A4> (Class<? super C> clazz, String name, boolean setAccessible, Class<? extends R> rType, Class<? super A1> a1Type, Class<? super A2> a2Type, Class<? super A3> a3Type, Class<? super A4> a4Type) load instance method that takes 4 parameters and return type R- Type Parameters:
A1- argument 1 typeA2- argument 2 typeA3- argument 3 typeA4- argument 4 typeC- instance class typeR- return type- Parameters:
clazz- class of instancename- name of methodsetAccessible- whether method is accessible (public vs private)rType- class of return typea1Type- argument 1 classa2Type- argument 2 classa3Type- argument 3 classa4Type- argument 4 class- Returns:
- function handle
-
loadInstanceV1
public static <A1,C> Functions.V2<C,A1> loadInstanceV1(Class<? super C> clazz, String name, boolean setAccessible, Class<? super A1> a1Type) load an instance method that take 1 parameter and does not return anything- Type Parameters:
A1- argument 1 typeC- instance class type- Parameters:
clazz- class of instancename- name of methodsetAccessible- whether method is accessible (public vs private)a1Type- argument 1 class- Returns:
- function handle
-
bindInstanceR0
public static <C,R> Functions.R0<R> bindInstanceR0(C instance, String name, boolean setAccessible, Class<? extends R> rType) load an instance method that takes no parameters and return type R- Type Parameters:
C- instance typeR- return type- Parameters:
instance- instance to load method fromname- method namesetAccessible- whether method is accessible (public vs private)rType- class of return type- Returns:
- function handle
-
bindInstanceR1
public static <A1,C, Functions.R1<R,R> A1> bindInstanceR1(C instance, String name, boolean setAccessible, Class<? extends R> rType, Class<? super A1> a1Type) load an instance method that takes 1 parameter and returns type R- Type Parameters:
A1- argument 1 typeC- instance typeR- return type- Parameters:
instance- instance to load method fromname- method namesetAccessible- whether method is accessible (public vs private)rType- class of return typea1Type- class of argument 1- Returns:
- function handle
-
bindInstanceV1
public static <A1,C> Functions.V1<A1> bindInstanceV1(C instance, String name, boolean setAccessible, Class<? super A1> a1Type) * load an instance method that takes 1 parameter and returns nothing- Type Parameters:
A1- argument 1 typeC- instance type- Parameters:
instance- instance to load method fromname- method namesetAccessible- whether method is accessible (public vs private)a1Type- class of argument 1- Returns:
- function handle
-
bindInstanceV2
public static <A1,A2, Functions.V2<A1,C> A2> bindInstanceV2(C instance, String name, boolean setAccessible, Class<? super A1> a1Type, Class<? super A2> a2Type) load an instance method that takes 2 parameter and returns nothing- Type Parameters:
A1- argument 1 typeA2- argument 2 typeC- instance type- Parameters:
instance- instance to load method fromname- method namesetAccessible- whether method is accessible (public vs private)a1Type- class of argument 1a2Type- class of argument 2- Returns:
- function handle
-
loadStaticR0
public static <R> Functions.R0<R> loadStaticR0(Class<?> clazz, String name, boolean setAccessible, Class<? extends R> rType) load static method that takes no parameters and returns type R- Type Parameters:
R- return type- Parameters:
clazz- class to load static method fromname- method namesetAccessible- whether method is accessible (public vs private)rType- class of return type- Returns:
- function handle
-
loadStaticR1
public static <A1,R> Functions.R1<R,A1> loadStaticR1(Class<?> clazz, String name, boolean setAccessible, Class<? extends R> rType, Class<? super A1> a1Type) load static method that takes one parameter and returns type R- Type Parameters:
A1- argument 1 typeR- return type- Parameters:
clazz- class to load static method fromname- method namesetAccessible- whether method is accessible (public vs private)rType- class of return typea1Type- argument 1 class- Returns:
- function handle
-
loadStaticV2
public static <A1,A2> Functions.V2<A1,A2> loadStaticV2(Class<?> clazz, String name, boolean setAccessible, Class<? super A1> a1Type, Class<? super A2> a2Type) load static method that takes two parameters and return nothing- Type Parameters:
A1- argument 1 typeA2- argument 2 type- Parameters:
clazz- class to load static method fromname- method namesetAccessible- whether method is accessible (public vs private)a1Type- argument 1 classa2Type- argument 2 class- Returns:
- function handle
-
loadConstructor0
load default constructor- Type Parameters:
C- Class type- Parameters:
clazz- Class to load constructor forsetAccessible- whether method is accessible (public vs private)- Returns:
- function handle
-
loadConstructor1
public static <A1,C> Functions.R1<C,A1> loadConstructor1(Class<? extends C> clazz, boolean setAccessible, Class<? super A1> a1Type) load constructor that takes 1 parameter- Type Parameters:
A1- argument 1 typeC- Class type- Parameters:
clazz- Class to load constructor forsetAccessible- whether method is accessible (public vs private)a1Type- argument 1 class- Returns:
- function handle
-
loadConstructor2
public static <A1,A2, Functions.R2<C,C> A1, loadConstructor2A2> (Class<? extends C> clazz, boolean setAccessible, Class<? super A1> a1Type, Class<? super A2> a2Type) load constructor that takes 2 parameters- Type Parameters:
A1- argument 1 typeA2- argument 2 typeC- Class type- Parameters:
clazz- Class to load constructor forsetAccessible- whether method is accessible (public vs private)a1Type- argument 1 classa2Type- argument 2 class- Returns:
- function handle
-
loadConstuctor3
public static <C,A1, Functions.R3<C,A2, A3> A1, loadConstuctor3A2, A3> (Class<? extends C> clazz, boolean setAccessible, Class<? super A1> a1Type, Class<? super A2> a2Type, Class<? super A3> a3Type) load constuctor that takes 3 parameters- Type Parameters:
C- Class typeA1- argument 1 typeA2- argument 2 typeA3- argument 3 type- Parameters:
clazz- class to load constructor forsetAccessible- whether method is accessible (public vs private)a1Type- argument 1 classa2Type- argument 2 classa3Type- argument 3 class- Returns:
- function handle
-
loadConstuctor4
public static <C,A1, Functions.R4<C,A2, A3, A4> A1, loadConstuctor4A2, A3, A4> (Class<? extends C> clazz, boolean setAccessible, Class<? super A1> a1Type, Class<? super A2> a2Type, Class<? super A3> a3Type, Class<? super A4> a4Type) loads constructor that takes 4 parameters- Type Parameters:
C- Class typeA1- argument 1 typeA2- argument 2 typeA3- argument 3 typeA4- argument 4 type- Parameters:
clazz- class to load constructor forsetAccessible- whether method is accessible (public vs private)a1Type- argument 1 classa2Type- argument 2 classa3Type- argument 3 classa4Type- argument 4 class- Returns:
- function handle
-
loadConstuctor5
public static <C,A1, Functions.R5<C,A2, A3, A4, A5> A1, loadConstuctor5A2, A3, A4, A5> (Class<? extends C> clazz, boolean setAccessible, Class<? super A1> a1Type, Class<? super A2> a2Type, Class<? super A3> a3Type, Class<? super A4> a4Type, Class<? super A5> a5Type) loads constructor that takes 5 paramters- Type Parameters:
C- Class typeA1- argument 1 typeA2- argument 2 typeA3- argument 3 typeA4- argument 4 typeA5- argument 5 type- Parameters:
clazz- class to load constructor forsetAccessible- whether method is accessible (public vs private)a1Type- argument 1 classa2Type- argument 2 classa3Type- argument 3 classa4Type- argument 4 classa5Type- argument 5 class- Returns:
- function handle
-
loadConstuctor9
public static <C,A1, Functions.R9<C,A2, A3, A4, A5, A6, A7, A8, A9> A1, loadConstuctor9A2, A3, A4, A5, A6, A7, A8, A9> (Class<? extends C> clazz, boolean setAccessible, Class<? super A1> a1Type, Class<? super A2> a2Type, Class<? super A3> a3Type, Class<? super A4> a4Type, Class<? super A5> a5Type, Class<? super A6> a6Type, Class<? super A7> a7Type, Class<? super A8> a8Type, Class<? super A9> a9type) load constuctor that takes 9 parameters- Type Parameters:
C- Class typeA1- argument 1 typeA2- argument 2 typeA3- argument 3 typeA4- argument 4 typeA5- argument 5 typeA6- argument 6 typeA7- argument 7 typeA8- argument 8 typeA9- argument 9 type- Parameters:
a1Type- argument 1 classa2Type- argument 2 classa3Type- argument 3 classa4Type- argument 4 classa5Type- argument 5 classa6Type- argument 6 classa7Type- argument 7 classa8Type- argument 8 classa9type- argument 9 class- Returns:
- function handle
-
getStaticField
-
setStaticField
-