Skip to content

Commit

Permalink
Fail the build instead of skipping Hibernate ORM bytecode enhancement…
Browse files Browse the repository at this point in the history
… when it's unsupported
  • Loading branch information
yrodiere committed Nov 26, 2024
1 parent 28cbabc commit 7df943a
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.hibernate.bytecode.enhance.spi.DefaultEnhancementContext;
import org.hibernate.bytecode.enhance.spi.UnloadedField;
import org.hibernate.bytecode.enhance.spi.UnsupportedEnhancementStrategy;

public final class QuarkusEnhancementContext extends DefaultEnhancementContext {

Expand All @@ -26,4 +27,15 @@ public ClassLoader getLoadingClassLoader() {
throw new IllegalStateException("The Classloader of the EnhancementContext should not be used");
}

@Override
public UnsupportedEnhancementStrategy getUnsupportedEnhancementStrategy() {
// We expect model classes to be enhanced.
// Lack of enhancement could lead to many problems,
// from bad performance, to Quarkus-specific optimizations causing errors/data loss,
// to incorrect generated bytecode (references to non-existing methods).
// If something prevents enhancement, it's just safer to have Hibernate ORM's enhancer fail
// with a clear error message pointing to the application class that needs to be fixed.
return UnsupportedEnhancementStrategy.FAIL;
}

}

0 comments on commit 7df943a

Please sign in to comment.