private void preInitializeLeakyClasses ( ) { try { Class < ? > readerClass = ClassNameReader . class ; Field field = readerClass . getDeclaredField ( "EARLY_EXIT" ) ; field . setAccessible ( true ) ; ( ( Throwable ) field . get ( null ) ) . fillInStackTrace ( ) ; } catch ( Exception ex ) { this . logger . warn ( "Unable to pre-initialize classes" , ex ) ; } }
CGLIB has a private exception field which needs to initialized early to ensure that the stacktrace doesn t retain a reference to the RestartClassLoader .