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.
*/
public Class<?> load(Class<?> referenceClass, Function<ByteBuddy, DynamicType.Builder<?>> makeClassFunction) {
return make( makeClassFunction.apply( byteBuddy ) )
.load( referenceClass.getClassLoader(), resolveClassLoadingStrategy( referenceClass ) )
.getLoaded();
Unloaded<?> result =
make( makeClassFunction.apply( byteBuddy ) );
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();
}
/**