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

Error extracting downloaded toolchain for JvmImplementation.J9 #19382

Closed
bigdaz opened this issue Dec 21, 2021 · 16 comments · Fixed by #19570
Closed

Error extracting downloaded toolchain for JvmImplementation.J9 #19382

bigdaz opened this issue Dec 21, 2021 · 16 comments · Fixed by #19570

Comments

@bigdaz
Copy link
Member

bigdaz commented Dec 21, 2021

When choosing the "Open J9" Java Toolchain implementation as described in the docs, there is an error extracting the the downloaded Toolchain distribution, resulting in a build failure.

Expected Behavior

The J9 toolchain distribution should be successfully downloaded, provisioned and used.

Current Behavior

The build fails with this error occurring when extracting the toolchain:

* What went wrong:
Execution failed for task ':compileJava'.
> Error while evaluating property 'javaCompiler' of task ':compileJava'
   > Failed to calculate the value of task ':compileJava' property 'javaCompiler'.
      > Unable to download toolchain matching these requirements: {languageVersion=11, vendor=ADOPTOPENJDK, implementation=J9}
         > Could not copy tar entry /Users/daz/dev/playground/java-tool/HOME/jdks/adoptopenjdk-11-x64-mac.tar.gz!1413453464414134534642/./ to '/Users/daz/dev/playground/java-tool/HOME/.tmp/expandedArchives/adoptopenjdk-11-x64-mac.tar.gz_09fc3ceb3762da51449cb5292ffc4737/1413453464414134534642/.'.
            > Failed to create parent directory '/Users/daz/dev/playground/java-tool/HOME/.tmp/expandedArchives/adoptopenjdk-11-x64-mac.tar.gz_09fc3ceb3762da51449cb5292ffc4737/1413453464414134534642' when creating directory '/Users/daz/dev/playground/java-tool/HOME/.tmp/expandedArchives/adoptopenjdk-11-x64-mac.tar.gz_09fc3ceb3762da51449cb5292ffc4737/1413453464414134534642/.'

Steps to Reproduce

  1. Checkout the main branch of https://github.com/bigdaz/gradle-toolchain-issues
  2. ./gradlew -g HOME build

Build scan URL: https://scans.gradle.com/s/ri37b7rtrdmf6/failure#1

@bigdaz
Copy link
Member Author

bigdaz commented Dec 21, 2021

Interesting: looking at the build scan there are a bunch of Unicode [U+0000] characters in the Tar entry name: https://scans.gradle.com/s/ri37b7rtrdmf6/failure?anchor=e30&focused-exception-line=0-1-2-3-4-5-0#1

@jbartok jbartok added in:toolchains Java Toolchains and removed to-triage labels Dec 22, 2021
@jbartok jbartok self-assigned this Dec 22, 2021
@jbartok jbartok added this to the 7.4 RC1 milestone Dec 22, 2021
@jbartok
Copy link
Member

jbartok commented Dec 23, 2021

Conclusions so far:

@jbartok
Copy link
Member

jbartok commented Dec 27, 2021

I've tracked this down to the exact change in Ant that introduces the code which is broken. It was introduced when they switched from 1.8 to 1.9.

The buggy code is this prefix shenanigans which wasn't there until then and in case of this particular compressed tar archive doesn't behave as expected.

I think that the tar.gz has some fault too, it probably has some header values which aren't correct and lead to the manifestation of the Ant bug.

What to do about it... The whole Ant project, as it's set up, in my opinion, just screams "we don't really need your contribution", I got a bit discouraged when even contemplating submitting a bug report, but that's probably what we'll need to do.

Or switch to some other tool for decompressing tars. I'm sure we can find something a bit more modern.

Let's discuss it internally.

@jbartok
Copy link
Member

jbartok commented Dec 27, 2021

We have decided to try to report this to Adoptium, maybe they'll fix the archive.

@ljacomet ljacomet removed this from the 7.4 RC1 milestone Dec 27, 2021
@bigdaz
Copy link
Member Author

bigdaz commented Dec 29, 2021

things work with other J9 implementation jars too properly, for example if the language level is 16

@jbartok This doesn't match my experience: I've tested with various languageVersion settings and get the same failure for some other versions.

Note that I start with an empty Gradle User Home in each case, to avoid getting false positives/negatives due to #19383

@jbartok
Copy link
Member

jbartok commented Dec 29, 2021

Ok, good to know. I've only tried with 11 and 16. I will double-check and report those to Adoptium too.

@jbartok
Copy link
Member

jbartok commented Jan 6, 2022

@bigdaz Turns out that the archives that are NOT ok are the regular IBM Semeru Runtime ones (ibm-semeru-open-jdk_x64_mac_xxx.tar.gz).

The ones that work, are different somehow, IBM doesn't provide Semeru archives for Java 14 & 15. What Adoptium provides are some kind of OpenJDK ones, called OpenJDK14U-jdk_x64_mac_openj9_14.0.2_12_openj9-0.21.0.tar.gz and OpenJDK15U-jdk_x64_mac_openj9_15.0.2_7_openj9-0.24.0.tar.gz. Anyways, these work just fine, we can ignore them for now.

I'm trying to contact IBM, let's see if they are willing to look into and do something about their Semeru archives. But, just as Ant, they really don't make it easy... Let's see if I can get anywhere with them.

@jbartok
Copy link
Member

jbartok commented Jan 7, 2022

Finally found the right place to submit the issue: ibmruntimes/Semeru-Runtimes#15

@ljacomet ljacomet added this to the 7.4 RC1 milestone Jan 12, 2022
@jbartok
Copy link
Member

