Classfile representation of specializable classes

David Chase at
Fri Jul 11 18:50:31 UTC 2014

On 2014-07-11, at 1:21 PM, Dan Smith <daniel.smith at> wrote:

> Maybe what you're after with classdynamic is (primarily) a ClassLoader feature rather than a VM feature?  That is, maybe 'defineClass' should be parameterized by a pluggable class-generation system, and that's where the expansion should take place, intercepting the bytes and spitting out the special class.  It's not totally clear to me how this would work, but I think it may be the right place for it.  (I have consistently felt like what we really want with classdynamic is ClassLoaders 2.0.)

We played this game in the Fortress implementation, borrowing design from NextGen
( )

85% of it is straightforward.  One tricky bit was the need to know whether the thing being
substituted for a T was a class or an interface (invokeinterface vs invokevirtual),
especially when that thing was itself the result of an instantiation.

(Reified) generic methods were tricky.  We could use invokedynamic to put lipstick on that
pig, but under the lipstick is still a pig.  I do not recall the precise mechanism that we used,
but I think it involved tables indexed by (secure?) hashcodes of instantiation signatures, returning
"closure" (Fortress-speak) objects.  There's some trickiness involved in getting the type
signatures right at both ends, as well as some trickiness in evaluating those secure hashcodes
at template-instantiation time (the stamper-outer has a special case for such calculations).


More information about the valhalla-dev mailing list