Skip to content
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

Java 12 build fails: Could not initialize class org.jboss.classfilewriter.DefaultClassFactory #1534

Closed
chris922 opened this issue Mar 16, 2019 · 18 comments · Fixed by #3906
Closed
Assignees
Labels
kind/bug Something isn't working
Milestone

Comments

@chris922
Copy link

This issue looks very similar to #819, but it is a different class (from probably the same library):

Running our build with Quarkus 0.11.0 on JDK 12 fails:

Could not initialize class org.jboss.classfilewriter.DefaultClassFactory

java.lang.RuntimeException: 
org.jboss.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.deployment.logging.LoggingResourceProcessor#setupLoggingRuntimeInit threw an exception: java.lang.Error: java.lang.NoSuchFieldException: override
	[error]: Build step io.quarkus.deployment.logging.LoggingResourceProcessor#setupLoggingStaticInit threw an exception: java.lang.NoClassDefFoundError: Could not initialize class org.jboss.classfilewriter.DefaultClassFactory
Caused by: org.jboss.builder.BuildException: 
Build failure: Build failed due to errors
	[error]: Build step io.quarkus.deployment.logging.LoggingResourceProcessor#setupLoggingRuntimeInit threw an exception: java.lang.Error: java.lang.NoSuchFieldException: override
	[error]: Build step io.quarkus.deployment.logging.LoggingResourceProcessor#setupLoggingStaticInit threw an exception: java.lang.NoClassDefFoundError: Could not initialize class org.jboss.classfilewriter.DefaultClassFactory
Caused by: java.lang.Error: java.lang.NoSuchFieldException: override
Caused by: java.lang.NoSuchFieldException: override

You will find the full build-output here: https://travis-ci.org/mapstruct/mapstruct-examples/jobs/506375906 (I am not sure if these logs will be discarded after time).

Java version details:

openjdk version "12" 2019-03-19
OpenJDK Runtime Environment (build 12+33)
OpenJDK 64-Bit Server VM (build 12+33, mixed mode, sharing)

In case you need more information please let me know.

(nevertheless, thank you very much for Quarkus - just did a few tests with the library and it looks gorgeous!)

@fbricon
Copy link
Contributor

fbricon commented Mar 23, 2019

Issue is still present with Quarkus 0.12.0

[INFO] --- quarkus-maven-plugin:0.12.0:dev (default-cli) @ todo-quarked ---
[INFO] Using javaTool: /Users/fbricon/.sdkman/candidates/java/12.0.0-open/bin/java
[INFO] Using servlet resources /Users/fbricon/Dev/souk/todo-quarked/src/main/resources/META-INF/resources
Listening for transport dt_socket at address: 5005
19:28:25,165 INFO  [io.qua.dep.QuarkusAugmentor] Beginning quarkus augmentation
19:28:25,432 INFO  [org.jbo.threads] JBoss Threads version 3.0.0.Alpha4
19:28:25,638 WARN  [io.qua.config] Unrecognized configuration key "quarkus.undertow.resources" provided
19:28:25,651 ERROR [io.qua.dev.DevModeMain] Failed to start quarkus: java.lang.RuntimeException: org.jboss.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.deployment.logging.LoggingResourceProcessor#setupLoggingStaticInit threw an exception: java.lang.Error: java.lang.NoSuchFieldException: override
	at io.quarkus.runner.RuntimeRunner.run(RuntimeRunner.java:134)
	at io.quarkus.dev.DevModeMain.doStart(DevModeMain.java:105)
	at io.quarkus.dev.DevModeMain.main(DevModeMain.java:66)
Caused by: org.jboss.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.deployment.logging.LoggingResourceProcessor#setupLoggingStaticInit threw an exception: java.lang.Error: java.lang.NoSuchFieldException: override
	at org.jboss.builder.Execution.run(Execution.java:123)
	at org.jboss.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:136)
	at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:110)
	at io.quarkus.runner.RuntimeRunner.run(RuntimeRunner.java:99)
	... 2 more
Caused by: java.lang.Error: java.lang.NoSuchFieldException: override
	at org.jboss.classfilewriter.DefaultClassFactory$1.run(DefaultClassFactory.java:55)
	at org.jboss.classfilewriter.DefaultClassFactory$1.run(DefaultClassFactory.java:44)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:551)
	at org.jboss.classfilewriter.DefaultClassFactory.<init>(DefaultClassFactory.java:44)
	at org.jboss.classfilewriter.DefaultClassFactory.<clinit>(DefaultClassFactory.java:38)
	at org.jboss.classfilewriter.ClassFile.defineInternal(ClassFile.java:298)
	at org.jboss.classfilewriter.ClassFile.define(ClassFile.java:277)
	at org.jboss.invocation.proxy.AbstractClassFactory.defineClass(AbstractClassFactory.java:200)
	at org.jboss.invocation.proxy.AbstractClassFactory.newInstance(AbstractClassFactory.java:263)
	at org.jboss.invocation.proxy.ProxyFactory.newInstance(ProxyFactory.java:270)
	at io.quarkus.deployment.recording.BytecodeRecorderImpl$MethodRecorder.getRecordingProxy(BytecodeRecorderImpl.java:190)
	at io.quarkus.deployment.recording.BytecodeRecorderImpl.getRecordingProxy(BytecodeRecorderImpl.java:150)
	at io.quarkus.deployment.ExtensionLoader.lambda$loadStepsFrom$64(ExtensionLoader.java:411)
	at io.quarkus.deployment.ExtensionLoader$1.execute(ExtensionLoader.java:502)
	at org.jboss.builder.BuildContext.run(BuildContext.java:413)
	at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
	at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1998)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1525)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1416)
	at java.base/java.lang.Thread.run(Thread.java:835)
	at org.jboss.threads.JBossThread.run(JBossThread.java:479)
Caused by: java.lang.NoSuchFieldException: override
	at java.base/java.lang.Class.getDeclaredField(Class.java:2417)
	at org.jboss.classfilewriter.DefaultClassFactory$1.run(DefaultClassFactory.java:53)
	... 20 more

@gsmet gsmet added the kind/bug Something isn't working label Mar 25, 2019
@gsmet gsmet modified the milestone: 0.13.0 Mar 25, 2019
@gsmet
Copy link
Member

gsmet commented Mar 25, 2019

@stuartwdouglas @dmlloyd I see there is now a ClassFactory abstraction in jboss-classfilewriter but AFAICS the only implementation in the jar is one not suitable for JDK 12.

Is there any plan to fix that?

(with Quarkus being bleeding edge, there's a good chance people will play with it with the latest JDKs)

@dmlloyd
Copy link
Member

dmlloyd commented Mar 25, 2019

I believe that the preferred solution is still to drop jboss-classfilewriter but I don't think anyone is working that change at the moment.

@gunnarmorling
Copy link
Contributor

Just running into this with JDK 13; reading the discussion in #819, would it perhaps make sense to use ByteBuddy for that proxy generation?

@dmlloyd
Copy link
Member

dmlloyd commented May 7, 2019

We already have a number of bytecode creation tools at our disposal. I'd say that we should use Gizmo to generate these proxies; it shouldn't be too hard to do.

@patelapurv16
Copy link

Happened to come across the same issue with JRE 12, but the issue is solved with JRE 8.

@rsvoboda
Copy link
Member

@dmlloyd @stuartwdouglas any plans to make Quarkus run on java 12 and java 13 ?

@dmlloyd
Copy link
Member

dmlloyd commented Jun 24, 2019

Some day, for sure, because we'll want to support the next LTS version. But supporting 11 is a prerequisite.

@krzyk
Copy link

krzyk commented Jul 2, 2019

I just want to support what was written in #1534 (comment):

(with Quarkus being bleeding edge, there's a good chance people will play with it with the latest JDKs)

I use JDK 12 (with --enable-preview - it would be good to test if preview features also work with byte code generator you are using) and plan to test out JDK 13 before it is released. And I also wanted to give Quarkus a chance, but lack of latest Java version support for a bleeding edge is quite sad.

@JurrianFahner
Copy link

The problem stil exists in 0.21.1 version

@gsmet
Copy link
Member

gsmet commented Aug 21, 2019

Yes, it does, we haven't changed anything in this regard.

The idea is that we should get rid of the JBoss Invocation dependency which uses JBoss ClassFileWriter:

import org.jboss.invocation.proxy.ProxyConfiguration;
import org.jboss.invocation.proxy.ProxyFactory;

It's used in BytecodeRecorderImpl and QuarkusUnitTest AFAICS.

As they are build time code and test infrastructure, I think we can use a dynamic proxy. It will be a bit more code but it should work OK.

@gwenneg interested in this one?

@gwenneg
Copy link
Member

gwenneg commented Aug 21, 2019

@gsmet Yes, I'll gladly help on this one. I'm not sure there will be a PR ready for 0.22.0 though, I'll be pretty busy until the release.

@gwenneg gwenneg self-assigned this Aug 21, 2019
@geoand
Copy link
Contributor

geoand commented Sep 1, 2019

@gwenneg Is this something you started looking into? If not, I think it's something I can potentially get in before the next release

@gwenneg
Copy link
Member

gwenneg commented Sep 1, 2019

@geoand I took a quick look at it and didn't find how to solve this with dynamic proxies only, then I started looking for a way to do it with Gizmo but I didn't spend much time on it and won't be able to until 0.22.0. Do not hesitate do submit a PR to fix this issue in 0.22.0 :)

@geoand
Copy link
Contributor

geoand commented Sep 1, 2019

Thanks for the info. I'll take a look at a Gizmo based solution, hopefully I can have it in time for 0.22

@geoand
Copy link
Contributor

geoand commented Sep 1, 2019

Now that I think about it more it might not be wise to get such a change in so close to release even if I do have a proper replacement.
In any case I'll work on it and we'll see how it goes.

geoand added a commit to geoand/quarkus that referenced this issue Sep 2, 2019
This is first step to allow the project to build on JDK 12+
Relates to: quarkusio#1534
@geoand
Copy link
Contributor

geoand commented Sep 2, 2019

I opened #3810 that allows for removing jboss-invocation but doesn't yet allow building on JDK 12 (although it gets closer than the current state)

@gwenneg gwenneg assigned geoand and unassigned gwenneg Sep 2, 2019
geoand added a commit to geoand/quarkus that referenced this issue Sep 6, 2019
This makes sense for Quarkus where the ClassLoader is under our control.
The benefit is that proxy classes can be generated no matter what JDK
version is being used (so now proxies can be generated even in JDK 12+)

Fixes: quarkusio#1534
geoand added a commit to geoand/quarkus that referenced this issue Sep 6, 2019
This makes sense for Quarkus where the ClassLoader is under our control.
The benefit is that proxy classes can be generated no matter what JDK
version is being used (so now proxies can be generated even in JDK 12+)

Fixes: quarkusio#1534
@geoand
Copy link
Contributor

geoand commented Sep 6, 2019

#3906 should take care of the issue for good

@gsmet gsmet added this to the 0.23.0 milestone Sep 12, 2019
nmasse-itix added a commit to nmasse-itix/rhforum-2019-quotegame that referenced this issue Apr 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.