quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.57k stars 2.63k forks source link

Reduce the amount of reflection registration in native image for Hibernate ORM value generators #32609

Open yrodiere opened 1 year ago

yrodiere commented 1 year ago

Description

Follow-up on https://github.com/quarkusio/quarkus/pull/32433

Ideally we should not need reflection on all generator classes, but only those that are actually used in the application.

Implementation ideas

We could try to detect at build time the value generators that will be used, but that might be fragile (especially since generator configuration in XML mapping is different, I believe).

We could try collecting the generator classes from the metadata during static init, and somehow pass those classes to a GraalVM "Feature", but I'm not sure that's even possible; so far I've only seen "build-time" reflection registration, even though the actual GraalVM calls happen in-JVM during static init.

But ideally, we would improve Hibernate ORM so that it resolves constructors during static init, which might completely remove the need to enable reflection on generator classes. I've done something like that before, for JPA event listeners: https://github.com/hibernate/hibernate-orm/pull/4296/files#diff-c24aac287c39a1f113fe6f2b8f7f1e419673977a65c5a31eb02a5a371fa83844R25-R39

quarkus-bot[bot] commented 1 year ago

/cc @Sanne (hibernate-orm), @gsmet (hibernate-orm)