Repository: quarkusio/quarkus
Issue: Hibernate Proxy classes generated with incorrect java release version

**Describe the bug**
We can set the java release version to be used through maven property `maven.compiler.release` (e.g. `<maven.compiler.release>11</maven.compiler.release>`)

When the project is then compiled with a `javac` version >= 11 and run with java 11, an `java.lang.UnsupportedClassVersionError` is thrown on application startup.

**Expected behavior**
All sources should be compiled to target the specified java release, and the application should start up.

**Actual behavior**
On application startup, the following exception is thrown:
```
Exception in thread "main" java.lang.ExceptionInInitializerError
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.base/java.lang.reflect.Constructor.newInstance(Unknown Source)
	at java.base/java.lang.Class.newInstance(Unknown Source)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:61)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:38)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:104)
	at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)
Caused by: java.lang.RuntimeException: Failed to start quarkus
	at io.quarkus.runner.ApplicationImpl.<clinit>(ApplicationImpl.zig:249)
	... 9 more
Caused by: java.lang.UnsupportedClassVersionError: de/turing85/HelloEntity$HibernateProxy$0mzonqkm has been compiled by a more recent version of the Java Runtime (class file version 58.0), this version of the Java Runtime only recognizes class file versions up to 55.0
	at java.base/java.lang.ClassLoader.defineClass1(Native Method)
	at java.base/java.lang.ClassLoader.defineClass(Unknown Source)
	at java.base/java.security.SecureClassLoader.defineClass(Unknown Source)
	at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(Unknown Source)
	at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(Unknown Source)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(Unknown Source)
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Unknown Source)
	at io.quarkus.hibernate.orm.runtime.proxies.ProxyDefinitions.generateProxyClass(ProxyDefinitions.java:127)
	at io.quarkus.hibernate.orm.runtime.proxies.ProxyDefinitions.createFromMetadata(ProxyDefinitions.java:61)
	at io.quarkus.hibernate.orm.runtime.boot.FastBootMetadataBuilder.build(FastBootMetadataBuilder.java:318)
	at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.createMetadata(PersistenceUnitsHolder.java:101)
	at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.constructMetadataAdvance(PersistenceUnitsHolder.java:73)
	at io.quarkus.hibernate.orm.runtime.PersistenceUnitsHolder.initializeJpa(PersistenceUnitsHolder.java:40)
	at io.quarkus.hibernate.orm.runtime.HibernateOrmRecorder$1.created(HibernateOrmRecorder.java:58)
	at io.quarkus.arc.runtime.ArcRecorder.initBeanContainer(ArcRecorder.java:53)
	at io.quarkus.deployment.steps.ArcProcessor$generateResources-1025303321.deploy_0(ArcProcessor$generateResources-1025303321.zig:127)
	at io.quarkus.deployment.steps.ArcProcessor$generateResources-1025303321.deploy(ArcProcessor$generateResources-1025303321.zig:40)
	at io.quarkus.runner.ApplicationImpl.<clinit>(ApplicationImpl.zig:207)
	... 9 more
```
**To Reproduce**

- Checkout `https://github.com/turing85/quarkus-hibernate-javaversion-bug`
- verify `javac` version is `>11`: 

      > javac -version
      javac 14.0.2
- Compile project, start docker-container:

      ./mvnw clean install -Dquarkus.container-image.build=true && docker run quarkus-bug/hello-app:1.0.0

**Environment (please complete the following information):**
 - Output of `uname -a` or `ver`:  `Linux XXX 5.4.0-58-generic #64-Ubuntu SMP Wed Dec 9 08:16:25 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux`
 - Output of `java -version`: 

       openjdk 14.0.2 2020-07-14
       OpenJDK Runtime Environment AdoptOpenJDK (build 14.0.2+12)
       OpenJDK 64-Bit Server VM AdoptOpenJDK (build 14.0.2+12, mixed mode, sharing)

 - GraalVM version (if different from Java): N/A 
 - Quarkus version or git rev: `1.10.3.Final`
 - Build tool (ie. output of `mvnw --version` or `gradlew --version`): 

       Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
       Maven home: /home/marco/.m2/wrapper/dists/apache-maven-3.6.3-bin/1iopthnavndlasol9gbrbg6bf2/apache-maven-3.6.3
       Java version: 14.0.2, vendor: AdoptOpenJDK, runtime: /opt/adoptOpenJDK/14.0.2+12
       Default locale: en_US, platform encoding: UTF-8
       OS name: "linux", version: "5.4.0-58-generic", arch: "amd64", family: "unix"

**Additional Information:**
The problem starts occurring if and only if `quarkus.datasource.db-kind` is set.

