File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
hibernate-core/src/main/java/org/hibernate/jpa/internal/enhance Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,9 @@ public class EnhancingClassTransformerImpl implements ClassTransformer {
31
31
private final ReentrantLock lock = new ReentrantLock ();
32
32
private volatile WeakReference <Entry > entryReference ;
33
33
34
+ //This list is matching the constants used by CoreTypePool's default constructor
35
+ private static final String [] NO_TRANSFORM_PREFIXES = { "jakarta/" , "java/" , "org/hibernate/annotations/" };
36
+
34
37
public EnhancingClassTransformerImpl (EnhancementContext enhancementContext ) {
35
38
Objects .requireNonNull ( enhancementContext );
36
39
this .enhancementContext = enhancementContext ;
@@ -45,6 +48,16 @@ public byte[] transform(
45
48
ProtectionDomain protectionDomain ,
46
49
byte [] classfileBuffer ) throws TransformerException {
47
50
51
+ //Take care to not transform certain types; this is both an optimisation (we can skip this unnecessary work)
52
+ //and a safety precaution as we otherwise risk attempting to redefine classes which have already been loaded:
53
+ //see https://hibernate.atlassian.net/browse/HHH-18108
54
+ //N.B. this className doesn't use the dot-format but the slashes for package separators.
55
+ for ( String prefix : NO_TRANSFORM_PREFIXES ) {
56
+ if ( className .startsWith ( prefix ) ) {
57
+ return null ;
58
+ }
59
+ }
60
+
48
61
try {
49
62
return getEnhancer ( loader ).enhance ( className , classfileBuffer );
50
63
}
You can’t perform that action at this time.
0 commit comments