Package io.micronaut.test.typepollution
Class HookBootstrap
java.lang.Object
io.micronaut.test.typepollution.HookBootstrap
Method handle bootstrap used by generated code to call into the
ConcreteCounter
. Must be
public for generated code, but should never be used directly.-
Method Summary
Modifier and TypeMethodDescriptionstatic CallSite
dynamicTypeCheck
(MethodHandles.Lookup lookup, String name, MethodType type) Called on successful type check in scenarios where the interface type is not statically known, i.e.static CallSite
dynamicTypeCheckCast
(MethodHandles.Lookup lookup, String name, MethodType type) Called on successful type check forClass.cast(Object)
.static CallSite
reflectionConstructorCall
(MethodHandles.Lookup lookup, String name, MethodType type) Called before any call toConstructor.newInstance(Object...)
.static CallSite
reflectionFieldSet
(MethodHandles.Lookup lookup, String name, MethodType type) Called before any call toField.set(Object, Object)
.static CallSite
reflectionMethodCall
(MethodHandles.Lookup lookup, String name, MethodType type) Called before any call toMethod.invoke(Object, Object...)
.static CallSite
staticTypeCheck
(MethodHandles.Lookup lookup, String name, MethodType type, Class<?> interfaceType) Called on successful type check in scenarios where the interface type is statically known, i.e.
-
Method Details
-
staticTypeCheck
public static CallSite staticTypeCheck(MethodHandles.Lookup lookup, String name, MethodType type, Class<?> interfaceType) throws NoSuchMethodException, IllegalAccessException Called on successful type check in scenarios where the interface type is statically known, i.e. checkcast and instanceof instructions. Returned method type is(Ljava/lang/Object;)V
, where the sole parameter is the object that was type checked.- Parameters:
lookup
- Required bootstrap method parametername
- Required bootstrap method parametertype
- Required bootstrap method parameterinterfaceType
- The statically known interface type- Returns:
(Ljava/lang/Object;)V
- Throws:
NoSuchMethodException
IllegalAccessException
-
dynamicTypeCheck
public static CallSite dynamicTypeCheck(MethodHandles.Lookup lookup, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException Called on successful type check in scenarios where the interface type is not statically known, i.e.Class.isAssignableFrom(Class)
andClass.isInstance(Object)
calls. Returned method type is(Ljava/lang/Class;Ljava/lang/Class;)V
, where the first parameter is the interface type and the second parameter is the concrete type.- Parameters:
lookup
- Required bootstrap method parametername
- Required bootstrap method parametertype
- Required bootstrap method parameter- Returns:
(Ljava/lang/Class;Ljava/lang/Class;)V
- Throws:
NoSuchMethodException
IllegalAccessException
-
dynamicTypeCheckCast
public static CallSite dynamicTypeCheckCast(MethodHandles.Lookup lookup, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException Called on successful type check forClass.cast(Object)
. This is a slightly modifieddynamicTypeCheck(java.lang.invoke.MethodHandles.Lookup, java.lang.String, java.lang.invoke.MethodType)
to make the cast implementation work without local variables. Returned method type is(Ljava/lang/Class;Ljava/lang/Object;)Ljava/lang/Object;
, where the first parameter is the interface type and the second parameter is the concrete value that was cast. The return value is the second parameter.- Parameters:
lookup
- Required bootstrap method parametername
- Required bootstrap method parametertype
- Required bootstrap method parameter- Returns:
(Ljava/lang/Class;Ljava/lang/Object;)Ljava/lang/Object;
- Throws:
NoSuchMethodException
IllegalAccessException
-
reflectionMethodCall
public static CallSite reflectionMethodCall(MethodHandles.Lookup lookup, String name, MethodType type) Called before any call toMethod.invoke(Object, Object...)
. Returned method type is(Ljava/lang/reflect/Method;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/reflect/Method;
, where the first parameter is the method, the second parameter thethis
argument, and the third parameter the argument array. The returned type is the same method passed in.- Parameters:
lookup
- Required bootstrap method parametername
- Required bootstrap method parametertype
- Required bootstrap method parameter- Returns:
(Ljava/lang/reflect/Method;Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/reflect/Method;
-
reflectionConstructorCall
public static CallSite reflectionConstructorCall(MethodHandles.Lookup lookup, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException Called before any call toConstructor.newInstance(Object...)
. Returned method type is(Ljava/lang/reflect/Constructor;[Ljava/lang/Object;)V
, where the first parameter is the constructor and the second parameter the argument array.- Parameters:
lookup
- Required bootstrap method parametername
- Required bootstrap method parametertype
- Required bootstrap method parameter- Returns:
(Ljava/lang/reflect/Constructor;[Ljava/lang/Object;)V
- Throws:
NoSuchMethodException
IllegalAccessException
-
reflectionFieldSet
public static CallSite reflectionFieldSet(MethodHandles.Lookup lookup, String name, MethodType type) throws NoSuchMethodException, IllegalAccessException Called before any call toField.set(Object, Object)
. Returned method type is(Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/reflect/Field;
, where the first parameter is the field, the second the object that the field is set on, and the third parameter the field value. The return value is the same field that was passed in.- Parameters:
lookup
- Required bootstrap method parametername
- Required bootstrap method parametertype
- Required bootstrap method parameter- Returns:
(Ljava/lang/reflect/Field;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/reflect/Field;
- Throws:
NoSuchMethodException
IllegalAccessException
-