Changed files:
extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/ProxyBuildingHelper.java
extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/proxies/ProxyDefinitions.java
extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/BootstrapOnlyProxyFactoryFactoryInitiator.java
extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateEntityEnhancer.java

diff --git a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateEntityEnhancer.java b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateEntityEnhancer.java
index a03ac63041a..1310099e050 100644
--- a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateEntityEnhancer.java
+++ b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateEntityEnhancer.java
@@ -12,6 +12,7 @@
 
 import io.quarkus.deployment.QuarkusClassWriter;
 import io.quarkus.gizmo.Gizmo;
+import net.bytebuddy.ClassFileVersion;
 
 /**
  * Used to transform bytecode by registering to
@@ -27,7 +28,8 @@
  */
 public final class HibernateEntityEnhancer implements BiFunction<String, ClassVisitor, ClassVisitor> {
 
-    private static final BytecodeProvider PROVIDER = new org.hibernate.bytecode.internal.bytebuddy.BytecodeProviderImpl();
+    private static final BytecodeProvider PROVIDER = new org.hibernate.bytecode.internal.bytebuddy.BytecodeProviderImpl(
+            ClassFileVersion.JAVA_V8);
 
     @Override
     public ClassVisitor apply(String className, ClassVisitor outputClassVisitor) {
diff --git a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/ProxyBuildingHelper.java b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/ProxyBuildingHelper.java
index 5c407026288..63429b0969c 100644
--- a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/ProxyBuildingHelper.java
+++ b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/ProxyBuildingHelper.java
@@ -5,6 +5,7 @@
 import org.hibernate.bytecode.internal.bytebuddy.BytecodeProviderImpl;
 import org.hibernate.proxy.pojo.bytebuddy.ByteBuddyProxyHelper;
 
+import net.bytebuddy.ClassFileVersion;
 import net.bytebuddy.dynamic.DynamicType;
 
 /**
@@ -29,7 +30,7 @@ private ByteBuddyProxyHelper getByteBuddyProxyHelper() {
         //Lazy initialization of Byte Buddy: we'll likely need it, but if we can avoid loading it
         //in some corner cases it's worth avoiding it.
         if (this.byteBuddyProxyHelper == null) {
-            bytecodeProvider = new BytecodeProviderImpl();
+            bytecodeProvider = new BytecodeProviderImpl(ClassFileVersion.JAVA_V8);
             this.byteBuddyProxyHelper = bytecodeProvider.getByteBuddyProxyHelper();
         }
         return this.byteBuddyProxyHelper;
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/BootstrapOnlyProxyFactoryFactoryInitiator.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/BootstrapOnlyProxyFactoryFactoryInitiator.java
index 45d565aa06f..f58b947e41f 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/BootstrapOnlyProxyFactoryFactoryInitiator.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/BootstrapOnlyProxyFactoryFactoryInitiator.java
@@ -7,6 +7,8 @@
 import org.hibernate.bytecode.spi.ProxyFactoryFactory;
 import org.hibernate.service.spi.ServiceRegistryImplementor;
 
+import net.bytebuddy.ClassFileVersion;
+
 /**
  * We need a different implementation of ProxyFactoryFactory during the build than at runtime,
  * so to allow metadata validation. This implementation is then swapped after the metadata has been recorded.
@@ -22,7 +24,7 @@ public final class BootstrapOnlyProxyFactoryFactoryInitiator implements Standard
 
     @Override
     public ProxyFactoryFactory initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
-        BytecodeProviderImpl bbProvider = new BytecodeProviderImpl();
+        BytecodeProviderImpl bbProvider = new BytecodeProviderImpl(ClassFileVersion.JAVA_V8);
         return bbProvider.getProxyFactoryFactory();
     }
 
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/proxies/ProxyDefinitions.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/proxies/ProxyDefinitions.java
index 1e7662652a5..b44d9cb114a 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/proxies/ProxyDefinitions.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/proxies/ProxyDefinitions.java
@@ -18,6 +18,8 @@
 import org.hibernate.proxy.pojo.bytebuddy.ByteBuddyProxyHelper;
 import org.jboss.logging.Logger;
 
+import net.bytebuddy.ClassFileVersion;
+
 /**
  * Runtime proxies are used by Hibernate ORM to handle a number of corner cases;
  * in particular Enhanced Proxies need special consideration in Quarkus as
@@ -191,7 +193,7 @@ private static final class LazyBytecode implements Supplier<ByteBuddyProxyHelper
         @Override
         public ByteBuddyProxyHelper get() {
             if (helper == null) {
-                bytecodeProvider = new BytecodeProviderImpl();
+                bytecodeProvider = new BytecodeProviderImpl(ClassFileVersion.JAVA_V8);
                 helper = bytecodeProvider.getByteBuddyProxyHelper();
             }
             return helper;