Skip to content

HHH-14792 Remove support for bytecode enhancement via Javassist #4171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
<bundle>mvn:com.fasterxml/classmate/0.8.0</bundle>
<bundle>mvn:org.apache.logging.log4j/log4j-api/2.0</bundle>
<bundle>mvn:org.jboss.logging/jboss-logging/3.2.1.Final</bundle>
<bundle>mvn:org.javassist/javassist/3.18.1-GA</bundle>

<bundle>mvn:org.hibernate.common/hibernate-commons-annotations/4.0.5.Final</bundle>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@
org.apache.karaf.shell.console,
org.apache.karaf.shell.commands,
javax.persistence;version="[1.0.0,2.1.0]",
<!-- Needed for proxying's Javassist enhancement during runtime -->
org.hibernate.proxy,
javassist.util.proxy,
*
</Import-Package>
<Meta-Persistence>META-INF/persistence.xml</Meta-Persistence>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<bundle>mvn:com.fasterxml/classmate/0.8.0</bundle>
<bundle>mvn:org.apache.logging.log4j/log4j-api/2.0</bundle>
<bundle>mvn:org.jboss.logging/jboss-logging/3.2.1.Final</bundle>
<bundle>mvn:org.javassist/javassist/3.18.1-GA</bundle>

<bundle>mvn:org.hibernate.common/hibernate-commons-annotations/4.0.5.Final</bundle>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@
org.apache.karaf.shell.commands,
org.h2,
javax.persistence;version="[1.0.0,2.1.0]",
<!-- Needed for proxying's Javassist enhancement during runtime -->
org.hibernate.proxy,
javassist.util.proxy,
*
</Import-Package>
</instructions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
<bundle>mvn:com.fasterxml/classmate/0.8.0</bundle>
<bundle>mvn:org.apache.logging.log4j/log4j-api/2.0</bundle>
<bundle>mvn:org.jboss.logging/jboss-logging/3.2.1.Final</bundle>
<bundle>mvn:org.javassist/javassist/3.18.1-GA</bundle>

<bundle>mvn:org.hibernate.common/hibernate-commons-annotations/4.0.5.Final</bundle>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@
org.hibernate.cfg,
org.hibernate.service,
javax.persistence;version="[1.0.0,2.1.0]",
<!-- Needed for proxy enhancement during runtime -->
org.hibernate.proxy,
javassist.util.proxy,
*
</Import-Package>
</instructions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ Enable lazy loading feature in runtime bytecode enhancement. This way, even basi
Enable association management feature in runtime bytecode enhancement which automatically synchronizes a bidirectional association when only one side is changed.

`*hibernate.bytecode.provider*` (e.g. `bytebuddy` (default value))::
The https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/bytecode/spi/BytecodeProvider.html[`BytecodeProvider`] built-in implementation flavor. Currently, only `bytebuddy` and `javassist` are valid values; `bytebuddy` is the default and recommended choice; `javassist` will be removed soon.
The https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/bytecode/spi/BytecodeProvider.html[`BytecodeProvider`] built-in implementation flavor. Currently, only `bytebuddy` is a valid value, as older deprecated options have been removed.

`*hibernate.bytecode.use_reflection_optimizer*` (e.g. `true` or `false` (default value))::
Should we use reflection optimization? The reflection optimizer implements the https://docs.jboss.org/hibernate/orm/{majorMinorVersion}/javadocs/org/hibernate/bytecode/spi/ReflectionOptimizer.html[`ReflectionOptimizer`] interface and improves entity instantiation and property getter/setter calls.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,9 @@ Hibernate will trigger a Persistence Context flush if there are pending `Account
==== Define a custom entity proxy

By default, when it needs to use a proxy instead of the actual POJO, Hibernate is going to use a Bytecode manipulation library like
https://jboss-javassist.github.io/javassist/[Javassist] or
https://bytebuddy.net/[Byte Buddy].

However, if the entity class is final, Javassist will not create a proxy and you will get a POJO even when you only need a proxy reference.
However, if the entity class is final, a proxy will not be created; you will get a POJO even when you only need a proxy reference.
In this case, you could proxy an interface that this particular entity implements, as illustrated by the following example.

[[entity-proxy-interface-mapping]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ That `DataSource` is then used by your `persistence.xml` persistence-unit. The f
Your bundle's manifest will need to import, at a minimum:

* `javax.persistence`
* `org.hibernate.proxy` and `javassist.util.proxy`, due to Hibernate's ability to return proxies for lazy initialization (Javassist enhancement occurs on the entity's `ClassLoader` during runtime).

=== Obtaining an EntityManger

Expand Down Expand Up @@ -123,7 +122,6 @@ Similar to any other JPA setup, your bundle must include a `persistence.xml` fil
Your bundle's manifest will need to import, at a minimum:

* `javax.persistence`
* `org.hibernate.proxy` and `javassist.util.proxy`, due to Hibernate's ability to return proxies for lazy initialization (Javassist enhancement occurs on the entity's `ClassLoader` during runtime)
* JDBC driver package (example: `org.h2`)
* `org.osgi.framework`, necessary to discover the `EntityManagerFactory` (described below)

