mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-25 02:39:43 +01:00
Compare commits
55 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d6de1034a | ||
|
|
2333999906 | ||
|
|
6ffcd2bf91 | ||
|
|
822b4a8c49 | ||
|
|
debc6336c0 | ||
|
|
1f93154f62 | ||
|
|
9f069ca59e | ||
|
|
53f1a647fd | ||
|
|
7d31563471 | ||
|
|
36ded60698 | ||
|
|
d53de90f8a | ||
|
|
6196076b95 | ||
|
|
0ee50cbed6 | ||
|
|
d6e6d315d2 | ||
|
|
0a3f7bd9b1 | ||
|
|
a2636bc8b2 | ||
|
|
11ad455c7a | ||
|
|
4141e567c0 | ||
|
|
8373eeea85 | ||
|
|
9f10f63459 | ||
|
|
0cb7b4565c | ||
|
|
e19109f401 | ||
|
|
c450a40e16 | ||
|
|
fe79f047d0 | ||
|
|
484bc6f18f | ||
|
|
1af965d658 | ||
|
|
d330782b50 | ||
|
|
ff6002ab87 | ||
|
|
ee9fe4ee55 | ||
|
|
b8e1373b53 | ||
|
|
1b9f385336 | ||
|
|
cd9cc5f395 | ||
|
|
54199dc06c | ||
|
|
66ddc58397 | ||
|
|
c5d124735c | ||
|
|
409e4932ad | ||
|
|
3bbd930114 | ||
|
|
0019142eaf | ||
|
|
41feaaedf0 | ||
|
|
3948c3538c | ||
|
|
497d00d82e | ||
|
|
37ceee0ce3 | ||
|
|
74dfdfbbfe | ||
|
|
8f1223d69a | ||
|
|
6d4c958c9a | ||
|
|
8730341c70 | ||
|
|
2aff4529b9 | ||
|
|
efd58e83eb | ||
|
|
1aa5510721 | ||
|
|
c14bfc9349 | ||
|
|
4d7b0f15c1 | ||
|
|
ac03a7a1e8 | ||
|
|
ba5209ec06 | ||
|
|
ed60a9c2bd | ||
|
|
9b4827a596 |
@@ -11,6 +11,7 @@ can be found on the [releases page](https://github.com/JetBrains/JetBrainsRuntim
|
||||
|
||||
| IDE Version | Latest JBR | Date Released |
|
||||
| --- | --- | --- |
|
||||
| 2022.1 | [17_0_2-b315.1](https://github.com/JetBrains/JetBrainsRuntime/releases/tag/jbr17_0_2b315.1) | 09-Feb-2022 |
|
||||
| 2021.3 | [17_0_1-b164.8](https://github.com/JetBrains/JetBrainsRuntime/releases/tag/jbr17_0_1b164.8) | 15-Nov-2021 |
|
||||
|
||||
## Contents
|
||||
|
||||
@@ -31,6 +31,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \
|
||||
libxt-dev \
|
||||
libxtst-dev \
|
||||
make \
|
||||
rsync \
|
||||
tar \
|
||||
unzip \
|
||||
zip && \
|
||||
|
||||
22
jb/project/docker/Dockerfile.musl_aarch64
Normal file
22
jb/project/docker/Dockerfile.musl_aarch64
Normal file
@@ -0,0 +1,22 @@
|
||||
# NOTE: This Dockerfile is meant to be used from the mkdocker_musl_aarch64.sh script.
|
||||
|
||||
# Pull a concrete version of Linux that does NOT recieve updates after it's
|
||||
# been created. This is so that the image is as stable as possible to make
|
||||
# image creation reproducible.
|
||||
# NB: this also means there may be no security-related fixes there, need to
|
||||
# move the version to the next manually.
|
||||
FROM arm64v8/alpine:3.12
|
||||
|
||||
# Install the necessary build tools
|
||||
RUN apk --no-cache add --update bash grep tar zip bzip2 rsync fontconfig build-base \
|
||||
git libx11-dev libxext-dev libxrandr-dev libxrender-dev libxt-dev \
|
||||
libxtst-dev autoconf freetype-dev cups-dev alsa-lib-dev file \
|
||||
fontconfig fontconfig-dev linux-headers
|
||||
|
||||
# Set up boot JDK for building
|
||||
COPY boot_jdk_musl_aarch64.tar.gz /jdk17/
|
||||
RUN cd /jdk17 && tar --strip-components=1 -xzf boot_jdk_musl_aarch64.tar.gz && rm /jdk17/boot_jdk_musl_aarch64.tar.gz
|
||||
ENV BOOT_JDK=/jdk17
|
||||
|
||||
RUN git config --global user.email "teamcity@jetbrains.com" && \
|
||||
git config --global user.name "builduser"
|
||||
22
jb/project/docker/Dockerfile.musl_x64
Normal file
22
jb/project/docker/Dockerfile.musl_x64
Normal file
@@ -0,0 +1,22 @@
|
||||
# NOTE: This Dockerfile is meant to be used from the mkdocker_musl_x64.sh script.
|
||||
|
||||
# Pull a concrete version of Linux that does NOT recieve updates after it's
|
||||
# been created. This is so that the image is as stable as possible to make
|
||||
# image creation reproducible.
|
||||
# NB: this also means there may be no security-related fixes there, need to
|
||||
# move the version to the next manually.
|
||||
FROM alpine:3.5
|
||||
|
||||
# Install the necessary build tools
|
||||
RUN apk --no-cache add --update bash grep tar zip bzip2 rsync fontconfig build-base \
|
||||
git libx11-dev libxext-dev libxrandr-dev libxrender-dev libxt-dev \
|
||||
libxtst-dev autoconf freetype-dev cups-dev alsa-lib-dev file \
|
||||
fontconfig fontconfig-dev linux-headers
|
||||
|
||||
# Set up boot JDK for building
|
||||
COPY boot_jdk_musl_amd64.tar.gz /jdk17/
|
||||
RUN cd /jdk17 && tar --strip-components=1 -xzf boot_jdk_musl_amd64.tar.gz && rm /jdk17/boot_jdk_musl_amd64.tar.gz
|
||||
ENV BOOT_JDK=/jdk17
|
||||
|
||||
RUN git config --global user.email "teamcity@jetbrains.com" && \
|
||||
git config --global user.name "builduser"
|
||||
26
jb/project/docker/mkdocker_musl_aarch64.sh
Executable file
26
jb/project/docker/mkdocker_musl_aarch64.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash -x
|
||||
|
||||
# This script creates a Docker image suitable for building musl AArch64 variant
|
||||
# of the JetBrains Runtime version 17.
|
||||
|
||||
BOOT_JDK_REMOTE_FILE=zulu17.32.13-ca-jdk17.0.2-linux_musl_aarch64.tar.gz
|
||||
BOOT_JDK_SHA=6b920559abafbe9bdef386a20ecf3a2f318bc1f0d8359eb1f95aee26606bbc70
|
||||
BOOT_JDK_LOCAL_FILE=boot_jdk_musl_aarch64.tar.gz
|
||||
|
||||
if [ ! -f $BOOT_JDK_LOCAL_FILE ]; then
|
||||
# Obtain "boot JDK" from outside of the container.
|
||||
wget -nc https://cdn.azul.com/zulu/bin/${BOOT_JDK_REMOTE_FILE} -O $BOOT_JDK_LOCAL_FILE
|
||||
else
|
||||
echo "boot JDK \"$BOOT_JDK_LOCAL_FILE\" present, skipping download"
|
||||
fi
|
||||
|
||||
# Verify that what we've downloaded can be trusted.
|
||||
sha256sum -c - <<EOF
|
||||
$BOOT_JDK_SHA *$BOOT_JDK_LOCAL_FILE
|
||||
EOF
|
||||
|
||||
docker build -t jbr17buildenv -f Dockerfile.musl_aarch64 .
|
||||
|
||||
# NB: the resulting container can (and should) be used without the network
|
||||
# connection (--network none) during build in order to reduce the chance
|
||||
# of build contamination.
|
||||
26
jb/project/docker/mkdocker_musl_x64.sh
Executable file
26
jb/project/docker/mkdocker_musl_x64.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash -x
|
||||
|
||||
# This script creates a Docker image suitable for building musl-x64 variant
|
||||
# of the JetBrains Runtime version 17.
|
||||
|
||||
BOOT_JDK_REMOTE_FILE=zulu17.32.13-ca-jdk17.0.2-linux_musl_x64.tar.gz
|
||||
BOOT_JDK_SHA=bcc5342011bd9f3643372aadbdfa68d47463ff0d8621668a0bdf2910614d95c6
|
||||
BOOT_JDK_LOCAL_FILE=boot_jdk_musl_amd64.tar.gz
|
||||
|
||||
if [ ! -f $BOOT_JDK_LOCAL_FILE ]; then
|
||||
# Obtain "boot JDK" from outside of the container.
|
||||
wget -nc https://cdn.azul.com/zulu/bin/${BOOT_JDK_REMOTE_FILE} -O $BOOT_JDK_LOCAL_FILE
|
||||
else
|
||||
echo "boot JDK \"$BOOT_JDK_LOCAL_FILE\" present, skipping download"
|
||||
fi
|
||||
|
||||
# Verify that what we've downloaded can be trusted.
|
||||
sha256sum -c - <<EOF
|
||||
$BOOT_JDK_SHA *$BOOT_JDK_LOCAL_FILE
|
||||
EOF
|
||||
|
||||
docker build -t jbr17buildenv -f Dockerfile.musl_x64 .
|
||||
|
||||
# NB: the resulting container can (and should) be used without the network
|
||||
# connection (--network none) during build in order to reduce the chance
|
||||
# of build contamination.
|
||||
@@ -1,6 +1,18 @@
|
||||
#!/bin/bash -x
|
||||
|
||||
tag_prefix="jbr-"
|
||||
function do_maketest() {
|
||||
if [ "${bundle_type: -1}" == "t" ]; then
|
||||
echo ${bundle_type%?}
|
||||
return 1
|
||||
else
|
||||
echo ${bundle_type}
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
function getVersionProp() {
|
||||
grep "^${1}" make/conf/version-numbers.conf | cut -d'=' -f2
|
||||
}
|
||||
|
||||
while getopts ":i?" o; do
|
||||
case "${o}" in
|
||||
@@ -12,27 +24,25 @@ while getopts ":i?" o; do
|
||||
done
|
||||
shift $((OPTIND-1))
|
||||
|
||||
if [ $# -le $min_parameters_count ]; then
|
||||
build_number=$1
|
||||
bundle_type=$2
|
||||
architecture=$3 # aarch64 or x64
|
||||
else
|
||||
JBSDK_VERSION=$1
|
||||
JDK_BUILD_NUMBER=$2
|
||||
build_number=$3
|
||||
bundle_type=$4
|
||||
architecture=$5 # aarch64 or x64
|
||||
fi
|
||||
build_number=$1
|
||||
bundle_type=$2
|
||||
architecture=$3 # aarch64 or x64
|
||||
|
||||
bundle_type=$(do_maketest)
|
||||
do_maketest=$?
|
||||
tag_prefix="jbr-"
|
||||
OPENJDK_TAG=$(git log --simplify-by-decoration --decorate=short --pretty=short | grep "$tag_prefix" | cut -d "(" -f2 | cut -d ")" -f1 | awk '{print $2}' | sort -t "-" -k 2 -g | tail -n 1)
|
||||
JBSDK_VERSION=${JBSDK_VERSION:=$(echo $OPENJDK_TAG | awk -F "-|[+]" '{print $2}')}
|
||||
VERSION_FEATURE=$(getVersionProp "DEFAULT_VERSION_FEATURE")
|
||||
VERSION_INTERIM=$(getVersionProp "DEFAULT_VERSION_INTERIM")
|
||||
VERSION_UPDATE=$(getVersionProp "DEFAULT_VERSION_UPDATE")
|
||||
[[ $VERSION_UPDATE = 0 ]] && JBSDK_VERSION="$VERSION_FEATURE" || JBSDK_VERSION="${VERSION_FEATURE}.${VERSION_INTERIM}.${VERSION_UPDATE}"
|
||||
echo "##teamcity[setParameter name='env.JBSDK_VERSION' value='${JBSDK_VERSION}']"
|
||||
JDK_BUILD_NUMBER=${JDK_BUILD_NUMBER:=$(echo $OPENJDK_TAG | awk -F "-|[+]" '{print $3}')}
|
||||
[ -z $JDK_BUILD_NUMBER ] && JDK_BUILD_NUMBER=1
|
||||
echo "##teamcity[setParameter name='env.JDK_UPDATE_NUMBER' value='${JDK_BUILD_NUMBER}']"
|
||||
JBSDK_VERSION_WITH_DOTS=$(echo $JBSDK_VERSION | sed 's/_/\./g')
|
||||
|
||||
VENDOR_NAME="JetBrains s.r.o."
|
||||
VENDOR_VERSION_STRING="JBR-${JBSDK_VERSION_WITH_DOTS}+${JDK_BUILD_NUMBER}-${build_number}"
|
||||
VENDOR_VERSION_STRING="JBR-${JBSDK_VERSION}+${JDK_BUILD_NUMBER}-${build_number}"
|
||||
[ -z "$bundle_type" ] || VENDOR_VERSION_STRING="${VENDOR_VERSION_STRING}-${bundle_type}"
|
||||
|
||||
do_reset_changes=0
|
||||
@@ -54,26 +64,40 @@ case "$OS_NAME" in
|
||||
BUILD_TIME="$(date --utc --date=@$SOURCE_DATE_EPOCH +%F)"
|
||||
REPRODUCIBLE_TAR_OPTS="--mtime=@$SOURCE_DATE_EPOCH --owner=0 --group=0 --numeric-owner --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime"
|
||||
;;
|
||||
CYGWIN*)
|
||||
COPYRIGHT_YEAR="$(date --utc --date=@$SOURCE_DATE_EPOCH +%Y)"
|
||||
BUILD_TIME="$(date --utc --date=@$SOURCE_DATE_EPOCH +%F)"
|
||||
REPRODUCIBLE_TAR_OPTS="--mtime=@$SOURCE_DATE_EPOCH --owner=0 --group=0 --numeric-owner --pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime"
|
||||
;;
|
||||
Darwin)
|
||||
COPYRIGHT_YEAR="$(date -u -r $SOURCE_DATE_EPOCH +%Y)"
|
||||
BUILD_TIME="$(date -u -r $SOURCE_DATE_EPOCH +%F)"
|
||||
TOUCH_TIME="$(date -u -r $SOURCE_DATE_EPOCH +%Y%m%d%H%M.%S)"
|
||||
REPRODUCIBLE_TAR_OPTS="--uid 0 --gid 0 --numeric-owner"
|
||||
;;
|
||||
*)
|
||||
# TODO: Windows
|
||||
;;
|
||||
esac
|
||||
|
||||
WITH_ZIPPED_NATIVE_DEBUG_SYMBOLS="--with-native-debug-symbols=zipped"
|
||||
|
||||
REPRODUCIBLE_BUILD_OPTS="--enable-reproducible-build
|
||||
--with-source-date=$SOURCE_DATE_EPOCH
|
||||
--with-hotspot-build-time=$BUILD_TIME
|
||||
--with-copyright-year=$COPYRIGHT_YEAR
|
||||
--disable-absolute-paths-in-output"
|
||||
|
||||
function zip_native_debug_symbols() {
|
||||
image_bundle_path=$(echo $1 | cut -d"/" -f-4)
|
||||
jbr_diz_name=$2
|
||||
|
||||
(cd $image_bundle_path && find . -name '*.diz' -exec rsync -R {} ../../../../dizfiles \; )
|
||||
|
||||
(cd dizfiles && find . -print0 | COPYFILE_DISABLE=1 \
|
||||
tar --no-recursion --null -T - -czf ../"$jbr_diz_name".tar.gz) || do_exit $?
|
||||
}
|
||||
|
||||
function do_exit() {
|
||||
exit_code=$1
|
||||
[ $do_reset_changes -eq 1 ] && git checkout HEAD modules.list src/java.desktop/share/classes/module-info.java
|
||||
[ $do_reset_changes -eq 1 ] && git checkout HEAD jb/project/tools/common/modules.list src/java.desktop/share/classes/module-info.java
|
||||
if [ $do_reset_dcevm -eq 1 ]; then
|
||||
[ ! -z $HEAD_REVISION ] && git reset --hard $HEAD_REVISION
|
||||
fi
|
||||
|
||||
@@ -1,24 +1,26 @@
|
||||
#!/bin/bash -x
|
||||
|
||||
# The following parameters must be specified:
|
||||
# JBSDK_VERSION - specifies the current version of OpenJDK e.g. 11_0_6
|
||||
# JDK_BUILD_NUMBER - specifies the number of OpenJDK build or the value of --with-version-build argument to configure
|
||||
# build_number - specifies the number of JetBrainsRuntime build
|
||||
#
|
||||
# jbrsdk-${JBSDK_VERSION}-osx-x64-b${build_number}.tar.gz
|
||||
# jbr-${JBSDK_VERSION}-osx-x64-b${build_number}.tar.gz
|
||||
#
|
||||
# $ ./java --version
|
||||
# openjdk 11.0.6 2020-01-14
|
||||
# OpenJDK Runtime Environment (build 11.0.6+${JDK_BUILD_NUMBER}-b${build_number})
|
||||
# OpenJDK 64-Bit Server VM (build 11.0.6+${JDK_BUILD_NUMBER}-b${build_number}, mixed mode)
|
||||
# The following parameter must be specified:
|
||||
# build_number - specifies the number of JetBrainsRuntime build
|
||||
#
|
||||
|
||||
min_parameters_count=1
|
||||
source jb/project/tools/common/scripts/common.sh
|
||||
|
||||
function is_musl {
|
||||
libc=$(ldd /bin/ls | grep 'musl' | head -1 | cut -d ' ' -f1)
|
||||
if [ -z $libc ]; then
|
||||
# This is not Musl, return 1 == false
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
JBRSDK_BASE_NAME=jbrsdk-${JBSDK_VERSION}
|
||||
|
||||
LIBC_TYPE_SUFFIX=''
|
||||
|
||||
if is_musl; then LIBC_TYPE_SUFFIX='musl-' ; fi
|
||||
|
||||
sh configure \
|
||||
--with-debug-level=release \
|
||||
--with-vendor-name="${VENDOR_NAME}" \
|
||||
@@ -30,11 +32,12 @@ sh configure \
|
||||
--with-boot-jdk=${BOOT_JDK} \
|
||||
--enable-cds=yes \
|
||||
$REPRODUCIBLE_BUILD_OPTS \
|
||||
$WITH_ZIPPED_NATIVE_DEBUG_SYMBOLS \
|
||||
|| exit $?
|
||||
make clean CONF=linux-aarch64-server-release || exit $?
|
||||
make images CONF=linux-aarch64-server-release test-image || exit $?
|
||||
|
||||
JBSDK=${JBRSDK_BASE_NAME}-linux-aarch64-b${build_number}
|
||||
JBSDK=${JBRSDK_BASE_NAME}-linux-${LIBC_TYPE_SUFFIX}aarch64-b${build_number}
|
||||
BASE_DIR=build/linux-aarch64-server-release/images
|
||||
JSDK=${BASE_DIR}/jdk
|
||||
JBRSDK_BUNDLE=jbrsdk
|
||||
@@ -49,6 +52,8 @@ echo Creating $JBSDK.tar.gz ...
|
||||
sed 's/JBR/JBRSDK/g' ${BASE_DIR}/${JBRSDK_BUNDLE}/release > release
|
||||
mv release ${BASE_DIR}/${JBRSDK_BUNDLE}/release
|
||||
|
||||
zip_native_debug_symbols $JSDK "${JBSDK}_diz"
|
||||
|
||||
# NB: --sort=name requires tar1.28
|
||||
tar $REPRODUCIBLE_TAR_OPTS --sort=name -pcf $JBSDK.tar \
|
||||
--exclude=*.debuginfo --exclude=demo --exclude=sample --exclude=man \
|
||||
@@ -60,8 +65,8 @@ JBR_BUNDLE=jbr
|
||||
JBR_BASE_NAME=jbr-$JBSDK_VERSION
|
||||
rm -rf $BASE_DIR/$JBR_BUNDLE
|
||||
|
||||
JBR=$JBR_BASE_NAME-linux-aarch64-b$build_number
|
||||
grep -v javafx modules.list | grep -v "jdk.internal.vm\|jdk.aot\|jcef" > modules.list.aarch64
|
||||
JBR=$JBR_BASE_NAME-linux-${LIBC_TYPE_SUFFIX}aarch64-b$build_number
|
||||
grep -v javafx jb/project/tools/common/modules.list | grep -v "jdk.internal.vm\|jdk.aot\|jcef" > modules.list.aarch64
|
||||
echo Running jlink....
|
||||
${JSDK}/bin/jlink \
|
||||
--module-path ${JSDK}/jmods --no-man-pages --compress=2 \
|
||||
@@ -76,7 +81,7 @@ tar $REPRODUCIBLE_TAR_OPTS --sort=name -pcf $JBR.tar -C $BASE_DIR ${JBR_BUNDLE}
|
||||
touch -c -d @$SOURCE_DATE_EPOCH $JBR.tar
|
||||
gzip $JBR.tar || exit $?
|
||||
|
||||
JBRSDK_TEST=$JBRSDK_BASE_NAME-linux-test-aarch64-b$build_number
|
||||
JBRSDK_TEST=$JBRSDK_BASE_NAME-linux-${LIBC_TYPE_SUFFIX}test-aarch64-b$build_number
|
||||
echo Creating $JBRSDK_TEST.tar.gz ...
|
||||
tar -pcf $JBRSDK_TEST.tar -C $BASE_DIR --exclude='test/jdk/demos' test || exit $?
|
||||
gzip $JBRSDK_TEST.tar || exit $?
|
||||
|
||||
@@ -1,27 +1,22 @@
|
||||
#!/bin/bash -x
|
||||
|
||||
# The following parameters must be specified:
|
||||
# JBSDK_VERSION - specifies major version of OpenJDK e.g. 11_0_6 (instead of dots '.' underbars "_" are used)
|
||||
# JDK_BUILD_NUMBER - specifies update release of OpenJDK build or the value of --with-version-build argument to configure
|
||||
# build_number - specifies the number of JetBrainsRuntime build
|
||||
# bundle_type - specifies bundle to be built; possible values:
|
||||
# <empty> or nomod - the release bundles without any additional modules (jcef)
|
||||
# jcef - the release bundles with jcef
|
||||
# fd - the fastdebug bundles which also include the jcef module
|
||||
# build_number - specifies the number of JetBrainsRuntime build
|
||||
# bundle_type - specifies bundle to be built;possible values:
|
||||
# <empty> or nomod - the release bundles without any additional modules (jcef)
|
||||
# jcef - the release bundles with jcef
|
||||
# fd - the fastdebug bundles which also include the jcef module
|
||||
#
|
||||
# jbrsdk-${JBSDK_VERSION}-osx-x64-b${build_number}.tar.gz
|
||||
# jbr-${JBSDK_VERSION}-osx-x64-b${build_number}.tar.gz
|
||||
#
|
||||
# $ ./java --version
|
||||
# openjdk 11.0.6 2020-01-14
|
||||
# OpenJDK Runtime Environment (build 11.0.6+${JDK_BUILD_NUMBER}-b${build_number})
|
||||
# OpenJDK 64-Bit Server VM (build 11.0.6+${JDK_BUILD_NUMBER}-b${build_number}, mixed mode)
|
||||
# This script makes test-image along with JDK images when bundle_type is set to "jcef".
|
||||
# If the character 't' is added at the end of bundle_type then it also makes test-image along with JDK images.
|
||||
#
|
||||
# Environment variables:
|
||||
# JDK_BUILD_NUMBER - specifies update release of OpenJDK build or the value of --with-version-build argument
|
||||
# to configure
|
||||
# By default JDK_BUILD_NUMBER is set zero
|
||||
# JCEF_PATH - specifies the path to the directory with JCEF binaries.
|
||||
# By default JCEF binaries should be located in ./jcef_linux_x64
|
||||
|
||||
min_parameters_count=2
|
||||
source jb/project/tools/common/scripts/common.sh
|
||||
|
||||
JCEF_PATH=${JCEF_PATH:=./jcef_linux_x64}
|
||||
@@ -38,17 +33,31 @@ function do_configure {
|
||||
--with-boot-jdk="$BOOT_JDK" \
|
||||
--enable-cds=yes \
|
||||
$REPRODUCIBLE_BUILD_OPTS \
|
||||
$WITH_ZIPPED_NATIVE_DEBUG_SYMBOLS \
|
||||
|| do_exit $?
|
||||
}
|
||||
|
||||
function is_musl {
|
||||
libc=$(ldd /bin/ls | grep 'musl' | head -1 | cut -d ' ' -f1)
|
||||
if [ -z $libc ]; then
|
||||
# This is not Musl, return 1 == false
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
function create_image_bundle {
|
||||
__bundle_name=$1
|
||||
__arch_name=$2
|
||||
__modules_path=$3
|
||||
__modules=$4
|
||||
|
||||
libc_type_suffix=''
|
||||
|
||||
if is_musl; then libc_type_suffix='musl-' ; fi
|
||||
|
||||
[ "$bundle_type" == "fd" ] && [ "$__arch_name" == "$JBRSDK_BUNDLE" ] && __bundle_name=$__arch_name && fastdebug_infix="fastdebug-"
|
||||
JBR=${__bundle_name}-${JBSDK_VERSION}-linux-x64-${fastdebug_infix}b${build_number}
|
||||
JBR=${__bundle_name}-${JBSDK_VERSION}-linux-${libc_type_suffix}x64-${fastdebug_infix}b${build_number}
|
||||
|
||||
echo Running jlink....
|
||||
[ -d "$IMAGES_DIR"/"$__arch_name" ] && rm -rf "${IMAGES_DIR:?}"/"$__arch_name"
|
||||
@@ -61,6 +70,7 @@ function create_image_bundle {
|
||||
sed 's/JBR/JBRSDK/g' "$IMAGES_DIR"/"$__arch_name"/release > release
|
||||
mv release "$IMAGES_DIR"/"$__arch_name"/release
|
||||
copy_jmods "$__modules" "$__modules_path" "$IMAGES_DIR"/"$__arch_name"/jmods
|
||||
zip_native_debug_symbols $IMAGES_DIR/jdk "${JBR}_diz"
|
||||
fi
|
||||
|
||||
# jmod does not preserve file permissions (JDK-8173610)
|
||||
@@ -85,6 +95,7 @@ RELEASE_NAME=linux-x86_64-server-release
|
||||
case "$bundle_type" in
|
||||
"jcef")
|
||||
do_reset_changes=1
|
||||
do_maketest=1
|
||||
;;
|
||||
"nomod" | "")
|
||||
bundle_type=""
|
||||
@@ -119,7 +130,7 @@ if [ "$bundle_type" == "jcef" ] || [ "$bundle_type" == "fd" ]; then
|
||||
fi
|
||||
|
||||
# create runtime image bundle
|
||||
modules=$(xargs < modules.list | sed s/" "//g) || do_exit $?
|
||||
modules=$(xargs < jb/project/tools/common/modules.list | sed s/" "//g) || do_exit $?
|
||||
create_image_bundle "jbr${jbr_name_postfix}" "jbr" $JSDK_MODS_DIR "$modules" || do_exit $?
|
||||
|
||||
# create sdk image bundle
|
||||
@@ -129,9 +140,10 @@ if [ "$bundle_type" == "jcef" ] || [ "$bundle_type" == "fd" ] || [ "$bundle_type
|
||||
fi
|
||||
create_image_bundle "$JBRSDK_BUNDLE${jbr_name_postfix}" $JBRSDK_BUNDLE $JSDK_MODS_DIR "$modules" || do_exit $?
|
||||
|
||||
if [ -z "$bundle_type" ]; then
|
||||
JBRSDK_TEST=${JBRSDK_BUNDLE}-${JBSDK_VERSION}-linux-test-x64-b${build_number}
|
||||
if [ $do_maketest -eq 1 ]; then
|
||||
JBRSDK_TEST=${JBRSDK_BUNDLE}-${JBSDK_VERSION}-linux-${libc_type_suffix}test-x64-b${build_number}
|
||||
echo Creating "$JBRSDK_TEST" ...
|
||||
[ $do_reset_changes -eq 1 ] && git checkout HEAD jb/project/tools/common/modules.list src/java.desktop/share/classes/module-info.java
|
||||
make test-image CONF=$RELEASE_NAME || do_exit $?
|
||||
tar -pcf "$JBRSDK_TEST".tar -C $IMAGES_DIR --exclude='test/jdk/demos' test || do_exit $?
|
||||
[ -f "$JBRSDK_TEST.tar.gz" ] && rm "$JBRSDK_TEST.tar.gz"
|
||||
|
||||
@@ -61,7 +61,7 @@ JBR_BASE_NAME=jbr-$JBSDK_VERSION
|
||||
rm -rf $BASE_DIR/$JBR_BUNDLE
|
||||
|
||||
JBR=$JBR_BASE_NAME-linux-x86-b$build_number
|
||||
grep -v javafx modules.list | grep -v "jdk.internal.vm\|jdk.aot\|jcef" > modules.list.x86
|
||||
grep -v javafx jb/project/tools/common/modules.list | grep -v "jdk.internal.vm\|jdk.aot\|jcef" > modules.list.x86
|
||||
echo Running jlink....
|
||||
${JSDK}/bin/jlink \
|
||||
--module-path ${JSDK}/jmods --no-man-pages --compress=2 \
|
||||
@@ -77,4 +77,4 @@ gzip $JBR.tar || exit $?
|
||||
JBRSDK_TEST=$JBRSDK_BASE_NAME-linux-test-x86-b$build_number
|
||||
echo Creating $JBRSDK_TEST.tar.gz ...
|
||||
tar -pcf $JBRSDK_TEST.tar -C $BASE_DIR --exclude='test/jdk/demos' --exclude='test/hotspot/gtest' test || exit $?
|
||||
gzip $JBRSDK_TEST.tar || exit $?
|
||||
gzip $JBRSDK_TEST.tar || exit $?
|
||||
|
||||
@@ -1,29 +1,24 @@
|
||||
#!/bin/bash -x
|
||||
|
||||
# The following parameters must be specified:
|
||||
# JBSDK_VERSION - specifies major version of OpenJDK e.g. 11_0_6 (instead of dots '.' underbars "_" are used)
|
||||
# JDK_BUILD_NUMBER - specifies update release of OpenJDK build or the value of --with-version-build argument to configure
|
||||
# build_number - specifies the number of JetBrainsRuntime build
|
||||
# bundle_type - specifies bundle to be built; possible values:
|
||||
# <empty> or nomod - the release bundles without any additional modules (jcef)
|
||||
# jcef - the release bundles with jcef
|
||||
# fd - the fastdebug bundles which also include the jcef module
|
||||
# build_number - specifies the number of JetBrainsRuntime build
|
||||
# bundle_type - specifies bundle to be built;possible values:
|
||||
# <empty> or nomod - the release bundles without any additional modules (jcef)
|
||||
# jcef - the release bundles with jcef
|
||||
# fd - the fastdebug bundles which also include the jcef module
|
||||
#
|
||||
# jbrsdk-${JBSDK_VERSION}-osx-x64-b${build_number}.tar.gz
|
||||
# jbr-${JBSDK_VERSION}-osx-x64-b${build_number}.tar.gz
|
||||
#
|
||||
# $ ./java --version
|
||||
# openjdk 11.0.6 2020-01-14
|
||||
# OpenJDK Runtime Environment (build 11.0.6+${JDK_BUILD_NUMBER}-b${build_number})
|
||||
# OpenJDK 64-Bit Server VM (build 11.0.6+${JDK_BUILD_NUMBER}-b${build_number}, mixed mode)
|
||||
# This script makes test-image along with JDK images when bundle_type is set to "jcef".
|
||||
# If the character 't' is added at the end of bundle_type then it also makes test-image along with JDK images.
|
||||
#
|
||||
# Environment variables:
|
||||
# JDK_BUILD_NUMBER - specifies update release of OpenJDK build or the value of --with-version-build argument
|
||||
# to configure
|
||||
# By default JDK_BUILD_NUMBER is set zero
|
||||
# JCEF_PATH - specifies the path to the directory with JCEF binaries.
|
||||
# By default JCEF binaries should be located in ./jcef_mac
|
||||
# MACOSX_VERSION_MAX - specifies value for the --with-macosx-version-max parameter. By default it is 10.12.00 for x64
|
||||
# and 11.00.00 for aarch64
|
||||
|
||||
min_parameters_count=3
|
||||
source jb/project/tools/common/scripts/common.sh
|
||||
|
||||
JCEF_PATH=${JCEF_PATH:=./jcef_mac}
|
||||
@@ -50,6 +45,7 @@ function do_configure {
|
||||
--with-extra-cxxflags="-F$(pwd)/Frameworks" \
|
||||
--with-extra-ldflags="-F$(pwd)/Frameworks" \
|
||||
$REPRODUCIBLE_BUILD_OPTS \
|
||||
$WITH_ZIPPED_NATIVE_DEBUG_SYMBOLS \
|
||||
|| do_exit $?
|
||||
else
|
||||
sh configure \
|
||||
@@ -66,6 +62,7 @@ function do_configure {
|
||||
--with-macosx-version-max="${MACOSX_VERSION_MAX:="10.12.00"}" \
|
||||
--enable-cds=yes \
|
||||
$REPRODUCIBLE_BUILD_OPTS \
|
||||
$WITH_ZIPPED_NATIVE_DEBUG_SYMBOLS \
|
||||
|| do_exit $?
|
||||
fi
|
||||
}
|
||||
@@ -95,6 +92,7 @@ function create_image_bundle {
|
||||
sed 's/JBR/JBRSDK/g' $JRE_CONTENTS/Home/release > release
|
||||
mv release $JRE_CONTENTS/Home/release
|
||||
copy_jmods "$__modules" "$__modules_path" "$JRE_CONTENTS"/Home/jmods
|
||||
zip_native_debug_symbols $IMAGES_DIR/jdk-bundle/jdk-$JBSDK_VERSION.jdk "${JBR}_diz"
|
||||
fi
|
||||
|
||||
cp -R "$JSDK"/../MacOS "$JRE_CONTENTS"
|
||||
@@ -124,6 +122,7 @@ RELEASE_NAME=macosx-${CONF_ARCHITECTURE}-server-release
|
||||
case "$bundle_type" in
|
||||
"jcef")
|
||||
do_reset_changes=1
|
||||
do_maketest=1
|
||||
;;
|
||||
"nomod" | "")
|
||||
bundle_type=""
|
||||
@@ -144,10 +143,7 @@ make images CONF=$RELEASE_NAME || do_exit $?
|
||||
|
||||
IMAGES_DIR=build/$RELEASE_NAME/images
|
||||
|
||||
major_version=$(echo "$JBSDK_VERSION_WITH_DOTS" | awk -F "." '{print $1}')
|
||||
minor_version=$(echo "$JBSDK_VERSION_WITH_DOTS" | awk -F "." '{print $3}')
|
||||
[ -z "$minor_version" -o "$minor_version" = "0" ] && version_dir=$major_version || version_dir=$JBSDK_VERSION_WITH_DOTS
|
||||
JSDK=$IMAGES_DIR/jdk-bundle/jdk-$version_dir.jdk/Contents/Home
|
||||
JSDK=$IMAGES_DIR/jdk-bundle/jdk-$JBSDK_VERSION.jdk/Contents/Home
|
||||
JSDK_MODS_DIR=$IMAGES_DIR/jmods
|
||||
JBRSDK_BUNDLE=jbrsdk
|
||||
|
||||
@@ -160,7 +156,7 @@ if [ "$bundle_type" == "jcef" ] || [ "$bundle_type" == "fd" ]; then
|
||||
fi
|
||||
|
||||
# create runtime image bundle
|
||||
modules=$(xargs < modules.list | sed s/" "//g) || do_exit $?
|
||||
modules=$(xargs < jb/project/tools/common/modules.list | sed s/" "//g) || do_exit $?
|
||||
create_image_bundle "jbr${jbr_name_postfix}" "jbr" $JSDK_MODS_DIR "$modules" || do_exit $?
|
||||
|
||||
# create sdk image bundle
|
||||
@@ -170,9 +166,10 @@ if [ "$bundle_type" == "jcef" ] || [ "$bundle_type" == "fd" ] || [ "$bundle_type
|
||||
fi
|
||||
create_image_bundle "$JBRSDK_BUNDLE${jbr_name_postfix}" "$JBRSDK_BUNDLE" "$JSDK_MODS_DIR" "$modules" || do_exit $?
|
||||
|
||||
if [ -z "$bundle_type" ]; then
|
||||
if [ $do_maketest -eq 1 ]; then
|
||||
JBRSDK_TEST=${JBRSDK_BUNDLE}-${JBSDK_VERSION}-osx-test-${architecture}-b${build_number}
|
||||
echo Creating "$JBRSDK_TEST" ...
|
||||
[ $do_reset_changes -eq 1 ] && git checkout HEAD jb/project/tools/common/modules.list src/java.desktop/share/classes/module-info.java
|
||||
make test-image CONF=$RELEASE_NAME || do_exit $?
|
||||
[ -f "$JBRSDK_TEST.tar.gz" ] && rm "$JBRSDK_TEST.tar.gz"
|
||||
COPYFILE_DISABLE=1 tar -pczf "$JBRSDK_TEST".tar.gz -C $IMAGES_DIR --exclude='test/jdk/demos' test || do_exit $?
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
diff --git modules.list modules.list
|
||||
index 054f21d1ee0..d9a121f0273 100644
|
||||
--- modules.list
|
||||
+++ modules.list
|
||||
@@ -49,4 +49,7 @@ jdk.unsupported,
|
||||
diff --git jb/project/tools/common/modules.list jb/project/tools/common/modules.list
|
||||
index 522acb7cb43..c40e689d5de 100644
|
||||
--- jb/project/tools/common/modules.list
|
||||
+++ jb/project/tools/common/modules.list
|
||||
@@ -51,4 +51,7 @@ jdk.unsupported.desktop,
|
||||
jdk.xml.dom,
|
||||
jdk.zipfs,
|
||||
jdk.hotspot.agent,
|
||||
|
||||
@@ -25,16 +25,39 @@ case "${unameOut}" in
|
||||
echo "Unknown machine: ${unameOut}"
|
||||
exit 1
|
||||
esac
|
||||
FILENAME=$(basename ${NEWFILEPATH})
|
||||
#
|
||||
# Get pattern of artifact name
|
||||
# Base filename pattern: <BUNDLE_TYPE>-<JDK_VERSION>-<OS>-<ARCH>-b<BUILD>.tar.gz: jbr_dcevm-17.0.2-osx-x64-b1234.tar.gz
|
||||
# BUNDLE_TYPE: jbr, jbrsdk, jbr_dcevm, jbrsdk_jcef etc.
|
||||
# OS_ARCH_PATTERN - <os_architecture>: osx-x64, linux-aarch64, windows-x64 etc.
|
||||
|
||||
echo "New size of $NEWFILEPATH = $NEWFILESIZE bytes."
|
||||
BUNDLE_TYPE=jbrsdk
|
||||
OS_ARCH_PATTERN=""
|
||||
re='(jbr[a-z_]*).+[0-9_]+-(.+)-b.+\.tar\.gz'
|
||||
if [[ $FILENAME =~ $re ]]; then
|
||||
BUNDLE_TYPE=${BASH_REMATCH[1]}
|
||||
OS_ARCH_PATTERN=${BASH_REMATCH[2]}
|
||||
fi
|
||||
echo "BUNDLE_TYPE: " $BUNDLE_TYPE
|
||||
echo "OS_ARCH_PATTERN: " $OS_ARCH_PATTERN
|
||||
echo "New size of $FILENAME = $NEWFILESIZE bytes."
|
||||
|
||||
# example: IntellijCustomJdk_Jdk17_Master_LinuxX64jcef
|
||||
|
||||
#
|
||||
# Get previous successful build ID
|
||||
# Example:
|
||||
# CONFIGID=IntellijCustomJdk_Jdk17_Master_LinuxX64jcef
|
||||
# BUILDID=12345678
|
||||
#
|
||||
# expected return value
|
||||
# id="123".number="567"
|
||||
#
|
||||
CURL_RESPONSE=$(curl --header "Authorization: Bearer $TOKEN" "https://buildserver.labs.intellij.net/app/rest/builds/?locator=buildType:(id:$CONFIGID),status:success,count:1,finishDate:(build:$BUILDID,condition:before)")
|
||||
re='id=\"([0-9]+)\".+number=\"([0-9\.]+)\"'
|
||||
|
||||
re='id=\"([0-9]+)\".+number=\"([0-9]+)\"'
|
||||
# ID: Previous successful build id
|
||||
ID=0
|
||||
|
||||
if [[ $CURL_RESPONSE =~ $re ]]; then
|
||||
ID=${BASH_REMATCH[1]}
|
||||
echo "BUILD Number: ${BASH_REMATCH[2]}"
|
||||
@@ -44,13 +67,18 @@ else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#
|
||||
# Get artifacts from previous successful build
|
||||
#
|
||||
# expected return value
|
||||
# name="jbrsdk_jcef*.tar.gz size="123'
|
||||
#
|
||||
CURL_RESPONSE=$(curl --header "Authorization: Bearer $TOKEN" "https://buildserver.labs.intellij.net/app/rest/builds/$ID?fields=id,number,artifacts(file(name,size))")
|
||||
|
||||
echo "Atrifacts of last pinned build of $CONFIGID :\n"
|
||||
echo "Atrifacts of previous build of $CONFIGID :"
|
||||
echo $CURL_RESPONSE
|
||||
|
||||
# Find size (in response) with reg exp
|
||||
re='name=\"(jbrsdk_jcef[^\"]+\.tar\.gz)\" size=\"([0-9]+)\"'
|
||||
# Find binary size (in response) with reg exp
|
||||
re='name=\"('$BUNDLE_TYPE'[^\"]+'${OS_ARCH_PATTERN}'[^\"]+\.tar\.gz)\" size=\"([0-9]+)\"'
|
||||
|
||||
if [[ $CURL_RESPONSE =~ $re ]]; then
|
||||
OLDFILENAME=${BASH_REMATCH[1]}
|
||||
@@ -63,6 +91,8 @@ if [[ $CURL_RESPONSE =~ $re ]]; then
|
||||
if [[ "$NEWFILESIZE" -gt "$allowedSize" ]]; then
|
||||
echo "ERROR: new size is significally greater than prev size (need to investigate)"
|
||||
exit 1
|
||||
else
|
||||
echo "PASSED"
|
||||
fi
|
||||
else
|
||||
echo "ERROR: can't find string with size in xml response:"
|
||||
|
||||
@@ -1,27 +1,22 @@
|
||||
#!/bin/bash -x
|
||||
|
||||
# The following parameters must be specified:
|
||||
# JBSDK_VERSION - specifies major version of OpenJDK e.g. 11_0_6 (instead of dots '.' underbars "_" are used)
|
||||
# JDK_BUILD_NUMBER - specifies update release of OpenJDK build or the value of --with-version-build argument to configure
|
||||
# build_number - specifies the number of JetBrainsRuntime build
|
||||
# bundle_type - specifies bundle to be built; possible values:
|
||||
# <empty> or nomod - the release bundles without any additional modules (jcef)
|
||||
# jcef - the release bundles with jcef
|
||||
# fd - the fastdebug bundles which also include the jcef module
|
||||
# build_number - specifies the number of JetBrainsRuntime build
|
||||
# bundle_type - specifies bundle to be built;possible values:
|
||||
# <empty> or nomod - the release bundles without any additional modules (jcef)
|
||||
# jcef - the release bundles with jcef
|
||||
# fd - the fastdebug bundles which also include the jcef module
|
||||
#
|
||||
# jbrsdk-${JBSDK_VERSION}-osx-x64-b${build_number}.tar.gz
|
||||
# jbr-${JBSDK_VERSION}-osx-x64-b${build_number}.tar.gz
|
||||
#
|
||||
# $ ./java --version
|
||||
# openjdk 11.0.6 2020-01-14
|
||||
# OpenJDK Runtime Environment (build 11.0.6+${JDK_BUILD_NUMBER}-b${build_number})
|
||||
# OpenJDK 64-Bit Server VM (build 11.0.6+${JDK_BUILD_NUMBER}-b${build_number}, mixed mode)
|
||||
# This script makes test-image along with JDK images when bundle_type is set to "jcef".
|
||||
# If the character 't' is added at the end of bundle_type then it also makes test-image along with JDK images.
|
||||
#
|
||||
# Environment variables:
|
||||
# JDK_BUILD_NUMBER - specifies update release of OpenJDK build or the value of --with-version-build argument
|
||||
# to configure
|
||||
# By default JDK_BUILD_NUMBER is set zero
|
||||
# JCEF_PATH - specifies the path to the directory with JCEF binaries.
|
||||
# By default JCEF binaries should be located in ./jcef_win_x64
|
||||
|
||||
min_parameters_count=2
|
||||
source jb/project/tools/common/scripts/common.sh
|
||||
|
||||
WORK_DIR=$(pwd)
|
||||
@@ -39,7 +34,9 @@ function do_configure {
|
||||
--with-toolchain-version=$TOOLCHAIN_VERSION \
|
||||
--with-boot-jdk=$BOOT_JDK \
|
||||
--disable-ccache \
|
||||
--enable-cds=yes || do_exit $?
|
||||
--enable-cds=yes \
|
||||
$REPRODUCIBLE_BUILD_OPTS \
|
||||
|| do_exit $?
|
||||
}
|
||||
|
||||
function create_image_bundle {
|
||||
@@ -69,6 +66,7 @@ RELEASE_NAME=windows-x86_64-server-release
|
||||
case "$bundle_type" in
|
||||
"jcef")
|
||||
do_reset_changes=0
|
||||
do_maketest=1
|
||||
;;
|
||||
"nomod" | "")
|
||||
bundle_type=""
|
||||
@@ -82,13 +80,13 @@ esac
|
||||
|
||||
if [ -z "$INC_BUILD" ]; then
|
||||
do_configure || do_exit $?
|
||||
if [ -z "$bundle_type" ]; then
|
||||
if [ $do_maketest -eq 1 ]; then
|
||||
make LOG=info CONF=$RELEASE_NAME clean images test-image || do_exit $?
|
||||
else
|
||||
make LOG=info CONF=$RELEASE_NAME clean images || do_exit $?
|
||||
fi
|
||||
else
|
||||
if [ -z "$bundle_type" ]; then
|
||||
if [ $do_maketest -eq 1 ]; then
|
||||
make LOG=info CONF=$RELEASE_NAME images test-image || do_exit $?
|
||||
else
|
||||
make LOG=info CONF=$RELEASE_NAME images || do_exit $?
|
||||
@@ -108,8 +106,9 @@ if [ "$bundle_type" == "jcef" ] || [ "$bundle_type" == "fd" ]; then
|
||||
jbr_name_postfix="_${bundle_type}"
|
||||
fi
|
||||
|
||||
# create runtime image bundle
|
||||
modules=$(xargs < modules.list | sed s/" "//g) || do_exit $?
|
||||
# create runtime image bundlef
|
||||
modules=$(xargs < jb/project/tools/common/modules.list | sed s/" "//g) || do_exit $?
|
||||
modules+=",jdk.crypto.mscapi"
|
||||
create_image_bundle "jbr${jbr_name_postfix}" "jbr" $JSDK_MODS_DIR "$modules" || do_exit $?
|
||||
|
||||
# create sdk image bundle
|
||||
@@ -119,4 +118,4 @@ if [ "$bundle_type" == "jcef" ] || [ "$bundle_type" == "fd" ] || [ "$bundle_type
|
||||
fi
|
||||
create_image_bundle "$JBRSDK_BUNDLE${jbr_name_postfix}" "$JBRSDK_BUNDLE" "$JSDK_MODS_DIR" "$modules" || do_exit $?
|
||||
|
||||
do_exit 0
|
||||
do_exit 0
|
||||
|
||||
@@ -53,7 +53,8 @@ mv release ${JBRSDK_BUNDLE}/release
|
||||
|
||||
JBR_BUNDLE=jbr
|
||||
rm -rf ${JBR_BUNDLE}
|
||||
grep -v javafx modules.list | grep -v "jdk.internal.vm\|jdk.aot\|jcef" > modules.list.x86
|
||||
grep -v javafx jb/project/tools/common/modules.list | grep -v "jdk.internal.vm\|jdk.aot\|jcef" > modules.list.x86
|
||||
echo ",jdk.crypto.mscapi" >> modules.list.x86
|
||||
${JSDK}/bin/jlink \
|
||||
--module-path ${JSDK}/jmods --no-man-pages --compress=2 \
|
||||
--add-modules $(xargs < modules.list.x86 | sed s/" "//g) --output ${JBR_BUNDLE} || exit $?
|
||||
|
||||
@@ -1,29 +1,19 @@
|
||||
#!/bin/bash -x
|
||||
|
||||
# The following parameters must be specified:
|
||||
# JBSDK_VERSION - specifies major version of OpenJDK e.g. 11_0_6 (instead of dots '.' underbars "_" are used)
|
||||
# JDK_BUILD_NUMBER - specifies udate release of OpenJDK build or the value of --with-version-build argument to configure
|
||||
# build_number - specifies the number of JetBrainsRuntime build
|
||||
# bundle_type - specifies bundle to be built; possible values:
|
||||
# <empty> or nomod - the bundles without any additional modules (jcef)
|
||||
# jcef - the bundles with jcef
|
||||
# fd - the fastdebug bundles which also include the jcef module
|
||||
# build_number - specifies the number of JetBrainsRuntime build
|
||||
# bundle_type - specifies bundle to be built;possible values:
|
||||
# <empty> or nomod - the release bundles without any additional modules (jcef)
|
||||
# jcef - the release bundles with jcef
|
||||
# fd - the fastdebug bundles which also include the jcef module
|
||||
#
|
||||
# jbrsdk-${JBSDK_VERSION}-osx-x64-b${build_number}.tar.gz
|
||||
# jbr-${JBSDK_VERSION}-osx-x64-b${build_number}.tar.gz
|
||||
#
|
||||
# $ ./java --version
|
||||
# openjdk 11.0.6 2020-01-14
|
||||
# OpenJDK Runtime Environment (build 11.0.6+${JDK_BUILD_NUMBER}-b${build_number})
|
||||
# OpenJDK 64-Bit Server VM (build 11.0.6+${JDK_BUILD_NUMBER}-b${build_number}, mixed mode)
|
||||
# This script packs test-image along with JDK images when bundle_type is set to "jcef".
|
||||
# If the character 't' is added at the end of bundle_type then it also makes test-image along with JDK images.
|
||||
#
|
||||
|
||||
source jb/project/tools/common/scripts/common.sh
|
||||
|
||||
JBSDK_VERSION=$1
|
||||
JDK_BUILD_NUMBER=$2
|
||||
build_number=$3
|
||||
bundle_type=$4
|
||||
[ "$bundle_type" == "jcef" ] && do_maketest=1
|
||||
|
||||
function pack_jbr {
|
||||
__bundle_name=$1
|
||||
@@ -51,7 +41,7 @@ fi
|
||||
pack_jbr jbr${jbr_name_postfix} jbr
|
||||
pack_jbr jbrsdk${jbr_name_postfix} jbrsdk
|
||||
|
||||
if [ -z "$bundle_type" ]; then
|
||||
if [ $do_maketest -eq 1 ]; then
|
||||
JBRSDK_TEST=$JBRSDK_BUNDLE-$JBSDK_VERSION-windows-test-x64-b$build_number
|
||||
echo Creating $JBRSDK_TEST.tar.gz ...
|
||||
/usr/bin/tar -czf $JBRSDK_TEST.tar.gz -C $IMAGES_DIR --exclude='test/jdk/demos' test || do_exit $?
|
||||
|
||||
@@ -784,10 +784,8 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_CPU_DEP],
|
||||
test "x$ENABLE_REPRODUCIBLE_BUILD" = xtrue; then
|
||||
# There is a known issue with the pathmap if the mapping is made to the
|
||||
# empty string. Add a minimal string "s" as prefix to work around this.
|
||||
workspace_root_win=`$FIXPATH_BASE print "${WORKSPACE_ROOT%/}"`
|
||||
# PATHMAP_FLAGS is also added to LDFLAGS in flags-ldflags.m4.
|
||||
PATHMAP_FLAGS="-pathmap:${workspace_root_win//\//\\\\}=s \
|
||||
-pathmap:${workspace_root_win}=s"
|
||||
PATHMAP_FLAGS="-pathmap:${WORKSPACE_ROOT}=s"
|
||||
FILE_MACRO_CFLAGS="$PATHMAP_FLAGS"
|
||||
FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${FILE_MACRO_CFLAGS}],
|
||||
PREFIX: $3,
|
||||
|
||||
@@ -341,9 +341,9 @@ void PhaseIdealLoop::clone_skeleton_predicates_to_unswitched_loop(IdealLoopTree*
|
||||
assert(predicate->is_Proj() && predicate->as_Proj()->is_IfProj(), "predicate must be a projection of an if node");
|
||||
IfProjNode* predicate_proj = predicate->as_IfProj();
|
||||
|
||||
ProjNode* fast_proj = clone_skeleton_predicate_for_unswitched_loops(iff, predicate_proj, uncommon_proj, reason, iffast_pred, loop);
|
||||
ProjNode* fast_proj = clone_skeleton_predicate_for_unswitched_loops(iff, predicate_proj, reason, iffast_pred);
|
||||
assert(skeleton_predicate_has_opaque(fast_proj->in(0)->as_If()), "must find skeleton predicate for fast loop");
|
||||
ProjNode* slow_proj = clone_skeleton_predicate_for_unswitched_loops(iff, predicate_proj, uncommon_proj, reason, ifslow_pred, loop);
|
||||
ProjNode* slow_proj = clone_skeleton_predicate_for_unswitched_loops(iff, predicate_proj, reason, ifslow_pred);
|
||||
assert(skeleton_predicate_has_opaque(slow_proj->in(0)->as_If()), "must find skeleton predicate for slow loop");
|
||||
|
||||
// Update control dependent data nodes.
|
||||
@@ -397,10 +397,10 @@ void PhaseIdealLoop::get_skeleton_predicates(Node* predicate, Unique_Node_List&
|
||||
// Clone a skeleton predicate for an unswitched loop. OpaqueLoopInit and OpaqueLoopStride nodes are cloned and uncommon
|
||||
// traps are kept for the predicate (a Halt node is used later when creating pre/main/post loops and copying this cloned
|
||||
// predicate again).
|
||||
ProjNode* PhaseIdealLoop::clone_skeleton_predicate_for_unswitched_loops(Node* iff, ProjNode* predicate, Node* uncommon_proj,
|
||||
Deoptimization::DeoptReason reason, ProjNode* output_proj,
|
||||
IdealLoopTree* loop) {
|
||||
Node* bol = clone_skeleton_predicate_bool(iff, NULL, NULL, predicate, uncommon_proj, output_proj, loop);
|
||||
ProjNode* PhaseIdealLoop::clone_skeleton_predicate_for_unswitched_loops(Node* iff, ProjNode* predicate,
|
||||
Deoptimization::DeoptReason reason,
|
||||
ProjNode* output_proj) {
|
||||
Node* bol = clone_skeleton_predicate_bool(iff, NULL, NULL, output_proj);
|
||||
ProjNode* proj = create_new_if_for_predicate(output_proj, NULL, reason, iff->Opcode(), predicate->is_IfTrue());
|
||||
_igvn.replace_input_of(proj->in(0), 1, bol);
|
||||
_igvn.replace_input_of(output_proj->in(0), 0, proj);
|
||||
|
||||
@@ -1264,10 +1264,12 @@ void PhaseIdealLoop::copy_skeleton_predicates_to_main_loop_helper(Node* predicat
|
||||
// Clone the skeleton predicate twice and initialize one with the initial
|
||||
// value of the loop induction variable. Leave the other predicate
|
||||
// to be initialized when increasing the stride during loop unrolling.
|
||||
prev_proj = clone_skeleton_predicate_for_main_loop(iff, opaque_init, NULL, predicate, uncommon_proj, current_proj, outer_loop, prev_proj);
|
||||
prev_proj = clone_skeleton_predicate_for_main_or_post_loop(iff, opaque_init, NULL, predicate, uncommon_proj,
|
||||
current_proj, outer_loop, prev_proj);
|
||||
assert(skeleton_predicate_has_opaque(prev_proj->in(0)->as_If()), "");
|
||||
|
||||
prev_proj = clone_skeleton_predicate_for_main_loop(iff, init, stride, predicate, uncommon_proj, current_proj, outer_loop, prev_proj);
|
||||
prev_proj = clone_skeleton_predicate_for_main_or_post_loop(iff, init, stride, predicate, uncommon_proj,
|
||||
current_proj, outer_loop, prev_proj);
|
||||
assert(!skeleton_predicate_has_opaque(prev_proj->in(0)->as_If()), "");
|
||||
|
||||
// Rewire any control inputs from the cloned skeleton predicates down to the main and post loop for data nodes that are part of the
|
||||
@@ -1344,8 +1346,7 @@ bool PhaseIdealLoop::skeleton_predicate_has_opaque(IfNode* iff) {
|
||||
// Clone the skeleton predicate bool for a main or unswitched loop:
|
||||
// Main loop: Set new_init and new_stride nodes as new inputs.
|
||||
// Unswitched loop: new_init and new_stride are both NULL. Clone OpaqueLoopInit and OpaqueLoopStride instead.
|
||||
Node* PhaseIdealLoop::clone_skeleton_predicate_bool(Node* iff, Node* new_init, Node* new_stride, Node* predicate, Node* uncommon_proj,
|
||||
Node* control, IdealLoopTree* outer_loop) {
|
||||
Node* PhaseIdealLoop::clone_skeleton_predicate_bool(Node* iff, Node* new_init, Node* new_stride, Node* control) {
|
||||
Node_Stack to_clone(2);
|
||||
to_clone.push(iff->in(1), 1);
|
||||
uint current = C->unique();
|
||||
@@ -1421,9 +1422,9 @@ Node* PhaseIdealLoop::clone_skeleton_predicate_bool(Node* iff, Node* new_init, N
|
||||
|
||||
// Clone a skeleton predicate for the main loop. new_init and new_stride are set as new inputs. Since the predicates cannot fail at runtime,
|
||||
// Halt nodes are inserted instead of uncommon traps.
|
||||
Node* PhaseIdealLoop::clone_skeleton_predicate_for_main_loop(Node* iff, Node* new_init, Node* new_stride, Node* predicate, Node* uncommon_proj,
|
||||
Node* control, IdealLoopTree* outer_loop, Node* input_proj) {
|
||||
Node* result = clone_skeleton_predicate_bool(iff, new_init, new_stride, predicate, uncommon_proj, control, outer_loop);
|
||||
Node* PhaseIdealLoop::clone_skeleton_predicate_for_main_or_post_loop(Node* iff, Node* new_init, Node* new_stride, Node* predicate, Node* uncommon_proj,
|
||||
Node* control, IdealLoopTree* outer_loop, Node* input_proj) {
|
||||
Node* result = clone_skeleton_predicate_bool(iff, new_init, new_stride, control);
|
||||
Node* proj = predicate->clone();
|
||||
Node* other_proj = uncommon_proj->clone();
|
||||
Node* new_iff = iff->clone();
|
||||
@@ -1437,8 +1438,8 @@ Node* PhaseIdealLoop::clone_skeleton_predicate_for_main_loop(Node* iff, Node* ne
|
||||
C->root()->add_req(halt);
|
||||
new_iff->set_req(0, input_proj);
|
||||
|
||||
register_control(new_iff, outer_loop->_parent, input_proj);
|
||||
register_control(proj, outer_loop->_parent, new_iff);
|
||||
register_control(new_iff, outer_loop == _ltree_root ? _ltree_root : outer_loop->_parent, input_proj);
|
||||
register_control(proj, outer_loop == _ltree_root ? _ltree_root : outer_loop->_parent, new_iff);
|
||||
register_control(other_proj, _ltree_root, new_iff);
|
||||
register_control(halt, _ltree_root, other_proj);
|
||||
return proj;
|
||||
@@ -1521,7 +1522,8 @@ void PhaseIdealLoop::insert_pre_post_loops(IdealLoopTree *loop, Node_List &old_n
|
||||
// Add the post loop
|
||||
const uint idx_before_pre_post = Compile::current()->unique();
|
||||
CountedLoopNode *post_head = NULL;
|
||||
Node *main_exit = insert_post_loop(loop, old_new, main_head, main_end, incr, limit, post_head);
|
||||
Node* post_incr = incr;
|
||||
Node* main_exit = insert_post_loop(loop, old_new, main_head, main_end, post_incr, limit, post_head);
|
||||
const uint idx_after_post_before_pre = Compile::current()->unique();
|
||||
|
||||
//------------------------------
|
||||
@@ -1620,6 +1622,7 @@ void PhaseIdealLoop::insert_pre_post_loops(IdealLoopTree *loop, Node_List &old_n
|
||||
assert(post_head->in(1)->is_IfProj(), "must be zero-trip guard If node projection of the post loop");
|
||||
copy_skeleton_predicates_to_main_loop(pre_head, castii, stride, outer_loop, outer_main_head, dd_main_head,
|
||||
idx_before_pre_post, idx_after_post_before_pre, min_taken, post_head->in(1), old_new);
|
||||
copy_skeleton_predicates_to_post_loop(outer_main_head, post_head, post_incr, stride);
|
||||
|
||||
// Step B4: Shorten the pre-loop to run only 1 iteration (for now).
|
||||
// RCE and alignment may change this later.
|
||||
@@ -1742,6 +1745,7 @@ void PhaseIdealLoop::insert_vector_post_loop(IdealLoopTree *loop, Node_List &old
|
||||
// In this case we throw away the result as we are not using it to connect anything else.
|
||||
CountedLoopNode *post_head = NULL;
|
||||
insert_post_loop(loop, old_new, main_head, main_end, incr, limit, post_head);
|
||||
copy_skeleton_predicates_to_post_loop(main_head->skip_strip_mined(), post_head, incr, main_head->stride());
|
||||
|
||||
// It's difficult to be precise about the trip-counts
|
||||
// for post loops. They are usually very short,
|
||||
@@ -1788,6 +1792,7 @@ void PhaseIdealLoop::insert_scalar_rced_post_loop(IdealLoopTree *loop, Node_List
|
||||
// In this case we throw away the result as we are not using it to connect anything else.
|
||||
CountedLoopNode *post_head = NULL;
|
||||
insert_post_loop(loop, old_new, main_head, main_end, incr, limit, post_head);
|
||||
copy_skeleton_predicates_to_post_loop(main_head->skip_strip_mined(), post_head, incr, main_head->stride());
|
||||
|
||||
// It's difficult to be precise about the trip-counts
|
||||
// for post loops. They are usually very short,
|
||||
@@ -1804,9 +1809,9 @@ void PhaseIdealLoop::insert_scalar_rced_post_loop(IdealLoopTree *loop, Node_List
|
||||
|
||||
//------------------------------insert_post_loop-------------------------------
|
||||
// Insert post loops. Add a post loop to the given loop passed.
|
||||
Node *PhaseIdealLoop::insert_post_loop(IdealLoopTree *loop, Node_List &old_new,
|
||||
CountedLoopNode *main_head, CountedLoopEndNode *main_end,
|
||||
Node *incr, Node *limit, CountedLoopNode *&post_head) {
|
||||
Node *PhaseIdealLoop::insert_post_loop(IdealLoopTree* loop, Node_List& old_new,
|
||||
CountedLoopNode* main_head, CountedLoopEndNode* main_end,
|
||||
Node*& incr, Node* limit, CountedLoopNode*& post_head) {
|
||||
IfNode* outer_main_end = main_end;
|
||||
IdealLoopTree* outer_loop = loop;
|
||||
if (main_head->is_strip_mined()) {
|
||||
@@ -1890,8 +1895,8 @@ Node *PhaseIdealLoop::insert_post_loop(IdealLoopTree *loop, Node_List &old_new,
|
||||
}
|
||||
|
||||
// CastII for the new post loop:
|
||||
Node* castii = cast_incr_before_loop(zer_opaq->in(1), zer_taken, post_head);
|
||||
assert(castii != NULL, "no castII inserted");
|
||||
incr = cast_incr_before_loop(zer_opaq->in(1), zer_taken, post_head);
|
||||
assert(incr != NULL, "no castII inserted");
|
||||
|
||||
return new_main_exit;
|
||||
}
|
||||
@@ -1933,7 +1938,8 @@ void PhaseIdealLoop::update_main_loop_skeleton_predicates(Node* ctrl, CountedLoo
|
||||
_igvn.replace_input_of(iff, 1, iff->in(1)->in(2));
|
||||
} else {
|
||||
// Add back predicates updated for the new stride.
|
||||
prev_proj = clone_skeleton_predicate_for_main_loop(iff, init, max_value, entry, proj, ctrl, outer_loop, prev_proj);
|
||||
prev_proj = clone_skeleton_predicate_for_main_or_post_loop(iff, init, max_value, entry, proj, ctrl, outer_loop,
|
||||
prev_proj);
|
||||
assert(!skeleton_predicate_has_opaque(prev_proj->in(0)->as_If()), "unexpected");
|
||||
}
|
||||
}
|
||||
@@ -1945,6 +1951,34 @@ void PhaseIdealLoop::update_main_loop_skeleton_predicates(Node* ctrl, CountedLoo
|
||||
}
|
||||
}
|
||||
|
||||
void PhaseIdealLoop::copy_skeleton_predicates_to_post_loop(LoopNode* main_loop_head, CountedLoopNode* post_loop_head, Node* init, Node* stride) {
|
||||
// Go over the skeleton predicates of the main loop and make a copy for the post loop with its initial iv value and
|
||||
// stride as inputs.
|
||||
Node* post_loop_entry = post_loop_head->in(LoopNode::EntryControl);
|
||||
Node* main_loop_entry = main_loop_head->in(LoopNode::EntryControl);
|
||||
IdealLoopTree* post_loop = get_loop(post_loop_head);
|
||||
|
||||
Node* ctrl = main_loop_entry;
|
||||
Node* prev_proj = post_loop_entry;
|
||||
while (ctrl != NULL && ctrl->is_Proj() && ctrl->in(0)->is_If()) {
|
||||
IfNode* iff = ctrl->in(0)->as_If();
|
||||
ProjNode* proj = iff->proj_out(1 - ctrl->as_Proj()->_con);
|
||||
if (proj->unique_ctrl_out()->Opcode() != Op_Halt) {
|
||||
break;
|
||||
}
|
||||
if (iff->in(1)->Opcode() == Op_Opaque4 && skeleton_predicate_has_opaque(iff)) {
|
||||
prev_proj = clone_skeleton_predicate_for_main_or_post_loop(iff, init, stride, ctrl, proj, post_loop_entry,
|
||||
post_loop, prev_proj);
|
||||
assert(!skeleton_predicate_has_opaque(prev_proj->in(0)->as_If()), "unexpected");
|
||||
}
|
||||
ctrl = ctrl->in(0)->in(0);
|
||||
}
|
||||
if (prev_proj != post_loop_entry) {
|
||||
_igvn.replace_input_of(post_loop_head, LoopNode::EntryControl, prev_proj);
|
||||
set_idom(post_loop_head, prev_proj, dom_depth(post_loop_head));
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------do_unroll--------------------------------------
|
||||
// Unroll the loop body one step - make each trip do 2 iterations.
|
||||
void PhaseIdealLoop::do_unroll(IdealLoopTree *loop, Node_List &old_new, bool adjust_min_trip) {
|
||||
|
||||
@@ -2150,12 +2150,14 @@ Node* CountedLoopNode::skip_predicates_from_entry(Node* ctrl) {
|
||||
}
|
||||
|
||||
Node* CountedLoopNode::skip_predicates() {
|
||||
Node* ctrl = in(LoopNode::EntryControl);
|
||||
if (is_main_loop()) {
|
||||
Node* ctrl = skip_strip_mined()->in(LoopNode::EntryControl);
|
||||
|
||||
ctrl = skip_strip_mined()->in(LoopNode::EntryControl);
|
||||
}
|
||||
if (is_main_loop() || is_post_loop()) {
|
||||
return skip_predicates_from_entry(ctrl);
|
||||
}
|
||||
return in(LoopNode::EntryControl);
|
||||
return ctrl;
|
||||
}
|
||||
|
||||
|
||||
@@ -5351,38 +5353,45 @@ void PhaseIdealLoop::build_loop_late_post_work(Node *n, bool pinned) {
|
||||
}
|
||||
assert(early == legal || legal != C->root(), "bad dominance of inputs");
|
||||
|
||||
if (least != early) {
|
||||
// Move the node above predicates as far up as possible so a
|
||||
// following pass of loop predication doesn't hoist a predicate
|
||||
// that depends on it above that node.
|
||||
Node* new_ctrl = least;
|
||||
for (;;) {
|
||||
if (!new_ctrl->is_Proj()) {
|
||||
break;
|
||||
}
|
||||
CallStaticJavaNode* call = new_ctrl->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none);
|
||||
if (call == NULL) {
|
||||
break;
|
||||
}
|
||||
int req = call->uncommon_trap_request();
|
||||
Deoptimization::DeoptReason trap_reason = Deoptimization::trap_request_reason(req);
|
||||
if (trap_reason != Deoptimization::Reason_loop_limit_check &&
|
||||
trap_reason != Deoptimization::Reason_predicate &&
|
||||
trap_reason != Deoptimization::Reason_profile_predicate) {
|
||||
break;
|
||||
}
|
||||
Node* c = new_ctrl->in(0)->in(0);
|
||||
if (is_dominator(c, early) && c != early) {
|
||||
break;
|
||||
}
|
||||
new_ctrl = c;
|
||||
}
|
||||
least = new_ctrl;
|
||||
}
|
||||
// Try not to place code on a loop entry projection
|
||||
// which can inhibit range check elimination.
|
||||
if (least != early) {
|
||||
Node* ctrl_out = least->unique_ctrl_out();
|
||||
if (ctrl_out && ctrl_out->is_Loop() &&
|
||||
least == ctrl_out->in(LoopNode::EntryControl)) {
|
||||
// Move the node above predicates as far up as possible so a
|
||||
// following pass of loop predication doesn't hoist a predicate
|
||||
// that depends on it above that node.
|
||||
Node* new_ctrl = least;
|
||||
for (;;) {
|
||||
if (!new_ctrl->is_Proj()) {
|
||||
break;
|
||||
}
|
||||
CallStaticJavaNode* call = new_ctrl->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none);
|
||||
if (call == NULL) {
|
||||
break;
|
||||
}
|
||||
int req = call->uncommon_trap_request();
|
||||
Deoptimization::DeoptReason trap_reason = Deoptimization::trap_request_reason(req);
|
||||
if (trap_reason != Deoptimization::Reason_loop_limit_check &&
|
||||
trap_reason != Deoptimization::Reason_predicate &&
|
||||
trap_reason != Deoptimization::Reason_profile_predicate) {
|
||||
break;
|
||||
}
|
||||
Node* c = new_ctrl->in(0)->in(0);
|
||||
if (is_dominator(c, early) && c != early) {
|
||||
break;
|
||||
}
|
||||
new_ctrl = c;
|
||||
least == ctrl_out->in(LoopNode::EntryControl) &&
|
||||
(ctrl_out->is_CountedLoop() || ctrl_out->is_OuterStripMinedLoop())) {
|
||||
Node* least_dom = idom(least);
|
||||
if (get_loop(least_dom)->is_member(get_loop(least))) {
|
||||
least = least_dom;
|
||||
}
|
||||
least = new_ctrl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -915,13 +915,13 @@ private:
|
||||
void copy_skeleton_predicates_to_main_loop(CountedLoopNode* pre_head, Node* init, Node* stride, IdealLoopTree* outer_loop, LoopNode* outer_main_head,
|
||||
uint dd_main_head, const uint idx_before_pre_post, const uint idx_after_post_before_pre,
|
||||
Node* zero_trip_guard_proj_main, Node* zero_trip_guard_proj_post, const Node_List &old_new);
|
||||
Node* clone_skeleton_predicate_for_main_loop(Node* iff, Node* new_init, Node* new_stride, Node* predicate, Node* uncommon_proj, Node* control,
|
||||
IdealLoopTree* outer_loop, Node* input_proj);
|
||||
Node* clone_skeleton_predicate_bool(Node* iff, Node* new_init, Node* new_stride, Node* predicate, Node* uncommon_proj, Node* control,
|
||||
IdealLoopTree* outer_loop);
|
||||
Node* clone_skeleton_predicate_for_main_or_post_loop(Node* iff, Node* new_init, Node* new_stride, Node* predicate, Node* uncommon_proj, Node* control,
|
||||
IdealLoopTree* outer_loop, Node* input_proj);
|
||||
Node* clone_skeleton_predicate_bool(Node* iff, Node* new_init, Node* new_stride, Node* control);
|
||||
static bool skeleton_predicate_has_opaque(IfNode* iff);
|
||||
static void get_skeleton_predicates(Node* predicate, Unique_Node_List& list, bool get_opaque = false);
|
||||
void update_main_loop_skeleton_predicates(Node* ctrl, CountedLoopNode* loop_head, Node* init, int stride_con);
|
||||
void copy_skeleton_predicates_to_post_loop(LoopNode* main_loop_head, CountedLoopNode* post_loop_head, Node* init, Node* stride);
|
||||
void insert_loop_limit_check(ProjNode* limit_check_proj, Node* cmp_limit, Node* bol);
|
||||
#ifdef ASSERT
|
||||
bool only_has_infinite_loops();
|
||||
@@ -1244,9 +1244,9 @@ public:
|
||||
void insert_pre_post_loops( IdealLoopTree *loop, Node_List &old_new, bool peel_only );
|
||||
|
||||
// Add post loop after the given loop.
|
||||
Node *insert_post_loop(IdealLoopTree *loop, Node_List &old_new,
|
||||
CountedLoopNode *main_head, CountedLoopEndNode *main_end,
|
||||
Node *incr, Node *limit, CountedLoopNode *&post_head);
|
||||
Node *insert_post_loop(IdealLoopTree* loop, Node_List& old_new,
|
||||
CountedLoopNode* main_head, CountedLoopEndNode* main_end,
|
||||
Node*& incr, Node* limit, CountedLoopNode*& post_head);
|
||||
|
||||
// Add an RCE'd post loop which we will multi-version adapt for run time test path usage
|
||||
void insert_scalar_rced_post_loop( IdealLoopTree *loop, Node_List &old_new );
|
||||
@@ -1579,8 +1579,9 @@ private:
|
||||
Node_List* old_new = NULL);
|
||||
void clone_skeleton_predicates_to_unswitched_loop(IdealLoopTree* loop, const Node_List& old_new, Deoptimization::DeoptReason reason,
|
||||
ProjNode* old_predicate_proj, ProjNode* iffast_pred, ProjNode* ifslow_pred);
|
||||
ProjNode* clone_skeleton_predicate_for_unswitched_loops(Node* iff, ProjNode* predicate, Node* uncommon_proj, Deoptimization::DeoptReason reason,
|
||||
ProjNode* output_proj, IdealLoopTree* loop);
|
||||
ProjNode* clone_skeleton_predicate_for_unswitched_loops(Node* iff, ProjNode* predicate,
|
||||
Deoptimization::DeoptReason reason,
|
||||
ProjNode* output_proj);
|
||||
static void check_created_predicate_for_unswitching(const Node* new_entry) PRODUCT_RETURN;
|
||||
|
||||
bool _created_loop_node;
|
||||
|
||||
@@ -2562,6 +2562,7 @@ void PhaseMacroExpand::eliminate_macro_nodes() {
|
||||
assert(n->Opcode() == Op_LoopLimit ||
|
||||
n->Opcode() == Op_Opaque2 ||
|
||||
n->Opcode() == Op_Opaque3 ||
|
||||
n->Opcode() == Op_Opaque4 ||
|
||||
BarrierSet::barrier_set()->barrier_set_c2()->is_gc_barrier_node(n),
|
||||
"unknown node type in macro list");
|
||||
}
|
||||
@@ -2623,6 +2624,19 @@ bool PhaseMacroExpand::expand_macro_nodes() {
|
||||
_igvn.replace_node(n, repl);
|
||||
success = true;
|
||||
#endif
|
||||
} else if (n->Opcode() == Op_Opaque4) {
|
||||
// With Opaque4 nodes, the expectation is that the test of input 1
|
||||
// is always equal to the constant value of input 2. So we can
|
||||
// remove the Opaque4 and replace it by input 2. In debug builds,
|
||||
// leave the non constant test in instead to sanity check that it
|
||||
// never fails (if it does, that subgraph was constructed so, at
|
||||
// runtime, a Halt node is executed).
|
||||
#ifdef ASSERT
|
||||
_igvn.replace_node(n, n->in(1));
|
||||
#else
|
||||
_igvn.replace_node(n, n->in(2));
|
||||
#endif
|
||||
success = true;
|
||||
} else if (n->Opcode() == Op_OuterStripMinedLoop) {
|
||||
n->as_OuterStripMinedLoop()->adjust_strip_mined_loop(&_igvn);
|
||||
C->remove_macro_node(n);
|
||||
|
||||
@@ -60,25 +60,6 @@ bool Opaque2Node::cmp( const Node &n ) const {
|
||||
return (&n == this); // Always fail except on self
|
||||
}
|
||||
|
||||
Node* Opaque4Node::Identity(PhaseGVN* phase) {
|
||||
if (phase->C->post_loop_opts_phase()) {
|
||||
// With Opaque4 nodes, the expectation is that the test of input 1
|
||||
// is always equal to the constant value of input 2. So we can
|
||||
// remove the Opaque4 and replace it by input 2. In debug builds,
|
||||
// leave the non constant test in instead to sanity check that it
|
||||
// never fails (if it does, that subgraph was constructed so, at
|
||||
// runtime, a Halt node is executed).
|
||||
#ifdef ASSERT
|
||||
return this->in(1);
|
||||
#else
|
||||
return this->in(2);
|
||||
#endif
|
||||
} else {
|
||||
phase->C->record_for_post_loop_opts_igvn(this);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
const Type* Opaque4Node::Value(PhaseGVN* phase) const {
|
||||
return phase->type(in(1));
|
||||
}
|
||||
|
||||
@@ -114,11 +114,13 @@ class Opaque3Node : public Opaque2Node {
|
||||
// GraphKit::must_be_not_null().
|
||||
class Opaque4Node : public Node {
|
||||
public:
|
||||
Opaque4Node(Compile* C, Node *tst, Node* final_tst) : Node(NULL, tst, final_tst) {}
|
||||
Opaque4Node(Compile* C, Node *tst, Node* final_tst) : Node(NULL, tst, final_tst) {
|
||||
init_flags(Flag_is_macro);
|
||||
C->add_macro_node(this);
|
||||
}
|
||||
|
||||
virtual int Opcode() const;
|
||||
virtual const Type *bottom_type() const { return TypeInt::BOOL; }
|
||||
virtual Node* Identity(PhaseGVN* phase);
|
||||
virtual const Type* Value(PhaseGVN* phase) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -200,6 +200,24 @@ bool PhaseIdealLoop::split_up( Node *n, Node *blk1, Node *blk2 ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (n->Opcode() == Op_OpaqueLoopStride || n->Opcode() == Op_OpaqueLoopInit) {
|
||||
Unique_Node_List wq;
|
||||
wq.push(n);
|
||||
for (uint i = 0; i < wq.size(); i++) {
|
||||
Node* m = wq.at(i);
|
||||
if (m->is_If()) {
|
||||
assert(skeleton_predicate_has_opaque(m->as_If()), "opaque node not reachable from if?");
|
||||
Node* bol = clone_skeleton_predicate_bool(m, NULL, NULL, m->in(0));
|
||||
_igvn.replace_input_of(m, 1, bol);
|
||||
} else {
|
||||
assert(!m->is_CFG(), "not CFG expected");
|
||||
for (DUIterator_Fast jmax, j = m->fast_outs(jmax); j < jmax; j++) {
|
||||
Node* u = m->fast_out(j);
|
||||
wq.push(u);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// See if splitting-up a Store. Any anti-dep loads must go up as
|
||||
// well. An anti-dep load might be in the wrong block, because in
|
||||
|
||||
@@ -117,7 +117,7 @@ const char* Abstract_VM_Version::vm_vendor() {
|
||||
#ifdef VENDOR
|
||||
return VENDOR;
|
||||
#else
|
||||
return "Oracle Corporation";
|
||||
return "JetBrains s.r.o.";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -1337,6 +1337,7 @@ bool Arguments::add_property(const char* prop, PropertyWriteable writeable, Prop
|
||||
log_info(cds)("optimized module handling: disabled due to incompatible property: %s=%s", key, value);
|
||||
}
|
||||
if (strcmp(key, "jdk.module.showModuleResolution") == 0 ||
|
||||
strcmp(key, "jdk.module.illegalAccess") == 0 ||
|
||||
strcmp(key, "jdk.module.validation") == 0 ||
|
||||
strcmp(key, "java.system.class.loader") == 0) {
|
||||
MetaspaceShared::disable_full_module_graph();
|
||||
@@ -2131,7 +2132,8 @@ bool Arguments::parse_uintx(const char* value,
|
||||
}
|
||||
|
||||
bool Arguments::create_module_property(const char* prop_name, const char* prop_value, PropertyInternal internal) {
|
||||
assert(is_internal_module_property(prop_name), "unknown module property: '%s'", prop_name);
|
||||
assert(is_internal_module_property(prop_name) ||
|
||||
strcmp(prop_name, "jdk.module.illegalAccess") == 0, "unknown module property: '%s'", prop_name);
|
||||
size_t prop_len = strlen(prop_name) + strlen(prop_value) + 2;
|
||||
char* property = AllocateHeap(prop_len, mtArguments);
|
||||
int ret = jio_snprintf(property, prop_len, "%s=%s", prop_name, prop_value);
|
||||
@@ -2503,6 +2505,11 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
|
||||
char version[256];
|
||||
JDK_Version::jdk(17).to_string(version, sizeof(version));
|
||||
warning("Ignoring option %s; support was removed in %s", option->optionString, version);
|
||||
} else if (match_option(option, "--jbr-illegal-access", &tail)) {
|
||||
warning("Option --jbr-illegal-access is deprecated and will be removed in a future release.");
|
||||
if (!create_module_property("jdk.module.illegalAccess", "permit", ExternalProperty)) {
|
||||
return JNI_ENOMEM;
|
||||
}
|
||||
// -agentlib and -agentpath
|
||||
} else if (match_option(option, "-agentlib:", &tail) ||
|
||||
(is_absolute_path = match_option(option, "-agentpath:", &tail))) {
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
package com.jetbrains.internal;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
@@ -103,9 +105,10 @@ public class JBRApi {
|
||||
JBRApi.outerLookup = outerLookup;
|
||||
try {
|
||||
Class<?> metadataClass = outerLookup.findClass("com.jetbrains.JBR$Metadata");
|
||||
knownServices = Set.of((String[]) outerLookup.findStaticVarHandle(metadataClass,
|
||||
Lookup lookup = MethodHandles.privateLookupIn(metadataClass, outerLookup);
|
||||
knownServices = Set.of((String[]) lookup.findStaticVarHandle(metadataClass,
|
||||
"KNOWN_SERVICES", String[].class).get());
|
||||
knownProxies = Set.of((String[]) outerLookup.findStaticVarHandle(metadataClass,
|
||||
knownProxies = Set.of((String[]) lookup.findStaticVarHandle(metadataClass,
|
||||
"KNOWN_PROXIES", String[].class).get());
|
||||
} catch (ClassNotFoundException | NoSuchFieldException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
@@ -156,13 +159,52 @@ public class JBRApi {
|
||||
RegisteredProxyInfo info = registeredProxyInfoByTargetName.get(targetName);
|
||||
if (info == null) return null;
|
||||
try {
|
||||
return (info.type() == ProxyInfo.Type.CLIENT_PROXY ? info.apiModule() : outerLookup)
|
||||
return (info.type().isPublicApi() ? outerLookup : info.apiModule())
|
||||
.findClass(info.interfaceName());
|
||||
} catch (ClassNotFoundException | IllegalAccessException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static InternalServiceBuilder internalServiceBuilder(Lookup interFace, String target) {
|
||||
return new InternalServiceBuilder(new RegisteredProxyInfo(
|
||||
interFace, interFace.lookupClass().getName(), target, ProxyInfo.Type.INTERNAL_SERVICE, new ArrayList<>()));
|
||||
}
|
||||
|
||||
public static class InternalServiceBuilder {
|
||||
|
||||
private final RegisteredProxyInfo info;
|
||||
|
||||
private InternalServiceBuilder(RegisteredProxyInfo info) {
|
||||
this.info = info;
|
||||
}
|
||||
|
||||
public InternalServiceBuilder withStatic(String methodName, String clazz) {
|
||||
return withStatic(methodName, clazz, methodName);
|
||||
}
|
||||
|
||||
public InternalServiceBuilder withStatic(String interfaceMethodName, String clazz, String methodName) {
|
||||
info.staticMethods().add(
|
||||
new RegisteredProxyInfo.StaticMethodMapping(interfaceMethodName, clazz, methodName));
|
||||
return this;
|
||||
}
|
||||
|
||||
public Object build() {
|
||||
ProxyInfo info = ProxyInfo.resolve(this.info);
|
||||
if (info == null) return null;
|
||||
ProxyGenerator generator = new ProxyGenerator(info);
|
||||
if (!generator.areAllMethodsImplemented()) return null;
|
||||
generator.defineClasses();
|
||||
MethodHandle constructor = generator.findConstructor();
|
||||
generator.init();
|
||||
try {
|
||||
return constructor.invoke();
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by {@linkplain com.jetbrains.bootstrap.JBRApiBootstrap#MODULES registry classes}
|
||||
* to register a new mapping for corresponding modules.
|
||||
|
||||
@@ -78,7 +78,7 @@ class ProxyGenerator {
|
||||
*/
|
||||
ProxyGenerator(ProxyInfo info) {
|
||||
this.info = info;
|
||||
generateBridge = info.type != ProxyInfo.Type.CLIENT_PROXY;
|
||||
generateBridge = info.type.isPublicApi();
|
||||
int nameId = nameCounter.getAndIncrement();
|
||||
proxyName = Type.getInternalName(info.interFace) + "$$JBRApiProxy$" + nameId;
|
||||
bridgeName = generateBridge ? info.apiModule.lookupClass().getPackageName().replace('.', '/') + "/" +
|
||||
@@ -153,7 +153,7 @@ class ProxyGenerator {
|
||||
} else {
|
||||
MethodHandle c = generatedProxy.findConstructor(generatedProxy.lookupClass(),
|
||||
MethodType.methodType(void.class, Object.class));
|
||||
if (info.type == ProxyInfo.Type.SERVICE) {
|
||||
if (info.type.isService()) {
|
||||
try {
|
||||
return MethodHandles.foldArguments(c, info.target.findConstructor(info.target.lookupClass(),
|
||||
MethodType.methodType(void.class)).asType(MethodType.methodType(Object.class)));
|
||||
|
||||
@@ -66,7 +66,7 @@ class ProxyInfo {
|
||||
}
|
||||
|
||||
Lookup getInterfaceLookup() {
|
||||
return type == Type.CLIENT_PROXY ? apiModule : JBRApi.outerLookup;
|
||||
return type == Type.CLIENT_PROXY || type == Type.INTERNAL_SERVICE ? apiModule : JBRApi.outerLookup;
|
||||
}
|
||||
|
||||
Lookup getTargetLookup() {
|
||||
@@ -74,12 +74,18 @@ class ProxyInfo {
|
||||
}
|
||||
|
||||
private Lookup lookup(Lookup lookup, String clazz) {
|
||||
try {
|
||||
return MethodHandles.privateLookupIn(lookup.findClass(clazz), lookup);
|
||||
} catch (ClassNotFoundException | IllegalAccessException e) {
|
||||
if (lookup == JBRApi.outerLookup) return null;
|
||||
else throw new RuntimeException(e);
|
||||
String[] nestedClasses = clazz.split("\\$");
|
||||
clazz = "";
|
||||
for (int i = 0; i < nestedClasses.length; i++) {
|
||||
try {
|
||||
if (i != 0) clazz += "$";
|
||||
clazz += nestedClasses[i];
|
||||
lookup = MethodHandles.privateLookupIn(lookup.findClass(clazz), lookup);
|
||||
} catch (ClassNotFoundException | IllegalAccessException ignore) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return lookup;
|
||||
}
|
||||
|
||||
record StaticMethodMapping(Lookup lookup, String methodName) {}
|
||||
@@ -90,6 +96,15 @@ class ProxyInfo {
|
||||
enum Type {
|
||||
PROXY,
|
||||
SERVICE,
|
||||
CLIENT_PROXY
|
||||
CLIENT_PROXY,
|
||||
INTERNAL_SERVICE;
|
||||
|
||||
public boolean isPublicApi() {
|
||||
return this == PROXY || this == SERVICE;
|
||||
}
|
||||
|
||||
public boolean isService() {
|
||||
return this == SERVICE || this == INTERNAL_SERVICE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,4 +68,14 @@ class ExplodedSystemModules implements SystemModules {
|
||||
public Map<String, Set<String>> moduleReads() {
|
||||
throw new InternalError();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Set<String>> concealedPackagesToOpen() {
|
||||
return Map.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Set<String>> exportedPackagesToOpen() {
|
||||
return Map.of();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package jdk.internal.module;
|
||||
|
||||
import sun.nio.cs.UTF_8;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.lang.module.ModuleDescriptor;
|
||||
import java.lang.module.ModuleFinder;
|
||||
import java.lang.module.ModuleReference;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Generates the maps of concealed and exported packages to open at run-time.
|
||||
*
|
||||
* This is used at run-time for exploded builds, and at link-time to generate
|
||||
* the maps for the system modules in the run-time image.
|
||||
*/
|
||||
|
||||
public class IllegalAccessMaps {
|
||||
private final Map<String, Set<String>> concealedPackagesToOpen;
|
||||
private final Map<String, Set<String>> exportedPackagesToOpen;
|
||||
|
||||
private IllegalAccessMaps(Map<String, Set<String>> map1,
|
||||
Map<String, Set<String>> map2) {
|
||||
this.concealedPackagesToOpen = map1;
|
||||
this.exportedPackagesToOpen = map2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the map of concealed packages to open. The map key is the
|
||||
* module name, the value is the set of concealed packages to open.
|
||||
*/
|
||||
public Map<String, Set<String>> concealedPackagesToOpen() {
|
||||
return concealedPackagesToOpen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the map of exported packages to open. The map key is the
|
||||
* module name, the value is the set of exported packages to open.
|
||||
*/
|
||||
public Map<String, Set<String>> exportedPackagesToOpen() {
|
||||
return exportedPackagesToOpen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the maps of module to concealed and exported packages for
|
||||
* the system modules that are observable with the given module finder.
|
||||
*/
|
||||
public static IllegalAccessMaps generate(ModuleFinder finder) {
|
||||
Map<String, ModuleDescriptor> map = new HashMap<>();
|
||||
finder.findAll().stream()
|
||||
.map(ModuleReference::descriptor)
|
||||
.forEach(md -> md.packages().forEach(pn -> map.putIfAbsent(pn, md)));
|
||||
|
||||
Map<String, Set<String>> concealedPackagesToOpen = new HashMap<>();
|
||||
Map<String, Set<String>> exportedPackagesToOpen = new HashMap<>();
|
||||
|
||||
String rn = "jdk8_packages.dat";
|
||||
InputStream in = IllegalAccessMaps.class.getResourceAsStream(rn);
|
||||
if (in == null) {
|
||||
throw new InternalError(rn + " not found");
|
||||
}
|
||||
try (BufferedReader br = new BufferedReader(
|
||||
new InputStreamReader(in, UTF_8.INSTANCE)))
|
||||
{
|
||||
br.lines()
|
||||
.filter(line -> !line.isEmpty() && !line.startsWith("#"))
|
||||
.forEach(pn -> {
|
||||
ModuleDescriptor descriptor = map.get(pn);
|
||||
if (descriptor != null && !isOpen(descriptor, pn)) {
|
||||
String name = descriptor.name();
|
||||
if (isExported(descriptor, pn)) {
|
||||
exportedPackagesToOpen.computeIfAbsent(name,
|
||||
k -> new HashSet<>()).add(pn);
|
||||
} else {
|
||||
concealedPackagesToOpen.computeIfAbsent(name,
|
||||
k -> new HashSet<>()).add(pn);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
} catch (IOException ioe) {
|
||||
throw new UncheckedIOException(ioe);
|
||||
}
|
||||
|
||||
return new IllegalAccessMaps(concealedPackagesToOpen, exportedPackagesToOpen);
|
||||
}
|
||||
|
||||
private static boolean isExported(ModuleDescriptor descriptor, String pn) {
|
||||
return descriptor.exports()
|
||||
.stream()
|
||||
.anyMatch(e -> e.source().equals(pn) && !e.isQualified());
|
||||
}
|
||||
|
||||
private static boolean isOpen(ModuleDescriptor descriptor, String pn) {
|
||||
return descriptor.opens()
|
||||
.stream()
|
||||
.anyMatch(e -> e.source().equals(pn) && !e.isQualified());
|
||||
}
|
||||
}
|
||||
@@ -147,7 +147,8 @@ public final class ModuleBootstrap {
|
||||
getProperty("jdk.module.limitmods") == null && // --limit-modules
|
||||
getProperty("jdk.module.addreads.0") == null && // --add-reads
|
||||
getProperty("jdk.module.addexports.0") == null && // --add-exports
|
||||
getProperty("jdk.module.addopens.0") == null; // --add-opens
|
||||
getProperty("jdk.module.addopens.0") == null && // --add-opens
|
||||
getProperty("jdk.module.illegalAccess") == null; // --jbr-illegal-access
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,6 +189,7 @@ public final class ModuleBootstrap {
|
||||
String mainModule = System.getProperty("jdk.module.main");
|
||||
Set<String> addModules = addModules();
|
||||
Set<String> limitModules = limitModules();
|
||||
String illegalAccess = getAndRemoveProperty("jdk.module.illegalAccess");
|
||||
|
||||
PrintStream traceOutput = null;
|
||||
String trace = getAndRemoveProperty("jdk.module.showModuleResolution");
|
||||
@@ -219,7 +221,8 @@ public final class ModuleBootstrap {
|
||||
&& !haveModulePath
|
||||
&& addModules.isEmpty()
|
||||
&& limitModules.isEmpty()
|
||||
&& !isPatched) {
|
||||
&& !isPatched
|
||||
&& illegalAccess == null) {
|
||||
systemModuleFinder = archivedModuleGraph.finder();
|
||||
hasSplitPackages = archivedModuleGraph.hasSplitPackages();
|
||||
hasIncubatorModules = archivedModuleGraph.hasIncubatorModules();
|
||||
@@ -454,10 +457,19 @@ public final class ModuleBootstrap {
|
||||
checkIncubatingStatus(cf);
|
||||
}
|
||||
|
||||
// --add-reads, --add-exports/--add-opens
|
||||
// --add-reads, --add-exports/--add-opens, and --jbr-illegal-access
|
||||
addExtraReads(bootLayer);
|
||||
boolean extraExportsOrOpens = addExtraExportsAndOpens(bootLayer);
|
||||
|
||||
if (illegalAccess != null) {
|
||||
assert systemModules != null;
|
||||
addIllegalAccess(illegalAccess,
|
||||
systemModules,
|
||||
upgradeModulePath,
|
||||
bootLayer,
|
||||
extraExportsOrOpens);
|
||||
}
|
||||
|
||||
// add enable native access
|
||||
addEnableNativeAccess(bootLayer);
|
||||
|
||||
@@ -813,6 +825,74 @@ public final class ModuleBootstrap {
|
||||
return modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process the --jbr-illegal-access option to open packages of system modules
|
||||
* in the boot layer to code in unnamed modules.
|
||||
*/
|
||||
private static void addIllegalAccess(String illegalAccess,
|
||||
SystemModules systemModules,
|
||||
ModuleFinder upgradeModulePath,
|
||||
ModuleLayer bootLayer,
|
||||
boolean extraExportsOrOpens) {
|
||||
|
||||
Map<String, Set<String>> concealedPackagesToOpen = systemModules.concealedPackagesToOpen();
|
||||
Map<String, Set<String>> exportedPackagesToOpen = systemModules.exportedPackagesToOpen();
|
||||
if (concealedPackagesToOpen.isEmpty() && exportedPackagesToOpen.isEmpty()) {
|
||||
// need to generate (exploded build)
|
||||
IllegalAccessMaps maps = IllegalAccessMaps.generate(limitedFinder());
|
||||
concealedPackagesToOpen = maps.concealedPackagesToOpen();
|
||||
exportedPackagesToOpen = maps.exportedPackagesToOpen();
|
||||
}
|
||||
|
||||
// open specific packages in the system modules
|
||||
Set<String> emptySet = Set.of();
|
||||
for (Module m : bootLayer.modules()) {
|
||||
ModuleDescriptor descriptor = m.getDescriptor();
|
||||
String name = m.getName();
|
||||
|
||||
// skip open modules
|
||||
if (descriptor.isOpen()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// skip modules loaded from the upgrade module path
|
||||
if (upgradeModulePath != null
|
||||
&& upgradeModulePath.find(name).isPresent()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Set<String> concealedPackages = concealedPackagesToOpen.getOrDefault(name, emptySet);
|
||||
Set<String> exportedPackages = exportedPackagesToOpen.getOrDefault(name, emptySet);
|
||||
|
||||
// refresh the set of concealed and exported packages if needed
|
||||
if (extraExportsOrOpens) {
|
||||
concealedPackages = new HashSet<>(concealedPackages);
|
||||
exportedPackages = new HashSet<>(exportedPackages);
|
||||
Iterator<String> iterator = concealedPackages.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
String pn = iterator.next();
|
||||
if (m.isExported(pn, BootLoader.getUnnamedModule())) {
|
||||
// concealed package is exported to ALL-UNNAMED
|
||||
iterator.remove();
|
||||
exportedPackages.add(pn);
|
||||
}
|
||||
}
|
||||
iterator = exportedPackages.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
String pn = iterator.next();
|
||||
if (m.isOpen(pn, BootLoader.getUnnamedModule())) {
|
||||
// exported package is opened to ALL-UNNAMED
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// open the packages to unnamed modules
|
||||
JLA.addOpensToAllUnnamed(m, concealedPackages, exportedPackages);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the values of --add-reads, -add-exports, --add-opens or
|
||||
* --patch-modules options that are encoded in system properties.
|
||||
|
||||
@@ -83,4 +83,16 @@ interface SystemModules {
|
||||
* by this SystemModules object.
|
||||
*/
|
||||
Map<String, Set<String>> moduleReads();
|
||||
|
||||
/**
|
||||
* Returns the map of module concealed packages to open. The map key is the
|
||||
* module name, the value is the set of concealed packages to open.
|
||||
*/
|
||||
Map<String, Set<String>> concealedPackagesToOpen();
|
||||
|
||||
/**
|
||||
* Returns the map of module exported packages to open. The map key is the
|
||||
* module name, the value is the set of exported packages to open.
|
||||
*/
|
||||
Map<String, Set<String>> exportedPackagesToOpen();
|
||||
}
|
||||
|
||||
1340
src/java.base/share/classes/jdk/internal/module/jdk8_packages.dat
Normal file
1340
src/java.base/share/classes/jdk/internal/module/jdk8_packages.dat
Normal file
File diff suppressed because it is too large
Load Diff
@@ -188,6 +188,10 @@ java.launcher.X.usage=\n\
|
||||
\ --add-opens <module>/<package>=<target-module>(,<target-module>)*\n\
|
||||
\ updates <module> to open <package> to\n\
|
||||
\ <target-module>, regardless of module declaration.\n\
|
||||
\ --jbr-illegal-access\n\
|
||||
\ permit access to members of types in named modules\n\
|
||||
\ by code in unnamed modules.\n\
|
||||
\ This option will be removed in a future release.\n\
|
||||
\ --limit-modules <module name>[,<module name>...]\n\
|
||||
\ limit the universe of observable modules\n\
|
||||
\ --patch-module <module>=<file>({0}<file>)*\n\
|
||||
|
||||
@@ -249,6 +249,13 @@ public final class CStrike extends PhysicalStrike {
|
||||
}
|
||||
}
|
||||
|
||||
int getSlot0GlyphImagePtrs(int[] glyphCodes, long[] images, int len) {
|
||||
int ourGlyphs = 0;
|
||||
while (ourGlyphs < len && (glyphCodes[ourGlyphs] & CompositeGlyphMapper.SLOTMASK) == 0) ourGlyphs++;
|
||||
getGlyphImagePtrs(glyphCodes, images, ourGlyphs);
|
||||
return ourGlyphs;
|
||||
}
|
||||
|
||||
// called from the Sun2D renderer
|
||||
void getGlyphImagePtrs(int[] glyphCodes, long[] images, int len) {
|
||||
synchronized (glyphInfoCache) {
|
||||
|
||||
@@ -38,11 +38,10 @@ import java.beans.PropertyChangeListener;
|
||||
import java.lang.annotation.Native;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.Arrays;
|
||||
@@ -76,24 +75,18 @@ import sun.lwawt.LWWindowPeer;
|
||||
@SuppressWarnings("removal")
|
||||
class CAccessibility implements PropertyChangeListener {
|
||||
private static Set<String> ignoredRoles;
|
||||
private static final int INVOKE_TIMEOUT_SECONDS_DEFAULT = 1;
|
||||
private static final int INVOKE_TIMEOUT_SECONDS;
|
||||
|
||||
static {
|
||||
AtomicInteger invokeTimeoutSecondsRef = new AtomicInteger();
|
||||
// Need to load the native library for this code.
|
||||
java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<Void>() {
|
||||
public Void run() {
|
||||
System.loadLibrary("awt");
|
||||
invokeTimeoutSecondsRef.set(
|
||||
// (-1) for the infinite timeout
|
||||
Integer.getInteger("sun.lwawt.macosx.CAccessibility.invokeTimeoutSeconds",
|
||||
INVOKE_TIMEOUT_SECONDS_DEFAULT));
|
||||
return null;
|
||||
}
|
||||
// (-1) for the infinite timeout
|
||||
@SuppressWarnings("removal")
|
||||
int value = java.security.AccessController.doPrivileged(
|
||||
(PrivilegedAction<Integer>) () -> {
|
||||
// Need to load the native library for this code.
|
||||
System.loadLibrary("awt");
|
||||
return Integer.getInteger("sun.lwawt.macosx.CAccessibility.invokeTimeoutSeconds", 1);
|
||||
});
|
||||
INVOKE_TIMEOUT_SECONDS = invokeTimeoutSecondsRef.get();
|
||||
INVOKE_TIMEOUT_SECONDS = value;
|
||||
}
|
||||
|
||||
static CAccessibility sAccessibility;
|
||||
|
||||
@@ -205,6 +205,7 @@ class CAccessible extends CFRetainedResource implements Accessible {
|
||||
} else if (oldValue != null &&
|
||||
((AccessibleState) oldValue) == AccessibleState.VISIBLE) {
|
||||
execute(ptr -> menuClosed(ptr));
|
||||
execute(ptr -> unregisterFromCocoaAXSystem(ptr));
|
||||
}
|
||||
} else if (thisRole == AccessibleRole.MENU_ITEM) {
|
||||
if (newValue != null &&
|
||||
|
||||
@@ -66,6 +66,7 @@ import sun.awt.AWTAccessor.ComponentAccessor;
|
||||
import sun.awt.AWTAccessor.WindowAccessor;
|
||||
import sun.awt.AWTThreading;
|
||||
import sun.java2d.SurfaceData;
|
||||
import sun.lwawt.LWComponentPeer;
|
||||
import sun.lwawt.LWLightweightFramePeer;
|
||||
import sun.lwawt.LWToolkit;
|
||||
import sun.lwawt.LWWindowPeer;
|
||||
@@ -105,6 +106,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
private static native boolean nativeDelayShowing(long nsWindowPtr);
|
||||
private static native void nativeRaiseLevel(long nsWindowPtr, boolean popup, boolean onlyIfParentIsActive);
|
||||
private static native void nativeSetTransparentTitleBarHeight(long nsWindowPtr, float height);
|
||||
private static native void nativeCallDeliverMoveResizeEvent(long nsWindowPtr);
|
||||
|
||||
// Loger to report issues happened during execution but that do not affect functionality
|
||||
private static final PlatformLogger logger = PlatformLogger.getLogger("sun.lwawt.macosx.CPlatformWindow");
|
||||
@@ -290,7 +292,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
new Property<CPlatformWindow>(WINDOW_TRANSPARENT_TITLE_BAR_HEIGHT) {
|
||||
public void applyProperty(final CPlatformWindow c, final Object value) {
|
||||
if (value != null && (value instanceof Float)) {
|
||||
c.execute(ptr -> nativeSetTransparentTitleBarHeight(ptr, (float) value));
|
||||
c.execute(ptr -> AWTThreading.executeWaitToolkit(wait -> nativeSetTransparentTitleBarHeight(ptr, (float) value)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1195,6 +1197,10 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
responder.handleWindowFocusEvent(gained, oppositePeer);
|
||||
}
|
||||
|
||||
public void doDeliverMoveResizeEvent() {
|
||||
execute(ptr -> nativeCallDeliverMoveResizeEvent(ptr));
|
||||
}
|
||||
|
||||
protected void deliverMoveResizeEvent(int x, int y, int width, int height,
|
||||
boolean byUser) {
|
||||
AtomicBoolean ref = new AtomicBoolean();
|
||||
@@ -1339,7 +1345,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
// which is going to become 'main window', are placed above their siblings.
|
||||
CPlatformWindow rootOwner = getRootOwner();
|
||||
if (rootOwner.isVisible() && !rootOwner.isIconified() && !rootOwner.isActive()) {
|
||||
rootOwner.execute(CWrapper.NSWindow::orderFront);
|
||||
rootOwner.execute(CWrapper.NSWindow::orderFrontIfOnActiveSpace);
|
||||
}
|
||||
|
||||
// Do not order child windows of iconified owner.
|
||||
@@ -1375,7 +1381,7 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
}
|
||||
pwUnder.execute(underPtr -> {
|
||||
pw.execute(ptr -> {
|
||||
CWrapper.NSWindow.orderWindow(ptr, CWrapper.NSWindow.NSWindowAbove, underPtr);
|
||||
CWrapper.NSWindow.orderWindowIfOnActiveSpace(ptr, CWrapper.NSWindow.NSWindowAbove, underPtr);
|
||||
});
|
||||
});
|
||||
pwUnder = pw;
|
||||
@@ -1456,28 +1462,20 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
isFullScreenAnimationOn = false;
|
||||
}
|
||||
|
||||
// called from client via reflection
|
||||
private void setTransparentTitleBarHeight(float height) {
|
||||
execute(ptr -> {
|
||||
nativeSetTransparentTitleBarHeight(ptr, height);
|
||||
});
|
||||
}
|
||||
|
||||
private volatile List<Rectangle> customDecorHitTestSpots;
|
||||
|
||||
// called from client via reflection
|
||||
private void setCustomDecorationHitTestSpots(List<Rectangle> hitTestSpots) {
|
||||
this.customDecorHitTestSpots = new CopyOnWriteArrayList<>(hitTestSpots);
|
||||
}
|
||||
|
||||
// called from native
|
||||
private boolean hitTestCustomDecoration(float x, float y) {
|
||||
List<Rectangle> spots = customDecorHitTestSpots;
|
||||
if (spots == null) return false;
|
||||
for (Rectangle spot : spots) {
|
||||
if (spot.contains(x, y)) return true;
|
||||
// JBR API internals
|
||||
private static void setCustomDecorationTitleBarHeight(Window target, ComponentPeer peer, float height) {
|
||||
if (peer instanceof LWComponentPeer) {
|
||||
PlatformWindow platformWindow = ((LWComponentPeer<?, ?>) peer).getPlatformWindow();
|
||||
if (platformWindow instanceof CPlatformWindow) {
|
||||
((CPlatformWindow) platformWindow).execute(ptr -> {
|
||||
AWTThreading.executeWaitToolkit(wait -> nativeSetTransparentTitleBarHeight(ptr, height));
|
||||
});
|
||||
if (target instanceof javax.swing.RootPaneContainer) {
|
||||
final javax.swing.JRootPane rootpane = ((javax.swing.RootPaneContainer)target).getRootPane();
|
||||
if (rootpane != null) rootpane.putClientProperty(WINDOW_TRANSPARENT_TITLE_BAR_HEIGHT, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -56,8 +56,10 @@ final class CWrapper {
|
||||
static native boolean isKeyWindow(long window);
|
||||
|
||||
static native void orderFront(long window);
|
||||
static native void orderFrontIfOnActiveSpace(long window);
|
||||
static native void orderFrontRegardless(long window);
|
||||
static native void orderWindow(long window, int ordered, long relativeTo);
|
||||
static native void orderWindowIfOnActiveSpace(long window, int ordered, long relativeTo);
|
||||
|
||||
/**
|
||||
* Removes the window from the screen.
|
||||
|
||||
@@ -89,6 +89,7 @@ import java.net.URL;
|
||||
import java.security.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
@@ -675,30 +676,12 @@ public final class LWCToolkit extends LWToolkit {
|
||||
return invokeAndWait(callable, component, -1);
|
||||
}
|
||||
|
||||
static <T> T invokeAndWait(final Callable<T> callable, Component component, int timeoutSeconds) throws Exception {
|
||||
public static <T> T invokeAndWait(final Callable<T> callable, Component component, int timeoutSeconds) throws Exception {
|
||||
final CallableWrapper<T> wrapper = new CallableWrapper<>(callable);
|
||||
invokeAndWait(wrapper, component, false, timeoutSeconds);
|
||||
return wrapper.getResult();
|
||||
}
|
||||
|
||||
static final class CancelableRunnable implements Runnable {
|
||||
volatile Runnable runnable;
|
||||
|
||||
public CancelableRunnable(Runnable runnable) {
|
||||
this.runnable = runnable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Runnable r = runnable;
|
||||
if (r != null) r.run();
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
runnable = null;
|
||||
}
|
||||
}
|
||||
|
||||
static final class CallableWrapper<T> implements Runnable {
|
||||
final Callable<T> callable;
|
||||
T object;
|
||||
@@ -776,7 +759,7 @@ public final class LWCToolkit extends LWToolkit {
|
||||
invokeAndWait(runnable, component, false, -1);
|
||||
}
|
||||
|
||||
static void invokeAndWait(Runnable runnable, Component component, boolean processEvents, int timeoutSeconds)
|
||||
public static void invokeAndWait(Runnable runnable, Component component, boolean processEvents, int timeoutSeconds)
|
||||
throws InvocationTargetException
|
||||
{
|
||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
@@ -784,24 +767,17 @@ public final class LWCToolkit extends LWToolkit {
|
||||
}
|
||||
|
||||
boolean nonBlockingRunLoop;
|
||||
CancelableRunnable cancelableRunnable = new CancelableRunnable(runnable);
|
||||
|
||||
synchronized (priorityInvocationPending) {
|
||||
nonBlockingRunLoop = priorityInvocationPending.get();
|
||||
if (!nonBlockingRunLoop) blockingRunLoopCounter.incrementAndGet();
|
||||
}
|
||||
|
||||
final long mediator = createAWTRunLoopMediator();
|
||||
AWTThreading.TrackedInvocationEvent invocationEvent =
|
||||
AWTThreading.createAndTrackInvocationEvent(component, runnable, true);
|
||||
|
||||
InvocationEvent invocationEvent =
|
||||
AWTThreading.createAndTrackInvocationEvent(component,
|
||||
cancelableRunnable,
|
||||
() -> {
|
||||
if (mediator != 0) {
|
||||
stopAWTRunLoop(mediator);
|
||||
}
|
||||
},
|
||||
true);
|
||||
long mediator = createAWTRunLoopMediator();
|
||||
invocationEvent.onDone(() -> stopAWTRunLoop(mediator));
|
||||
|
||||
if (component != null) {
|
||||
AppContext appContext = SunToolkit.targetToAppContext(component);
|
||||
@@ -815,10 +791,21 @@ public final class LWCToolkit extends LWToolkit {
|
||||
((LWCToolkit)Toolkit.getDefaultToolkit()).getSystemEventQueueForInvokeAndWait().postEvent(invocationEvent);
|
||||
}
|
||||
|
||||
CompletableFuture<Void> eventDispatchThreadFreeFuture =
|
||||
AWTThreading.getInstance(component).onEventDispatchThreadFree(() -> {
|
||||
if (!invocationEvent.isDone()) {
|
||||
// EventQueue is now empty but the posted InvocationEvent is still not dispatched,
|
||||
// consider it lost then.
|
||||
invocationEvent.dispose("InvocationEvent was lost");
|
||||
}
|
||||
});
|
||||
|
||||
invocationEvent.onDone(() -> eventDispatchThreadFreeFuture.cancel(false));
|
||||
|
||||
if (!doAWTRunLoop(mediator, nonBlockingRunLoop, timeoutSeconds)) {
|
||||
new Throwable("Invocation timed out (" + timeoutSeconds + "sec)").printStackTrace();
|
||||
cancelableRunnable.cancel();
|
||||
invocationEvent.dispose("InvocationEvent has timed out");
|
||||
}
|
||||
|
||||
if (!nonBlockingRunLoop) blockingRunLoopCounter.decrementAndGet();
|
||||
|
||||
if (log.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
|
||||
@@ -50,6 +50,10 @@
|
||||
NSWindowTabbingMode javaWindowTabbingMode;
|
||||
BOOL isEnterFullScreen;
|
||||
CGFloat _transparentTitleBarHeight;
|
||||
id<NSObject> _windowWillEnterFullScreenNotification;
|
||||
id<NSObject> _windowWillExitFullScreenNotification;
|
||||
id<NSObject> _windowDidExitFullScreenNotification;
|
||||
NSMutableArray* _transparentTitleBarConstraints;
|
||||
NSLayoutConstraint *_transparentTitleBarHeightConstraint;
|
||||
NSMutableArray *_transparentTitleBarButtonCenterXConstraints;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include <objc/objc-runtime.h>
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include <java_awt_Window_CustomWindowDecoration.h>
|
||||
#import "sun_lwawt_macosx_CPlatformWindow.h"
|
||||
#import "com_apple_eawt_event_GestureHandler.h"
|
||||
#import "com_apple_eawt_FullScreenHandler.h"
|
||||
@@ -69,6 +70,9 @@ static NSPoint lastTopLeftPoint;
|
||||
|
||||
static BOOL ignoreResizeWindowDuringAnotherWindowEnd = NO;
|
||||
|
||||
static BOOL fullScreenTransitionInProgress = NO;
|
||||
static BOOL orderingScheduled = NO;
|
||||
|
||||
// --------------------------------------------------------------
|
||||
// NSWindow/NSPanel descendants implementation
|
||||
#define AWT_NS_WINDOW_IMPLEMENTATION \
|
||||
@@ -399,10 +403,11 @@ AWT_NS_WINDOW_IMPLEMENTATION
|
||||
|
||||
if (IS(mask, FULLSCREENABLE) && [self.nsWindow respondsToSelector:@selector(toggleFullScreen:)]) {
|
||||
if (IS(bits, FULLSCREENABLE)) {
|
||||
[self.nsWindow setCollectionBehavior:
|
||||
NSWindowCollectionBehaviorFullScreenPrimary | NSWindowCollectionBehaviorManaged];
|
||||
self.nsWindow.collectionBehavior = self.nsWindow.collectionBehavior |
|
||||
NSWindowCollectionBehaviorFullScreenPrimary;
|
||||
} else {
|
||||
[self.nsWindow setCollectionBehavior: NSWindowCollectionBehaviorManaged];
|
||||
self.nsWindow.collectionBehavior = self.nsWindow.collectionBehavior &
|
||||
~NSWindowCollectionBehaviorFullScreenPrimary;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -478,6 +483,7 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
self.isJustCreated = YES;
|
||||
|
||||
self.javaWindowTabbingMode = [self getJavaWindowTabbingMode];
|
||||
self.nsWindow.collectionBehavior = NSWindowCollectionBehaviorManaged;
|
||||
self.isEnterFullScreen = NO;
|
||||
|
||||
return self;
|
||||
@@ -641,8 +647,9 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
- (BOOL) delayShowing {
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
|
||||
return ownerWindow != nil && ([ownerWindow delayShowing] || !ownerWindow.nsWindow.onActiveSpace)
|
||||
&& !nsWindow.visible;
|
||||
return ownerWindow != nil &&
|
||||
([ownerWindow delayShowing] || !ownerWindow.nsWindow.onActiveSpace) &&
|
||||
!nsWindow.visible;
|
||||
}
|
||||
|
||||
- (BOOL) checkBlockingAndOrder {
|
||||
@@ -663,14 +670,19 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
+ (void)activeSpaceDidChange {
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
|
||||
for (NSWindow* window in [NSApp windows]) {
|
||||
if (window.onActiveSpace && window.mainWindow && [AWTWindow isJavaPlatformWindowVisible:window]) {
|
||||
if (fullScreenTransitionInProgress) {
|
||||
orderingScheduled = YES;
|
||||
return;
|
||||
}
|
||||
|
||||
// show delayed windows
|
||||
for (NSWindow *window in NSApp.windows) {
|
||||
if ([AWTWindow isJavaPlatformWindowVisible:window] && !window.visible) {
|
||||
AWTWindow *awtWindow = (AWTWindow *)[window delegate];
|
||||
// there can be only one current blocker per window hierarchy,
|
||||
// so we're checking just hierarchy root
|
||||
if (awtWindow.ownerWindow == nil) {
|
||||
// this should ensure that delayed blocking windows
|
||||
// show up on space activation
|
||||
while (awtWindow.ownerWindow != nil) {
|
||||
awtWindow = awtWindow.ownerWindow;
|
||||
}
|
||||
if (awtWindow.nsWindow.visible && awtWindow.nsWindow.onActiveSpace) {
|
||||
[awtWindow checkBlockingAndOrder];
|
||||
}
|
||||
}
|
||||
@@ -719,11 +731,6 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
// back to normal window level
|
||||
[window setLevel:NSNormalWindowLevel];
|
||||
}
|
||||
if (window.onActiveSpace && owner.onActiveSpace) {
|
||||
// The childWindow should be displayed in front of
|
||||
// its nearest parentWindow
|
||||
[window orderWindow:NSWindowAbove relativeTo:[owner windowNumber]];
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
@@ -769,7 +776,7 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
// NSWindowDelegate methods
|
||||
|
||||
- (void) _deliverMoveResizeEvent {
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
|
||||
// deliver the event if this is a user-initiated live resize or as a side-effect
|
||||
// of a Java initiated resize, because AppKit can override the bounds and force
|
||||
@@ -778,10 +785,18 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow);
|
||||
if (platformWindow == NULL) {
|
||||
// TODO: create generic AWT assert
|
||||
NSLog(@"[AWTWindow _deliverMoveResizeEvent]: platformWindow == NULL");
|
||||
return;
|
||||
}
|
||||
NSRect frame;
|
||||
@try {
|
||||
frame = ConvertNSScreenRect(env, [self.nsWindow frame]);
|
||||
} @catch (NSException *e) {
|
||||
NSLog(@"WARNING: suppressed exception from ConvertNSScreenRect() in [AWTWindow _deliverMoveResizeEvent]");
|
||||
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
|
||||
[NSApplicationAWT logException:e forProcess:processInfo];
|
||||
return;
|
||||
}
|
||||
|
||||
NSRect frame = ConvertNSScreenRect(env, [self.nsWindow frame]);
|
||||
|
||||
GET_CPLATFORM_WINDOW_CLASS();
|
||||
DECLARE_METHOD(jm_deliverMoveResizeEvent, jc_CPlatformWindow, "deliverMoveResizeEvent", "(IIIIZ)V");
|
||||
@@ -1003,7 +1018,7 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
#ifdef DEBUG
|
||||
NSLog(@"resigned key: %d %@ %@", [self.nsWindow isMainWindow], [self.nsWindow title], [self menuBarForWindow]);
|
||||
#endif
|
||||
if (![self.nsWindow isMainWindow]) {
|
||||
if (![self.nsWindow isMainWindow] || [NSApp keyWindow] == self.nsWindow) {
|
||||
[self deactivateWindow];
|
||||
}
|
||||
}
|
||||
@@ -1032,7 +1047,9 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
NSWindow *keyWindow = [NSApp keyWindow];
|
||||
AWTWindow *opposite = nil;
|
||||
if ([AWTWindow isAWTWindow: keyWindow]) {
|
||||
opposite = (AWTWindow *)[keyWindow delegate];
|
||||
if (keyWindow != self.nsWindow) {
|
||||
opposite = (AWTWindow *)[keyWindow delegate];
|
||||
}
|
||||
[AWTWindow setLastKeyWindow: self];
|
||||
} else {
|
||||
[AWTWindow setLastKeyWindow: nil];
|
||||
@@ -1080,13 +1097,26 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
[self processVisibleChildren:^void(AWTWindow* child){
|
||||
NSWindow *window = child.nsWindow;
|
||||
NSWindowCollectionBehavior behavior = window.collectionBehavior;
|
||||
behavior &= !(NSWindowCollectionBehaviorManaged | NSWindowCollectionBehaviorTransient);
|
||||
behavior &= ~(NSWindowCollectionBehaviorManaged | NSWindowCollectionBehaviorTransient);
|
||||
behavior |= allow ? NSWindowCollectionBehaviorTransient : NSWindowCollectionBehaviorManaged;
|
||||
window.collectionBehavior = behavior;
|
||||
}];
|
||||
}
|
||||
|
||||
- (void) fullScreenTransitionStarted {
|
||||
fullScreenTransitionInProgress = YES;
|
||||
}
|
||||
|
||||
- (void) fullScreenTransitionFinished {
|
||||
fullScreenTransitionInProgress = NO;
|
||||
if (orderingScheduled) {
|
||||
orderingScheduled = NO;
|
||||
[self checkBlockingAndOrder];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)windowWillEnterFullScreen:(NSNotification *)notification {
|
||||
[self fullScreenTransitionStarted];
|
||||
[self allowMovingChildrenBetweenSpaces:YES];
|
||||
|
||||
self.isEnterFullScreen = YES;
|
||||
@@ -1107,6 +1137,7 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
self.isEnterFullScreen = YES;
|
||||
|
||||
[self allowMovingChildrenBetweenSpaces:NO];
|
||||
[self fullScreenTransitionFinished];
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
GET_CPLATFORM_WINDOW_CLASS();
|
||||
@@ -1124,6 +1155,8 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
- (void)windowWillExitFullScreen:(NSNotification *)notification {
|
||||
self.isEnterFullScreen = NO;
|
||||
|
||||
[self fullScreenTransitionStarted];
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
GET_CPLATFORM_WINDOW_CLASS();
|
||||
DECLARE_METHOD(jm_windowWillExitFullScreen, jc_CPlatformWindow, "windowWillExitFullScreen", "()V");
|
||||
@@ -1144,6 +1177,8 @@ AWT_ASSERT_APPKIT_THREAD;
|
||||
- (void)windowDidExitFullScreen:(NSNotification *)notification {
|
||||
self.isEnterFullScreen = NO;
|
||||
|
||||
[self fullScreenTransitionFinished];
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow);
|
||||
if (platformWindow != NULL) {
|
||||
@@ -1270,10 +1305,10 @@ static const CGFloat DefaultHorizontalTitleBarButtonOffset = 20.0;
|
||||
NSView* titlebarContainer = titlebar.superview;
|
||||
NSView* themeFrame = titlebarContainer.superview;
|
||||
|
||||
NSMutableArray* newConstraints = [[NSMutableArray alloc] init];
|
||||
_transparentTitleBarConstraints = [[NSMutableArray alloc] init];
|
||||
titlebarContainer.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
_transparentTitleBarHeightConstraint = [titlebarContainer.heightAnchor constraintEqualToConstant:_transparentTitleBarHeight];
|
||||
[newConstraints addObjectsFromArray:@[
|
||||
[_transparentTitleBarConstraints addObjectsFromArray:@[
|
||||
[titlebarContainer.leftAnchor constraintEqualToAnchor:themeFrame.leftAnchor],
|
||||
[titlebarContainer.widthAnchor constraintEqualToAnchor:themeFrame.widthAnchor],
|
||||
[titlebarContainer.topAnchor constraintEqualToAnchor:themeFrame.topAnchor],
|
||||
@@ -1286,7 +1321,7 @@ static const CGFloat DefaultHorizontalTitleBarButtonOffset = 20.0;
|
||||
for (NSView* view in @[titlebar, windowDragView])
|
||||
{
|
||||
view.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
[newConstraints addObjectsFromArray:@[
|
||||
[_transparentTitleBarConstraints addObjectsFromArray:@[
|
||||
[view.leftAnchor constraintEqualToAnchor:titlebarContainer.leftAnchor],
|
||||
[view.rightAnchor constraintEqualToAnchor:titlebarContainer.rightAnchor],
|
||||
[view.topAnchor constraintEqualToAnchor:titlebarContainer.topAnchor],
|
||||
@@ -1302,7 +1337,7 @@ static const CGFloat DefaultHorizontalTitleBarButtonOffset = 20.0;
|
||||
button.translatesAutoresizingMaskIntoConstraints = NO;
|
||||
NSLayoutConstraint* buttonCenterXConstraint = [button.centerXAnchor constraintEqualToAnchor:titlebarContainer.leftAnchor constant:(_transparentTitleBarHeight/2.0 + (index * horizontalButtonOffset))];
|
||||
[_transparentTitleBarButtonCenterXConstraints addObject:buttonCenterXConstraint];
|
||||
[newConstraints addObjectsFromArray:@[
|
||||
[_transparentTitleBarConstraints addObjectsFromArray:@[
|
||||
[button.widthAnchor constraintLessThanOrEqualToAnchor:titlebarContainer.heightAnchor multiplier:0.5],
|
||||
// Those corrections are required to keep the icons perfectly round because macOS adds a constant 2 px in resulting height to their frame
|
||||
[button.heightAnchor constraintEqualToAnchor: button.widthAnchor multiplier:14.0/12.0 constant:-2.0],
|
||||
@@ -1311,7 +1346,7 @@ static const CGFloat DefaultHorizontalTitleBarButtonOffset = 20.0;
|
||||
]];
|
||||
}];
|
||||
|
||||
[NSLayoutConstraint activateConstraints:newConstraints];
|
||||
[NSLayoutConstraint activateConstraints:_transparentTitleBarConstraints];
|
||||
}
|
||||
|
||||
- (void) updateTransparentTitleBarConstraints
|
||||
@@ -1337,20 +1372,22 @@ static const CGFloat DefaultHorizontalTitleBarButtonOffset = 20.0;
|
||||
NSView* titlebarContainer = titlebar.superview;
|
||||
NSView* themeFrame = titlebarContainer.superview;
|
||||
|
||||
[NSLayoutConstraint deactivateConstraints:_transparentTitleBarConstraints];
|
||||
|
||||
AWTWindowDragView* windowDragView;
|
||||
for (NSView* view in titlebar.subviews) {
|
||||
if ([view isMemberOfClass:[AWTWindowDragView class]]) {
|
||||
windowDragView = view;
|
||||
}
|
||||
if (view.translatesAutoresizingMaskIntoConstraints == NO) {
|
||||
[view removeConstraints:view.constraints];
|
||||
view.translatesAutoresizingMaskIntoConstraints = YES;
|
||||
}
|
||||
}
|
||||
[windowDragView removeFromSuperview];
|
||||
[titlebarContainer removeConstraints:titlebarContainer.constraints];
|
||||
titlebarContainer.translatesAutoresizingMaskIntoConstraints = YES;
|
||||
titlebar.translatesAutoresizingMaskIntoConstraints = YES;
|
||||
|
||||
_transparentTitleBarConstraints = nil;
|
||||
_transparentTitleBarHeightConstraint = nil;
|
||||
_transparentTitleBarButtonCenterXConstraints = nil;
|
||||
}
|
||||
@@ -1379,23 +1416,44 @@ static const CGFloat DefaultHorizontalTitleBarButtonOffset = 20.0;
|
||||
});
|
||||
NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter];
|
||||
NSOperationQueue* mainQueue = [NSOperationQueue mainQueue];
|
||||
[defaultCenter addObserverForName:NSWindowWillEnterFullScreenNotification object:self.nsWindow queue:mainQueue usingBlock:^(NSNotification* notification) {
|
||||
_windowWillEnterFullScreenNotification = [defaultCenter addObserverForName:NSWindowWillEnterFullScreenNotification object:self.nsWindow queue:mainQueue usingBlock:^(NSNotification* notification) {
|
||||
[self resetTitleBar];
|
||||
}];
|
||||
[defaultCenter addObserverForName:NSWindowWillExitFullScreenNotification object:self.nsWindow queue:mainQueue usingBlock:^(NSNotification* notification) {
|
||||
_windowWillExitFullScreenNotification = [defaultCenter addObserverForName:NSWindowWillExitFullScreenNotification object:self.nsWindow queue:mainQueue usingBlock:^(NSNotification* notification) {
|
||||
[self setWindowControlsHidden:YES];
|
||||
}];
|
||||
[defaultCenter addObserverForName:NSWindowDidExitFullScreenNotification object:self.nsWindow queue:mainQueue usingBlock:^(NSNotification* notification) {
|
||||
_windowDidExitFullScreenNotification = [defaultCenter addObserverForName:NSWindowDidExitFullScreenNotification object:self.nsWindow queue:mainQueue usingBlock:^(NSNotification* notification) {
|
||||
[self setUpTransparentTitleBar];
|
||||
[self setWindowControlsHidden:NO];
|
||||
}];
|
||||
}
|
||||
|
||||
- (void) configureWindowAndListenersForDefaultTitleBar
|
||||
{
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
[self.nsWindow setTitlebarAppearsTransparent:NO];
|
||||
[self.nsWindow setTitleVisibility:NSWindowTitleVisible];
|
||||
[self.nsWindow setStyleMask:[self.nsWindow styleMask]&(~NSWindowStyleMaskFullSizeContentView)];
|
||||
|
||||
if (!self.isFullScreen) {
|
||||
[self resetTitleBar];
|
||||
}
|
||||
});
|
||||
NSNotificationCenter* defaultCenter = [NSNotificationCenter defaultCenter];
|
||||
[defaultCenter removeObserver:_windowWillEnterFullScreenNotification];
|
||||
[defaultCenter removeObserver:_windowWillExitFullScreenNotification];
|
||||
[defaultCenter removeObserver:_windowDidExitFullScreenNotification];
|
||||
_windowWillEnterFullScreenNotification = _windowWillExitFullScreenNotification = _windowDidExitFullScreenNotification = nil;
|
||||
}
|
||||
|
||||
- (void) setTransparentTitleBarHeight: (CGFloat) transparentTitleBarHeight
|
||||
{
|
||||
if (_transparentTitleBarHeight == transparentTitleBarHeight) return;
|
||||
if (_transparentTitleBarHeight != 0.0f) {
|
||||
_transparentTitleBarHeight = transparentTitleBarHeight;
|
||||
if (_transparentTitleBarHeightConstraint != nil || _transparentTitleBarButtonCenterXConstraints != nil) {
|
||||
if (transparentTitleBarHeight == 0.0f) {
|
||||
[self configureWindowAndListenersForDefaultTitleBar];
|
||||
} else if (_transparentTitleBarHeightConstraint != nil || _transparentTitleBarButtonCenterXConstraints != nil) {
|
||||
[self updateTransparentTitleBarConstraints];
|
||||
}
|
||||
} else {
|
||||
@@ -1431,11 +1489,18 @@ static const CGFloat DefaultHorizontalTitleBarButtonOffset = 20.0;
|
||||
jobject platformWindow = (*env)->NewLocalRef(env, self.javaPlatformWindow);
|
||||
if (platformWindow != NULL) {
|
||||
GET_CPLATFORM_WINDOW_CLASS_RETURN(YES);
|
||||
DECLARE_METHOD_RETURN(jm_hitTestCustomDecoration, jc_CPlatformWindow, "hitTestCustomDecoration", "(FF)Z", YES);
|
||||
NSRect frame = [self.window frame];
|
||||
float windowHeight = frame.size.height;
|
||||
returnValue = (*env)->CallBooleanMethod(env, platformWindow, jm_hitTestCustomDecoration, point.x, windowHeight - point.y) == JNI_TRUE ? NO : YES;
|
||||
CHECK_EXCEPTION_IN_ENV(env);
|
||||
DECLARE_FIELD_RETURN(jf_target, jc_CPlatformWindow, "target", "Ljava/awt/Window;", YES);
|
||||
DECLARE_CLASS_RETURN(jc_Window, "java/awt/Window", YES);
|
||||
DECLARE_METHOD_RETURN(jm_hitTestCustomDecoration, jc_Window, "hitTestCustomDecoration", "(II)I", YES);
|
||||
jobject awtWindow = (*env)->GetObjectField(env, platformWindow, jf_target);
|
||||
if (awtWindow != NULL) {
|
||||
NSRect frame = [self.window frame];
|
||||
float windowHeight = frame.size.height;
|
||||
returnValue = (*env)->CallIntMethod(env, awtWindow, jm_hitTestCustomDecoration, (jint) point.x, (jint) (windowHeight - point.y)) ==
|
||||
(jint) java_awt_Window_CustomWindowDecoration_NO_HIT_SPOT ? YES : NO;
|
||||
CHECK_EXCEPTION();
|
||||
(*env)->DeleteLocalRef(env, awtWindow);
|
||||
}
|
||||
(*env)->DeleteLocalRef(env, platformWindow);
|
||||
}
|
||||
return returnValue;
|
||||
@@ -1588,7 +1653,15 @@ JNI_COCOA_ENTER(env);
|
||||
|
||||
// resets the NSWindow's style mask if the mask intersects any of those bits
|
||||
if (mask & MASK(_STYLE_PROP_BITMASK)) {
|
||||
[nsWindow setStyleMask:[AWTWindow styleMaskForStyleBits:newBits]];
|
||||
NSWindowStyleMask styleMask = [AWTWindow styleMaskForStyleBits:newBits];
|
||||
@try {
|
||||
[nsWindow setStyleMask:styleMask];
|
||||
} @catch (NSException *e) {
|
||||
NSLog(@"WARNING: suppressed exception from [NSWindow setStyleMask] in CPlatformWindow"
|
||||
".nativeSetNSWindowStyleBits");
|
||||
NSProcessInfo *processInfo = [NSProcessInfo processInfo];
|
||||
[NSApplicationAWT logException:e forProcess:processInfo];
|
||||
}
|
||||
}
|
||||
|
||||
// calls methods on NSWindow to change other properties, based on the mask
|
||||
@@ -2276,4 +2349,18 @@ JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeSetTransparen
|
||||
[window setTransparentTitleBarHeight:((CGFloat) transparentTitleBarHeight)];
|
||||
|
||||
JNI_COCOA_EXIT(env);
|
||||
}
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CPlatformWindow_nativeCallDeliverMoveResizeEvent
|
||||
(JNIEnv *env, jclass clazz, jlong windowPtr)
|
||||
{
|
||||
JNI_COCOA_ENTER(env);
|
||||
|
||||
NSWindow *nsWindow = (NSWindow *)jlong_to_ptr(windowPtr);
|
||||
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
|
||||
AWTWindow *window = (AWTWindow*)[nsWindow delegate];
|
||||
[window _deliverMoveResizeEvent];
|
||||
}];
|
||||
|
||||
JNI_COCOA_EXIT(env);
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ static BOOL sNeedsEnter;
|
||||
jobject transferer = [self dataTransferer:env];
|
||||
jbyteArray data = nil;
|
||||
|
||||
if (transferer != NULL) {
|
||||
if (transferer != NULL && fComponent != NULL) {
|
||||
GET_DT_CLASS_RETURN(NULL);
|
||||
DECLARE_METHOD_RETURN(convertDataMethod, DataTransfererClass, "convertData", "(Ljava/lang/Object;Ljava/awt/datatransfer/Transferable;JLjava/util/Map;Z)[B", NULL);
|
||||
data = (*env)->CallObjectMethod(env, transferer, convertDataMethod, fComponent, fTransferable, format, fFormatMap, (jboolean) TRUE);
|
||||
|
||||
@@ -154,6 +154,25 @@ JNI_COCOA_ENTER(env);
|
||||
JNI_COCOA_EXIT(env);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_lwawt_macosx_CWrapper$NSWindow
|
||||
* Method: orderFrontIfOnActiveSpace
|
||||
* Signature: (J)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_orderFrontIfOnActiveSpace
|
||||
(JNIEnv *env, jclass cls, jlong windowPtr)
|
||||
{
|
||||
JNI_COCOA_ENTER(env);
|
||||
|
||||
NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
|
||||
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
|
||||
if (window.onActiveSpace) [window orderFront:window];
|
||||
}];
|
||||
|
||||
JNI_COCOA_EXIT(env);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_lwawt_macosx_CWrapper$NSWindow
|
||||
* Method: nativeOrderOut
|
||||
@@ -231,6 +250,26 @@ JNI_COCOA_ENTER(env);
|
||||
JNI_COCOA_EXIT(env);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_lwawt_macosx_CWrapper$NSWindow
|
||||
* Method: orderWindowIfOnActiveSpace
|
||||
* Signature: (JIJ)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL
|
||||
Java_sun_lwawt_macosx_CWrapper_00024NSWindow_orderWindowIfOnActiveSpace
|
||||
(JNIEnv *env, jclass cls, jlong windowPtr, jint order, jlong relativeToPtr)
|
||||
{
|
||||
JNI_COCOA_ENTER(env);
|
||||
|
||||
NSWindow *window = (NSWindow *)jlong_to_ptr(windowPtr);
|
||||
NSWindow *relativeTo = (NSWindow *)jlong_to_ptr(relativeToPtr);
|
||||
[ThreadUtilities performOnMainThreadWaiting:NO block:^(){
|
||||
if (window.onActiveSpace) [window orderWindow:(NSWindowOrderingMode)order relativeTo:[relativeTo windowNumber]];
|
||||
}];
|
||||
|
||||
JNI_COCOA_EXIT(env);
|
||||
}
|
||||
|
||||
// Used for CWrapper.NSWindow.setLevel() (and level() which isn't implemented yet)
|
||||
static NSInteger LEVELS[sun_lwawt_macosx_CWrapper_NSWindow_MAX_WINDOW_LEVELS];
|
||||
static void initLevels()
|
||||
|
||||
@@ -161,8 +161,8 @@ void initializeActions() {
|
||||
[sActions setObject:NSAccessibilityPressAction forKey:@"click"];
|
||||
[sActions setObject:NSAccessibilityIncrementAction forKey:@"increment"];
|
||||
[sActions setObject:NSAccessibilityDecrementAction forKey:@"decrement"];
|
||||
[sActions setObject:NSAccessibilityShowMenuAction forKey:@"togglePopup"];
|
||||
[sActions setObject:NSAccessibilityPressAction forKey:@"toggleExpand"];
|
||||
[sActions setObject:NSAccessibilityShowMenuAction forKey:@"toggle popup"];
|
||||
[sActions setObject:NSAccessibilityPressAction forKey:@"toggleexpand"];
|
||||
|
||||
sActionSelectors = [[NSMutableDictionary alloc] initWithCapacity:actionsCount];
|
||||
|
||||
|
||||
@@ -632,6 +632,8 @@ JNI_COCOA_ENTER(env);
|
||||
|
||||
AWTRunLoopObject* mediatorObject = (AWTRunLoopObject*)jlong_to_ptr(mediator);
|
||||
|
||||
if (mediatorObject == nil) return;
|
||||
|
||||
[ThreadUtilities performOnMainThread:@selector(endRunLoop) on:mediatorObject withObject:nil waitUntilDone:NO];
|
||||
|
||||
[mediatorObject release];
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
- (BOOL)isAccessibilityElement
|
||||
{
|
||||
return YES;
|
||||
return [[[self accessibilityParent] accessibilityRole] isEqualToString:NSAccessibilityComboBoxRole];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -3371,7 +3371,7 @@ JNI_COCOA_ENTER(env);
|
||||
anotherBaseFont = true;
|
||||
}
|
||||
CTFontRef font = (CTFontRef)nsFont;
|
||||
CFArrayRef codes = CFLocaleCopyISOLanguageCodes();
|
||||
CFArrayRef codes = CFLocaleCopyPreferredLanguages();
|
||||
|
||||
CFArrayRef fds = CTFontCopyDefaultCascadeListForLanguages(font, codes);
|
||||
CFRelease(codes);
|
||||
|
||||
@@ -30,6 +30,7 @@ public class JBRApiModule {
|
||||
.withStatic("getSubpixelResolution", "sun.font.FontUtilities")
|
||||
.service("com.jetbrains.JBRFileDialogService", null)
|
||||
.withStatic("getFileDialog", "com.jetbrains.desktop.JBRFileDialog", "get")
|
||||
.proxy("com.jetbrains.JBRFileDialog", "com.jetbrains.desktop.JBRFileDialog");
|
||||
.proxy("com.jetbrains.JBRFileDialog", "com.jetbrains.desktop.JBRFileDialog")
|
||||
.service("com.jetbrains.CustomWindowDecoration", "java.awt.Window$CustomWindowDecoration");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,6 +358,7 @@ public class EventQueue {
|
||||
if (shouldNotify) {
|
||||
if (theEvent.getSource() != AWTAutoShutdown.getInstance()) {
|
||||
AWTAutoShutdown.getInstance().notifyThreadBusy(dispatchThread);
|
||||
AWTThreading.getInstance(dispatchThread).notifyEventDispatchThreadBusy();
|
||||
}
|
||||
pushPopCond.signalAll();
|
||||
} else if (notifyID) {
|
||||
@@ -570,6 +571,7 @@ public class EventQueue {
|
||||
return event;
|
||||
}
|
||||
AWTAutoShutdown.getInstance().notifyThreadFree(dispatchThread);
|
||||
AWTThreading.getInstance(dispatchThread).notifyEventDispatchThreadFree();
|
||||
pushPopCond.await();
|
||||
} finally {
|
||||
pushPopLock.unlock();
|
||||
@@ -1128,6 +1130,7 @@ public class EventQueue {
|
||||
t.setPriority(Thread.NORM_PRIORITY + 1);
|
||||
t.setDaemon(false);
|
||||
AWTAutoShutdown.getInstance().notifyThreadBusy(t);
|
||||
AWTThreading.getInstance(t).notifyEventDispatchThreadBusy();
|
||||
return t;
|
||||
}
|
||||
}
|
||||
@@ -1158,6 +1161,7 @@ public class EventQueue {
|
||||
dispatchThread = null;
|
||||
}
|
||||
AWTAutoShutdown.getInstance().notifyThreadFree(edt);
|
||||
AWTThreading.getInstance(edt).notifyEventDispatchThreadFree();
|
||||
/*
|
||||
* Event was posted after EDT events pumping had stopped, so start
|
||||
* another EDT to handle this event
|
||||
|
||||
@@ -46,13 +46,17 @@ import java.io.ObjectOutputStream;
|
||||
import java.io.OptionalDataException;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.lang.annotation.Native;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.security.AccessController;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.EventListener;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
import java.util.Vector;
|
||||
@@ -64,6 +68,7 @@ import javax.accessibility.AccessibleRole;
|
||||
import javax.accessibility.AccessibleState;
|
||||
import javax.accessibility.AccessibleStateSet;
|
||||
|
||||
import com.jetbrains.internal.JBRApi;
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.awt.AWTPermissions;
|
||||
import sun.awt.AppContext;
|
||||
@@ -4007,7 +4012,66 @@ public class Window extends Container implements Accessible {
|
||||
}
|
||||
|
||||
private volatile boolean hasCustomDecoration;
|
||||
private volatile List<Map.Entry<Shape, Integer>> customDecorHitTestSpots;
|
||||
private volatile int customDecorTitleBarHeight = -1; // 0 can be a legal value when no title bar is expected
|
||||
|
||||
// called from native
|
||||
private int hitTestCustomDecoration(int x, int y) {
|
||||
var spots = customDecorHitTestSpots;
|
||||
if (spots == null) return CustomWindowDecoration.NO_HIT_SPOT;
|
||||
for (var spot : spots) {
|
||||
if (spot.getKey().contains(x, y)) return spot.getValue();
|
||||
}
|
||||
return CustomWindowDecoration.NO_HIT_SPOT;
|
||||
}
|
||||
|
||||
private static class CustomWindowDecoration {
|
||||
|
||||
@Native public static final int
|
||||
NO_HIT_SPOT = 0,
|
||||
OTHER_HIT_SPOT = 1,
|
||||
MINIMIZE_BUTTON = 2,
|
||||
MAXIMIZE_BUTTON = 3,
|
||||
CLOSE_BUTTON = 4,
|
||||
MENU_BAR = 5;
|
||||
|
||||
void setCustomDecorationEnabled(Window window, boolean enabled) {
|
||||
window.hasCustomDecoration = enabled;
|
||||
if (MacOS.INSTANCE != null && window.customDecorTitleBarHeight > 0f) {
|
||||
MacOS.INSTANCE.setTitleBarHeight(window, window.peer, enabled ? window.customDecorTitleBarHeight : 0);
|
||||
}
|
||||
}
|
||||
boolean isCustomDecorationEnabled(Window window) {
|
||||
return window.hasCustomDecoration;
|
||||
}
|
||||
|
||||
void setCustomDecorationHitTestSpots(Window window, List<Map.Entry<Shape, Integer>> spots) {
|
||||
window.customDecorHitTestSpots = List.copyOf(spots);
|
||||
}
|
||||
List<Map.Entry<Shape, Integer>> getCustomDecorationHitTestSpots(Window window) {
|
||||
return window.customDecorHitTestSpots;
|
||||
}
|
||||
|
||||
void setCustomDecorationTitleBarHeight(Window window, int height) {
|
||||
if (height >= 0) {
|
||||
window.customDecorTitleBarHeight = height;
|
||||
if (MacOS.INSTANCE != null && window.hasCustomDecoration) {
|
||||
MacOS.INSTANCE.setTitleBarHeight(window, window.peer, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
int getCustomDecorationTitleBarHeight(Window window) {
|
||||
return window.customDecorTitleBarHeight;
|
||||
}
|
||||
|
||||
private interface MacOS {
|
||||
MacOS INSTANCE = (MacOS) JBRApi.internalServiceBuilder(MethodHandles.lookup(), null)
|
||||
.withStatic("setTitleBarHeight", "sun.lwawt.macosx.CPlatformWindow", "setCustomDecorationTitleBarHeight").build();
|
||||
void setTitleBarHeight(Window target, ComponentPeer peer, float height);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
boolean hasCustomDecoration() {
|
||||
return hasCustomDecoration;
|
||||
}
|
||||
@@ -4015,6 +4079,7 @@ public class Window extends Container implements Accessible {
|
||||
/**
|
||||
* Set via reflection (JB JdkEx API).
|
||||
*/
|
||||
@Deprecated
|
||||
void setHasCustomDecoration() {
|
||||
hasCustomDecoration = true;
|
||||
}
|
||||
|
||||
@@ -8,15 +8,27 @@ import java.awt.event.InvocationEvent;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Used to perform a cross threads (EventDispatch, Toolkit) execution so that the execution does not cause a deadlock.
|
||||
*
|
||||
* Note: the log messages are tested by jdk/jb/java/awt/Toolkit/LWCToolkitInvokeAndWaitTest.java
|
||||
*/
|
||||
public class AWTThreading {
|
||||
private static final PlatformLogger logger = PlatformLogger.getLogger("sun.awt.AWTThreading");
|
||||
private static final PlatformLogger logger = PlatformLogger.getLogger(AWTThreading.class.getName());
|
||||
|
||||
private static final Runnable EMPTY_RUNNABLE = () -> {};
|
||||
|
||||
private static final AtomicReference<Function<Thread, AWTThreading>> theAWTThreadingFactory =
|
||||
new AtomicReference<>(AWTThreading::new);
|
||||
|
||||
private final Thread eventDispatchThread;
|
||||
|
||||
private ExecutorService executor;
|
||||
// every invokeAndWait() pushes a queue of invocations
|
||||
@@ -24,13 +36,21 @@ public class AWTThreading {
|
||||
|
||||
private int level; // re-entrance level
|
||||
|
||||
private final List<CompletableFuture<Void>> eventDispatchThreadStateNotifiers = new ArrayList<>();
|
||||
private volatile boolean isEventDispatchThreadFree;
|
||||
|
||||
// invocations should be dispatched on proper EDT (per AppContext)
|
||||
private static final Map<Thread, AWTThreading> EDT_TO_INSTANCE_MAP = new ConcurrentHashMap<>();
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private static class TrackingQueue extends LinkedBlockingQueue<InvocationEvent> {}
|
||||
|
||||
private AWTThreading() {}
|
||||
/**
|
||||
* WARNING: for testing purpose, use {@link AWTThreading#getInstance(Thread)} instead.
|
||||
*/
|
||||
public AWTThreading(Thread edt) {
|
||||
eventDispatchThread = edt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes a callable from EventDispatch thread (EDT). It's assumed the callable either performs a blocking execution on Toolkit
|
||||
@@ -178,8 +198,15 @@ public class AWTThreading {
|
||||
* <li>If the event is first dispatched from EventQueue - it gets removed from the tracking queue.
|
||||
* <li>If the event is first dispatched from the tracking queue - its dispatching on EventQueue will be noop.
|
||||
* <ul>
|
||||
*
|
||||
* @param source the source of the event
|
||||
* @param onDispatched called back on event dispatching
|
||||
* @param catchThrowables should catch Throwable's or propagate to the EventDispatch thread's loop
|
||||
*/
|
||||
public static InvocationEvent createAndTrackInvocationEvent(Object source, Runnable runnable, Runnable listener, boolean catchThrowables) {
|
||||
public static TrackedInvocationEvent createAndTrackInvocationEvent(Object source,
|
||||
Runnable onDispatched,
|
||||
boolean catchThrowables)
|
||||
{
|
||||
AWTThreading instance = getInstance(source);
|
||||
if (instance != null) {
|
||||
synchronized (instance.invocations) {
|
||||
@@ -187,65 +214,204 @@ public class AWTThreading {
|
||||
instance.invocations.push(new TrackingQueue());
|
||||
}
|
||||
final TrackingQueue queue = instance.invocations.peek();
|
||||
final InvocationEvent[] eventRef = new InvocationEvent[1];
|
||||
final AtomicReference<TrackedInvocationEvent> eventRef = new AtomicReference<>();
|
||||
|
||||
queue.add(eventRef[0] = new InvocationEvent(
|
||||
source,
|
||||
runnable,
|
||||
// Wrap the original completion listener so that it:
|
||||
// - guarantees a single run either from dispatch or dispose
|
||||
// - removes the invocation event from the tracking queue
|
||||
new Runnable() {
|
||||
WeakReference<TrackingQueue> queueRef = new WeakReference<>(queue);
|
||||
eventRef.set(TrackedInvocationEvent.create(
|
||||
source,
|
||||
onDispatched,
|
||||
new Runnable() {
|
||||
final WeakReference<TrackingQueue> queueRef = new WeakReference<>(queue);
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (queueRef != null) {
|
||||
if (listener != null) {
|
||||
listener.run();
|
||||
}
|
||||
TrackingQueue q = queueRef.get();
|
||||
if (q != null) {
|
||||
q.remove(eventRef[0]);
|
||||
}
|
||||
queueRef = null;
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
TrackingQueue queue = queueRef.get();
|
||||
queueRef.clear();
|
||||
if (queue != null) {
|
||||
queue.remove(eventRef.get());
|
||||
}
|
||||
},
|
||||
catchThrowables)
|
||||
{
|
||||
@Override
|
||||
public void dispatch() {
|
||||
if (!isDispatched()) {
|
||||
super.dispatch();
|
||||
}
|
||||
}
|
||||
});
|
||||
return eventRef[0];
|
||||
},
|
||||
catchThrowables));
|
||||
|
||||
queue.add(eventRef.get());
|
||||
return eventRef.get();
|
||||
}
|
||||
}
|
||||
return new InvocationEvent(source, runnable, listener, catchThrowables);
|
||||
return TrackedInvocationEvent.create(source, onDispatched, () -> {}, catchThrowables);
|
||||
}
|
||||
|
||||
private static AWTThreading getInstance(Object obj) {
|
||||
if (obj == null) return null;
|
||||
@SuppressWarnings("serial")
|
||||
public static class TrackedInvocationEvent extends InvocationEvent {
|
||||
private final long creationTime = System.currentTimeMillis();
|
||||
private final Throwable throwable = new Throwable();
|
||||
private final CompletableFuture<Void> futureResult = new CompletableFuture<>();
|
||||
|
||||
// dispatched or disposed
|
||||
private final AtomicBoolean isFinished = new AtomicBoolean(false);
|
||||
|
||||
static TrackedInvocationEvent create(Object source,
|
||||
Runnable onDispatch,
|
||||
Runnable onDone,
|
||||
boolean catchThrowables)
|
||||
{
|
||||
final AtomicReference<TrackedInvocationEvent> eventRef = new AtomicReference<>();
|
||||
eventRef.set(new TrackedInvocationEvent(
|
||||
source,
|
||||
onDispatch,
|
||||
() -> {
|
||||
if (onDone != null) {
|
||||
onDone.run();
|
||||
}
|
||||
TrackedInvocationEvent thisEvent = eventRef.get();
|
||||
if (!thisEvent.isDispatched()) {
|
||||
// If we're here - this {onDone} is being disposed.
|
||||
thisEvent.finishIfNotYet(() ->
|
||||
// If we're here - this {onDone} is called by the outer AWTAccessor.getInvocationEventAccessor().dispose()
|
||||
// which we do not control, so complete here.
|
||||
thisEvent.futureResult.completeExceptionally(new Throwable("InvocationEvent was disposed"))
|
||||
);
|
||||
}
|
||||
},
|
||||
catchThrowables));
|
||||
return eventRef.get();
|
||||
}
|
||||
|
||||
protected TrackedInvocationEvent(Object source, Runnable onDispatched, Runnable onDone, boolean catchThrowables) {
|
||||
super(source,
|
||||
Optional.of(onDispatched).orElse(EMPTY_RUNNABLE),
|
||||
Optional.of(onDone).orElse(EMPTY_RUNNABLE),
|
||||
catchThrowables);
|
||||
|
||||
futureResult.whenComplete((r, ex) -> {
|
||||
if (ex != null) {
|
||||
String message = ex.getMessage() + " (awaiting " + (System.currentTimeMillis() - creationTime) + " ms)";
|
||||
if (logger.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
ex.initCause(throwable);
|
||||
logger.fine(message, ex);
|
||||
} else if (logger.isLoggable(PlatformLogger.Level.INFO)) {
|
||||
StackTraceElement[] stack = throwable.getStackTrace();
|
||||
logger.info(message + ". Originated at " + stack[stack.length - 1]);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispatch() {
|
||||
finishIfNotYet(super::dispatch);
|
||||
futureResult.complete(null);
|
||||
}
|
||||
|
||||
public void dispose(String reason) {
|
||||
finishIfNotYet(() -> AWTAccessor.getInvocationEventAccessor().dispose(this));
|
||||
futureResult.completeExceptionally(new Throwable(reason));
|
||||
}
|
||||
|
||||
private void finishIfNotYet(Runnable finish) {
|
||||
if (!isFinished.getAndSet(true)) {
|
||||
finish.run();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the event is dispatched or disposed.
|
||||
*/
|
||||
public boolean isDone() {
|
||||
return futureResult.isDone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls the runnable when it's done (immediately if it's done).
|
||||
*/
|
||||
public void onDone(Runnable runnable) {
|
||||
futureResult.whenComplete((r, ex) -> Optional.of(runnable).orElse(EMPTY_RUNNABLE).run());
|
||||
}
|
||||
}
|
||||
|
||||
public static AWTThreading getInstance(Object obj) {
|
||||
if (obj == null) {
|
||||
return getInstance(Toolkit.getDefaultToolkit().getSystemEventQueue());
|
||||
}
|
||||
|
||||
AppContext appContext = SunToolkit.targetToAppContext(obj);
|
||||
if (appContext == null) return null;
|
||||
if (appContext == null) {
|
||||
return getInstance(Toolkit.getDefaultToolkit().getSystemEventQueue());
|
||||
}
|
||||
|
||||
return getInstance((EventQueue)appContext.get(AppContext.EVENT_QUEUE_KEY));
|
||||
}
|
||||
|
||||
private static AWTThreading getInstance(EventQueue eq) {
|
||||
public static AWTThreading getInstance(EventQueue eq) {
|
||||
if (eq == null) return null;
|
||||
|
||||
return getInstance(AWTAccessor.getEventQueueAccessor().getDispatchThread(eq));
|
||||
}
|
||||
|
||||
private static AWTThreading getInstance(Thread edt) {
|
||||
if (edt == null) return null;
|
||||
public static AWTThreading getInstance(Thread edt) {
|
||||
assert edt != null;
|
||||
|
||||
return EDT_TO_INSTANCE_MAP.computeIfAbsent(edt, key -> new AWTThreading());
|
||||
return EDT_TO_INSTANCE_MAP.computeIfAbsent(edt, key -> theAWTThreadingFactory.get().apply(edt));
|
||||
}
|
||||
|
||||
public Thread getEventDispatchThread() {
|
||||
return eventDispatchThread;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets {@code AWTThreading} instance factory.
|
||||
* WARNING: for testing purpose.
|
||||
*/
|
||||
public static void setAWTThreadingFactory(Function<Thread, AWTThreading> factory) {
|
||||
theAWTThreadingFactory.set(factory);
|
||||
}
|
||||
|
||||
public void notifyEventDispatchThreadFree() {
|
||||
List<CompletableFuture<Void>> notifiers = Collections.emptyList();
|
||||
synchronized (eventDispatchThreadStateNotifiers) {
|
||||
isEventDispatchThreadFree = true;
|
||||
if (eventDispatchThreadStateNotifiers.size() > 0) {
|
||||
notifiers = List.copyOf(eventDispatchThreadStateNotifiers);
|
||||
}
|
||||
}
|
||||
if (logger.isLoggable(PlatformLogger.Level.FINER)) {
|
||||
logger.finer("notifyEventDispatchThreadFree");
|
||||
}
|
||||
// notify callbacks out of the synchronization block
|
||||
notifiers.forEach(f -> f.complete(null));
|
||||
}
|
||||
|
||||
public void notifyEventDispatchThreadBusy() {
|
||||
synchronized (eventDispatchThreadStateNotifiers) {
|
||||
isEventDispatchThreadFree = false;
|
||||
}
|
||||
if (logger.isLoggable(PlatformLogger.Level.FINER)) {
|
||||
logger.finer("notifyEventDispatchThreadBusy");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a callback and returns a {@code CompletableFuture} reporting the case when the associated EventDispatch thread
|
||||
* has gone sleeping and stopped dispatching events because of empty EventQueue. If the EventDispatch thread is free
|
||||
* at the moment then the callback is called immediately on the caller's thread and the future completes.
|
||||
*/
|
||||
public CompletableFuture<Void> onEventDispatchThreadFree(Runnable runnable) {
|
||||
CompletableFuture<Void> future = new CompletableFuture<>();
|
||||
future.thenRun(Optional.of(runnable).orElse(EMPTY_RUNNABLE));
|
||||
|
||||
if (!isEventDispatchThreadFree) {
|
||||
synchronized (eventDispatchThreadStateNotifiers) {
|
||||
if (!isEventDispatchThreadFree) {
|
||||
eventDispatchThreadStateNotifiers.add(future);
|
||||
future.whenComplete((r, ex) -> eventDispatchThreadStateNotifiers.remove(future));
|
||||
return future;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (logger.isLoggable(PlatformLogger.Level.FINER)) {
|
||||
logger.finer("onEventDispatchThreadFree: free at the moment");
|
||||
}
|
||||
future.complete(null);
|
||||
return future;
|
||||
}
|
||||
|
||||
public interface Task {
|
||||
|
||||
@@ -781,19 +781,12 @@ abstract class XDecoratedPeer extends XWindowPeer {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Some window managers configure before we are reparented and
|
||||
* the send event flag is set! ugh... (Enlighetenment for one,
|
||||
* possibly MWM as well). If we haven't been reparented yet
|
||||
* this is just the WM shuffling us into position. Ignore
|
||||
* it!!!! or we wind up in a bogus location.
|
||||
*/
|
||||
int runningWM = XWM.getWMID();
|
||||
if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
|
||||
insLog.fine("reparented={0}, visible={1}, WM={2}, decorations={3}",
|
||||
isReparented(), isVisible(), runningWM, getDecorations());
|
||||
}
|
||||
if (!isReparented() && isVisible() && runningWM != XWM.NO_WM
|
||||
if (ENABLE_REPARENTING_CHECK && !isReparented() && isVisible() && runningWM != XWM.NO_WM
|
||||
&& !XWM.isNonReparentingWM()
|
||||
&& getDecorations() != XWindowAttributesData.AWT_DECOR_NONE) {
|
||||
insLog.fine("- visible but not reparented, skipping");
|
||||
|
||||
@@ -52,6 +52,8 @@ import sun.awt.X11GraphicsEnvironment;
|
||||
import sun.java2d.pipe.Region;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
import sun.security.action.GetPropertyAction;
|
||||
|
||||
class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
DisplayChangedListener {
|
||||
|
||||
@@ -61,6 +63,9 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
private static final PlatformLogger grabLog = PlatformLogger.getLogger("sun.awt.X11.grab.XWindowPeer");
|
||||
private static final PlatformLogger iconLog = PlatformLogger.getLogger("sun.awt.X11.icon.XWindowPeer");
|
||||
|
||||
static final boolean ENABLE_REPARENTING_CHECK
|
||||
= "true".equals(GetPropertyAction.privilegedGetProperty("reparenting.check"));
|
||||
|
||||
// should be synchronized on awtLock
|
||||
private static Set<XWindowPeer> windows = new HashSet<XWindowPeer>();
|
||||
|
||||
@@ -747,7 +752,8 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
|
||||
int runningWM = XWM.getWMID();
|
||||
Point newLocation = targetBounds.getLocation();
|
||||
if (xe.get_send_event() || runningWM == XWM.NO_WM || XWM.isNonReparentingWM()) {
|
||||
if (xe.get_send_event() ||
|
||||
(ENABLE_REPARENTING_CHECK ? (runningWM == XWM.NO_WM || XWM.isNonReparentingWM()) : !isReparented())) {
|
||||
// Location, Client size + insets
|
||||
newLocation = new Point(scaleDown(xe.get_x()) - leftInset,
|
||||
scaleDown(xe.get_y()) - topInset);
|
||||
@@ -1443,6 +1449,14 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
isUnhiding |= isWMStateNetHidden();
|
||||
|
||||
super.handleMapNotifyEvent(xev);
|
||||
|
||||
if (!ENABLE_REPARENTING_CHECK && delayedModalBlocking) {
|
||||
// case of non-re-parenting WM
|
||||
// (for a re-parenting WM this should have been already done on ReparentNotify processing)
|
||||
addToTransientFors(AWTAccessor.getComponentAccessor().getPeer(modalBlocker));
|
||||
delayedModalBlocking = false;
|
||||
}
|
||||
|
||||
if (isBeforeFirstMapNotify && !winAttr.initialFocus && shouldSuppressWmTakeFocus()) {
|
||||
suppressWmTakeFocus(false); // restore the protocol.
|
||||
if (!XWM.isKDE2()) {
|
||||
@@ -1662,7 +1676,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
}
|
||||
modalBlocker = d;
|
||||
|
||||
if (isReparented() || XWM.isNonReparentingWM()) {
|
||||
if (isReparented() || ENABLE_REPARENTING_CHECK && XWM.isNonReparentingWM()) {
|
||||
addToTransientFors(blockerPeer, javaToplevels);
|
||||
} else {
|
||||
delayedModalBlocking = true;
|
||||
@@ -1673,7 +1687,7 @@ class XWindowPeer extends XPanelPeer implements WindowPeer,
|
||||
}
|
||||
modalBlocker = null;
|
||||
|
||||
if (isReparented() || XWM.isNonReparentingWM()) {
|
||||
if (isReparented() || ENABLE_REPARENTING_CHECK && XWM.isNonReparentingWM()) {
|
||||
removeFromTransientFors();
|
||||
} else {
|
||||
delayedModalBlocking = false;
|
||||
|
||||
@@ -37,7 +37,9 @@
|
||||
#include "sizecalc.h"
|
||||
#include <jni_util.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "awt.h"
|
||||
#include "debug_assert.h"
|
||||
|
||||
static void *gtk3_libhandle = NULL;
|
||||
static void *gthread_libhandle = NULL;
|
||||
@@ -2911,17 +2913,45 @@ static void transform_detail_string (const gchar *detail,
|
||||
}
|
||||
}
|
||||
|
||||
inline static int scale_down_to_plus_inf(int what, int scale) {
|
||||
return (int)ceilf(what / (float)scale);
|
||||
}
|
||||
|
||||
inline static int scale_down_to_minus_inf(int what, int scale) {
|
||||
return (int)floorf(what / (float)scale);
|
||||
}
|
||||
|
||||
static gboolean gtk3_get_drawable_data(JNIEnv *env, jintArray pixelArray,
|
||||
int x, jint y, jint width, jint height, jint jwidth, int dx, int dy,
|
||||
jint scale) {
|
||||
GdkPixbuf *pixbuf;
|
||||
jint *ary;
|
||||
|
||||
int skip_left = 0;
|
||||
int skip_top = 0;
|
||||
GdkWindow *root = (*fp_gdk_get_default_root_window)();
|
||||
if (gtk3_version_3_10) {
|
||||
int win_scale = (*fp_gdk_window_get_scale_factor)(root);
|
||||
|
||||
// Scale the coordinate and size carefully such that the captured area
|
||||
// is at least as large as requested. We trim off excess later by
|
||||
// using the skip_* variables.
|
||||
const int x_scaled = scale_down_to_minus_inf(x, win_scale);
|
||||
const int y_scaled = scale_down_to_minus_inf(y, win_scale);
|
||||
skip_left = x - x_scaled*win_scale;
|
||||
skip_top = y - y_scaled*win_scale;
|
||||
DASSERT(skip_left >= 0 && skip_top >= 0);
|
||||
|
||||
const int x_right_scaled = scale_down_to_plus_inf(x + width, win_scale);
|
||||
const int width_scaled = x_right_scaled - x_scaled;
|
||||
DASSERT(width_scaled > 0);
|
||||
|
||||
const int y_bottom_scaled = scale_down_to_plus_inf(y + height, win_scale);
|
||||
const int height_scaled = y_bottom_scaled - y_scaled;
|
||||
DASSERT(height_scaled > 0);
|
||||
|
||||
pixbuf = (*fp_gdk_pixbuf_get_from_drawable)(
|
||||
root, x, y, (int) (width / (float) win_scale + 0.5), (int) (height / (float) win_scale + 0.5));
|
||||
root, x_scaled, y_scaled, width_scaled, height_scaled);
|
||||
} else {
|
||||
pixbuf = (*fp_gdk_pixbuf_get_from_drawable)(root, x, y, width, height);
|
||||
}
|
||||
@@ -2956,7 +2986,8 @@ static gboolean gtk3_get_drawable_data(JNIEnv *env, jintArray pixelArray,
|
||||
int index;
|
||||
for (_y = 0; _y < height; _y++) {
|
||||
for (_x = 0; _x < width; _x++) {
|
||||
p = pix + (intptr_t) _y * stride + _x * nchan;
|
||||
p = pix + (intptr_t) (_y + skip_top) * stride
|
||||
+ (_x + skip_left) * nchan;
|
||||
|
||||
index = (_y + dy) * jwidth + (_x + dx);
|
||||
ary[index] = 0xff000000
|
||||
|
||||
@@ -55,8 +55,11 @@ import java.awt.image.DataBufferInt;
|
||||
import java.awt.peer.WindowPeer;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import sun.awt.AWTAccessor;
|
||||
@@ -991,31 +994,29 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
|
||||
return err;
|
||||
}
|
||||
|
||||
private volatile List<Rectangle> customDecorHitTestSpots;
|
||||
private volatile int customDecorTitleBarHeight = -1; // 0 can be a legal value when no title bar is expected
|
||||
|
||||
// called from client via reflection
|
||||
@Deprecated
|
||||
private void setCustomDecorationHitTestSpots(List<Rectangle> hitTestSpots) {
|
||||
this.customDecorHitTestSpots = new CopyOnWriteArrayList<>(hitTestSpots);
|
||||
List<Map.Entry<Shape, Integer>> spots = new ArrayList<>();
|
||||
for (Rectangle spot : hitTestSpots) spots.add(Map.entry(spot, 1));
|
||||
try {
|
||||
Field f = Window.class.getDeclaredField("customDecorHitTestSpots");
|
||||
f.setAccessible(true);
|
||||
f.set(target, spots);
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
// called from client via reflection
|
||||
@Deprecated
|
||||
private void setCustomDecorationTitleBarHeight(int height) {
|
||||
if (height >= 0) customDecorTitleBarHeight = height;
|
||||
}
|
||||
|
||||
// called from native
|
||||
private boolean hitTestCustomDecoration(int x, int y) {
|
||||
List<Rectangle> spots = customDecorHitTestSpots;
|
||||
if (spots == null) return false;
|
||||
for (Rectangle spot : spots) {
|
||||
if (spot.contains(x, y)) return true;
|
||||
try {
|
||||
Field f = Window.class.getDeclaredField("customDecorTitleBarHeight");
|
||||
f.setAccessible(true);
|
||||
f.set(target, height);
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// called from native
|
||||
private int getCustomDecorationTitleBarHeight() {
|
||||
return customDecorTitleBarHeight;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1646,6 +1646,9 @@ LRESULT AwtComponent::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
||||
case WM_NCRBUTTONDOWN:
|
||||
mr = WmNcMouseDown(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), RIGHT_BUTTON);
|
||||
break;
|
||||
case WM_NCMOUSEMOVE:
|
||||
mr = WmNcMouseMove(wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam));
|
||||
break;
|
||||
case WM_LBUTTONUP:
|
||||
if (ignoreNextLBTNUP) {
|
||||
ignoreNextLBTNUP = FALSE;
|
||||
@@ -2330,6 +2333,9 @@ MsgRouting AwtComponent::WmNcMouseDown(WPARAM hitTest, int x, int y, int button)
|
||||
MsgRouting AwtComponent::WmNcMouseUp(WPARAM hitTest, int x, int y, int button) {
|
||||
return mrDoDefault;
|
||||
}
|
||||
MsgRouting AwtComponent::WmNcMouseMove(WPARAM hitTest, int x, int y) {
|
||||
return mrDoDefault;
|
||||
}
|
||||
|
||||
MsgRouting AwtComponent::WmWindowPosChanging(LPARAM windowPos) {
|
||||
return mrDoDefault;
|
||||
@@ -2784,9 +2790,12 @@ AwtComponent::GetJavaModifiers()
|
||||
if (HIBYTE(::GetKeyState(VK_MENU)) != 0) {
|
||||
modifiers |= java_awt_event_InputEvent_ALT_DOWN_MASK;
|
||||
}
|
||||
if (HIBYTE(::GetKeyState(VK_RMENU)) != 0) {
|
||||
modifiers |= java_awt_event_InputEvent_ALT_GRAPH_DOWN_MASK;
|
||||
}
|
||||
// Reverted fix of JDK-8041928: MouseEvent.getModifiersEx gives wrong result
|
||||
// Because it breaks AltGr shortcuts.
|
||||
// See IDEA-287559, JBR-4207 for more info.
|
||||
// if (HIBYTE(::GetKeyState(VK_RMENU)) != 0) {
|
||||
// modifiers |= java_awt_event_InputEvent_ALT_GRAPH_DOWN_MASK;
|
||||
// }
|
||||
if (HIBYTE(::GetKeyState(VK_MBUTTON)) != 0) {
|
||||
modifiers |= java_awt_event_InputEvent_BUTTON2_DOWN_MASK;
|
||||
}
|
||||
|
||||
@@ -525,6 +525,7 @@ public:
|
||||
int wheelRotation, BOOL isHorizontal);
|
||||
virtual MsgRouting WmNcMouseDown(WPARAM hitTest, int x, int y, int button);
|
||||
virtual MsgRouting WmNcMouseUp(WPARAM hitTest, int x, int y, int button);
|
||||
virtual MsgRouting WmNcMouseMove(WPARAM hitTest, int x, int y);
|
||||
virtual MsgRouting WmWindowPosChanging(LPARAM windowPos);
|
||||
virtual MsgRouting WmWindowPosChanged(LPARAM windowPos);
|
||||
virtual void WmTouch(WPARAM wParam, LPARAM lParam);
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <dwmapi.h>
|
||||
|
||||
#include <java_lang_Integer.h>
|
||||
#include <java_awt_Window_CustomWindowDecoration.h>
|
||||
#include <sun_awt_windows_WEmbeddedFrame.h>
|
||||
#include <sun_awt_windows_WEmbeddedFramePeer.h>
|
||||
|
||||
@@ -622,6 +623,23 @@ MsgRouting AwtFrame::WmNcMouseDown(WPARAM hitTest, int x, int y, int button) {
|
||||
if (m_grabbedWindow != NULL/* && !m_grabbedWindow->IsOneOfOwnersOf(this)*/) {
|
||||
m_grabbedWindow->Ungrab();
|
||||
}
|
||||
// For windows with custom decorations, handle caption-related mouse events
|
||||
// Do not handle events from caption itself to preserve native drag behavior
|
||||
if (HasCustomDecoration()) {
|
||||
switch (hitTest) {
|
||||
case HTMINBUTTON:
|
||||
case HTMAXBUTTON:
|
||||
case HTCLOSE:
|
||||
case HTMENU:
|
||||
RECT rcWindow;
|
||||
GetWindowRect(GetHWnd(), &rcWindow);
|
||||
WmMouseDown(GetButtonMK(button),
|
||||
x - rcWindow.left,
|
||||
y - rcWindow.top,
|
||||
button);
|
||||
return mrConsume;
|
||||
}
|
||||
}
|
||||
if (!IsFocusableWindow() && (button & LEFT_BUTTON)) {
|
||||
switch (hitTest) {
|
||||
case HTTOP:
|
||||
@@ -653,6 +671,24 @@ MsgRouting AwtFrame::WmNcMouseDown(WPARAM hitTest, int x, int y, int button) {
|
||||
return AwtWindow::WmNcMouseDown(hitTest, x, y, button);
|
||||
}
|
||||
|
||||
MsgRouting AwtFrame::WmNcMouseMove(WPARAM hitTest, int x, int y) {
|
||||
// For windows with custom decorations, handle caption-related mouse events
|
||||
if (HasCustomDecoration()) {
|
||||
switch (hitTest) {
|
||||
case HTMINBUTTON:
|
||||
case HTMAXBUTTON:
|
||||
case HTCLOSE:
|
||||
case HTMENU:
|
||||
case HTCAPTION:
|
||||
RECT rcWindow;
|
||||
GetWindowRect(GetHWnd(), &rcWindow);
|
||||
WmMouseMove(0, x - rcWindow.left, y - rcWindow.top);
|
||||
if (hitTest != HTCAPTION) return mrConsume; // Preserve default window drag for HTCAPTION
|
||||
}
|
||||
}
|
||||
return AwtWindow::WmNcMouseMove(hitTest, x, y);
|
||||
}
|
||||
|
||||
// Override AwtWindow::Reshape() to handle minimized/maximized
|
||||
// frames (see 6525850, 4065534)
|
||||
void AwtFrame::Reshape(int x, int y, int w, int h)
|
||||
@@ -1670,7 +1706,7 @@ BOOL AwtFrame::HasCustomDecoration()
|
||||
if (!m_pHasCustomDecoration) {
|
||||
m_pHasCustomDecoration = new BOOL;
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2);
|
||||
*m_pHasCustomDecoration = JNU_CallMethodByName(env, NULL, GetTarget(env), "hasCustomDecoration", "()Z").z;
|
||||
*m_pHasCustomDecoration = JNU_GetFieldByName(env, NULL, GetTarget(env), "hasCustomDecoration", "Z").z;
|
||||
}
|
||||
return *m_pHasCustomDecoration;
|
||||
}
|
||||
@@ -1712,10 +1748,8 @@ LRESULT HitTestNCA(AwtFrame* frame, int x, int y) {
|
||||
AdjustWindowRectEx(&rcFrame, WS_OVERLAPPEDWINDOW & ~WS_CAPTION, FALSE, NULL);
|
||||
|
||||
JNIEnv *env = (JNIEnv *) JNU_GetEnv(jvm, JNI_VERSION_1_2);
|
||||
int titleHeight = (int)JNU_CallMethodByName(env, NULL, frame->GetPeer(env),
|
||||
"getCustomDecorationTitleBarHeight", "()I",
|
||||
frame->ScaleDownX(x - rcWindow.left),
|
||||
frame->ScaleDownY(y - rcWindow.top)).i;
|
||||
int titleHeight = (int)JNU_GetFieldByName(env, NULL, frame->GetTarget(env),
|
||||
"customDecorTitleBarHeight", "I").i;
|
||||
if (titleHeight >= 0) {
|
||||
titleHeight = frame->ScaleUpY(titleHeight);
|
||||
insets.top = titleHeight; // otherwise leave default
|
||||
@@ -1728,12 +1762,23 @@ LRESULT HitTestNCA(AwtFrame* frame, int x, int y) {
|
||||
if (y >= rcWindow.top &&
|
||||
y < rcWindow.top + insets.top)
|
||||
{
|
||||
if (JNU_CallMethodByName(env, NULL, frame->GetPeer(env),
|
||||
"hitTestCustomDecoration", "(II)Z",
|
||||
frame->ScaleDownX(x - rcWindow.left),
|
||||
frame->ScaleDownY(y - rcWindow.top)).z)
|
||||
{
|
||||
return HTNOWHERE;
|
||||
jint customSpot = JNU_CallMethodByName(env, NULL, frame->GetTarget(env),
|
||||
"hitTestCustomDecoration", "(II)I",
|
||||
frame->ScaleDownX(x - rcWindow.left),
|
||||
frame->ScaleDownY(y - rcWindow.top)).i;
|
||||
switch (customSpot) {
|
||||
case java_awt_Window_CustomWindowDecoration_NO_HIT_SPOT:
|
||||
break; // Nothing
|
||||
case java_awt_Window_CustomWindowDecoration_MINIMIZE_BUTTON:
|
||||
return HTMINBUTTON;
|
||||
case java_awt_Window_CustomWindowDecoration_MAXIMIZE_BUTTON:
|
||||
return HTMAXBUTTON;
|
||||
case java_awt_Window_CustomWindowDecoration_CLOSE_BUTTON:
|
||||
return HTCLOSE;
|
||||
case java_awt_Window_CustomWindowDecoration_MENU_BAR:
|
||||
return HTMENU;
|
||||
default:
|
||||
return HTNOWHERE;
|
||||
}
|
||||
fOnResizeBorder = (y < (rcWindow.top - rcFrame.top));
|
||||
uRow = 0;
|
||||
|
||||
@@ -111,6 +111,7 @@ public:
|
||||
MsgRouting WmMouseMove(UINT flags, int x, int y);
|
||||
MsgRouting WmNcMouseDown(WPARAM hitTest, int x, int y, int button);
|
||||
MsgRouting WmNcMouseUp(WPARAM hitTest, int x, int y, int button);
|
||||
MsgRouting WmNcMouseMove(WPARAM hitTest, int x, int y);
|
||||
MsgRouting WmGetIcon(WPARAM iconType, LRESULT& retVal);
|
||||
MsgRouting WmShowWindow(BOOL show, UINT status);
|
||||
MsgRouting WmWindowPosChanging(LPARAM windowPos);
|
||||
|
||||
@@ -60,6 +60,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import jdk.internal.module.Checks;
|
||||
import jdk.internal.module.DefaultRoots;
|
||||
import jdk.internal.module.IllegalAccessMaps;
|
||||
import jdk.internal.module.Modules;
|
||||
import jdk.internal.module.ModuleHashes;
|
||||
import jdk.internal.module.ModuleInfo.Attributes;
|
||||
@@ -621,6 +622,9 @@ public final class SystemModulesPlugin extends AbstractPlugin {
|
||||
// generate moduleReads
|
||||
genModuleReads(cw, cf);
|
||||
|
||||
// generate concealedPackagesToOpen and exportedPackagesToOpen
|
||||
genXXXPackagesToOpenMethods(cw);
|
||||
|
||||
return cw;
|
||||
}
|
||||
|
||||
@@ -851,6 +855,16 @@ public final class SystemModulesPlugin extends AbstractPlugin {
|
||||
generate(cw, "moduleReads", map, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate concealedPackagesToOpen and exportedPackagesToOpen methods.
|
||||
*/
|
||||
private void genXXXPackagesToOpenMethods(ClassWriter cw) {
|
||||
ModuleFinder finder = finderOf(moduleInfos);
|
||||
IllegalAccessMaps maps = IllegalAccessMaps.generate(finder);
|
||||
generate(cw, "concealedPackagesToOpen", maps.concealedPackagesToOpen(), false);
|
||||
generate(cw, "exportedPackagesToOpen", maps.exportedPackagesToOpen(), false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate method to return {@code Map<String, Set<String>>}.
|
||||
*
|
||||
|
||||
117
src/jetbrains.api/src/com/jetbrains/CustomWindowDecoration.java
Normal file
117
src/jetbrains.api/src/com/jetbrains/CustomWindowDecoration.java
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright 2000-2021 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.jetbrains;
|
||||
|
||||
import java.awt.*;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public interface CustomWindowDecoration {
|
||||
|
||||
/*CONST java.awt.Window.*_HIT_SPOT*/
|
||||
/*CONST java.awt.Window.*_BUTTON*/
|
||||
/*CONST java.awt.Window.MENU_BAR*/
|
||||
|
||||
void setCustomDecorationEnabled(Window window, boolean enabled);
|
||||
boolean isCustomDecorationEnabled(Window window);
|
||||
|
||||
void setCustomDecorationHitTestSpots(Window window, List<Map.Entry<Shape, Integer>> spots);
|
||||
List<Map.Entry<Shape, Integer>> getCustomDecorationHitTestSpots(Window window);
|
||||
|
||||
void setCustomDecorationTitleBarHeight(Window window, int height);
|
||||
int getCustomDecorationTitleBarHeight(Window window);
|
||||
|
||||
|
||||
@SuppressWarnings("all")
|
||||
class __Fallback implements CustomWindowDecoration {
|
||||
|
||||
private final Method
|
||||
hasCustomDecoration,
|
||||
setHasCustomDecoration,
|
||||
setCustomDecorationHitTestSpots,
|
||||
setCustomDecorationTitleBarHeight;
|
||||
private final Field peer;
|
||||
|
||||
__Fallback() throws Exception {
|
||||
hasCustomDecoration = Window.class.getDeclaredMethod("hasCustomDecoration");
|
||||
hasCustomDecoration.setAccessible(true);
|
||||
setHasCustomDecoration = Window.class.getDeclaredMethod("setHasCustomDecoration");
|
||||
setHasCustomDecoration.setAccessible(true);
|
||||
Class<?> wpeer = Class.forName("sun.awt.windows.WWindowPeer");
|
||||
setCustomDecorationHitTestSpots = wpeer.getDeclaredMethod("setCustomDecorationHitTestSpots", List.class);
|
||||
setCustomDecorationHitTestSpots.setAccessible(true);
|
||||
setCustomDecorationTitleBarHeight = wpeer.getDeclaredMethod("setCustomDecorationTitleBarHeight", int.class);
|
||||
setCustomDecorationTitleBarHeight.setAccessible(true);
|
||||
peer = Component.class.getDeclaredField("peer");
|
||||
peer.setAccessible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomDecorationEnabled(Window window, boolean enabled) {
|
||||
if (enabled) {
|
||||
try {
|
||||
setHasCustomDecoration.invoke(window);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCustomDecorationEnabled(Window window) {
|
||||
try {
|
||||
return (boolean) hasCustomDecoration.invoke(window);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomDecorationHitTestSpots(Window window, List<Map.Entry<Shape, Integer>> spots) {
|
||||
List<Rectangle> hitTestSpots = spots.stream().map(e -> e.getKey().getBounds()).collect(Collectors.toList());
|
||||
try {
|
||||
setCustomDecorationHitTestSpots.invoke(peer.get(window), hitTestSpots);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map.Entry<Shape, Integer>> getCustomDecorationHitTestSpots(Window window) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomDecorationTitleBarHeight(Window window, int height) {
|
||||
try {
|
||||
setCustomDecorationTitleBarHeight.invoke(peer.get(window), height);
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCustomDecorationTitleBarHeight(Window window) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,6 +66,15 @@ public class JBR {
|
||||
|
||||
private JBR() {}
|
||||
|
||||
private static <T> T getService(Class<T> interFace, FallbackSupplier<T> fallback) {
|
||||
T service = getService(interFace);
|
||||
try {
|
||||
return service != null ? service : fallback != null ? fallback.get() : null;
|
||||
} catch (Throwable ignore) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static <T> T getService(Class<T> interFace) {
|
||||
return api == null ? null : api.getService(interFace);
|
||||
}
|
||||
@@ -94,6 +103,11 @@ public class JBR {
|
||||
<T> T getService(Class<T> interFace);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
private interface FallbackSupplier<T> {
|
||||
T get() throws Throwable;
|
||||
}
|
||||
|
||||
// ========================== Generated metadata ==========================
|
||||
|
||||
/**
|
||||
|
||||
@@ -92,7 +92,7 @@ public class Gensrc {
|
||||
}
|
||||
|
||||
private static String generate(String content) throws IOException {
|
||||
Pattern pattern = compile("/\\*CONST ((?:[a-zA-Z0-9]+\\.)+)([a-zA-Z0-9_*]+)\s*\\*/");
|
||||
Pattern pattern = compile("/\\*CONST ((?:[a-zA-Z0-9]+\\.)+)([a-zA-Z0-9_*]+)\\s*\\*/");
|
||||
for (;;) {
|
||||
Matcher matcher = pattern.matcher(content);
|
||||
if (!matcher.find()) return content;
|
||||
@@ -102,15 +102,23 @@ public class Gensrc {
|
||||
for (Path module : modules.paths) {
|
||||
Path f = module.resolve("share/classes").resolve(file);
|
||||
if (Files.exists(f)) {
|
||||
Pattern namePattern = compile(name.replaceAll("\\*", "[a-zA-Z0-9_]+") + "\s*=");
|
||||
Pattern statementPattern = compile("((?:(?:public|protected|private|static|final)\s+){2,3})([a-zA-Z0-9]+)\s+([^;]+);");
|
||||
Pattern namePattern = compile(name.replaceAll("\\*", "\\\\w+"));
|
||||
Pattern statementPattern = compile(
|
||||
"((?:(?:MODS) ){2,3})([a-zA-Z0-9]+) (FIELD(?:, FIELD)*);"
|
||||
.replaceAll("MODS", "public|protected|private|static|final")
|
||||
.replaceAll("FIELD", "\\\\w+ = [\\\\w\"']+ ")
|
||||
.replaceAll(" ", "\\\\s+")
|
||||
.replaceAll(" ", "\\\\s*")
|
||||
);
|
||||
Matcher statementMatcher = statementPattern.matcher(Files.readString(f));
|
||||
while (statementMatcher.find()) {
|
||||
String mods = statementMatcher.group(1);
|
||||
if (!mods.contains("static") || !mods.contains("final")) continue;
|
||||
for (String s : statementMatcher.group(3).split(",")) {
|
||||
if (!namePattern.matcher(s).find()) continue;
|
||||
statements.add("public static final " + statementMatcher.group(2) + " " + s.strip() + ";");
|
||||
s = s.strip();
|
||||
String nm = s.substring(0, s.indexOf('=')).strip();
|
||||
if (!namePattern.matcher(nm).matches()) continue;
|
||||
statements.add("public static final " + statementMatcher.group(2) + " " + s + ";");
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -164,7 +172,7 @@ public class Gensrc {
|
||||
}
|
||||
|
||||
private static Service[] findPublicServiceInterfaces() {
|
||||
Pattern javadocPattern = Pattern.compile("/\\*\\*((?:.|\n)*?)(\s|\n)*\\*/");
|
||||
Pattern javadocPattern = Pattern.compile("/\\*\\*((?:.|\n)*?)\\s*\\*/");
|
||||
return modules.services.stream()
|
||||
.map(fullName -> {
|
||||
if (fullName.indexOf('$') != -1) return null; // Only top level services can be public
|
||||
@@ -186,7 +194,8 @@ public class Gensrc {
|
||||
javadocEnd = 0;
|
||||
}
|
||||
return new Service(name, javadoc,
|
||||
content.substring(javadocEnd, indexOfDeclaration).contains("@Deprecated"));
|
||||
content.substring(javadocEnd, indexOfDeclaration).contains("@Deprecated"),
|
||||
content.contains("__Fallback"));
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(e);
|
||||
}
|
||||
@@ -197,7 +206,7 @@ public class Gensrc {
|
||||
private static String generateMethodsForService(Service service) {
|
||||
return """
|
||||
private static class $__Holder {<DEPRECATED>
|
||||
private static final $ INSTANCE = api != null ? api.getService($.class) : null;
|
||||
private static final $ INSTANCE = getService($.class, <FALLBACK>);
|
||||
}
|
||||
/**
|
||||
* @return true if current runtime has implementation for all methods in {@link $}
|
||||
@@ -214,12 +223,13 @@ public class Gensrc {
|
||||
return $__Holder.INSTANCE;
|
||||
}
|
||||
"""
|
||||
.replace("<FALLBACK>", service.hasFallback ? "$.__Fallback::new" : "null")
|
||||
.replaceAll("\\$", service.name)
|
||||
.replace("<JAVADOC>", service.javadoc)
|
||||
.replaceAll("<DEPRECATED>", service.deprecated ? "\n@Deprecated" : "");
|
||||
}
|
||||
|
||||
private record Service(String name, String javadoc, boolean deprecated) {}
|
||||
private record Service(String name, String javadoc, boolean deprecated, boolean hasFallback) {}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -240,7 +250,7 @@ public class Gensrc {
|
||||
}
|
||||
|
||||
private void findInModule(String content) {
|
||||
Pattern servicePattern = compile("(service|proxy|twoWayProxy)\s*\\(([^)]+)");
|
||||
Pattern servicePattern = compile("(service|proxy|twoWayProxy)\\s*\\(([^)]+)");
|
||||
Matcher matcher = servicePattern.matcher(content);
|
||||
while (matcher.find()) {
|
||||
String type = matcher.group(1);
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
# 2. When only new API is added, or some existing API was @Deprecated - increment MINOR, reset PATCH to 0
|
||||
# 3. For major backwards incompatible API changes - increment MAJOR, reset MINOR and PATCH to 0
|
||||
|
||||
VERSION = 0.0.2
|
||||
VERSION = 0.0.4
|
||||
|
||||
# Hash is used to track changes to jetbrains.api, so you would not forget to update version when needed.
|
||||
# When you make any changes, "make jbr-api" will fail and ask you to update hash and version number here.
|
||||
|
||||
HASH = 814F29888E5EB6C23DF27B53636E9F94
|
||||
HASH = 74417FA361EA554F9C90873A3FF354
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Red Hat, Inc. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @bug 8275330
|
||||
* @summary C2: assert(n->is_Root() || n->is_Region() || n->is_Phi() || n->is_MachMerge() || def_block->dominates(block)) failed: uses must be dominated by definitions
|
||||
*
|
||||
* @run main/othervm -Xmx512m -XX:+UnlockDiagnosticVMOptions -Xcomp -XX:CompileOnly=TestDeadPostLoopBecausePredicate TestDeadPostLoopBecausePredicate
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
public class TestDeadPostLoopBecausePredicate {
|
||||
|
||||
public static final int N = 400;
|
||||
|
||||
public static int iFld=54270;
|
||||
public static int iFld1=-4;
|
||||
public int iFld2=201;
|
||||
|
||||
public int mainTest(String[] strArr1) {
|
||||
|
||||
int i=0, i17=8052, i19=22380, i20=60894, iArr[]=new int[N];
|
||||
init(iArr, 4);
|
||||
|
||||
i = 1;
|
||||
do {
|
||||
for (i17 = 5; i17 < 114; i17++) {
|
||||
switch ((i17 % 7) + 126) {
|
||||
case 126:
|
||||
for (i19 = 2; i19 > i; i19 -= 3) {
|
||||
try {
|
||||
i20 = (iFld2 % TestDeadPostLoopBecausePredicate.iFld1);
|
||||
i20 = (iArr[i19 - 1] % TestDeadPostLoopBecausePredicate.iFld);
|
||||
TestDeadPostLoopBecausePredicate.iFld = (TestDeadPostLoopBecausePredicate.iFld1 % iArr[i19]);
|
||||
} catch (ArithmeticException a_e) {}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (++i < 220);
|
||||
|
||||
return i20;
|
||||
}
|
||||
|
||||
public static void init(int[] a, int seed) {
|
||||
for (int j = 0; j < a.length; j++) {
|
||||
a[j] = (j % 2 == 0) ? seed + j : seed - j;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] strArr) {
|
||||
TestDeadPostLoopBecausePredicate _instance = new TestDeadPostLoopBecausePredicate();
|
||||
for (int i = 0; i < 10; i++ ) {
|
||||
_instance.mainTest(strArr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Red Hat, Inc. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* bug 8280799
|
||||
* @summary С2: assert(false) failed: cyclic dependency prevents range check elimination
|
||||
* @run main/othervm -XX:-BackgroundCompilation -XX:-UseCountedLoopSafepoints TestPredicateInputBelowLoopPredicate
|
||||
*/
|
||||
|
||||
public class TestPredicateInputBelowLoopPredicate {
|
||||
private static final Object object = new Object();
|
||||
private static int fieldStop = 100;
|
||||
private static int[] array = new int[200];
|
||||
private static int[] array2 = new int[200];
|
||||
private static int fieldStart = 0;
|
||||
|
||||
public static void main(String[] args) {
|
||||
for (int i = 0; i < 20_000; i++) {
|
||||
test(true);
|
||||
test(false);
|
||||
}
|
||||
}
|
||||
|
||||
private static void test(boolean flag) {
|
||||
if (array == null) {
|
||||
}
|
||||
int start = fieldStart;
|
||||
int i = start;
|
||||
for(;;) {
|
||||
int j;
|
||||
for (j = -10; j < 0; j++) {
|
||||
}
|
||||
int stop = fieldStop;
|
||||
// bound check becomes candidate for predication once
|
||||
// loop above is optimized out
|
||||
array[stop - i + j] = 0;
|
||||
|
||||
// A bunch of stuff to grow loop body size and prevent peeling:
|
||||
array2[0] = 0;
|
||||
array2[1] = 0;
|
||||
array2[2] = 0;
|
||||
array2[3] = 0;
|
||||
array2[4] = 0;
|
||||
array2[5] = 0;
|
||||
array2[6] = 0;
|
||||
array2[7] = 0;
|
||||
array2[8] = 0;
|
||||
array2[9] = 0;
|
||||
array2[10] = 0;
|
||||
array2[11] = 0;
|
||||
array2[12] = 0;
|
||||
array2[13] = 0;
|
||||
array2[14] = 0;
|
||||
array2[15] = 0;
|
||||
array2[16] = 0;
|
||||
array2[17] = 0;
|
||||
array2[18] = 0;
|
||||
array2[19] = 0;
|
||||
array2[20] = 0;
|
||||
array2[21] = 0;
|
||||
array2[22] = 0;
|
||||
array2[23] = 0;
|
||||
array2[24] = 0;
|
||||
array2[25] = 0;
|
||||
array2[26] = 0;
|
||||
array2[27] = 0;
|
||||
array2[28] = 0;
|
||||
array2[29] = 0;
|
||||
array2[30] = 0;
|
||||
array2[31] = 0;
|
||||
array2[32] = 0;
|
||||
array2[33] = 0;
|
||||
array2[34] = 0;
|
||||
array2[35] = 0;
|
||||
array2[36] = 0;
|
||||
array2[37] = 0;
|
||||
array2[38] = 0;
|
||||
array2[39] = 0;
|
||||
array2[40] = 0;
|
||||
array2[41] = 0;
|
||||
array2[42] = 0;
|
||||
array2[43] = 0;
|
||||
array2[44] = 0;
|
||||
array2[45] = 0;
|
||||
array2[46] = 0;
|
||||
array2[47] = 0;
|
||||
array2[48] = 0;
|
||||
array2[49] = 0;
|
||||
array2[50] = 0;
|
||||
array2[51] = 0;
|
||||
array2[52] = 0;
|
||||
array2[53] = 0;
|
||||
array2[54] = 0;
|
||||
array2[55] = 0;
|
||||
array2[56] = 0;
|
||||
array2[57] = 0;
|
||||
array2[58] = 0;
|
||||
array2[59] = 0;
|
||||
array2[60] = 0;
|
||||
array2[61] = 0;
|
||||
array2[62] = 0;
|
||||
array2[63] = 0;
|
||||
array2[64] = 0;
|
||||
array2[65] = 0;
|
||||
array2[66] = 0;
|
||||
array2[67] = 0;
|
||||
array2[68] = 0;
|
||||
array2[69] = 0;
|
||||
array2[70] = 0;
|
||||
array2[71] = 0;
|
||||
array2[72] = 0;
|
||||
array2[73] = 0;
|
||||
array2[74] = 0;
|
||||
array2[75] = 0;
|
||||
array2[76] = 0;
|
||||
array2[77] = 0;
|
||||
array2[78] = 0;
|
||||
array2[79] = 0;
|
||||
array2[80] = 0;
|
||||
array2[81] = 0;
|
||||
array2[82] = 0;
|
||||
array2[83] = 0;
|
||||
array2[84] = 0;
|
||||
array2[85] = 0;
|
||||
array2[86] = 0;
|
||||
array2[87] = 0;
|
||||
array2[88] = 0;
|
||||
array2[89] = 0;
|
||||
array2[90] = 0;
|
||||
array2[91] = 0;
|
||||
array2[92] = 0;
|
||||
array2[93] = 0;
|
||||
array2[94] = 0;
|
||||
array2[95] = 0;
|
||||
array2[96] = 0;
|
||||
array2[97] = 0;
|
||||
array2[98] = 0;
|
||||
array2[99] = 0;
|
||||
|
||||
array2[100] = 0;
|
||||
array2[101] = 0;
|
||||
array2[102] = 0;
|
||||
array2[103] = 0;
|
||||
array2[104] = 0;
|
||||
array2[105] = 0;
|
||||
array2[106] = 0;
|
||||
array2[107] = 0;
|
||||
array2[108] = 0;
|
||||
array2[109] = 0;
|
||||
array2[110] = 0;
|
||||
array2[111] = 0;
|
||||
array2[112] = 0;
|
||||
array2[113] = 0;
|
||||
array2[114] = 0;
|
||||
array2[115] = 0;
|
||||
array2[116] = 0;
|
||||
array2[117] = 0;
|
||||
array2[118] = 0;
|
||||
array2[119] = 0;
|
||||
array2[120] = 0;
|
||||
array2[121] = 0;
|
||||
array2[122] = 0;
|
||||
array2[123] = 0;
|
||||
array2[124] = 0;
|
||||
array2[125] = 0;
|
||||
array2[126] = 0;
|
||||
array2[127] = 0;
|
||||
array2[128] = 0;
|
||||
array2[129] = 0;
|
||||
array2[130] = 0;
|
||||
array2[131] = 0;
|
||||
array2[132] = 0;
|
||||
array2[133] = 0;
|
||||
array2[134] = 0;
|
||||
array2[135] = 0;
|
||||
array2[136] = 0;
|
||||
array2[137] = 0;
|
||||
array2[138] = 0;
|
||||
array2[139] = 0;
|
||||
array2[140] = 0;
|
||||
array2[141] = 0;
|
||||
array2[142] = 0;
|
||||
array2[143] = 0;
|
||||
array2[144] = 0;
|
||||
array2[145] = 0;
|
||||
array2[146] = 0;
|
||||
array2[147] = 0;
|
||||
array2[148] = 0;
|
||||
array2[149] = 0;
|
||||
array2[150] = 0;
|
||||
array2[151] = 0;
|
||||
array2[152] = 0;
|
||||
array2[153] = 0;
|
||||
array2[154] = 0;
|
||||
array2[155] = 0;
|
||||
array2[156] = 0;
|
||||
array2[157] = 0;
|
||||
array2[158] = 0;
|
||||
array2[159] = 0;
|
||||
array2[160] = 0;
|
||||
array2[161] = 0;
|
||||
array2[162] = 0;
|
||||
array2[163] = 0;
|
||||
array2[164] = 0;
|
||||
array2[165] = 0;
|
||||
array2[166] = 0;
|
||||
array2[167] = 0;
|
||||
array2[168] = 0;
|
||||
array2[169] = 0;
|
||||
array2[170] = 0;
|
||||
array2[171] = 0;
|
||||
array2[172] = 0;
|
||||
array2[173] = 0;
|
||||
array2[174] = 0;
|
||||
array2[175] = 0;
|
||||
array2[176] = 0;
|
||||
array2[177] = 0;
|
||||
array2[178] = 0;
|
||||
array2[179] = 0;
|
||||
array2[180] = 0;
|
||||
array2[181] = 0;
|
||||
array2[182] = 0;
|
||||
array2[183] = 0;
|
||||
array2[184] = 0;
|
||||
array2[185] = 0;
|
||||
array2[186] = 0;
|
||||
array2[187] = 0;
|
||||
array2[188] = 0;
|
||||
array2[189] = 0;
|
||||
array2[190] = 0;
|
||||
array2[191] = 0;
|
||||
array2[192] = 0;
|
||||
array2[193] = 0;
|
||||
array2[194] = 0;
|
||||
array2[195] = 0;
|
||||
array2[196] = 0;
|
||||
array2[197] = 0;
|
||||
array2[198] = 0;
|
||||
array2[199] = 0;
|
||||
i++;
|
||||
|
||||
if (i == stop) { // requires a loop limit predicate
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@@ -109,6 +109,7 @@ public class LambdaEagerInit {
|
||||
static void testDefaultArchiveWithEagerInitializationEnabled() throws Exception {
|
||||
// run with default CDS archive with the -Djdk.internal.lambda.disableEagerInitialization=true property
|
||||
CDSOptions runOpts = (new CDSOptions())
|
||||
.setXShareMode("auto")
|
||||
.addPrefix("-cp", appJar, testProperty, "-Xlog:class+load,cds=debug")
|
||||
.setUseSystemArchive(true)
|
||||
.setUseVersion(false)
|
||||
@@ -122,13 +123,16 @@ public class LambdaEagerInit {
|
||||
static void testDefaultArchiveWithEagerInitializationDisabled() throws Exception {
|
||||
// run with default CDS archive without the -Djdk.internal.lambda.disableEagerInitialization=true property
|
||||
CDSOptions runOpts = (new CDSOptions())
|
||||
.setXShareMode("auto")
|
||||
.addPrefix("-cp", appJar, "-Xlog:class+load,cds=debug")
|
||||
.setUseSystemArchive(true)
|
||||
.setUseVersion(false)
|
||||
.addSuffix(mainClass);
|
||||
.addSuffix("-showversion", mainClass);
|
||||
OutputAnalyzer output = CDSTestUtils.runWithArchive(runOpts);
|
||||
output.shouldMatch(lambdaLoadedFromArchive)
|
||||
.shouldMatch(cdsLoadedLambdaProxy)
|
||||
.shouldHaveExitValue(0);
|
||||
if (output.getStderr().contains("sharing")) {
|
||||
output.shouldMatch(lambdaLoadedFromArchive)
|
||||
.shouldMatch(cdsLoadedLambdaProxy);
|
||||
}
|
||||
output.shouldHaveExitValue(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,13 +25,17 @@ import java.awt.Dimension;
|
||||
import java.awt.DisplayMode;
|
||||
import java.awt.GraphicsDevice;
|
||||
import java.awt.GraphicsEnvironment;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.MemoryMXBean;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.nio.file.Path;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.WindowConstants;
|
||||
import jdk.jfr.Recording;
|
||||
import java.io.IOException;
|
||||
import jdk.jfr.consumer.RecordedEvent;
|
||||
import jdk.jfr.consumer.RecordedFrame;
|
||||
import jdk.jfr.consumer.RecordingFile;
|
||||
|
||||
/*
|
||||
* @test
|
||||
@@ -39,20 +43,21 @@ import javax.swing.WindowConstants;
|
||||
*
|
||||
* @summary Test verifies that there is no extra allocation after display mode switch
|
||||
*
|
||||
* @run main/othervm -Xmx750M ExtraAllocationTest
|
||||
* @run main/othervm -Xmx750M ExtraAllocationTest
|
||||
*/
|
||||
|
||||
|
||||
public class ExtraAllocationTest {
|
||||
private static final int MAX_MODES = 10;
|
||||
private static final int W = 500;
|
||||
private static final int H = 500;
|
||||
static JFrame f = null;
|
||||
|
||||
public static void main(String[] args) throws InterruptedException, InvocationTargetException {
|
||||
MemoryMXBean memBean = ManagementFactory.getMemoryMXBean();
|
||||
memBean.gc();
|
||||
Thread.sleep(2000);
|
||||
static long th = ((long) W * H * 32) / (8 * 2);
|
||||
public static void main(String[] args) throws InterruptedException, InvocationTargetException,
|
||||
IOException
|
||||
{
|
||||
Recording recording = new Recording();
|
||||
recording.enable("jdk.ObjectAllocationOutsideTLAB");
|
||||
recording.start();
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
f = new JFrame();
|
||||
f.add(new JPanel());
|
||||
@@ -66,35 +71,38 @@ public class ExtraAllocationTest {
|
||||
GraphicsDevice d = ge.getDefaultScreenDevice();
|
||||
|
||||
if (d.isDisplayChangeSupported()) {
|
||||
DisplayMode odm = d.getDisplayMode();
|
||||
DisplayMode[] modes = d.getDisplayModes();
|
||||
try {
|
||||
int modesCount = Math.min(modes.length, MAX_MODES);
|
||||
int modesCount = Math.min(modes.length, MAX_MODES);
|
||||
|
||||
for (int i = 0; i < modesCount; i++) {
|
||||
DisplayMode mode = modes[i];
|
||||
int w = mode.getWidth();
|
||||
int h = mode.getHeight();
|
||||
int bpp = mode.getBitDepth();
|
||||
long th = ((long) W * H * bpp) / (8 * 2);
|
||||
DisplayMode newMode =
|
||||
new DisplayMode(w, h, bpp, DisplayMode.REFRESH_RATE_UNKNOWN);
|
||||
long usedHeap = memBean.getHeapMemoryUsage().getUsed();
|
||||
d.setDisplayMode(newMode);
|
||||
Thread.sleep(2000);
|
||||
long memDiff = memBean.getHeapMemoryUsage().getUsed() - usedHeap;
|
||||
if (memDiff > th) {
|
||||
throw new RuntimeException("Extra allocation detected: " + memDiff);
|
||||
}
|
||||
ManagementFactory.getMemoryMXBean().gc();
|
||||
Thread.sleep(2000);
|
||||
for (int i = 0; i < modesCount; i++) {
|
||||
DisplayMode mode = modes[i];
|
||||
try {
|
||||
d.setDisplayMode(mode);
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} finally {
|
||||
d.setDisplayMode(odm);
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
}
|
||||
f.setVisible(false);
|
||||
f.dispose();
|
||||
Thread.sleep(1000);
|
||||
Path path = Path.of("recording.jfr");
|
||||
recording.dump(path);
|
||||
recording.close();
|
||||
for (RecordedEvent event : RecordingFile.readAllEvents(path)) {
|
||||
if ("jdk.ObjectAllocationOutsideTLAB".equalsIgnoreCase(event.getEventType().getName())) {
|
||||
for (RecordedFrame recordedFrame :event.getStackTrace().getFrames()) {
|
||||
if (recordedFrame.isJavaFrame() &&
|
||||
"java.awt.image.DataBufferInt".equals(
|
||||
recordedFrame.getMethod().getType().getName()) &&
|
||||
event.getLong("allocationSize") > th)
|
||||
{
|
||||
throw new RuntimeException("Extra allocation detected: " +
|
||||
event.getLong("allocationSize"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,20 +27,29 @@ import java.awt.Color;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Panel;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Robot;
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.swing.UIManager;
|
||||
import javax.imageio.ImageIO;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 8073320
|
||||
* @bug 8073320 8280861
|
||||
* @summary Windows HiDPI support
|
||||
* @author Alexander Scherbatiy
|
||||
* @requires (os.family == "linux" | os.family == "windows")
|
||||
* @requires !display.XWayland
|
||||
* @run main/othervm -Dsun.java2d.win.uiScaleX=3 -Dsun.java2d.win.uiScaleY=2
|
||||
* HiDPIRobotScreenCaptureTest
|
||||
* @run main/othervm -Dsun.java2d.uiScale=1
|
||||
* HiDPIRobotScreenCaptureTest
|
||||
* @run main/othervm -Dsun.java2d.uiScale=2
|
||||
* HiDPIRobotScreenCaptureTest
|
||||
*/
|
||||
|
||||
public class HiDPIRobotScreenCaptureTest {
|
||||
@@ -60,7 +69,14 @@ public class HiDPIRobotScreenCaptureTest {
|
||||
}
|
||||
|
||||
Frame frame = new Frame();
|
||||
frame.setBounds(40, 30, 400, 300);
|
||||
// Position the frame on prime number coordinates to avoid
|
||||
// them being multiple of the desktop scale; this tests Linux
|
||||
// color picker better.
|
||||
// Also, the position should be far enough from the top left
|
||||
// corner of the screen to reduce the chance of being repositioned
|
||||
// by the system because that area's occupied by the global
|
||||
// menu bar and such.
|
||||
frame.setBounds(83, 97, 400, 300);
|
||||
frame.setUndecorated(true);
|
||||
|
||||
Panel panel = new Panel(new BorderLayout());
|
||||
@@ -78,6 +94,13 @@ public class HiDPIRobotScreenCaptureTest {
|
||||
g.fillRect(0, h / 2, w / 2, h / 2);
|
||||
g.setColor(COLORS[3]);
|
||||
g.fillRect(w / 2, h / 2, w / 2, h / 2);
|
||||
|
||||
// Several distinct pixels next to one another
|
||||
// in order to test color picker's precision.
|
||||
for (int i = 1; i < 4; i++) {
|
||||
g.setColor(COLORS[i]);
|
||||
g.fillRect(i, 0, 1, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -86,11 +109,15 @@ public class HiDPIRobotScreenCaptureTest {
|
||||
frame.setVisible(true);
|
||||
Robot robot = new Robot();
|
||||
robot.waitForIdle();
|
||||
Thread.sleep(200);
|
||||
robot.delay(500);
|
||||
|
||||
final Point screenLocation = frame.getLocationOnScreen();
|
||||
checkPixelColors(robot, screenLocation.x, screenLocation.y);
|
||||
|
||||
Rectangle rect = canvas.getBounds();
|
||||
rect.setLocation(canvas.getLocationOnScreen());
|
||||
|
||||
System.out.println("Creating screen capture of " + rect);
|
||||
BufferedImage image = robot.createScreenCapture(rect);
|
||||
frame.dispose();
|
||||
|
||||
@@ -101,20 +128,53 @@ public class HiDPIRobotScreenCaptureTest {
|
||||
throw new RuntimeException("Wrong image size!");
|
||||
}
|
||||
|
||||
if (image.getRGB(w / 4, h / 4) != COLORS[0].getRGB()) {
|
||||
throw new RuntimeException("Wrong image color!");
|
||||
}
|
||||
|
||||
if (image.getRGB(3 * w / 4, h / 4) != COLORS[1].getRGB()) {
|
||||
throw new RuntimeException("Wrong image color!");
|
||||
}
|
||||
checkRectColor(image, new Rectangle(0, 0, w / 2, h / 2), COLORS[0]);
|
||||
checkRectColor(image, new Rectangle(w / 2, 0, w / 2, h / 2), COLORS[1]);
|
||||
checkRectColor(image, new Rectangle(0, h / 2, w / 2, h / 2), COLORS[2]);
|
||||
checkRectColor(image, new Rectangle(w / 2, h / 2, w / 2, h / 2), COLORS[3]);
|
||||
}
|
||||
|
||||
if (image.getRGB(w / 4, 3 * h / 4) != COLORS[2].getRGB()) {
|
||||
throw new RuntimeException("Wrong image color!");
|
||||
}
|
||||
static void checkPixelColors(Robot robot, int x, int y) {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
final Color actualColor = robot.getPixelColor(x + i, y);
|
||||
System.out.print("Checking color at " + (x + i) + ", " + y + " to be equal to " + COLORS[i]);
|
||||
if (!actualColor.equals(COLORS[i])) {
|
||||
System.out.println("... Mismatch: found " + actualColor + " instead");
|
||||
throw new RuntimeException("Wrong screen pixel color");
|
||||
|
||||
if (image.getRGB(3 * w / 4, 3 * h / 4) != COLORS[3].getRGB()) {
|
||||
throw new RuntimeException("Wrong image color!");
|
||||
} else {
|
||||
System.out.println("... OK");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static final int OFFSET = 5;
|
||||
static void checkRectColor(BufferedImage image, Rectangle rect, Color expectedColor) {
|
||||
System.out.println("Checking rectangle " + rect + " to have color " + expectedColor);
|
||||
final Point[] pointsToCheck = new Point[] {
|
||||
new Point(rect.x + OFFSET, rect.y + OFFSET), // top left corner
|
||||
new Point(rect.x + rect.width - OFFSET, rect.y + OFFSET), // top right corner
|
||||
new Point(rect.x + rect.width / 2, rect.y + rect.height / 2), // center
|
||||
new Point(rect.x + OFFSET, rect.y + rect.height - OFFSET), // bottom left corner
|
||||
new Point(rect.x + rect.width - OFFSET, rect.y + rect.height - OFFSET) // bottom right corner
|
||||
};
|
||||
|
||||
for (final var point : pointsToCheck) {
|
||||
System.out.print("Checking color at " + point + " to be equal to " + expectedColor);
|
||||
final int actualColor = image.getRGB(point.x, point.y);
|
||||
if (actualColor != expectedColor.getRGB()) {
|
||||
System.out.println("... Mismatch: found " + new Color(actualColor) + " instead. Check image.png.");
|
||||
try {
|
||||
ImageIO.write(image, "png", new File("image.png"));
|
||||
} catch(IOException e) {
|
||||
System.out.println("failed to save image.png.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
throw new RuntimeException("Wrong image color!");
|
||||
} else {
|
||||
System.out.println("... OK");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,8 @@
|
||||
/*
|
||||
* @test
|
||||
* @key headful
|
||||
* @bug 8162959
|
||||
* @bug 8162959 8280861
|
||||
* @requires !display.XWayland
|
||||
* @summary Validate output of createMultiResolutionScreenCapture
|
||||
* new API which returns MultiResolutionImage.
|
||||
* @run main/othervm -Dsun.java2d.uiScale=1 ScreenCaptureTest
|
||||
@@ -44,6 +45,7 @@ import java.awt.Color;
|
||||
import java.awt.Frame;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Panel;
|
||||
import java.awt.Point;
|
||||
import java.awt.Robot;
|
||||
import java.util.List;
|
||||
|
||||
@@ -58,7 +60,14 @@ public class ScreenCaptureTest {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
frame = new Frame();
|
||||
frame.setBounds(0, 0, 400, 400);
|
||||
// Position the frame on prime number coordinates to avoid
|
||||
// them being multiple of the desktop scale; this tests Linux
|
||||
// color picker better.
|
||||
// Also, the position should be far enough from the top left
|
||||
// corner of the screen to reduce the chance of being repositioned
|
||||
// by the system because that area's occupied by the global
|
||||
// menu bar and such.
|
||||
frame.setBounds(83, 97, 400, 400);
|
||||
frame.setUndecorated(true);
|
||||
robot = new Robot();
|
||||
Panel panel = new Panel(new BorderLayout());
|
||||
@@ -87,97 +96,112 @@ public class ScreenCaptureTest {
|
||||
int w = frame.getWidth();
|
||||
int h = frame.getHeight();
|
||||
|
||||
// getPixelColor Test
|
||||
// Check pixel color in first quardant GREEN; x=100, y=100
|
||||
if (!robot.getPixelColor(w / 4, h / 4).equals(COLORS[0])) {
|
||||
throw new RuntimeException("Wrong Pixel Color! Expected GREEN");
|
||||
}
|
||||
// Check pixel color in second quardant; BLUE, x=300, y=100
|
||||
if (!robot.getPixelColor(3 * w / 4, h / 4).equals(COLORS[1])) {
|
||||
throw new RuntimeException("Wrong Pixel Color! Expected BLUE");
|
||||
}
|
||||
// Check pixel color in third quardant; ORANGE, x=100, y=300
|
||||
if (!robot.getPixelColor(w / 4, 3 * h / 4).equals(COLORS[2])) {
|
||||
throw new RuntimeException("Wrong Pixel Color! Expected ORANGE");
|
||||
}
|
||||
// Check pixel color in fourth quardant; RED, x=300, y=300
|
||||
if (!robot.getPixelColor(3 * w / 4, 3 * h / 4).equals(COLORS[3])) {
|
||||
throw new RuntimeException("Wrong Pixel Color! Expected RED");
|
||||
}
|
||||
final Point screenLocation = frame.getLocationOnScreen();
|
||||
final int x = screenLocation.x;
|
||||
final int y = screenLocation.y;
|
||||
try {
|
||||
// getPixelColor() tests
|
||||
checkRectColor(new Rectangle(x, y, w / 2, h / 2), COLORS[0]);
|
||||
checkRectColor(new Rectangle(x + w / 2, y, w / 2, h / 2), COLORS[1]);
|
||||
checkRectColor(new Rectangle(x, y + h / 2, w / 2, h / 2), COLORS[2]);
|
||||
checkRectColor(new Rectangle(x + w / 2, y + h / 2, w / 2, h / 2), COLORS[3]);
|
||||
|
||||
// createScreenCaptureTest
|
||||
AffineTransform tx = GraphicsEnvironment.getLocalGraphicsEnvironment()
|
||||
.getDefaultScreenDevice().getDefaultConfiguration()
|
||||
.getDefaultTransform();
|
||||
// createScreenCaptureTest
|
||||
AffineTransform tx = GraphicsEnvironment.getLocalGraphicsEnvironment()
|
||||
.getDefaultScreenDevice().getDefaultConfiguration()
|
||||
.getDefaultTransform();
|
||||
|
||||
if (tx.getScaleX() == 1 && tx.getScaleY() == 1) {
|
||||
isHiDPI = false;
|
||||
}
|
||||
|
||||
MultiResolutionImage image
|
||||
= robot.createMultiResolutionScreenCapture(frame.getBounds());
|
||||
List<Image> imageList = image.getResolutionVariants();
|
||||
int size = imageList.size();
|
||||
BufferedImage lowResImage;
|
||||
BufferedImage highResImage;
|
||||
|
||||
if (!isHiDPI) {
|
||||
// Check if output is MultiResolutionImage with one variant
|
||||
if (size != 1) {
|
||||
throw new RuntimeException(" Invalid variant size");
|
||||
if (tx.getScaleX() == 1 && tx.getScaleY() == 1) {
|
||||
isHiDPI = false;
|
||||
}
|
||||
|
||||
lowResImage = (BufferedImage) imageList.get(0);
|
||||
System.out.println(frame.getBounds());
|
||||
System.out.println(lowResImage.getWidth()+" "+lowResImage.getHeight());
|
||||
if (frame.getWidth() != lowResImage.getWidth()
|
||||
MultiResolutionImage image
|
||||
= robot.createMultiResolutionScreenCapture(frame.getBounds());
|
||||
List<Image> imageList = image.getResolutionVariants();
|
||||
int size = imageList.size();
|
||||
BufferedImage lowResImage;
|
||||
BufferedImage highResImage;
|
||||
|
||||
if (!isHiDPI) {
|
||||
// Check if output is MultiResolutionImage with one variant
|
||||
if (size != 1) {
|
||||
throw new RuntimeException(" Invalid variant size");
|
||||
}
|
||||
|
||||
lowResImage = (BufferedImage) imageList.get(0);
|
||||
System.out.println(frame.getBounds());
|
||||
System.out.println(lowResImage.getWidth() + " " + lowResImage.getHeight());
|
||||
if (frame.getWidth() != lowResImage.getWidth()
|
||||
|| frame.getHeight() != lowResImage.getHeight()) {
|
||||
throw new RuntimeException(" Invalid Image size");
|
||||
throw new RuntimeException(" Invalid Image size");
|
||||
}
|
||||
|
||||
} else {
|
||||
// Check if output contains two variants.
|
||||
if (size != 2) {
|
||||
throw new RuntimeException(" Invalid variant size");
|
||||
}
|
||||
|
||||
// Check if hight resolution image size is scale times low resolution image.
|
||||
lowResImage = (BufferedImage) imageList.get(0);
|
||||
highResImage = (BufferedImage) imageList.get(1);
|
||||
|
||||
int lW = (int) lowResImage.getWidth();
|
||||
int lH = (int) lowResImage.getHeight();
|
||||
int hW = (int) highResImage.getWidth();
|
||||
int hH = (int) highResImage.getHeight();
|
||||
|
||||
if (hW != (tx.getScaleX() * lW) || hH != (tx.getScaleY() * lH)) {
|
||||
throw new RuntimeException(" Invalid Resolution Variants");
|
||||
}
|
||||
|
||||
// Check if both image colors are same at some location.
|
||||
if (lowResImage.getRGB(lW / 4, lH / 4)
|
||||
!= highResImage.getRGB(hW / 4, hH / 4)) {
|
||||
throw new RuntimeException("Wrong image color!");
|
||||
}
|
||||
|
||||
if (lowResImage.getRGB(3 * lW / 4, lH / 4)
|
||||
!= highResImage.getRGB(3 * hW / 4, hH / 4)) {
|
||||
throw new RuntimeException("Wrong image color!");
|
||||
}
|
||||
|
||||
if (lowResImage.getRGB(lW / 4, 3 * lH / 4)
|
||||
!= highResImage.getRGB(hW / 4, 3 * hH / 4)) {
|
||||
throw new RuntimeException("Wrong image color!");
|
||||
}
|
||||
|
||||
if (lowResImage.getRGB(3 * lW / 4, 3 * lH / 4)
|
||||
!= highResImage.getRGB(3 * hW / 4, 3 * hH / 4)) {
|
||||
throw new RuntimeException("Wrong image color!");
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// Check if output contains two variants.
|
||||
if (size != 2) {
|
||||
throw new RuntimeException(" Invalid variant size");
|
||||
}
|
||||
|
||||
// Check if hight resolution image size is scale times low resolution image.
|
||||
lowResImage = (BufferedImage) imageList.get(0);
|
||||
highResImage = (BufferedImage) imageList.get(1);
|
||||
|
||||
int lW = (int) lowResImage.getWidth();
|
||||
int lH = (int) lowResImage.getHeight();
|
||||
int hW = (int) highResImage.getWidth();
|
||||
int hH = (int) highResImage.getHeight();
|
||||
|
||||
if ( hW != (tx.getScaleX() * lW) || hH != (tx.getScaleY() * lH)) {
|
||||
throw new RuntimeException(" Invalid Resolution Variants");
|
||||
}
|
||||
|
||||
// Check if both image colors are same at some location.
|
||||
if (lowResImage.getRGB(lW / 4, lH / 4)
|
||||
!= highResImage.getRGB(hW / 4, hH / 4)) {
|
||||
throw new RuntimeException("Wrong image color!");
|
||||
}
|
||||
|
||||
if (lowResImage.getRGB(3 * lW / 4, lH / 4)
|
||||
!= highResImage.getRGB(3 * hW / 4, hH / 4)) {
|
||||
throw new RuntimeException("Wrong image color!");
|
||||
}
|
||||
|
||||
if (lowResImage.getRGB(lW / 4, 3 * lH / 4)
|
||||
!= highResImage.getRGB(hW / 4, 3 * hH / 4)) {
|
||||
throw new RuntimeException("Wrong image color!");
|
||||
}
|
||||
|
||||
if (lowResImage.getRGB(3 * lW / 4, 3 * lH / 4)
|
||||
!= highResImage.getRGB(3 * hW / 4, 3 * hH / 4)) {
|
||||
throw new RuntimeException("Wrong image color!");
|
||||
}
|
||||
|
||||
} finally {
|
||||
frame.dispose();
|
||||
}
|
||||
|
||||
frame.dispose();
|
||||
}
|
||||
|
||||
|
||||
private static final int OFFSET = 5;
|
||||
static void checkRectColor(Rectangle rect, Color expectedColor) {
|
||||
System.out.println("Checking rectangle " + rect + " to have color " + expectedColor);
|
||||
final Point[] pointsToCheck = new Point[] {
|
||||
new Point(rect.x + OFFSET, rect.y + OFFSET), // top left corner
|
||||
new Point(rect.x + rect.width - OFFSET, rect.y + OFFSET), // top right corner
|
||||
new Point(rect.x + rect.width / 2, rect.y + rect.height / 2), // center
|
||||
new Point(rect.x + OFFSET, rect.y + rect.height - OFFSET), // bottom left corner
|
||||
new Point(rect.x + rect.width - OFFSET, rect.y + rect.height - OFFSET) // bottom right corner
|
||||
};
|
||||
|
||||
for (final var point : pointsToCheck) {
|
||||
System.out.print("Checking color at " + point + " to be equal to " + expectedColor);
|
||||
final Color actualColor = robot.getPixelColor(point.x, point.y);
|
||||
if (!actualColor.equals(expectedColor)) {
|
||||
System.out.println("... Mismatch: found " + actualColor + " instead");
|
||||
throw new RuntimeException("Wrong image color!");
|
||||
} else {
|
||||
System.out.println("... OK");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
183
test/jdk/java/awt/a11y/AccessibleActionsTest.java
Normal file
183
test/jdk/java/awt/a11y/AccessibleActionsTest.java
Normal file
@@ -0,0 +1,183 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, JetBrains s.r.o.. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8281338
|
||||
* @summary Test for an element that has more than one Accessibility Action
|
||||
* @author Artem.Semenov@jetbrains.com
|
||||
* @run main/manual AccessibleActionsTest
|
||||
* @requires (os.family == "mac")
|
||||
*/
|
||||
|
||||
import javax.accessibility.Accessible;
|
||||
import javax.accessibility.AccessibleAction;
|
||||
import javax.accessibility.AccessibleContext;
|
||||
import javax.swing.*;
|
||||
import javax.swing.tree.TreeModel;
|
||||
import javax.swing.tree.TreePath;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Hashtable;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
public class AccessibleActionsTest extends AccessibleComponentTest {
|
||||
|
||||
@Override
|
||||
public CountDownLatch createCountDownLatch() {
|
||||
return new CountDownLatch(1);
|
||||
}
|
||||
|
||||
void createTest() {
|
||||
INSTRUCTIONS = "INSTRUCTIONS:\n"
|
||||
+ "Check a11y actions.\n\n"
|
||||
+ "Turn screen reader on, and Tab to the label.\n\n"
|
||||
+ "Perform the VO action \"Press\" (VO+space)\n"
|
||||
+ "Perform the VO action \"Show menu\" (VO+m)\n\n"
|
||||
+ "If after the first action the text of the label has changed, and after the second action the menu appears tab further and press PASS, otherwise press FAIL.";
|
||||
|
||||
exceptionString = "AccessibleAction test failed!";
|
||||
super.createUI(new AccessibleActionsTestFrame(), "AccessibleActionsTest");
|
||||
}
|
||||
|
||||
void createTree() {
|
||||
INSTRUCTIONS = "INSTRUCTIONS:\n"
|
||||
+ "Check a11y actions.\n\n"
|
||||
+ "Turn screen reader on, and Tab to the label.\n\n"
|
||||
+ "Perform the VO action \"Press\" (VO+space) on tree nodes\n\n"
|
||||
+ "If after press the tree node is expanded tab further and press PASS, otherwise press FAIL.";
|
||||
|
||||
String root = "Root";
|
||||
String[] nodes = new String[] {"One node", "Two node"};
|
||||
String[][] leafs = new String[][]{{"leaf 1.1", "leaf 1.2", "leaf 1.3", "leaf 1.4"},
|
||||
{"leaf 2.1", "leaf 2.2", "leaf 2.3", "leaf 2.4"}};
|
||||
|
||||
Hashtable<String, String[]> data = new Hashtable<String, String[]>();
|
||||
for (int i = 0; i < nodes.length; i++) {
|
||||
data.put(nodes[i], leafs[i]);
|
||||
}
|
||||
|
||||
JTree tree = new JTree(data);
|
||||
tree.setRootVisible(true);
|
||||
|
||||
JPanel panel = new JPanel();
|
||||
panel.setLayout(new FlowLayout());
|
||||
JScrollPane scrollPane = new JScrollPane(tree);
|
||||
panel.add(scrollPane);
|
||||
panel.setFocusable(false);
|
||||
|
||||
exceptionString = "AccessibleAction test failed!";
|
||||
super.createUI(panel, "AccessibleActionsTest");
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
AccessibleActionsTest test = new AccessibleActionsTest();
|
||||
|
||||
countDownLatch = test.createCountDownLatch();
|
||||
SwingUtilities.invokeLater(test::createTest);
|
||||
countDownLatch.await();
|
||||
|
||||
if (!testResult) {
|
||||
throw new RuntimeException(a11yTest.exceptionString);
|
||||
}
|
||||
|
||||
countDownLatch = test.createCountDownLatch();
|
||||
SwingUtilities.invokeLater(test::createTree);
|
||||
countDownLatch.await();
|
||||
|
||||
if (!testResult) {
|
||||
throw new RuntimeException(a11yTest.exceptionString);
|
||||
}
|
||||
}
|
||||
|
||||
private class AccessibleActionsTestFrame extends JPanel {
|
||||
|
||||
public AccessibleActionsTestFrame() {
|
||||
MyLabel label = new MyLabel("I'm waiting for the push");
|
||||
label.setComponentPopupMenu(createPopup());
|
||||
label.setFocusable(true);
|
||||
add(label);
|
||||
setLayout(new FlowLayout());
|
||||
}
|
||||
|
||||
private static class MyLabel extends JLabel {
|
||||
public MyLabel(String text) {
|
||||
super(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccessibleContext getAccessibleContext() {
|
||||
if (accessibleContext == null) {
|
||||
accessibleContext = new MyAccessibleJLabel();
|
||||
}
|
||||
return accessibleContext;
|
||||
}
|
||||
|
||||
private class MyAccessibleJLabel extends JLabel.AccessibleJLabel {
|
||||
@Override
|
||||
public AccessibleAction getAccessibleAction() {
|
||||
return new AccessibleAction() {
|
||||
@Override
|
||||
public int getAccessibleActionCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAccessibleActionDescription(int i) {
|
||||
if (i == 0) {
|
||||
return AccessibleAction.CLICK;
|
||||
}
|
||||
return AccessibleAction.TOGGLE_POPUP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doAccessibleAction(int i) {
|
||||
if (i == 0) {
|
||||
changeText(MyLabel.this, "label is pressed");
|
||||
return true;
|
||||
}
|
||||
JPopupMenu popup = createPopup();
|
||||
popup.show(MyLabel.this, 0, 0);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static JPopupMenu createPopup() {
|
||||
JPopupMenu popup = new JPopupMenu("MENU");
|
||||
popup.add("One");
|
||||
popup.add("Two");
|
||||
popup.add("Three");
|
||||
return popup;
|
||||
}
|
||||
|
||||
private static void changeText(JLabel label, String text) {
|
||||
label.setText(text);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,9 @@ import java.awt.geom.*;
|
||||
import java.awt.image.*;
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
public class GradientPaints extends Canvas {
|
||||
|
||||
@@ -68,8 +70,8 @@ public class GradientPaints extends Canvas {
|
||||
(int)(TESTW * TESTH * 0.18);
|
||||
private static final int ALLOWED_MISMATCHES_RADIAL =
|
||||
(int)(TESTW * TESTH * 0.45);
|
||||
private static final int ALLOWED_RENDER_ATTEMPTS = 5;
|
||||
|
||||
private static boolean done;
|
||||
private static boolean verbose;
|
||||
|
||||
private static final Color[] COLORS = {
|
||||
@@ -83,8 +85,8 @@ public class GradientPaints extends Canvas {
|
||||
new Color(128, 128, 128),
|
||||
};
|
||||
|
||||
private static enum PaintType {BASIC, LINEAR, RADIAL};
|
||||
private static enum XformType {IDENTITY, TRANSLATE, SCALE, SHEAR, ROTATE};
|
||||
private enum PaintType {BASIC, LINEAR, RADIAL}
|
||||
private enum XformType {IDENTITY, TRANSLATE, SCALE, SHEAR, ROTATE}
|
||||
private static final int[] numStopsArray = {2, 4, 7};
|
||||
private static final Object[] hints = {
|
||||
RenderingHints.VALUE_ANTIALIAS_OFF,
|
||||
@@ -92,35 +94,14 @@ public class GradientPaints extends Canvas {
|
||||
};
|
||||
|
||||
public void paint(Graphics g) {
|
||||
synchronized (this) {
|
||||
if (!done) {
|
||||
done = true;
|
||||
notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void testOne(BufferedImage refImg, VolatileImage testImg) {
|
||||
Graphics2D gref = refImg.createGraphics();
|
||||
Graphics2D gtest = testImg.createGraphics();
|
||||
Paint paint =
|
||||
makePaint(PaintType.RADIAL, CycleMethod.REPEAT,
|
||||
ColorSpaceType.SRGB, XformType.IDENTITY, 7);
|
||||
Object aahint = hints[0];
|
||||
renderTest(gref, paint, aahint);
|
||||
renderTest(gtest, paint, aahint);
|
||||
Toolkit.getDefaultToolkit().sync();
|
||||
compareImages(refImg, testImg.getSnapshot(),
|
||||
TOLERANCE, 0, "");
|
||||
gref.dispose();
|
||||
gtest.dispose();
|
||||
painted.countDown();
|
||||
}
|
||||
|
||||
private void testAll(Graphics gscreen,
|
||||
BufferedImage refImg, VolatileImage testImg)
|
||||
BufferedImage refImg, VolatileImage testImg, GraphicsConfiguration gc)
|
||||
{
|
||||
Graphics2D gref = refImg.createGraphics();
|
||||
Graphics2D gtest = testImg.createGraphics();
|
||||
testImg.validate(gc);
|
||||
for (PaintType paintType : PaintType.values()) {
|
||||
for (CycleMethod cycleMethod : CycleMethod.values()) {
|
||||
for (ColorSpaceType colorSpace : ColorSpaceType.values()) {
|
||||
@@ -138,16 +119,32 @@ public class GradientPaints extends Canvas {
|
||||
" numStops=" + numStops +
|
||||
" aa=" + aahint;
|
||||
renderTest(gref, paint, aahint);
|
||||
renderTest(gtest, paint, aahint);
|
||||
gscreen.drawImage(testImg, 0, 0, null);
|
||||
Toolkit.getDefaultToolkit().sync();
|
||||
int allowedMismatches =
|
||||
paintType == PaintType.RADIAL ?
|
||||
ALLOWED_MISMATCHES_RADIAL :
|
||||
ALLOWED_MISMATCHES_LINEAR;
|
||||
compareImages(refImg, testImg.getSnapshot(),
|
||||
TOLERANCE, allowedMismatches,
|
||||
msg);
|
||||
int allowedMismatches = paintType == PaintType.RADIAL ?
|
||||
ALLOWED_MISMATCHES_RADIAL : ALLOWED_MISMATCHES_LINEAR;
|
||||
int attempt = 0;
|
||||
while (true) {
|
||||
Graphics2D gtest = testImg.createGraphics();
|
||||
renderTest(gtest, paint, aahint);
|
||||
gscreen.drawImage(testImg, 0, 0, null);
|
||||
Toolkit.getDefaultToolkit().sync();
|
||||
gtest.dispose();
|
||||
BufferedImage snapshot = testImg.getSnapshot();
|
||||
if (testImg.contentsLost() &&
|
||||
testImg.validate(gc) != VolatileImage.IMAGE_OK)
|
||||
{
|
||||
if (attempt++ >= ALLOWED_RENDER_ATTEMPTS) {
|
||||
throw new RuntimeException("Cannot render to VI");
|
||||
}
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
continue;
|
||||
}
|
||||
compareImages(refImg, snapshot, allowedMismatches, msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,7 +152,6 @@ public class GradientPaints extends Canvas {
|
||||
}
|
||||
}
|
||||
gref.dispose();
|
||||
gtest.dispose();
|
||||
}
|
||||
|
||||
private Paint makePaint(PaintType paintType,
|
||||
@@ -172,7 +168,6 @@ public class GradientPaints extends Canvas {
|
||||
int focusX = ctrX + 20;
|
||||
int focusY = ctrY + 20;
|
||||
float radius = 100.0f;
|
||||
Paint paint;
|
||||
AffineTransform transform;
|
||||
|
||||
Color[] colors = Arrays.copyOf(COLORS, numStops);
|
||||
@@ -181,57 +176,30 @@ public class GradientPaints extends Canvas {
|
||||
fractions[i] = ((float)i) / (fractions.length-1);
|
||||
}
|
||||
|
||||
switch (xformType) {
|
||||
default:
|
||||
case IDENTITY:
|
||||
transform = new AffineTransform();
|
||||
break;
|
||||
case TRANSLATE:
|
||||
transform = AffineTransform.getTranslateInstance(2, 2);
|
||||
break;
|
||||
case SCALE:
|
||||
transform = AffineTransform.getScaleInstance(1.2, 1.4);
|
||||
break;
|
||||
case SHEAR:
|
||||
transform = AffineTransform.getShearInstance(0.1, 0.1);
|
||||
break;
|
||||
case ROTATE:
|
||||
transform = AffineTransform.getRotateInstance(Math.PI / 4,
|
||||
getWidth()/2,
|
||||
getHeight()/2);
|
||||
break;
|
||||
}
|
||||
transform = switch (xformType) {
|
||||
case IDENTITY -> new AffineTransform();
|
||||
case TRANSLATE -> AffineTransform.getTranslateInstance(2, 2);
|
||||
case SCALE -> AffineTransform.getScaleInstance(1.2, 1.4);
|
||||
case SHEAR -> AffineTransform.getShearInstance(0.1, 0.1);
|
||||
case ROTATE -> AffineTransform.getRotateInstance(Math.PI / 4,
|
||||
getWidth() >> 1, getHeight() >> 1);
|
||||
};
|
||||
|
||||
switch (paintType) {
|
||||
case BASIC:
|
||||
boolean cyclic = (cycleMethod != CycleMethod.NO_CYCLE);
|
||||
paint =
|
||||
new GradientPaint(startX, startY, Color.RED,
|
||||
endX, endY, Color.BLUE, cyclic);
|
||||
break;
|
||||
|
||||
default:
|
||||
case LINEAR:
|
||||
paint =
|
||||
new LinearGradientPaint(new Point2D.Float(startX, startY),
|
||||
new Point2D.Float(endX, endY),
|
||||
fractions, colors,
|
||||
cycleMethod, colorSpace,
|
||||
transform);
|
||||
break;
|
||||
|
||||
case RADIAL:
|
||||
paint =
|
||||
new RadialGradientPaint(new Point2D.Float(ctrX, ctrY),
|
||||
radius,
|
||||
new Point2D.Float(focusX, focusY),
|
||||
fractions, colors,
|
||||
cycleMethod, colorSpace,
|
||||
transform);
|
||||
break;
|
||||
}
|
||||
|
||||
return paint;
|
||||
return switch (paintType) {
|
||||
case BASIC -> new GradientPaint(startX, startY, Color.RED,
|
||||
endX, endY, Color.BLUE, (cycleMethod != CycleMethod.NO_CYCLE));
|
||||
case LINEAR -> new LinearGradientPaint(new Point2D.Float(startX, startY),
|
||||
new Point2D.Float(endX, endY),
|
||||
fractions, colors,
|
||||
cycleMethod, colorSpace,
|
||||
transform);
|
||||
case RADIAL -> new RadialGradientPaint(new Point2D.Float(ctrX, ctrY),
|
||||
radius,
|
||||
new Point2D.Float(focusX, focusY),
|
||||
fractions, colors,
|
||||
cycleMethod, colorSpace,
|
||||
transform);
|
||||
};
|
||||
}
|
||||
|
||||
private void renderTest(Graphics2D g2d, Paint p, Object aahint) {
|
||||
@@ -248,7 +216,7 @@ public class GradientPaints extends Canvas {
|
||||
|
||||
private static void compareImages(BufferedImage refImg,
|
||||
BufferedImage testImg,
|
||||
int tolerance, int allowedMismatches,
|
||||
int allowedMismatches,
|
||||
String msg)
|
||||
{
|
||||
int numMismatches = 0;
|
||||
@@ -261,7 +229,7 @@ public class GradientPaints extends Canvas {
|
||||
for (int x = x1; x < x2; x++) {
|
||||
Color expected = new Color(refImg.getRGB(x, y));
|
||||
Color actual = new Color(testImg.getRGB(x, y));
|
||||
if (!isSameColor(expected, actual, tolerance)) {
|
||||
if (!isSameColor(expected, actual)) {
|
||||
numMismatches++;
|
||||
}
|
||||
}
|
||||
@@ -277,6 +245,7 @@ public class GradientPaints extends Canvas {
|
||||
ImageIO.write(testImg, "png",
|
||||
new File("GradientPaints.cap.png"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (!verbose) {
|
||||
System.err.println(msg);
|
||||
@@ -285,53 +254,49 @@ public class GradientPaints extends Canvas {
|
||||
numMismatches +
|
||||
") exceeds limit (" +
|
||||
allowedMismatches +
|
||||
") with tolerance=" +
|
||||
tolerance);
|
||||
") with tolerance=" + TOLERANCE);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isSameColor(Color c1, Color c2, int e) {
|
||||
private static boolean isSameColor(Color c1, Color c2) {
|
||||
int r1 = c1.getRed();
|
||||
int g1 = c1.getGreen();
|
||||
int b1 = c1.getBlue();
|
||||
int r2 = c2.getRed();
|
||||
int g2 = c2.getGreen();
|
||||
int b2 = c2.getBlue();
|
||||
int rmin = Math.max(r2-e, 0);
|
||||
int gmin = Math.max(g2-e, 0);
|
||||
int bmin = Math.max(b2-e, 0);
|
||||
int rmax = Math.min(r2+e, 255);
|
||||
int gmax = Math.min(g2+e, 255);
|
||||
int bmax = Math.min(b2+e, 255);
|
||||
if (r1 >= rmin && r1 <= rmax &&
|
||||
g1 >= gmin && g1 <= gmax &&
|
||||
b1 >= bmin && b1 <= bmax)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
int rmin = Math.max(r2- TOLERANCE, 0);
|
||||
int gmin = Math.max(g2- TOLERANCE, 0);
|
||||
int bmin = Math.max(b2- TOLERANCE, 0);
|
||||
int rmax = Math.min(r2+ TOLERANCE, 255);
|
||||
int gmax = Math.min(g2+ TOLERANCE, 255);
|
||||
int bmax = Math.min(b2+ TOLERANCE, 255);
|
||||
return r1 >= rmin && r1 <= rmax &&
|
||||
g1 >= gmin && g1 <= gmax &&
|
||||
b1 >= bmin && b1 <= bmax;
|
||||
}
|
||||
|
||||
static CountDownLatch painted = new CountDownLatch(1);
|
||||
static Frame frame = null;
|
||||
|
||||
public static void main(String[] args) {
|
||||
if (args.length == 1 && args[0].equals("-verbose")) {
|
||||
verbose = true;
|
||||
}
|
||||
|
||||
GradientPaints test = new GradientPaints();
|
||||
Frame frame = new Frame();
|
||||
frame.add(test);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
frame = new Frame();
|
||||
frame.add(test);
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
});
|
||||
|
||||
// Wait until the component's been painted
|
||||
synchronized (test) {
|
||||
while (!done) {
|
||||
try {
|
||||
test.wait();
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException("Failed: Interrupted");
|
||||
}
|
||||
}
|
||||
try {
|
||||
painted.await();
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException("Failed: Interrupted");
|
||||
}
|
||||
|
||||
GraphicsConfiguration gc = frame.getGraphicsConfiguration();
|
||||
@@ -345,10 +310,9 @@ public class GradientPaints extends Canvas {
|
||||
BufferedImage refImg =
|
||||
new BufferedImage(TESTW, TESTH, BufferedImage.TYPE_INT_RGB);
|
||||
VolatileImage testImg = frame.createVolatileImage(TESTW, TESTH);
|
||||
testImg.validate(gc);
|
||||
|
||||
try {
|
||||
test.testAll(test.getGraphics(), refImg, testImg);
|
||||
test.testAll(test.getGraphics(), refImg, testImg, gc);
|
||||
} finally {
|
||||
frame.dispose();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
/*
|
||||
* @test
|
||||
* @requires (os.family == "linux")
|
||||
* @requires !display.XWayland
|
||||
* @key headful
|
||||
* @bug 8214112
|
||||
* @summary Tests JPasswordField selected Text background color
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
/*
|
||||
* @test
|
||||
* @requires (os.family == "linux")
|
||||
* @requires !display.XWayland
|
||||
* @key headful
|
||||
* @bug 8218472
|
||||
* @summary Tests JProgressBar highlight color
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
/*
|
||||
* @test
|
||||
* @requires (os.family == "linux")
|
||||
* @requires !display.XWayland
|
||||
* @key headful
|
||||
* @bug 8218469
|
||||
* @summary Tests JSlider is rendered properly with gtk3
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
/*
|
||||
* @test
|
||||
* @requires (os.family == "linux")
|
||||
* @requires !display.XWayland
|
||||
* @key headful
|
||||
* @bug 8214112
|
||||
* @summary Tests JSpinner selected Text background color
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
/*
|
||||
* @test
|
||||
* @requires (os.family == "linux")
|
||||
* @requires !display.XWayland
|
||||
* @key headful
|
||||
* @bug 8218479
|
||||
* @summary Tests JTextPane background color
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
/*
|
||||
* @test
|
||||
* @requires (os.family == "linux")
|
||||
* @requires !display.XWayland
|
||||
* @key headful
|
||||
* @bug 8214253
|
||||
* @summary Tests JToolTip background color
|
||||
|
||||
106
test/jdk/jb/build/CheckJBRModules.java
Normal file
106
test/jdk/jb/build/CheckJBRModules.java
Normal file
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright 2022 JetBrains s.r.o.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @requires !vm.graal.enabled
|
||||
* @summary Verifies the list of available modules
|
||||
* @library /test/lib
|
||||
* @run main CheckJBRModules
|
||||
*/
|
||||
public class CheckJBRModules {
|
||||
static final String moduleNames[] = {
|
||||
"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.smartcardio",
|
||||
"java.sql",
|
||||
"java.sql.rowset",
|
||||
"java.transaction.xa",
|
||||
"java.xml",
|
||||
"java.xml.crypto",
|
||||
"jdk.accessibility",
|
||||
"jdk.attach",
|
||||
"jdk.charsets",
|
||||
"jdk.compiler",
|
||||
"jdk.crypto.cryptoki",
|
||||
"jdk.crypto.ec",
|
||||
"jdk.dynalink",
|
||||
"jdk.httpserver",
|
||||
"jdk.internal.ed",
|
||||
"jdk.internal.le",
|
||||
"jdk.internal.vm.ci",
|
||||
"jdk.javadoc",
|
||||
"jdk.jdi",
|
||||
"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.sctp",
|
||||
"jdk.security.auth",
|
||||
"jdk.security.jgss",
|
||||
"jdk.unsupported",
|
||||
"jdk.unsupported.desktop",
|
||||
"jdk.xml.dom",
|
||||
"jdk.zipfs",
|
||||
"jdk.hotspot.agent",
|
||||
"jdk.jcmd" };
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
final OutputAnalyzer oa = exec("--list-modules").shouldHaveExitValue(0);
|
||||
for(String moduleName : moduleNames) {
|
||||
oa.shouldContain(moduleName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* java args... returning the OutputAnalyzer to analyzer the output
|
||||
*/
|
||||
private static OutputAnalyzer exec(String... args) throws Exception {
|
||||
return ProcessTools.executeTestJava(args)
|
||||
.outputTo(System.out)
|
||||
.errorTo(System.out);
|
||||
}
|
||||
}
|
||||
53
test/jdk/jb/build/CheckJBRModulesWindows.java
Normal file
53
test/jdk/jb/build/CheckJBRModulesWindows.java
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2022 JetBrains s.r.o.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import jdk.test.lib.process.ProcessTools;
|
||||
import jdk.test.lib.process.OutputAnalyzer;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @requires !vm.graal.enabled
|
||||
* @requires (os.family == "windows")
|
||||
* @summary Verifies the list of available modules specific to Windows
|
||||
* @library /test/lib
|
||||
* @run main CheckJBRModulesWindows
|
||||
*/
|
||||
public class CheckJBRModulesWindows {
|
||||
static final String moduleNames[] = { "jdk.crypto.mscapi" };
|
||||
|
||||
public static void main(String args[]) throws Exception {
|
||||
final OutputAnalyzer oa = exec("--list-modules").shouldHaveExitValue(0);
|
||||
for(String moduleName : moduleNames) {
|
||||
oa.shouldContain(moduleName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* java args... returning the OutputAnalyzer to analyzer the output
|
||||
*/
|
||||
private static OutputAnalyzer exec(String... args) throws Exception {
|
||||
return ProcessTools.executeTestJava(args)
|
||||
.outputTo(System.out)
|
||||
.errorTo(System.out);
|
||||
}
|
||||
}
|
||||
@@ -35,13 +35,13 @@ public class ProxyInfoResolvingTest {
|
||||
JBRApi.ModuleRegistry r = init();
|
||||
// No mapping defined -> null
|
||||
requireNull(getProxy(ProxyInfoResolvingTest.class));
|
||||
// Invalid JBR-side target class -> error
|
||||
// Invalid JBR-side target class -> null
|
||||
r.proxy(InterfaceWithoutImplementation.class.getName(), "absentImpl");
|
||||
mustFail(() -> getProxy(InterfaceWithoutImplementation.class), RuntimeException.class, ClassNotFoundException.class);
|
||||
// Invalid JBR-side target static method mapping -> error
|
||||
requireNull(getProxy(InterfaceWithoutImplementation.class));
|
||||
// Invalid JBR-side target static method mapping -> null
|
||||
r.service(ServiceWithoutImplementation.class.getName(), null)
|
||||
.withStatic("someMethod", "NoClass");
|
||||
mustFail(() -> getProxy(ServiceWithoutImplementation.class), RuntimeException.class, ClassNotFoundException.class);
|
||||
requireNull(getProxy(ServiceWithoutImplementation.class));
|
||||
// Service without target class or static method mapping -> null
|
||||
r.service(EmptyService.class.getName(), null);
|
||||
requireNull(getProxy(EmptyService.class));
|
||||
|
||||
85
test/jdk/jb/java/awt/Focus/MacSpecialFocusLostCase.java
Normal file
85
test/jdk/jb/java/awt/Focus/MacSpecialFocusLostCase.java
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright 2022 JetBrains s.r.o.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @summary Regression test for JBR-4281 Window losing focus isn't detected in some cases on macOS
|
||||
* @key headful
|
||||
* @requires (os.family == "mac")
|
||||
*/
|
||||
|
||||
public class MacSpecialFocusLostCase {
|
||||
private static Robot robot;
|
||||
private static JFrame frame;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(MacSpecialFocusLostCase::initUI);
|
||||
checkFocusedStatus(true);
|
||||
pressCmdSpace(); // open Spotlight popup
|
||||
checkFocusedStatus(false);
|
||||
pressEsc(); // close Spotlight popup
|
||||
checkFocusedStatus(true);
|
||||
} finally {
|
||||
pressEsc(); // make sure popup is closed in any case
|
||||
SwingUtilities.invokeAndWait(MacSpecialFocusLostCase::disposeUI);
|
||||
}
|
||||
}
|
||||
|
||||
private static void initUI() {
|
||||
frame = new JFrame("MacSpecialFocusLostCase");
|
||||
frame.setBounds(200, 200, 300, 200);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private static void disposeUI() {
|
||||
if (frame != null) frame.dispose();
|
||||
}
|
||||
|
||||
private static void checkFocusedStatus(boolean expected) throws Exception {
|
||||
robot.delay(1000);
|
||||
boolean[] result = new boolean[1];
|
||||
SwingUtilities.invokeAndWait(() -> result[0] = frame.isFocused());
|
||||
if (result[0] != expected) {
|
||||
throw new RuntimeException(expected ? "Frame isn't focused" : "Frame is still focused");
|
||||
}
|
||||
}
|
||||
|
||||
private static void pressCmdSpace() {
|
||||
robot.keyPress(KeyEvent.VK_META);
|
||||
robot.keyPress(KeyEvent.VK_SPACE);
|
||||
robot.keyRelease(KeyEvent.VK_SPACE);
|
||||
robot.keyRelease(KeyEvent.VK_META);
|
||||
}
|
||||
|
||||
private static void pressEsc() {
|
||||
robot.keyPress(KeyEvent.VK_ESCAPE);
|
||||
robot.keyRelease(KeyEvent.VK_ESCAPE);
|
||||
}
|
||||
}
|
||||
98
test/jdk/jb/java/awt/MouseInfo/GetPointerInfoTest.java
Normal file
98
test/jdk/jb/java/awt/MouseInfo/GetPointerInfoTest.java
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright 2000-2022 JetBrains s.r.o.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
@test
|
||||
@key headful
|
||||
@summary a regression test for JBR-4303.
|
||||
@run main GetPointerInfoTest
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* The test checks <code>MouseInfo.getPointerInfo()</code> for all locations with the steps <code>X_STEP</code> and
|
||||
* <code>Y_STEP</code> on all graphic devices.
|
||||
* It moves mouse to the current location via <code>Robot.mouseMove()</code> and checks that
|
||||
* <code>MouseInfo.getPointerInfo()</code> is not NULL.
|
||||
* It also checks <code>MouseInfo.getPointerInfo().getLocation()</code> returns expected values.
|
||||
*/
|
||||
public class GetPointerInfoTest {
|
||||
|
||||
public static int X_STEP = 100;
|
||||
public static int Y_STEP = 100;
|
||||
|
||||
static boolean isPassed = true;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
GraphicsDevice[] graphicsDevices = ge.getScreenDevices();
|
||||
|
||||
for (GraphicsDevice gd : graphicsDevices) {
|
||||
String name = gd.getIDstring();
|
||||
int width = gd.getDisplayMode().getWidth();
|
||||
int height = gd.getDisplayMode().getHeight();
|
||||
System.out.println("Check for device: " + name + " " + width + "x" + height);
|
||||
|
||||
Robot robot = new Robot(gd);
|
||||
|
||||
robot.setAutoDelay(0);
|
||||
robot.setAutoWaitForIdle(true);
|
||||
robot.delay(10);
|
||||
robot.waitForIdle();
|
||||
|
||||
GraphicsConfiguration gc = gd.getDefaultConfiguration();
|
||||
|
||||
Rectangle bounds = gc.getBounds();
|
||||
|
||||
for (double y = bounds.getY(); y < bounds.getY() + bounds.getHeight(); y += Y_STEP) {
|
||||
|
||||
for (double x = bounds.getX(); x < bounds.getX() + bounds.getWidth(); x += X_STEP) {
|
||||
|
||||
Point p = new Point((int)x, (int)y);
|
||||
|
||||
System.out.println("\tmouse move to x=" + p.x + " y=" + p.y);
|
||||
robot.mouseMove(p.x, p.y);
|
||||
|
||||
System.out.print("\t\tMouseInfo.getPointerInfo.getLocation");
|
||||
PointerInfo pi = MouseInfo.getPointerInfo();
|
||||
if (pi == null) {
|
||||
throw new RuntimeException("Test failed. getPointerInfo() returned null value.");
|
||||
}
|
||||
|
||||
Point piLocation = pi.getLocation();
|
||||
if (piLocation.x != p.x || piLocation.y != p.y) {
|
||||
System.out.println(" - ***FAILED*** x=" + piLocation.x + " y=" + piLocation.y);
|
||||
isPassed = false;
|
||||
} else {
|
||||
System.out.println(" x=" + p.x + ", y=" + p.y + " - passed");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( !isPassed )
|
||||
throw new RuntimeException("PointerInfo.getLocation() returns unexpected value(s).");
|
||||
|
||||
System.out.println("Test PASSED.");
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
@@ -9,11 +9,9 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.locks.Condition;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import sun.awt.InvokeOnToolkitHelper;
|
||||
import sun.lwawt.macosx.CThreading;
|
||||
import sun.lwawt.macosx.LWCToolkit;
|
||||
|
||||
import javax.swing.*;
|
||||
import sun.awt.AWTThreading;
|
||||
|
||||
/*
|
||||
* @test
|
||||
@@ -50,6 +48,7 @@ public class AWTThreadingTest {
|
||||
|
||||
static void runGui() {
|
||||
frame = new JFrame("frame");
|
||||
frame.getContentPane().setBackground(Color.green);
|
||||
frame.setLocationRelativeTo(null);
|
||||
frame.setSize(200, 200);
|
||||
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||
@@ -88,7 +87,7 @@ public class AWTThreadingTest {
|
||||
EventQueue.invokeLater(() -> {
|
||||
passed.set(false);
|
||||
|
||||
Boolean success = InvokeOnToolkitHelper.invokeAndBlock(() -> {
|
||||
Boolean success = AWTThreading.executeWaitToolkit(() -> {
|
||||
try {
|
||||
return CThreading.executeOnAppKit(() -> Boolean.TRUE);
|
||||
} catch (Throwable e) {
|
||||
|
||||
229
test/jdk/jb/java/awt/Toolkit/LWCToolkitInvokeAndWaitTest.java
Normal file
229
test/jdk/jb/java/awt/Toolkit/LWCToolkitInvokeAndWaitTest.java
Normal file
@@ -0,0 +1,229 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.InvocationEvent;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.*;
|
||||
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.awt.AWTThreading;
|
||||
import sun.lwawt.macosx.CThreading;
|
||||
import sun.lwawt.macosx.LWCToolkit;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @summary Tests different scenarios for LWCToolkit.invokeAndWait().
|
||||
* @requires (os.family == "mac")
|
||||
* @modules java.desktop/sun.lwawt.macosx java.desktop/sun.awt
|
||||
* @run main LWCToolkitInvokeAndWaitTest
|
||||
* @run main/othervm -DAWTThreading.level.FINER=true LWCToolkitInvokeAndWaitTest
|
||||
* @author Anton Tarasov
|
||||
*/
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public class LWCToolkitInvokeAndWaitTest {
|
||||
// This property is used in {CAccessibility}
|
||||
private static final int INVOKE_TIMEOUT_SECONDS = Integer.getInteger("sun.lwawt.macosx.CAccessibility.invokeTimeoutSeconds", 1);
|
||||
|
||||
static TestLogHandler LOG_HANDLER = new TestLogHandler();
|
||||
static volatile CompletableFuture<Boolean> FUTURE;
|
||||
static volatile CountDownLatch EDT_FAST_FREE_LATCH;
|
||||
static volatile JFrame FRAME;
|
||||
static volatile Thread MAIN_THREAD;
|
||||
static int TEST_COUNTER;
|
||||
|
||||
static final Runnable CONSUME_DISPATCHING = () -> FUTURE.completeExceptionally(new Throwable("Unexpected dispatching!"));
|
||||
|
||||
static {
|
||||
AWTThreading.setAWTThreadingFactory(edt -> new AWTThreading(edt) {
|
||||
@Override
|
||||
public CompletableFuture<Void> onEventDispatchThreadFree(Runnable runnable) {
|
||||
if (EDT_FAST_FREE_LATCH != null) {
|
||||
// 1. wait for the invocation event to be dispatched
|
||||
// 2. wait for EDT to become free
|
||||
trycatch(() -> EDT_FAST_FREE_LATCH.await());
|
||||
|
||||
EDT_FAST_FREE_LATCH = null;
|
||||
}
|
||||
// if EDT is free the runnable should be called immediately
|
||||
return super.onEventDispatchThreadFree(runnable);
|
||||
}
|
||||
@Override
|
||||
public void notifyEventDispatchThreadFree() {
|
||||
if (EDT_FAST_FREE_LATCH != null &&
|
||||
// if the invocation event is dispatched by now
|
||||
EDT_FAST_FREE_LATCH.getCount() == 1)
|
||||
{
|
||||
EDT_FAST_FREE_LATCH.countDown();
|
||||
}
|
||||
super.notifyEventDispatchThreadFree();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
MAIN_THREAD = Thread.currentThread();
|
||||
|
||||
trycatch(() -> {
|
||||
Logger log = LogManager.getLogManager().getLogger(AWTThreading.class.getName());
|
||||
log.setUseParentHandlers(false);
|
||||
log.addHandler(LOG_HANDLER);
|
||||
if (Boolean.getBoolean("AWTThreading.level.FINER")) {
|
||||
log.setLevel(Level.FINER);
|
||||
}
|
||||
});
|
||||
|
||||
Consumer<InvocationEvent> noop = e -> {};
|
||||
|
||||
try {
|
||||
trycatch(() -> EventQueue.invokeAndWait(LWCToolkitInvokeAndWaitTest::runGui));
|
||||
|
||||
test("InvocationEvent is normally dispatched",
|
||||
"",
|
||||
noop,
|
||||
() -> System.out.println("I'm dispatched"));
|
||||
|
||||
test("InvocationEvent is lost",
|
||||
"lost",
|
||||
noop,
|
||||
CONSUME_DISPATCHING);
|
||||
|
||||
EDT_FAST_FREE_LATCH = new CountDownLatch(2);
|
||||
test("InvocationEvent is lost (EDT becomes fast free)",
|
||||
"lost",
|
||||
// notify the invocationEvent has been dispatched
|
||||
invocationEvent -> EDT_FAST_FREE_LATCH.countDown(),
|
||||
CONSUME_DISPATCHING);
|
||||
|
||||
test("InvocationEvent is disposed",
|
||||
"disposed",
|
||||
invocationEvent -> AWTAccessor.getInvocationEventAccessor().dispose(invocationEvent),
|
||||
CONSUME_DISPATCHING);
|
||||
|
||||
test("InvocationEvent is timed out (delayed before dispatching)",
|
||||
"timed out",
|
||||
invocationEvent -> sleep(INVOKE_TIMEOUT_SECONDS * 4),
|
||||
CONSUME_DISPATCHING);
|
||||
|
||||
test("InvocationEvent is timed out (delayed during dispatching)",
|
||||
"timed out",
|
||||
noop,
|
||||
() -> sleep(INVOKE_TIMEOUT_SECONDS * 4));
|
||||
|
||||
} finally {
|
||||
FRAME.dispose();
|
||||
}
|
||||
System.out.println("Test PASSED");
|
||||
}
|
||||
|
||||
static void runGui() {
|
||||
FRAME = new JFrame(LWCToolkitInvokeAndWaitTest.class.getSimpleName());
|
||||
FRAME.getContentPane().setBackground(Color.green);
|
||||
FRAME.setLocationRelativeTo(null);
|
||||
FRAME.setSize(200, 200);
|
||||
FRAME.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||
FRAME.setVisible(true);
|
||||
}
|
||||
|
||||
static void test(String testCaption,
|
||||
String expectedInLog,
|
||||
Consumer<InvocationEvent> onBeforeDispatching,
|
||||
Runnable onDispatching)
|
||||
{
|
||||
System.out.println("\n(" + (++TEST_COUNTER) + ") TEST: " + testCaption);
|
||||
|
||||
FUTURE = new CompletableFuture<>();
|
||||
FUTURE.whenComplete((r, ex) -> Optional.of(ex).ifPresent(Throwable::printStackTrace));
|
||||
|
||||
EventQueue.invokeLater(() -> subTest(onBeforeDispatching, onDispatching));
|
||||
|
||||
trycatch(() -> {
|
||||
if (!FUTURE.get(INVOKE_TIMEOUT_SECONDS * 2L, TimeUnit.SECONDS)) {
|
||||
throw new RuntimeException("Test FAILED! (negative result)");
|
||||
}
|
||||
});
|
||||
|
||||
// let AppKit and EDT print all the logging
|
||||
var latch = new CountDownLatch(1);
|
||||
CThreading.executeOnAppKit(latch::countDown);
|
||||
trycatch(latch::await);
|
||||
trycatch(() -> EventQueue.invokeAndWait(() -> {}));
|
||||
|
||||
if (!LOG_HANDLER.testContains(expectedInLog)) {
|
||||
throw new RuntimeException("Test FAILED! (not found in the log: \"" + expectedInLog + "\")");
|
||||
}
|
||||
|
||||
System.out.println("(" + TEST_COUNTER + ") SUCCEEDED\n");
|
||||
}
|
||||
|
||||
static void subTest(Consumer<InvocationEvent> onBeforeDispatching, Runnable onDispatching) {
|
||||
Toolkit.getDefaultToolkit().getSystemEventQueue().push(new EventQueue() {
|
||||
@Override
|
||||
protected void dispatchEvent(AWTEvent event) {
|
||||
//
|
||||
// Intercept the invocation posted from Appkit.
|
||||
//
|
||||
if (event instanceof AWTThreading.TrackedInvocationEvent) {
|
||||
System.out.println("Before dispatching: " + event);
|
||||
onBeforeDispatching.accept((InvocationEvent)event);
|
||||
|
||||
if (onDispatching == CONSUME_DISPATCHING) {
|
||||
System.out.println("Consuming: " + event);
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.dispatchEvent(event);
|
||||
}
|
||||
});
|
||||
CThreading.executeOnAppKit(() -> trycatch(() -> {
|
||||
//
|
||||
// Post an invocation from AppKit.
|
||||
//
|
||||
LWCToolkit.invokeAndWait(onDispatching, FRAME, false, INVOKE_TIMEOUT_SECONDS);
|
||||
FUTURE.complete(true);
|
||||
}));
|
||||
}
|
||||
|
||||
static void sleep(int seconds) {
|
||||
trycatch(() -> Thread.sleep(seconds * 1000L));
|
||||
}
|
||||
|
||||
static void trycatch(ThrowableRunnable runnable) {
|
||||
try {
|
||||
runnable.run();
|
||||
} catch (Exception e) {
|
||||
if (Thread.currentThread() == MAIN_THREAD) {
|
||||
throw new RuntimeException("Test FAILED!", e);
|
||||
} else {
|
||||
FUTURE.completeExceptionally(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface ThrowableRunnable {
|
||||
void run() throws Exception;
|
||||
}
|
||||
|
||||
static class TestLogHandler extends StreamHandler {
|
||||
public StringBuilder buffer = new StringBuilder();
|
||||
|
||||
public TestLogHandler() {
|
||||
// Use System.out to merge with the test printing.
|
||||
super(System.out, new SimpleFormatter());
|
||||
setLevel(Level.ALL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publish(LogRecord record) {
|
||||
buffer.append(record.getMessage());
|
||||
super.publish(record);
|
||||
flush();
|
||||
}
|
||||
|
||||
public boolean testContains(String str) {
|
||||
boolean contains = buffer.toString().contains(str);
|
||||
buffer.setLength(0);
|
||||
return contains;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,22 +32,23 @@ import java.nio.file.Files;
|
||||
* @summary Regression test for JBR-3671 Window order changes for a background app on macOS desktop space switch
|
||||
* @key headful
|
||||
* @requires (os.family == "mac")
|
||||
* @compile MacSpacesUtil.java
|
||||
* @run main BackgroundWindowOrderOnSpaceChange
|
||||
*/
|
||||
|
||||
public class BackgroundWindowOrderOnSpaceChange {
|
||||
private static Robot robot;
|
||||
private static JFrame frame1;
|
||||
private static JFrame frame2;
|
||||
private static Process otherProcess;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
robot = new Robot();
|
||||
MacSpacesUtil.ensureMoreThanOneSpaceExists();
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(BackgroundWindowOrderOnSpaceChange::initUI);
|
||||
launchProcessWithWindow();
|
||||
switchToNextSpace();
|
||||
switchToPreviousSpace();
|
||||
Color color = robot.getPixelColor(400, 400);
|
||||
MacSpacesUtil.switchToNextSpace();
|
||||
MacSpacesUtil.switchToPreviousSpace();
|
||||
Color color = new Robot().getPixelColor(400, 400);
|
||||
if (!Color.green.equals(color)) {
|
||||
throw new RuntimeException("Frame 1 isn't shown on top. Found color: " + color);
|
||||
}
|
||||
@@ -102,20 +103,4 @@ public class BackgroundWindowOrderOnSpaceChange {
|
||||
throw new RuntimeException("Error starting process");
|
||||
}
|
||||
}
|
||||
|
||||
private static void switchToPreviousSpace() {
|
||||
robot.keyPress(KeyEvent.VK_CONTROL);
|
||||
robot.keyPress(KeyEvent.VK_LEFT);
|
||||
robot.keyRelease(KeyEvent.VK_LEFT);
|
||||
robot.keyRelease(KeyEvent.VK_CONTROL);
|
||||
robot.delay(1000); // wait for animation to finish
|
||||
}
|
||||
|
||||
private static void switchToNextSpace() {
|
||||
robot.keyPress(KeyEvent.VK_CONTROL);
|
||||
robot.keyPress(KeyEvent.VK_RIGHT);
|
||||
robot.keyRelease(KeyEvent.VK_RIGHT);
|
||||
robot.keyRelease(KeyEvent.VK_CONTROL);
|
||||
robot.delay(1000); // wait for animation to finish
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,9 @@ import java.util.concurrent.TimeUnit;
|
||||
* @requires (os.family == "mac")
|
||||
* @modules java.desktop/com.apple.eawt
|
||||
* java.desktop/com.apple.eawt.event
|
||||
*/
|
||||
* @compile MacSpacesUtil.java
|
||||
* @run main FullScreenChildWindow
|
||||
*/
|
||||
|
||||
public class FullScreenChildWindow {
|
||||
private static final CompletableFuture<Boolean> shownAtFullScreen = new CompletableFuture<>();
|
||||
@@ -55,14 +57,12 @@ public class FullScreenChildWindow {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(50); // without delay between key presses, 'switchToPreviousSpace' doesn't always work
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(FullScreenChildWindow::initUI);
|
||||
shownAtFullScreen.get(5, TimeUnit.SECONDS);
|
||||
clickAt(button);
|
||||
dialogShown.get(5, TimeUnit.SECONDS);
|
||||
switchToPreviousSpace();
|
||||
robot.delay(2000);
|
||||
MacSpacesUtil.switchToPreviousSpace();
|
||||
if (!frame1.isFocused()) {
|
||||
throw new RuntimeException("Unexpected state");
|
||||
}
|
||||
@@ -120,11 +120,4 @@ public class FullScreenChildWindow {
|
||||
Point location = component.getLocationOnScreen();
|
||||
clickAt(location.x + component.getWidth() / 2, location.y + component.getHeight() / 2);
|
||||
}
|
||||
|
||||
private static void switchToPreviousSpace() {
|
||||
robot.keyPress(KeyEvent.VK_CONTROL);
|
||||
robot.keyPress(KeyEvent.VK_LEFT);
|
||||
robot.keyRelease(KeyEvent.VK_LEFT);
|
||||
robot.keyRelease(KeyEvent.VK_CONTROL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ import java.awt.event.WindowEvent;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/**
|
||||
* @test
|
||||
@@ -41,24 +40,28 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
* @key headful
|
||||
* @requires (os.family == "mac")
|
||||
* @modules java.desktop/com.apple.eawt
|
||||
* @compile MacSpacesUtil.java
|
||||
* @run main FullScreenChildWindowShownBefore
|
||||
*/
|
||||
|
||||
public class FullScreenChildWindowShownBefore {
|
||||
private static final CompletableFuture<Boolean> dialogShown = new CompletableFuture<>();
|
||||
|
||||
private static Robot robot;
|
||||
private static JFrame frame;
|
||||
private static JDialog dialog;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
robot = new Robot();
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(FullScreenChildWindowShownBefore::initUI);
|
||||
dialogShown.get(5, TimeUnit.SECONDS);
|
||||
SwingUtilities.invokeAndWait(() -> Application.getApplication().requestToggleFullScreen(frame));
|
||||
robot.delay(1000); // wait for transition to full screen to finish
|
||||
ensureVisible(frame);
|
||||
ensureVisible(dialog);
|
||||
Thread.sleep(1000); // wait for transition to full screen to finish
|
||||
ensureVisible(frame, 250, 150);
|
||||
ensureVisible(dialog, 250, 250);
|
||||
SwingUtilities.invokeAndWait(() -> Application.getApplication().requestToggleFullScreen(frame));
|
||||
Thread.sleep(1000); // wait for transition from full screen to finish
|
||||
ensureVisible(frame, 250, 150);
|
||||
ensureVisible(dialog, 250, 250);
|
||||
} finally {
|
||||
SwingUtilities.invokeAndWait(FullScreenChildWindowShownBefore::disposeUI);
|
||||
}
|
||||
@@ -66,8 +69,7 @@ public class FullScreenChildWindowShownBefore {
|
||||
|
||||
private static void initUI() {
|
||||
frame = new JFrame("FullScreenChildWindowShownBefore");
|
||||
frame.setSize(100, 100);
|
||||
frame.setLocation(100, 100);
|
||||
frame.setBounds(100, 100, 300, 300);
|
||||
frame.setVisible(true);
|
||||
|
||||
dialog = new JDialog(frame, false);
|
||||
@@ -77,8 +79,7 @@ public class FullScreenChildWindowShownBefore {
|
||||
dialogShown.complete(true);
|
||||
}
|
||||
});
|
||||
dialog.setSize(100, 100);
|
||||
dialog.setLocation(100, 300);
|
||||
dialog.setBounds(200, 200, 100, 100);
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
|
||||
@@ -86,38 +87,7 @@ public class FullScreenChildWindowShownBefore {
|
||||
if (frame != null) frame.dispose();
|
||||
}
|
||||
|
||||
private static void ensureVisible(Window window) throws Exception {
|
||||
AtomicReference<Point> location = new AtomicReference<>();
|
||||
AtomicBoolean movementDetected = new AtomicBoolean();
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
if (window.isVisible()) {
|
||||
Rectangle bounds = window.getBounds();
|
||||
Insets insets = window.getInsets();
|
||||
bounds.x += insets.left;
|
||||
bounds.y += insets.top;
|
||||
bounds.width -= insets.left + insets.right;
|
||||
bounds.height -= insets.top + insets.bottom;
|
||||
if (!bounds.isEmpty()) {
|
||||
location.set(new Point((int) bounds.getCenterX(), (int) bounds.getCenterY()));
|
||||
window.addMouseMotionListener(new MouseMotionAdapter() {
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
movementDetected.set(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
Point target = location.get();
|
||||
if (target != null) {
|
||||
robot.mouseMove(target.x, target.y);
|
||||
robot.delay(100);
|
||||
robot.mouseMove(target.x + 1, target.y + 1);
|
||||
robot.delay(1000);
|
||||
if (movementDetected.get()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException(window + " isn't visible");
|
||||
private static void ensureVisible(Window window, int x, int y) throws Exception {
|
||||
if (!MacSpacesUtil.isWindowVisibleAtPoint(window, x, y)) throw new RuntimeException(window + " isn't visible");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,32 +40,32 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
* @requires (os.family == "mac")
|
||||
* @modules java.desktop/com.apple.eawt
|
||||
* java.desktop/com.apple.eawt.event
|
||||
* @compile MacSpacesUtil.java
|
||||
* @run main FullScreenInactiveDialog
|
||||
*/
|
||||
|
||||
public class FullScreenInactiveDialog {
|
||||
private static final CompletableFuture<Boolean> shownAtFullScreen = new CompletableFuture<>();
|
||||
|
||||
private static Robot robot;
|
||||
private static JFrame frame;
|
||||
private static JDialog dialog;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(50); // without delay between key presses, 'switchToPreviousSpace' doesn't always work
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(FullScreenInactiveDialog::initUI);
|
||||
shownAtFullScreen.get(5, TimeUnit.SECONDS);
|
||||
switchToPreviousSpace();
|
||||
MacSpacesUtil.switchToPreviousSpace();
|
||||
SwingUtilities.invokeLater(FullScreenInactiveDialog::openDialog);
|
||||
robot.delay(1000);
|
||||
if (isWindowReallyShowing(dialog)) {
|
||||
Thread.sleep(1000);
|
||||
if (MacSpacesUtil.isWindowVisible(dialog)) {
|
||||
throw new RuntimeException("Dialog is showing earlier than expected");
|
||||
}
|
||||
activateApp(); // simulates clicking on app icon in dock or switch using Cmd+Tab
|
||||
if (!isWindowReallyShowing(dialog)) {
|
||||
Desktop.getDesktop().requestForeground(false); // simulates clicking on app icon in dock or switch using Cmd+Tab
|
||||
Thread.sleep(1000); // wait for animation to finish
|
||||
if (!MacSpacesUtil.isWindowVisible(dialog)) {
|
||||
throw new RuntimeException("Dialog isn't showing when expected");
|
||||
}
|
||||
if (!isWindowReallyShowing(frame)) {
|
||||
if (!MacSpacesUtil.isWindowVisible(frame)) {
|
||||
throw new RuntimeException("Frame isn't showing when expected");
|
||||
}
|
||||
} finally {
|
||||
@@ -97,50 +97,4 @@ public class FullScreenInactiveDialog {
|
||||
private static void disposeUI() {
|
||||
if (frame != null) frame.dispose();
|
||||
}
|
||||
|
||||
private static void switchToPreviousSpace() {
|
||||
robot.keyPress(KeyEvent.VK_CONTROL);
|
||||
robot.keyPress(KeyEvent.VK_LEFT);
|
||||
robot.keyRelease(KeyEvent.VK_LEFT);
|
||||
robot.keyRelease(KeyEvent.VK_CONTROL);
|
||||
robot.delay(1000); // wait for animation to finish
|
||||
}
|
||||
|
||||
private static void activateApp() {
|
||||
Desktop.getDesktop().requestForeground(false);
|
||||
robot.delay(1000); // wait for animation to finish
|
||||
}
|
||||
|
||||
private static boolean isWindowReallyShowing(Window window) throws Exception {
|
||||
Point[] location = new Point[1];
|
||||
AtomicBoolean movementDetected = new AtomicBoolean();
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
if (window.isVisible()) {
|
||||
Rectangle bounds = window.getBounds();
|
||||
Insets insets = window.getInsets();
|
||||
bounds.x += insets.left;
|
||||
bounds.y += insets.top;
|
||||
bounds.width -= insets.left + insets.right;
|
||||
bounds.height -= insets.top + insets.bottom;
|
||||
if (!bounds.isEmpty()) {
|
||||
location[0] = new Point(bounds.x + bounds.width / 2, bounds.y + bounds.height / 2);
|
||||
window.addMouseMotionListener(new MouseMotionAdapter() {
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
movementDetected.set(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
Point target = location[0];
|
||||
if (target == null) {
|
||||
return false;
|
||||
}
|
||||
robot.mouseMove(target.x, target.y);
|
||||
robot.delay(100);
|
||||
robot.mouseMove(target.x + 1, target.y + 1);
|
||||
robot.delay(1000);
|
||||
return movementDetected.get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,29 +40,28 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
* @requires (os.family == "mac")
|
||||
* @modules java.desktop/com.apple.eawt
|
||||
* java.desktop/com.apple.eawt.event
|
||||
* @compile MacSpacesUtil.java
|
||||
* @run main FullScreenInactiveModalDialog
|
||||
*/
|
||||
|
||||
public class FullScreenInactiveModalDialog {
|
||||
private static final CompletableFuture<Boolean> shownAtFullScreen = new CompletableFuture<>();
|
||||
|
||||
private static Robot robot;
|
||||
private static JFrame frame;
|
||||
private static JDialog dialog;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
robot = new Robot();
|
||||
robot.setAutoDelay(50); // without delay between key presses, 'switchToPreviousSpace'/'switchToNextSpace' don't always work
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(FullScreenInactiveModalDialog::initUI);
|
||||
shownAtFullScreen.get(5, TimeUnit.SECONDS);
|
||||
switchToPreviousSpace();
|
||||
MacSpacesUtil.switchToPreviousSpace();
|
||||
SwingUtilities.invokeLater(FullScreenInactiveModalDialog::openDialog);
|
||||
robot.delay(1000);
|
||||
if (isWindowReallyShowing(dialog)) {
|
||||
Thread.sleep(1000);
|
||||
if (MacSpacesUtil.isWindowVisible(dialog)) {
|
||||
throw new RuntimeException("Dialog is showing earlier than expected");
|
||||
}
|
||||
switchToNextSpace();
|
||||
if (!isWindowReallyShowing(dialog)) {
|
||||
MacSpacesUtil.switchToNextSpace();
|
||||
if (!MacSpacesUtil.isWindowVisible(dialog)) {
|
||||
throw new RuntimeException("Dialog isn't showing when expected");
|
||||
}
|
||||
} finally {
|
||||
@@ -94,53 +93,4 @@ public class FullScreenInactiveModalDialog {
|
||||
private static void disposeUI() {
|
||||
if (frame != null) frame.dispose();
|
||||
}
|
||||
|
||||
private static void switchToPreviousSpace() {
|
||||
robot.keyPress(KeyEvent.VK_CONTROL);
|
||||
robot.keyPress(KeyEvent.VK_LEFT);
|
||||
robot.keyRelease(KeyEvent.VK_LEFT);
|
||||
robot.keyRelease(KeyEvent.VK_CONTROL);
|
||||
robot.delay(1000); // wait for animation to finish
|
||||
}
|
||||
|
||||
private static void switchToNextSpace() {
|
||||
robot.keyPress(KeyEvent.VK_CONTROL);
|
||||
robot.keyPress(KeyEvent.VK_RIGHT);
|
||||
robot.keyRelease(KeyEvent.VK_RIGHT);
|
||||
robot.keyRelease(KeyEvent.VK_CONTROL);
|
||||
robot.delay(1000); // wait for animation to finish
|
||||
}
|
||||
|
||||
private static boolean isWindowReallyShowing(Window window) throws Exception {
|
||||
Point[] location = new Point[1];
|
||||
AtomicBoolean movementDetected = new AtomicBoolean();
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
if (window.isVisible()) {
|
||||
Rectangle bounds = window.getBounds();
|
||||
Insets insets = window.getInsets();
|
||||
bounds.x += insets.left;
|
||||
bounds.y += insets.top;
|
||||
bounds.width -= insets.left + insets.right;
|
||||
bounds.height -= insets.top + insets.bottom;
|
||||
if (!bounds.isEmpty()) {
|
||||
location[0] = new Point(bounds.x + bounds.width / 2, bounds.y + bounds.height / 2);
|
||||
window.addMouseMotionListener(new MouseMotionAdapter() {
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
movementDetected.set(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
Point target = location[0];
|
||||
if (target == null) {
|
||||
return false;
|
||||
}
|
||||
robot.mouseMove(target.x, target.y);
|
||||
robot.delay(100);
|
||||
robot.mouseMove(target.x + 1, target.y + 1);
|
||||
robot.delay(1000);
|
||||
return movementDetected.get();
|
||||
}
|
||||
}
|
||||
|
||||
168
test/jdk/jb/java/awt/Window/MacSpacesUtil.java
Normal file
168
test/jdk/jb/java/awt/Window/MacSpacesUtil.java
Normal file
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* Copyright 2022 JetBrains s.r.o.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class MacSpacesUtil {
|
||||
public static boolean hasMoreThanOneSpace() throws Exception {
|
||||
return Runtime.getRuntime().exec(new String[]{
|
||||
"plutil",
|
||||
"-extract",
|
||||
"SpacesDisplayConfiguration.Space Properties.1",
|
||||
"json",
|
||||
"-o",
|
||||
"-",
|
||||
System.getProperty("user.home") + "/Library/Preferences/com.apple.spaces.plist"
|
||||
}).waitFor() == 0;
|
||||
}
|
||||
|
||||
public static void addSpace() throws Exception {
|
||||
toggleMissionControl();
|
||||
|
||||
// press button at top right corner to add a new space
|
||||
int screenWidth = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
|
||||
.getDefaultConfiguration().getBounds().width;
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
robot.mouseMove(screenWidth, 0);
|
||||
robot.mouseMove(screenWidth - 5, 5);
|
||||
robot.mouseMove(screenWidth - 10, 10);
|
||||
robot.delay(1000);
|
||||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.delay(1000);
|
||||
|
||||
toggleMissionControl();
|
||||
}
|
||||
|
||||
public static boolean isWindowVisibleAtPoint(Window window, int x, int y) throws Exception {
|
||||
CountDownLatch movementDetected = new CountDownLatch(1);
|
||||
MouseMotionListener listener = new MouseMotionAdapter() {
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
movementDetected.countDown();
|
||||
}
|
||||
};
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(() -> window.addMouseMotionListener(listener));
|
||||
Robot robot = new Robot();
|
||||
robot.mouseMove(x, y);
|
||||
robot.delay(50);
|
||||
robot.mouseMove(x + 1, y + 1);
|
||||
return movementDetected.await(1, TimeUnit.SECONDS);
|
||||
} finally {
|
||||
SwingUtilities.invokeAndWait(() -> window.removeMouseMotionListener(listener));
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isWindowVisible(Window window) throws Exception {
|
||||
Rectangle bounds = window.getBounds();
|
||||
Insets insets = window.getInsets();
|
||||
bounds.x += insets.left;
|
||||
bounds.y += insets.top;
|
||||
bounds.width -= insets.left + insets.right;
|
||||
bounds.height -= insets.top + insets.bottom;
|
||||
return isWindowVisibleAtPoint(window, bounds.x + bounds.width / 2, bounds.y + bounds.height / 2);
|
||||
}
|
||||
|
||||
public static void verifyAdditionalSpaceExists() throws Exception {
|
||||
AtomicReference<JFrame> frameRef = new AtomicReference<>();
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
JFrame f = new JFrame("Spaces check");
|
||||
frameRef.set(f);
|
||||
f.setBounds(100, 100, 200, 200);
|
||||
f.setVisible(true);
|
||||
Desktop.getDesktop().requestForeground(true);
|
||||
});
|
||||
|
||||
if (!isWindowVisibleAtPoint(frameRef.get(), 200, 200)) {
|
||||
throw new RuntimeException("Test frame not visible");
|
||||
}
|
||||
|
||||
switchToNextSpace();
|
||||
|
||||
if (isWindowVisibleAtPoint(frameRef.get(), 200, 200)) {
|
||||
throw new RuntimeException("Extra space isn't available");
|
||||
}
|
||||
} finally {
|
||||
switchToPreviousSpace();
|
||||
SwingUtilities.invokeAndWait(() -> {
|
||||
JFrame f = frameRef.get();
|
||||
if (f != null) f.dispose();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void toggleMissionControl() throws Exception {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
robot.keyPress(KeyEvent.VK_CONTROL);
|
||||
robot.keyPress(KeyEvent.VK_UP);
|
||||
robot.keyRelease(KeyEvent.VK_UP);
|
||||
robot.keyRelease(KeyEvent.VK_CONTROL);
|
||||
robot.delay(1000); // wait for animation to finish
|
||||
}
|
||||
|
||||
public static void switchToPreviousSpace() throws Exception {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
robot.keyPress(KeyEvent.VK_CONTROL);
|
||||
robot.keyPress(KeyEvent.VK_LEFT);
|
||||
robot.keyRelease(KeyEvent.VK_LEFT);
|
||||
robot.keyRelease(KeyEvent.VK_CONTROL);
|
||||
robot.delay(1000); // wait for animation to finish
|
||||
}
|
||||
|
||||
public static void switchToNextSpace() throws Exception {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
robot.keyPress(KeyEvent.VK_CONTROL);
|
||||
robot.keyPress(KeyEvent.VK_RIGHT);
|
||||
robot.keyRelease(KeyEvent.VK_RIGHT);
|
||||
robot.keyRelease(KeyEvent.VK_CONTROL);
|
||||
robot.delay(1000); // wait for animation to finish
|
||||
}
|
||||
|
||||
// press Control+Right while holding mouse pressed over window's header
|
||||
public static void moveWindowToNextSpace(Window window) throws Exception {
|
||||
Robot robot = new Robot();
|
||||
robot.setAutoDelay(50);
|
||||
Point location = window.getLocationOnScreen();
|
||||
robot.mouseMove(location.x + window.getWidth() / 2, location.y + window.getInsets().top / 2);
|
||||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||
switchToNextSpace();
|
||||
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
||||
}
|
||||
|
||||
public static void ensureMoreThanOneSpaceExists() throws Exception {
|
||||
if (hasMoreThanOneSpace()) return;
|
||||
addSpace();
|
||||
verifyAdditionalSpaceExists();
|
||||
}
|
||||
}
|
||||
81
test/jdk/jb/java/awt/Window/ParentMovingToAnotherSpace.java
Normal file
81
test/jdk/jb/java/awt/Window/ParentMovingToAnotherSpace.java
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* Copyright 2022 JetBrains s.r.o.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseMotionAdapter;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @summary Regression test for JBR-4186 Unexpected desktop switch after moving a window to another desktop
|
||||
* @key headful
|
||||
* @requires (os.family == "mac")
|
||||
* @compile MacSpacesUtil.java
|
||||
* @run main ParentMovingToAnotherSpace
|
||||
*/
|
||||
|
||||
public class ParentMovingToAnotherSpace {
|
||||
private static JFrame frame1;
|
||||
private static JFrame frame2;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
MacSpacesUtil.ensureMoreThanOneSpaceExists();
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(ParentMovingToAnotherSpace::initUI);
|
||||
Thread.sleep(1000); // wait for windows to appear
|
||||
MacSpacesUtil.moveWindowToNextSpace(frame2);
|
||||
if (MacSpacesUtil.isWindowVisible(frame1)) {
|
||||
throw new RuntimeException("Space switch didn't work");
|
||||
}
|
||||
if (!MacSpacesUtil.isWindowVisible(frame2)) {
|
||||
throw new RuntimeException("Frame isn't showing when expected");
|
||||
}
|
||||
} finally {
|
||||
MacSpacesUtil.switchToPreviousSpace();
|
||||
SwingUtilities.invokeAndWait(ParentMovingToAnotherSpace::disposeUI);
|
||||
}
|
||||
}
|
||||
|
||||
private static void initUI() {
|
||||
frame1 = new JFrame("ParentMovingToAnotherSpace-1");
|
||||
frame1.setBounds(100, 100, 300, 100);
|
||||
frame1.setVisible(true);
|
||||
|
||||
frame2 = new JFrame("ParentMovingToAnotherSpace-2");
|
||||
frame2.setBounds(100, 300, 300, 100);
|
||||
frame2.setVisible(true);
|
||||
|
||||
JWindow window = new JWindow(frame2);
|
||||
window.setBounds(100, 500, 300, 100);
|
||||
window.setVisible(true);
|
||||
}
|
||||
|
||||
private static void disposeUI() {
|
||||
if (frame1 != null) frame1.dispose();
|
||||
if (frame2 != null) frame2.dispose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright 2000-2022 JetBrains s.r.o.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseMotionAdapter;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @summary Specific case for JBR-4186 Unexpected desktop switch after moving a window to another desktop
|
||||
* @key headful
|
||||
* @requires (os.family == "mac")
|
||||
* @compile MacSpacesUtil.java
|
||||
* @run main TwoFramesAndDialogOnDifferentSpaces
|
||||
*/
|
||||
|
||||
public class TwoFramesAndDialogOnDifferentSpaces {
|
||||
private static Robot robot;
|
||||
private static JFrame frame1;
|
||||
private static JFrame frame2;
|
||||
private static JDialog dialog;
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
MacSpacesUtil.ensureMoreThanOneSpaceExists();
|
||||
robot = new Robot();
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(TwoFramesAndDialogOnDifferentSpaces::initUI);
|
||||
robot.delay(1000);
|
||||
ensureVisibility(true, true, true);
|
||||
MacSpacesUtil.moveWindowToNextSpace(frame1);
|
||||
ensureVisibility(true, false, false);
|
||||
MacSpacesUtil.switchToPreviousSpace();
|
||||
ensureVisibility(false, true, true);
|
||||
clickOn(frame2);
|
||||
robot.delay(1000);
|
||||
MacSpacesUtil.switchToNextSpace();
|
||||
ensureVisibility(true, false, false);
|
||||
} finally {
|
||||
MacSpacesUtil.switchToPreviousSpace();
|
||||
SwingUtilities.invokeAndWait(TwoFramesAndDialogOnDifferentSpaces::disposeUI);
|
||||
}
|
||||
}
|
||||
|
||||
private static void initUI() {
|
||||
frame1 = new JFrame("TFADODS-1");
|
||||
frame1.setBounds(200, 200, 300, 100);
|
||||
frame1.setVisible(true);
|
||||
|
||||
frame2 = new JFrame("TFADODS-2");
|
||||
frame2.setBounds(200, 400, 300, 100);
|
||||
frame2.setVisible(true);
|
||||
|
||||
dialog = new JDialog(frame2, "TFADODS");
|
||||
dialog.setBounds(200, 600, 300, 100);
|
||||
dialog.setVisible(true);
|
||||
}
|
||||
|
||||
private static void disposeUI() {
|
||||
if (frame1 != null) frame1.dispose();
|
||||
if (frame2 != null) frame2.dispose();
|
||||
}
|
||||
|
||||
private static void ensureVisibility(boolean frame1Visible, boolean frame2Visible, boolean dialogVisible)
|
||||
throws Exception {
|
||||
if (frame1Visible != MacSpacesUtil.isWindowVisible(frame1)) {
|
||||
throw new RuntimeException("Frame 1 is " + (frame1Visible ? "not " : "") + " visible");
|
||||
}
|
||||
if (frame2Visible != MacSpacesUtil.isWindowVisible(frame2)) {
|
||||
throw new RuntimeException("Frame 2 is " + (frame2Visible ? "not " : "") + " visible");
|
||||
}
|
||||
if (dialogVisible != MacSpacesUtil.isWindowVisible(dialog)) {
|
||||
throw new RuntimeException("Dialog is " + (dialogVisible ? "not " : "") + " visible");
|
||||
}
|
||||
}
|
||||
|
||||
private static void clickAt(int x, int y) {
|
||||
robot.mouseMove(x, y);
|
||||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
||||
}
|
||||
|
||||
private static void clickOn(Component component) {
|
||||
Point location = component.getLocationOnScreen();
|
||||
clickAt(location.x + component.getWidth() / 2, location.y + component.getHeight() / 2);
|
||||
}
|
||||
}
|
||||
@@ -24,17 +24,17 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @summary Regression test for JBR-3838 ensures that pressing each layout-free key + AltGr produces AltGr modifier
|
||||
* @summary Regression test for JBR-4207 ensures that pressing each layout-free key + AltGr produces AltGr modifier
|
||||
* @requires (os.family == "windows")
|
||||
* @key headful
|
||||
* @run main AltGrMustGenerateAltGrModifierTest3838
|
||||
* @run main AltGrMustGenerateAltGrModifierTest4207
|
||||
* @author Nikita Provotorov
|
||||
*/
|
||||
public class AltGrMustGenerateAltGrModifierTest3838 extends Frame {
|
||||
public class AltGrMustGenerateAltGrModifierTest4207 extends Frame {
|
||||
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
final AltGrMustGenerateAltGrModifierTest3838 mainWindow = new AltGrMustGenerateAltGrModifierTest3838();
|
||||
final AltGrMustGenerateAltGrModifierTest4207 mainWindow = new AltGrMustGenerateAltGrModifierTest4207();
|
||||
|
||||
try {
|
||||
mainWindow.setVisible(true);
|
||||
@@ -63,7 +63,7 @@ public class AltGrMustGenerateAltGrModifierTest3838 extends Frame {
|
||||
}
|
||||
|
||||
|
||||
private AltGrMustGenerateAltGrModifierTest3838()
|
||||
private AltGrMustGenerateAltGrModifierTest4207()
|
||||
{
|
||||
super("AltGr must generate AltGr modifier");
|
||||
|
||||
@@ -178,7 +178,7 @@ public class AltGrMustGenerateAltGrModifierTest3838 extends Frame {
|
||||
|
||||
// Sometimes top-level Frame does not get focus when requestFocus is called.
|
||||
// For example, when this test is launched after test/.../bug6361367.java:
|
||||
// jtreg test/jdk/javax/swing/text/JTextComponent/6361367/bug6361367.java test/jdk/jb/java/awt/keyboard/AltGrMustGenerateAltGrModifierTest3838.java
|
||||
// jtreg test/jdk/javax/swing/text/JTextComponent/6361367/bug6361367.java test/jdk/jb/java/awt/keyboard/AltGrMustGenerateAltGrModifierTest4207.java
|
||||
//
|
||||
// So this method forces the focus acquiring via mouse clicking to the component.
|
||||
private static void forceFocusTo(final Component component, final Robot robot) {
|
||||
@@ -35,20 +35,20 @@ public enum Layout_ABC implements LayoutKey {
|
||||
// located on the left side of the key 1 on the Apple International English keyboard
|
||||
// SECTION ('§', '§', '±', '±'),
|
||||
|
||||
VK_MINUS ('-', '–', '_', '—'),
|
||||
VK_EQUALS ('=', '≠', '+', '±'),
|
||||
VK_MINUS ('-', '–', '_', '—', '\u001F'),
|
||||
VK_EQUALS ('=', '≠', '+', '±', '='),
|
||||
|
||||
VK_OPEN_BRACKET ('[', '“', '{', '”'),
|
||||
VK_CLOSE_BRACKET (']', '‘', '}', '’'),
|
||||
VK_OPEN_BRACKET ('[', '“', '{', '”', '\u001B'),
|
||||
VK_CLOSE_BRACKET (']', '‘', '}', '’', '\u001D'),
|
||||
|
||||
VK_SEMICOLON (';', '…', ':', 'Ú'),
|
||||
VK_QUOTE ('\'', 'æ', '"', 'Æ'),
|
||||
VK_BACK_SLASH ('\\', '«', '|', '»'),
|
||||
VK_SEMICOLON (';', '…', ':', 'Ú', ';'),
|
||||
VK_QUOTE ('\'', 'æ', '"', 'Æ', '\''),
|
||||
VK_BACK_SLASH ('\\', '«', '|', '»', '\u001C'),
|
||||
|
||||
VK_BACK_QUOTE (KeyChar.ch('`'), KeyChar.dead('`'), KeyChar.ch('~'), KeyChar.ch('`')),
|
||||
VK_COMMA (',', '≤', '<', '¯'),
|
||||
VK_PERIOD ('.', '≥', '>', '˘'),
|
||||
VK_SLASH ('/', '÷', '?', '¿'),
|
||||
VK_BACK_QUOTE (KeyChar.ch('`'), KeyChar.dead('`'), KeyChar.ch('~'), KeyChar.ch('`'), KeyChar.ch('`')),
|
||||
VK_COMMA (',', '≤', '<', '¯', ','),
|
||||
VK_PERIOD ('.', '≥', '>', '˘', '.'),
|
||||
VK_SLASH ('/', '÷', '?', '¿', '/'),
|
||||
|
||||
//VK_1 ('1', '¡', '!', '⁄'),
|
||||
//VK_2 ('2', '™', '@', '€'),
|
||||
@@ -99,12 +99,12 @@ public enum Layout_ABC implements LayoutKey {
|
||||
|
||||
private final Key key;
|
||||
|
||||
Layout_ABC(char no, char alt, char shift, char alt_shift) {
|
||||
key = new Key(name(), new MappedKeyChars(no, alt, shift, alt_shift));
|
||||
Layout_ABC(char no, char alt, char shift, char alt_shift, char control) {
|
||||
key = new Key(name(), new MappedKeyChars(no, alt, shift, alt_shift, control));
|
||||
}
|
||||
|
||||
Layout_ABC(KeyChar no, KeyChar alt, KeyChar shift, KeyChar alt_shift) {
|
||||
key = new Key(name(), new MappedKeyChars(no, alt, shift, alt_shift));
|
||||
Layout_ABC(KeyChar no, KeyChar alt, KeyChar shift, KeyChar alt_shift, KeyChar control) {
|
||||
key = new Key(name(), new MappedKeyChars(no, alt, shift, alt_shift, control));
|
||||
}
|
||||
|
||||
public Key getKey() {
|
||||
|
||||
@@ -30,20 +30,20 @@ public enum Layout_FRENCH_PC implements LayoutKey {
|
||||
// Enum name must be the same as KeyEvent.VK_ constant name corresponding to the key on US keyboard layout
|
||||
// Note that '\u0000' may be used if no char is mapped to a key + modifier or if one wants to skip its testing
|
||||
|
||||
VK_MINUS (')', ']', '°', ']'),
|
||||
VK_EQUALS ('=', '}', '+', '≠'),
|
||||
VK_MINUS (')', ']', '°', ']', '\u001B'),
|
||||
VK_EQUALS ('=', '}', '+', '≠', '\u001F'),
|
||||
|
||||
VK_OPEN_BRACKET (KeyChar.dead('^'), KeyChar.ch('ô'), KeyChar.dead('¨'), KeyChar.ch('Ô')),
|
||||
VK_CLOSE_BRACKET ('$', '¤', '£', '¥'),
|
||||
VK_OPEN_BRACKET (KeyChar.dead('^'), KeyChar.ch('ô'), KeyChar.dead('¨'), KeyChar.ch('Ô'), KeyChar.ch('\u001E')),
|
||||
VK_CLOSE_BRACKET ('$', '¤', '£', '¥', '\u001D'),
|
||||
|
||||
VK_SEMICOLON ('m', 'µ', 'M', 'Ó'),
|
||||
VK_QUOTE ('ù', 'Ù', '%', '‰'),
|
||||
VK_BACK_SLASH ('*', '@', 'μ', '#'),
|
||||
VK_SEMICOLON ('m', 'µ', 'M', 'Ó', '\r'),
|
||||
VK_QUOTE ('ù', 'Ù', '%', '‰', 'ù'),
|
||||
VK_BACK_SLASH ('*', '@', 'μ', '#', '\u001C'),
|
||||
|
||||
VK_BACK_QUOTE ('<', '«', '>', '≥'),
|
||||
VK_COMMA (';', '…', '.', '•'),
|
||||
VK_PERIOD (':', '÷', '/', '\\'),
|
||||
VK_SLASH ('!', '¡', '§', '±'),
|
||||
VK_BACK_QUOTE ('<', '«', '>', '≥', '<'),
|
||||
VK_COMMA (';', '…', '.', '•', ';'),
|
||||
VK_PERIOD (':', '÷', '/', '\\', ':'),
|
||||
VK_SLASH ('!', '¡', '§', '±', '='),
|
||||
|
||||
;
|
||||
|
||||
@@ -51,12 +51,12 @@ public enum Layout_FRENCH_PC implements LayoutKey {
|
||||
|
||||
private final Key key;
|
||||
|
||||
Layout_FRENCH_PC(char no, char alt, char shift, char alt_shift) {
|
||||
key = new Key(name(), new MappedKeyChars(no, alt, shift, alt_shift));
|
||||
Layout_FRENCH_PC(char no, char alt, char shift, char alt_shift, char control) {
|
||||
key = new Key(name(), new MappedKeyChars(no, alt, shift, alt_shift, control));
|
||||
}
|
||||
|
||||
Layout_FRENCH_PC(KeyChar no, KeyChar alt, KeyChar shift, KeyChar alt_shift) {
|
||||
key = new Key(name(), new MappedKeyChars(no, alt, shift, alt_shift));
|
||||
Layout_FRENCH_PC(KeyChar no, KeyChar alt, KeyChar shift, KeyChar alt_shift, KeyChar control) {
|
||||
key = new Key(name(), new MappedKeyChars(no, alt, shift, alt_shift, control));
|
||||
}
|
||||
|
||||
public Key getKey() {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user