File tree Expand file tree Collapse file tree
byte-buddy-dep/src/test/java/net/bytebuddy/asm Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -978,6 +978,24 @@ public void testSubstitutionChainMethodInvocation() throws Exception {
978978 assertThat (type .getDeclaredField (BAR ).get (instance ), is ((Object ) BAZ ));
979979 }
980980
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+
981999 @ Test
9821000 public void testSubstitutionChainStaticMethodInvocation () throws Exception {
9831001 Class <?> type = new ByteBuddy ()
You can’t perform that action at this time.
0 commit comments