Expand Down Expand Up @@ -157,7 +155,6 @@ Native Hibernate use is also supported. The client bundle is responsible for man
Your bundle's manifest will need to import, at a minimum:

* `javax.persistence`
* `org.hibernate.proxy` and `javassist.util.proxy`, due to Hibernate's ability to return proxies for lazy initialization (Javassist enhancement occurs on the entity's `ClassLoader` during runtime)
* JDBC driver package (example: `org.h2`)
* `org.osgi.framework`, necessary to discover the `SessionFactory` (described below)
* `org.hibernate.*` packages, as necessary (ex: cfg, criterion, service, etc.)
Expand Down
1 change: 0 additions & 1 deletion gradle/java-module.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ dependencies {
testCompile( libraries.byteman_bmunit )

testRuntime( libraries.log4j2 )
testRuntime( libraries.javassist )
testRuntime( libraries.byteBuddy )

//Databases
Expand Down
4 changes: 0 additions & 4 deletions gradle/libraries.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ ext {
weldVersion = '3.1.5.Final'
jakartaWeldVersion = '4.0.1.SP1'

javassistVersion = '3.27.0-GA'
byteBuddyVersion = '1.11.12'

agroalVersion = '1.9'
Expand Down Expand Up @@ -64,9 +63,6 @@ ext {
// Dom4J
dom4j: 'org.dom4j:dom4j:2.1.3@jar',

// Javassist
javassist: "org.javassist:javassist:${javassistVersion}",

// Byte Buddy
byteBuddy: "net.bytebuddy:byte-buddy:${byteBuddyVersion}",

Expand Down
3 changes: 0 additions & 3 deletions hibernate-core-jakarta/hibernate-core-jakarta.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ configurations {

dependencies {
compile( libraries.jakarta_jpa )
// This can now be made provided
compile( libraries.javassist )
// Could be made optional?
compile( libraries.byteBuddy )
compile( libraries.antlr )
Expand Down Expand Up @@ -75,7 +73,6 @@ dependencies {
testRuntime( "org.jboss.spec.javax.ejb:jboss-ejb-api_3.2_spec:1.0.0.Final" )
testRuntime( libraries.jakarta_el )
testRuntime( 'jaxen:jaxen:1.1' )
testRuntime( libraries.javassist )
testRuntime( libraries.byteBuddy )
testRuntime( libraries.jakarta_weld )
testRuntime( libraries.atomikos )
Expand Down
50 changes: 0 additions & 50 deletions hibernate-core/hibernate-core.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,31 +28,17 @@ sourceSets {
setSrcDirs( ['src/test/java','src/test/resources','src/test/bundles'] )
}
}

testJavassist {
java {
compileClasspath += main.output + test.output
runtimeClasspath += main.output + test.output
}
}
}

configurations {
tests {
description = 'Configuration for the produced test jar'
}

//Configures the compile and runtime configurations for our javassist tests
//and includes the dependencies of the test task.
testJavassistCompile.extendsFrom testCompile
testJavassistRuntime.extendsFrom testRuntime
}

dependencies {

compile( libraries.jpa )
// This can now be made provided
compile( libraries.javassist )
// Could be made optional?
compile( libraries.byteBuddy )
compile( libraries.antlr )
Expand Down Expand Up @@ -103,7 +89,6 @@ dependencies {
testRuntime( "org.jboss.spec.javax.ejb:jboss-ejb-api_3.2_spec:1.0.0.Final" )
testRuntime( libraries.expression_language )
testRuntime( 'jaxen:jaxen:1.1' )
testRuntime( libraries.javassist )
testRuntime( libraries.byteBuddy )
testRuntime( libraries.weld )
testRuntime( libraries.atomikos )
Expand All @@ -118,9 +103,6 @@ dependencies {
testCompile libraries.jboss_ejb_spec_jar
testCompile libraries.jboss_annotation_spec_jar

// Additional tests requiring Javassist
// folder in src/javassist/java
testJavassistCompile libraries.javassist
}

jar {
Expand Down Expand Up @@ -265,35 +247,3 @@ test {
}
}

//Create the task that runs the integration tests found from the
//configured source directory and uses the correct classpath.
task testJavassist(type: Test) {
testClassesDirs = sourceSets.testJavassist.output.classesDirs
classpath = sourceSets.testJavassist.runtimeClasspath
//If you want to ensure that integration tests are run every time when you invoke
//this task, uncomment the following line.
//outputs.upToDateWhen { false }

if ( gradle.ext.javaToolchainEnabled ) {
// Configure version of Java tools
javaLauncher = javaToolchains.launcherFor {
languageVersion = gradle.ext.javaVersions.test.launcher
}

// Configure JVM Options
jvmArgs( getProperty( 'toolchain.launcher.jvmargs' ).toString().split( ' ' ) )

// Display version of Java tools
doFirst {
logger.lifecycle "Testing javassist with '${javaLauncher.get().metadata.installationPath}'"
}
}

if ( gradle.ext.javaVersions.test.launcher.asInt() >= 9 ) {
// Javassist needs this to generate proxies
jvmArgs( ['--add-opens', 'java.base/java.lang=ALL-UNNAMED'] )
}
}

check.dependsOn testJavassist
testJavassist.mustRunAfter test
Loading