Re: How to modify instructions in BootstrapMethods using ASM?
David Dunkle <[email protected]> Thu, 30 Nov 2017 11:53:51 -0800
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <CAFhFTkvs__5cz06HjU3ZQ8ZJ5XsnJc=hG2YXR7O164n+1Sjc0Q@mail.gmail.com> |
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? -David 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