jbartok commented Jan 12, 2022

Note to myself: in the meantime I should come up with a PR for replacing the Ant code when uncompressing the archives.

@ljacomet
Copy link
Member

This turns out to be somewhat tricky to fix, so will not be done for 7.4

@gabrieljones
Copy link

gabrieljones commented Jan 17, 2022

I just hit this in gradle v7.3.3 with:

build.gradle.kts

// ...
java {
  toolchain {
    languageVersion.set(JavaLanguageVersion.of(17))
  }
}
// ...

Works fine on my MacBook, but breaks on our Jenkins build servers.

build log

Downloading https://<corp proxy>/v3/binary/latest/17/ga/linux/x64/jdk/hotspot/normal/adoptopenjdk to /XXXXX/jenkins/.gradle/jdks/adoptopenjdk-17-x64-linux.tar.gz

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'pipeline-template'.
> Failed to calculate the value of task ':compileJava' property 'javaCompiler'.
   > Unable to download toolchain matching these requirements: {languageVersion=17, vendor=any, implementation=vendor-specific}
       > Could not copy tar entry /XXXXX/jenkins/.gradle/jdks/adoptopenjdk-17-x64-linux.tar.gz!jdk-17.0.1+12/lib/server/classes.jsa to '/XXXXX/jenkins/.gradle/jdks/jdk-17.0.1+12/lib/server/classes.jsa'.
          > /XXXXX/jenkins/.gradle/jdks/jdk-17.0.1+12/lib/server/classes.jsa (No such file or directory)

Anyone have a workaround yet?

Edit:
My current workaround is to predownload and install with curl and tar shell commands like so:

Jenkinsfile

// ...
    stage('pre download toolchain') {
      steps {
        sh 'curl https://<corp proxy>/v3/binary/latest/17/ga/linux/x64/jdk/hotspot/normal/adoptopenjdk --create-dirs -fsSLo ~/.gradle/jdks/adoptopenjdk-17-x64-linux.tar.gz'
        sh 'tar -xf ~/.gradle/jdks/adoptopenjdk-17-x64-linux.tar.gz -C ~/.gradle/jdks/'
      }
    }
// ...

@gabrieljones
Copy link

Unable to reproduce in Github Actions:

Downloading https://api.adoptopenjdk.net/v3/binary/latest/17/ga/linux/x64/jdk/hotspot/normal/adoptopenjdk to /home/runner/.gradle/jdks/adoptopenjdk-17-x64-linux.tar.gz
Installed adoptopenjdk-17-x64-linux.tar.gz into /home/runner/.gradle/jdks/jdk-17.0.1+12

-- https://github.com/gabrieljones/gradle-toolchain-issues/runs/4843169424

@jbartok
Copy link
Member

jbartok commented Mar 9, 2022

I just hit this in gradle v7.3.3 with:

build.gradle.kts

// ...
java {
  toolchain {
    languageVersion.set(JavaLanguageVersion.of(17))
  }
}
// ...

Works fine on my MacBook, but breaks on our Jenkins build servers.

build log

Downloading https://<corp proxy>/v3/binary/latest/17/ga/linux/x64/jdk/hotspot/normal/adoptopenjdk to /XXXXX/jenkins/.gradle/jdks/adoptopenjdk-17-x64-linux.tar.gz

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'pipeline-template'.
> Failed to calculate the value of task ':compileJava' property 'javaCompiler'.
   > Unable to download toolchain matching these requirements: {languageVersion=17, vendor=any, implementation=vendor-specific}
       > Could not copy tar entry /XXXXX/jenkins/.gradle/jdks/adoptopenjdk-17-x64-linux.tar.gz!jdk-17.0.1+12/lib/server/classes.jsa to '/XXXXX/jenkins/.gradle/jdks/jdk-17.0.1+12/lib/server/classes.jsa'.
          > /XXXXX/jenkins/.gradle/jdks/jdk-17.0.1+12/lib/server/classes.jsa (No such file or directory)

Anyone have a workaround yet?

Edit: My current workaround is to predownload and install with curl and tar shell commands like so:

Jenkinsfile

// ...
    stage('pre download toolchain') {
      steps {
        sh 'curl https://<corp proxy>/v3/binary/latest/17/ga/linux/x64/jdk/hotspot/normal/adoptopenjdk --create-dirs -fsSLo ~/.gradle/jdks/adoptopenjdk-17-x64-linux.tar.gz'
        sh 'tar -xf ~/.gradle/jdks/adoptopenjdk-17-x64-linux.tar.gz -C ~/.gradle/jdks/'
      }
    }
// ...

@gabrieljones this has nothing to do with this current issue; pls. file a separate issue for it and we'll try to investigate.

@jbartok jbartok modified the milestones: 7.5 RC1, 8.0 RC1 Mar 9, 2022
@EdGue42
Copy link

EdGue42 commented May 13, 2022

What is the reason that this has been moved out to Gradle 8?

Why do we have to wait for the next major version update?

Gradle 8 is really problematic, as A) who knows when it will be coming and B) there might be various issues preventing us to moving to gradle 8.

@amankr55
Copy link

@jbartok Is it fixed already with Gradle 7.5? If not, are there any plans to fix it with next Gradle release before Gradle 8?

@jbartok
Copy link
Member

jbartok commented Jul 22, 2022

@amankr55 changing the archive decompression library will only happen in Gradle 8, no sooner; it's too big of a change for us to do in a non-major release

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

Successfully merging a pull request may close this issue.

7 participants