Re: RFR: 8200559: Java agents doing instrumentation need a means to define auxiliary classes [v2]

2024-01-29 Thread Alexander Kriegisch
On Mon, 29 Jan 2024 14:31:10 GMT, Andrew Dinn wrote: > > Bytecode transformation should not be rocket science, but it progressively > > is developing in that direction. > > Hmm? Bytecode transformation of the JDK runtime implementation is a lot more > complicated than your comments seem to ack

Re: RFR: 8200559: Java agents doing instrumentation need a means to define auxiliary classes [v2]

2024-01-29 Thread Andrew Dinn
On Sat, 27 Jan 2024 05:11:28 GMT, Alexander Kriegisch wrote: > Bytecode transformation should not be rocket science, but it progressively is > developing in that direction. Hmm? Bytecode transformation of the JDK runtime implementation is a lot more complicated than your comments seem to ackno

Re: RFR: 8200559: Java agents doing instrumentation need a means to define auxiliary classes [v2]

2024-01-29 Thread Rafael Winterhalter
On Fri, 16 Apr 2021 20:30:15 GMT, Rafael Winterhalter wrote: >> To allow agents the definition of auxiliary classes, an API is needed to >> allow this. Currently, this is often achieved by using `sun.misc.Unsafe` or >> `jdk.internal.misc.Unsafe` ever since the `defineClass` method was removed

Re: RFR: 8200559: Java agents doing instrumentation need a means to define auxiliary classes [v2]

2024-01-29 Thread Andrew Dinn
On Sun, 28 Jan 2024 22:33:01 GMT, Rafael Winterhalter wrote: > What stops people from supplying a fake instance? Wouldn't you need to "test > run" the instance first? Not necessarily. When the generated API implementation relies on the capabilities of class `Instrumentation` -- such as openin

Re: RFR: 8200559: Java agents doing instrumentation need a means to define auxiliary classes [v2]

2024-01-29 Thread Alan Bateman
On Mon, 29 Jan 2024 14:09:40 GMT, Andrew Dinn wrote: > What stops people from supplying a fake instance? Wouldn't you need to "test > run" the instance first? In passing, Instrumentation was a candidate to be sealed at one point as the only implementations should be in the java.instrument modu

Re: RFR: 8200559: Java agents doing instrumentation need a means to define auxiliary classes [v2]

2024-01-28 Thread Rafael Winterhalter
On Thu, 25 Jan 2024 10:04:08 GMT, Andrew Dinn wrote: > pass a non-null Instrumentation instance i.e. to have agent capabilities. What stops people from supplying a fake instance? Wouldn't you need to "test run" the instance first? - PR Comment: https://git.openjdk.org/jdk/pull/354

Re: RFR: 8200559: Java agents doing instrumentation need a means to define auxiliary classes [v2]

2024-01-28 Thread Rafael Winterhalter
On Fri, 16 Apr 2021 20:30:15 GMT, Rafael Winterhalter wrote: >> To allow agents the definition of auxiliary classes, an API is needed to >> allow this. Currently, this is often achieved by using `sun.misc.Unsafe` or >> `jdk.internal.misc.Unsafe` ever since the `defineClass` method was removed

Re: RFR: 8200559: Java agents doing instrumentation need a means to define auxiliary classes [v2]

2024-01-26 Thread Alexander Kriegisch
On Fri, 26 Jan 2024 12:27:02 GMT, Andrew Dinn wrote: > Luckily, you and your customers are not obliged to use the JPMS They are obliged to deal with it, and so am I as a tool maintainer. Just look the the approaches mentioned here. They all are in the category which in German we would call "vo

Re: RFR: 8200559: Java agents doing instrumentation need a means to define auxiliary classes [v2]

2024-01-26 Thread Jorn Vernee
On Fri, 26 Jan 2024 09:12:53 GMT, Alan Bateman wrote: > The target class is transformed in such a way to call the auxiliary class, > which necessitates the the aux-class to be in the same classloader as the > target class. But because the aux-class is defined while the target class is > still

Re: RFR: 8200559: Java agents doing instrumentation need a means to define auxiliary classes [v2]

2024-01-26 Thread Andrew Dinn
On Fri, 26 Jan 2024 10:17:16 GMT, Alexander Kriegisch wrote: >>> @AlanBateman, the AspectJ weaving agent creates an auxiliary class to >>> implement an "around" advice for a method, i.e. a method execution is >>> intercepted and the user has options to do something before optionally >>> callin

Re: RFR: 8200559: Java agents doing instrumentation need a means to define auxiliary classes [v2]

2024-01-26 Thread Alexander Kriegisch
On Fri, 26 Jan 2024 09:12:53 GMT, Alan Bateman wrote: > load-time instrumentation that defines auxiliary classes in the same run-time > package is a reasonable addition Thanks for finding some common ground. I appreciate it. > The more general request for an "unrestricted defineClass" conflict

