@Test @JavaVersionRule.Enforce(7) public void testBootstrapMethod() throws Exception { for (Method method : Class.forName(BOOTSTRAP_CLASS).getDeclaredMethods()) { if (!method.getName().equals("bootstrap")) { continue; } DynamicType.Loaded<Simple> dynamicType = new ByteBuddy() .subclass(Simple.class) .method(isDeclaredBy(Simple.class)) .intercept(InvokeDynamic.bootstrap(method).withoutArguments()) .make() .load(getClass().getClassLoader(), ClassLoadingStrategy.Default.WRAPPER); assertThat(dynamicType.getLoaded().getDeclaredConstructor().newInstance().foo(), is(FOO)); } }
public static WithImplicitTarget bootstrap(Method method, Object... constant) { return bootstrap(new MethodDescription.ForLoadedMethod(method), constant); }
InvokeDynamic implements Implementation.Composable { public static WithImplicitTarget bootstrap(Method method, Object... constant) { return bootstrap(new MethodDescription.ForLoadedMethod(method), constant); } }
InvokeDynamic implements Implementation.Composable { public static WithImplicitTarget bootstrap(Method method, Object... constant) { return bootstrap(new MethodDescription.ForLoadedMethod(method), constant); } protected  InvokeDynamic(MethodDescription.InDefinedShape bootstrap,
                            List<?> arguments,
                            InvocationProvider invocationProvider,
                            TerminationHandler terminationHandler,
                            Assigner assigner,
                            Assigner.Typing typing); }
InvokeDynamic implements Implementation.Composable { public static WithImplicitTarget bootstrap(Method method, Object... constant) { return bootstrap(new MethodDescription.ForLoadedMethod(method), constant); } protected  InvokeDynamic(MethodDescription.InDefinedShape bootstrap,
                            List<?> arguments,
                            InvocationProvider invocationProvider,
                            TerminationHandler terminationHandler,
                            Assigner assigner,
                            Assigner.Typing typing); static WithImplicitTarget bootstrap(Method method, Object... constant); static WithImplicitTarget bootstrap(Method method, List<?> constants); static WithImplicitTarget bootstrap(Constructor<?> constructor, Object... constant); static WithImplicitTarget bootstrap(Constructor<?> constructor, List<?> constants); static WithImplicitTarget bootstrap(MethodDescription.InDefinedShape bootstrap, Object... constant); static WithImplicitTarget bootstrap(MethodDescription.InDefinedShape bootstrap, List<?> constants); static WithImplicitArguments lambda(Method method, Class<?> functionalInterface); static WithImplicitArguments lambda(Method method, Class<?> functionalInterface, MethodGraph.Compiler methodGraphCompiler); static WithImplicitArguments lambda(MethodDescription.InDefinedShape methodDescription, TypeDescription functionalInterface); static WithImplicitArguments lambda(MethodDescription.InDefinedShape methodDescription,
                                               TypeDescription functionalInterface,
                                               MethodGraph.Compiler methodGraphCompiler); InvokeDynamic withBooleanValue(boolean... value); InvokeDynamic withByteValue(byte... value); InvokeDynamic withShortValue(short... value); InvokeDynamic withCharacterValue(char... value); InvokeDynamic withIntegerValue(int... value); InvokeDynamic withLongValue(long... value); InvokeDynamic withFloatValue(float... value); InvokeDynamic withDoubleValue(double... value); InvokeDynamic withValue(Object... value); WithImplicitType withReference(Object value); InvokeDynamic withReference(Object... value); InvokeDynamic withType(TypeDescription... typeDescription); InvokeDynamic withEnumeration(EnumerationDescription... enumerationDescription); InvokeDynamic withInstance(JavaConstant... javaConstant); InvokeDynamic withNullValue(Class<?>... type); InvokeDynamic withNullValue(TypeDescription... typeDescription); InvokeDynamic withArgument(int... index); WithImplicitType withArgument(int index); InvokeDynamic withThis(Class<?>... type); InvokeDynamic withThis(TypeDescription... typeDescription); InvokeDynamic withMethodArguments(); InvokeDynamic withImplicitAndMethodArguments(); InvokeDynamic withField(String... name); InvokeDynamic withField(FieldLocator.Factory fieldLocatorFactory, String... name); WithImplicitType withField(String name); WithImplicitType withField(String name, FieldLocator.Factory fieldLocatorFactory); Implementation.Composable withAssigner(Assigner assigner, Assigner.Typing typing); Implementation andThen(Implementation implementation); Composable andThen(Composable implementation); InstrumentedType prepare(InstrumentedType instrumentedType); ByteCodeAppender appender(Target implementationTarget); }
