├── .github └── workflows │ └── build.yml ├── .gitignore ├── README.md ├── android-wrapped-clang ├── android-wrapped-clang++ ├── buildjdk.sh ├── buildlibs.sh ├── ci_build_arch_aarch32.sh ├── ci_build_arch_aarch64.sh ├── ci_build_arch_x86.sh ├── ci_build_arch_x86_64.sh ├── ci_build_global.sh ├── cleanarchbuild.sh ├── clonejdk.sh ├── devkit.info.arm ├── devkit.info.arm64 ├── devkit.info.x86 ├── devkit.info.x86_64 ├── getlibs.sh ├── jre_override └── lib │ ├── fontconfig.Linux.bfc │ ├── fontconfig.Linux.properties.src │ ├── fontconfig.bfc │ ├── fontconfig.properties │ ├── fontconfig.properties.src │ └── fonts │ ├── Alibaba-PuHuiTi-Heavy.ttf │ ├── LucidaBrightDemiBold.ttf │ ├── LucidaBrightDemiItalic.ttf │ ├── LucidaBrightItalic.ttf │ ├── LucidaBrightRegular.ttf │ ├── LucidaSansDemiBold.ttf │ ├── LucidaSansRegular.ttf │ ├── LucidaTypewriterBold.ttf │ ├── LucidaTypewriterRegular.ttf │ └── fonts.dir ├── makejdkwithoutconfigure.sh ├── patches └── jdk17u_android.diff ├── removejdkdebuginfo.sh ├── repackjre.sh ├── setdevkitpath.sh └── tarjdk.sh /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build OpenJDK for Android 2 | 3 | on: 4 | workflow_dispatch: 5 | jobs: 6 | build_android: 7 | strategy: 8 | matrix: 9 | arch: [ "aarch32", "aarch64", "x86", "x86_64" ] 10 | fail-fast: false 11 | 12 | name: "Build for Android ${{matrix.arch}}" 13 | runs-on: ubuntu-24.04 14 | steps: 15 | - name: Checkout repository 16 | uses: actions/checkout@main 17 | - name: set up JDK 17 18 | uses: actions/setup-java@main 19 | with: 20 | java-version: 17 21 | distribution: temurin 22 | - name: Install build dependencies 23 | run: | 24 | sudo apt update 25 | sudo apt -y install systemtap-sdt-dev libxtst-dev libasound2-dev libelf-dev libfontconfig1-dev libx11-dev libxext-dev libxrandr-dev libxrender-dev libxtst-dev libxt-dev 26 | - name: Build with CI build script 27 | run: bash "ci_build_arch_${{matrix.arch}}.sh" 28 | - name: Upload JDK build output 29 | uses: actions/upload-artifact@main 30 | with: 31 | name: "jdk17-${{matrix.arch}}" 32 | path: jdk17*.tar.xz 33 | - name: Upload JRE build output 34 | uses: actions/upload-artifact@main 35 | with: 36 | name: 'jre17-${{matrix.arch}}' 37 | path: jre17*.tar.xz 38 | - name: Upload JRE debuginfo build output 39 | uses: actions/upload-artifact@main 40 | with: 41 | name: "jre17-debuginfo-${{matrix.arch}}" 42 | path: dizout 43 | 44 | pojav: 45 | needs: build_android 46 | runs-on: ubuntu-24.04 47 | steps: 48 | - name: Checkout repository 49 | uses: actions/checkout@main 50 | - name: Get jre17-aarch32 51 | uses: actions/download-artifact@main 52 | with: 53 | name: jre17-aarch32 54 | path: pojav 55 | - name: Get jre17-aarch64 56 | uses: actions/download-artifact@main 57 | with: 58 | name: jre17-aarch64 59 | path: pojav 60 | - name: Get jre17-x86 61 | uses: actions/download-artifact@main 62 | with: 63 | name: jre17-x86 64 | path: pojav 65 | - name: Get jre17-x86_64 66 | uses: actions/download-artifact@main 67 | with: 68 | name: jre17-x86_64 69 | path: pojav 70 | - name: Repack JRE 71 | run: bash "repackjre.sh" $GITHUB_WORKSPACE/pojav $GITHUB_WORKSPACE/pojav/jre17-pojav 72 | - name: Upload artifact 73 | uses: actions/upload-artifact@main 74 | with: 75 | name: jre17-pojav 76 | path: pojav/jre17-pojav/* 77 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | cups-*-source.tar.gz 2 | freetype-*.tar.gz 3 | freetype-* 4 | cups-* 5 | dummy_libs 6 | freetype-*-x86 7 | jdk1.8.0_* 8 | openjdk 9 | android-ndk-r* 10 | jre.tar.xz 11 | jreout 12 | .DS_Store 13 | .idea 14 | ios-missing-include/cups 15 | ios-missing-include/X11 16 | ios-missing-include/Xm 17 | dizout 18 | jreout 19 | jdkout 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # mobile-openjdk8-build-multiarch 4 | 5 | Based on http://openjdk.java.net/projects/mobile/android.html 6 | 7 | ## Building 8 | 9 | ### Setup 10 | #### Android 11 | - Download Android NDK r21 from https://developer.android.com/ndk/downloads/older_releases.html and place it in this directory (Can't automatically download because of EULA) 12 | - **Warning**: Do not attempt to build use newer or older NDK, it will lead to compilation errors. 13 | 14 | #### iOS 15 | - You should get latest Xcode (tested with Xcode 12). 16 | 17 | ### Platform and architecture specific environment variables 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 |
Environment variables
Platform - ArchitectureTARGETTARGET_JDK
Android - armv8/aarch64aarch64-linux-androidaarch64
Android - armv7/aarch32arm-linux-androideabiarm
Android - x86/i686i686-linux-androidx86
Android - x86_64/amd64x86_64-linux-androidx86_64
iOS/iPadOS - armv8/aarch64aarch64-macos-iosaarch64
58 | 59 | ### Run in this directory: 60 | ``` 61 | export BUILD_IOS=1 # only when targeting iOS, default is 0 (target Android) 62 | 63 | export BUILD_FREETYPE_VERSION=[2.6.2/.../2.10.4] # default: 2.10.0 64 | export JDK_DEBUG_LEVEL=[release/fastdebug/debug] # default: release 65 | export JVM_VARIANTS=[client/server] # default: client (aarch32), server (other architectures) 66 | 67 | # Setup NDK, run once (Android only) 68 | ./extractndk.sh 69 | ./maketoolchain.sh 70 | 71 | # Get CUPS, Freetype and build Freetype 72 | ./getlibs.sh 73 | ./buildlibs.sh 74 | 75 | # Clone JDK, run once 76 | ./clonejdk.sh 77 | 78 | # Configure JDK and build, if no configuration is changed, run makejdkwithoutconfigure.sh instead 79 | ./buildjdk.sh 80 | 81 | # Pack the built JDK 82 | ./removejdkdebuginfo.sh 83 | ./tarjdk.sh 84 | ``` 85 | 86 | 87 | -------------------------------------------------------------------------------- /android-wrapped-clang: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [[ "$1" = "--version" ]]; then 3 | echo "${TARGET}-gcc (GCC) 14.1 20240507 (release)" 4 | echo "Copyright (C) Free Software Foundation, Inc." 5 | echo "This is free software; see the source for copying conditions. There is NO" 6 | echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." 7 | else 8 | exec $thecc -Wno-unknown-warning-option "${@/-fno-var-tracking-assignments/}" 9 | # exec $thecc "$theargs" 10 | fi 11 | -------------------------------------------------------------------------------- /android-wrapped-clang++: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [[ "$1" = "--version" ]]; then 3 | echo "${TARGET}-g++ (GCC) 14.1 20240507 (release)" 4 | echo "Copyright (C) Free Software Foundation, Inc." 5 | echo "This is free software; see the source for copying conditions. There is NO" 6 | echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." 7 | else 8 | # theargs= 9 | exec $thecxx -Wno-unknown-warning-option "${@/-fno-var-tracking-assignments/}" 10 | # exec $thecxx "$theargs" 11 | fi 12 | -------------------------------------------------------------------------------- /buildjdk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | . setdevkitpath.sh 4 | 5 | export FREETYPE_DIR=$PWD/freetype-$BUILD_FREETYPE_VERSION/build_android-$TARGET_SHORT 6 | export CUPS_DIR=$PWD/cups 7 | export CFLAGS+=" -DLE_STANDALONE -Wno-error=int-conversion -Wno-error=implicit-function-declaration" # -I$FREETYPE_DIR -I$CUPS_DI 8 | if [[ "$TARGET_JDK" == "arm" ]] 9 | then 10 | export CFLAGS+=" -O3 -D__thumb__" 11 | else 12 | if [[ "$TARGET_JDK" == "x86" ]]; then 13 | export CFLAGS+=" -O3 -mstackrealign" 14 | else 15 | export CFLAGS+=" -O3" 16 | fi 17 | fi 18 | 19 | # if [ "$TARGET_JDK" == "aarch32" ] || [ "$TARGET_JDK" == "aarch64" ] 20 | # then 21 | # export CFLAGS+=" -march=armv7-a+neon" 22 | # fi 23 | 24 | # It isn't good, but need make it build anyways 25 | # cp -R $CUPS_DIR/* $ANDROID_INCLUDE/ 26 | 27 | # cp -R /usr/include/X11 $ANDROID_INCLUDE/ 28 | # cp -R /usr/include/fontconfig $ANDROID_INCLUDE/ 29 | 30 | chmod +x android-wrapped-clang 31 | chmod +x android-wrapped-clang++ 32 | ln -s -f /usr/include/X11 $ANDROID_INCLUDE/ 33 | ln -s -f /usr/include/fontconfig $ANDROID_INCLUDE/ 34 | platform_args="--with-toolchain-type=gcc \ 35 | --with-freetype-include=$FREETYPE_DIR/include/freetype2 \ 36 | --with-freetype-lib=$FREETYPE_DIR/lib \ 37 | OBJDUMP=${OBJDUMP} \ 38 | STRIP=${STRIP} \ 39 | NM=${NM} \ 40 | AR=${AR} \ 41 | OBJCOPY=${OBJCOPY} \ 42 | CXXFILT=${CXXFILT} \ 43 | " 44 | AUTOCONF_x11arg="--x-includes=$ANDROID_INCLUDE/X11" 45 | AUTOCONF_EXTRA_ARGS+="OBJCOPY=$OBJCOPY \ 46 | AR=$AR \ 47 | STRIP=$STRIP \ 48 | " 49 | 50 | export CFLAGS+=" -mllvm -polly -DANDROID" 51 | export LDFLAGS+=" -L$PWD/dummy_libs -Wl,--undefined-version" 52 | 53 | # Create dummy libraries so we won't have to remove them in OpenJDK makefiles 54 | mkdir -p dummy_libs 55 | ar cr dummy_libs/libpthread.a 56 | ar cr dummy_libs/librt.a 57 | ar cr dummy_libs/libthread_db.a 58 | 59 | # fix building libjawt 60 | ln -s -f $CUPS_DIR/cups $ANDROID_INCLUDE/ 61 | 62 | cd openjdk 63 | 64 | # Apply patches 65 | git reset --hard 66 | git apply --reject --whitespace=fix ../patches/jdk17u_android.diff || echo "git apply failed (Android patch set)" 67 | 68 | # rm -rf build 69 | 70 | # --with-extra-cxxflags="$CXXFLAGS -Dchar16_t=uint16_t -Dchar32_t=uint32_t" \ 71 | # --with-extra-cflags="$CPPFLAGS" \ 72 | 73 | bash ./configure \ 74 | --with-version-pre=" " \ 75 | --openjdk-target=$TARGET \ 76 | --with-extra-cflags="$CFLAGS" \ 77 | --with-extra-cxxflags="$CFLAGS" \ 78 | --with-extra-ldflags="$LDFLAGS" \ 79 | --disable-precompiled-headers \ 80 | --disable-warnings-as-errors \ 81 | --enable-option-checking=fatal \ 82 | --enable-headless-only=yes \ 83 | --with-jvm-variants=$JVM_VARIANTS \ 84 | --with-jvm-features=-dtrace,-zero,-vm-structs,-epsilongc \ 85 | --with-cups-include=$CUPS_DIR \ 86 | --with-devkit=$TOOLCHAIN \ 87 | --with-native-debug-symbols=external \ 88 | --with-debug-level=$JDK_DEBUG_LEVEL \ 89 | --with-fontconfig-include=$ANDROID_INCLUDE \ 90 | $AUTOCONF_x11arg $AUTOCONF_EXTRA_ARGS \ 91 | --x-libraries=/usr/lib \ 92 | $platform_args || \ 93 | error_code=$? 94 | if [[ "$error_code" -ne 0 ]]; then 95 | echo "\n\nCONFIGURE ERROR $error_code , config.log:" 96 | cat config.log 97 | exit $error_code 98 | fi 99 | 100 | jobs=$(nproc) 101 | 102 | echo Running ${jobs} jobs to build the jdk 103 | 104 | cd build/${JVM_PLATFORM}-${TARGET_JDK}-${JVM_VARIANTS}-${JDK_DEBUG_LEVEL} 105 | make JOBS=$jobs images || \ 106 | error_code=$? 107 | if [[ "$error_code" -ne 0 ]]; then 108 | echo "Build failure, exited with code $error_code. Trying again." 109 | make JOBS=$jobs images 110 | fi 111 | -------------------------------------------------------------------------------- /buildlibs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | . setdevkitpath.sh 4 | cd freetype-$BUILD_FREETYPE_VERSION 5 | 6 | echo "Building Freetype" 7 | 8 | export PATH=$TOOLCHAIN/bin:$PATH 9 | ./configure \ 10 | --host=$TARGET \ 11 | --prefix=${PWD}/build_android-${TARGET_SHORT} \ 12 | --without-zlib \ 13 | --with-png=no \ 14 | --with-brotli=no \ 15 | --with-harfbuzz=no $EXTRA_ARGS \ 16 | || error_code=$? 17 | 18 | if [[ "$error_code" -ne 0 ]]; then 19 | echo "\n\nCONFIGURE ERROR $error_code , config.log:" 20 | cat ${PWD}/builds/unix/config.log 21 | exit $error_code 22 | fi 23 | 24 | CFLAGS=-fno-rtti CXXFLAGS=-fno-rtti make -j4 25 | make install 26 | -------------------------------------------------------------------------------- /ci_build_arch_aarch32.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | export TARGET=armv7a-linux-androideabi 5 | export TARGET_2=arm-linux-androideabi 6 | export TARGET_JDK=arm 7 | 8 | bash ci_build_global.sh 9 | 10 | -------------------------------------------------------------------------------- /ci_build_arch_aarch64.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | export TARGET=aarch64-linux-android 4 | export TARGET_JDK=aarch64 5 | 6 | bash ci_build_global.sh 7 | 8 | -------------------------------------------------------------------------------- /ci_build_arch_x86.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | export TARGET=i686-linux-android 5 | export TARGET_JDK=x86 6 | 7 | bash ci_build_global.sh 8 | 9 | -------------------------------------------------------------------------------- /ci_build_arch_x86_64.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | export TARGET=x86_64-linux-android 5 | export TARGET_JDK=x86_64 6 | 7 | bash ci_build_global.sh 8 | 9 | -------------------------------------------------------------------------------- /ci_build_global.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | . setdevkitpath.sh 4 | 5 | export JDK_DEBUG_LEVEL=release 6 | 7 | if [[ -d "$ANDROID_NDK_HOME" ]]; then 8 | echo "NDK already exists: $ANDROID_NDK_HOME" 9 | else 10 | echo "Downloading NDK" 11 | wget -nc -nv -O android-ndk-$NDK_VERSION-linux-x86_64.zip "https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-linux.zip" 12 | unzip -q android-ndk-$NDK_VERSION-linux-x86_64.zip 13 | fi 14 | cp devkit.info.${TARGET_SHORT} ${TOOLCHAIN} 15 | 16 | # Some modifies to NDK to fix 17 | 18 | ./getlibs.sh 19 | ./buildlibs.sh 20 | ./clonejdk.sh 21 | ./buildjdk.sh 22 | ./removejdkdebuginfo.sh 23 | ./tarjdk.sh 24 | -------------------------------------------------------------------------------- /cleanarchbuild.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # TODO or separate work 5 | 6 | -------------------------------------------------------------------------------- /clonejdk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | git clone --depth 1 https://github.com/openjdk/jdk17u openjdk 5 | -------------------------------------------------------------------------------- /devkit.info.arm: -------------------------------------------------------------------------------- 1 | DEVKIT_NAME="Android ARM" 2 | DEVKIT_TOOLCHAIN_PATH="$DEVKIT_ROOT/arm-linux-androideabi/bin" 3 | DEVKIT_SYSROOT="$DEVKIT_ROOT/sysroot" 4 | -------------------------------------------------------------------------------- /devkit.info.arm64: -------------------------------------------------------------------------------- 1 | DEVKIT_NAME="Android ARM64" 2 | DEVKIT_TOOLCHAIN_PATH="$DEVKIT_ROOT/aarch64-linux-android/bin" 3 | DEVKIT_SYSROOT="$DEVKIT_ROOT/sysroot" 4 | -------------------------------------------------------------------------------- /devkit.info.x86: -------------------------------------------------------------------------------- 1 | DEVKIT_NAME="Android X86" 2 | DEVKIT_TOOLCHAIN_PATH="$DEVKIT_ROOT/i686-linux-android/bin" 3 | DEVKIT_SYSROOT="$DEVKIT_ROOT/sysroot" 4 | -------------------------------------------------------------------------------- /devkit.info.x86_64: -------------------------------------------------------------------------------- 1 | DEVKIT_NAME="Android X86_64" 2 | DEVKIT_TOOLCHAIN_PATH="$DEVKIT_ROOT/x86_64-linux-android/bin" 3 | DEVKIT_SYSROOT="$DEVKIT_ROOT/sysroot" 4 | -------------------------------------------------------------------------------- /getlibs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # https://github.com/termux/termux-packages/blob/master/disabled-packages/openjdk-9-jre-headless/build.sh 3 | set -e 4 | 5 | . setdevkitpath.sh 6 | 7 | wget https://downloads.sourceforge.net/project/freetype/freetype2/$BUILD_FREETYPE_VERSION/freetype-$BUILD_FREETYPE_VERSION.tar.gz 8 | tar xf freetype-$BUILD_FREETYPE_VERSION.tar.gz 9 | git clone --depth 1 https://github.com/OpenPrinting/cups 10 | -------------------------------------------------------------------------------- /jre_override/lib/fontconfig.Linux.bfc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Vera-Firefly/android-openjdk-build/595ccf465931b4c52240e7b58525c982d3604b20/jre_override/lib/fontconfig.Linux.bfc -------------------------------------------------------------------------------- /jre_override/lib/fontconfig.Linux.properties.src: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. 3 | # 4 | 5 | # Version 6 | 7 | version=1 8 | # Component Font Mappings 9 | 10 | allfonts.chinese-gbk=-tlc-songti-medium-r-normal--*-%d-*-*-c-*-gbk-0 11 | allfonts.chinese-gb2312=-tlc-songti-medium-r-normal--*-%d-*-*-c-*-gb2312.1980-0 12 | allfonts.chinese-iso10646=-tlc-songti-medium-r-normal--*-%d-*-*-c-*-iso10646-1 13 | allfonts.chinese-big5=-tlc-songti-medium-r-normal--*-%d-*-*-c-*-big5-0 14 | allfonts.lucida=-b&h-lucidasans-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1 15 | 16 | serif.plain.japanese-x0201=-ricoh-mincho-medium-r-normal--*-%d-*-*-c-*-jisx0201.1976-0 17 | serif.plain.japanese-x0208=-ricoh-mincho-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0 18 | serif.plain.latin-1=-b&h-lucidabright-medium-r-normal--*-%d-*-*-p-*-iso8859-1 19 | 20 | serif.bold.japanese-x0201=-ricoh-mincho-medium-r-normal--*-%d-*-*-c-*-jisx0201.1976-0 21 | serif.bold.japanese-x0208=-ricoh-mincho-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0 22 | serif.bold.latin-1=-b&h-lucidabright-demibold-r-normal--*-%d-*-*-p-*-iso8859-1 23 | 24 | serif.italic.japanese-x0201=-ricoh-mincho-medium-r-normal--*-%d-*-*-c-*-jisx0201.1976-0 25 | serif.italic.japanese-x0208=-ricoh-mincho-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0 26 | serif.italic.latin-1=-b&h-lucidabright-medium-i-normal--*-%d-*-*-p-*-iso8859-1 27 | 28 | serif.bolditalic.japanese-x0201=-ricoh-mincho-medium-r-normal--*-%d-*-*-c-*-jisx0201.1976-0 29 | serif.bolditalic.japanese-x0208=-ricoh-mincho-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0 30 | serif.bolditalic.latin-1=-b&h-lucidabright-demibold-i-normal--*-%d-*-*-p-*-iso8859-1 31 | 32 | sansserif.plain.japanese-x0201=-ricoh-gothic-medium-r-normal--*-%d-*-*-c-*-jisx0201.1976-0 33 | sansserif.plain.japanese-x0208=-ricoh-gothic-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0 34 | sansserif.plain.latin-1=-b&h-lucidasans-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1 35 | 36 | sansserif.bold.japanese-x0201=-ricoh-gothic-medium-r-normal--*-%d-*-*-c-*-jisx0201.1976-0 37 | sansserif.bold.japanese-x0208=-ricoh-gothic-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0 38 | sansserif.bold.latin-1=-b&h-lucidasans-bold-r-normal-sans-*-%d-*-*-p-*-iso8859-1 39 | 40 | sansserif.italic.japanese-x0201=-ricoh-gothic-medium-r-normal--*-%d-*-*-c-*-jisx0201.1976-0 41 | sansserif.italic.japanese-x0208=-ricoh-gothic-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0 42 | sansserif.italic.latin-1=-b&h-lucidasans-medium-i-normal-sans-*-%d-*-*-p-*-iso8859-1 43 | 44 | sansserif.bolditalic.japanese-x0201=-ricoh-gothic-medium-r-normal--*-%d-*-*-c-*-jisx0201.1976-0 45 | sansserif.bolditalic.japanese-x0208=-ricoh-gothic-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0 46 | sansserif.bolditalic.latin-1=-b&h-lucidasans-bold-i-normal-sans-*-%d-*-*-p-*-iso8859-1 47 | 48 | monospaced.plain.japanese-x0201=-ricoh-mincho-medium-r-normal--*-%d-*-*-c-*-jisx0201.1976-0 49 | monospaced.plain.japanese-x0208=-ricoh-mincho-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0 50 | monospaced.plain.latin-1=-b&h-lucidatypewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1 51 | 52 | monospaced.bold.japanese-x0201=-ricoh-mincho-medium-r-normal--*-%d-*-*-c-*-jisx0201.1976-0 53 | monospaced.bold.japanese-x0208=-ricoh-mincho-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0 54 | monospaced.bold.latin-1=-b&h-lucidatypewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1 55 | 56 | monospaced.italic.japanese-x0201=-ricoh-mincho-medium-r-normal--*-%d-*-*-c-*-jisx0201.1976-0 57 | monospaced.italic.japanese-x0208=-ricoh-mincho-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0 58 | monospaced.italic.latin-1=-b&h-lucidatypewriter-medium-i-normal-sans-*-%d-*-*-m-*-iso8859-1 59 | 60 | monospaced.bolditalic.japanese-x0201=-ricoh-mincho-medium-r-normal--*-%d-*-*-c-*-jisx0201.1976-0 61 | monospaced.bolditalic.japanese-x0208=-ricoh-mincho-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0 62 | monospaced.bolditalic.latin-1=-b&h-lucidatypewriter-bold-i-normal-sans-*-%d-*-*-m-*-iso8859-1 63 | 64 | dialog.plain.japanese-x0201=-ricoh-gothic-medium-r-normal--*-%d-*-*-c-*-jisx0201.1976-0 65 | dialog.plain.japanese-x0208=-ricoh-gothic-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0 66 | dialog.plain.latin-1=-b&h-lucidasans-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1 67 | 68 | dialog.bold.japanese-x0201=-ricoh-gothic-medium-r-normal--*-%d-*-*-c-*-jisx0201.1976-0 69 | dialog.bold.japanese-x0208=-ricoh-gothic-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0 70 | dialog.bold.latin-1=-b&h-lucidasans-bold-r-normal-sans-*-%d-*-*-p-*-iso8859-1 71 | 72 | dialog.italic.japanese-x0201=-ricoh-gothic-medium-r-normal--*-%d-*-*-c-*-jisx0201.1976-0 73 | dialog.italic.japanese-x0208=-ricoh-gothic-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0 74 | dialog.italic.latin-1=-b&h-lucidasans-medium-i-normal-sans-*-%d-*-*-p-*-iso8859-1 75 | 76 | dialog.bolditalic.japanese-x0201=-ricoh-gothic-medium-r-normal--*-%d-*-*-c-*-jisx0201.1976-0 77 | dialog.bolditalic.japanese-x0208=-ricoh-gothic-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0 78 | dialog.bolditalic.latin-1=-b&h-lucidasans-bold-i-normal-sans-*-%d-*-*-p-*-iso8859-1 79 | 80 | dialoginput.plain.japanese-x0201=-ricoh-mincho-medium-r-normal--*-%d-*-*-c-*-jisx0201.1976-0 81 | dialoginput.plain.japanese-x0208=-ricoh-mincho-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0 82 | dialoginput.plain.latin-1=-b&h-lucidatypewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1 83 | 84 | dialoginput.bold.japanese-x0201=-ricoh-mincho-medium-r-normal--*-%d-*-*-c-*-jisx0201.1976-0 85 | dialoginput.bold.japanese-x0208=-ricoh-mincho-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0 86 | dialoginput.bold.latin-1=-b&h-lucidatypewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1 87 | 88 | dialoginput.italic.japanese-x0201=-ricoh-mincho-medium-r-normal--*-%d-*-*-c-*-jisx0201.1976-0 89 | dialoginput.italic.japanese-x0208=-ricoh-mincho-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0 90 | dialoginput.italic.latin-1=-b&h-lucidatypewriter-medium-i-normal-sans-*-%d-*-*-m-*-iso8859-1 91 | 92 | dialoginput.bolditalic.japanese-x0201=-ricoh-mincho-medium-r-normal--*-%d-*-*-c-*-jisx0201.1976-0 93 | dialoginput.bolditalic.japanese-x0208=-ricoh-mincho-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0 94 | dialoginput.bolditalic.latin-1=-b&h-lucidatypewriter-bold-i-normal-sans-*-%d-*-*-m-*-iso8859-1 95 | 96 | 97 | # Search Sequences 98 | 99 | sequence.allfonts=latin-1 100 | sequence.allfonts.Big5=latin-1,chinese-big5 101 | sequence.allfonts.Big5-HKSCS=latin-1,chinese-big5 102 | sequence.allfonts.GB18030=latin-1,chinese-gbk,chinese-iso10646 103 | sequence.allfonts.GBK=latin-1,chinese-gbk 104 | sequence.allfonts.GB2312=latin-1,chinese-gb2312 105 | sequence.allfonts.x-euc-jp-linux=latin-1,japanese-x0208,japanese-x0201 106 | sequence.allfonts.UTF-8.ja.JP=latin-1,japanese-x0208,japanese-x0201,chinese-iso10646 107 | sequence.allfonts.UTF-8.zh=latin-1,chinese-iso10646,japanese-x0208,japanese-x0201 108 | sequence.fallback=lucida,chinese-big5,chinese-iso10646,japanese-x0208 109 | 110 | # Exclusion Ranges 111 | exclusion.japanese-x0201=0390-03d6,2200-22ef,2701-27be 112 | exclusion.japanese-x0208=0390-03d6,2200-22ef,2701-27be 113 | 114 | # Font File Names 115 | filename.-b&h-lucidasans-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1=$JRE_LIB_FONTS/LucidaSansRegular.ttf 116 | filename.-b&h-lucidabright-medium-r-normal--*-%d-*-*-p-*-iso8859-1=$JRE_LIB_FONTS/LucidaBrightRegular.ttf 117 | filename.-b&h-lucidabright-demibold-r-normal--*-%d-*-*-p-*-iso8859-1=$JRE_LIB_FONTS/LucidaBrightDemiBold.ttf 118 | filename.-b&h-lucidabright-medium-i-normal--*-%d-*-*-p-*-iso8859-1=$JRE_LIB_FONTS/LucidaBrightItalic.ttf 119 | filename.-b&h-lucidabright-demibold-i-normal--*-%d-*-*-p-*-iso8859-1=$JRE_LIB_FONTS/LucidaBrightDemiItalic.ttf 120 | filename.-b&h-lucidasans-bold-r-normal-sans-*-%d-*-*-p-*-iso8859-1=$JRE_LIB_FONTS/LucidaSansDemiBold.ttf 121 | filename.-b&h-lucidasans-medium-i-normal-sans-*-%d-*-*-p-*-iso8859-1=$JRE_LIB_FONTS/LucidaSansRegular.ttf 122 | filename.-b&h-lucidasans-bold-i-normal-sans-*-%d-*-*-p-*-iso8859-1=$JRE_LIB_FONTS/LucidaSansDemiBold.ttf 123 | filename.-b&h-lucidatypewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1=$JRE_LIB_FONTS/LucidaTypewriterRegular.ttf 124 | filename.-b&h-lucidatypewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1=$JRE_LIB_FONTS/LucidaTypewriterBold.ttf 125 | filename.-b&h-lucidatypewriter-medium-i-normal-sans-*-%d-*-*-m-*-iso8859-1=$JRE_LIB_FONTS/LucidaTypewriterRegular.ttf 126 | filename.-b&h-lucidatypewriter-bold-i-normal-sans-*-%d-*-*-m-*-iso8859-1=$JRE_LIB_FONTS/LucidaTypewriterBold.ttf 127 | 128 | filename.-tlc-songti-medium-r-normal--*-%d-*-*-c-*-big5-0=$JRE_LIB_FONTS/Alibaba-PuHuiTi-Heavy.ttf 129 | filename.-tlc-songti-medium-r-normal--*-%d-*-*-c-*-iso10646-1=$JRE_LIB_FONTS/Alibaba-PuHuiTi-Heavy.ttf 130 | filename.-tlc-songti-medium-r-normal--*-%d-*-*-c-*-gbk-0=$JRE_LIB_FONTS/Alibaba-PuHuiTi-Heavy.ttf 131 | filename.-tlc-songti-medium-r-normal--*-%d-*-*-c-*-gb2312.1980-0=$JRE_LIB_FONTS/Alibaba-PuHuiTi-Heavy.ttf 132 | filename.-ricoh-gothic-medium-r-normal--*-%d-*-*-c-*-jisx0201.1976-0=$JRE_LIB_FONTS/Alibaba-PuHuiTi-Heavy.ttf 133 | filename.-ricoh-gothic-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0=$JRE_LIB_FONTS/Alibaba-PuHuiTi-Heavy.ttf 134 | filename.-ricoh-mincho-medium-r-normal--*-%d-*-*-c-*-jisx0201.1976-0=$JRE_LIB_FONTS/Alibaba-PuHuiTi-Heavy.ttf 135 | filename.-ricoh-mincho-medium-r-normal--*-%d-*-*-c-*-jisx0208.1983-0=$JRE_LIB_FONTS/Alibaba-PuHuiTi-Heavy.ttf 136 | 137 | 138 | # AWT X11 font paths 139 | awtfontpath.chinese-big5=$JRE_LIB_FONTS 140 | awtfontpath.chinese-gb2312=$JRE_LIB_FONTS 141 | awtfontpath.chinese-gbk=$JRE_LIB_FONTS 142 | awtfontpath.chinese-iso10646=$JRE_LIB_FONTS 143 | awtfontpath.japanese-x0201=$JRE_LIB_FONTS 144 | awtfontpath.japanese-x0208=$JRE_LIB_FONTS 145 | nese-iso10646=/usr/share/fonts/zh_CN/TrueType 146 | awtfontpath.japanese-x0201=/usr/share/fonts/ja/TrueType 147 | awtfontpath.japanese-x0208=/usr/share/fonts/ja/TrueType 148 | -------------------------------------------------------------------------------- /jre_override/lib/fontconfig.bfc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Vera-Firefly/android-openjdk-build/595ccf465931b4c52240e7b58525c982d3604b20/jre_override/lib/fontconfig.bfc -------------------------------------------------------------------------------- /jre_override/lib/fontconfig.properties: -------------------------------------------------------------------------------- 1 | version=1 2 | sequence.allfonts=default -------------------------------------------------------------------------------- /jre_override/lib/fontconfig.properties.src: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. 3 | # 4 | 5 | # Version 6 | 7 | version=1 8 | 9 | # Component Font Mappings 10 | 11 | 12 | serif.plain.latin-1=-b&h-lucidabright-medium-r-normal--*-%d-*-*-p-*-iso8859-1 13 | serif.bold.latin-1=-b&h-lucidabright-demibold-r-normal--*-%d-*-*-p-*-iso8859-1 14 | serif.italic.latin-1=-b&h-lucidabright-medium-i-normal--*-%d-*-*-p-*-iso8859-1 15 | serif.bolditalic.latin-1=-b&h-lucidabright-demibold-i-normal--*-%d-*-*-p-*-iso8859-1 16 | 17 | sansserif.plain.latin-1=-b&h-lucidasans-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1 18 | sansserif.bold.latin-1=-b&h-lucidasans-bold-r-normal-sans-*-%d-*-*-p-*-iso8859-1 19 | sansserif.italic.latin-1=-b&h-lucidasans-medium-i-normal-sans-*-%d-*-*-p-*-iso8859-1 20 | sansserif.bolditalic.latin-1=-b&h-lucidasans-bold-i-normal-sans-*-%d-*-*-p-*-iso8859-1 21 | 22 | monospaced.plain.latin-1=-b&h-lucidatypewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1 23 | monospaced.bold.latin-1=-b&h-lucidatypewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1 24 | monospaced.italic.latin-1=-b&h-lucidatypewriter-medium-i-normal-sans-*-%d-*-*-m-*-iso8859-1 25 | monospaced.bolditalic.latin-1=-b&h-lucidatypewriter-bold-i-normal-sans-*-%d-*-*-m-*-iso8859-1 26 | 27 | dialog.plain.latin-1=-b&h-lucidasans-medium-r-normal-sans-*-%d-*-*-p-*-iso8859-1 28 | dialog.bold.latin-1=-b&h-lucidasans-bold-r-normal-sans-*-%d-*-*-p-*-iso8859-1 29 | dialog.italic.latin-1=-b&h-lucidasans-medium-i-normal-sans-*-%d-*-*-p-*-iso8859-1 30 | dialog.bolditalic.latin-1=-b&h-lucidasans-bold-i-normal-sans-*-%d-*-*-p-*-iso8859-1 31 | 32 | dialoginput.plain.latin-1=-b&h-lucidatypewriter-medium-r-normal-sans-*-%d-*-*-m-*-iso8859-1 33 | dialoginput.bold.latin-1=-b&h-lucidatypewriter-bold-r-normal-sans-*-%d-*-*-m-*-iso8859-1 34 | dialoginput.italic.latin-1=-b&h-lucidatypewriter-medium-i-normal-sans-*-%d-*-*-m-*-iso8859-1 35 | dialoginput.bolditalic.latin-1=-b&h-lucidatypewriter-bold-i-normal-sans-*-%d-*-*-m-*-iso8859-1 36 | 37 | # Search Sequences 38 | 39 | sequence.allfonts=latin-1 40 | 41 | # Exclusion Ranges 42 | 43 | # Font File Names 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /jre_override/lib/fonts/Alibaba-PuHuiTi-Heavy.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Vera-Firefly/android-openjdk-build/595ccf465931b4c52240e7b58525c982d3604b20/jre_override/lib/fonts/Alibaba-PuHuiTi-Heavy.ttf -------------------------------------------------------------------------------- /jre_override/lib/fonts/LucidaBrightDemiBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Vera-Firefly/android-openjdk-build/595ccf465931b4c52240e7b58525c982d3604b20/jre_override/lib/fonts/LucidaBrightDemiBold.ttf -------------------------------------------------------------------------------- /jre_override/lib/fonts/LucidaBrightDemiItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Vera-Firefly/android-openjdk-build/595ccf465931b4c52240e7b58525c982d3604b20/jre_override/lib/fonts/LucidaBrightDemiItalic.ttf -------------------------------------------------------------------------------- /jre_override/lib/fonts/LucidaBrightItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Vera-Firefly/android-openjdk-build/595ccf465931b4c52240e7b58525c982d3604b20/jre_override/lib/fonts/LucidaBrightItalic.ttf -------------------------------------------------------------------------------- /jre_override/lib/fonts/LucidaBrightRegular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Vera-Firefly/android-openjdk-build/595ccf465931b4c52240e7b58525c982d3604b20/jre_override/lib/fonts/LucidaBrightRegular.ttf -------------------------------------------------------------------------------- /jre_override/lib/fonts/LucidaSansDemiBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Vera-Firefly/android-openjdk-build/595ccf465931b4c52240e7b58525c982d3604b20/jre_override/lib/fonts/LucidaSansDemiBold.ttf -------------------------------------------------------------------------------- /jre_override/lib/fonts/LucidaSansRegular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Vera-Firefly/android-openjdk-build/595ccf465931b4c52240e7b58525c982d3604b20/jre_override/lib/fonts/LucidaSansRegular.ttf -------------------------------------------------------------------------------- /jre_override/lib/fonts/LucidaTypewriterBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Vera-Firefly/android-openjdk-build/595ccf465931b4c52240e7b58525c982d3604b20/jre_override/lib/fonts/LucidaTypewriterBold.ttf -------------------------------------------------------------------------------- /jre_override/lib/fonts/LucidaTypewriterRegular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Vera-Firefly/android-openjdk-build/595ccf465931b4c52240e7b58525c982d3604b20/jre_override/lib/fonts/LucidaTypewriterRegular.ttf -------------------------------------------------------------------------------- /jre_override/lib/fonts/fonts.dir: -------------------------------------------------------------------------------- 1 | 49 2 | LucidaBrightRegular.ttf -b&h-lucidabright-medium-r-normal--0-0-0-0-p-0-gbk 3 | LucidaBrightItalic.ttf -b&h-lucidabright-medium-i-normal--0-0-0-0-p-0-gbk 4 | LucidaBrightDemiBold.ttf -b&h-lucidabright-demibold-r-normal--0-0-0-0-p-0-gbk 5 | LucidaBrightDemiItalic.ttf -b&h-lucidabright-demibold-i-normal--0-0-0-0-p-0-gbk 6 | LucidaSansRegular.ttf -b&h-lucidasans-medium-r-normal-sans-0-0-0-0-p-0-gbk 7 | LucidaSansDemiBold.ttf -b&h-lucidasans-bold-r-normal-sans-0-0-0-0-p-0-gbk 8 | LucidaTypewriterRegular.ttf -b&h-lucidatypewriter-medium-r-normal-sans-0-0-0-0-m-0-gbk 9 | LucidaTypewriterBold.ttf -b&h-lucidatypewriter-bold-r-normal-sans-0-0-0-0-m-0-gbk 10 | LucidaBrightRegular.ttf -b&h-lucidabright-medium-r-normal--0-0-0-0-p-0-gbk 11 | LucidaBrightItalic.ttf -b&h-lucidabright-medium-i-normal--0-0-0-0-p-0-gbk 12 | LucidaBrightDemiBold.ttf -b&h-lucidabright-demibold-r-normal--0-0-0-0-p-0-gbk 13 | LucidaBrightDemiItalic.ttf -b&h-lucidabright-demibold-i-normal--0-0-0-0-p-0-gbk 14 | LucidaSansRegular.ttf -b&h-lucidasans-medium-r-normal-sans-0-0-0-0-p-0-gbk 15 | LucidaSansDemiBold.ttf -b&h-lucidasans-bold-r-normal-sans-0-0-0-0-p-0-gbk 16 | LucidaTypewriterRegular.ttf -b&h-lucidatypewriter-medium-r-normal-sans-0-0-0-0-m-0-gbk 17 | LucidaTypewriterBold.ttf -b&h-lucidatypewriter-bold-r-normal-sans-0-0-0-0-m-0-gbk 18 | LucidaBrightRegular.ttf -b&h-lucidabright-medium-r-normal--0-0-0-0-p-0-gbk 19 | LucidaBrightItalic.ttf -b&h-lucidabright-medium-i-normal--0-0-0-0-p-0-gbk 20 | LucidaBrightDemiBold.ttf -b&h-lucidabright-demibold-r-normal--0-0-0-0-p-0-gbk 21 | LucidaBrightDemiItalic.ttf -b&h-lucidabright-demibold-i-normal--0-0-0-0-p-0-gbk 22 | LucidaSansRegular.ttf -b&h-lucidasans-medium-r-normal-sans-0-0-0-0-p-0-gbk 23 | LucidaSansDemiBold.ttf -b&h-lucidasans-bold-r-normal-sans-0-0-0-0-p-0-gbk 24 | LucidaTypewriterRegular.ttf -b&h-lucidatypewriter-medium-r-normal-sans-0-0-0-0-m-0-gbk 25 | LucidaTypewriterBold.ttf -b&h-lucidatypewriter-bold-r-normal-sans-0-0-0-0-m-0-gbk 26 | LucidaBrightRegular.ttf -b&h-lucidabright-medium-r-normal--0-0-0-0-p-0-gbk 27 | LucidaBrightItalic.ttf -b&h-lucidabright-medium-i-normal--0-0-0-0-p-0-gbk 28 | LucidaBrightDemiBold.ttf -b&h-lucidabright-demibold-r-normal--0-0-0-0-p-0-gbk 29 | LucidaBrightDemiItalic.ttf -b&h-lucidabright-demibold-i-normal--0-0-0-0-p-0-gbk 30 | LucidaSansRegular.ttf -b&h-lucidasans-medium-r-normal-sans-0-0-0-0-p-0-gbk 31 | LucidaSansDemiBold.ttf -b&h-lucidasans-bold-r-normal-sans-0-0-0-0-p-0-gbk 32 | LucidaTypewriterRegular.ttf -b&h-lucidatypewriter-medium-r-normal-sans-0-0-0-0-m-0-gbk 33 | LucidaTypewriterBold.ttf -b&h-lucidatypewriter-bold-r-normal-sans-0-0-0-0-m-0-gbk 34 | LucidaBrightRegular.ttf -b&h-lucidabright-medium-r-normal--0-0-0-0-p-0-gbk 35 | LucidaBrightItalic.ttf -b&h-lucidabright-medium-i-normal--0-0-0-0-p-0-gbk 36 | LucidaBrightDemiBold.ttf -b&h-lucidabright-demibold-r-normal--0-0-0-0-p-0-gbk 37 | LucidaBrightDemiItalic.ttf -b&h-lucidabright-demibold-i-normal--0-0-0-0-p-0-gbk 38 | LucidaSansRegular.ttf -b&h-lucidasans-medium-r-normal-sans-0-0-0-0-p-0-gbk 39 | LucidaSansDemiBold.ttf -b&h-lucidasans-bold-r-normal-sans-0-0-0-0-p-0-gbk 40 | LucidaTypewriterRegular.ttf -b&h-lucidatypewriter-medium-r-normal-sans-0-0-0-0-m-0-gbk 41 | LucidaTypewriterBold.ttf -b&h-lucidatypewriter-bold-r-normal-sans-0-0-0-0-m-0-gbk 42 | LucidaBrightRegular.ttf -b&h-lucidabright-medium-r-normal--0-0-0-0-p-0-gbk 43 | LucidaBrightItalic.ttf -b&h-lucidabright-medium-i-normal--0-0-0-0-p-0-gbk 44 | LucidaBrightDemiBold.ttf -b&h-lucidabright-demibold-r-normal--0-0-0-0-p-0-gbk 45 | LucidaBrightDemiItalic.ttf -b&h-lucidabright-demibold-i-normal--0-0-0-0-p-0-gbk 46 | LucidaSansRegular.ttf -b&h-lucidasans-medium-r-normal-sans-0-0-0-0-p-0-gbk 47 | LucidaSansDemiBold.ttf -b&h-lucidasans-bold-r-normal-sans-0-0-0-0-p-0-gbk 48 | LucidaTypewriterRegular.ttf -b&h-lucidatypewriter-medium-r-normal-sans-0-0-0-0-m-0-gbk 49 | LucidaTypewriterBold.ttf -b&h-lucidatypewriter-bold-r-normal-sans-0-0-0-0-m-0-gbk 50 | Alibaba-PuHuiTi-Heavy.ttf -ricoh-gothic-medium-r-normal--*-%d-*-*-c-*-jisx0201.1976-0 -------------------------------------------------------------------------------- /makejdkwithoutconfigure.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # duplicate of buildjdk.sh that avoids reconfiguring. Used for making changes to openjdk code. 3 | 4 | set -e 5 | . setdevkitpath.sh 6 | export FREETYPE_DIR=`pwd`/freetype-${BUILD_FREETYPE_VERSION}/build_android-${TARGET_SHORT} 7 | export CUPS_DIR=`pwd`/cups 8 | 9 | cd openjdk/build/${JVM_PLATFORM}-${TARGET_JDK}-${JVM_VARIANTS}-release 10 | make JOBS=$(nproc) images 11 | -------------------------------------------------------------------------------- /patches/jdk17u_android.diff: -------------------------------------------------------------------------------- 1 | diff --git a/make/autoconf/build-aux/config.sub b/make/autoconf/build-aux/config.sub 2 | index 8f5a5cf52..34943b6ed 100644 3 | --- a/make/autoconf/build-aux/config.sub 4 | +++ b/make/autoconf/build-aux/config.sub 5 | @@ -47,7 +47,8 @@ if echo $* | grep pc-msys >/dev/null ; then 6 | fi 7 | 8 | # Filter out everything that doesn't begin with "aarch64-" 9 | -if ! echo $* | grep '^aarch64-' >/dev/null ; then 10 | +# or that ends with "-android" 11 | +if ! echo $* | egrep "^aarch64-|-android" >/dev/null ; then 12 | . $DIR/autoconf-config.sub "$@" 13 | # autoconf-config.sub exits, so we never reach here, but just in 14 | # case we do: 15 | @@ -58,6 +59,10 @@ while test $# -gt 0 ; do 16 | case $1 in 17 | -- ) # Stop option processing 18 | shift; break ;; 19 | + *-android* ) 20 | + echo $1 21 | + exit 22 | + ;; 23 | aarch64-* ) 24 | config=`echo $1 | sed 's/^aarch64-/arm-/'` 25 | sub_args="$sub_args $config" 26 | diff --git a/make/autoconf/flags-cflags.m4 b/make/autoconf/flags-cflags.m4 27 | index 5eed1138f..b4319de67 100644 28 | --- a/make/autoconf/flags-cflags.m4 29 | +++ b/make/autoconf/flags-cflags.m4 30 | @@ -374,4 +374,4 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER], 31 | if test "x$OPENJDK_TARGET_OS" = xlinux; then 32 | CFLAGS_OS_DEF_JVM="-DLINUX -D_FILE_OFFSET_BITS=64" 33 | - CFLAGS_OS_DEF_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE" 34 | + CFLAGS_OS_DEF_JDK="-D_GNU_SOURCE -D_REENTRANT -D_LARGEFILE64_SOURCE -D__USE_BSD" 35 | elif test "x$OPENJDK_TARGET_OS" = xmacosx; then 36 | diff --git a/make/autoconf/flags-ldflags.m4 b/make/autoconf/flags-ldflags.m4 37 | index 23bb33e87..ad0ab88d0 100644 38 | --- a/make/autoconf/flags-ldflags.m4 39 | +++ b/make/autoconf/flags-ldflags.m4 40 | @@ -179,7 +179,9 @@ AC_DEFUN([FLAGS_SETUP_LDFLAGS_CPU_DEP], 41 | test "x${OPENJDK_$1_CPU}" = xmips64el; then 42 | $1_CPU_LDFLAGS="${$1_CPU_LDFLAGS} -Wl,--hash-style=sysv" 43 | else 44 | - $1_CPU_LDFLAGS="${$1_CPU_LDFLAGS} -Wl,--hash-style=gnu" 45 | + # Android 5.x does not support GNU hash style 46 | + # gnu 47 | + $1_CPU_LDFLAGS="${$1_CPU_LDFLAGS} -Wl,--hash-style=sysv" 48 | fi 49 | 50 | elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then 51 | diff --git a/make/autoconf/lib-freetype.m4 b/make/autoconf/lib-freetype.m4 52 | index 6a7109342..2d74ffc5b 100644 53 | --- a/make/autoconf/lib-freetype.m4 54 | +++ b/make/autoconf/lib-freetype.m4 55 | @@ -103,7 +103,8 @@ AC_DEFUN_ONCE([LIB_SETUP_FREETYPE], 56 | FREETYPE_TO_USE=bundled 57 | if test "x$OPENJDK_TARGET_OS" != "xwindows" && \ 58 | test "x$OPENJDK_TARGET_OS" != "xmacosx" && \ 59 | - test "x$OPENJDK_TARGET_OS" != "xaix"; then 60 | + test "x$OPENJDK_TARGET_OS" != "xaix" && \ 61 | + test "x$OPENJDK_TARGET_OS" != "xandroid"; then 62 | FREETYPE_TO_USE=system 63 | fi 64 | if test "x$with_freetype" != "x" ; then 65 | diff --git a/make/autoconf/libraries.m4 b/make/autoconf/libraries.m4 66 | index a65d91ee9..961f57db9 100644 67 | --- a/make/autoconf/libraries.m4 68 | +++ b/make/autoconf/libraries.m4 69 | @@ -40,8 +40,8 @@ m4_include([lib-tests.m4]) 70 | AC_DEFUN_ONCE([LIB_DETERMINE_DEPENDENCIES], 71 | [ 72 | # Check if X11 is needed 73 | - if test "x$OPENJDK_TARGET_OS" = xwindows || test "x$OPENJDK_TARGET_OS" = xmacosx; then 74 | - # No X11 support on windows or macosx 75 | + if test "x$OPENJDK_TARGET_OS" = xwindows || test "x$OPENJDK_TARGET_OS" = xmacosx || test "x$OPENJDK_TARGET_OS" = xandroid; then 76 | + # No X11 support on windows, macosx or android 77 | NEEDS_LIB_X11=false 78 | elif test "x$ENABLE_HEADLESS_ONLY" = xtrue; then 79 | # No X11 support needed when building headless only 80 | @@ -52,8 +52,8 @@ AC_DEFUN_ONCE([LIB_DETERMINE_DEPENDENCIES], 81 | fi 82 | 83 | # Check if fontconfig is needed 84 | - if test "x$OPENJDK_TARGET_OS" = xwindows || test "x$OPENJDK_TARGET_OS" = xmacosx; then 85 | - # No fontconfig support on windows or macosx 86 | + if test "x$OPENJDK_TARGET_OS" = xwindows || test "x$OPENJDK_TARGET_OS" = xmacosx || test "x$OPENJDK_TARGET_OS" = xandroid; then 87 | + # No fontconfig support on windows, macosx or android 88 | NEEDS_LIB_FONTCONFIG=false 89 | else 90 | # All other instances need fontconfig, even if building headless only, 91 | diff --git a/make/autoconf/platform.m4 b/make/autoconf/platform.m4 92 | index 2dd13d0d5..ea06c46a7 100644 93 | --- a/make/autoconf/platform.m4 94 | +++ b/make/autoconf/platform.m4 95 | @@ -190,6 +190,10 @@ AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_OS], 96 | VAR_OS=linux 97 | VAR_OS_TYPE=unix 98 | ;; 99 | + *android*) 100 | + VAR_OS=linux 101 | + VAR_OS_TYPE=unix 102 | + ;; 103 | *darwin*) 104 | VAR_OS=macosx 105 | VAR_OS_TYPE=unix 106 | diff --git a/make/autoconf/toolchain.m4 b/make/autoconf/toolchain.m4 107 | index 788958880..5dc9ade78 100644 108 | --- a/make/autoconf/toolchain.m4 109 | +++ b/make/autoconf/toolchain.m4 110 | @@ -35,10 +35,10 @@ 111 | m4_include([toolchain_microsoft.m4]) 112 | 113 | # All valid toolchains, regardless of platform (used by help.m4) 114 | -VALID_TOOLCHAINS_all="gcc clang xlc microsoft" 115 | +VALID_TOOLCHAINS_all="clang gcc xlc microsoft" 116 | 117 | # These toolchains are valid on different platforms 118 | -VALID_TOOLCHAINS_linux="gcc clang" 119 | +VALID_TOOLCHAINS_linux="clang gcc" 120 | VALID_TOOLCHAINS_macosx="gcc clang" 121 | VALID_TOOLCHAINS_aix="xlc" 122 | VALID_TOOLCHAINS_windows="microsoft" 123 | @@ -899,8 +899,8 @@ AC_DEFUN_ONCE([TOOLCHAIN_SETUP_BUILD_COMPILERS], 124 | UTIL_REQUIRE_PROGS(BUILD_CC, clang cc gcc) 125 | UTIL_REQUIRE_PROGS(BUILD_CXX, clang++ CC g++) 126 | else 127 | - UTIL_REQUIRE_PROGS(BUILD_CC, cc gcc) 128 | - UTIL_REQUIRE_PROGS(BUILD_CXX, CC g++) 129 | + UTIL_REQUIRE_PROGS(BUILD_CC, clang cc gcc) 130 | + UTIL_REQUIRE_PROGS(BUILD_CXX, clang++ CC g++) 131 | fi 132 | UTIL_LOOKUP_PROGS(BUILD_NM, nm gcc-nm) 133 | UTIL_LOOKUP_PROGS(BUILD_AR, ar gcc-ar lib) 134 | @@ -915,11 +915,14 @@ AC_DEFUN_ONCE([TOOLCHAIN_SETUP_BUILD_COMPILERS], 135 | 136 | PATH="$OLDPATH" 137 | 138 | - TOOLCHAIN_EXTRACT_COMPILER_VERSION(BUILD_CC, [BuildC]) 139 | - TOOLCHAIN_EXTRACT_COMPILER_VERSION(BUILD_CXX, [BuildC++]) 140 | - TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS([BUILD_], [OPENJDK_BUILD_], [build ]) 141 | - TOOLCHAIN_EXTRACT_LD_VERSION(BUILD_LD, [build linker]) 142 | - TOOLCHAIN_PREPARE_FOR_LD_VERSION_COMPARISONS([BUILD_], [OPENJDK_BUILD_]) 143 | + # xandroid 144 | + if test "x$OPENJDK_BUILD_OS" != "xlinux"; then 145 | + TOOLCHAIN_EXTRACT_COMPILER_VERSION(BUILD_CC, [BuildC]) 146 | + TOOLCHAIN_EXTRACT_COMPILER_VERSION(BUILD_CXX, [BuildC++]) 147 | + TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS([BUILD_], [OPENJDK_BUILD_], [build ]) 148 | + TOOLCHAIN_EXTRACT_LD_VERSION(BUILD_LD, [build linker]) 149 | + TOOLCHAIN_PREPARE_FOR_LD_VERSION_COMPARISONS([BUILD_], [OPENJDK_BUILD_]) 150 | + fi 151 | else 152 | # If we are not cross compiling, use the normal target compilers for 153 | # building the build platform executables. 154 | diff --git a/make/common/JdkNativeCompilation.gmk b/make/common/JdkNativeCompilation.gmk 155 | index 6a963ac2c..349ff126b 100644 156 | --- a/make/common/JdkNativeCompilation.gmk 157 | +++ b/make/common/JdkNativeCompilation.gmk 158 | @@ -41,6 +41,12 @@ FindSrcDirsForLib += \ 159 | $(TOPDIR)/src/$(strip $1)/$(OPENJDK_TARGET_OS_TYPE)/native/lib$(strip $2) \ 160 | $(TOPDIR)/src/$(strip $1)/share/native/lib$(strip $2))) 161 | 162 | +ifeq ($(OPENJDK_TARGET_OS), android) 163 | + FindSrcDirsForLib += \ 164 | + $(call uniq, $(wildcard \ 165 | + $(TOPDIR)/src/$(strip $1)/linux/native/lib$(strip $2))) 166 | +endif 167 | + 168 | FindSrcDirsForComponent += \ 169 | $(call uniq, $(wildcard \ 170 | $(TOPDIR)/src/$(strip $1)/$(OPENJDK_TARGET_OS)/native/$(strip $2) \ 171 | diff --git a/make/common/Modules.gmk b/make/common/Modules.gmk 172 | index 0eb0fb2dd..e0431de0b 100644 173 | --- a/make/common/Modules.gmk 174 | +++ b/make/common/Modules.gmk 175 | @@ -83,6 +83,10 @@ GENERATED_SRC_DIRS += \ 176 | TOP_SRC_DIRS += \ 177 | $(TOPDIR)/src \ 178 | # 179 | +ifeq ($(OPENJDK_TARGET_OS), android) 180 | + SRC_SUBDIRS += linux/classes 181 | +endif 182 | + 183 | 184 | SRC_SUBDIRS += $(OPENJDK_TARGET_OS)/classes 185 | ifneq ($(OPENJDK_TARGET_OS), $(OPENJDK_TARGET_OS_TYPE)) 186 | diff --git a/make/common/Utils.gmk b/make/common/Utils.gmk 187 | index a7df32065..0eaa1ec40 100644 188 | --- a/make/common/Utils.gmk 189 | +++ b/make/common/Utils.gmk 190 | @@ -307,6 +307,12 @@ check-jvm-variant = \ 191 | isTargetOs = \ 192 | $(strip $(if $(filter $(OPENJDK_TARGET_OS), $1), true, false)) 193 | 194 | +ifeq ($(call isTargetOs, android), true) 195 | + # PATCH: Since Android is Linux, so Linux specific things are also built for Android. 196 | + isTargetOs = \ 197 | + $(strip $(if $(filter $(OPENJDK_TARGET_OS), $1), true, $(if $(filter linux, $1), true, false))) 198 | +endif 199 | + 200 | isTargetOsType = \ 201 | $(strip $(if $(filter $(OPENJDK_TARGET_OS_TYPE), $1), true, false)) 202 | 203 | diff --git a/make/hotspot/lib/JvmMapfile.gmk b/make/hotspot/lib/JvmMapfile.gmk 204 | index 5cba93178..181e0db5c 100644 205 | --- a/make/hotspot/lib/JvmMapfile.gmk 206 | +++ b/make/hotspot/lib/JvmMapfile.gmk 207 | @@ -52,7 +52,7 @@ endif 208 | # Create a dynamic list of symbols from the built object files. This is highly 209 | # platform dependent. 210 | 211 | -ifeq ($(call isTargetOs, linux), true) 212 | +ifeq ($(call isTargetOs, android linux), true) 213 | - DUMP_SYMBOLS_CMD := $(NM) --defined-only *.o 214 | + DUMP_SYMBOLS_CMD := $(NM) --defined-only --extern-only *.o 215 | ifneq ($(FILTER_SYMBOLS_PATTERN), ) 216 | FILTER_SYMBOLS_PATTERN := $(FILTER_SYMBOLS_PATTERN)| 217 | diff --git a/make/hotspot/lib/JvmOverrideFiles.gmk b/make/hotspot/lib/JvmOverrideFiles.gmk 218 | index a9f8a0e54..c2fd95850 100644 219 | --- a/make/hotspot/lib/JvmOverrideFiles.gmk 220 | +++ b/make/hotspot/lib/JvmOverrideFiles.gmk 221 | @@ -65,7 +65,8 @@ ifeq ($(call isTargetOs, linux), true) 222 | # 223 | endif 224 | 225 | - ifeq ($(call isTargetCpu, x86), true) 226 | + #ifeq ($(call isTargetCpu, x86), true) 227 | + ifeq (false, true) 228 | # Performance measurements show that by compiling GC related code, we could 229 | # significantly reduce the GC pause time on 32 bit Linux/Unix platforms by 230 | # compiling without the PIC flag (-fPIC on linux). 231 | diff --git a/make/modules/java.base/lib/CoreLibraries.gmk b/make/modules/java.base/lib/CoreLibraries.gmk 232 | index 1d5fede2a..37624ce84 100644 233 | --- a/make/modules/java.base/lib/CoreLibraries.gmk 234 | +++ b/make/modules/java.base/lib/CoreLibraries.gmk 235 | @@ -112,6 +112,10 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJAVA, \ 236 | 237 | TARGETS += $(BUILD_LIBJAVA) 238 | 239 | +ifeq ($(OPENJDK_TARGET_OS), linux) 240 | + $(BUILD_LIBJAVA): $(BUILD_LIBTINYICONV) 241 | +endif 242 | + 243 | $(BUILD_LIBJAVA): $(BUILD_LIBVERIFY) 244 | 245 | $(BUILD_LIBJAVA): $(BUILD_LIBFDLIBM) 246 | diff --git a/make/modules/java.desktop/Lib.gmk b/make/modules/java.desktop/Lib.gmk 247 | index 22b07289a..7281c96b9 100644 248 | --- a/make/modules/java.desktop/Lib.gmk 249 | +++ b/make/modules/java.desktop/Lib.gmk 250 | @@ -76,7 +76,7 @@ ifeq ($(call isTargetOs, aix), false) 251 | 252 | $(BUILD_LIBJSOUND): $(call FindLib, java.base, java) 253 | 254 | - TARGETS += $(BUILD_LIBJSOUND) 255 | + # TARGETS += $(BUILD_LIBJSOUND) 256 | 257 | endif 258 | 259 | diff --git a/make/modules/java.desktop/lib/Awt2dLibraries.gmk b/make/modules/java.desktop/lib/Awt2dLibraries.gmk 260 | index 4d0c0c00d..0bd1b5063 100644 261 | --- a/make/modules/java.desktop/lib/Awt2dLibraries.gmk 262 | +++ b/make/modules/java.desktop/lib/Awt2dLibraries.gmk 263 | @@ -527,7 +527,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBFONTMANAGER, \ 264 | LDFLAGS_unix := -L$(INSTALL_LIBRARIES_HERE), \ 265 | LDFLAGS_aix := -Wl$(COMMA)-berok, \ 266 | LIBS := $(BUILD_LIBFONTMANAGER_FONTLIB), \ 267 | - LIBS_unix := -lawt -ljava -ljvm $(LIBM) $(LIBCXX), \ 268 | + LIBS_unix := -lawt -lawt_headless -ljava -ljvm -lc $(LIBM) $(LIBCXX), \ 269 | LIBS_macosx := -lawt_lwawt -framework CoreText -framework CoreFoundation -framework CoreGraphics, \ 270 | LIBS_windows := $(WIN_JAVA_LIB) advapi32.lib user32.lib gdi32.lib \ 271 | $(WIN_AWT_LIB), \ 272 | @@ -753,7 +753,7 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false) 273 | LIBS_aix := -liconv, \ 274 | )) 275 | 276 | - TARGETS += $(BUILD_LIBSPLASHSCREEN) 277 | + # TARGETS += $(BUILD_LIBAWT_XAWT) 278 | 279 | ifeq ($(call isTargetOs, macosx), true) 280 | $(BUILD_LIBSPLASHSCREEN): $(call FindLib, $(MODULE), osxapp) 281 | diff --git a/make/modules/java.instrument/Lib.gmk b/make/modules/java.instrument/Lib.gmk 282 | index 3996ad213..bba075e69 100644 283 | --- a/make/modules/java.instrument/Lib.gmk 284 | +++ b/make/modules/java.instrument/Lib.gmk 285 | @@ -36,9 +36,11 @@ endif 286 | $(eval $(call SetupJdkLibrary, BUILD_LIBINSTRUMENT, \ 287 | NAME := instrument, \ 288 | OPTIMIZATION := LOW, \ 289 | + EXTRA_SRC := java.base:libtinyiconv, \ 290 | CFLAGS := $(CFLAGS_JDKLIB) $(LIBINSTRUMENT_CFLAGS), \ 291 | CFLAGS_debug := -DJPLIS_LOGGING, \ 292 | CFLAGS_release := -DNO_JPLIS_LOGGING, \ 293 | + CXXFLAGS := $(CXXFLAGS_JDKLIB), \ 294 | DISABLED_WARNINGS_gcc := unused-function, \ 295 | EXTRA_HEADER_DIRS := java.base:libjli, \ 296 | LDFLAGS := $(LDFLAGS_JDKLIB) \ 297 | diff --git a/make/modules/jdk.hotspot.agent/Lib.gmk b/make/modules/jdk.hotspot.agent/Lib.gmk 298 | index 59b24d0e4..d35dbfd17 100644 299 | --- a/make/modules/jdk.hotspot.agent/Lib.gmk 300 | +++ b/make/modules/jdk.hotspot.agent/Lib.gmk 301 | @@ -74,6 +74,6 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBSA, \ 302 | LIBS_windows := dbgeng.lib $(WIN_JAVA_LIB), \ 303 | )) 304 | 305 | -TARGETS += $(BUILD_LIBSA) 306 | +# TARGETS += $(BUILD_LIBSA) 307 | 308 | ################################################################################ 309 | diff --git a/make/modules/jdk.jdwp.agent/Lib.gmk b/make/modules/jdk.jdwp.agent/Lib.gmk 310 | index aef358c14..7b9e5097c 100644 311 | --- a/make/modules/jdk.jdwp.agent/Lib.gmk 312 | +++ b/make/modules/jdk.jdwp.agent/Lib.gmk 313 | @@ -52,12 +52,14 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJDWP, \ 314 | NAME := jdwp, \ 315 | OPTIMIZATION := LOW, \ 316 | CFLAGS := $(CFLAGS_JDKLIB) -DJDWP_LOGGING, \ 317 | + CXXFLAGS := $(CXXFLAGS_JDKLIB), \ 318 | DISABLED_WARNINGS_gcc := unused-function, \ 319 | DISABLED_WARNINGS_clang := sometimes-uninitialized format-nonliteral \ 320 | self-assign, \ 321 | EXTRA_HEADER_DIRS := \ 322 | include \ 323 | libjdwp/export, \ 324 | + EXTRA_SRC := java.base:libtinyiconv, \ 325 | LDFLAGS := $(LDFLAGS_JDKLIB) \ 326 | $(call SET_SHARED_LIBRARY_ORIGIN), \ 327 | LIBS := $(JDKLIB_LIBS), \ 328 | diff --git a/make/modules/jdk.net/Lib.gmk b/make/modules/jdk.net/Lib.gmk 329 | index 3c9d1055f..e4260da69 100644 330 | --- a/make/modules/jdk.net/Lib.gmk 331 | +++ b/make/modules/jdk.net/Lib.gmk 332 | @@ -27,7 +27,7 @@ include LibCommon.gmk 333 | 334 | ################################################################################ 335 | 336 | -ifeq ($(call isTargetOs, linux macosx windows), true) 337 | +ifeq ($(call isTargetOs, linux macosx windows android), true) 338 | 339 | $(eval $(call SetupJdkLibrary, BUILD_LIBEXTNET, \ 340 | NAME := extnet, \ 341 | diff --git a/src/hotspot/cpu/arm/icache_arm.cpp b/src/hotspot/cpu/arm/icache_arm.cpp 342 | index 61fcb8a35..93d2ad4f4 100644 343 | --- a/src/hotspot/cpu/arm/icache_arm.cpp 344 | +++ b/src/hotspot/cpu/arm/icache_arm.cpp 345 | @@ -31,7 +31,7 @@ 346 | 347 | 348 | static int icache_flush(address addr, int lines, int magic) { 349 | - __builtin___clear_cache(addr, addr + (lines << ICache::log2_line_size)); 350 | + __builtin___clear_cache((char*) addr, (char*) (addr + (lines << ICache::log2_line_size))); 351 | return magic; 352 | } 353 | 354 | diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp 355 | index ae0c73dcb..e2c9a21f7 100644 356 | --- a/src/hotspot/os/linux/os_linux.cpp 357 | +++ b/src/hotspot/os/linux/os_linux.cpp 358 | @@ -132,7 +132,7 @@ 359 | // for timer info max values which include all bits 360 | #define ALL_64_BITS CONST64(0xFFFFFFFFFFFFFFFF) 361 | 362 | -#ifdef MUSL_LIBC 363 | +#if defined(MUSL_LIBC) || defined(__ANDROID__) 364 | // dlvsym is not a part of POSIX 365 | // and musl libc doesn't implement it. 366 | static void *dlvsym(void *handle, 367 | @@ -182,6 +182,8 @@ static int clock_tics_per_sec = 100; 368 | // avoid this 369 | static bool suppress_primordial_thread_resolution = false; 370 | 371 | +static bool read_so_path_from_maps(const char* so_name, char* buf, int buflen); 372 | + 373 | // utility functions 374 | 375 | julong os::available_memory() { 376 | @@ -322,11 +324,11 @@ bool os::have_special_privileges() { 377 | 378 | 379 | #ifndef SYS_gettid 380 | -// i386: 224, ia64: 1105, amd64: 186, sparc: 143 381 | +// i386 & arm: 224, ia64: 1105, amd64: 186, sparc: 143, aarch64: 178 382 | #ifdef __ia64__ 383 | #define SYS_gettid 1105 384 | #else 385 | - #ifdef __i386__ 386 | + #if defined(__i386__) || defined(__arm__) 387 | #define SYS_gettid 224 388 | #else 389 | #ifdef __amd64__ 390 | @@ -334,6 +336,8 @@ bool os::have_special_privileges() { 391 | #else 392 | #ifdef __sparc__ 393 | #define SYS_gettid 143 394 | + #elif defined(__arm64__) || defined(__aarch64__) 395 | + #define SYS_gettid 178 396 | #else 397 | #error define gettid for the arch 398 | #endif 399 | @@ -515,6 +519,7 @@ extern "C" void breakpoint() { 400 | // detecting pthread library 401 | 402 | void os::Linux::libpthread_init() { 403 | +#ifndef __ANDROID__ 404 | // Save glibc and pthread version strings. 405 | #if !defined(_CS_GNU_LIBC_VERSION) || \ 406 | !defined(_CS_GNU_LIBPTHREAD_VERSION) 407 | @@ -539,6 +544,9 @@ void os::Linux::libpthread_init() { 408 | confstr(_CS_GNU_LIBPTHREAD_VERSION, str, n); 409 | os::Linux::set_libpthread_version(str); 410 | #endif 411 | +#else 412 | + os::Linux::set_libpthread_version("NPTL"); 413 | +#endif 414 | } 415 | 416 | ///////////////////////////////////////////////////////////////////////////// 417 | @@ -1374,6 +1382,12 @@ const char* os::dll_file_extension() { return ".so"; } 418 | 419 | // This must be hard coded because it's the system's temporary 420 | // directory not the java application's temp directory, ala java.io.tmpdir. 421 | -const char* os::get_temp_directory() { return "/tmp"; } 422 | +const char* os::get_temp_directory() { 423 | +#ifndef __ANDROID__ 424 | + return "/tmp"; 425 | +#else 426 | + return "/data/tmp"; 427 | +#endif 428 | +} 429 | 430 | // check if addr is inside libjvm.so 431 | @@ -1517,6 +1531,30 @@ bool os::dll_address_to_library_name(address addr, char* buf, 432 | return false; 433 | } 434 | 435 | +static bool read_so_path_from_maps(const char* so_name, char* buf, int buflen) { 436 | + FILE *fp = fopen("/proc/self/maps", "r"); 437 | + assert(fp, "Failed to open /proc/self/maps"); 438 | + if (!fp) { 439 | + return false; 440 | + } 441 | + 442 | + char maps_buffer[2048]; 443 | + while (fgets(maps_buffer, 2048, fp) != NULL) { 444 | + if (strstr(maps_buffer, so_name) == NULL) { 445 | + continue; 446 | + } 447 | + 448 | + char *so_path = strchr(maps_buffer, '/'); 449 | + so_path[strlen(so_path) - 1] = '\0'; // Cut trailing \n 450 | + jio_snprintf(buf, buflen, "%s", so_path); 451 | + fclose(fp); 452 | + return true; 453 | + } 454 | + 455 | + fclose(fp); 456 | + return false; 457 | +} 458 | + 459 | // Loads .dll/.so and 460 | // in case of error it checks if .dll/.so was built for the 461 | // same architecture as Hotspot is running on 462 | @@ -1863,6 +1901,7 @@ void * os::Linux::dll_load_in_vmthread(const char *filename, char *ebuf, 463 | } 464 | 465 | const char* os::Linux::dll_path(void* lib) { 466 | +#ifdef RTLD_DI_LINKMAP 467 | struct link_map *lmap; 468 | const char* l_path = NULL; 469 | assert(lib != NULL, "dll_path parameter must not be NULL"); 470 | @@ -1872,6 +1911,9 @@ const char* os::Linux::dll_path(void* lib) { 471 | l_path = lmap->l_name; 472 | } 473 | return l_path; 474 | +#else 475 | + return NULL; 476 | +#endif 477 | } 478 | 479 | static bool _print_ascii_file(const char* filename, outputStream* st, const char* hdr = NULL) { 480 | @@ -2538,6 +2576,19 @@ void os::jvm_path(char *buf, jint buflen) { 481 | CAST_FROM_FN_PTR(address, os::jvm_path), 482 | dli_fname, sizeof(dli_fname), NULL); 483 | assert(ret, "cannot locate libjvm"); 484 | +#ifdef __ANDROID__ 485 | + if (dli_fname[0] == '\0') { 486 | + return; 487 | + } 488 | + 489 | + if (strchr(dli_fname, '/') == NULL) { 490 | + bool ok = read_so_path_from_maps(dli_fname, buf, buflen); 491 | + assert(ok, "unable to turn relative libjvm.so path into absolute"); 492 | + return; 493 | + } 494 | + 495 | + snprintf(buf, buflen, /* "%s/lib/%s/server/%s", java_home_var, cpu_arch, */ "%s", dli_fname); 496 | +#else // !__ANDROID__ 497 | char *rp = NULL; 498 | if (ret && dli_fname[0] != '\0') { 499 | rp = os::Posix::realpath(dli_fname, buf, buflen); 500 | @@ -2603,6 +2654,7 @@ void os::jvm_path(char *buf, jint buflen) { 501 | } 502 | } 503 | } 504 | +#endif 505 | 506 | strncpy(saved_jvm_path, buf, MAXPATHLEN); 507 | saved_jvm_path[MAXPATHLEN - 1] = '\0'; 508 | @@ -2937,7 +2989,8 @@ void os::Linux::sched_getcpu_init() { 509 | } 510 | 511 | if (sched_getcpu() == -1) { 512 | - vm_exit_during_initialization("getcpu(2) system call not supported by kernel"); 513 | + // vm_exit_during_initialization 514 | + warning("getcpu(2) system call not supported by kernel"); 515 | } 516 | } 517 | 518 | @@ -3554,6 +3607,7 @@ bool os::Linux::hugetlbfs_sanity_check(bool warn, size_t page_size) { 519 | } 520 | 521 | bool os::Linux::shm_hugetlbfs_sanity_check(bool warn, size_t page_size) { 522 | +#ifndef __ANDROID__ 523 | // Try to create a large shared memory segment. 524 | int shmid = shmget(IPC_PRIVATE, page_size, SHM_HUGETLB|IPC_CREAT|SHM_R|SHM_W); 525 | if (shmid == -1) { 526 | @@ -3575,6 +3629,10 @@ bool os::Linux::shm_hugetlbfs_sanity_check(bool warn, size_t page_size) { 527 | // Managed to create a segment, now delete it. 528 | shmctl(shmid, IPC_RMID, NULL); 529 | return true; 530 | +#else 531 | + warning("UseSHM not supported on this platform"); 532 | + return false; 533 | +#endif 534 | } 535 | 536 | // From the coredump_filter documentation: 537 | @@ -3838,6 +3896,8 @@ void os::large_page_init() { 538 | #define SHM_HUGETLB 04000 539 | #endif 540 | 541 | +#ifndef __ANDROID__ 542 | + 543 | #define shm_warning_format(format, ...) \ 544 | do { \ 545 | if (UseLargePages && \ 546 | @@ -3930,8 +3990,11 @@ static char* shmat_large_pages(int shmid, size_t bytes, size_t alignment, char* 547 | } 548 | } 549 | 550 | +#endif // !__ANDROID__ 551 | + 552 | char* os::Linux::reserve_memory_special_shm(size_t bytes, size_t alignment, 553 | char* req_addr, bool exec) { 554 | +#ifndef __ANDROID__ 555 | // "exec" is passed in but not used. Creating the shared image for 556 | // the code cache doesn't have an SHM_X executable permission to check. 557 | assert(UseLargePages && UseSHM, "only for SHM large pages"); 558 | @@ -3976,6 +4039,10 @@ char* os::Linux::reserve_memory_special_shm(size_t bytes, size_t alignment, 559 | shmctl(shmid, IPC_RMID, NULL); 560 | 561 | return addr; 562 | +#else 563 | + assert(0, "SHM not supported on this platform"); 564 | + return NULL; 565 | +#endif // !__ANDROID__ 566 | } 567 | 568 | static void warn_on_commit_special_failure(char* req_addr, size_t bytes, 569 | @@ -4111,8 +4178,13 @@ char* os::pd_reserve_memory_special(size_t bytes, size_t alignment, size_t page_ 570 | } 571 | 572 | bool os::Linux::release_memory_special_shm(char* base, size_t bytes) { 573 | +#ifndef __ANDROID__ 574 | // detaching the SHM segment will also delete it, see reserve_memory_special_shm() 575 | return shmdt(base) == 0; 576 | +#else 577 | + assert(0, "SHM not supported on this platform"); 578 | + return false; 579 | +#endif // SUPPORTS_SHM 580 | } 581 | 582 | bool os::Linux::release_memory_special_huge_tlbfs(char* base, size_t bytes) { 583 | @@ -5181,7 +5253,46 @@ bool os::is_thread_cpu_time_supported() { 584 | // Linux doesn't yet have a (official) notion of processor sets, 585 | // so just return the system wide load average. 586 | int os::loadavg(double loadavg[], int nelem) { 587 | +#ifndef __ANDROID__ 588 | return ::getloadavg(loadavg, nelem); 589 | +#else 590 | +/* 591 | + * Copyright (C) 2018 The Android Open Source Project 592 | + * All rights reserved. 593 | + * 594 | + * Redistribution and use in source and binary forms, with or without 595 | + * modification, are permitted provided that the following conditions 596 | + * are met: 597 | + * * Redistributions of source code must retain the above copyright 598 | + * notice, this list of conditions and the following disclaimer. 599 | + * * Redistributions in binary form must reproduce the above copyright 600 | + * notice, this list of conditions and the following disclaimer in 601 | + * the documentation and/or other materials provided with the 602 | + * distribution. 603 | + * 604 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 605 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 606 | + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 607 | + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 608 | + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 609 | + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 610 | + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 611 | + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 612 | + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 613 | + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 614 | + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 615 | + * SUCH DAMAGE. 616 | + */ 617 | + 618 | + if (nelem < 0) return -1; 619 | + if (nelem > 3) nelem = 3; 620 | + struct sysinfo si; 621 | + if (sysinfo(&si) == -1) return -1; 622 | + for (int i = 0; i < nelem; ++i) { 623 | + loadavg[i] = static_cast(si.loads[i]) / static_cast(1 << SI_LOAD_SHIFT); 624 | + } 625 | + return nelem; 626 | +#endif 627 | } 628 | 629 | void os::pause() { 630 | diff --git a/src/hotspot/os/linux/os_perf_linux.cpp b/src/hotspot/os/linux/os_perf_linux.cpp 631 | index 7c42379a0..5b76b3f42 100644 632 | --- a/src/hotspot/os/linux/os_perf_linux.cpp 633 | +++ b/src/hotspot/os/linux/os_perf_linux.cpp 634 | @@ -45,9 +45,312 @@ 635 | #include 636 | #include 637 | #include 638 | +#ifndef __ANDROID__ 639 | #include 640 | +#else 641 | +#include 642 | +#include 643 | +#include 644 | +#include 645 | +#include 646 | +#include 647 | +#include 648 | +#include 649 | +#endif 650 | #include 651 | 652 | +#ifdef __ANDROID__ 653 | +/* 654 | + * Copyright (C) 2015 The Android Open Source Project 655 | + * All rights reserved. 656 | + * 657 | + * Redistribution and use in source and binary forms, with or without 658 | + * modification, are permitted provided that the following conditions 659 | + * are met: 660 | + * * Redistributions of source code must retain the above copyright 661 | + * notice, this list of conditions and the following disclaimer. 662 | + * * Redistributions in binary form must reproduce the above copyright 663 | + * notice, this list of conditions and the following disclaimer in 664 | + * the documentation and/or other materials provided with the 665 | + * distribution. 666 | + * 667 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 668 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 669 | + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 670 | + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 671 | + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 672 | + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 673 | + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 674 | + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 675 | + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 676 | + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 677 | + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 678 | + * SUCH DAMAGE. 679 | + */ 680 | + 681 | +__BEGIN_DECLS 682 | + 683 | +/** 684 | + * Returned by getifaddrs() and freed by freeifaddrs(). 685 | + */ 686 | +struct ifaddrs { 687 | + /** Pointer to the next element in the linked list. */ 688 | + struct ifaddrs* ifa_next; 689 | + 690 | + /** Interface name. */ 691 | + char* ifa_name; 692 | + 693 | + /** Interface flags (like `SIOCGIFFLAGS`). */ 694 | + unsigned int ifa_flags; 695 | + 696 | + /** Interface address. */ 697 | + struct sockaddr* ifa_addr; 698 | + 699 | + /** Interface netmask. */ 700 | + struct sockaddr* ifa_netmask; 701 | + 702 | + union { 703 | + /** Interface broadcast address (if IFF_BROADCAST is set). */ 704 | + struct sockaddr* ifu_broadaddr; 705 | + 706 | + /** Interface destination address (if IFF_POINTOPOINT is set). */ 707 | + struct sockaddr* ifu_dstaddr; 708 | + } ifa_ifu; 709 | + 710 | + /** Unused. */ 711 | + void* ifa_data; 712 | +}; 713 | + 714 | +/** Synonym for `ifa_ifu.ifu_broadaddr` in `struct ifaddrs`. */ 715 | +#define ifa_broadaddr ifa_ifu.ifu_broadaddr 716 | + 717 | +/** Synonym for `ifa_ifu.ifu_dstaddr` in `struct ifaddrs`. */ 718 | +#define ifa_dstaddr ifa_ifu.ifu_dstaddr 719 | + 720 | +/** 721 | + * [getifaddrs(3)](http://man7.org/linux/man-pages/man3/getifaddrs.3.html) creates a linked list 722 | + * of `struct ifaddrs`. The list must be freed by freeifaddrs(). 723 | + * 724 | + * Returns 0 and stores the list in `*__list_ptr` on success, 725 | + * and returns -1 and sets `errno` on failure. 726 | + * 727 | + * Available since API level 24. 728 | + */ 729 | +int getifaddrs(struct ifaddrs** __list_ptr); // __INTRODUCED_IN(24); 730 | + 731 | +/** 732 | + * [freeifaddrs(3)](http://man7.org/linux/man-pages/man3/freeifaddrs.3.html) frees a linked list 733 | + * of `struct ifaddrs` returned by getifaddrs(). 734 | + * 735 | + * Available since API level 24. 736 | + */ 737 | +void freeifaddrs(struct ifaddrs* __ptr); // __INTRODUCED_IN(24); 738 | + 739 | +__END_DECLS 740 | + 741 | +#define nullptr 0 742 | + 743 | +// The public ifaddrs struct is full of pointers. Rather than track several 744 | +// different allocations, we use a maximally-sized structure with the public 745 | +// part at offset 0, and pointers into its hidden tail. 746 | +struct ifaddrs_storage { 747 | + // Must come first, so that `ifaddrs_storage` is-a `ifaddrs`. 748 | + ifaddrs ifa; 749 | + // The interface index, so we can match RTM_NEWADDR messages with 750 | + // earlier RTM_NEWLINK messages (to copy the interface flags). 751 | + int interface_index; 752 | + // Storage for the pointers in `ifa`. 753 | + sockaddr_storage addr; 754 | + sockaddr_storage netmask; 755 | + sockaddr_storage ifa_ifu; 756 | + char name[IFNAMSIZ + 1]; 757 | + // Netlink gives us the address family in the header, and the 758 | + // sockaddr_in or sockaddr_in6 bytes as the payload. We need to 759 | + // stitch the two bits together into the sockaddr that's part of 760 | + // our portable interface. 761 | + void SetAddress(int family, const void* data, size_t byteCount) { 762 | + addr.ss_family = family; 763 | + memcpy(SockaddrBytes(family, &addr), data, byteCount); 764 | + ifa.ifa_addr = reinterpret_cast(&addr); 765 | + } 766 | + void SetBroadcastAddress(int family, const void* data, size_t byteCount) { 767 | + ifa_ifu.ss_family = family; 768 | + memcpy(SockaddrBytes(family, &ifa_ifu), data, byteCount); 769 | + ifa.ifa_dstaddr = reinterpret_cast(&ifa_ifu); 770 | + } 771 | + // Netlink gives us the prefix length as a bit count. We need to turn 772 | + // that into a BSD-compatible netmask represented by a sockaddr*. 773 | + void SetNetmask(int family, size_t prefix_length) { 774 | + // ...and work out the netmask from the prefix length. 775 | + netmask.ss_family = family; 776 | + uint8_t* dst = SockaddrBytes(family, &netmask); 777 | + memset(dst, 0xff, prefix_length / 8); 778 | + if ((prefix_length % 8) != 0) { 779 | + dst[prefix_length/8] = (0xff << (8 - (prefix_length % 8))); 780 | + } 781 | + ifa.ifa_netmask = reinterpret_cast(&netmask); 782 | + } 783 | + void SetPacketAttributes(int ifindex, unsigned short hatype, unsigned char halen) { 784 | + sockaddr_ll* sll = reinterpret_cast(&addr); 785 | + sll->sll_ifindex = ifindex; 786 | + sll->sll_hatype = hatype; 787 | + sll->sll_halen = halen; 788 | + } 789 | + private: 790 | + // Returns a pointer to the first byte in the address data (which is 791 | + // stored in network byte order). 792 | + uint8_t* SockaddrBytes(int family, sockaddr_storage* ss) { 793 | + if (family == AF_INET) { 794 | + sockaddr_in* ss4 = reinterpret_cast(ss); 795 | + return reinterpret_cast(&ss4->sin_addr); 796 | + } else if (family == AF_INET6) { 797 | + sockaddr_in6* ss6 = reinterpret_cast(ss); 798 | + return reinterpret_cast(&ss6->sin6_addr); 799 | + } else if (family == AF_PACKET) { 800 | + sockaddr_ll* sll = reinterpret_cast(ss); 801 | + return reinterpret_cast(&sll->sll_addr); 802 | + } 803 | + return nullptr; 804 | + } 805 | +}; 806 | +ifaddrs_storage* new_ifaddrs_storage(ifaddrs** list) { 807 | + ifaddrs_storage *storage; 808 | + memset(storage, 0, sizeof(*storage)); 809 | + // push_front onto `list`. 810 | + storage->ifa.ifa_next = *list; 811 | + *list = reinterpret_cast(storage); 812 | + return storage; 813 | +} 814 | +#if !defined(__clang__) 815 | +// GCC gets confused by NLMSG_DATA and doesn't realize that the old-style 816 | +// cast is from a system header and should be ignored. 817 | +#pragma GCC diagnostic ignored "-Wold-style-cast" 818 | +#endif 819 | +static void __handle_netlink_response(ifaddrs** out, nlmsghdr* hdr) { 820 | + if (hdr->nlmsg_type == RTM_NEWLINK) { 821 | + ifinfomsg* ifi = reinterpret_cast(NLMSG_DATA(hdr)); 822 | + // Create a new ifaddr entry, and set the interface index and flags. 823 | + ifaddrs_storage* new_addr = new_ifaddrs_storage(out); 824 | + new_addr->interface_index = ifi->ifi_index; 825 | + new_addr->ifa.ifa_flags = ifi->ifi_flags; 826 | + // Go through the various bits of information and find the name. 827 | + rtattr* rta = IFLA_RTA(ifi); 828 | + size_t rta_len = IFLA_PAYLOAD(hdr); 829 | + while (RTA_OK(rta, rta_len)) { 830 | + if (rta->rta_type == IFLA_ADDRESS) { 831 | + if (RTA_PAYLOAD(rta) < sizeof(new_addr->addr)) { 832 | + new_addr->SetAddress(AF_PACKET, RTA_DATA(rta), RTA_PAYLOAD(rta)); 833 | + new_addr->SetPacketAttributes(ifi->ifi_index, ifi->ifi_type, RTA_PAYLOAD(rta)); 834 | + } 835 | + } else if (rta->rta_type == IFLA_BROADCAST) { 836 | + if (RTA_PAYLOAD(rta) < sizeof(new_addr->ifa_ifu)) { 837 | + new_addr->SetBroadcastAddress(AF_PACKET, RTA_DATA(rta), RTA_PAYLOAD(rta)); 838 | + new_addr->SetPacketAttributes(ifi->ifi_index, ifi->ifi_type, RTA_PAYLOAD(rta)); 839 | + } 840 | + } else if (rta->rta_type == IFLA_IFNAME) { 841 | + if (RTA_PAYLOAD(rta) < sizeof(new_addr->name)) { 842 | + memcpy(new_addr->name, RTA_DATA(rta), RTA_PAYLOAD(rta)); 843 | + new_addr->ifa.ifa_name = new_addr->name; 844 | + } 845 | + } 846 | + rta = RTA_NEXT(rta, rta_len); 847 | + } 848 | + } else if (hdr->nlmsg_type == RTM_NEWADDR) { 849 | + ifaddrmsg* msg = reinterpret_cast(NLMSG_DATA(hdr)); 850 | + // We should already know about this from an RTM_NEWLINK message. 851 | + const ifaddrs_storage* addr = reinterpret_cast(*out); 852 | + while (addr != nullptr && addr->interface_index != static_cast(msg->ifa_index)) { 853 | + addr = reinterpret_cast(addr->ifa.ifa_next); 854 | + } 855 | + // If this is an unknown interface, ignore whatever we're being told about it. 856 | + if (addr == nullptr) return; 857 | + // Create a new ifaddr entry and copy what we already know. 858 | + ifaddrs_storage* new_addr = new_ifaddrs_storage(out); 859 | + // We can just copy the name rather than look for IFA_LABEL. 860 | + strcpy(new_addr->name, addr->name); 861 | + new_addr->ifa.ifa_name = new_addr->name; 862 | + new_addr->ifa.ifa_flags = addr->ifa.ifa_flags; 863 | + new_addr->interface_index = addr->interface_index; 864 | + // Go through the various bits of information and find the address 865 | + // and any broadcast/destination address. 866 | + rtattr* rta = IFA_RTA(msg); 867 | + size_t rta_len = IFA_PAYLOAD(hdr); 868 | + while (RTA_OK(rta, rta_len)) { 869 | + if (rta->rta_type == IFA_ADDRESS) { 870 | + if (msg->ifa_family == AF_INET || msg->ifa_family == AF_INET6) { 871 | + new_addr->SetAddress(msg->ifa_family, RTA_DATA(rta), RTA_PAYLOAD(rta)); 872 | + new_addr->SetNetmask(msg->ifa_family, msg->ifa_prefixlen); 873 | + } 874 | + } else if (rta->rta_type == IFA_BROADCAST) { 875 | + if (msg->ifa_family == AF_INET || msg->ifa_family == AF_INET6) { 876 | + new_addr->SetBroadcastAddress(msg->ifa_family, RTA_DATA(rta), RTA_PAYLOAD(rta)); 877 | + } 878 | + } 879 | + rta = RTA_NEXT(rta, rta_len); 880 | + } 881 | + } 882 | +} 883 | +static bool __send_netlink_request(int fd, int type) { 884 | + struct NetlinkMessage { 885 | + nlmsghdr hdr; 886 | + rtgenmsg msg; 887 | + } request; 888 | + memset(&request, 0, sizeof(request)); 889 | + request.hdr.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST; 890 | + request.hdr.nlmsg_type = type; 891 | + request.hdr.nlmsg_len = sizeof(request); 892 | + request.msg.rtgen_family = AF_UNSPEC; // All families. 893 | + return (TEMP_FAILURE_RETRY(send(fd, &request, sizeof(request), 0)) == sizeof(request)); 894 | +} 895 | +static bool __read_netlink_responses(int fd, ifaddrs** out, char* buf, size_t buf_len) { 896 | + ssize_t bytes_read; 897 | + // Read through all the responses, handing interesting ones to __handle_netlink_response. 898 | + while ((bytes_read = TEMP_FAILURE_RETRY(recv(fd, buf, buf_len, 0))) > 0) { 899 | + nlmsghdr* hdr = reinterpret_cast(buf); 900 | + for (; NLMSG_OK(hdr, static_cast(bytes_read)); hdr = NLMSG_NEXT(hdr, bytes_read)) { 901 | + if (hdr->nlmsg_type == NLMSG_DONE) return true; 902 | + if (hdr->nlmsg_type == NLMSG_ERROR) return false; 903 | + __handle_netlink_response(out, hdr); 904 | + } 905 | + } 906 | + // We only get here if recv fails before we see a NLMSG_DONE. 907 | + return false; 908 | +} 909 | +int getifaddrs(ifaddrs** out) { 910 | + // Make cleanup easy. 911 | + *out = nullptr; 912 | + // The kernel keeps packets under 8KiB (NLMSG_GOODSIZE), 913 | + // but that's a bit too large to go on the stack. 914 | + size_t buf_len = 8192; 915 | + char* buf = NEW_C_HEAP_ARRAY(char, buf_len, mtInternal); 916 | + if (buf == nullptr) return -1; 917 | + // Open the netlink socket and ask for all the links and addresses. 918 | + int fd = socket(PF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE); 919 | + bool okay = fd != -1 && 920 | + __send_netlink_request(fd, RTM_GETLINK) && __read_netlink_responses(fd, out, buf, buf_len) && 921 | + __send_netlink_request(fd, RTM_GETADDR) && __read_netlink_responses(fd, out, buf, buf_len); 922 | + if (!okay) { 923 | + freeifaddrs(*out); 924 | + // Ensure that callers crash if they forget to check for success. 925 | + *out = nullptr; 926 | + } 927 | + { 928 | + int saved_errno = errno; 929 | + close(fd); 930 | + FREE_C_HEAP_ARRAY(char, buf); 931 | + errno = saved_errno; 932 | + } 933 | + return okay ? 0 : -1; 934 | +} 935 | +void freeifaddrs(ifaddrs* list) { 936 | + while (list != nullptr) { 937 | + ifaddrs* current = list; 938 | + list = list->ifa_next; 939 | + free(current); 940 | + } 941 | +} 942 | +#endif 943 | + 944 | /** 945 | /proc/[number]/stat 946 | Status information about the process. This is used by ps(1). It is defined in /usr/src/linux/fs/proc/array.c. 947 | diff --git a/src/hotspot/os/posix/os_posix.cpp b/src/hotspot/os/posix/os_posix.cpp 948 | index ae058dd34..ea99a3755 100644 949 | --- a/src/hotspot/os/posix/os_posix.cpp 950 | +++ b/src/hotspot/os/posix/os_posix.cpp 951 | @@ -65,7 +65,9 @@ 952 | #include 953 | #include 954 | #include 955 | +#ifndef __ANDROID__ 956 | #include 957 | +#endif 958 | 959 | #ifdef __APPLE__ 960 | #include 961 | @@ -418,6 +420,7 @@ void os::Posix::print_load_average(outputStream* st) { 962 | // unfortunately it does not work on macOS and Linux because the utx chain has no entry 963 | // for reboot at least on my test machines 964 | void os::Posix::print_uptime_info(outputStream* st) { 965 | +#ifndef __ANDROID__ 966 | int bootsec = -1; 967 | int currsec = time(NULL); 968 | struct utmpx* ent; 969 | @@ -432,6 +435,7 @@ void os::Posix::print_uptime_info(outputStream* st) { 970 | if (bootsec != -1) { 971 | os::print_dhm(st, "OS uptime:", (long) (currsec-bootsec)); 972 | } 973 | +#endif 974 | } 975 | 976 | static void print_rlimit(outputStream* st, const char* msg, 977 | diff --git a/src/hotspot/os_cpu/linux_aarch64/threadLS_linux_aarch64.S b/src/hotspot/os_cpu/linux_aarch64/threadLS_linux_aarch64.S 978 | index f541844b9..dd83b3723 100644 979 | --- a/src/hotspot/os_cpu/linux_aarch64/threadLS_linux_aarch64.S 980 | +++ b/src/hotspot/os_cpu/linux_aarch64/threadLS_linux_aarch64.S 981 | @@ -19,6 +19,7 @@ 982 | // or visit www.oracle.com if you need additional information or have any 983 | // questions. 984 | 985 | +#ifndef __ANDROID__ 986 | // JavaThread::aarch64_get_thread_helper() 987 | // 988 | // Return the current thread pointer in x0. 989 | @@ -42,3 +43,4 @@ _ZN10JavaThread25aarch64_get_thread_helperEv: 990 | ret 991 | 992 | .size _ZN10JavaThread25aarch64_get_thread_helperEv, .-_ZN10JavaThread25aarch64_get_thread_helperEv 993 | +#endif 994 | diff --git a/src/hotspot/os_cpu/linux_aarch64/thread_linux_aarch64.hpp b/src/hotspot/os_cpu/linux_aarch64/thread_linux_aarch64.hpp 995 | index 5a1f273c5..88b6750db 100644 996 | --- a/src/hotspot/os_cpu/linux_aarch64/thread_linux_aarch64.hpp 997 | +++ b/src/hotspot/os_cpu/linux_aarch64/thread_linux_aarch64.hpp 998 | @@ -47,6 +47,13 @@ private: 999 | bool pd_get_top_frame(frame* fr_addr, void* ucontext, bool isInJava); 1000 | public: 1001 | 1002 | - static Thread *aarch64_get_thread_helper(); 1003 | + static Thread *aarch64_get_thread_helper() 1004 | +#ifndef __ANDROID__ 1005 | +; 1006 | +#else 1007 | + { 1008 | + return Thread::current(); 1009 | + } 1010 | +#endif 1011 | 1012 | #endif // OS_CPU_LINUX_AARCH64_THREAD_LINUX_AARCH64_HPP 1013 | diff --git a/src/hotspot/os_cpu/linux_arm/fpu_control.h b/src/hotspot/os_cpu/linux_arm/fpu_control.h 1014 | new file mode 100644 1015 | index 000000000..745243d62 1016 | --- /dev/null 1017 | +++ b/src/hotspot/os_cpu/linux_arm/fpu_control.h 1018 | @@ -0,0 +1,59 @@ 1019 | +/* FPU control word definitions. ARM VFP version. 1020 | + Copyright (C) 2004-2019 Free Software Foundation, Inc. 1021 | + This file is part of the GNU C Library. 1022 | + The GNU C Library is free software; you can redistribute it and/or 1023 | + modify it under the terms of the GNU Lesser General Public 1024 | + License as published by the Free Software Foundation; either 1025 | + version 2.1 of the License, or (at your option) any later version. 1026 | + The GNU C Library is distributed in the hope that it will be useful, 1027 | + but WITHOUT ANY WARRANTY; without even the implied warranty of 1028 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1029 | + Lesser General Public License for more details. 1030 | + You should have received a copy of the GNU Lesser General Public 1031 | + License along with the GNU C Library. If not, see 1032 | + . */ 1033 | +#ifndef _FPU_CONTROL_H 1034 | +#define _FPU_CONTROL_H 1035 | +#if !(defined(_LIBC) && !defined(_LIBC_TEST)) && defined(__SOFTFP__) 1036 | +#define _FPU_RESERVED 0xffffffff 1037 | +#define _FPU_DEFAULT 0x00000000 1038 | +typedef unsigned int fpu_control_t; 1039 | +#define _FPU_GETCW(cw) (cw) = 0 1040 | +#define _FPU_SETCW(cw) (void) (cw) 1041 | +extern fpu_control_t __fpu_control; 1042 | +#else 1043 | +/* masking of interrupts */ 1044 | +#define _FPU_MASK_IM 0x00000100 /* invalid operation */ 1045 | +#define _FPU_MASK_ZM 0x00000200 /* divide by zero */ 1046 | +#define _FPU_MASK_OM 0x00000400 /* overflow */ 1047 | +#define _FPU_MASK_UM 0x00000800 /* underflow */ 1048 | +#define _FPU_MASK_PM 0x00001000 /* inexact */ 1049 | +#define _FPU_MASK_NZCV 0xf0000000 /* NZCV flags */ 1050 | +#define _FPU_MASK_RM 0x00c00000 /* rounding mode */ 1051 | +#define _FPU_MASK_EXCEPT 0x00001f1f /* all exception flags */ 1052 | +/* Some bits in the FPSCR are not yet defined. They must be preserved when 1053 | + modifying the contents. */ 1054 | +#define _FPU_RESERVED 0x00086060 1055 | +#define _FPU_DEFAULT 0x00000000 1056 | +/* Default + exceptions enabled. */ 1057 | +#define _FPU_IEEE (_FPU_DEFAULT | 0x00001f00) 1058 | +/* Type of the control word. */ 1059 | +typedef unsigned int fpu_control_t; 1060 | +/* Macros for accessing the hardware control word. */ 1061 | +#ifdef __SOFTFP__ 1062 | +/* This is fmrx %0, fpscr. */ 1063 | +# define _FPU_GETCW(cw) \ 1064 | + __asm__ __volatile__ ("mrc p10, 7, %0, cr1, cr0, 0" : "=r" (cw)) 1065 | +/* This is fmxr fpscr, %0. */ 1066 | +# define _FPU_SETCW(cw) \ 1067 | + __asm__ __volatile__ ("mcr p10, 7, %0, cr1, cr0, 0" : : "r" (cw)) 1068 | +#else 1069 | +# define _FPU_GETCW(cw) \ 1070 | + __asm__ __volatile__ ("vmrs %0, fpscr" : "=r" (cw)) 1071 | +# define _FPU_SETCW(cw) \ 1072 | + __asm__ __volatile__ ("vmsr fpscr, %0" : : "r" (cw)) 1073 | +#endif 1074 | +/* Default control word set at startup. */ 1075 | +extern fpu_control_t __fpu_control; 1076 | +#endif /* __SOFTFP__ */ 1077 | +#endif /* _FPU_CONTROL_H */ 1078 | diff --git a/src/hotspot/os_cpu/linux_arm/linux_arm_32.S b/src/hotspot/os_cpu/linux_arm/linux_arm_32.S 1079 | index c1c8fd428..626982e13 100644 1080 | --- a/src/hotspot/os_cpu/linux_arm/linux_arm_32.S 1081 | +++ b/src/hotspot/os_cpu/linux_arm/linux_arm_32.S 1082 | @@ -94,7 +94,7 @@ dw_f2b_loop_32: 1083 | stmia to!, {r3 - r9, ip} 1084 | bgt dw_f2b_loop_32 1085 | dw_f2b_loop_32_finish: 1086 | - addlts r2, #32 1087 | + addslt r2, #32 1088 | beq disjoint_words_finish 1089 | cmp r2, #16 1090 | blt disjoint_words_small 1091 | @@ -142,7 +142,7 @@ cw_f2b_loop_32: 1092 | stmia to!, {r3 - r9, ip} 1093 | bgt cw_f2b_loop_32 1094 | cw_f2b_loop_32_finish: 1095 | - addlts r2, #32 1096 | + addslt r2, #32 1097 | beq conjoint_words_finish 1098 | cmp r2, #16 1099 | blt conjoint_words_small 1100 | @@ -175,7 +175,7 @@ cw_b2f_loop_32: 1101 | stmdb to!, {r3-r9,ip} 1102 | bgt cw_b2f_loop_32 1103 | cw_b2f_loop_32_finish: 1104 | - addlts r2, #32 1105 | + addslt r2, #32 1106 | beq conjoint_words_finish 1107 | cmp r2, #16 1108 | blt cw_b2f_copy_small 1109 | @@ -227,7 +227,7 @@ cs_f2b_loop_32: 1110 | stmia to!, {r3 - r9, ip} 1111 | bgt cs_f2b_loop_32 1112 | cs_f2b_loop_32_finish: 1113 | - addlts r2, #32 1114 | + addslt r2, #32 1115 | beq conjoint_shorts_finish 1116 | movs r6, r2, lsr #3 1117 | .align 3 1118 | @@ -243,11 +243,11 @@ cs_f2b_4: 1119 | beq conjoint_shorts_finish 1120 | cmp r2, #4 1121 | ldrh r3, [from], #2 1122 | - ldrgeh r4, [from], #2 1123 | - ldrgth r5, [from], #2 1124 | + ldrhge r4, [from], #2 1125 | + ldrhgt r5, [from], #2 1126 | strh r3, [to], #2 1127 | - strgeh r4, [to], #2 1128 | - strgth r5, [to], #2 1129 | + strhge r4, [to], #2 1130 | + strhgt r5, [to], #2 1131 | b conjoint_shorts_finish 1132 | 1133 | # Destination not aligned 1134 | @@ -305,11 +305,11 @@ cs_f2b_4_u: 1135 | beq conjoint_shorts_finish 1136 | cmp r2, #4 1137 | ldrh r3, [from], #2 1138 | - ldrgeh r4, [from], #2 1139 | - ldrgth r5, [from], #2 1140 | + ldrhge r4, [from], #2 1141 | + ldrhgt r5, [from], #2 1142 | strh r3, [to], #2 1143 | - strgeh r4, [to], #2 1144 | - strgth r5, [to], #2 1145 | + strhge r4, [to], #2 1146 | + strhgt r5, [to], #2 1147 | b conjoint_shorts_finish 1148 | 1149 | # Src and dest overlap, copy in a descending order 1150 | @@ -332,7 +332,7 @@ cs_b2f_loop_32: 1151 | stmdb to!, {r3-r9,ip} 1152 | bgt cs_b2f_loop_32 1153 | cs_b2f_loop_32_finish: 1154 | - addlts r2, #32 1155 | + addslt r2, #32 1156 | beq conjoint_shorts_finish 1157 | cmp r2, #24 1158 | blt cs_b2f_16 1159 | @@ -358,11 +358,11 @@ cs_b2f_8: 1160 | cs_b2f_all_copy: 1161 | cmp r2, #4 1162 | ldrh r3, [from, #-2]! 1163 | - ldrgeh r4, [from, #-2]! 1164 | - ldrgth r5, [from, #-2]! 1165 | + ldrhge r4, [from, #-2]! 1166 | + ldrhgt r5, [from, #-2]! 1167 | strh r3, [to, #-2]! 1168 | - strgeh r4, [to, #-2]! 1169 | - strgth r5, [to, #-2]! 1170 | + strhge r4, [to, #-2]! 1171 | + strhgt r5, [to, #-2]! 1172 | b conjoint_shorts_finish 1173 | 1174 | # Destination not aligned 1175 | @@ -397,7 +397,7 @@ cs_b2f_16_loop_u: 1176 | bgt cs_b2f_16_loop_u 1177 | beq conjoint_shorts_finish 1178 | cs_b2f_16_loop_u_finished: 1179 | - addlts r2, #16 1180 | + addslt r2, #16 1181 | ldr r3, [from] 1182 | cmp r2, #10 1183 | blt cs_b2f_2_u_loop 1184 | @@ -460,7 +460,7 @@ cl_f2b_loop_32: 1185 | stmia to!, {r3 - r9, ip} 1186 | bgt cl_f2b_loop_32 1187 | cl_f2b_loop_32_finish: 1188 | - addlts r2, #32 1189 | + addslt r2, #32 1190 | beq conjoint_longs_finish 1191 | conjoint_longs_small: 1192 | cmp r2, #16 1193 | @@ -493,7 +493,7 @@ cl_b2f_loop_32: 1194 | stmdb to!, {r3 - r9, ip} 1195 | bgt cl_b2f_loop_32 1196 | cl_b2f_loop_32_finish: 1197 | - addlts r2, #32 1198 | + addslt r2, #32 1199 | beq conjoint_longs_finish 1200 | cmp r2, #16 1201 | blt cl_b2f_copy_8 1202 | diff --git a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp 1203 | index 6fc0c8406..f0314a729 100644 1204 | --- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp 1205 | +++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp 1206 | @@ -70,7 +70,11 @@ 1207 | # include 1208 | # include 1209 | # include 1210 | +#ifndef __ANDROID__ 1211 | # include 1212 | +#else 1213 | +# include "fpu_control.h" //include the local header 1214 | +#endif 1215 | # include 1216 | 1217 | #define SPELL_REG_SP "sp" 1218 | @@ -81,8 +85,14 @@ 1219 | #endif 1220 | 1221 | address os::current_stack_pointer() { 1222 | +#if defined(__clang__) || defined(__llvm__) 1223 | + void *sp; 1224 | + __asm__("mov %0, " SPELL_REG_SP : "=r"(sp)); 1225 | + return (address) sp; 1226 | +#else 1227 | register address sp __asm__ (SPELL_REG_SP); 1228 | return sp; 1229 | +#endif 1230 | } 1231 | 1232 | char* os::non_memory_address_word() { 1233 | @@ -406,8 +416,8 @@ void os::setup_fpu() { 1234 | #if !defined(__SOFTFP__) && defined(__VFP_FP__) 1235 | // Turn on IEEE-754 compliant VFP mode 1236 | __asm__ volatile ( 1237 | - "mov %%r0, #0;" 1238 | - "fmxr fpscr, %%r0" 1239 | + "mov r0, #0;" 1240 | + "fmxr fpscr, r0" 1241 | : /* no output */ : /* no input */ : "r0" 1242 | ); 1243 | #endif 1244 | diff --git a/src/hotspot/os_cpu/linux_x86/fpu_control.h b/src/hotspot/os_cpu/linux_x86/fpu_control.h 1245 | new file mode 100644 1246 | index 000000000..605302c09 1247 | --- /dev/null 1248 | +++ b/src/hotspot/os_cpu/linux_x86/fpu_control.h 1249 | @@ -0,0 +1,109 @@ 1250 | +/* FPU control word bits. x86 version. 1251 | + Copyright (C) 1993-2012 Free Software Foundation, Inc. 1252 | + This file is part of the GNU C Library. 1253 | + Contributed by Olaf Flebbe. 1254 | + 1255 | + The GNU C Library is free software; you can redistribute it and/or 1256 | + modify it under the terms of the GNU Lesser General Public 1257 | + License as published by the Free Software Foundation; either 1258 | + version 2.1 of the License, or (at your option) any later version. 1259 | + 1260 | + The GNU C Library is distributed in the hope that it will be useful, 1261 | + but WITHOUT ANY WARRANTY; without even the implied warranty of 1262 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1263 | + Lesser General Public License for more details. 1264 | + 1265 | + You should have received a copy of the GNU Lesser General Public 1266 | + License along with the GNU C Library; if not, see 1267 | + . */ 1268 | + 1269 | +#ifndef _FPU_CONTROL_H 1270 | +#define _FPU_CONTROL_H 1 1271 | + 1272 | +/* Note that this file sets on x86-64 only the x87 FPU, it does not 1273 | + touch the SSE unit. */ 1274 | + 1275 | +/* Here is the dirty part. Set up your 387 through the control word 1276 | + * (cw) register. 1277 | + * 1278 | + * 15-13 12 11-10 9-8 7-6 5 4 3 2 1 0 1279 | + * | reserved | IC | RC | PC | reserved | PM | UM | OM | ZM | DM | IM 1280 | + * 1281 | + * IM: Invalid operation mask 1282 | + * DM: Denormalized operand mask 1283 | + * ZM: Zero-divide mask 1284 | + * OM: Overflow mask 1285 | + * UM: Underflow mask 1286 | + * PM: Precision (inexact result) mask 1287 | + * 1288 | + * Mask bit is 1 means no interrupt. 1289 | + * 1290 | + * PC: Precision control 1291 | + * 11 - round to extended precision 1292 | + * 10 - round to double precision 1293 | + * 00 - round to single precision 1294 | + * 1295 | + * RC: Rounding control 1296 | + * 00 - rounding to nearest 1297 | + * 01 - rounding down (toward - infinity) 1298 | + * 10 - rounding up (toward + infinity) 1299 | + * 11 - rounding toward zero 1300 | + * 1301 | + * IC: Infinity control 1302 | + * That is for 8087 and 80287 only. 1303 | + * 1304 | + * The hardware default is 0x037f which we use. 1305 | + */ 1306 | + 1307 | +#include 1308 | + 1309 | +/* masking of interrupts */ 1310 | +#define _FPU_MASK_IM 0x01 1311 | +#define _FPU_MASK_DM 0x02 1312 | +#define _FPU_MASK_ZM 0x04 1313 | +#define _FPU_MASK_OM 0x08 1314 | +#define _FPU_MASK_UM 0x10 1315 | +#define _FPU_MASK_PM 0x20 1316 | + 1317 | +/* precision control */ 1318 | +#define _FPU_EXTENDED 0x300 /* libm requires double extended precision. */ 1319 | +#define _FPU_DOUBLE 0x200 1320 | +#define _FPU_SINGLE 0x0 1321 | + 1322 | +/* rounding control */ 1323 | +#define _FPU_RC_NEAREST 0x0 /* RECOMMENDED */ 1324 | +#define _FPU_RC_DOWN 0x400 1325 | +#define _FPU_RC_UP 0x800 1326 | +#define _FPU_RC_ZERO 0xC00 1327 | + 1328 | +#define _FPU_RESERVED 0xF0C0 /* Reserved bits in cw */ 1329 | + 1330 | + 1331 | +/* The fdlibm code requires strict IEEE double precision arithmetic, 1332 | + and no interrupts for exceptions, rounding to nearest. */ 1333 | + 1334 | +#define _FPU_DEFAULT 0x037f 1335 | + 1336 | +/* IEEE: same as above. */ 1337 | +#define _FPU_IEEE 0x037f 1338 | + 1339 | +/* Type of the control word. */ 1340 | +typedef unsigned int fpu_control_t __attribute__ ((__mode__ (__HI__))); 1341 | + 1342 | +/* Macros for accessing the hardware control word. "*&" is used to 1343 | + work around a bug in older versions of GCC. __volatile__ is used 1344 | + to support combination of writing the control register and reading 1345 | + it back. Without __volatile__, the old value may be used for reading 1346 | + back under compiler optimization. 1347 | + 1348 | + Note that the use of these macros is not sufficient anymore with 1349 | + recent hardware nor on x86-64. Some floating point operations are 1350 | + executed in the SSE/SSE2 engines which have their own control and 1351 | + status register. */ 1352 | +#define _FPU_GETCW(cw) __asm__ __volatile__ ("fnstcw %0" : "=m" (*&cw)) 1353 | +#define _FPU_SETCW(cw) __asm__ __volatile__ ("fldcw %0" : : "m" (*&cw)) 1354 | + 1355 | +/* Default control word set at startup. */ 1356 | +extern fpu_control_t __fpu_control; 1357 | + 1358 | +#endif /* fpu_control.h */ 1359 | diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp 1360 | index cc71b0d27..d3a40d433 100644 1361 | --- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp 1362 | +++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp 1363 | @@ -73,8 +73,10 @@ 1364 | # include 1365 | # include 1366 | # include 1367 | -#ifndef AMD64 1368 | +#if !defined(AMD64) && !defined(__ANDROID__) 1369 | # include 1370 | +#elif defined(__ANDROID__) 1371 | +# include "fpu_control.h" 1372 | #endif 1373 | 1374 | #ifdef AMD64 1375 | diff --git a/src/hotspot/share/utilities/elfFile.hpp b/src/hotspot/share/utilities/elfFile.hpp 1376 | index 0db847238..cee0456ed 100644 1377 | --- a/src/hotspot/share/utilities/elfFile.hpp 1378 | +++ b/src/hotspot/share/utilities/elfFile.hpp 1379 | @@ -47,8 +47,10 @@ typedef Elf64_Phdr Elf_Phdr; 1380 | typedef Elf64_Sym Elf_Sym; 1381 | 1382 | #if !defined(_ALLBSD_SOURCE) || defined(__APPLE__) 1383 | +#ifndef ELF_ST_TYPE 1384 | #define ELF_ST_TYPE ELF64_ST_TYPE 1385 | #endif 1386 | +#endif 1387 | 1388 | #else 1389 | 1390 | @@ -63,9 +65,11 @@ typedef Elf32_Phdr Elf_Phdr; 1391 | typedef Elf32_Sym Elf_Sym; 1392 | 1393 | #if !defined(_ALLBSD_SOURCE) || defined(__APPLE__) 1394 | +#ifndef ELF_ST_TYPE 1395 | #define ELF_ST_TYPE ELF32_ST_TYPE 1396 | #endif 1397 | #endif 1398 | +#endif 1399 | 1400 | #include "globalDefinitions.hpp" 1401 | #include "memory/allocation.hpp" 1402 | diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp 1403 | index 30cca9ee7..896690c9a 100644 1404 | --- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp 1405 | +++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp 1406 | @@ -48,6 +48,10 @@ 1407 | #include 1408 | #include 1409 | 1410 | +#if defined(__ANDROID__) && !defined(ANDROID) 1411 | +#define ANDROID 1 1412 | +#endif 1413 | + 1414 | #if defined(LINUX) || defined(_ALLBSD_SOURCE) 1415 | #include 1416 | #include 1417 | diff --git a/src/java.base/share/native/libtinyiconv/iconv.cpp b/src/java.base/share/native/libtinyiconv/iconv.cpp 1418 | new file mode 100644 1419 | index 000000000..7018b6ce2 1420 | --- /dev/null 1421 | +++ b/src/java.base/share/native/libtinyiconv/iconv.cpp 1422 | @@ -0,0 +1,438 @@ 1423 | +/* 1424 | + * Copyright (C) 2017 The Android Open Source Project 1425 | + * All rights reserved. 1426 | + * 1427 | + * Redistribution and use in source and binary forms, with or without 1428 | + * modification, are permitted provided that the following conditions 1429 | + * are met: 1430 | + * * Redistributions of source code must retain the above copyright 1431 | + * notice, this list of conditions and the following disclaimer. 1432 | + * * Redistributions in binary form must reproduce the above copyright 1433 | + * notice, this list of conditions and the following disclaimer in 1434 | + * the documentation and/or other materials provided with the 1435 | + * distribution. 1436 | + * 1437 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1438 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1439 | + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 1440 | + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 1441 | + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 1442 | + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 1443 | + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 1444 | + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 1445 | + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 1446 | + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 1447 | + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 1448 | + * SUCH DAMAGE. 1449 | + */ 1450 | + 1451 | +#ifdef __ANDROID__ 1452 | + 1453 | +#include 1454 | +#include 1455 | +#include 1456 | +#include 1457 | +#include 1458 | +#include 1459 | +#include 1460 | +#include 1461 | +#include 1462 | +#include 1463 | + 1464 | +__BEGIN_DECLS 1465 | + 1466 | +/* 1467 | + * These return values are specified by POSIX for multibyte conversion 1468 | + * functions. 1469 | + */ 1470 | + 1471 | +#ifdef __cplusplus 1472 | +#define __MB_ERR_ILLEGAL_SEQUENCE static_cast(-1) 1473 | +#define __MB_ERR_INCOMPLETE_SEQUENCE static_cast(-2) 1474 | +#else 1475 | +#define __MB_ERR_ILLEGAL_SEQUENCE (size_t)(-1) 1476 | +#define __MB_ERR_INCOMPLETE_SEQUENCE (size_t)(-2) 1477 | +#endif // __cplusplus 1478 | +#define __MB_IS_ERR(rv) (rv == __MB_ERR_ILLEGAL_SEQUENCE || \ 1479 | + rv == __MB_ERR_INCOMPLETE_SEQUENCE) 1480 | +static inline __wur size_t mbstate_bytes_so_far(const mbstate_t* ps) { 1481 | + return 1482 | + (ps->__seq[2] != 0) ? 3 : 1483 | + (ps->__seq[1] != 0) ? 2 : 1484 | + (ps->__seq[0] != 0) ? 1 : 0; 1485 | +} 1486 | +static inline void mbstate_set_byte(mbstate_t* ps, int i, char byte) { 1487 | + ps->__seq[i] = (uint8_t)(byte); 1488 | +} 1489 | +static inline __wur uint8_t mbstate_get_byte(const mbstate_t* ps, int n) { 1490 | + return ps->__seq[n]; 1491 | +} 1492 | +static inline __wur size_t mbstate_reset_and_return_illegal(int _errno, mbstate_t* ps) { 1493 | + errno = _errno; 1494 | +#ifdef __cplusplus 1495 | + *(reinterpret_cast(ps->__seq)) = 0; 1496 | +#else 1497 | + *(uint32_t*)(ps->__seq) = 0; 1498 | +#endif // __cplusplus 1499 | + return __MB_ERR_ILLEGAL_SEQUENCE; 1500 | +} 1501 | +static inline __wur size_t mbstate_reset_and_return(int _return, mbstate_t* ps) { 1502 | +#ifdef __cplusplus 1503 | + *(reinterpret_cast(ps->__seq)) = 0; 1504 | +#else 1505 | + *(uint32_t*)(ps->__seq) = 0; 1506 | +#endif // __cplusplus 1507 | + return _return; 1508 | +} 1509 | + 1510 | +#ifdef __cplusplus 1511 | +# define INVALID_ICONV_T reinterpret_cast(-1) 1512 | +#else // !__cplusplus 1513 | +# define INVALID_ICONV_T (iconv_t)(-1) 1514 | +#endif // __cplusplus 1515 | + 1516 | +// Ideally we'd use icu4c but the API mismatch seems too great. So we just offer something 1517 | +// equivalent to (but slightly easier to use for runs of text than) . If you're 1518 | +// here to add more encodings, consider working on finishing the icu4c NDK wrappers instead. 1519 | + 1520 | +#ifdef __cplusplus 1521 | + enum Encoding 1522 | +#else 1523 | + typedef enum 1524 | +#endif // __cplusplus 1525 | +{ 1526 | + US_ASCII, 1527 | + UTF_8, 1528 | + UTF_16_LE, 1529 | + UTF_16_BE, 1530 | + UTF_32_LE, 1531 | + UTF_32_BE, 1532 | + WCHAR_T, 1533 | +#ifdef __cplusplus 1534 | + }; 1535 | +#else 1536 | + } Encoding; 1537 | +#endif // __cplusplus 1538 | + 1539 | +#ifdef __cplusplus 1540 | + enum Mode 1541 | +#else 1542 | + typedef enum 1543 | +#endif // __cplusplus 1544 | +{ 1545 | + ERROR, 1546 | + IGNORE, 1547 | + TRANSLIT, 1548 | +#ifdef __cplusplus 1549 | + }; 1550 | +#else 1551 | + } Mode; 1552 | +#endif // __cplusplus 1553 | + 1554 | +// This matching is strange but true. 1555 | +// See http://www.unicode.org/reports/tr22/#Charset_Alias_Matching. 1556 | +static bool __match_encoding(const char* lhs, const char* rhs) { 1557 | + while (*lhs && *rhs) { 1558 | + // Skip non-alnum in lhs; "UTF-8", "UTF_8", "UTF8", "UTF 8" are all equivalent. 1559 | + // Also implement the "delete each 0 that is not preceded by a digit" rule. 1560 | + for (; *lhs; ++lhs) { 1561 | + if (isalnum(*lhs) && (*lhs != '0' || !isdigit(*(lhs + 1)))) break; 1562 | + } 1563 | + // Case doesn't matter either. 1564 | + if (tolower(*lhs) != tolower(*rhs)) break; 1565 | + ++lhs; 1566 | + ++rhs; 1567 | + } 1568 | + // As a special case we treat the GNU "//" extensions as end of string. 1569 | + if ((*lhs == '\0' || strstr(lhs, "//") == lhs) && *rhs == '\0') return true; 1570 | + return false; 1571 | +} 1572 | + 1573 | +static bool __parse_encoding(const char* s, Encoding* encoding, Mode* mode) { 1574 | + const char* suffix = strstr(s, "//"); 1575 | + if (suffix) { 1576 | + if (!mode) return false; 1577 | + if (strcmp(suffix, "//IGNORE") == 0) { 1578 | + *mode = IGNORE; 1579 | + } else if (strcmp(suffix, "//TRANSLIT") == 0) { 1580 | + *mode = TRANSLIT; 1581 | + } else { 1582 | + return false; 1583 | + } 1584 | + } 1585 | + if (__match_encoding(s, "utf8")) { 1586 | + *encoding = UTF_8; 1587 | + } else if (__match_encoding(s, "ascii") || __match_encoding(s, "usascii")) { 1588 | + *encoding = US_ASCII; 1589 | + } else if (__match_encoding(s, "utf16le")) { 1590 | + *encoding = UTF_16_LE; 1591 | + } else if (__match_encoding(s, "utf16be")) { 1592 | + *encoding = UTF_16_BE; 1593 | + } else if (__match_encoding(s, "utf32le")) { 1594 | + *encoding = UTF_32_LE; 1595 | + } else if (__match_encoding(s, "utf32be")) { 1596 | + *encoding = UTF_32_BE; 1597 | + } else if (__match_encoding(s, "wchart")) { 1598 | + *encoding = WCHAR_T; 1599 | + } else { 1600 | + return false; 1601 | + } 1602 | + return true; 1603 | +} 1604 | + 1605 | +struct __iconv_t { 1606 | + Encoding src_encoding; 1607 | + Encoding dst_encoding; 1608 | + Mode mode; 1609 | +/* 1610 | + __iconv_t() : mode(ERROR) { 1611 | + } 1612 | +*/ 1613 | + int Convert(char** src_buf0, size_t* src_bytes_left0, char** dst_buf0, size_t* dst_bytes_left0) { 1614 | + // Reset state. 1615 | + wc = 0; 1616 | + memset(&ps, 0, sizeof(ps)); 1617 | + replacement_count = 0; 1618 | + ignored = false; 1619 | + src_buf = src_buf0; 1620 | + src_bytes_left = src_bytes_left0; 1621 | + dst_buf = dst_buf0; 1622 | + dst_bytes_left = dst_bytes_left0; 1623 | + while (*src_bytes_left > 0) { 1624 | + if (!GetNext() || !Convert()) return -1; 1625 | + } 1626 | + return Done(); 1627 | + } 1628 | + private: 1629 | + char32_t wc; 1630 | + char buf[16]; 1631 | + size_t src_bytes_used; 1632 | + size_t dst_bytes_used; 1633 | + mbstate_t ps; 1634 | + size_t replacement_count; 1635 | + bool ignored; 1636 | + char** src_buf; 1637 | + size_t* src_bytes_left; 1638 | + char** dst_buf; 1639 | + size_t* dst_bytes_left; 1640 | + bool GetNext() { 1641 | + errno = 0; 1642 | + switch (src_encoding) { 1643 | + case US_ASCII: 1644 | + wc = **src_buf; 1645 | + src_bytes_used = 1; 1646 | + if (wc > 0x7f) errno = EILSEQ; 1647 | + break; 1648 | + case UTF_8: 1649 | + src_bytes_used = mbrtoc32(&wc, *src_buf, *src_bytes_left, &ps); 1650 | + if (src_bytes_used == __MB_ERR_ILLEGAL_SEQUENCE) { 1651 | + break; // EILSEQ already set. 1652 | + } else if (src_bytes_used == __MB_ERR_INCOMPLETE_SEQUENCE) { 1653 | + errno = EINVAL; 1654 | + return false; 1655 | + } 1656 | + break; 1657 | + case UTF_16_BE: 1658 | + case UTF_16_LE: { 1659 | + if (*src_bytes_left < 2) { 1660 | + errno = EINVAL; 1661 | + return false; 1662 | + } 1663 | + bool swap = (src_encoding == UTF_16_BE); 1664 | + wc = In16(*src_buf, swap); 1665 | + // 0xd800-0xdbff: high surrogates 1666 | + // 0xdc00-0xdfff: low surrogates 1667 | + if (wc >= 0xd800 && wc <= 0xdfff) { 1668 | + if (wc >= 0xdc00) { // Low surrogate before high surrogate. 1669 | + errno = EILSEQ; 1670 | + return false; 1671 | + } 1672 | + if (*src_bytes_left < 4) { 1673 | + errno = EINVAL; 1674 | + return false; 1675 | + } 1676 | + uint16_t hi = wc; 1677 | + uint16_t lo = In16(*src_buf + 2, swap); 1678 | + wc = 0x10000 + ((hi - 0xd800) << 10) + (lo - 0xdc00); 1679 | + src_bytes_used = 4; 1680 | + } 1681 | + break; 1682 | + } 1683 | + case UTF_32_BE: 1684 | + case UTF_32_LE: 1685 | + case WCHAR_T: 1686 | + if (*src_bytes_left < 4) { 1687 | + errno = EINVAL; 1688 | + return false; 1689 | + } 1690 | + wc = In32(*src_buf, (src_encoding == UTF_32_BE)); 1691 | + break; 1692 | + } 1693 | + if (errno == EILSEQ) { 1694 | + switch (mode) { 1695 | + case ERROR: 1696 | + return false; 1697 | + case IGNORE: 1698 | + *src_buf += src_bytes_used; 1699 | + *src_bytes_left -= src_bytes_used; 1700 | + ignored = true; 1701 | + return GetNext(); 1702 | + case TRANSLIT: 1703 | + wc = '?'; 1704 | + ++replacement_count; 1705 | + return true; 1706 | + } 1707 | + } 1708 | + return true; 1709 | + } 1710 | + 1711 | + bool Convert() { 1712 | + errno = 0; 1713 | + switch (dst_encoding) { 1714 | + case US_ASCII: 1715 | + buf[0] = wc; 1716 | + dst_bytes_used = 1; 1717 | + if (wc > 0x7f) errno = EILSEQ; 1718 | + break; 1719 | + case UTF_8: 1720 | + dst_bytes_used = c32rtomb(buf, wc, &ps); 1721 | + if (dst_bytes_used == __MB_ERR_ILLEGAL_SEQUENCE) { 1722 | + break; // EILSEQ already set. 1723 | + } else if (dst_bytes_used == __MB_ERR_INCOMPLETE_SEQUENCE) { 1724 | + errno = EINVAL; 1725 | + return false; 1726 | + } 1727 | + break; 1728 | + case UTF_16_BE: 1729 | + case UTF_16_LE: { 1730 | + bool swap = (dst_encoding == UTF_16_BE); 1731 | + if (wc < 0x10000) { // BMP. 1732 | + Out16(buf, wc, swap); 1733 | + } else { // Supplementary plane; output surrogate pair. 1734 | + wc -= 0x10000; 1735 | + char16_t hi = 0xd800 | (wc >> 10); 1736 | + char16_t lo = 0xdc00 | (wc & 0x3ff); 1737 | + Out16(buf + 0, hi, swap); 1738 | + Out16(buf + 2, lo, swap); 1739 | + dst_bytes_used = 4; 1740 | + } 1741 | + } break; 1742 | + case UTF_32_BE: 1743 | + case UTF_32_LE: 1744 | + case WCHAR_T: 1745 | + Out32(wc, (dst_encoding == UTF_32_BE)); 1746 | + break; 1747 | + } 1748 | + if (errno == EILSEQ) { 1749 | + if (mode == IGNORE) { 1750 | + *src_buf += src_bytes_used; 1751 | + *src_bytes_left -= src_bytes_used; 1752 | + ignored = true; 1753 | + return true; 1754 | + } else if (mode == TRANSLIT) { 1755 | + wc = '?'; 1756 | + ++replacement_count; 1757 | + return Convert(); 1758 | + } 1759 | + return false; 1760 | + } 1761 | + return Emit(); 1762 | + } 1763 | + 1764 | + uint16_t In16(const char* buf, bool swap) { 1765 | +#ifdef __cplusplus 1766 | + const uint8_t* src = reinterpret_cast(buf); 1767 | +#else // !__cplusplus 1768 | + const uint8_t* src = (const uint8_t*)(buf); 1769 | +#endif // __cplusplus 1770 | + uint16_t wc = (src[0]) | (src[1] << 8); 1771 | + if (swap) wc = __swap16(wc); 1772 | + src_bytes_used = 2; 1773 | + return wc; 1774 | + } 1775 | + 1776 | + uint32_t In32(const char* buf, bool swap) { 1777 | +#ifdef __cplusplus 1778 | + const uint8_t* src = reinterpret_cast(buf); 1779 | +#else // !__cplusplus 1780 | + const uint8_t* src = (const uint8_t*)(buf); 1781 | +#endif // __cplusplus 1782 | + uint32_t wc = (src[0]) | (src[1] << 8) | (src[2] << 16) | (src[3] << 24); 1783 | + if (swap) wc = __swap32(wc); 1784 | + src_bytes_used = 4; 1785 | + return wc; 1786 | + } 1787 | + 1788 | + void Out16(char* dst, char16_t ch, bool swap) { 1789 | + if (swap) ch = __swap16(ch); 1790 | + dst[0] = ch; 1791 | + dst[1] = ch >> 8; 1792 | + dst_bytes_used = 2; 1793 | + } 1794 | + 1795 | + void Out32(char32_t ch, bool swap) { 1796 | + if (swap) ch = __swap32(ch); 1797 | + buf[0] = ch; 1798 | + buf[1] = ch >> 8; 1799 | + buf[2] = ch >> 16; 1800 | + buf[3] = ch >> 24; 1801 | + dst_bytes_used = 4; 1802 | + } 1803 | + 1804 | + bool Emit() { 1805 | + if (dst_bytes_used > *dst_bytes_left) { 1806 | + errno = E2BIG; 1807 | + return false; 1808 | + } 1809 | + memcpy(*dst_buf, buf, dst_bytes_used); 1810 | + *src_buf += src_bytes_used; 1811 | + *src_bytes_left -= src_bytes_used; 1812 | + *dst_buf += dst_bytes_used; 1813 | + *dst_bytes_left -= dst_bytes_used; 1814 | + return true; 1815 | + } 1816 | + 1817 | + int Done() { 1818 | + if (mode == TRANSLIT) return replacement_count; 1819 | + if (ignored) { 1820 | + errno = EILSEQ; 1821 | + return -1; 1822 | + } 1823 | + return 0; 1824 | + } 1825 | +}; 1826 | + 1827 | +iconv_t iconv_open(const char* __dst_encoding, const char* __src_encoding) { 1828 | + iconv_t result = iconv_t(); 1829 | + result->mode = ERROR; 1830 | + if (!__parse_encoding(__src_encoding, &result->src_encoding, 0 /* nullptr */) || 1831 | + !__parse_encoding(__dst_encoding, &result->dst_encoding, &result->mode)) { 1832 | + free(result); 1833 | + errno = EINVAL; 1834 | + return INVALID_ICONV_T; 1835 | + } 1836 | + return result; 1837 | +} 1838 | + 1839 | +size_t iconv(iconv_t __converter, 1840 | + char** __src_buf, size_t* __src_bytes_left, 1841 | + char** __dst_buf, size_t* __dst_bytes_left) { 1842 | + if (__converter == INVALID_ICONV_T) { 1843 | + errno = EBADF; 1844 | + return -1; 1845 | + } 1846 | + return __converter->Convert(__src_buf, __src_bytes_left, __dst_buf, __dst_bytes_left); 1847 | +} 1848 | + 1849 | +int iconv_close(iconv_t __converter) { 1850 | + if (__converter == INVALID_ICONV_T) { 1851 | + errno = EBADF; 1852 | + return -1; 1853 | + } 1854 | + free(__converter); 1855 | + return 0; 1856 | +} 1857 | + 1858 | +__END_DECLS 1859 | + 1860 | +#endif // __ANDROID__ 1861 | diff --git a/src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java b/src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java 1862 | index d46138f23..eadaf92a4 100644 1863 | --- a/src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java 1864 | +++ b/src/java.base/unix/classes/sun/net/dns/ResolverConfigurationImpl.java 1865 | @@ -62,9 +62,11 @@ public class ResolverConfigurationImpl 1866 | { 1867 | LinkedList ll = new LinkedList<>(); 1868 | 1869 | + String resolvPath = System.getProperty("ext.net.resolvPath", "/etc/resolv.conf"); 1870 | + 1871 | try { 1872 | BufferedReader in = 1873 | - new BufferedReader(new FileReader("/etc/resolv.conf")); 1874 | + new BufferedReader(new FileReader(resolvPath)); 1875 | String line; 1876 | while ((line = in.readLine()) != null) { 1877 | int maxvalues = maxperkeyword; 1878 | diff --git a/src/java.base/unix/native/libjava/java_props_md.c b/src/java.base/unix/native/libjava/java_props_md.c 1879 | index 36a08d4c1..a0eca754b 100644 1880 | --- a/src/java.base/unix/native/libjava/java_props_md.c 1881 | +++ b/src/java.base/unix/native/libjava/java_props_md.c 1882 | @@ -46,6 +46,100 @@ 1883 | #include "java_props_macosx.h" 1884 | #endif 1885 | 1886 | +#ifdef __ANDROID__ 1887 | +// From https://android.googlesource.com/platform/bionic/+/master/libc/bionic/langinfo.cpp 1888 | +/* 1889 | + * Copyright (C) 2016 The Android Open Source Project 1890 | + * All rights reserved. 1891 | + * 1892 | + * Redistribution and use in source and binary forms, with or without 1893 | + * modification, are permitted provided that the following conditions 1894 | + * are met: 1895 | + * * Redistributions of source code must retain the above copyright 1896 | + * notice, this list of conditions and the following disclaimer. 1897 | + * * Redistributions in binary form must reproduce the above copyright 1898 | + * notice, this list of conditions and the following disclaimer in 1899 | + * the documentation and/or other materials provided with the 1900 | + * distribution. 1901 | + * 1902 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 1903 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 1904 | + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 1905 | + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 1906 | + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 1907 | + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 1908 | + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 1909 | + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 1910 | + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 1911 | + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 1912 | + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 1913 | + * SUCH DAMAGE. 1914 | + */ 1915 | + 1916 | +char* nl_langinfo(nl_item item) { 1917 | + const char* result = ""; 1918 | + switch (item) { 1919 | + case CODESET: result = (MB_CUR_MAX == 1) ? "ASCII" : "UTF-8"; break; 1920 | + case D_T_FMT: result = "%F %T %z"; break; 1921 | + case D_FMT: result = "%F"; break; 1922 | + case T_FMT: result = "%T"; break; 1923 | + case T_FMT_AMPM: result = "%I:%M:%S %p"; break; 1924 | + case AM_STR: result = "AM"; break; 1925 | + case PM_STR: result = "PM"; break; 1926 | + case DAY_1: result = "Sunday"; break; 1927 | + case DAY_2: result = "Monday"; break; 1928 | + case DAY_3: result = "Tuesday"; break; 1929 | + case DAY_4: result = "Wednesday"; break; 1930 | + case DAY_5: result = "Thursday"; break; 1931 | + case DAY_6: result = "Friday"; break; 1932 | + case DAY_7: result = "Saturday"; break; 1933 | + case ABDAY_1: result = "Sun"; break; 1934 | + case ABDAY_2: result = "Mon"; break; 1935 | + case ABDAY_3: result = "Tue"; break; 1936 | + case ABDAY_4: result = "Wed"; break; 1937 | + case ABDAY_5: result = "Thu"; break; 1938 | + case ABDAY_6: result = "Fri"; break; 1939 | + case ABDAY_7: result = "Sat"; break; 1940 | + case MON_1: result = "January"; break; 1941 | + case MON_2: result = "February"; break; 1942 | + case MON_3: result = "March"; break; 1943 | + case MON_4: result = "April"; break; 1944 | + case MON_5: result = "May"; break; 1945 | + case MON_6: result = "June"; break; 1946 | + case MON_7: result = "July"; break; 1947 | + case MON_8: result = "August"; break; 1948 | + case MON_9: result = "September"; break; 1949 | + case MON_10: result = "October"; break; 1950 | + case MON_11: result = "November"; break; 1951 | + case MON_12: result = "December"; break; 1952 | + case ABMON_1: result = "Jan"; break; 1953 | + case ABMON_2: result = "Feb"; break; 1954 | + case ABMON_3: result = "Mar"; break; 1955 | + case ABMON_4: result = "Apr"; break; 1956 | + case ABMON_5: result = "May"; break; 1957 | + case ABMON_6: result = "Jun"; break; 1958 | + case ABMON_7: result = "Jul"; break; 1959 | + case ABMON_8: result = "Aug"; break; 1960 | + case ABMON_9: result = "Sep"; break; 1961 | + case ABMON_10: result = "Oct"; break; 1962 | + case ABMON_11: result = "Nov"; break; 1963 | + case ABMON_12: result = "Dec"; break; 1964 | + case ERA: result = ""; break; 1965 | + case ERA_D_FMT: result = ""; break; 1966 | + case ERA_D_T_FMT: result = ""; break; 1967 | + case ERA_T_FMT: result = ""; break; 1968 | + case ALT_DIGITS: result = ""; break; 1969 | + case RADIXCHAR: result = "."; break; 1970 | + case THOUSEP: result = ""; break; 1971 | + case YESEXPR: result = "^[yY]"; break; 1972 | + case NOEXPR: result = "^[nN]"; break; 1973 | + case CRNCYSTR: result = ""; break; 1974 | + default: break; 1975 | + } 1976 | + return (char*) result; 1977 | +} 1978 | +#endif 1979 | + 1980 | #if defined(_ALLBSD_SOURCE) 1981 | #if !defined(P_tmpdir) 1982 | #include 1983 | diff --git a/src/java.base/share/native/libjli/java.c b/src/java.base/share/native/libjli/java.c 1984 | index 3b4a15b..1bca2bc 100644 1985 | --- a/src/java.base/share/native/libjli/java.c 1986 | +++ b/src/java.base/share/native/libjli/java.c 1987 | @@ -56,6 +56,32 @@ 1988 | #include "java.h" 1989 | #include "jni.h" 1990 | 1991 | +#ifdef __ANDROID__ 1992 | +#include 1993 | +#include 1994 | +static void android_disable_tags() { 1995 | + void *lib_handle = dlopen("libc.so", RTLD_LAZY); 1996 | + if (lib_handle) { 1997 | + if (android_get_device_api_level() >= 31) { 1998 | + int (*mallopt_func)(int, int) = dlsym(lib_handle, "mallopt"); 1999 | + if (mallopt_func) { 2000 | + mallopt_func(M_BIONIC_SET_HEAP_TAGGING_LEVEL, 0); 2001 | + } 2002 | + return; 2003 | + } 2004 | + /* android_get_device_api_level() < 31 */ 2005 | + bool (*android_mallopt)(int opcode, void* arg, size_t arg_size) = dlsym(lib_handle, "android_mallopt"); 2006 | + if (android_mallopt) { 2007 | + int android_malloc_tag_level = 0; 2008 | + android_mallopt(8, &android_malloc_tag_level, sizeof(android_malloc_tag_level)); 2009 | + } 2010 | + dlclose(lib_handle); 2011 | + } 2012 | +} 2013 | +#else 2014 | +static void android_disable_tags(){} 2015 | +#endif 2016 | + 2017 | /* 2018 | * A NOTE TO DEVELOPERS: For performance reasons it is important that 2019 | * the program image remain relatively small until after SelectVersion 2020 | @@ -253,6 +279,8 @@ JLI_Launch(int argc, char ** argv, /* main argc, argv */ 2021 | _is_java_args = javaargs; 2022 | _wc_enabled = cpwildcard; 2023 | 2024 | + android_disable_tags(); 2025 | + 2026 | InitLauncher(javaw); 2027 | DumpState(); 2028 | if (JLI_IsTraceLauncher()) { 2029 | diff --git a/src/java.base/unix/native/libjava/jni_util_md.c b/src/java.base/unix/native/libjava/jni_util_md.c 2030 | index 460503cd7..193480e73 100644 2031 | --- a/src/java.base/unix/native/libjava/jni_util_md.c 2032 | +++ b/src/java.base/unix/native/libjava/jni_util_md.c 2033 | @@ -31,7 +31,7 @@ 2034 | #include "jni_util.h" 2035 | #include "dlfcn.h" 2036 | 2037 | -#if defined(LINUX) && (defined(_GNU_SOURCE) || \ 2038 | +#if !defined(__ANDROID__) && defined(LINUX) && (defined(_GNU_SOURCE) || \ 2039 | (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE < 200112L \ 2040 | && defined(_XOPEN_SOURCE) && _XOPEN_SOURCE < 600)) 2041 | extern int __xpg_strerror_r(int, char *, size_t); 2042 | diff --git a/src/java.base/unix/native/libjava/posix_spawn.c b/src/java.base/unix/native/libjava/posix_spawn.c 2043 | new file mode 100644 2044 | index 000000000..f9032bab4 2045 | --- /dev/null 2046 | +++ b/src/java.base/unix/native/libjava/posix_spawn.c 2047 | @@ -0,0 +1,147 @@ 2048 | +// From https://android.googlesource.com/platform/external/dhcpcd-6.8.2/+/refs/heads/pie-dr1-release/compat/posix_spawn.c 2049 | +/* 2050 | + * dhcpcd - DHCP client daemon 2051 | + * Copyright (c) 2006-2012 Roy Marples 2052 | + * All rights reserved 2053 | + * Redistribution and use in source and binary forms, with or without 2054 | + * modification, are permitted provided that the following conditions 2055 | + * are met: 2056 | + * 1. Redistributions of source code must retain the above copyright 2057 | + * notice, this list of conditions and the following disclaimer. 2058 | + * 2. Redistributions in binary form must reproduce the above copyright 2059 | + * notice, this list of conditions and the following disclaimer in the 2060 | + * documentation and/or other materials provided with the distribution. 2061 | + * 2062 | + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 2063 | + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2064 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2065 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2066 | + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2067 | + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2068 | + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2069 | + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2070 | + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2071 | + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2072 | + * SUCH DAMAGE. 2073 | + */ 2074 | + 2075 | +/* This implementation of posix_spawn is only suitable for the needs of dhcpcd 2076 | + * but it could easily be extended to other applications. */ 2077 | + 2078 | +#include 2079 | +#include 2080 | +#include 2081 | +#include 2082 | +#include 2083 | +#include 2084 | +#include 2085 | + 2086 | +#include "posix_spawn.h" 2087 | + 2088 | +#ifndef _NSIG 2089 | +#ifdef _SIG_MAXSIG 2090 | +#define _NSIG _SIG_MAXSIG + 1 2091 | +#else 2092 | +/* Guess */ 2093 | +#define _NSIG SIGPWR + 1 2094 | +#endif 2095 | +#endif 2096 | + 2097 | +extern char **environ; 2098 | + 2099 | +static int 2100 | +posix_spawnattr_handle(const posix_spawnattr_t *attrp) 2101 | +{ 2102 | + struct sigaction sa; 2103 | + int i; 2104 | + if (attrp->posix_attr_flags & POSIX_SPAWN_SETSIGMASK) 2105 | + sigprocmask(SIG_SETMASK, &attrp->posix_attr_sigmask, NULL); 2106 | + if (attrp->posix_attr_flags & POSIX_SPAWN_SETSIGDEF) { 2107 | + memset(&sa, 0, sizeof(sa)); 2108 | + sa.sa_handler = SIG_DFL; 2109 | + for (i = 1; i < _NSIG; i++) { 2110 | + if (sigismember(&attrp->posix_attr_sigdefault, i)) { 2111 | + if (sigaction(i, &sa, NULL) == -1) 2112 | + return -1; 2113 | + } 2114 | + } 2115 | + } 2116 | + return 0; 2117 | +} 2118 | + 2119 | +inline static int 2120 | +is_vfork_safe(short int flags) 2121 | +{ 2122 | + return !(flags & (POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETSIGMASK)); 2123 | +} 2124 | + 2125 | +int 2126 | +posix_spawn(pid_t *pid, const char *path, 2127 | + const posix_spawn_file_actions_t *file_actions, 2128 | + const posix_spawnattr_t *attrp, 2129 | + char *const argv[], char *const envp[]) 2130 | +{ 2131 | + short int flags; 2132 | + pid_t p; 2133 | + volatile int error; 2134 | + error = 0; 2135 | + flags = attrp ? attrp->posix_attr_flags : 0; 2136 | + if (file_actions == NULL && is_vfork_safe(flags)) 2137 | + p = vfork(); 2138 | + else 2139 | +#ifdef THERE_IS_NO_FORK 2140 | + return ENOSYS; 2141 | +#else 2142 | + p = fork(); 2143 | +#endif 2144 | + switch (p) { 2145 | + case -1: 2146 | + return errno; 2147 | + case 0: 2148 | + if (attrp) { 2149 | + error = posix_spawnattr_handle(attrp); 2150 | + if (error) 2151 | + _exit(127); 2152 | + } 2153 | + execve(path, argv, envp); 2154 | + error = errno; 2155 | + _exit(127); 2156 | + default: 2157 | + if (error != 0) 2158 | + waitpid(p, NULL, WNOHANG); 2159 | + else if (pid != NULL) 2160 | + *pid = p; 2161 | + return error; 2162 | + } 2163 | +} 2164 | + 2165 | +int 2166 | +posix_spawnattr_init(posix_spawnattr_t *attr) 2167 | +{ 2168 | + memset(attr, 0, sizeof(*attr)); 2169 | + attr->posix_attr_flags = 0; 2170 | + sigprocmask(0, NULL, &attr->posix_attr_sigmask); 2171 | + sigemptyset(&attr->posix_attr_sigdefault); 2172 | + return 0; 2173 | +} 2174 | + 2175 | +int 2176 | +posix_spawnattr_setflags(posix_spawnattr_t *attr, short flags) 2177 | +{ 2178 | + attr->posix_attr_flags = flags; 2179 | + return 0; 2180 | +} 2181 | + 2182 | +int 2183 | +posix_spawnattr_setsigmask(posix_spawnattr_t *attr, const sigset_t *sigmask) 2184 | +{ 2185 | + attr->posix_attr_sigmask = *sigmask; 2186 | + return 0; 2187 | +} 2188 | + 2189 | +int 2190 | +posix_spawnattr_setsigdefault(posix_spawnattr_t *attr, const sigset_t *sigmask) 2191 | +{ 2192 | + attr->posix_attr_sigdefault = *sigmask; 2193 | + return 0; 2194 | +} 2195 | diff --git a/src/java.base/unix/native/libjava/posix_spawn.h b/src/java.base/unix/native/libjava/posix_spawn.h 2196 | new file mode 100644 2197 | index 000000000..388016eb3 2198 | --- /dev/null 2199 | +++ b/src/java.base/unix/native/libjava/posix_spawn.h 2200 | @@ -0,0 +1,53 @@ 2201 | +// From https://android.googlesource.com/platform/external/dhcpcd-6.8.2/+/refs/heads/pie-dr1-release/compat/posix_spawn.h 2202 | +/* 2203 | + * dhcpcd - DHCP client daemon 2204 | + * Copyright (c) 2006-2012 Roy Marples 2205 | + * All rights reserved 2206 | + * Redistribution and use in source and binary forms, with or without 2207 | + * modification, are permitted provided that the following conditions 2208 | + * are met: 2209 | + * 1. Redistributions of source code must retain the above copyright 2210 | + * notice, this list of conditions and the following disclaimer. 2211 | + * 2. Redistributions in binary form must reproduce the above copyright 2212 | + * notice, this list of conditions and the following disclaimer in the 2213 | + * documentation and/or other materials provided with the distribution. 2214 | + * 2215 | + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 2216 | + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2217 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2218 | + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2219 | + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2220 | + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2221 | + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2222 | + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2223 | + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2224 | + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2225 | + * SUCH DAMAGE. 2226 | + */ 2227 | + 2228 | +#ifndef POSIX_SPAWN_H 2229 | +#define POSIX_SPAWN_H 2230 | + 2231 | +#include 2232 | + 2233 | +typedef struct { 2234 | + short posix_attr_flags; 2235 | +#define POSIX_SPAWN_SETSIGDEF 0x10 2236 | +#define POSIX_SPAWN_SETSIGMASK 0x20 2237 | + sigset_t posix_attr_sigmask; 2238 | + sigset_t posix_attr_sigdefault; 2239 | +} posix_spawnattr_t; 2240 | + 2241 | +typedef struct { 2242 | +// int unused; 2243 | +} posix_spawn_file_actions_t; 2244 | + 2245 | +int posix_spawn(pid_t *, const char *, 2246 | + const posix_spawn_file_actions_t *, const posix_spawnattr_t *, 2247 | + char *const [], char *const []); 2248 | +int posix_spawnattr_init(posix_spawnattr_t *); 2249 | +int posix_spawnattr_setflags(posix_spawnattr_t *, short); 2250 | +int posix_spawnattr_setsigmask(posix_spawnattr_t *, const sigset_t *); 2251 | +int posix_spawnattr_setsigdefault(posix_spawnattr_t *, const sigset_t *); 2252 | + 2253 | +#endif 2254 | diff --git a/src/java.base/unix/native/libjli/java_md.c b/src/java.base/unix/native/libjli/java_md.c 2255 | index 503a2457b..d6ac325c8 100644 2256 | --- a/src/java.base/unix/native/libjli/java_md.c 2257 | +++ b/src/java.base/unix/native/libjli/java_md.c 2258 | @@ -585,7 +585,58 @@ const char* 2259 | SetExecname(char **argv) 2260 | { 2261 | char* exec_path = NULL; 2262 | -#if defined(__linux__) 2263 | +#if defined(__ANDROID__) //Since both __ANDROID__ and __linux__ are defined, we must let the preprocessor preprocess the __ANDRIOD__ part first 2264 | + char *__java_home = getenv("JAVA_HOME"); 2265 | + // From http://hg.openjdk.java.net/mobile/jdk9/jdk/file/17bb8a98d5e3/src/java.base/unix/native/libjli/java_md_solinux.c#l844 2266 | + /* For Android, 'self' would point to /system/bin/app_process 2267 | + * since we are really executing a Dalvik program at this point. 2268 | + * argv[0] points to the Dalvik application name and we set the 2269 | + * path to __java_home. 2270 | + */ 2271 | + char buf[PATH_MAX+1]; 2272 | + char *p = NULL; 2273 | + if ((p = JLI_StrRChr(argv[0], '/')) != 0) { 2274 | + /* may be running from command line */ 2275 | + p++; 2276 | + if ((JLI_StrLen(p) == 4) && JLI_StrCmp(p, "java") == 0) { 2277 | + /* started as 'java'. Must be command line */ 2278 | + JLI_TraceLauncher("SetExecName maybe command line = %s\n", argv[0]); 2279 | + if (*argv[0] != '/') { 2280 | + char *curdir = NULL; 2281 | + /* get absolute path */ 2282 | + getcwd(buf, PATH_MAX); 2283 | + curdir = JLI_StringDup(buf); 2284 | + JLI_Snprintf(buf, PATH_MAX, "%s/%s", curdir, argv[0]); 2285 | + JLI_MemFree(curdir); 2286 | + } else { 2287 | + JLI_Snprintf(buf, PATH_MAX, "%s", argv[0]); 2288 | + } 2289 | + } else { 2290 | + /* Not command line, see if __java_home set */ 2291 | + if (__java_home != NULL) { 2292 | + JLI_TraceLauncher("SetExecName not java = %s\n", __java_home); 2293 | + JLI_Snprintf(buf, PATH_MAX, "%s/bin/java", __java_home); 2294 | + } else { 2295 | + /* Fake it as best we can or should we punt? */ 2296 | + JLI_TraceLauncher("SetExecName fake it = %s\n", argv[0]); 2297 | + JLI_Snprintf(buf, PATH_MAX, "/data/data/%s/storage/jvm/bin/java", 2298 | + argv[0]); 2299 | + } 2300 | + } 2301 | + } else { 2302 | + /* Not started as 'java', see if __java_home set */ 2303 | + if (__java_home != NULL) { 2304 | + JLI_TraceLauncher("SetExecName not command line = %s\n", __java_home); 2305 | + JLI_Snprintf(buf, PATH_MAX, "%s/bin/java", __java_home); 2306 | + } else { 2307 | + /* Fake it as best we can or should we punt? */ 2308 | + JLI_TraceLauncher("SetExecName fake it 2 = %s\n", argv[0]); 2309 | + JLI_Snprintf(buf, PATH_MAX, "/data/data/%s/storage/jvm/bin/java", 2310 | + argv[0]); 2311 | + } 2312 | + } 2313 | + exec_path = JLI_StringDup(buf); 2314 | +#elif defined(__linux__) 2315 | { 2316 | const char* self = "/proc/self/exe"; 2317 | char buf[PATH_MAX+1]; 2318 | @@ -595,10 +646,6 @@ SetExecname(char **argv) 2319 | exec_path = JLI_StringDup(buf); 2320 | } 2321 | } 2322 | -#else /* !__linux__ */ 2323 | - { 2324 | - /* Not implemented */ 2325 | - } 2326 | #endif 2327 | 2328 | if (exec_path == NULL) { 2329 | diff --git a/src/java.base/unix/native/libnet/net_util_md.h b/src/java.base/unix/native/libnet/net_util_md.h 2330 | index 68835987b..eafd4509e 100644 2331 | --- a/src/java.base/unix/native/libnet/net_util_md.h 2332 | +++ b/src/java.base/unix/native/libnet/net_util_md.h 2333 | @@ -26,6 +26,9 @@ 2334 | #ifndef NET_UTILS_MD_H 2335 | #define NET_UTILS_MD_H 2336 | 2337 | +#ifdef __ANDROID__ 2338 | +#include 2339 | +#endif 2340 | #include 2341 | #include 2342 | #include 2343 | diff --git a/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c b/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c 2344 | index 9df8be1e6..12f9b4de3 100644 2345 | --- a/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c 2346 | +++ b/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c 2347 | @@ -140,6 +140,7 @@ typedef int fstatat64_func(int, const char *, struct stat64 *, int); 2348 | typedef int unlinkat_func(int, const char*, int); 2349 | typedef int renameat_func(int, const char*, int, const char*); 2350 | typedef int futimesat_func(int, const char *, const struct timeval *); 2351 | +typedef int utimensat_func(int, const char *, const struct timespec *, int flags); 2352 | typedef int futimens_func(int, const struct timespec *); 2353 | typedef int lutimes_func(const char *, const struct timeval *); 2354 | typedef DIR* fdopendir_func(int); 2355 | @@ -149,13 +150,48 @@ static fstatat64_func* my_fstatat64_func = NULL; 2356 | static unlinkat_func* my_unlinkat_func = NULL; 2357 | static renameat_func* my_renameat_func = NULL; 2358 | static futimesat_func* my_futimesat_func = NULL; 2359 | +static utimensat_func* my_utimensat_func = NULL; 2360 | static futimens_func* my_futimens_func = NULL; 2361 | static lutimes_func* my_lutimes_func = NULL; 2362 | static fdopendir_func* my_fdopendir_func = NULL; 2363 | #if defined(__linux__) 2364 | static statx_func* my_statx_func = NULL; 2365 | #endif 2366 | +#ifdef __ANDROID__ 2367 | +/* 2368 | + * TODO: Android lacks support for the methods listed below. In it's place are 2369 | + * alternatives that use existing Android functionality, but lack reentrant 2370 | + * support. Determine if the following are the most suitable alternatives. 2371 | + * 2372 | + */ 2373 | +int getgrgid_r(gid_t gid, struct group* grp, char* buf, size_t buflen, struct group** result) { 2374 | + 2375 | + *result = NULL; 2376 | + errno = 0; 2377 | + grp = getgrgid(gid); 2378 | + if (grp == NULL) { 2379 | + return errno; 2380 | + } 2381 | + // buf not used by caller (see below) 2382 | + *result = grp; 2383 | + return 0; 2384 | +} 2385 | + 2386 | +int getgrnam_r(const char *name, struct group* grp, char* buf, size_t buflen, struct group** result) { 2387 | + 2388 | + *result = NULL; 2389 | + errno = 0; 2390 | + grp = getgrnam(name); 2391 | + if (grp == NULL) { 2392 | + return errno; 2393 | + } 2394 | + // buf not used by caller (see below) 2395 | + *result = grp; 2396 | + return 0; 2397 | + 2398 | +} 2399 | +#endif 2400 | 2401 | /** 2402 | * fstatat missing from glibc on Linux. 2403 | */ 2404 | @@ -272,6 +309,9 @@ Java_sun_nio_fs_UnixNativeDispatcher_init(JNIEnv* env, jclass this) 2405 | #ifndef _ALLBSD_SOURCE 2406 | my_futimesat_func = (futimesat_func*) dlsym(RTLD_DEFAULT, "futimesat"); 2407 | my_lutimes_func = (lutimes_func*) dlsym(RTLD_DEFAULT, "lutimes"); 2408 | +#endif 2409 | +#ifdef __ANDROID__ 2410 | + my_utimensat_func = (utimensat_func*) dlsym(RTLD_DEFAULT, "utimensat"); 2411 | #endif 2412 | my_futimens_func = (futimens_func*) dlsym(RTLD_DEFAULT, "futimens"); 2413 | #if defined(_AIX) 2414 | @@ -292,7 +332,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_init(JNIEnv* env, jclass this) 2415 | capabilities |= sun_nio_fs_UnixNativeDispatcher_SUPPORTS_FUTIMES; 2416 | capabilities |= sun_nio_fs_UnixNativeDispatcher_SUPPORTS_LUTIMES; 2417 | #else 2418 | - if (my_futimesat_func != NULL) 2419 | + if (my_futimesat_func != NULL || my_utimensat_func != NULL) 2420 | capabilities |= sun_nio_fs_UnixNativeDispatcher_SUPPORTS_FUTIMES; 2421 | if (my_lutimes_func != NULL) 2422 | capabilities |= sun_nio_fs_UnixNativeDispatcher_SUPPORTS_LUTIMES; 2423 | @@ -304,7 +344,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_init(JNIEnv* env, jclass this) 2424 | 2425 | if (my_openat64_func != NULL && my_fstatat64_func != NULL && 2426 | my_unlinkat_func != NULL && my_renameat_func != NULL && 2427 | - my_futimesat_func != NULL && my_fdopendir_func != NULL) 2428 | + (my_futimesat_func != NULL || my_utimensat_func != NULL) && my_fdopendir_func != NULL) 2429 | { 2430 | capabilities |= sun_nio_fs_UnixNativeDispatcher_SUPPORTS_OPENAT; 2431 | } 2432 | @@ -689,22 +729,30 @@ Java_sun_nio_fs_UnixNativeDispatcher_futimes(JNIEnv* env, jclass this, jint file 2433 | jlong accessTime, jlong modificationTime) 2434 | { 2435 | struct timeval times[2]; 2436 | + struct timespec times2[2]; 2437 | int err = 0; 2438 | 2439 | - times[0].tv_sec = accessTime / 1000000; 2440 | + times[0].tv_sec = times2[0].tv_sec = accessTime / 1000000; 2441 | times[0].tv_usec = accessTime % 1000000; 2442 | 2443 | - times[1].tv_sec = modificationTime / 1000000; 2444 | + times[1].tv_sec = times2[1].tv_sec = modificationTime / 1000000; 2445 | times[1].tv_usec = modificationTime % 1000000; 2446 | 2447 | + times2[0].tv_nsec = times[0].tv_usec * 1000; 2448 | + times2[1].tv_nsec = times[1].tv_usec * 1000; 2449 | + 2450 | #ifdef _ALLBSD_SOURCE 2451 | RESTARTABLE(futimes(filedes, ×[0]), err); 2452 | #else 2453 | - if (my_futimesat_func == NULL) { 2454 | - JNU_ThrowInternalError(env, "my_futimesat_func is NULL"); 2455 | + if (my_futimesat_func == NULL && my_utimensat_func == NULL) { 2456 | + JNU_ThrowInternalError(env, "my_futimesat_func and my_utimensat_func are NULL"); 2457 | return; 2458 | } 2459 | - RESTARTABLE((*my_futimesat_func)(filedes, NULL, ×[0]), err); 2460 | + if (my_futimesat_func != NULL) { 2461 | + RESTARTABLE((*my_futimesat_func)(filedes, NULL, ×[0]), err); 2462 | + } else { 2463 | + RESTARTABLE((*my_utimensat_func)(filedes, NULL, ×2[0], 0), err); 2464 | + } 2465 | #endif 2466 | if (err == -1) { 2467 | throwUnixException(env, errno); 2468 | diff --git a/src/java.desktop/unix/native/libawt/awt/awt_LoadLibrary.c b/src/java.desktop/unix/native/libawt/awt/awt_LoadLibrary.c 2469 | index fbd6ce9d1..94d238f8e 100644 2470 | --- a/src/java.desktop/unix/native/libawt/awt/awt_LoadLibrary.c 2471 | +++ b/src/java.desktop/unix/native/libawt/awt/awt_LoadLibrary.c 2472 | @@ -30,6 +30,7 @@ 2473 | #include 2474 | #include 2475 | #include 2476 | +#include 2477 | #include "gdefs.h" 2478 | 2479 | #include 2480 | @@ -98,6 +99,30 @@ JNIEXPORT jboolean JNICALL AWTIsHeadless() { 2481 | #define HEADLESS_PATH "/libawt_headless.so" 2482 | #endif 2483 | 2484 | +static bool read_so_path_from_maps(const char* so_name, char* buf) { 2485 | + FILE *fp = fopen("/proc/self/maps", "r"); 2486 | + 2487 | + if (!fp) { 2488 | + return false; 2489 | + } 2490 | + 2491 | + char maps_buffer[2048]; 2492 | + while (fgets(maps_buffer, 2048, fp) != NULL) { 2493 | + if (strstr(maps_buffer, so_name) == NULL) { 2494 | + continue; 2495 | + } 2496 | + 2497 | + char *so_path = strchr(maps_buffer, '/'); 2498 | + so_path[strlen(so_path) - 1] = '\0'; // Cut trailing \n 2499 | + strcpy(buf,so_path); 2500 | + fclose(fp); 2501 | + return true; 2502 | + } 2503 | + 2504 | + fclose(fp); 2505 | + return false; 2506 | +} 2507 | + 2508 | jint 2509 | AWT_OnLoad(JavaVM *vm, void *reserved) 2510 | { 2511 | @@ -121,7 +146,11 @@ AWT_OnLoad(JavaVM *vm, void *reserved) 2512 | #ifndef STATIC_BUILD 2513 | /* Get address of this library and the directory containing it. */ 2514 | dladdr((void *)AWT_OnLoad, &dlinfo); 2515 | - realpath((char *)dlinfo.dli_fname, buf); 2516 | + if (strrchr(dlinfo.dli_fname, '/') != NULL) { 2517 | + realpath((char *)dlinfo.dli_fname, buf); 2518 | + }else{ 2519 | + read_so_path_from_maps(dlinfo.dli_fname,buf); 2520 | + } 2521 | len = strlen(buf); 2522 | p = strrchr(buf, '/'); 2523 | #endif 2524 | diff --git a/src/java.instrument/unix/native/libinstrument/EncodingSupport_md.c b/src/java.instrument/unix/native/libinstrument/EncodingSupport_md.c 2525 | index 13cca6453..796666173 100644 2526 | --- a/src/java.instrument/unix/native/libinstrument/EncodingSupport_md.c 2527 | +++ b/src/java.instrument/unix/native/libinstrument/EncodingSupport_md.c 2528 | @@ -64,7 +64,11 @@ utfInitialize(void) 2529 | (void)setlocale(LC_ALL, ""); 2530 | 2531 | /* Get the codeset name */ 2532 | +#ifndef __ANDROID__ 2533 | codeset = (char*)nl_langinfo(CODESET); 2534 | +#else 2535 | + codeset = "ASCII"; // (MB_CUR_MAX == 1) ? "ASCII" : "UTF-8"; 2536 | +#endif 2537 | if ( codeset == NULL || codeset[0] == 0 ) { 2538 | UTF_DEBUG(("NO codeset returned by nl_langinfo(CODESET)\n")); 2539 | return; 2540 | diff --git a/src/jdk.jdwp.agent/share/native/libjdwp/utf_util.c b/src/jdk.jdwp.agent/share/native/libjdwp/utf_util.c 2541 | index 3fb38893e..20ac7b270 100644 2542 | --- a/src/jdk.jdwp.agent/share/native/libjdwp/utf_util.c 2543 | +++ b/src/jdk.jdwp.agent/share/native/libjdwp/utf_util.c 2544 | @@ -483,7 +483,11 @@ static int iconvConvert(conv_direction drn, char *bytes, size_t len, char *outpu 2545 | // locale is not initialized, do it now 2546 | if (setlocale(LC_ALL, "") != NULL) { 2547 | // nl_langinfo returns ANSI_X3.4-1968 by default 2548 | +#ifndef __ANDROID__ 2549 | codeset = (char*)nl_langinfo(CODESET); 2550 | +#else 2551 | + codeset = "ASCII"; 2552 | +#endif 2553 | } 2554 | 2555 | if (codeset == NULL) { 2556 | diff --git a/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c b/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c 2557 | index be578a0bb..ce5e8b400 100644 2558 | --- a/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c 2559 | +++ b/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c 2560 | @@ -80,5 +80,5 @@ 2561 | // not relying on included headers. 2562 | 2563 | -#ifndef __GLIBC__ 2564 | +#if !defined(__GLIBC__) && !defined(__ANDROID__) 2565 | // Alpine doesn't know these types, define them 2566 | typedef unsigned int __uint32_t; 2567 | diff --git a/make/data/hotspot-symbols/symbols-aix b/make/data/hotspot-symbols/symbols-aix 2568 | index 92703573a5f5..11dad0fece50 100644 2569 | --- a/make/data/hotspot-symbols/symbols-aix 2570 | +++ b/make/data/hotspot-symbols/symbols-aix 2571 | @@ -24,4 +24,3 @@ 2572 | JVM_handle_aix_signal 2573 | numa_error 2574 | numa_warn 2575 | -sysThreadAvailableStackWithSlack 2576 | diff --git a/make/data/hotspot-symbols/symbols-linux b/make/data/hotspot-symbols/symbols-linux 2577 | index bbb0d35115fc..b0d802f1773f 100644 2578 | --- a/make/data/hotspot-symbols/symbols-linux 2579 | +++ b/make/data/hotspot-symbols/symbols-linux 2580 | @@ -25,4 +25,3 @@ JVM_handle_linux_signal 2581 | JVM_IsUseContainerSupport 2582 | numa_error 2583 | numa_warn 2584 | -sysThreadAvailableStackWithSlack 2585 | // skip some checks as AOSP does 2586 | diff --git a/src/java.base/unix/native/libnet/net_util_md.c b/src/java.base/unix/native/libnet/net_util_md.c 2587 | index 4ec11a136..01b85db4d 100644 2588 | --- a/src/java.base/unix/native/libnet/net_util_md.c 2589 | +++ b/src/java.base/unix/native/libnet/net_util_md.c 2590 | @@ -129,6 +129,7 @@ jint IPv6_supported() 2591 | SOCKETADDRESS sa; 2592 | socklen_t sa_len = sizeof(SOCKETADDRESS); 2593 | 2594 | +#ifndef __ANDROID__ // ANDROID: skip check, see libcore commit ae218d9b 2595 | fd = socket(AF_INET6, SOCK_STREAM, 0) ; 2596 | if (fd < 0) { 2597 | /* 2598 | @@ -172,6 +173,7 @@ jint IPv6_supported() 2599 | } 2600 | } 2601 | #endif 2602 | +#endif // !defined __ANDROID__ 2603 | 2604 | /* 2605 | * OK we may have the stack available in the kernel, 2606 | -------------------------------------------------------------------------------- /removejdkdebuginfo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | . setdevkitpath.sh 5 | 6 | imagespath=openjdk/build/${JVM_PLATFORM}-${TARGET_JDK}-${JVM_VARIANTS}-${JDK_DEBUG_LEVEL}/images 7 | 8 | rm -rf dizout jreout jdkout dSYM-temp 9 | mkdir -p dizout dSYM-temp/{lib,bin} 10 | 11 | cp freetype-${BUILD_FREETYPE_VERSION}/build_android-$TARGET_SHORT/lib/libfreetype.so $imagespath/jdk/lib/ 12 | 13 | cp -r $imagespath/jdk jdkout 14 | 15 | # JDK no longer create separate JRE image, so we have to create one manually. 16 | #mkdir -p jreout/bin 17 | #cp jdkout/bin/{java,jfr,keytool,rmiregistry} jreout/bin/ 18 | #cp -r jdkout/{conf,legal,lib,man,release} jreout/ 19 | #rm jreout/lib/src.zip 20 | 21 | export EXTRA_JLINK_OPTION= 22 | 23 | if [[ "$TARGET_JDK" == "aarch64" ]] || [[ "$TARGET_JDK" == "x86_64" ]]; then 24 | echo "Building for aarch64 or x86_64, introducing JVMCI module" 25 | export EXTRA_JLINK_OPTION=,jdk.internal.vm.ci 26 | fi 27 | 28 | # Produce the jre equivalent from the jdk (https://blog.adoptium.net/2021/10/jlink-to-produce-own-runtime/) 29 | export JLINK_STRIP_ARG="--strip-native-debug-symbols=exclude-debuginfo-files:objcopy=${OBJCOPY}" 30 | 31 | jlink \ 32 | --module-path=jdkout/jmods \ 33 | --add-modules java.base,java.compiler,java.datatransfer,java.desktop,java.instrument,java.logging,java.management,java.management.rmi,java.naming,java.net.http,java.prefs,java.rmi,java.scripting,java.se,java.security.jgss,java.security.sasl,java.sql,java.sql.rowset,java.transaction.xa,java.xml,java.xml.crypto,jdk.accessibility,jdk.charsets,jdk.crypto.cryptoki,jdk.crypto.ec,jdk.dynalink,jdk.httpserver,jdk.jdwp.agent,jdk.jfr,jdk.jsobject,jdk.localedata,jdk.management,jdk.management.agent,jdk.management.jfr,jdk.naming.dns,jdk.naming.rmi,jdk.net,jdk.nio.mapmode,jdk.sctp,jdk.security.auth,jdk.security.jgss,jdk.unsupported,jdk.xml.dom,jdk.zipfs,jdk.random$EXTRA_JLINK_OPTION \ 34 | --output jreout \ 35 | $JLINK_STRIP_ARG \ 36 | --no-man-pages \ 37 | --no-header-files \ 38 | --release-info=jdkout/release \ 39 | --compress=0 40 | 41 | cp freetype-${BUILD_FREETYPE_VERSION}/build_android-$TARGET_SHORT/lib/libfreetype.so jreout/lib/ 42 | cp freetype-${BUILD_FREETYPE_VERSION}/build_android-$TARGET_SHORT/lib/libfreetype.so jdkout/lib/ 43 | 44 | # mv jreout/lib/${TARGET_JDK}/libfontmanager.diz jreout/lib/${TARGET_JDK}/libfontmanager.diz.keep 45 | # find jreout -name "*.debuginfo" | xargs -- rm 46 | # mv jreout/lib/${TARGET_JDK}/libfontmanager.diz.keep jreout/lib/${TARGET_JDK}/libfontmanager.diz 47 | 48 | #find jdkout -name "*.debuginfo" | xargs -- rm 49 | find jdkout -name "*.debuginfo" -exec mv {} dizout/ \; 50 | 51 | find jdkout -name "*.dSYM" | xargs -- rm -rf 52 | 53 | #TODO: fix .dSYM stuff 54 | -------------------------------------------------------------------------------- /repackjre.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | ## Usage: 5 | ## ./repackjre.sh [path_to_normal_jre_tarballs] [output_path] 6 | 7 | # set args 8 | export in="$1" 9 | export out="$2" 10 | 11 | # set working dirs 12 | work="$in/work" 13 | work1="$in/work1" 14 | 15 | # make sure paths exist 16 | mkdir -p "$work" 17 | mkdir -p "$work1" 18 | mkdir -p "$out" 19 | 20 | # here comes a not-so-complicated functions to easily make desired arch 21 | ## Usage: makearch [jre_libs_dir_name] [name_in_tarball] 22 | makearch () { 23 | echo "Making $2..."; 24 | cd "$work"; 25 | tar xf $(find "$in" -name jre17-$2-*release.tar.xz) > /dev/null 2>&1; 26 | mv bin "$work1"/; 27 | mkdir -p "$work1"/lib; 28 | 29 | #mv lib/$1 "$work1"/lib/; 30 | mv lib/jexec "$work1"/lib/; 31 | 32 | # server contains the libjvm.so 33 | mv lib/server "$work1"/lib/; 34 | 35 | # All the other .so files are at the root of the lib folder 36 | find ./ -name '*.so' -execdir mv {} "$work1"/lib/{} \; 37 | 38 | mv release "$work1"/release 39 | 40 | XZ_OPT="-6 --threads=0" tar cJf bin-$2.tar.xz -C "$work1" . > /dev/null; 41 | mv bin-$2.tar.xz "$out"/; 42 | rm -rf "$work"/*; 43 | rm -rf "$work1"/*; 44 | } 45 | 46 | # this one's static 47 | makeuni () { 48 | echo "Making universal..."; 49 | cd "$work"; 50 | tar xf $(find "$in" -name jre17-arm64-*release.tar.xz) > /dev/null 2>&1; 51 | 52 | rm -rf bin; 53 | rm -rf lib/server; 54 | rm lib/jexec; 55 | find ./ -name '*.so' -execdir rm {} \; # Remove arch specific shared objects 56 | rm release 57 | 58 | XZ_OPT="-6 --threads=0" tar cJf universal.tar.xz * > /dev/null; 59 | mv universal.tar.xz "$out"/; 60 | rm -rf "$work"/*; 61 | } 62 | 63 | # now time to use them! 64 | makeuni 65 | makearch aarch32 arm 66 | makearch aarch64 arm64 67 | makearch i386 x86 68 | makearch amd64 x86_64 69 | 70 | # formatted system date 71 | date +%Y%m%d>"$out"/version 72 | -------------------------------------------------------------------------------- /setdevkitpath.sh: -------------------------------------------------------------------------------- 1 | # Use the old NDK r10e to not get internal compile error at (still?) 2 | # https://github.com/PojavLauncherTeam/openjdk-multiarch-jdk8u/blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/native/sun/java2d/loops/GraphicsPrimitiveMgr.c 3 | export NDK_VERSION=r27b 4 | 5 | if [[ -z "$BUILD_FREETYPE_VERSION" ]] 6 | then 7 | export BUILD_FREETYPE_VERSION="2.13.3" 8 | fi 9 | 10 | if [[ -z "$JDK_DEBUG_LEVEL" ]] 11 | then 12 | export JDK_DEBUG_LEVEL=release 13 | fi 14 | 15 | if [[ "$TARGET_JDK" == "aarch64" ]] 16 | then 17 | export TARGET_SHORT=arm64 18 | else 19 | export TARGET_SHORT=$TARGET_JDK 20 | fi 21 | 22 | if [[ -z "$JVM_VARIANTS" ]] 23 | then 24 | export JVM_VARIANTS=server 25 | fi 26 | 27 | export JVM_PLATFORM=linux 28 | # Set NDK 29 | export API=21 30 | 31 | # Runners usually ship with a recent NDK already 32 | if [[ -z "$ANDROID_NDK_HOME" ]] 33 | then 34 | export ANDROID_NDK_HOME=$PWD/android-ndk-$NDK_VERSION 35 | fi 36 | 37 | export TOOLCHAIN=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64 38 | 39 | export ANDROID_INCLUDE=$TOOLCHAIN/sysroot/usr/include 40 | 41 | export CPPFLAGS="-I$ANDROID_INCLUDE -I$ANDROID_INCLUDE/$TARGET" # -I/usr/include -I/usr/lib 42 | if [[ "$TARGET_JDK" == "arm" ]] 43 | then 44 | export LDFLAGS="-L$TOOLCHAIN/sysroot/usr/lib/${TARGET_2}/${API}" 45 | else 46 | export LDFLAGS="-L$TOOLCHAIN/sysroot/usr/lib/${TARGET}/${API}" 47 | fi 48 | export thecc=$TOOLCHAIN/bin/${TARGET}${API}-clang 49 | export thecxx=$TOOLCHAIN/bin/${TARGET}${API}-clang++ 50 | 51 | # Configure and build. 52 | export DLLTOOL=$TOOLCHAIN/bin/llvm-dlltool 53 | export CXXFILT=$TOOLCHAIN/bin/llvm-cxxfilt 54 | export NM=$TOOLCHAIN/bin/llvm-nm 55 | export CC=$PWD/android-wrapped-clang 56 | export CXX=$PWD/android-wrapped-clang++ 57 | export AR=$TOOLCHAIN/bin/llvm-ar 58 | export AS=$TOOLCHAIN/bin/llvm-as 59 | export LD=$TOOLCHAIN/bin/ld 60 | export OBJCOPY=$TOOLCHAIN/bin/llvm-objcopy 61 | export OBJDUMP=$TOOLCHAIN/bin/llvm-objdump 62 | export READELF=$TOOLCHAIN/bin/llvm-readelf 63 | export RANLIB=$TOOLCHAIN/bin/llvm-ranlib 64 | export STRIP=$TOOLCHAIN/bin/llvm-strip 65 | export LINK=$TOOLCHAIN/bin/llvm-link 66 | -------------------------------------------------------------------------------- /tarjdk.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | . setdevkitpath.sh 4 | 5 | unset AR AS CC CXX LD OBJCOPY RANLIB STRIP CPPFLAGS LDFLAGS 6 | git clone --depth 1 https://github.com/termux/termux-elf-cleaner || true 7 | cd termux-elf-cleaner 8 | mkdir build 9 | cd build 10 | export CFLAGS=-D__ANDROID_API__=${API} 11 | cmake .. 12 | make -j4 13 | unset CFLAGS 14 | cd ../.. 15 | 16 | findexec() { find $1 -type f -name "*" -not -name "*.o" -exec sh -c ' 17 | case "$(head -n 1 "$1")" in 18 | ?ELF*) exit 0;; 19 | MZ*) exit 0;; 20 | #!*/ocamlrun*)exit0;; 21 | esac 22 | exit 1 23 | ' sh {} \; -print 24 | } 25 | 26 | findexec jreout | xargs -- ./termux-elf-cleaner/build/termux-elf-cleaner 27 | findexec jdkout | xargs -- ./termux-elf-cleaner/build/termux-elf-cleaner 28 | 29 | cp -rv jre_override/lib/* jreout/lib/ || true 30 | cp -rv jre_override/lib/* jdkout/lib/ || true 31 | 32 | if [ "${TARGET_SHORT}" = "arm64" ] && [ -f jreout/lib/jspawnhelper ]; then 33 | cp jreout/lib/jspawnhelper libjsph17.so 34 | fi 35 | 36 | cd jreout 37 | 38 | # Strip 39 | find ./ -name '*.so' -execdir ${TOOLCHAIN}/bin/llvm-strip {} \; 40 | 41 | tar cJf ../jre17-${TARGET_SHORT}-`date +%Y%m%d`-${JDK_DEBUG_LEVEL}.tar.xz . 42 | 43 | cd ../jdkout 44 | tar cJf ../jdk17-${TARGET_SHORT}-`date +%Y%m%d`-${JDK_DEBUG_LEVEL}.tar.xz . 45 | 46 | # Remove jreout and jdkout 47 | cd .. 48 | rm -rf jreout jdkout 49 | --------------------------------------------------------------------------------