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

RuntimeException using VirtualThreads with Jacoco #31375

Closed
HiddenSplioGuy opened this issue Feb 23, 2023 · 16 comments · Fixed by #42897
Closed

RuntimeException using VirtualThreads with Jacoco #31375

HiddenSplioGuy opened this issue Feb 23, 2023 · 16 comments · Fixed by #42897
Labels
kind/bug Something isn't working
Milestone

Comments

@HiddenSplioGuy
Copy link

HiddenSplioGuy commented Feb 23, 2023

Describe the bug

Building a quarkus 2.16.3 app using Virtual threads on JDK 19 I came up with the following error on runtime :

Method xxx of class 'XXX' uses @RunOnVirtualThread but the target JDK version doesn't support virtual threads. Please configure your build tool to target Java 19 or above.

I know my project is built correctly using the JDK19 because I checked the .class major version and it was correctly set to 63.

Expected behavior

No error.

Actual behavior

It seems like Quarkus pickups the first class file it found in the build directory to determine the project majorVersion.

I have run the compiledJavaVersion function on my built files and it always picked up AgentJar.class file (From Jacoco) with a majorVersion set to 49.
Here is another Jacoco class getting picked up by your algo after setting classDumpDir with :

classDumpDir = layout.buildDirectory.dir('jacoco/classpathdumps').get().asFile
KryoException.a0b9661061bc7653.class
majorFound : 49

How to Reproduce?

Output of uname -a or ver

Linux 91d7275ab5b8 5.15.79.1-microsoft-standard-WSL2 #1 SMP Wed Nov 23 01:01:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Output of java -version

openjdk version "19.0.2" 2023-01-17
OpenJDK Runtime Environment Temurin-19.0.2+7 (build 19.0.2+7)
OpenJDK 64-Bit Server VM Temurin-19.0.2+7 (build 19.0.2+7, mixed mode, sharing)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.16.3

Build tool (ie. output of mvnw --version or gradlew --version)

8.0.1

Additional information

Is quarkus-jacoco using the latest Jacoco version with jdk19 class support ?
https://github.com/jacoco/jacoco/releases

@HiddenSplioGuy HiddenSplioGuy added the kind/bug Something isn't working label Feb 23, 2023
@HiddenSplioGuy HiddenSplioGuy changed the title Quarkus pickup targetJavaVersion of libraries. RuntimeException using VirtualThreads with Jacoco Feb 23, 2023
@geoand
Copy link
Contributor

geoand commented Feb 24, 2023

Can you provide a sample application I can use to debug?

Thanks

@geoand geoand added the triage/needs-reproducer We are waiting for a reproducer. label Feb 24, 2023
@HiddenSplioGuy
Copy link
Author

Hi @geoand ,

I added a reproducer,

Thank you.

@geoand geoand removed the triage/needs-reproducer We are waiting for a reproducer. label Feb 24, 2023
@geoand
Copy link
Contributor

geoand commented Feb 24, 2023

Does one really need to execute it in a gitlab environment in order to see the issue?

@HiddenSplioGuy
Copy link
Author

I did not manage to reproduce the issue running the project locally.
So I'd say yes.

@geoand
Copy link
Contributor

geoand commented Feb 24, 2023

I see, thanks.

@geoand
Copy link
Contributor

geoand commented Feb 28, 2023

I'll try and have a look this week

geoand added a commit to geoand/quarkus that referenced this issue Mar 1, 2023
This might help in determining the cause of
quarkusio#31375
@geoand
Copy link
Contributor

geoand commented Mar 1, 2023

Hm.. Without being able to add a debbuger to this, it's very hard to figure ouw what's going on. I have opened #31510 to add more logging

geoand added a commit that referenced this issue Mar 1, 2023
Add logging to CompiledJavaVersionBuildStep
@HiddenSplioGuy
Copy link
Author

HiddenSplioGuy commented Mar 2, 2023

I personally used this small project which copycats the compiledJavaVersion function to debug this.
I just compiled the project into a jar and put in the repo which then allowed me to debug the behaviour of the function in the gitlab env.

gsmet pushed a commit that referenced this issue Mar 2, 2023
This might help in determining the cause of
#31375

(cherry picked from commit c00f211)
@manuito
Copy link

manuito commented Dec 18, 2023

Hi,

I had the same issue on another project, once again only if jacoco is integrated.

After investigation, the faulty component is https://github.com/quarkusio/quarkus/blob/main/core/deployment/src/main/java/io/quarkus/deployment/steps/CompiledJavaVersionBuildStep.java which define the javaVersion used at https://github.com/quarkusio/quarkus/blob/main/independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/EndpointIndexer.java#L831 to validate @RunOnVirtualThread compatibility.

To get the target javaVersion, it walks through build content and detect it from the first found .class. This seems to induce a lot of issues :

  • File walk is filesystem dependent : the order of listed file could depend on the natural sort order of the file system. Behavior could change between 2 different OS / FS. I have an example with jacoco agent entrypoint (ex build/tmp/.cache/expanded/zip_0bd0851504e6286cb5fc6f37a81e25cc/org/jacoco/agent/AgentJar.class) being the 1st loaded file on zfs but not on ext4, for same project, and same build stack. That's why this pb was first detected as an incompatibility with jacoco (& difficult to reproduce). Usually we should avoid any behavior based on file listing of class files.
  • The "maximum" javaVersion should be used here instead of the 1st one. Yes, it will have dramatic impact on perf (because we have to check all class files, so we shouldn't do that... But technically it would be more correct this way because here we are looking for a constraint on java version : the good one is the "max one"
  • There is no option to setup the javaVersion from the build options. Nothing is available for now on BuildSystemTargetBuildItem.buildSystemProps. Maybe the source and target java version from build tool should be shared here and used as the default java version definition

I know that detecting "automatically" the build target can be complex, and I'm out of idea for now on how to improve it. But this problem still exists and adding the use of build tool java version props could help to avoid it in most cases.

Regards.

@mjedwabn
Copy link

mjedwabn commented Jan 10, 2024

Ugly w/a:

build.gradle:

task quarkus31375wa(type: JavaCompile) {
    source = 'src/fixes/java'
    include 'AFixForQuarkus31375.java'
    classpath = sourceSets.main.compileClasspath
    destinationDir = new File('build/z')
}

src/fixes/java/AFixForQuarkus31375.java:

class AFixForQuarkus31375 {
}

then just include quarkus31375wa step before test, ex.
gradle clean quarkus31375wa test

@AntonFagerberg
Copy link
Contributor

We're experiencing the same issue but on Azure DevOps (with Java 21).
Works fine locally and on Azure DevOps after disabling the Jacoco gradle plugin.

@chwalker-fadv
Copy link

Any update on when this will be fixed?

@gsmet
Copy link
Member

gsmet commented Aug 29, 2024

@geoand have you seen this comment: #31375 (comment) ?

It looks interesting.

@geoand
Copy link
Contributor

geoand commented Aug 29, 2024

I have not. I'll take a look at some point

@gsmet
Copy link
Member

gsmet commented Aug 30, 2024

I think this is probably this problem occurring: #42884 that will be fixed by #42897.

@geoand
Copy link
Contributor

geoand commented Aug 30, 2024

Thanks

I'm totally out of that loop, so can't really comment now.

@quarkus-bot quarkus-bot bot added this to the 3.16 - main milestone Aug 30, 2024
@gsmet gsmet removed this from the 3.16 - main milestone Aug 30, 2024
@gsmet gsmet added this to the 3.14.2 milestone Aug 30, 2024
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
7 participants