Common bootstrap
Attila Szegedi
szegedia at gmail.com
Wed Aug 25 00:17:57 PDT 2010
Well, it might have to do with the security. Bootstrap method implementations will likely use MethodHandles.* methods -- unreflect(), findVirtual() etc. The access checks are performed at the point of invocation of these discovery methods, resolved against the caller of these methods. A "rogue" subclass could inherit its bootstrap from a trusted class and link to and invoke methods it would otherwise not have access to. (For purpose of access checks, the caller would still be the superclass, since the bootstrap methods are static.)
That's what I think; John Rose might clarify :-)
Attila.
On 2010.08.24., at 22:15, Jim Laskey wrote:
> Likely some subtlety I'm missing here.
>
> I meant inherited in the general sense. Maybe hierarchically blest is a better term. That is, that during initialization, a subclass copies the bootstrap MH from it's parent class (no instances involved.) The subclass can still override the bootstrap with a static initializer. The point is to simplify the launch effort/size/performance in each of the subclasses.
>
> So instead of
>
> class LangBaseClass {
> public static CallSite bootstrap(Class caller, String name, MethodType type) {
> ...
> return callSite;
> }
>
> static {
> java.dyn.Linkage.registerBootstrapMethod(LangBaseClass.class, "bootstrap");
> }
> }
>
> class LangSubClass1 extends LangBaseClass {
> static {
> java.dyn.Linkage.registerBootstrapMethod(LangBaseClass.class, "bootstrap");
> }
>
> ...
>
> InvokeDynamic.foo();
>
> }
>
> class LangSubclass2 extends LangBaseClass {
> static {
> java.dyn.Linkage.registerBootstrapMethod(LangBaseClass.class, "bootstrap");
> }
>
> ...
>
> InvokeDynamic.bar();
>
> }
>
> ...
>
> We have;
>
>
> class LangBaseClass {
> public static CallSite bootstrap(Class caller, String name, MethodType type) {
> ...
> return callSite;
> }
>
> static {
> java.dyn.Linkage.registerBootstrapMethod(LangBaseClass.class, "bootstrap");
> }
> }
>
> class LangSubClass1 extends LangBaseClass {
>
> ...
>
> InvokeDynamic.foo();
>
> }
>
> class LangSubclass2 extends LangBaseClass {
>
> ...
>
> InvokeDynamic.bar();
>
> }
>
> ...
>
>> Date: Tue, 24 Aug 2010 16:01:00 +0200
>> From: R?mi Forax <forax at univ-mlv.fr>
>> Subject: Re: Common bootstrap
>> To: mlvm-dev at openjdk.java.net
>> Message-ID: <4C73D09C.60404 at univ-mlv.fr>
>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>>
>> Le 24/08/2010 15:36, Jim Laskey a ?crit :
>>> Excuse me for being late in the game but I have a na?ve question.
>>>
>>> Why not have the bootstrap method be inherited? Isn't it likely that a j-lang would have a base class and that often a common bootstrap might be used? (I'm assuming it's an implementation/security issue, but asking anyway.)
>>>
>>> Cheers,
>>>
>>> -- Jim
>>>
>>
>> Before bootstrapping you have nothing :)
>> so you have no object to do a virtual call.
>>
>> Attila Szegedi has an interesting answers on how to share/reuse some
>> infrastructure on top of invokedynamic:
>> http://wiki.jvmlangsummit.com/images/7/73/Metaobject_Protocol_Meets_Invokedynamic.pdf
>>
>> R?mi
Attila.
--
home: http://www.szegedi.org
twitter: http://twitter.com/szegedi
weblog: http://constc.blogspot.com
More information about the mlvm-dev
mailing list