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

HHH-11152: Added BytecodeProvider based on Byte Buddy #1622

Merged
merged 1 commit into from Nov 16, 2016

Conversation

Projects
None yet
4 participants
@raphw
Member

raphw commented Nov 11, 2016

https://hibernate.atlassian.net/browse/HHH-11152

  1. Refactored Enhancer contract to no longer depend on Javassist.
  2. Refactored BytecodeProvider to also supply Enhancer.
  3. Refactored tests to no longer reject running upon discovering a non-Javassist implementation of Enhancer.
  4. Refactored Enhancer implementation to return null upon a non-transformed class to allow for special handling, e.g. not rewriting a file during applying a plugin.
  5. Added Byte Buddy-based implementation of a BytecodeProvider.
  6. Declared the latter implementation to be used by default (6.0 only).
  7. Refactored tests and different APIs to no longer use Javassist but rather represent such logic within the BytecodeProvider contract.
@raphw

This comment has been minimized.

Show comment
Hide comment
@raphw

raphw Nov 12, 2016

Member

PS: For full support of Java 9, exchange the byte-buddy dependency with byte-buddy-dep and include asm in version 6-ALPHA. As the class file format is still changing, this is not yet included in the official release.

This is however only relevant for the Enhancer. Proxies for Java 9 VMs are already supported.

Member

raphw commented Nov 12, 2016

PS: For full support of Java 9, exchange the byte-buddy dependency with byte-buddy-dep and include asm in version 6-ALPHA. As the class file format is still changing, this is not yet included in the official release.

This is however only relevant for the Enhancer. Proxies for Java 9 VMs are already supported.

@sebersole

This comment has been minimized.

Show comment
Hide comment
@sebersole

sebersole Nov 14, 2016

Member

Regarding Enhancer and Java 9... what is the plan wrt artifacts? Will we need to swap byte-buddy dependency with byte-buddy-dep + asm long term? Or is that simply a function of Java 9 not being final yet?

I guess what I am asking is, after Java 9 is finalized do you see us still needing to choose different dependencies for different VM runtimes?

Member

sebersole commented Nov 14, 2016

Regarding Enhancer and Java 9... what is the plan wrt artifacts? Will we need to swap byte-buddy dependency with byte-buddy-dep + asm long term? Or is that simply a function of Java 9 not being final yet?

I guess what I am asking is, after Java 9 is finalized do you see us still needing to choose different dependencies for different VM runtimes?

@sebersole

Were the changes in gradlew something you specifically changed?

@raphw

This comment has been minimized.

Show comment
Hide comment
@raphw

raphw Nov 14, 2016

Member

Once Java 9 spec is finalized, you only need to update to a new version. I did not intend to change gradlew, I can revert that tomorrow.

Member

raphw commented Nov 14, 2016

Once Java 9 spec is finalized, you only need to update to a new version. I did not intend to change gradlew, I can revert that tomorrow.

@raphw

This comment has been minimized.

Show comment
Hide comment
@raphw

raphw Nov 15, 2016

Member

I reverted all unintended changes. Should be clean now.

Member

raphw commented Nov 15, 2016

I reverted all unintended changes. Should be clean now.

@sebersole

sebersole approved these changes Nov 15, 2016 edited

These changes look good to me. @barreiro - what are your thoughts?

@barreiro

Overall, it looks good!

@sebersole sebersole merged commit ba3359f into hibernate:master Nov 16, 2016

@sebersole

This comment has been minimized.

Show comment
Hide comment
@sebersole

sebersole Nov 16, 2016

Member

I should point out that I ended up including this in 5.2 (5.2.5) but that there it is NOT the default. Also its artifact must be named as an explicit dependency by the app.

We will change this in 6.0 and most likely also remove Javassist support at that time.

Member

sebersole commented Nov 16, 2016

I should point out that I ended up including this in 5.2 (5.2.5) but that there it is NOT the default. Also its artifact must be named as an explicit dependency by the app.

We will change this in 6.0 and most likely also remove Javassist support at that time.

@sebersole

This comment has been minimized.

Show comment
Hide comment
@sebersole

sebersole Nov 17, 2016

Member

Hm, I am still seeing hibernate-osgi test failure after applying these changes: http://ci.hibernate.org/job/hibernate-orm-master-h2-main/286/

org.ops4j.pax.exam.TimeoutException: Timeout passed and bundle has state 'resolved' not 'active' as expected

Perhaps this has to do with making bytebuddy dependency "provided"? @brmeyer - any ideas?

Member

sebersole commented Nov 17, 2016

