halcyon / asdf-java

A Java plugin for asdf-vm.
MIT License
454 stars 86 forks source link

Latest Adoptium/AdoptOpenJDK LTS versions do not install binaries #167

Closed bfrengley closed 2 years ago

bfrengley commented 2 years ago

Description

Adoptium (formerly AdoptOpenJDK) JDKs are generally supported by asdf-java (see #158). However, with the most recent LTS releases of the JDK, Adoptium/AdoptOpenJDK also releases static libs (see their release page for JDK 11.0.13+8 as an example).

These static lib releases are picked up by asdf-java (see https://github.com/halcyon/asdf-java/blob/797b8c199cd4eb1729e802fd0e4e7ffd5ec43884/data/jdk-linux-x86_64.tsv#L41 for example) and are selected due to being last in the release list (due to tail -n 1 in https://github.com/halcyon/asdf-java/blob/797b8c199cd4eb1729e802fd0e4e7ffd5ec43884/bin/functions#L74). asdf-java only selects a single archive to download/install for an installation, so it only selects the static libs archive which does not include binaries and therefore installing the affected versions does not install a usable JDK or javac.

This issue affects four different Adoptium/AdoptOpenJDK releases, all of which are LTS releases:

tmp.pLplZRHBjQ ❯❯❯ rg 'static-libs' /tmp/asdf-java.cache/releases-linux-x86_64.tsv | awk '{print $1}'
adoptopenjdk-11.0.13+8
adoptopenjdk-11.0.13+8
adoptopenjdk-17.0.1+12
adoptopenjdk-17.0.1+12
temurin-11.0.13+8
temurin-11.0.13+8
temurin-17.0.1+12
temurin-17.0.1+12

Other Adoptium/AdoptOpenJDK releases work correctly (including previous releases of JDK 11 and 17) because Adoptium did not publish static libs for those releases.

Environment

OS: Debian GNU/Linux bookworm/sid on Windows 10 x86_64 (WSL2) CPU: Intel i7-11700

Replication steps

  1. Run asdf install java temurin-11.0.13+8
  2. Run asdf shell java temurin-11.0.13+8
  3. Run asdf which javac

Expected outcome

Temurin JDK 11.0.13+8 is installed and asdf which javac succeeds.

Actual outcome

asdf-java installs the Temurin JDK 11.0.13+8 static libs only which does not include binaries, so asdf cannot find javac:

tmp.pLplZRHBjQ ❯❯❯ asdf install java temurin-11.0.13+8
############################################################################################################ 100.0%############################################################################################################ 100.0%
OpenJDK11U-static-libs-musl_x64_alpine-linux_hotspot_11.0.13_8.tar.gz
OpenJDK11U-static-libs-musl_x64_alpine-linux_hotspot_11.0.13_8.tar.gz: OK
tmp.pLplZRHBjQ ❯❯❯ asdf shell java temurin-11.0.13+8
tmp.pLplZRHBjQ ❯❯❯ asdf which javac
unknown command: javac. Perhaps you have to reshim?
✘ tmp.pLplZRHBjQ ❯❯❯ asdf where java
/home/ben/.asdf/installs/java/temurin-11.0.13+8
tmp.pLplZRHBjQ ❯❯❯ exa -T $(asdf where java)
/home/ben/.asdf/installs/java/temurin-11.0.13+8
└── lib
   └── static
      └── linux-amd64
         └── musl
            ├── libattach.a
            ├── libawt.a
            ├── libawt_headless.a
            ├── libdt_socket.a
            ├── libextnet.a
            ├── libfdlibm.a
            ├── libfontmanager.a
            ├── libinstrument.a
            ├── libj2gss.a
            ├── libj2pcsc.a
            ├── libj2pkcs11.a
            ├── libjaas.a
            ├── libjava.a
            ├── libjavajpeg.a
            ├── libjawt.a
            ├── libjdwp.a
            ├── libjimage.a
            ├── libjli.a
            ├── libjsig.a
            ├── libjsound.a
            ├── liblcms.a
            ├── libmanagement.a
            ├── libmanagement_agent.a
            ├── libmanagement_ext.a
            ├── libmlib_image.a
            ├── libnet.a
            ├── libnio.a
            ├── libprefs.a
            ├── librmi.a
            ├── libsaproc.a
            ├── libsctp.a
            ├── libsunec.a
            ├── libunpack.a
            ├── libverify.a
            └── libzip.a
fairbanksg commented 2 years ago

This also affects macOS.

$ asdf install java temurin-11.0.13+8
########################### 100.0%
########################### 100.0%
OpenJDK11U-static-libs_x64_mac_hotspot_11.0.13_8.tar.gz
OpenJDK11U-static-libs_x64_mac_hotspot_11.0.13_8.tar.gz: OK
Integrating with /usr/libexec/java_home needs root permission for it to create folders under /Library/Java/JavaVirtualMachines
cp: /private/var/folders/f0/2hl24lbx1nzdqzbp7yl6trp00000gp/T/asdf-java.dxeLX7Rc/jdk-11.0.13+8-static-libs/Contents/MacOS: No such file or directory
cp: /private/var/folders/f0/2hl24lbx1nzdqzbp7yl6trp00000gp/T/asdf-java.dxeLX7Rc/jdk-11.0.13+8-static-libs/Contents/Info.plist: No such file or directory
chadlwilson commented 2 years ago

Fix for this looks to be at #166

joschi commented 2 years ago

There was an issue in the upstream project providing the release metadata (https://github.com/joschi/java-metadata/issues/23).

The issue should be fixed since https://github.com/halcyon/asdf-java/commit/7e886b44a83c39d970b3243a1bb64cf49d335a97.

fairbanksg commented 2 years ago

👍 After updating the plugin, I was able to install the correct temurin-11 and temurin-17.

bfrengley commented 2 years ago

The issue should be fixed since 7e886b4.

It now works for me as well, thanks @joschi!