InvokeDynamic implements Implementation.Composable { public static WithImplicitTarget bootstrap(Method method, Object... constant) { return bootstrap(new MethodDescription.ForLoadedMethod(method), constant); } protected  InvokeDynamic(MethodDescription.InDefinedShape bootstrap,
                            List<?> arguments,
                            InvocationProvider invocationProvider,
                            TerminationHandler terminationHandler,
                            Assigner assigner,
                            Assigner.Typing typing); static WithImplicitTarget bootstrap(Method method, Object... constant); static WithImplicitTarget bootstrap(Method method, List<?> constants); static WithImplicitTarget bootstrap(Constructor<?> constructor, Object... constant); static WithImplicitTarget bootstrap(Constructor<?> constructor, List<?> constants); static WithImplicitTarget bootstrap(MethodDescription.InDefinedShape bootstrap, Object... constant); static WithImplicitTarget bootstrap(MethodDescription.InDefinedShape bootstrap, List<?> constants); static WithImplicitArguments lambda(Method method, Class<?> functionalInterface); static WithImplicitArguments lambda(Method method, Class<?> functionalInterface, MethodGraph.Compiler methodGraphCompiler); static WithImplicitArguments lambda(MethodDescription.InDefinedShape methodDescription, TypeDescription functionalInterface); static WithImplicitArguments lambda(MethodDescription.InDefinedShape methodDescription,
                                               TypeDescription functionalInterface,
                                               MethodGraph.Compiler methodGraphCompiler); InvokeDynamic withBooleanValue(boolean... value); InvokeDynamic withByteValue(byte... value); InvokeDynamic withShortValue(short... value); InvokeDynamic withCharacterValue(char... value); InvokeDynamic withIntegerValue(int... value); InvokeDynamic withLongValue(long... value); InvokeDynamic withFloatValue(float... value); InvokeDynamic withDoubleValue(double... value); InvokeDynamic withValue(Object... value); WithImplicitType withReference(Object value); InvokeDynamic withReference(Object... value); InvokeDynamic withType(TypeDescription... typeDescription); InvokeDynamic withEnumeration(EnumerationDescription... enumerationDescription); InvokeDynamic withInstance(JavaConstant... javaConstant); InvokeDynamic withNullValue(Class<?>... type); InvokeDynamic withNullValue(TypeDescription... typeDescription); InvokeDynamic withArgument(int... index); WithImplicitType withArgument(int index); InvokeDynamic withThis(Class<?>... type); InvokeDynamic withThis(TypeDescription... typeDescription); InvokeDynamic withMethodArguments(); InvokeDynamic withImplicitAndMethodArguments(); InvokeDynamic withField(String... name); InvokeDynamic withField(FieldLocator.Factory fieldLocatorFactory, String... name); WithImplicitType withField(String name); WithImplicitType withField(String name, FieldLocator.Factory fieldLocatorFactory); Implementation.Composable withAssigner(Assigner assigner, Assigner.Typing typing); Implementation andThen(Implementation implementation); Composable andThen(Composable implementation); InstrumentedType prepare(InstrumentedType instrumentedType); ByteCodeAppender appender(Target implementationTarget);  }