<div dir="ltr">Awesome, thanks! <br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">pon., 15 maj 2023 o 16:40 Volker Simonis <<a href="mailto:volker.simonis@gmail.com">volker.simonis@gmail.com</a>> napisał(a):<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">If you really want to see the execution of every single bytecode, you<br>
can run in interpreted mode (`-Xint`) and use the<br>
`-XX:+TraceBytecodes` command line option. There's also<br>
`-XX:StopInterpreterAt=<int>`, but that's really only useful if<br>
running in a native debugger like gdb. Both these options are only<br>
available in debug builds (both fast- and slowdebug).<br>
<br>
For what you plan to do it's probably better to write a Java bytecode<br>
agent which allows you too hook into arbitrary Java methods [1]. There<br>
exists a lot of information about bytecode instrumentation on the net,<br>
but some of the tools you're definitely want to look at are ASM [2],<br>
ByteBuddy [3] and Byteman [4].<br>
<br>
Regards,<br>
Volker<br>
<br>
[1] <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/instrument/package-summary.html" rel="noreferrer" target="_blank">https://docs.oracle.com/javase/8/docs/api/java/lang/instrument/package-summary.html</a><br>
[2] <a href="https://asm.ow2.io/" rel="noreferrer" target="_blank">https://asm.ow2.io/</a><br>
[3] <a href="https://bytebuddy.net/#/" rel="noreferrer" target="_blank">https://bytebuddy.net/#/</a><br>
[4] <a href="https://byteman.jboss.org/" rel="noreferrer" target="_blank">https://byteman.jboss.org/</a><br>
<br>
On Mon, May 15, 2023 at 4:00 PM QwertyYtPL QwertyYtPL<br>
<<a href="mailto:qwertyytpl1612@gmail.com" target="_blank">qwertyytpl1612@gmail.com</a>> wrote:<br>
><br>
> I wanted to modify OpenJDK's source code just for myself to add little event that will be called just before one bytecode will be called, in this event i want to be able to check what bytecode it is and like all attributes (i guess that i need Node or something). I want to do that to have control over java application ran, for example if I'm running some virus written in java I will be able to stop everything at some specific instruction that for example causes some file to download or command to execute. It will be a gate for creating some security system that for example asks the user if he wants a java program to download something or run something (on runtime). I think that I will just do this event that will call functions in my dll or something, so I won't be coping with the jdk build system. I can even do lua scripting for that, so my dll will be able to read lua script and let it handle events. I'm asking it here because firstly I have problems with finding a place for hooking an event and secondly I want to ask if it even makes sense.<br>
</blockquote></div>