add DEBUG flag save of loaded entity as proxy

Signed-off-by: Scott Marlow <smarlow@redhat.com>
This commit is contained in:
Scott Marlow 2022-09-19 11:30:14 -04:00 committed by Andrea Boriero
parent b3b62ad685
commit 7b9c14d8a1
1 changed files with 12 additions and 3 deletions

View File

@ -128,9 +128,18 @@ public final class ByteBuddyState {
* @return The loaded generated class. * @return The loaded generated class.
*/ */
public Class<?> load(Class<?> referenceClass, Function<ByteBuddy, DynamicType.Builder<?>> makeClassFunction) { public Class<?> load(Class<?> referenceClass, Function<ByteBuddy, DynamicType.Builder<?>> makeClassFunction) {
return make( makeClassFunction.apply( byteBuddy ) ) Unloaded<?> result =
.load( referenceClass.getClassLoader(), resolveClassLoadingStrategy( referenceClass ) ) make( makeClassFunction.apply( byteBuddy ) );
.getLoaded(); if (DEBUG) {
try {
result.saveIn( new File( System.getProperty( "java.io.tmpdir" ) + "/bytebuddy/" ) );
}
catch (IOException e) {
LOG.warn( "Unable to save generated class %1$s", result.getTypeDescription().getName(), e );
}
}
return result.load( referenceClass.getClassLoader(), resolveClassLoadingStrategy( referenceClass ) )
.getLoaded();
} }
/** /**