Defining anonymous classes

Florian Weimer fweimer at
Sun Aug 17 10:55:50 UTC 2014

On 08/16/2014 12:39 AM, John Rose wrote:

> Do you have a use case in mind that could be expressed as a more tightly focused API?

My use-case is run-time class generation and avoiding unnecessary 
retention of classes which are referred to by the generated class.

I do not need constant pool patching.  It would be interesting to inject 
static final values of arbitrary types, but I could use a thread-local 
variable for that if necessary.  Being able to pass parameters to 
<clinit> would be a much cleaner way to achieve that, but it doesn't 
seem strictly necessary.

 > Or, most or all of dAC could be simulated using regular class
 > loading, into a single-use ClassLoader object.  The nominal bytecodes
 > would have to be rewritten to use invokedynamic to manage the
 > linking, at least to host-class names.

Why is that?  Because you cannot directly reference to a class by name 
if you don't use the class loader which was used to define the class to 
look up the name?

Florian Weimer / Red Hat Product Security

More information about the mlvm-dev mailing list