Re: How to modify instructions in BootstrapMethods using ASM?

Remi Forax <[email protected]> Thu, 30 Nov 2017 07:09:02 +0000
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <[email protected]>
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