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

Created on 16 Mar 2019  路  18Comments  路  Source: quarkusio/quarkus

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!)_

kinbug

Most helpful comment

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

All 18 comments

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

@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)

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.

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

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.

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

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

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

I just want to support what was written in https://github.com/quarkusio/quarkus/issues/1534#issuecomment-476261148:

(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.

The problem stil exists in 0.21.1 version

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?

@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 Is this something you started looking into? If not, I think it's something I can potentially get in before the next release

@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 :)

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

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.

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)

3906 should take care of the issue for good

Was this page helpful?
0 / 5 - 0 ratings