The loading of the newly defined classes should not happen via .load( classloader ) as this breaks depending on different Byte Buddy versions / JDK versions. We introduced an helper for the same problem in Hibernate ORM called org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState#resolveClassLoadingStrategy. This was meant as an internal contract for ORM though, so maybe we want to promote it as SPI? Also this method was only just introduced in ORM 5.3.1.Final so it would require a dependency upgrade if we wanted to use it as-is in OGM. |