Re: How to modify instructions in BootstrapMethods using ASM?
David Dunkle <[email protected]> Thu, 30 Nov 2017 15:16:25 -0800
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <CAFhFTktAXGJ3+t4gTnv1VhmsdsMSWBbKqvk4=BJ-Y882qpB+hg@mail.gmail.com> |
It appears to work so far. -David On Thu, Nov 30, 2017 at 12:23 PM, <[email protected]> wrote: > > > ------------------------------ > > *De: *"David Dunkle" <[email protected]> > *À: *"Remi Forax" <[email protected]> > *Cc: *"asm" <[email protected]> > *Envoyé: *Jeudi 30 Novembre 2017 20:53:51 > *Objet: *Re: [asm] How to modify instructions in BootstrapMethods using > ASM? > > I got an interesting answer on stack overflow: > https://stackoverflow.com/questions/47561756/how-to- > modify-instructions-in-java-bootstrapmethods-using-asm > > Perhaps that answer is a more verbose statement of the same thing Remi has > been telling me? > > > yes, this mysterious Holger is better at explaining things than me :) > > > -David > > > Rémi > > > On Thu, Nov 30, 2017 at 7:09 AM, David Dunkle <[email protected]> > wrote: > >> I am doing that now, but I don’t see how changing the reference to the >> bootstrap method allows me to change the instructions of the existing >> bootstrap methods. >> >> Am I missing something? >> >> -David >> >> On Nov 29, 2017, at 11:09 PM, Remi Forax <[email protected]> wrote: >> >> Hi, >> those constants are referenced by some invokedynamic instructions in the >> bytecode. >> When you see an invokedynamic instruction with the MethodVisitor at that >> point, you can change the reference to the bootstrap method you want. >> >> cheers, >> Rémi >> >> >> >> On November 29, 2017 9:54:48 PM GMT+01:00, David Dunkle < >> [email protected]> wrote: >>> >>> After compiling with Java 8 and dumping the resulting class files with >>> javap, I see this, of which I am only showing the first 2 items: >>> >>> BootstrapMethods: >>> >>> 0: #174 invokestatic java/lang/invoke/LambdaMetafactory.metafactory: >>> (Ljava/lang/invoke/MethodHandles$Lookup;Ljava/ >>> lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/ >>> MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/ >>> invoke/MethodType;)Ljava/lang/invoke/CallSite; >>> >>> Method arguments: >>> >>> #175 (Ljava/lang/Object;)Z >>> >>> #179 invokestatic llllll/lallll.lambda$printPersons$0:(Lllllll/ >>> lallll;)Z >>> >>> #180 (Lllllll/lallll;)Z >>> >>> 1: #174 invokestatic java/lang/invoke/LambdaMetafactory.metafactory: >>> (Ljava/lang/invoke/MethodHandles$Lookup;Ljava/ >>> lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/ >>> MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/ >>> invoke/MethodType;)Ljava/lang/invoke/CallSite; >>> >>> Method arguments: >>> >>> #175 (Ljava/lang/Object;)Z >>> >>> #191 invokestatic llllll/lallll.lambda$printPersons$1:(Lllllll/ >>> lallll;)Z >>> >>> #180 (Lllllll/lallll;)Z >>> >>> 2: #174 invokestatic java/lang/invoke/LambdaMetafactory.metafactory: >>> (Ljava/lang/invoke/MethodHandles$Lookup;Ljava/ >>> lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/inv >>> >>> >>> Can I use ASM to visit the instructions in these bootstrap methods and >>> change, say, the names of the methods being called using invokestatic >>> instructions above? >>> >>> Apparently these methods are not part of the normal methods of a class, >>> and I haven't had any luck visiting them using standard ASM class and >>> method techniques. >>> >>> thanks, >>> >>> -David >>> >> >> -- >> Sent from my Android device with K-9 Mail. Please excuse my brevity. >> >> > -- You receive this message as a subscriber of the [email protected] mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws