Skip to content

Jetbrains Runtime with GraalVM for Android Studio 4.0

Compare
Choose a tag to compare
@ganadist ganadist released this 14 Jun 14:43
· 33 commits to master since this release
771d7a8

DO NOT USE THIS Release for Android Studio 4.2

Description

  • Jetbrains Runtime is Java Runtime for IntelliJ platform.
    • This includes many improvements for modern desktop such as
      • Subpixel Anti-Aliasing
      • HiDPI Supports
      • Font Ligatures
    • Also this includes incremental build support for Room compiler
    • Most improvements are on Java APIs implementation.
  • GraalVM can run java program faster than OpenJDK about 10%-20%
  • This is a combination of Jetbrains Runtime and GraalVM, and brings improvements of both sides.

OSX 10.15(Catalina) installation

$ curl -LJO https://github.com/ganadist/graalvm-ce-builds/releases/download/vm-20.1.0/graalvm-ce-java8-darwin-amd64-20.1.0-jetbrains.tar.gz
$ sudo tar xf graalvm-ce-java8-darwin-amd64-20.1.0-jetbrains.tar.gz \
    -C /Library/Java/JavaVirtualMachines
$ sudo xattr -r -d com.apple.quarantine \
    /Library/Java/JavaVirtualMachines/graalvm-ce-java8-20.1.0-jetbrains
$ echo -n /Library/Java/JavaVirtualMachines/graalvm-ce-java8-20.1.0-jetbrains \
     > ~/Library/Preferences/AndroidStudio4.0/studio.jdk

And (re)start your Android Studio.

Restore JDK for Android Studio

If you want to restore your Android Studio JDK, Just run following command

$ rm -f ~/Library/Preferences/AndroidStudio4.0/studio.jdk

And (re)start your Android Studio.

Linux installation (For CentOS 7.6)

$ curl -LJO https://github.com/ganadist/graalvm-ce-builds/releases/download/vm-20.1.0/graalvm-ce-java8-linux-centos76-amd64-20.1.0-jetbrains.tar.gz
$ sudo mkdir -p /usr/lib/jvm
$ sudo tar xf graalvm-ce-java8-linux-centos76-amd64-20.1.0-jetbrains.tar.gz -C /usr/lib/jvm
$ echo -n /usr/lib/jvm/java-8-graalvm-jetbrains > ~/.AndroidStudio4.0/config/studio.jdk

And (re)start your Android Studio.

After Android Studio is started up

You can see About Android Studio splash window whether GraalVM is applied on Android Studio.
image

Setup JVM for Gradle wrapper on Android Studio

And If you want to apply this on Gradle Build System, please select
File -> Other Settings -> Default Project Structures... -> JDK location
And select directory location which you installed this JDK

If you have interest about this,

Please go AOSP issue tracker, and give star to appeal to Google. ;D

These binaries are built by

$ git clone https://github.com/graalvm/graal-jvmci-8
$ git clone https://github.com/graalvm/mandrel -b 20.1
$ git clone https://github.com/graalvm/mx

$ export JDK8_UPDATE_VERSION="242"
$ export JDK8_UPDATE_VERSION_SUFFIX=""
$ export JAVA_HOME=~/tools/android-studio-4.0/jre
$ export MX_HOME=$PWD/mx
$ export MX_PYTHON=python3
$ export PATH=$MX_HOME:$PATH

$ cd graal-jvmci-8
$ export JVMCI_VERSION="jvmci-20.1-b02"
$ git checkout $JVMCI_VERSION

# Most improvements of IntelliJ platform can be unlocked by JVM vendor name
$ sed -i 's/GraalVM Community/JetBrains s.r.o/g' src/share/vm/runtime/vm_version.cpp
$ mx --java-home $JAVA_HOME build
$ export JAVA_HOME=$PWD/openjdk1.8.0_242-release/linux-amd64/product

$ cd ../mandrel
$ mx --primary-suite-path $PWD/compiler --J @"-Xmx2g" --java-home=$JAVA_HOME gate --strict-mode --tags bootstraplite,build
$ sdk/mxbuild/linux-amd64/GRAALVM_3398AB5293_JAVA8/graalvm-3398ab5293-java8-20.1.0/bin/java -version
openjdk version "1.8.0_242-release"
OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
OpenJDK 64-Bit Server VM GraalVM 20.1.0 (build 25.242-b3-jvmci-20.1-b02, mixed mode)