Hm, I am still seeing hibernate-osgi test failure after applying these changes: http://ci.hibernate.org/job/hibernate-orm-master-h2-main/286/

org.ops4j.pax.exam.TimeoutException: Timeout passed and bundle has state 'resolved' not 'active' as expected

Perhaps this has to do with making bytebuddy dependency "provided"? @brmeyer - any ideas?

@sebersole

This comment has been minimized.

Show comment
Hide comment
@sebersole

sebersole Nov 17, 2016

Member

I added the following line to the testing-bundles.xml file:

        <bundle>mvn:net.bytebuddy/byte-buddy/1.5.4</bundle>

That got past the bundle activation issue. But now I am back to "can't find javassist" errors:

java.lang.ClassNotFoundException: javassist.util.proxy.ProxyObject not found by org.hibernate.envers [55]

plus some NPE failures, e.g.:

java.lang.NullPointerException
    at org.hibernate.osgi.test.OsgiIntegrationTest.testNative(OsgiIntegrationTest.java:253)

which is the line trying to use the SessionFactory obtained by:

        final ServiceReference sr = bundleContext.getServiceReference( SessionFactory.class.getName() );
        final SessionFactory sf = (SessionFactory) bundleContext.getService( sr );
Member

sebersole commented Nov 17, 2016

I added the following line to the testing-bundles.xml file:

        <bundle>mvn:net.bytebuddy/byte-buddy/1.5.4</bundle>

That got past the bundle activation issue. But now I am back to "can't find javassist" errors:

java.lang.ClassNotFoundException: javassist.util.proxy.ProxyObject not found by org.hibernate.envers [55]

plus some NPE failures, e.g.:

java.lang.NullPointerException
    at org.hibernate.osgi.test.OsgiIntegrationTest.testNative(OsgiIntegrationTest.java:253)

which is the line trying to use the SessionFactory obtained by:

        final ServiceReference sr = bundleContext.getServiceReference( SessionFactory.class.getName() );
        final SessionFactory sf = (SessionFactory) bundleContext.getService( sr );
@sebersole

This comment has been minimized.

Show comment
Hide comment
@sebersole

sebersole Nov 17, 2016

Member

Not really. by making it provided we are saying that the application or
the environment it runs in must provide that dependency.

Another option would be to add the bytebuddy bundle to the karaf feature
file from hibernate-osgi.gradle, but then this would work differently in
OSGi compared to every other runtime environment.

On Thu, Nov 17, 2016 at 10:58 AM Brett Meyer notifications@github.com
wrote:

I added the following line to the testing-bundles.xml file:

A little surprising if ByteBuddy is provided. Will take a look...


You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub
#1622 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAOUE87qyLUze2MWkDWkbYdXkoc6Hd6-ks5q_IejgaJpZM4KwGDw
.

Member

sebersole commented Nov 17, 2016

Not really. by making it provided we are saying that the application or
the environment it runs in must provide that dependency.

Another option would be to add the bytebuddy bundle to the karaf feature
file from hibernate-osgi.gradle, but then this would work differently in
OSGi compared to every other runtime environment.

On Thu, Nov 17, 2016 at 10:58 AM Brett Meyer notifications@github.com
wrote:

I added the following line to the testing-bundles.xml file:

A little surprising if ByteBuddy is provided. Will take a look...


You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub
#1622 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAOUE87qyLUze2MWkDWkbYdXkoc6Hd6-ks5q_IejgaJpZM4KwGDw
.

@AndriyKalashnykov

This comment has been minimized.

Show comment
Hide comment
@AndriyKalashnykov

AndriyKalashnykov commented Dec 1, 2016

karaf.xml is missing byte-buddy dependency (net.bytebuddy/byte-buddy/1.5.4/) :
http://repo.maven.apache.org/maven2/org/hibernate/hibernate-osgi/5.2.5.Final/hibernate-osgi-5.2.5.Final-karaf.xml

@sebersole

This comment has been minimized.

Show comment
Hide comment
@sebersole

sebersole Dec 1, 2016

Member
Member

sebersole commented Dec 1, 2016

@AndriyKalashnykov

This comment has been minimized.

Show comment
Hide comment
@AndriyKalashnykov

AndriyKalashnykov Dec 1, 2016

This is what happens when hibernate-osgi feature deployed onto Karaf 3.0.3 (
http://archive.apache.org/dist/karaf/3.0.3/apache-karaf-3.0.3.zip)

admin@root()> feature:repo-add mvn:org.hibernate/hibernate-osgi/5.2.5.Final/xml/karaf
Adding feature url mvn:org.hibernate/hibernate-osgi/5.2.5.Final/xml/karaf
admin@root()> feature:install hibernate-orm
Error executing command: Can't install feature hibernate-orm/0.0.0:
Could not start bundle mvn:org.hibernate/hibernate-core/5.2.5.Final in feature(s) hibernate-orm-5.2.5.Final: Unresolved constraint in bundle org.hibernate.core [78]: Unable to resolve 78.0: missing requirement [78.0] osgi.wiring.package; (osgi.wiring.package=net.bytebuddy)

2016-12-01 11:55:17,332 | ERROR | h for user admin | ShellUtil | 25 - org.apache.karaf.shell.console - 3.0.3 | Exception caught while executing command
java.lang.IllegalStateException: Can't install feature hibernate-orm/0.0.0:
Could not start bundle mvn:org.hibernate/hibernate-core/5.2.5.Final in feature(s) hibernate-orm-5.2.5.Final: Unresolved constraint in bundle org.hibernate.core [78]: Unable to resolve 78.0: missing requirement [78.0] osgi.wiring.package; (osgi.wiring.package=net.bytebuddy)
at org.apache.karaf.features.internal.FeaturesServiceImpl.installFeature(FeaturesServiceImpl.java:388)
at Proxyc90c1e13_c733_4f0a_97b0_9628c22d85df.installFeature(Unknown Source)
at org.apache.karaf.features.command.InstallFeatureCommand.doExecute(InstallFeatureCommand.java:67)
at org.apache.karaf.features.command.FeaturesCommandSupport.doExecute(FeaturesCommandSupport.java:38)
at org.apache.karaf.shell.console.AbstractAction.execute(AbstractAction.java:33)[25:org.apache.karaf.shell.console:3.0.3]
at org.apache.karaf.shell.console.OsgiCommandSupport.execute(OsgiCommandSupport.java:39)[25:org.apache.karaf.shell.console:3.0.3]
at org.apache.karaf.shell.commands.basic.AbstractCommand.execute(AbstractCommand.java:33)[25:org.apache.karaf.shell.console:3.0.3]
at Proxy6847aa1c_e248_48fe_9b87_f085d501e09a.execute(Unknown Source)[:]
at Proxy6847aa1c_e248_48fe_9b87_f085d501e09a.execute(Unknown Source)[:]
at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:78)[25:org.apache.karaf.shell.console:3.0.3]
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)[25:org.apache.karaf.shell.console:3.0.3]
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)[25:org.apache.karaf.shell.console:3.0.3]
at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[25:org.apache.karaf.shell.console:3.0.3]
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)[25:org.apache.karaf.shell.console:3.0.3]
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)[25:org.apache.karaf.shell.console:3.0.3]
at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:92)
at org.apache.karaf.shell.console.impl.jline.ConsoleImpl.run(ConsoleImpl.java:208)
at org.apache.karaf.shell.ssh.ShellFactoryImpl$ShellImpl$1.runConsole(ShellFactoryImpl.java:158)[52:org.apache.karaf.shell.ssh:3.0.3]
at org.apache.karaf.shell.ssh.ShellFactoryImpl$ShellImpl$1$1.run(ShellFactoryImpl.java:133)
at java.security.AccessController.doPrivileged(Native Method)[:1.8.0_92]
at org.apache.karaf.jaas.modules.JaasHelper.doAs(JaasHelper.java:57)[26:org.apache.karaf.jaas.modules:3.0.3]
at org.apache.karaf.shell.ssh.ShellFactoryImpl$ShellImpl$1.run(ShellFactoryImpl.java:129)[52:org.apache.karaf.shell.ssh:3.0.3]

AndriyKalashnykov commented Dec 1, 2016

This is what happens when hibernate-osgi feature deployed onto Karaf 3.0.3 (
http://archive.apache.org/dist/karaf/3.0.3/apache-karaf-3.0.3.zip)

admin@root()> feature:repo-add mvn:org.hibernate/hibernate-osgi/5.2.5.Final/xml/karaf
Adding feature url mvn:org.hibernate/hibernate-osgi/5.2.5.Final/xml/karaf
admin@root()> feature:install hibernate-orm
Error executing command: Can't install feature hibernate-orm/0.0.0:
Could not start bundle mvn:org.hibernate/hibernate-core/5.2.5.Final in feature(s) hibernate-orm-5.2.5.Final: Unresolved constraint in bundle org.hibernate.core [78]: Unable to resolve 78.0: missing requirement [78.0] osgi.wiring.package; (osgi.wiring.package=net.bytebuddy)

2016-12-01 11:55:17,332 | ERROR | h for user admin | ShellUtil | 25 - org.apache.karaf.shell.console - 3.0.3 | Exception caught while executing command
java.lang.IllegalStateException: Can't install feature hibernate-orm/0.0.0:
Could not start bundle mvn:org.hibernate/hibernate-core/5.2.5.Final in feature(s) hibernate-orm-5.2.5.Final: Unresolved constraint in bundle org.hibernate.core [78]: Unable to resolve 78.0: missing requirement [78.0] osgi.wiring.package; (osgi.wiring.package=net.bytebuddy)
at org.apache.karaf.features.internal.FeaturesServiceImpl.installFeature(FeaturesServiceImpl.java:388)
at Proxyc90c1e13_c733_4f0a_97b0_9628c22d85df.installFeature(Unknown Source)
at org.apache.karaf.features.command.InstallFeatureCommand.doExecute(InstallFeatureCommand.java:67)
at org.apache.karaf.features.command.FeaturesCommandSupport.doExecute(FeaturesCommandSupport.java:38)
at org.apache.karaf.shell.console.AbstractAction.execute(AbstractAction.java:33)[25:org.apache.karaf.shell.console:3.0.3]
at org.apache.karaf.shell.console.OsgiCommandSupport.execute(OsgiCommandSupport.java:39)[25:org.apache.karaf.shell.console:3.0.3]
at org.apache.karaf.shell.commands.basic.AbstractCommand.execute(AbstractCommand.java:33)[25:org.apache.karaf.shell.console:3.0.3]
at Proxy6847aa1c_e248_48fe_9b87_f085d501e09a.execute(Unknown Source)[:]
at Proxy6847aa1c_e248_48fe_9b87_f085d501e09a.execute(Unknown Source)[:]
at org.apache.felix.gogo.runtime.CommandProxy.execute(CommandProxy.java:78)[25:org.apache.karaf.shell.console:3.0.3]
at org.apache.felix.gogo.runtime.Closure.executeCmd(Closure.java:477)[25:org.apache.karaf.shell.console:3.0.3]
at org.apache.felix.gogo.runtime.Closure.executeStatement(Closure.java:403)[25:org.apache.karaf.shell.console:3.0.3]
at org.apache.felix.gogo.runtime.Pipe.run(Pipe.java:108)[25:org.apache.karaf.shell.console:3.0.3]
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:183)[25:org.apache.karaf.shell.console:3.0.3]
at org.apache.felix.gogo.runtime.Closure.execute(Closure.java:120)[25:org.apache.karaf.shell.console:3.0.3]
at org.apache.felix.gogo.runtime.CommandSessionImpl.execute(CommandSessionImpl.java:92)
at org.apache.karaf.shell.console.impl.jline.ConsoleImpl.run(ConsoleImpl.java:208)
at org.apache.karaf.shell.ssh.ShellFactoryImpl$ShellImpl$1.runConsole(ShellFactoryImpl.java:158)[52:org.apache.karaf.shell.ssh:3.0.3]
at org.apache.karaf.shell.ssh.ShellFactoryImpl$ShellImpl$1$1.run(ShellFactoryImpl.java:133)
at java.security.AccessController.doPrivileged(Native Method)[:1.8.0_92]
at org.apache.karaf.jaas.modules.JaasHelper.doAs(JaasHelper.java:57)[26:org.apache.karaf.jaas.modules:3.0.3]
at org.apache.karaf.shell.ssh.ShellFactoryImpl$ShellImpl$1.run(ShellFactoryImpl.java:129)[52:org.apache.karaf.shell.ssh:3.0.3]

@sebersole

This comment has been minimized.

Show comment
Hide comment
@sebersole

sebersole Dec 1, 2016

Member
Member

sebersole commented Dec 1, 2016

@AndriyKalashnykov

This comment has been minimized.

Show comment
Hide comment
@AndriyKalashnykov

AndriyKalashnykov Dec 1, 2016

Not aware what was decided.
Adding it manually always an option:

install -s mvn:net.bytebuddy/byte-buddy/1.5.4/
feature:repo-add mvn:org.hibernate/hibernate-osgi/5.2.5.Final/xml/karaf
feature:install hibernate-orm

AndriyKalashnykov commented Dec 1, 2016

Not aware what was decided.
Adding it manually always an option:

install -s mvn:net.bytebuddy/byte-buddy/1.5.4/
feature:repo-add mvn:org.hibernate/hibernate-osgi/5.2.5.Final/xml/karaf
feature:install hibernate-orm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment