Skip to content

Commit 52b292e

Browse files
committed
Make GeneratorStrategy.generate unreachable on native
1 parent 796b8c1 commit 52b292e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

spring-core/src/main/java/org/springframework/cglib/core/AbstractClassGenerator.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.springframework.asm.ClassReader;
2727
import org.springframework.cglib.core.internal.Function;
2828
import org.springframework.cglib.core.internal.LoadingCache;
29+
import org.springframework.core.NativeDetector;
2930

3031
/**
3132
* Abstract class for all code-generating CGLIB utilities.
@@ -359,6 +360,11 @@ protected Class generate(ClassLoaderData data) {
359360
// ignore
360361
}
361362
}
363+
// SPRING PATCH BEGIN
364+
if (NativeDetector.inNativeImage()) {
365+
throw new UnsupportedOperationException("CGLIB enhancement should not happen at runtime on native image");
366+
}
367+
// SPRING PATCH END
362368
byte[] b = strategy.generate(this);
363369
String className = ClassNameReader.getClassName(new ClassReader(b));
364370
ProtectionDomain protectionDomain = getProtectionDomain();

0 commit comments

Comments
 (0)