JAVA_HOME is not exported for arm64 architecture

I see a strange behavior that I believe is a bug.

If I use the following config:

language: java
jdk: oraclejdk11

install:
    - echo $JAVA_HOME 
    - false

then the outcome is:

$ java -Xmx32m -version
openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment 18.9 (build 11.0.2+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.2+9, mixed mode)
$ javac -J-Xmx32m -version
javac 11.0.2
install.1
0.00s$ echo $JAVA_HOME
/usr/local/lib/jvm/openjdk11
0.00s$ false

But if I add arch: arm64 to the config:

language: java
jdk: oraclejdk11
arch: arm64

install:
    - echo $JAVA_HOME 
    - false

then JAVA_HOME is empty:

$ java -Xmx32m -version
openjdk version "11.0.5" 2019-10-15
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.5+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.5+10, mixed mode)
$ javac -J-Xmx32m -version
javac 11.0.5
install.1
0.02s$ echo $JAVA_HOME
0.01s$ false

Thanks for the report. I took a quick look.

We are installing adoptopenjdk-*-hotspot package https://github.com/travis-ci/travis-build/blob/0d3f1f908897605ec66c0d04b2e150741c4381dc/lib/travis/build/bash/travis_install_jdk.bash#L45-L57 I believe the expectation was that these packages would set necessary environment variables, but probably that was wrong. We will look into it.

Curiously,


does not mention $JAVA_HOME for Linux installation.

We can guess the value based on files at hand, and it would go something like this:

f=$(which javac)
while [[ -L $f ]]; do f=$(readlink $f); done
export JAVA_HOME=${f%/bin/*}

The result is something like this: https://travis-ci.org/BanzaiMan/travis_production_test/builds/641393626#L890

Could you add the snippet above in your build and see if that meets your needs?

Thanks.

Thank you for the workaround! It helps!

Did that work for you?

Yes!
But I think it would be better if it is consistent in both environments.

Not clear to me that would be possible, given that we use different mechanisms to install the Java packages.

Is that solicitation for a patch? :slight_smile:

Anyway,