On 03/04/2017 15:15, Russell Gold wrote:
Upon further testing, this turns out to be less capable than the
“Unsafe” version - in particular, I cannot create a test stub in a
closed package. The problem is that unit tests often need to do a
number of things like this that make no sense in a
yes :)
Remi
On March 8, 2017 9:41:13 PM GMT+01:00, John Rose wrote:
>On Mar 8, 2017, at 10:47 AM, Remi Forax wrote:
>>
>> The exception if the lookup is PRIVATE should be
>IllegalStateException and not UnuspportedOperationException.
>> then, given
On 14/03/2017 17:37, Russell Gold wrote:
Hi Alan,
I am trying this in SimpleStub, and it seems to work for my current
test cases if I do this:
MethodHandles.Lookup in = MethodHandles.privateLookupIn(baseClass,
MethodHandles.lookup() ).dropLookupMode( MethodHandles.Lookup.PRIVATE );
return
nd in the same runtime package
> as the Lookup's lookup class.
>
> An initial implementation of Lookup.defineClass is in the current Jigsaw EA
> builds [1], the javadoc is also online [2]. We are currently looking for help
> in trying out this method to see how it might be used
Hi Alan,
i've already updated the only code i had that was using ClassLoader.defineClass
after a Method.setAccessible() to use Unsafe.defineClass
(no way to remove it, i need to be able to inject code a la Mockito)
so Lookup.defineClass is a safe replacement of Unsafe.defineClass , i suppose