diff --git a/.github/workflows/build-cross-compile.yml b/.github/workflows/build-cross-compile.yml index 0b2888ca6e0..f8e7306a8c0 100644 --- a/.github/workflows/build-cross-compile.yml +++ b/.github/workflows/build-cross-compile.yml @@ -60,33 +60,33 @@ jobs: gnu-arch: aarch64 debian-arch: arm64 debian-repository: https://httpredir.debian.org/debian/ - debian-version: bookworm + debian-version: trixie tolerate-sysroot-errors: false - target-cpu: arm gnu-arch: arm debian-arch: armhf debian-repository: https://httpredir.debian.org/debian/ - debian-version: bookworm + debian-version: trixie tolerate-sysroot-errors: false gnu-abi: eabihf - target-cpu: s390x gnu-arch: s390x debian-arch: s390x debian-repository: https://httpredir.debian.org/debian/ - debian-version: bookworm + debian-version: trixie tolerate-sysroot-errors: false - target-cpu: ppc64le gnu-arch: powerpc64le debian-arch: ppc64el debian-repository: https://httpredir.debian.org/debian/ - debian-version: bookworm + debian-version: trixie tolerate-sysroot-errors: false - target-cpu: riscv64 gnu-arch: riscv64 debian-arch: riscv64 debian-repository: https://httpredir.debian.org/debian/ - debian-version: sid - tolerate-sysroot-errors: true + debian-version: trixie + tolerate-sysroot-errors: false steps: - name: 'Checkout the JDK source' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 14de10b1031..f2d1d01f905 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -237,8 +237,8 @@ jobs: uses: ./.github/workflows/build-macos.yml with: platform: macos-x64 - runs-on: 'macos-13' - xcode-toolset-version: '14.3.1' + runs-on: 'macos-15-intel' + xcode-toolset-version: '16.4' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} if: needs.prepare.outputs.macos-x64 == 'true' @@ -249,8 +249,8 @@ jobs: uses: ./.github/workflows/build-macos.yml with: platform: macos-aarch64 - runs-on: 'macos-14' - xcode-toolset-version: '15.4' + runs-on: 'macos-15' + xcode-toolset-version: '16.4' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} if: needs.prepare.outputs.macos-aarch64 == 'true' @@ -311,17 +311,6 @@ jobs: bootjdk-platform: linux-x64 runs-on: ubuntu-22.04 - test-macos-x64: - name: macos-x64 - needs: - - build-macos-x64 - uses: ./.github/workflows/test.yml - with: - platform: macos-x64 - bootjdk-platform: macos-x64 - runs-on: macos-13 - xcode-toolset-version: '14.3.1' - test-macos-aarch64: name: macos-aarch64 needs: @@ -330,8 +319,8 @@ jobs: with: platform: macos-aarch64 bootjdk-platform: macos-aarch64 - runs-on: macos-14 - xcode-toolset-version: '15.4' + runs-on: macos-15 + xcode-toolset-version: '16.4' test-windows-x64: name: windows-x64 diff --git a/.jcheck/conf b/.jcheck/conf index 35de7d4d946..d89c28169f4 100644 --- a/.jcheck/conf +++ b/.jcheck/conf @@ -1,7 +1,7 @@ [general] project=jdk-updates jbs=JDK -version=21.0.9 +version=21.0.10 [checks] error=author,committer,reviewers,merge,issues,executable,symlink,message,hg-tag,whitespace,problemlists diff --git a/doc/building.html b/doc/building.html index 5295c0e6451..26720dd5b39 100644 --- a/doc/building.html +++ b/doc/building.html @@ -476,7 +476,7 @@
The basic tooling is provided as part of the core operating system, but you will most likely need to install developer packages.
For apt-based distributions (Debian, Ubuntu, etc), try this:
-sudo apt-get install build-essential
+sudo apt-get install build-essential autoconf
For rpm-based distributions (Fedora, Red Hat, etc), try this:
sudo yum groupinstall "Development Tools"
For Alpine Linux, aside from basic tooling, install the GNU versions @@ -539,7 +539,7 @@
configure and are unlikely to
work.
The JDK is currently known to be able to compile with at least -version 11.2 of gcc.
+version 13.2 of gcc.In general, any version between these two should be usable.
The minimum accepted version of clang is 3.5. Older versions will not diff --git a/doc/building.md b/doc/building.md index 36bf32945a8..addc74aae51 100644 --- a/doc/building.md +++ b/doc/building.md @@ -289,7 +289,7 @@ will most likely need to install developer packages. For apt-based distributions (Debian, Ubuntu, etc), try this: ``` -sudo apt-get install build-essential +sudo apt-get install build-essential autoconf ``` For rpm-based distributions (Fedora, Red Hat, etc), try this: @@ -336,7 +336,7 @@ issues. | Operating system | Toolchain version | | ------------------ | ------------------------------------------ | -| Linux | gcc 11.2.0 | +| Linux | gcc 13.2.0 | | macOS | Apple Xcode 10.1 (using clang 10.0.0) | | Windows | Microsoft Visual Studio 2022 update 17.1.0 | @@ -350,7 +350,7 @@ features that it does support. The minimum accepted version of gcc is 5.0. Older versions will generate a warning by `configure` and are unlikely to work. -The JDK is currently known to be able to compile with at least version 11.2 of +The JDK is currently known to be able to compile with at least version 13.2 of gcc. In general, any version between these two should be usable. diff --git a/make/RunTests.gmk b/make/RunTests.gmk index 8c6e0f1924f..b490f9f7748 100644 --- a/make/RunTests.gmk +++ b/make/RunTests.gmk @@ -1077,7 +1077,7 @@ UseSpecialTestHandler = \ # Now process each test to run and setup a proper make rule $(foreach test, $(TESTS_TO_RUN), \ $(eval TEST_ID := $(shell $(ECHO) $(strip $(test)) | \ - $(TR) -cs '[a-z][A-Z][0-9]\n' '[_*1000]')) \ + $(TR) -cs '[a-z][A-Z][0-9]\n' '_')) \ $(eval ALL_TEST_IDS += $(TEST_ID)) \ $(if $(call UseCustomTestHandler, $(test)), \ $(eval $(call SetupRunCustomTest, $(TEST_ID), \ @@ -1157,9 +1157,9 @@ run-test-report: post-run-test TEST TOTAL PASS FAIL ERROR " " $(foreach test, $(TESTS_TO_RUN), \ $(eval TEST_ID := $(shell $(ECHO) $(strip $(test)) | \ - $(TR) -cs '[a-z][A-Z][0-9]\n' '[_*1000]')) \ + $(TR) -cs '[a-z][A-Z][0-9]\n' '_')) \ $(ECHO) >> $(TEST_LAST_IDS) $(TEST_ID) $(NEWLINE) \ - $(eval NAME_PATTERN := $(shell $(ECHO) $(test) | $(TR) -c '\n' '[_*1000]')) \ + $(eval NAME_PATTERN := $(shell $(ECHO) $(test) | $(TR) -c '\n' '_')) \ $(if $(filter __________________________________________________%, $(NAME_PATTERN)), \ $(eval TEST_NAME := ) \ $(PRINTF) >> $(TEST_SUMMARY) "%2s %-49s\n" " " "$(test)" $(NEWLINE) \ diff --git a/make/autoconf/configure.ac b/make/autoconf/configure.ac index f7e9844a643..44f0c15f15d 100644 --- a/make/autoconf/configure.ac +++ b/make/autoconf/configure.ac @@ -223,6 +223,9 @@ JDKOPT_SETUP_UNDEFINED_BEHAVIOR_SANITIZER # LeakSanitizer JDKOPT_SETUP_LEAK_SANITIZER +# Setup static analyzer +JDKOPT_SETUP_STATIC_ANALYZER + # Fallback linker # This needs to go before 'LIB_DETERMINE_DEPENDENCIES' JDKOPT_SETUP_FALLBACK_LINKER diff --git a/make/autoconf/flags-cflags.m4 b/make/autoconf/flags-cflags.m4 index 9b022792e15..ab8c48e16d4 100644 --- a/make/autoconf/flags-cflags.m4 +++ b/make/autoconf/flags-cflags.m4 @@ -625,8 +625,8 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER], TOOLCHAIN_CFLAGS_JVM="-qtbtable=full -qtune=balanced -fno-exceptions \ -qalias=noansi -qstrict -qtls=default -qnortti -qnoeh -qignerrno -qstackprotect" elif test "x$TOOLCHAIN_TYPE" = xmicrosoft; then - TOOLCHAIN_CFLAGS_JVM="-nologo -MD -Zc:preprocessor -Zc:strictStrings -MP" - TOOLCHAIN_CFLAGS_JDK="-nologo -MD -Zc:preprocessor -Zc:strictStrings -Zc:wchar_t-" + TOOLCHAIN_CFLAGS_JVM="-nologo -MD -Zc:preprocessor -Zc:throwingNew -permissive- -MP" + TOOLCHAIN_CFLAGS_JDK="-nologo -MD -Zc:preprocessor -Zc:throwingNew -permissive- -Zc:wchar_t-" fi # CFLAGS C language level for JDK sources (hotspot only uses C++) diff --git a/make/autoconf/jdk-options.m4 b/make/autoconf/jdk-options.m4 index a9863c501a0..77cba5f2ac5 100644 --- a/make/autoconf/jdk-options.m4 +++ b/make/autoconf/jdk-options.m4 @@ -462,6 +462,31 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_ADDRESS_SANITIZER], ############################################################################### # +# Static analyzer +# +AC_DEFUN_ONCE([JDKOPT_SETUP_STATIC_ANALYZER], +[ + UTIL_ARG_ENABLE(NAME: static-analyzer, DEFAULT: false, RESULT: STATIC_ANALYZER_ENABLED, + DESC: [enable the GCC static analyzer], + CHECK_AVAILABLE: [ + AC_MSG_CHECKING([if static analyzer is available]) + if test "x$TOOLCHAIN_TYPE" = "xgcc"; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + AVAILABLE=false + fi + ], + IF_ENABLED: [ + STATIC_ANALYZER_CFLAGS="-fanalyzer -Wno-analyzer-fd-leak" + CFLAGS_JDKLIB="$CFLAGS_JDKLIB $STATIC_ANALYZER_CFLAGS" + CFLAGS_JDKEXE="$CFLAGS_JDKEXE $STATIC_ANALYZER_CFLAGS" + ]) + AC_SUBST(STATIC_ANALYZER_ENABLED) +]) + +################################################################################ +# # LeakSanitizer # AC_DEFUN_ONCE([JDKOPT_SETUP_LEAK_SANITIZER], diff --git a/make/conf/jib-profiles.js b/make/conf/jib-profiles.js index 91ed780e555..886b6ce0418 100644 --- a/make/conf/jib-profiles.js +++ b/make/conf/jib-profiles.js @@ -1080,10 +1080,10 @@ var getJibProfilesProfiles = function (input, common, data) { var getJibProfilesDependencies = function (input, common) { var devkit_platform_revisions = { - linux_x64: "gcc11.2.0-OL6.4+1.0", + linux_x64: "gcc13.2.0-OL6.4+1.0", macosx: "Xcode12.4+1.1", windows_x64: "VS2022-17.1.0+1.1", - linux_aarch64: input.build_cpu == "x64" ? "gcc11.2.0-OL7.6+1.1" : "gcc11.2.0-OL7.6+1.0", + linux_aarch64: "gcc13.2.0-OL7.6+1.0", linux_arm: "gcc8.2.0-Fedora27+1.0", linux_ppc64le: "gcc8.2.0-Fedora27+1.0", linux_s390x: "gcc8.2.0-Fedora27+1.0", diff --git a/make/conf/version-numbers.conf b/make/conf/version-numbers.conf index 107d9b9b6b4..4bfa1e358d3 100644 --- a/make/conf/version-numbers.conf +++ b/make/conf/version-numbers.conf @@ -28,15 +28,15 @@ DEFAULT_VERSION_FEATURE=21 DEFAULT_VERSION_INTERIM=0 -DEFAULT_VERSION_UPDATE=9 +DEFAULT_VERSION_UPDATE=10 DEFAULT_VERSION_PATCH=0 DEFAULT_VERSION_EXTRA1=0 DEFAULT_VERSION_EXTRA2=0 DEFAULT_VERSION_EXTRA3=0 -DEFAULT_VERSION_DATE=2025-10-21 +DEFAULT_VERSION_DATE=2026-01-20 DEFAULT_VERSION_CLASSFILE_MAJOR=65 # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`" DEFAULT_VERSION_CLASSFILE_MINOR=0 DEFAULT_VERSION_DOCS_API_SINCE=11 DEFAULT_ACCEPTABLE_BOOT_VERSIONS="20 21" DEFAULT_JDK_SOURCE_TARGET_VERSION=21 -DEFAULT_PROMOTED_VERSION_PRE= +DEFAULT_PROMOTED_VERSION_PRE=ea diff --git a/make/data/asan/asan_default_options.c b/make/data/asan/asan_default_options.c index 9e0887c5f67..70821045176 100644 --- a/make/data/asan/asan_default_options.c +++ b/make/data/asan/asan_default_options.c @@ -67,6 +67,8 @@ ATTRIBUTE_DEFAULT_VISIBILITY ATTRIBUTE_USED const char* CDECL __asan_default_opt #endif "print_suppressions=0," "handle_segv=0," + // A lot of libjsig related tests fail because of the link order check; so better avoid it + "verify_asan_link_order=0," // See https://github.com/google/sanitizers/issues/1322. Hopefully this is resolved // at some point and we can remove this option. "intercept_tls_get_addr=0"; diff --git a/make/devkit/Tools.gmk b/make/devkit/Tools.gmk index 187320ca26e..5c29ee4db75 100644 --- a/make/devkit/Tools.gmk +++ b/make/devkit/Tools.gmk @@ -55,11 +55,11 @@ KERNEL_HEADERS_RPM := kernel-headers ifeq ($(BASE_OS), OL) ifeq ($(ARCH), aarch64) - BASE_URL := http://yum.oracle.com/repo/OracleLinux/OL7/6/base/$(ARCH)/ + BASE_URL := https://yum.oracle.com/repo/OracleLinux/OL7/6/base/$(ARCH)/ LINUX_VERSION := OL7.6 KERNEL_HEADERS_RPM := kernel-uek-headers else - BASE_URL := http://yum.oracle.com/repo/OracleLinux/OL6/4/base/$(ARCH)/ + BASE_URL := https://yum.oracle.com/repo/OracleLinux/OL6/4/base/$(ARCH)/ LINUX_VERSION := OL6.4 endif else ifeq ($(BASE_OS), Fedora) @@ -96,8 +96,17 @@ endif # Define external dependencies # Latest that could be made to work. -GCC_VER := 11.3.0 -ifeq ($(GCC_VER), 11.3.0) +GCC_VER := 13.2.0 +ifeq ($(GCC_VER), 13.2.0) + gcc_ver := gcc-13.2.0 + binutils_ver := binutils-2.41 + ccache_ver := ccache-3.7.12 + mpfr_ver := mpfr-4.2.0 + gmp_ver := gmp-6.3.0 + mpc_ver := mpc-1.3.1 + gdb_ver := gdb-13.2 + REQUIRED_MIN_MAKE_MAJOR_VERSION := 4 +else ifeq ($(GCC_VER), 11.3.0) gcc_ver := gcc-11.3.0 binutils_ver := binutils-2.39 ccache_ver := ccache-3.7.12 @@ -671,7 +680,11 @@ $(PREFIX)/Tools.gmk: ./Tools.gmk rm -rf $@ cp $< $@ -THESE_MAKEFILES := $(PREFIX)/Makefile $(PREFIX)/Tools.gmk +$(PREFIX)/Tars.gmk: ./Tars.gmk + rm -rf $@ + cp $< $@ + +THESE_MAKEFILES := $(PREFIX)/Makefile $(PREFIX)/Tools.gmk $(PREFIX)/Tars.gmk ########################################################################################## diff --git a/make/ide/netbeans/langtools/build.xml b/make/ide/netbeans/langtools/build.xml index b23614649b8..f417b256eb6 100644 --- a/make/ide/netbeans/langtools/build.xml +++ b/make/ide/netbeans/langtools/build.xml @@ -1,6 +1,6 @@ - - -
-See the dialog box (usually in upper left corner) for instructions
- - diff --git a/test/jdk/java/awt/Cursor/MultiResolutionCursorTest/MultiResolutionCursorTest.java b/test/jdk/java/awt/Cursor/MultiResolutionCursorTest/MultiResolutionCursorTest.java deleted file mode 100644 index 6821f9c55e6..00000000000 --- a/test/jdk/java/awt/Cursor/MultiResolutionCursorTest/MultiResolutionCursorTest.java +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Copyright (c) 2013, 2018, 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. - * - * 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 java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Cursor; -import java.awt.Dialog; -import java.awt.Frame; -import java.awt.Graphics2D; -import java.awt.Image; -import java.awt.Label; -import java.awt.Point; -import java.awt.TextArea; -import java.awt.Toolkit; -import java.awt.image.BaseMultiResolutionImage; -import java.awt.image.BufferedImage; -import javax.swing.JApplet; - -import jdk.test.lib.Platform; - -/** - * @test - * @bug 8028212 - * @summary [macosx] Custom Cursor HiDPI support - * @author Alexander Scherbatiy - * @library /test/lib - * @modules java.desktop/sun.awt.image - * @build jdk.test.lib.Platform - * @run applet/manual=yesno MultiResolutionCursorTest.html - */ -public class MultiResolutionCursorTest extends JApplet { - //Declare things used in the test, like buttons and labels here - - static final int sizes[] = {8, 16, 32, 128}; - static final Color colors[] = {Color.WHITE, Color.RED, Color.GREEN, Color.BLUE}; - - public void init() { - //Create instructions for the user here, as well as set up - // the environment -- set the layout manager, add buttons, - // etc. - this.setLayout(new BorderLayout()); - - if (Platform.isOSX()) { - String[] instructions = { - "Verify that high resolution custom cursor is used" - + " on HiDPI displays.", - "1) Run the test on Retina display or enable the Quartz Debug" - + " and select the screen resolution with (HiDPI) label", - "2) Move the cursor to the Test Frame", - "3) Check that cursor has red, green or blue color", - "If so, press PASS, else press FAIL." - }; - Sysout.createDialogWithInstructions(instructions); - - } else { - String[] instructions = { - "This test is not applicable to the current platform. Press PASS." - }; - Sysout.createDialogWithInstructions(instructions); - } - }//End init() - - public void start() { - //Get things going. Request focus, set size, et cetera - setSize(200, 200); - setVisible(true); - validate(); - - final Image image = new BaseMultiResolutionImage( - createResolutionVariant(0), - createResolutionVariant(1), - createResolutionVariant(2), - createResolutionVariant(3) - ); - - int center = sizes[0] / 2; - Cursor cursor = Toolkit.getDefaultToolkit().createCustomCursor( - image, new Point(center, center), "multi-resolution cursor"); - - Frame frame = new Frame("Test Frame"); - frame.setSize(300, 300); - frame.setLocation(300, 50); - frame.add(new Label("Move cursor here")); - frame.setCursor(cursor); - frame.setVisible(true); - }// start() - - static BufferedImage createResolutionVariant(int i) { - BufferedImage resolutionVariant = new BufferedImage(sizes[i], sizes[i], - BufferedImage.TYPE_INT_RGB); - Graphics2D g2 = resolutionVariant.createGraphics(); - g2.setColor(colors[i]); - g2.fillRect(0, 0, sizes[i], sizes[i]); - g2.dispose(); - return resolutionVariant; - } -}// class BlockedWindowTest - -/* Place other classes related to the test after this line */ -/** - * ************************************************** - * Standard Test Machinery DO NOT modify anything below -- it's a standard chunk - * of code whose purpose is to make user interaction uniform, and thereby make - * it simpler to read and understand someone else's test. - * ************************************************** - */ -/** - * This is part of the standard test machinery. It creates a dialog (with the - * instructions), and is the interface for sending text messages to the user. To - * print the instructions, send an array of strings to Sysout.createDialog - * WithInstructions method. Put one line of instructions per array entry. To - * display a message for the tester to see, simply call Sysout.println with the - * string to be displayed. This mimics System.out.println but works within the - * test harness as well as standalone. - */ -class Sysout { - - private static TestDialog dialog; - - public static void createDialogWithInstructions(String[] instructions) { - dialog = new TestDialog(new Frame(), "Instructions"); - dialog.printInstructions(instructions); - dialog.setVisible(true); - println("Any messages for the tester will display here."); - } - - public static void createDialog() { - dialog = new TestDialog(new Frame(), "Instructions"); - String[] defInstr = {"Instructions will appear here. ", ""}; - dialog.printInstructions(defInstr); - dialog.setVisible(true); - println("Any messages for the tester will display here."); - } - - public static void printInstructions(String[] instructions) { - dialog.printInstructions(instructions); - } - - public static void println(String messageIn) { - dialog.displayMessage(messageIn); - } -}// Sysout class - -/** - * This is part of the standard test machinery. It provides a place for the test - * instructions to be displayed, and a place for interactive messages to the - * user to be displayed. To have the test instructions displayed, see Sysout. To - * have a message to the user be displayed, see Sysout. Do not call anything in - * this dialog directly. - */ -class TestDialog extends Dialog { - - TextArea instructionsText; - TextArea messageText; - int maxStringLength = 80; - - //DO NOT call this directly, go through Sysout - public TestDialog(Frame frame, String name) { - super(frame, name); - int scrollBoth = TextArea.SCROLLBARS_BOTH; - instructionsText = new TextArea("", 15, maxStringLength, scrollBoth); - add("North", instructionsText); - - messageText = new TextArea("", 5, maxStringLength, scrollBoth); - add("Center", messageText); - - pack(); - - setVisible(true); - }// TestDialog() - - //DO NOT call this directly, go through Sysout - public void printInstructions(String[] instructions) { - //Clear out any current instructions - instructionsText.setText(""); - - //Go down array of instruction strings - - String printStr, remainingStr; - for (int i = 0; i < instructions.length; i++) { - //chop up each into pieces maxSringLength long - remainingStr = instructions[ i]; - while (remainingStr.length() > 0) { - //if longer than max then chop off first max chars to print - if (remainingStr.length() >= maxStringLength) { - //Try to chop on a word boundary - int posOfSpace = remainingStr.lastIndexOf(' ', maxStringLength - 1); - - if (posOfSpace <= 0) { - posOfSpace = maxStringLength - 1; - } - - printStr = remainingStr.substring(0, posOfSpace + 1); - remainingStr = remainingStr.substring(posOfSpace + 1); - } //else just print - else { - printStr = remainingStr; - remainingStr = ""; - } - - instructionsText.append(printStr + "\n"); - - }// while - - }// for - - }//printInstructions() - - //DO NOT call this directly, go through Sysout - public void displayMessage(String messageIn) { - messageText.append(messageIn + "\n"); - System.out.println(messageIn); - } -}// Te diff --git a/test/jdk/java/awt/DesktopProperties/FontSmoothing.java b/test/jdk/java/awt/DesktopProperties/FontSmoothing.java new file mode 100644 index 00000000000..d3879d4893f --- /dev/null +++ b/test/jdk/java/awt/DesktopProperties/FontSmoothing.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2003, 2024, 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. + * + * 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 java.awt.Frame; +import java.awt.Toolkit; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +/* + * @test + * @bug 4808569 + * @requires (os.family == "windows") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @summary add desktop property for the Windows XP or later font smoothing settings + * @run main/manual FontSmoothing + */ + +public class FontSmoothing { + + private static final String PROP_NAME = "win.text.fontSmoothingType"; + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + This test should be run on Windows XP or later. + + On Windows 11: + 1. Open Run dialog by typing 'run' in search bar. + 2. Type 'cttune' and press Ok. + 3. Uncheck the "Turn On ClearType" checkbox and follow next instructions on screen. + 4. Repeat Step 1-2. + 5. Check the "Turn On ClearType" checkbox and follow next instructions on screen. + 6. Take a look at the output window to determine if the test passed or failed. + """; + + PassFailJFrame.builder() + .title("FontSmoothing Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(40) + .testTimeOut(5) + .testUI(FontSmoothing::createUI) + .logArea(8) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + Frame f = new Frame("FontSmoothing Test"); + f.setSize(50, 50); + + Object value = Toolkit.getDefaultToolkit().getDesktopProperty(PROP_NAME); + PassFailJFrame.log("toolkit.getDesktopProperty: " + PROP_NAME + " = " + value + "\n"); + + Toolkit.getDefaultToolkit().addPropertyChangeListener(PROP_NAME, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent e) { + PassFailJFrame.log("PropertyChangeEvent: " + e.getPropertyName() + + "\n old value=" + e.getOldValue() + + "\n new value=" + e.getNewValue()); + + Integer value = (Integer) Toolkit.getDefaultToolkit().getDesktopProperty(PROP_NAME); + PassFailJFrame.log("toolkit.getDesktopProperty:" + PROP_NAME + "=" + value); + + if (value.equals((Integer) e.getNewValue())) { + PassFailJFrame.log("test PASSED"); + } else { + PassFailJFrame.log("test FAILED"); + } + } + }); + return f; + } +} diff --git a/test/jdk/java/awt/DesktopProperties/ThreeDBackgroundColor.java b/test/jdk/java/awt/DesktopProperties/ThreeDBackgroundColor.java new file mode 100644 index 00000000000..26792e79a92 --- /dev/null +++ b/test/jdk/java/awt/DesktopProperties/ThreeDBackgroundColor.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2000, 2024, 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. + * + * 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 java.awt.Color; +import java.awt.Frame; +import java.awt.Toolkit; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; + +/* + * @test + * @bug 4368193 + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @requires (os.family == "windows") + * @summary Toolkit's getDesktopProperty returns stale values on Microsoft Windows + * @run main/manual ThreeDBackgroundColor + */ + +public class ThreeDBackgroundColor { + + private static final String PROP_NAME = "win.3d.backgroundColor"; + + public static void main(String[] args) throws Exception { + String INSTRUCTIONS = """ + On Windows 10: + 1. Open Windows Settings, in the search bar type + 'high contrast', in the list of suggestions choose option + 'Turn high contrast on or off' + 2. In the High contrast control panel click on the on/off switch + to initialize High contrast mode + 3. Wait for the High contrast mode to finish initialization + 4. Click on the same switch again to turn off High contrast mode + + On Windows 11: + 1. Open Windows settings, in the search bar type + 'Contrast Theme'. + 2. Select any value from 'Contrast themes' dropdown menu and press 'Apply'. + 3. Wait for the High contrast mode to finish initialization + 4. Select 'None' from 'Contrast themes' dropdown menu to revert the changes. + + Take a look at the output window to determine if the test passed or failed."""; + + PassFailJFrame.builder() + .title("ThreeDBackgroundColor Test Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 2) + .columns(40) + .testTimeOut(5) + .testUI(ThreeDBackgroundColor::createUI) + .logArea(8) + .build() + .awaitAndCheck(); + } + + private static Frame createUI() { + Frame f = new Frame("ThreeDBackgroundColor Test"); + f.setSize(50, 50); + + Object value = Toolkit.getDefaultToolkit().getDesktopProperty(PROP_NAME); + PassFailJFrame.log("toolkit.getDesktopProperty:" + PROP_NAME + "=" + value); + + Toolkit.getDefaultToolkit().addPropertyChangeListener(PROP_NAME, new PropertyChangeListener() { + public void propertyChange(PropertyChangeEvent e) { + PassFailJFrame.log("PropertyChangeEvent: " + e.getPropertyName() + + "\n old value=" + e.getOldValue() + + "\n new value=" + e.getNewValue()); + + Color value = (Color) Toolkit.getDefaultToolkit().getDesktopProperty(PROP_NAME); + PassFailJFrame.log("toolkit.getDesktopProperty:" + PROP_NAME + "=" + value); + if (value.equals((Color) e.getNewValue())) { + PassFailJFrame.log("test PASSED"); + } else { + PassFailJFrame.log("test FAILED"); + } + } + }); + return f; + } +} diff --git a/test/jdk/java/awt/FileDialog/DoubleActionESC.java b/test/jdk/java/awt/FileDialog/DoubleActionESC.java index 748c3aeb5e4..e8bb4963aa0 100644 --- a/test/jdk/java/awt/FileDialog/DoubleActionESC.java +++ b/test/jdk/java/awt/FileDialog/DoubleActionESC.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2025, 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 @@ -34,12 +34,15 @@ import java.awt.event.KeyEvent; import java.util.concurrent.CountDownLatch; +import static java.util.concurrent.TimeUnit.SECONDS; + /* * @test * @bug 5097243 * @summary Tests that FileDialog can be closed by ESC any time * @key headful * @run main DoubleActionESC + * @run main/othervm -Dsun.awt.disableGtkFileDialogs=true DoubleActionESC */ public class DoubleActionESC { @@ -49,47 +52,48 @@ public class DoubleActionESC { private static Robot robot; private static volatile Point p; private static volatile Dimension d; - private static volatile CountDownLatch latch; private static final int REPEAT_COUNT = 2; + private static final long LATCH_TIMEOUT = 10; - public static void main(String[] args) throws Exception { - latch = new CountDownLatch(1); + private static final CountDownLatch latch = new CountDownLatch(REPEAT_COUNT); + public static void main(String[] args) throws Exception { robot = new Robot(); - robot.setAutoDelay(100); + robot.setAutoDelay(50); try { EventQueue.invokeAndWait(() -> { createAndShowUI(); }); + robot.waitForIdle(); robot.delay(1000); + EventQueue.invokeAndWait(() -> { p = showBtn.getLocationOnScreen(); d = showBtn.getSize(); }); for (int i = 0; i < REPEAT_COUNT; ++i) { - Thread thread = new Thread(() -> { - robot.mouseMove(p.x + d.width / 2, p.y + d.height / 2); - robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); - robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); - }); - thread.start(); - robot.delay(3000); + robot.mouseMove(p.x + d.width / 2, p.y + d.height / 2); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(); + robot.delay(1000); - Thread thread1 = new Thread(() -> { - robot.keyPress(KeyEvent.VK_ESCAPE); - robot.keyRelease(KeyEvent.VK_ESCAPE); - robot.waitForIdle(); - }); - thread1.start(); - robot.delay(3000); + robot.keyPress(KeyEvent.VK_ESCAPE); + robot.keyRelease(KeyEvent.VK_ESCAPE); + robot.waitForIdle(); + robot.delay(1000); } - latch.await(); - if (fd.isVisible()) { - throw new RuntimeException("File Dialog is not closed"); + if (!latch.await(LATCH_TIMEOUT, SECONDS)) { + throw new RuntimeException("Test failed: Latch timeout reached"); } + EventQueue.invokeAndWait(() -> { + if (fd.isVisible()) { + throw new RuntimeException("File Dialog is not closed"); + } + }); } finally { EventQueue.invokeAndWait(() -> { if (f != null) { diff --git a/test/jdk/java/awt/Focus/ComponentLostFocusTest.java b/test/jdk/java/awt/Focus/ComponentLostFocusTest.java index 6af8322b2cd..8045ace43d5 100644 --- a/test/jdk/java/awt/Focus/ComponentLostFocusTest.java +++ b/test/jdk/java/awt/Focus/ComponentLostFocusTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2025, 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 @@ -35,13 +35,20 @@ import java.awt.Frame; import java.awt.KeyboardFocusManager; import java.awt.Point; +import java.awt.Rectangle; import java.awt.Robot; import java.awt.TextField; +import java.awt.Toolkit; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.awt.event.InputEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import java.io.File; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +import javax.imageio.ImageIO; public class ComponentLostFocusTest { @@ -49,10 +56,10 @@ public class ComponentLostFocusTest { static TextField tf; static Robot r; static Dialog dialog = null; - static volatile boolean passed; static volatile Point loc; static volatile int width; static volatile int top; + static final CountDownLatch focusGainedLatch = new CountDownLatch(1); private static void createTestUI() { @@ -75,11 +82,7 @@ public void windowGainedFocus(WindowEvent e) { public static void doTest() { System.out.println("dialog.setVisible.... "); - new Thread(new Runnable() { - public void run() { - dialog.setVisible(true); - } - }).start(); + new Thread(() -> dialog.setVisible(true)).start(); // The bug is that this construction leads to the redundant xRequestFocus // By the way, the requestFocusInWindow() works fine before the fix @@ -98,7 +101,7 @@ public void run() { tf.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { System.out.println("TextField gained focus: " + e); - passed = true; + focusGainedLatch.countDown(); } }); @@ -116,6 +119,17 @@ private static void doRequestFocusToTextField() { tf.requestFocus(); } + private static void captureScreen() { + try { + final Rectangle screenBounds = new Rectangle( + Toolkit.getDefaultToolkit().getScreenSize()); + ImageIO.write(r.createScreenCapture(screenBounds), + "png", new File("ComponentLostFocusTest.png")); + } catch (Exception e) { + e.printStackTrace(); + } + } + public static final void main(String args[]) throws Exception { r = new Robot(); r.setAutoDelay(100); @@ -138,9 +152,10 @@ public static final void main(String args[]) throws Exception { System.out.println("Focus owner: " + KeyboardFocusManager.getCurrentKeyboardFocusManager(). getFocusOwner()); - - if (!passed) { - throw new RuntimeException("TextField got no focus! Test failed."); + if (!focusGainedLatch.await(5, TimeUnit.SECONDS)) { + captureScreen(); + throw new RuntimeException("Waited too long, " + + "TextField got no focus! Test failed."); } } finally { EventQueue.invokeAndWait(() -> { @@ -151,4 +166,3 @@ public static final void main(String args[]) throws Exception { } } } - diff --git a/test/jdk/java/awt/Focus/MinimizeNonfocusableWindowTest.java b/test/jdk/java/awt/Focus/MinimizeNonfocusableWindowTest.java new file mode 100644 index 00000000000..3114850dc7a --- /dev/null +++ b/test/jdk/java/awt/Focus/MinimizeNonfocusableWindowTest.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2011, 2024, 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. + * + * 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 6399659 + * @summary When minimizing non-focusable window focus shouldn't jump out of the focused window. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual MinimizeNonfocusableWindowTest +*/ + +import java.awt.Frame; +import java.awt.Window; +import java.util.List; + +public class MinimizeNonfocusableWindowTest { + + private static final String INSTRUCTIONS = """ + + You should see three frames: Frame-1, Frame-2 and Unfocusable. + + 1. Click Frame-1 to make it focused window, then click Frame-2. + Minimize Unfocusable frame with the mouse. If Frame-2 is still + the focused window continue testing, otherwise press FAIL. + + 2. Restore Unfocusable frame to normal state. Try to resize by dragging + its edge with left mouse button. It should be resizable. If not press + FAIL. Try the same with right mouse button. It shouldn't resize. + If it does, press FAIL, otherwise press PASS."""; + + public static void main(String[] args) throws Exception { + PassFailJFrame.builder() + .title("MinimizeNonfocusableWindowTest Instructions") + .instructions(INSTRUCTIONS) + .rows((int) INSTRUCTIONS.lines().count() + 1) + .columns(40) + .testUI(MinimizeNonfocusableWindowTest::createTestUI) + .build() + .awaitAndCheck(); + } + + private static ListSee the dialog box (usually in upper left corner) for instructions
- - - - diff --git a/test/jdk/java/awt/Frame/ShownOnPack/ShownOnPack.java b/test/jdk/java/awt/Frame/ShownOnPack/ShownOnPack.java index a5763d0bed2..5e591bfe0a6 100644 --- a/test/jdk/java/awt/Frame/ShownOnPack/ShownOnPack.java +++ b/test/jdk/java/awt/Frame/ShownOnPack/ShownOnPack.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, 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 @@ -21,208 +21,48 @@ * questions. */ +import java.awt.EventQueue; +import java.awt.Frame; + /* - test - @bug 6525850 - @summary Iconified frame gets shown after pack() - @author anthony.petrov@...: area=awt.toplevel - @run applet/manual=yesno ShownOnPack.html + * @test + * @bug 6525850 + * @summary Iconified frame gets shown after pack() + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ShownOnPack */ - -/** - * ShownOnPack.java - * - * summary: - */ - -import java.applet.Applet; -import java.awt.*; - -public class ShownOnPack extends Applet -{ - //Declare things used in the test, like buttons and labels here - Frame f; - - public void init() - { - //Create instructions for the user here, as well as set up - // the environment -- set the layout manager, add buttons, - // etc. - this.setLayout (new BorderLayout ()); - - String[] instructions = - { - "This test creates an invisible and iconified frame that should not become visible.", - "If you observe the window titled 'Should NOT BE SHOWN' in the taskbar, press FAIL,", - "else press PASS" - }; - Sysout.createDialogWithInstructions( instructions ); - - }//End init() - - public void start () - { - //Get things going. Request focus, set size, et cetera - setSize (200,200); - setVisible(true); - validate(); - - //What would normally go into main() will probably go here. - //Use System.out.println for diagnostic messages that you want - // to read after the test is done. - //Use Sysout.println for messages you want the tester to read. - f = new Frame("Should NOT BE SHOWN"); - f.setExtendedState(Frame.ICONIFIED); - f.pack(); - }// start() - - //The rest of this class is the actions which perform the test... - - //Use Sysout.println to communicate with the user NOT System.out!! - //Sysout.println ("Something Happened!"); - -}// class ShownOnPack - -/* Place other classes related to the test after this line */ - - - - - -/**************************************************** - Standard Test Machinery - DO NOT modify anything below -- it's a standard - chunk of code whose purpose is to make user - interaction uniform, and thereby make it simpler - to read and understand someone else's test. - ****************************************************/ - -/** - This is part of the standard test machinery. - It creates a dialog (with the instructions), and is the interface - for sending text messages to the user. - To print the instructions, send an array of strings to Sysout.createDialog - WithInstructions method. Put one line of instructions per array entry. - To display a message for the tester to see, simply call Sysout.println - with the string to be displayed. - This mimics System.out.println but works within the test harness as well - as standalone. - */ - -class Sysout -{ - private static TestDialog dialog; - - public static void createDialogWithInstructions( String[] instructions ) - { - dialog = new TestDialog( new Frame(), "Instructions" ); - dialog.printInstructions( instructions ); - dialog.setVisible(true); - println( "Any messages for the tester will display here." ); - } - - public static void createDialog( ) - { - dialog = new TestDialog( new Frame(), "Instructions" ); - String[] defInstr = { "Instructions will appear here. ", "" } ; - dialog.printInstructions( defInstr ); - dialog.setVisible(true); - println( "Any messages for the tester will display here." ); +public class ShownOnPack { + + private static final String INSTRUCTIONS = """ + This test creates an invisible and iconified frame that should not become visible. + + If you observe the window titled 'Should NOT BE SHOWN' in the taskbar, + press FAIL, otherwise press PASS + """; + + static Frame frame; + + public static void main(String[] args) throws Exception { + PassFailJFrame shownOnPackInstructions = PassFailJFrame + .builder() + .title("ShownOnPack Instructions") + .instructions(INSTRUCTIONS) + .rows(5) + .columns(50) + .build(); + + EventQueue.invokeAndWait(() -> { + frame = new Frame("Should NOT BE SHOWN"); + frame.setExtendedState(Frame.ICONIFIED); + frame.pack(); + }); + + try { + shownOnPackInstructions.awaitAndCheck(); + } finally { + EventQueue.invokeAndWait(() -> frame.dispose()); + } } - - - public static void printInstructions( String[] instructions ) - { - dialog.printInstructions( instructions ); - } - - - public static void println( String messageIn ) - { - dialog.displayMessage( messageIn ); - } - -}// Sysout class - -/** - This is part of the standard test machinery. It provides a place for the - test instructions to be displayed, and a place for interactive messages - to the user to be displayed. - To have the test instructions displayed, see Sysout. - To have a message to the user be displayed, see Sysout. - Do not call anything in this dialog directly. - */ -class TestDialog extends Dialog -{ - - TextArea instructionsText; - TextArea messageText; - int maxStringLength = 80; - - //DO NOT call this directly, go through Sysout - public TestDialog( Frame frame, String name ) - { - super( frame, name ); - int scrollBoth = TextArea.SCROLLBARS_BOTH; - instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth ); - add( "North", instructionsText ); - - messageText = new TextArea( "", 5, maxStringLength, scrollBoth ); - add("Center", messageText); - - pack(); - - setVisible(true); - }// TestDialog() - - //DO NOT call this directly, go through Sysout - public void printInstructions( String[] instructions ) - { - //Clear out any current instructions - instructionsText.setText( "" ); - - //Go down array of instruction strings - - String printStr, remainingStr; - for( int i=0; i < instructions.length; i++ ) - { - //chop up each into pieces maxSringLength long - remainingStr = instructions[ i ]; - while( remainingStr.length() > 0 ) - { - //if longer than max then chop off first max chars to print - if( remainingStr.length() >= maxStringLength ) - { - //Try to chop on a word boundary - int posOfSpace = remainingStr. - lastIndexOf( ' ', maxStringLength - 1 ); - - if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1; - - printStr = remainingStr.substring( 0, posOfSpace + 1 ); - remainingStr = remainingStr.substring( posOfSpace + 1 ); - } - //else just print - else - { - printStr = remainingStr; - remainingStr = ""; - } - - instructionsText.append( printStr + "\n" ); - - }// while - - }// for - - }//printInstructions() - - //DO NOT call this directly, go through Sysout - public void displayMessage( String messageIn ) - { - messageText.append( messageIn + "\n" ); - System.out.println(messageIn); - } - -}// TestDialog class +} diff --git a/test/jdk/java/awt/FullScreen/NonfocusableFrameFullScreenTest.java b/test/jdk/java/awt/FullScreen/NonfocusableFrameFullScreenTest.java new file mode 100644 index 00000000000..a273adff6cc --- /dev/null +++ b/test/jdk/java/awt/FullScreen/NonfocusableFrameFullScreenTest.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2005, 2025, 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. + * + * 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 java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.GraphicsEnvironment; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JPanel; + +/* + * @test + * @bug 6225472 6682536 + * @requires (os.family != "linux") + * @summary Tests that non-focusable Frame in full-screen mode overlaps the task bar. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual NonfocusableFrameFullScreenTest + */ + +public class NonfocusableFrameFullScreenTest extends JPanel { + boolean fullscreen = false; + + public static void main(String[] args) throws Exception { + final String INSTRUCTIONS = """ + 1. Press "Show Frame" button to show a Frame with two buttons. + + 2. Press the button "To Full Screen" to bring the frame to + full-screen mode: + + The frame should overlap the taskbar + + 3. Press "To Windowed" button: + The frame should return to its original size. + The frame shouldn't be alwaysOnTop. + + 4. Press "Set Always On Top" button and make sure the frame + is alwaysOnTop, then press "To Full Screen" button + and then "To Windowed" button: + + The frame should return to its original size keeping alwaysOnTop + state on. + + Press Pass if everything is as expected."""; + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .columns(45) + .testUI(NonfocusableFrameFullScreenTest::new) + .build() + .awaitAndCheck(); + } + + private NonfocusableFrameFullScreenTest() { + Button b = new Button("Show Frame"); + b.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + showFrame(); + } + }); + setLayout(new BorderLayout()); + add(b, BorderLayout.CENTER); + } + + @Override + public Dimension getPreferredSize() { + return new Dimension(200, 100); + } + + public void showFrame() { + Frame frame = new Frame("Test Frame"); + + Button button = new Button("To Full Screen"); + button.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (fullscreen) { + GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(). + setFullScreenWindow(null); + button.setLabel("To Full Screen"); + fullscreen = false; + } else { + GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(). + setFullScreenWindow(frame); + button.setLabel("To Windowed"); + fullscreen = true; + } + frame.validate(); + } + }); + + Button button2 = new Button("Set Always On Top"); + button2.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (frame.isAlwaysOnTop()) { + button2.setLabel("Set Always On Top"); + frame.setAlwaysOnTop(false); + } else { + button2.setLabel("Set Not Always On Top"); + frame.setAlwaysOnTop(true); + } + frame.validate(); + } + }); + + frame.setLayout(new BorderLayout()); + frame.add(button, BorderLayout.WEST); + frame.add(button2, BorderLayout.EAST); + frame.setBounds(400, 200, 350, 100); + frame.setFocusableWindowState(false); + frame.setVisible(true); + } +} diff --git a/test/jdk/java/awt/Graphics/GDIResourceExhaustionTest.java b/test/jdk/java/awt/Graphics/GDIResourceExhaustionTest.java new file mode 100644 index 00000000000..b8ba155da60 --- /dev/null +++ b/test/jdk/java/awt/Graphics/GDIResourceExhaustionTest.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 1999, 2025, 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. + * + * 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.imageio.ImageIO; +import java.awt.AWTException; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Insets; +import java.awt.Label; +import java.awt.Panel; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Robot; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; + +/* + * @test + * @bug 4191297 + * @summary Tests that unreferenced GDI resources are correctly + * destroyed when no longer needed. + * @key headful + * @run main GDIResourceExhaustionTest + */ + +public class GDIResourceExhaustionTest extends Frame { + public void initUI() { + setSize(200, 200); + setUndecorated(true); + setLocationRelativeTo(null); + Panel labelPanel = new Panel(); + Label label = new Label("Red label"); + label.setBackground(Color.red); + labelPanel.add(label); + labelPanel.setLocation(20, 50); + add(labelPanel); + setVisible(true); + } + + public void paint(Graphics graphics) { + super.paint(graphics); + for (int rgb = 0; rgb <= 0xfff; rgb++) { + graphics.setColor(new Color(rgb)); + graphics.fillRect(0, 0, 5, 5); + } + } + + public void requestCoordinates(Rectangle r) { + Insets insets = getInsets(); + Point location = getLocationOnScreen(); + Dimension size = getSize(); + r.x = location.x + insets.left; + r.y = location.y + insets.top; + r.width = size.width - (insets.left + insets.right); + r.height = size.height - (insets.top + insets.bottom); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException, AWTException, IOException { + GDIResourceExhaustionTest test = new GDIResourceExhaustionTest(); + try { + EventQueue.invokeAndWait(test::initUI); + Robot robot = new Robot(); + robot.delay(2000); + Rectangle coords = new Rectangle(); + EventQueue.invokeAndWait(() -> { + test.requestCoordinates(coords); + }); + robot.mouseMove(coords.x - 50, coords.y - 50); + robot.waitForIdle(); + robot.delay(5000); + BufferedImage capture = robot.createScreenCapture(coords); + robot.delay(500); + boolean redFound = false; + int redRGB = Color.red.getRGB(); + for (int y = 0; y < capture.getHeight(); y++) { + for (int x = 0; x < capture.getWidth(); x++) { + if (capture.getRGB(x, y) == redRGB) { + redFound = true; + break; + } + if (redFound) { + break; + } + } + } + if (!redFound) { + File errorImage = new File("screenshot.png"); + ImageIO.write(capture, "png", errorImage); + throw new RuntimeException("Red label is not detected, possibly GDI resources exhausted"); + } + } finally { + EventQueue.invokeAndWait(test::dispose); + } + } +} diff --git a/test/jdk/java/awt/Graphics/RepeatedRepaintTest.java b/test/jdk/java/awt/Graphics/RepeatedRepaintTest.java new file mode 100644 index 00000000000..140cb48630d --- /dev/null +++ b/test/jdk/java/awt/Graphics/RepeatedRepaintTest.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 1998, 2025, 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. + * + * 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 java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.image.BufferedImage; +import java.lang.reflect.InvocationTargetException; + +/* + * @test + * @bug 4081126 4129709 + * @summary Test for proper repainting on multiprocessor systems. + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual RepeatedRepaintTest + */ +public class RepeatedRepaintTest extends Frame { + private Font font = null; + private Image background; + + static String INSTRUCTIONS = """ + The frame next to this window called "AWT Draw Test" has + some elements drawn on it. Move this window partially outside of the + screen bounds and then drag it back. Repeat it couple of times. + Drag the instructions window over the frame partially obscuring it. + If after number of attempts the frame content stops repainting + press "Fail", otherwise press "Pass". + """; + + public RepeatedRepaintTest() { + setTitle("AWT Draw Test"); + setSize(300, 300); + background = new BufferedImage(300, 300, BufferedImage.TYPE_INT_ARGB); + Graphics g = background.getGraphics(); + g.setColor(Color.black); + g.fillRect(0, 0, 300, 300); + g.dispose(); + } + + public void paint(Graphics g) { + Dimension dim = this.getSize(); + super.paint(g); + g.drawImage(background, 0, 0, dim.width, dim.height, null); + g.setColor(Color.white); + if (font == null) { + font = new Font("SansSerif", Font.PLAIN, 24); + } + g.setFont(font); + FontMetrics metrics = g.getFontMetrics(); + String message = "Draw Test"; + g.drawString(message, (dim.width / 2) - (metrics.stringWidth(message) / 2), + (dim.height / 2) + (metrics.getHeight() / 2)); + + int counter = 50; + for (int i = 0; i < 50; i++) { + counter += 4; + g.drawOval(counter, 50, i, i); + } + + counter = 20; + for (int i = 0; i < 100; i++) { + counter += 4; + g.drawOval(counter, 150, i, i); + } + g.setColor(Color.black); + g.drawLine(0, dim.height - 25, dim.width, dim.height - 25); + g.setColor(Color.gray); + g.drawLine(0, dim.height - 24, dim.width, dim.height - 24); + g.setColor(Color.lightGray); + g.drawLine(0, dim.height - 23, dim.width, dim.height - 23); + g.fillRect(0, dim.height - 22, dim.width, dim.height); + + + g.setXORMode(Color.blue); + g.fillRect(0, 0, 25, dim.height - 26); + g.setColor(Color.red); + g.fillRect(0, 0, 25, dim.height - 26); + g.setColor(Color.green); + g.fillRect(0, 0, 25, dim.height - 26); + g.setPaintMode(); + + Image img = createImage(50, 50); + Graphics imgGraphics = img.getGraphics(); + imgGraphics.setColor(Color.magenta); + imgGraphics.fillRect(0, 0, 50, 50); + imgGraphics.setColor(Color.yellow); + imgGraphics.drawString("offscreen", 0, 20); + imgGraphics.drawString("image", 0, 30); + + g.drawImage(img, dim.width - 100, dim.height - 100, Color.blue, null); + + g.setXORMode(Color.white); + drawAt(g, 100, 100, 50, 50); + drawAt(g, 105, 105, 50, 50); + drawAt(g, 110, 110, 50, 50); + } + + public void drawAt(Graphics g, int x, int y, int width, int height) { + g.setColor(Color.magenta); + g.fillRect(x, y, width, height); + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Repeated Repaint Test Instructions") + .instructions(INSTRUCTIONS) + .testUI(RepeatedRepaintTest::new) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/Graphics/SmallPrimitives.java b/test/jdk/java/awt/Graphics/SmallPrimitives.java new file mode 100644 index 00000000000..7eb267cf0b9 --- /dev/null +++ b/test/jdk/java/awt/Graphics/SmallPrimitives.java @@ -0,0 +1,224 @@ +/* + * Copyright (c) 2002, 2025, 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. + * + * 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 java.awt.Color; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Panel; +import java.awt.Polygon; +import java.awt.geom.GeneralPath; +import java.awt.geom.Line2D; +import java.lang.reflect.InvocationTargetException; + +/* + * @test + * @bug 4411814 4298688 4205762 4524760 4067534 + * @summary Check that Graphics rendering primitives function + * correctly when fed small and degenerate shapes + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual SmallPrimitives + */ + + +public class SmallPrimitives extends Panel { + + static String INSTRUCTIONS = """ + In the borderless frame next to this window there should be a + set of tiny narrow blue polygons painted next to the green rectangles. + If rectangle is vertical the corresponding polygon is painted to the right of it, + if rectangle is horizontal the polygon is painted below it. + The length of the polygon should be roughly the same as the length of the + green rectangle next to it. If size is significantly different or any of the + polygons is not painted press "Fail" otherwise press "Pass". + Note: one may consider using screen magnifier to compare sizes. + """; + + public void paint(Graphics g) { + Dimension d = getSize(); + Polygon p; + GeneralPath gp; + + g.setColor(Color.white); + g.fillRect(0, 0, d.width, d.height); + + // Reposition for horizontal tests (below) + g.translate(0, 20); + + // Reference shapes + g.setColor(Color.green); + g.fillRect(10, 7, 11, 1); + g.fillRect(10, 17, 11, 2); + g.fillRect(10, 27, 11, 1); + g.fillRect(10, 37, 11, 1); + g.fillRect(10, 47, 11, 2); + g.fillRect(10, 57, 11, 2); + g.fillRect(10, 67, 11, 1); + g.fillRect(10, 77, 11, 2); + g.fillRect(10, 87, 11, 1); + g.fillRect(10, 97, 11, 1); + g.fillRect(10, 107, 11, 1); + g.fillRect(10, 117, 6, 1); g.fillRect(20, 117, 6, 1); + + // Potentially problematic test shapes + g.setColor(Color.blue); + g.drawRect(10, 10, 10, 0); + g.drawRect(10, 20, 10, 1); + g.drawRoundRect(10, 30, 10, 0, 0, 0); + g.drawRoundRect(10, 40, 10, 0, 4, 4); + g.drawRoundRect(10, 50, 10, 1, 0, 0); + g.drawRoundRect(10, 60, 10, 1, 4, 4); + g.drawOval(10, 70, 10, 0); + g.drawOval(10, 80, 10, 1); + p = new Polygon(); + p.addPoint(10, 90); + p.addPoint(20, 90); + g.drawPolyline(p.xpoints, p.ypoints, p.npoints); + p = new Polygon(); + p.addPoint(10, 100); + p.addPoint(20, 100); + g.drawPolygon(p.xpoints, p.ypoints, p.npoints); + ((Graphics2D) g).draw(new Line2D.Double(10, 110, 20, 110)); + gp = new GeneralPath(); + gp.moveTo(10, 120); + gp.lineTo(15, 120); + gp.moveTo(20, 120); + gp.lineTo(25, 120); + ((Graphics2D) g).draw(gp); + + // Polygon limit tests + p = new Polygon(); + trypoly(g, p); + p.addPoint(10, 120); + trypoly(g, p); + + // Reposition for vertical tests (below) + g.translate(20, -20); + + // Reference shapes + g.setColor(Color.green); + g.fillRect(7, 10, 1, 11); + g.fillRect(17, 10, 2, 11); + g.fillRect(27, 10, 1, 11); + g.fillRect(37, 10, 1, 11); + g.fillRect(47, 10, 2, 11); + g.fillRect(57, 10, 2, 11); + g.fillRect(67, 10, 1, 11); + g.fillRect(77, 10, 2, 11); + g.fillRect(87, 10, 1, 11); + g.fillRect(97, 10, 1, 11); + g.fillRect(107, 10, 1, 11); + g.fillRect(117, 10, 1, 6); g.fillRect(117, 20, 1, 6); + + // Potentially problematic test shapes + g.setColor(Color.blue); + g.drawRect(10, 10, 0, 10); + g.drawRect(20, 10, 1, 10); + g.drawRoundRect(30, 10, 0, 10, 0, 0); + g.drawRoundRect(40, 10, 0, 10, 4, 4); + g.drawRoundRect(50, 10, 1, 10, 0, 0); + g.drawRoundRect(60, 10, 1, 10, 4, 4); + g.drawOval(70, 10, 0, 10); + g.drawOval(80, 10, 1, 10); + p = new Polygon(); + p.addPoint(90, 10); + p.addPoint(90, 20); + g.drawPolyline(p.xpoints, p.ypoints, p.npoints); + p = new Polygon(); + p.addPoint(100, 10); + p.addPoint(100, 20); + g.drawPolygon(p.xpoints, p.ypoints, p.npoints); + ((Graphics2D) g).draw(new Line2D.Double(110, 10, 110, 20)); + gp = new GeneralPath(); + gp.moveTo(120, 10); + gp.lineTo(120, 15); + gp.moveTo(120, 20); + gp.lineTo(120, 25); + ((Graphics2D) g).draw(gp); + + // Polygon limit tests + p = new Polygon(); + trypoly(g, p); + p.addPoint(110, 10); + trypoly(g, p); + + // Reposition for oval tests + g.translate(0, 20); + + for (int i = 0, xy = 8; i < 11; i++) { + g.setColor(Color.green); + g.fillRect(xy, 5, i, 1); + g.fillRect(5, xy, 1, i); + g.setColor(Color.blue); + g.fillOval(xy, 8, i, 1); + g.fillOval(8, xy, 1, i); + xy += i + 2; + } + + g.translate(10, 10); + for (int i = 0, xy = 9; i < 6; i++) { + g.setColor(Color.green); + g.fillRect(xy, 5, i, 2); + g.fillRect(5, xy, 2, i); + g.setColor(Color.blue); + g.fillOval(xy, 8, i, 2); + g.fillOval(8, xy, 2, i); + xy += i + 2; + } + } + + public static void trypoly(Graphics g, Polygon p) { + g.drawPolygon(p); + g.drawPolygon(p.xpoints, p.ypoints, p.npoints); + g.drawPolyline(p.xpoints, p.ypoints, p.npoints); + g.fillPolygon(p); + g.fillPolygon(p.xpoints, p.ypoints, p.npoints); + } + + public Dimension getPreferredSize() { + return new Dimension(150, 150); + } + + public static Frame createFrame() { + Frame f = new Frame(); + SmallPrimitives sp = new SmallPrimitives(); + sp.setLocation(0, 0); + f.add(sp); + f.setUndecorated(true); + f.pack(); + return f; + } + + public static void main(String argv[]) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Small Primitives Instructions") + .instructions(INSTRUCTIONS) + .columns(60) + .testUI(SmallPrimitives::createFrame) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/Graphics/TextAfterXor.java b/test/jdk/java/awt/Graphics/TextAfterXor.java new file mode 100644 index 00000000000..c9dc56d8b80 --- /dev/null +++ b/test/jdk/java/awt/Graphics/TextAfterXor.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2002, 2025, 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. + * + * 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 java.awt.Color; +import java.awt.Dimension; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Panel; +import java.awt.RenderingHints; +import java.awt.image.VolatileImage; +import java.lang.reflect.InvocationTargetException; + +/* + * @test + * @bug 4505650 + * @summary Check that you can render solid text after doing XOR mode + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual TextAfterXor + */ + +public class TextAfterXor extends Panel { + public static final int TESTW = 300; + public static final int TESTH = 100; + static String INSTRUCTIONS = """ + In the window called "Text After XOR Test" there should be two + composite components, at the bottom of each component the green text + "Test passes if this is green!" should be visible. + + On the top component this text should be green on all platforms. + On the bottom component it is possible that on non-Windows + platforms text can be of other color or not visible at all. + That does not constitute a problem. + + So if platform is Windows and green text appears twice or on any + other platform green text appears at least once press "Pass", + otherwise press "Fail". + """; + + VolatileImage vimg; + + public void paint(Graphics g) { + render(g); + g.drawString("(Drawing to screen)", 10, 60); + if (vimg == null) { + vimg = createVolatileImage(TESTW, TESTH); + } + do { + vimg.validate(null); + Graphics g2 = vimg.getGraphics(); + render(g2); + String not = vimg.getCapabilities().isAccelerated() ? "" : "not "; + g2.drawString("Image was " + not + "accelerated", 10, 55); + g2.drawString("(only matters on Windows)", 10, 65); + g2.dispose(); + g.drawImage(vimg, 0, TESTH, null); + } while (vimg.contentsLost()); + } + + public void render(Graphics g) { + g.setColor(Color.black); + g.fillRect(0, 0, TESTW, TESTH); + g.setColor(Color.white); + g.fillRect(5, 5, TESTW-10, TESTH-10); + + g.setColor(Color.black); + g.drawString("Test only passes if green string appears", 10, 20); + + g.setColor(Color.white); + g.setXORMode(Color.blue); + g.drawRect(30, 30, 10, 10); + g.setPaintMode(); + g.setColor(Color.green); + + ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + g.drawString("Test passes if this is green!", 10, 80); + + g.setColor(Color.black); + } + + public Dimension getPreferredSize() { + return new Dimension(TESTW, TESTH*2); + } + + public static Frame createFrame() { + Frame f = new Frame("Text After XOR Test"); + f.add(new TextAfterXor()); + f.pack(); + return f; + } + + public static void main(String[] args) throws InterruptedException, + InvocationTargetException { + PassFailJFrame.builder() + .title("Text After XOR Instructions") + .instructions(INSTRUCTIONS) + .testUI(TextAfterXor::createFrame) + .build() + .awaitAndCheck(); + } +} diff --git a/test/jdk/java/awt/GridBagLayout/ComponentShortage.java b/test/jdk/java/awt/GridBagLayout/ComponentShortage.java new file mode 100644 index 00000000000..dd641bbf066 --- /dev/null +++ b/test/jdk/java/awt/GridBagLayout/ComponentShortage.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2008, 2025, 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. + * + * 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 4238932 + * @summary JTextField in gridBagLayout does not properly set MinimumSize + * @key headful + * @run main ComponentShortage + */ + +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Robot; +import javax.swing.JFrame; +import javax.swing.JTextField; + +public class ComponentShortage { + static final int WIDTH_REDUCTION = 50; + static JFrame frame; + static JTextField jtf; + static volatile Dimension size; + static volatile Dimension fSize; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + try { + EventQueue.invokeAndWait(() -> { + frame = new JFrame(); + frame.setLayout(new GridBagLayout()); + GridBagConstraints gBC = new GridBagConstraints(); + + gBC.gridx = 1; + gBC.gridy = 0; + gBC.gridwidth = 1; + gBC.gridheight = 1; + gBC.weightx = 1.0; + gBC.weighty = 0.0; + gBC.fill = GridBagConstraints.NONE; + gBC.anchor = GridBagConstraints.NORTHWEST; + jtf = new JTextField(16); + frame.add(jtf, gBC); + frame.pack(); + frame.setVisible(true); + }); + robot.waitForIdle(); + robot.delay(1000); + + EventQueue.invokeAndWait(() -> { + size = jtf.getSize(); + }); + System.out.println("TextField size before Frame's width reduction : " + size); + + EventQueue.invokeAndWait(() -> { + frame.setSize(frame.getSize().width - WIDTH_REDUCTION, frame.getSize().height); + }); + frame.repaint(); + + EventQueue.invokeAndWait(() -> { + size = jtf.getSize(); + fSize = frame.getSize(); + }); + System.out.println("TextField size after Frame's width reduction : " + size); + + if (size.width < fSize.width - WIDTH_REDUCTION) { + throw new RuntimeException("Width of JTextField is too small to be visible."); + } + System.out.println("Test passed."); + } finally { + EventQueue.invokeAndWait(() -> { + if (frame != null) { + frame.dispose(); + } + }); + } + } +} diff --git a/test/jdk/java/awt/Icon/ChildFrameIconTest.java b/test/jdk/java/awt/Icon/ChildFrameIconTest.java new file mode 100644 index 00000000000..6d83fa95acb --- /dev/null +++ b/test/jdk/java/awt/Icon/ChildFrameIconTest.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2000, 2025, 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. + * + * 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 java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JFrame; +import javax.swing.JOptionPane; + +/* + * @test + * @bug 4284610 + * @summary Tests that a child of the non-resizable dialog acquires valid icon. + * @requires (os.family == "windows") + * @library /java/awt/regtesthelpers + * @build PassFailJFrame + * @run main/manual ChildFrameIconTest + */ + +public class ChildFrameIconTest { + public static void main(String[] args) throws Exception { + final String INSTRUCTIONS = """ + Press "Show Dialog" button to open a dialog with this message: + Do you see a coffee cup icon in the upper left corner ? + + Look at the icon in the upper left corner of the message dialog. + + Press Pass if you see default coffee cup icon else press Fail."""; + + PassFailJFrame.builder() + .title("ChildFrameIconTest Instruction") + .instructions(INSTRUCTIONS) + .columns(35) + .testUI(ChildFrameIconTest::createUI) + .build() + .awaitAndCheck(); + } + + private static JFrame createUI() { + JFrame f = new JFrame("ChildFrameIconTest UI"); + JButton b = new JButton("Show Dialog"); + b.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + String msg = "Do you see a coffee cup icon in the upper left corner ?"; + JDialog dlg = new JDialog(f, "Non-resizable JDialog", false); + dlg.setResizable(false); + JOptionPane.showMessageDialog(dlg, msg); + } + }); + f.add(b); + f.setSize(250, 100); + return f; + } +} diff --git a/test/jdk/java/awt/InputMethods/DiacriticsTest/DiacriticsTest.html b/test/jdk/java/awt/InputMethods/DiacriticsTest/DiacriticsTest.html deleted file mode 100644 index 5cf5c91ea71..00000000000 --- a/test/jdk/java/awt/InputMethods/DiacriticsTest/DiacriticsTest.html +++ /dev/null @@ -1,53 +0,0 @@ - - - - -