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