Skip to content

Commit

Permalink
Make GeneratorStrategy.generate unreachable on native
Browse files Browse the repository at this point in the history
  • Loading branch information
sdeleuze committed Nov 18, 2022
1 parent 796b8c1 commit 52b292e
Showing 1 changed file with 6 additions and 0 deletions.
Expand Up @@ -26,6 +26,7 @@
import org.springframework.asm.ClassReader;
import org.springframework.cglib.core.internal.Function;
import org.springframework.cglib.core.internal.LoadingCache;
import org.springframework.core.NativeDetector;

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

0 comments on commit 52b292e

Please sign in to comment.