Classfile representation of specializable classes
daniel.smith at oracle.com
Sat Jul 12 06:00:02 UTC 2014
On Jul 11, 2014, at 3:03 PM, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
> On 11/07/14 18:21, Dan Smith wrote:
>> On Jul 11, 2014, at 10:58 AM, Brian Goetz <brian.goetz at oracle.com> wrote:
>>> The example in the writeup has many pleasing properties (one artifact, so can't get out of sync; encode minimal additional metadata needed to efficiently transform an erased classfile to a specialized classfile; the "template" can be used as an erased classfile as is, just by ignoring the specialization metadata attributes.)
>>> It also has an unpleasant property: the bytecode for an already loaded class is not available easily through its classloader or reflection, meaning that a runtime specialization mechanism would have to jump through hoops (e.g., retransform-classes) to get at the bytecode. Since specializing a class under this scheme requires, as input, the bytecode of the original class, this could become problematic for classes that are themselves generated (i.e., not findable with ClassLoader.getResource("Foo.class")).
>> 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.)
> I believe that classloader was also NextGen way to get there:
Right. To be clear, I'm not just suggesting that we use ClassLoaders and call it a day. There a good reasons to want something more. But perhaps that "something more" can take the form of a re-architected ClassLoader API -- specifically one that exposes a hook between the byte array and the generated class.
More information about the valhalla-dev