Hidden classes + class data
david.holmes at oracle.com
Sun Nov 24 23:17:36 UTC 2019
On 23/11/2019 7:03 am, forax at univ-mlv.fr wrote:
> ----- Mail original -----
>> De: "mandy chung" <mandy.chung at oracle.com>
>> À: "Remi Forax" <forax at univ-mlv.fr>
>> Cc: "valhalla-dev" <valhalla-dev at openjdk.java.net>
>> Envoyé: Vendredi 22 Novembre 2019 17:56:24
>> Objet: Re: Hidden classes + class data
>> On 11/22/19 6:57 AM, Remi Forax wrote:
>>> Hi Mandy,
>>> hi all
>>> I've played a little with the nestmates branch, trying to see how to
>>> re-implement the reflection API based on the method handle API.
>>> A question, correct me if i'm wrong but every hidden classes has its own
>>> bytecode array even when i call defineHiddenClassWithClassData several times
>>> with the same byte array ?
>> Yes it does. It clones the given byte array to avoid it might be
>> modified after any kind of validation. Lookup::defineClass does the
>> clone too. Perhaps we have to rethink about the security aspect vs the
>> overhead of cloning ?
> Apart what Brian said about Array 2.0, i've no real solution.
>>> Also, is it possible to have a Lookup.defineClass variation that takes a class
>>> data as parameter but do not create a hidden class, something like
>>> Class<?> defineClassWithClassData(byte bytes, Object classData, boolean
>>> It would be very convenient in order to generate a something like a lambda body
>>> (not the lambda adapter/proxy) where you want it to appear in th stacktrace
>>> because it's a code produced by a user.
>> Does this also need access to its nestmate?
> no, it's a plain java class that needs a classData object.
>> Our intent is to limit the dynamic nestmates to hidden classes as the current scope for this work.
>> Separate the extension of dynamic nestmates to ordinary classes in the future.
> again, correct me if i'm wrong, technically, it's not really dynamic nestmates, it's more nest host delegation ?
> The hidden class being able to delegate all the security checks to another class.
No it is dynamic nestmates. The hidden class declares the existing
nest-host as its nest-host (thereby dynamically injecting itself into
the nest) and there after will pass all nestmate access checks between
itself, the host and any other nest members.
More information about the valhalla-dev