Looking for Sponsor: JDK-8229959 Convert proxy class to use constant dynamic

Mandy Chung mandy.chung at oracle.com
Fri Nov 22 23:15:56 UTC 2019



On 11/22/19 2:05 PM, Johannes Kuhn wrote:
> On 22.11.2019 22:41, Remi Forax wrote:
>> i wonder if some codes in the wild rely on that ?
> I don't think some code does, but you never know.
>> There is perhaps a better way, as part of the branch nestmates of 
>> valhalla, Mandy has added a way to transfer a live object to a Class 
>> when defining it, with that you can send all the Methods as an array 
>> and in the bootstrap method of a condy, access to the right method by 
>> extracting it from the array using an index.
>> It will avoid the whole serialization/deserialization of Methods dance.
>
> That is a better idea - and could be done today using 
> Unsafe.defineAnonymousClass - If it didn't need a host class.
>

The new API to define a hidden class [1] replaces all existing JDK use 
of Unsafe::defineAnonymousClass.

As for dynamic proxy class, it needs a mechanism to allow creating a 
hidden class in an empty package.  It's a separate RFE that I plan to 
follow up in the future.

>> Here is an example:
>> https://gist.github.com/forax/d0f0034190bc479b86ce977fb94ca176
>>
>> I believe those changes are planned for Java 14 so will be integrated 
>> very soon.

As RDP1 is approaching fast, I think it may catch the next train.
>
> It looks like the class is defined using 
> Lookup.defineHiddenClassWithClassData - in the current proxy 
> implementation there is no lookup object.
> Also, I'm not sure if the defined proxy class needs to be findable.

Proxy class should be a hidden class as it's not intended for other 
classes to symbolic reference it.

> In short: I did not do an evaluation on what unspecified parts of a 
> proxy can be changed without breaking someones cod

IMO I see JDK-8229959 requires a couple of prototypes to understand the 
pros and cons.   I can't put time on this RFE at this time due to other 
higher priority items.

Mandy
[1] https://bugs.openjdk.java.net/browse/JDK-8220607



More information about the core-libs-dev mailing list