File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
byte-buddy-dep/src/test/java/net/bytebuddy/asm Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -978,6 +978,24 @@ public void testSubstitutionChainMethodInvocation() throws Exception {
978
978
assertThat (type .getDeclaredField (BAR ).get (instance ), is ((Object ) BAZ ));
979
979
}
980
980
981
+ @ Test
982
+ public void testSubstitutionChainMethodInvocationWithArgument () throws Exception {
983
+ Class <?> type = new ByteBuddy ()
984
+ .redefine (StaticMethodInvokeSample .class )
985
+ .visit (MemberSubstitution .strict ().method (named (BAR )).replaceWithChain (
986
+ new MemberSubstitution .Substitution .Chain .Step .ForInvocation .Factory (
987
+ StaticMethodInvokeSample .class .getDeclaredMethod (BAZ , String .class ))).on (named (RUN )))
988
+ .make ()
989
+ .load (ClassLoadingStrategy .BOOTSTRAP_LOADER , ClassLoadingStrategy .Default .WRAPPER )
990
+ .getLoaded ();
991
+ Object instance = type .getDeclaredConstructor ().newInstance ();
992
+ assertThat (type .getDeclaredField (BAR ).get (instance ), is ((Object ) BAR ));
993
+ assertThat (type .getDeclaredField (BAZ ).get (instance ), is ((Object ) BAZ ));
994
+ assertThat (type .getDeclaredMethod (RUN ).invoke (instance ), nullValue (Object .class ));
995
+ assertThat (type .getDeclaredField (BAR ).get (instance ), is ((Object ) BAR ));
996
+ assertThat (type .getDeclaredField (BAZ ).get (instance ), is ((Object ) FOO ));
997
+ }
998
+
981
999
@ Test
982
1000
public void testSubstitutionChainStaticMethodInvocation () throws Exception {
983
1001
Class <?> type = new ByteBuddy ()
You can’t perform that action at this time.
0 commit comments