Re: RFR: 8200559: Java agents doing instrumentation need a means to define auxiliary classes [v2]

2024-01-26 Thread Alan Bateman
On Fri, 26 Jan 2024 08:27:41 GMT, Alan Bateman wrote: >>> BB currently opens the jdk.internal.misc.Unsafe class to a module on a >>> seperate class loader that is not reachable outside an agent, using >>> Instrumentation. >> >> @raphw, may I ask how? Is there any sample code that is not connec

Re: RFR: 8200559: Java agents doing instrumentation need a means to define auxiliary classes [v2]

2024-01-26 Thread Rafael Winterhalter
On Fri, 16 Apr 2021 20:30:15 GMT, Rafael Winterhalter wrote: >> To allow agents the definition of auxiliary classes, an API is needed to >> allow this. Currently, this is often achieved by using `sun.misc.Unsafe` or >> `jdk.internal.misc.Unsafe` ever since the `defineClass` method was removed

Re: RFR: 8200559: Java agents doing instrumentation need a means to define auxiliary classes [v2]

2024-01-26 Thread Alexander Kriegisch
On Fri, 26 Jan 2024 08:27:41 GMT, Alan Bateman wrote: >>> BB currently opens the jdk.internal.misc.Unsafe class to a module on a >>> seperate class loader that is not reachable outside an agent, using >>> Instrumentation. >> >> @raphw, may I ask how? Is there any sample code that is not connec

Re: RFR: 8200559: Java agents doing instrumentation need a means to define auxiliary classes [v2]

2024-01-26 Thread Alan Bateman
On Fri, 26 Jan 2024 08:01:59 GMT, Alexander Kriegisch wrote: > > BB currently opens the jdk.internal.misc.Unsafe class to a module on a > > seperate class loader that is not reachable outside an agent, using > > Instrumentation. > > @raphw, may I ask how? Is there any sample code that is not c

Re: RFR: 8200559: Java agents doing instrumentation need a means to define auxiliary classes [v2]

2024-01-26 Thread Alexander Kriegisch
On Thu, 25 Jan 2024 12:16:13 GMT, Rafael Winterhalter wrote: > BB currently opens the jdk.internal.misc.Unsafe class to a module on a > seperate class loader that is not reachable outside an agent, using > Instrumentation. @raphw, may I ask how? Is there any sample code that is not connected

Re: RFR: 8200559: Java agents doing instrumentation need a means to define auxiliary classes [v2]

2024-01-25 Thread Alexander Kriegisch
On Thu, 25 Jan 2024 13:33:10 GMT, Andrew Dinn wrote: >> Requiring such an API opens the module to anybody, though, punching a hole >> into the module boundary. >> >> BB currently opens the jdk.internal.misc.Unsafe class to a module on a >> seperate class loader that is not reachable outside an

Re: RFR: 8200559: Java agents doing instrumentation need a means to define auxiliary classes [v2]

2024-01-25 Thread Andrew Dinn
On Thu, 25 Jan 2024 12:16:13 GMT, Rafael Winterhalter wrote: > Requiring such an API opens the module to anybody, though, punching a hole > into the module boundary. How so? Any module created to print Lookups can easily rely on a shared secret to secure the API. Byteman employs a non-null In

Re: RFR: 8200559: Java agents doing instrumentation need a means to define auxiliary classes [v2]

2024-01-25 Thread Rafael Winterhalter
On Fri, 16 Apr 2021 20:30:15 GMT, Rafael Winterhalter wrote: >> To allow agents the definition of auxiliary classes, an API is needed to >> allow this. Currently, this is often achieved by using `sun.misc.Unsafe` or >> `jdk.internal.misc.Unsafe` ever since the `defineClass` method was removed

Re: RFR: 8200559: Java agents doing instrumentation need a means to define auxiliary classes [v2]

2024-01-25 Thread Andrew Dinn
On Thu, 25 Jan 2024 06:39:56 GMT, Alexander Kriegisch wrote: >> Setting '-javaagent' is mainly an operations problem. Many build tools do >> not allow to declare a test dependency this way as the life cycles are not >> laid out for it, the internal repository location might be machine >> dependen

Re: RFR: 8200559: Java agents doing instrumentation need a means to define auxiliary classes [v2]

2024-01-24 Thread Alexander Kriegisch
On Thu, 22 Apr 2021 21:50:45 GMT, Rafael Winterhalter wrote: >> Rafael Winterhalter has refreshed the contents of this pull request, and >> previous commits have been removed. Incremental views are not available. The >> pull request now contains one commit: >> >> 8200559: Java agents doing