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
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
-