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

Not downloading aarch64 (ARM64) version of java when running on Apple M1 #14

Closed
martonsz opened this issue Dec 16, 2022 · 7 comments · Fixed by Jabba-Team/index-generator#6
Labels
enhancement New feature or request

Comments

@martonsz
Copy link

I'm not getting the arm64 version of java on my MacBook Pro M1

In the following example, I'm installing [email protected] which exists in both darwin/aarch64 and darwin/amd64 in the index.json
The amd64 version is downloaded instead of the aarch64.

❯ jabba install [email protected]
Downloading [email protected] (https://api.foojay.io/disco/v3.0/ids/098fa753a35703dfe96f59e504d1b6af/redirect)
159012626/159012626
Extracting /var/folders/dx/2g7_y93s609bdsl5_87jg8pc0000gn/T/jabba-d-859770548 to /Users/marton.szucs/.jabba/jdk/[email protected]
[email protected] -> /Users/marton.szucs/.jabba/jdk/[email protected]

The workaround is to download using an URL to the aarch64 version

❯ jabba install 8.0.352-zulu-arm=tgz+https://api.foojay.io/disco/v3.0/ids/c3f7c076bf335d1061c74f7fab42bb89/redirect
Downloading 8.0.352-zulu-arm (https://api.foojay.io/disco/v3.0/ids/c3f7c076bf335d1061c74f7fab42bb89/redirect)
106088447/106088447
Extracting /var/folders/dx/2g7_y93s609bdsl5_87jg8pc0000gn/T/jabba-d-3868316553 to /Users/marton.szucs/.jabba/jdk/8.0.352-zulu-arm
❯ jabba --version
0.12.0

❯ uname -a
Darwin AMAYXVXTHQVW1 21.6.0 Darwin Kernel Version 21.6.0: Sun Nov  6 23:31:13 PST 2022; root:xnu-8020.240.14~1/RELEASE_ARM64_T6000 arm64
@nicerloop
Copy link

It seems that GOOS and GOARCH are used to get available release/url list, meaning these are fixed at build time.

releaseMap, err = LsRemote(runtime.GOOS, runtime.GOARCH)

Did you build a native arm jabba from source, or did you use the amd64 binary ?

@martonsz
Copy link
Author

martonsz commented Jan 1, 2023

I used the one that is downloaded when running the installer. Which is the darwin-amd64 version.

I didn't know that this was decided at compile time. That makes it even more problematic because I want to be able to download both AMD and ARM Java.
Some projects we are using contains libraries with AMD binaries (that doesn't work on our Apple M1 MacBooks). So we are forced to run AMD-java with Rossetta 2 on some projects :(

I have built a darwin-arm jabba from source. But it doesn't list anything with ls-remote.
I added darwin/arm64 to the makefile.

❯ ./jabba-0.12.0-darwin-arm64 ls-remote

❯ ./jabba-0.12.0-darwin-amd64 ls-remote |head -n2
[email protected]
aoj@16

❯ file jabba-0.12.0-darwin-arm64 jabba-0.12.0-darwin-amd64
jabba-0.12.0-darwin-arm64: Mach-O 64-bit executable arm64
jabba-0.12.0-darwin-amd64: Mach-O 64-bit executable x86_64

@martonsz
Copy link
Author

martonsz commented Jan 1, 2023

When I'm debugging the application on my MacBook I get the following values for os and arch when running the install command.

releaseMap, err = LsRemote(runtime.GOOS, runtime.GOARCH)

func LsRemote(os, arch string) (map[*semver.Version]string, error) {

os = darwin
arch = arm64

But the index.json is using the nameaarch64 instead of arm64

jabba/index.json

Line 3367 in a0d6422

"aarch64": {

The ls-remote command is able to override the os and arch values. That would be great for the install command. So I can install both a AMD and ARM version of java. But I think that there will be an issue with duplicate names right?

jabba/jabba.go

Lines 165 to 166 in a0d6422

os, _ := cmd.Flags().GetString("os")
arch, _ := cmd.Flags().GetString("arch")

❯ jabba ls-remote --arch aarch64 | head -n2
[email protected]
corretto@19

@patrick-mccourt patrick-mccourt added the enhancement New feature or request label Jan 3, 2023
@patrick-mccourt
Copy link

I don't think there was ever much multi-arch support in Jabba originally but it's been requested in other ways before. (i.e. 64 bit Windows users wanting to also install 32-bit java).

Definitely something worth adding though. I would like to bring all the go modules up to date as a first step then I can take a look at this.

@nicerloop
Copy link

It is probably better to fix the index from darwin/aarch64 to darwin/amd64 during generation.
See Jabba-Team/index-generator#5

@nicerloop
Copy link

@martonsz Can you check installing a jdk works on darwin/arm64 using a darwin/arm64 build?

@martonsz
Copy link
Author

martonsz commented Jan 7, 2023

@nicerloop Short answer: Version 0.12.1-rc works now on my MacBook with Apple M1

I have downloaded the binaries from GitHub and now the ARM64 version is downloading a JDK with the correct architecture.

❯ uname -a
Darwin MyMacBook 22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:03:51 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T6000 arm64

❯ cd ~/.jabba/bin
❯ l
lrwxr-xr-x    25 marton.szucs  7 Jan 09:15  jabba -> jabba-0.12.0-darwin-amd64
.rwxr-xr-x@  10M marton.szucs  7 Jan 09:02  jabba-0.12.0-darwin-amd64
.rwxr-xr-x@  10M marton.szucs  6 Jan 20:30  jabba-0.12.1-rc-darwin-amd64
.rwxr-xr-x@ 9.9M marton.szucs  6 Jan 20:29  jabba-0.12.1-rc-darwin-arm64

 
❯ find . -type f -exec bash -c 'echo -n $(shasum $1); echo -en "\t"; echo "$(file $1)"| cut -d " " -f 2-' - '{}' \;
a4c4ba8208b9cbe35ece5e0e8a1a93b50791df63 ./jabba-0.12.1-rc-darwin-arm64	Mach-O 64-bit executable arm64
7d2a883d1d068887a2475a55fd02803adf788f92 ./jabba-0.12.0-darwin-amd64	Mach-O 64-bit executable x86_64
752c4e91c7caf42b101d2ca4bb8bd78f66a83061 ./jabba-0.12.1-rc-darwin-amd64	Mach-O 64-bit executable x86_64

# Count number of java installations
❯ find . -type f -exec bash -c 'ln -sfv $1 jabba; source "/Users/marton.szucs/.jabba/jabba.sh"  ;jabba --version; jabba ls-remote | wc -l' - '{}' \;
jabba -> ./jabba-0.12.1-rc-darwin-arm64
0.12.1-rc
     210
jabba -> ./jabba-0.12.0-darwin-amd64
0.12.0
     586
jabba -> ./jabba-0.12.1-rc-darwin-amd64
0.12.1-rc
     586


# Installing the same java version with the different jabba binaries
# I have then checked if the installed java is running as "Intel" or "Apple" in the Activity Monitor. 
# "Intel" means that Rosetta 2 is translating from AMD to ARM
# "Apple" means that we are running at full speed! :)

# 0.12.0 AMD64
# This downloaded an AMD64 JDK that shows up as Intel in the Activity Monitor
❯ ln -sf jabba-0.12.0-darwin-amd64 jabba
❯ jabba install [email protected]
Downloading [email protected] (https://api.foojay.io/disco/v3.0/ids/8c8a5add5a04dcd698be0297764406ab/redirect)
195454218/195454218
Extracting /var/folders/dx/2g7_y93s609bdsl5_87jg8pc0000gn/T/jabba-d-3679347452 to /Users/marton.szucs/.jabba/jdk/[email protected]
[email protected] -> /Users/marton.szucs/.jabba/jdk/[email protected]


# 0.12.1 AMD64
# This downloaded exactly the same JDK as 0.12.0 AMD64
❯ for j in $(jabba ls); do jabba uninstall  $j; done
❯ ln -sf jabba-0.12.1-rc-darwin-amd64 jabba
❯ jabba install [email protected]
Downloading [email protected] (https://api.foojay.io/disco/v3.0/ids/8c8a5add5a04dcd698be0297764406ab/redirect)
195454218/195454218
Extracting /var/folders/dx/2g7_y93s609bdsl5_87jg8pc0000gn/T/jabba-d-2885191124 to /Users/marton.szucs/.jabba/jdk/[email protected]
[email protected] -> /Users/marton.szucs/.jabba/jdk/[email protected]


# 0.12.1 ARM64
# This downloads an ARM64 JDK that shows up as 'Apple' in the Activity Monitor 🥳
❯ for j in $(jabba ls); do jabba uninstall  $j; done
❯ ln -sf jabba-0.12.1-rc-darwin-arm64 jabba
❯ jabba install [email protected]
Downloading [email protected] (https://api.foojay.io/disco/v3.0/ids/e22625c9d01243314f0e711cfab17da8/redirect)
185292307/185292307
Extracting /var/folders/dx/2g7_y93s609bdsl5_87jg8pc0000gn/T/jabba-d-1665008487 to /Users/marton.szucs/.jabba/jdk/[email protected]
[email protected] -> /Users/marton.szucs/.jabba/jdk/[email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants