Hi Jochen, Is there anything stopping you for doing something like:
try { Class.forName(innerClassName, true, initalizeClass.getClassLoader()); } catch (ClassNotFoundException e) { throw new ExceptionInInitializerError(e); // Should never happen } I know it is not pretty. /Kasper On Wed, 29 Apr 2020 at 12:26, Jochen Theodorou <blackd...@gmx.org> wrote: > > Hi, > > when jigsaw started there was a lot of talk about providing alternatives > to what Unsafe offers. Today I am facing a problem I cannot solve > anymore it seems with this. > > My problem is that I need to ensure the static block of an inner class > has been executed before I do something, because the static block > contains setup data the class will need and influence what I do with the > class. Of course this might be not the best choice, I am just trying to > keep certain functionality. > > In the past I would have used Unsafe#ensureClassInitialized, but this > method has not found a replacement yet if I read JDK-8235521 : > Replacement API for Unsafe::ensureClassInitialized correctly. > > Also because of Unsafe#getUnsafe, checking for the platform loader for > the caller (which is not the case for me) I cannot get the unsafe object > itself "properly". > > Now I am wondering what alternatives exist. Are there any? > > bye Jochen