On Jul 12, 2017, at 12:08 PM, Paul Sandoz <paul.san...@oracle.com> wrote:
> 
> A ClassValue kind of map might be more efficient than say a ConcurrentHM.

A cell in the java.lang.Class is better.  It requires JVM collaboration.

The trick can be done 99% correctly with ThreadLocal and ClassValue.
The defineClass guy sets up a ThreadLocal to hold the value while
the class is loaded.  Then, in the same thread (we expect at a 99%
level) the ClassValue for the newly defined class is tickled.  The
recursive call to ClassValue.computeValue catches the long pass
from defineClass via the ThreadLocal, and… touchdown!

That wouldn't require any JVM changes at all but it might not be reliable.
Certainly not clean.

— John

Reply via email to