Skip to content
Advertisement

Tag: jep

Lambda expressions and anonymous classes don’t work when loaded as hidden classes

I am trying to compile and load dynamically generated Java code during runtime. Since both ClassLoader::defineClass and Unsafe::defineAnonymousClass have serious drawbacks in this scenario, I tried using hidden classes via Lookup::defineHiddenClass instead. This works fine for all classes that I tried to load, except for those that call lambda expressions or contain anonymous classes. Calling a lambda expression throws the

Advertisement