Re: Experiences with Lookup.defineClass

2017-03-13 Thread Alan Bateman
On 11/03/2017 16:48, Rafael Winterhalter wrote: : For testing libraries like Mockito, I would however prefer to use a mechanism similar to Unsafe::defineClass. My prefered way would be to add a test-specific module to any JDK installation that needs to be enabled by some flag. It would be too b

Re: Experiences with Lookup.defineClass

2017-03-11 Thread John Rose
On Mar 11, 2017, at 9:55 AM, Michael Rasmussen wrote: > > What should the Lookup be based on though, since you don't have a Class yet? Lookups are designed to represent computations in the context of a pre-existing class. I guess a Lookup for this use case would have to be based on a pre-exist

Re: Experiences with Lookup.defineClass

2017-03-11 Thread Rafael Winterhalter
You are right, that is a problem. However, I do not think that the lookup would need to be based on the class as long as it has the same priviledges. In this case, the lookupClass method could return null or throw an unsupported operation exception if the class is yet unloaded. I do not think that

Re: Experiences with Lookup.defineClass

2017-03-11 Thread Michael Rasmussen
> For this to work, I do however think it is crucial to add a parameter to > the ClassFileTransformer::transform method where a lookup object should be > provided as an additional argument in order to allow defining additional > classes in the instrumented class's loader and module. What should th