diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 4186c451b78..678f5a038e2 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -55,7 +55,7 @@ on: jobs: build-macos: name: build - runs-on: macos-13 + runs-on: macos-12 strategy: fail-fast: false diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 78a8e1e0d41..46cae3afbfb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -223,7 +223,7 @@ jobs: uses: ./.github/workflows/build-macos.yml with: platform: macos-x64 - xcode-toolset-version: '14.3.1' + xcode-toolset-version: '13.4.1' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} if: needs.select.outputs.macos-x64 == 'true' @@ -234,7 +234,7 @@ jobs: uses: ./.github/workflows/build-macos.yml with: platform: macos-aarch64 - xcode-toolset-version: '14.3.1' + xcode-toolset-version: '13.4.1' extra-conf-options: '--openjdk-target=aarch64-apple-darwin' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} @@ -298,7 +298,7 @@ jobs: with: platform: macos-x64 bootjdk-platform: macos-x64 - runs-on: macos-13 + runs-on: macos-12 test-windows-x64: name: windows-x64 @@ -341,7 +341,7 @@ jobs: -H 'Accept: application/vnd.github+json' \ -H 'Authorization: Bearer ${{ github.token }}' \ -H 'X-GitHub-Api-Version: 2022-11-28' \ - '${{ github.api_url }}/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts')" + '${{ github.api_url }}/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts?per_page=100')" BUNDLE_ARTIFACT_IDS="$(echo "$ALL_ARTIFACT_IDS" | jq -r -c '.artifacts | map(select(.name|startswith("bundles-"))) | .[].id')" for id in $BUNDLE_ARTIFACT_IDS; do echo "Removing $id" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c3560f2135c..dacf8eaba11 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -127,7 +127,7 @@ jobs: run: | # On macOS we need to install some dependencies for testing brew install make - sudo xcode-select --switch /Applications/Xcode_14.3.1.app/Contents/Developer + sudo xcode-select --switch /Applications/Xcode_13.4.1.app/Contents/Developer # This will make GNU make available as 'make' and not only as 'gmake' echo '/usr/local/opt/make/libexec/gnubin' >> $GITHUB_PATH if: runner.os == 'macOS' diff --git a/.jcheck/conf b/.jcheck/conf index 56362781209..5e870e3f5d6 100644 --- a/.jcheck/conf +++ b/.jcheck/conf @@ -1,7 +1,7 @@ [general] project=jdk-updates jbs=JDK -version=11.0.25 +version=11.0.26 [checks] error=author,committer,reviewers,merge,issues,executable,symlink,message,hg-tag,whitespace,problemlists diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000000..f4c5e7e67cb --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,3 @@ +# JDK Vulnerabilities + +Please follow the process outlined in the [OpenJDK Vulnerability Policy](https://openjdk.org/groups/vulnerability/report) to disclose vulnerabilities in the JDK. diff --git a/make/autoconf/version-numbers b/make/autoconf/version-numbers index fe5e0d9850f..0cb57cdf66b 100644 --- a/make/autoconf/version-numbers +++ b/make/autoconf/version-numbers @@ -28,16 +28,16 @@ DEFAULT_VERSION_FEATURE=11 DEFAULT_VERSION_INTERIM=0 -DEFAULT_VERSION_UPDATE=25 +DEFAULT_VERSION_UPDATE=26 DEFAULT_VERSION_PATCH=0 DEFAULT_VERSION_EXTRA1=0 DEFAULT_VERSION_EXTRA2=0 DEFAULT_VERSION_EXTRA3=0 -DEFAULT_VERSION_DATE=2024-10-15 +DEFAULT_VERSION_DATE=2025-01-21 DEFAULT_VERSION_CLASSFILE_MAJOR=55 # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`" DEFAULT_VERSION_CLASSFILE_MINOR=0 DEFAULT_ACCEPTABLE_BOOT_VERSIONS="10 11" -DEFAULT_PROMOTED_VERSION_PRE= +DEFAULT_PROMOTED_VERSION_PRE=ea LAUNCHER_NAME=openjdk PRODUCT_NAME=OpenJDK diff --git a/make/hotspot/lib/JvmFlags.gmk b/make/hotspot/lib/JvmFlags.gmk index 3246c83155b..1a91eb0079d 100644 --- a/make/hotspot/lib/JvmFlags.gmk +++ b/make/hotspot/lib/JvmFlags.gmk @@ -67,10 +67,12 @@ JVM_CFLAGS_TARGET_DEFINES += \ # ifeq ($(DEBUG_LEVEL), release) + # release builds disable uses of assert macro from . + JVM_CFLAGS_DEBUGLEVEL := -DNDEBUG # For hotspot, release builds differ internally between "optimized" and "product" # in that "optimize" does not define PRODUCT. ifneq ($(HOTSPOT_DEBUG_LEVEL), optimized) - JVM_CFLAGS_DEBUGLEVEL := -DPRODUCT + JVM_CFLAGS_DEBUGLEVEL += -DPRODUCT endif else ifeq ($(DEBUG_LEVEL), fastdebug) JVM_CFLAGS_DEBUGLEVEL := -DASSERT diff --git a/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java b/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java index f02537c305d..ef94e3879cc 100644 --- a/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java +++ b/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -363,33 +363,35 @@ int parseYear(String year, int defaultYear) { } Month parseMonth(String mon) { - switch (mon) { - case "Jan": return Month.JANUARY; - case "Feb": return Month.FEBRUARY; - case "Mar": return Month.MARCH; - case "Apr": return Month.APRIL; - case "May": return Month.MAY; - case "Jun": return Month.JUNE; - case "Jul": return Month.JULY; - case "Aug": return Month.AUGUST; - case "Sep": return Month.SEPTEMBER; - case "Oct": return Month.OCTOBER; - case "Nov": return Month.NOVEMBER; - case "Dec": return Month.DECEMBER; - } + int len = mon.length(); + + if (mon.regionMatches(true, 0, "January", 0, len)) return Month.JANUARY; + if (mon.regionMatches(true, 0, "February", 0, len)) return Month.FEBRUARY; + if (mon.regionMatches(true, 0, "March", 0, len)) return Month.MARCH; + if (mon.regionMatches(true, 0, "April", 0, len)) return Month.APRIL; + if (mon.regionMatches(true, 0, "May", 0, len)) return Month.MAY; + if (mon.regionMatches(true, 0, "June", 0, len)) return Month.JUNE; + if (mon.regionMatches(true, 0, "July", 0, len)) return Month.JULY; + if (mon.regionMatches(true, 0, "August", 0, len)) return Month.AUGUST; + if (mon.regionMatches(true, 0, "September", 0, len)) return Month.SEPTEMBER; + if (mon.regionMatches(true, 0, "October", 0, len)) return Month.OCTOBER; + if (mon.regionMatches(true, 0, "November", 0, len)) return Month.NOVEMBER; + if (mon.regionMatches(true, 0, "December", 0, len)) return Month.DECEMBER; + throw new IllegalArgumentException("Unknown month: " + mon); } DayOfWeek parseDayOfWeek(String dow) { - switch (dow) { - case "Mon": return DayOfWeek.MONDAY; - case "Tue": return DayOfWeek.TUESDAY; - case "Wed": return DayOfWeek.WEDNESDAY; - case "Thu": return DayOfWeek.THURSDAY; - case "Fri": return DayOfWeek.FRIDAY; - case "Sat": return DayOfWeek.SATURDAY; - case "Sun": return DayOfWeek.SUNDAY; - } + int len = dow.length(); + + if (dow.regionMatches(true, 0, "Monday", 0, len)) return DayOfWeek.MONDAY; + if (dow.regionMatches(true, 0, "Tuesday", 0, len)) return DayOfWeek.TUESDAY; + if (dow.regionMatches(true, 0, "Wednesday", 0, len)) return DayOfWeek.WEDNESDAY; + if (dow.regionMatches(true, 0, "Thursday", 0, len)) return DayOfWeek.THURSDAY; + if (dow.regionMatches(true, 0, "Friday", 0, len)) return DayOfWeek.FRIDAY; + if (dow.regionMatches(true, 0, "Saturday", 0, len)) return DayOfWeek.SATURDAY; + if (dow.regionMatches(true, 0, "Sunday", 0, len)) return DayOfWeek.SUNDAY; + throw new IllegalArgumentException("Unknown day-of-week: " + dow); } diff --git a/src/hotspot/share/asm/codeBuffer.cpp b/src/hotspot/share/asm/codeBuffer.cpp index 4912f880564..65b414a38ce 100644 --- a/src/hotspot/share/asm/codeBuffer.cpp +++ b/src/hotspot/share/asm/codeBuffer.cpp @@ -1046,10 +1046,11 @@ class CodeString: public CHeapObj { friend class CodeStrings; const char * _string; CodeString* _next; + CodeString* _prev; intptr_t _offset; ~CodeString() { - assert(_next == NULL, "wrong interface for freeing list"); + assert(_next == NULL && _prev == NULL, "wrong interface for freeing list"); os::free((void*)_string); } @@ -1057,7 +1058,7 @@ class CodeString: public CHeapObj { public: CodeString(const char * string, intptr_t offset = -1) - : _next(NULL), _offset(offset) { + : _next(NULL), _prev(NULL), _offset(offset) { _string = os::strdup(string, mtCode); } @@ -1065,7 +1066,12 @@ class CodeString: public CHeapObj { intptr_t offset() const { assert(_offset >= 0, "offset for non comment?"); return _offset; } CodeString* next() const { return _next; } - void set_next(CodeString* next) { _next = next; } + void set_next(CodeString* next) { + _next = next; + if (next != NULL) { + next->_prev = this; + } + } CodeString* first_comment() { if (is_comment()) { @@ -1093,12 +1099,9 @@ CodeString* CodeStrings::find(intptr_t offset) const { // Convenience for add_comment. CodeString* CodeStrings::find_last(intptr_t offset) const { - CodeString* a = find(offset); - if (a != NULL) { - CodeString* c = NULL; - while (((c = a->next_comment()) != NULL) && (c->offset() == offset)) { - a = c; - } + CodeString* a = _strings_last; + while (a != NULL && !a->is_comment() && a->offset() > offset) { + a = a->_prev; } return a; } @@ -1117,12 +1120,16 @@ void CodeStrings::add_comment(intptr_t offset, const char * comment) { c->set_next(_strings); _strings = c; } + if (c->next() == NULL) { + _strings_last = c; + } } void CodeStrings::assign(CodeStrings& other) { other.check_valid(); assert(is_null(), "Cannot assign onto non-empty CodeStrings"); _strings = other._strings; + _strings_last = other._strings_last; #ifdef ASSERT _defunct = false; #endif @@ -1138,8 +1145,11 @@ void CodeStrings::copy(CodeStrings& other) { assert(is_null(), "Cannot copy onto non-empty CodeStrings"); CodeString* n = other._strings; CodeString** ps = &_strings; + CodeString* prev = NULL; while (n != NULL) { *ps = new CodeString(n->string(),n->offset()); + (*ps)->_prev = prev; + prev = *ps; ps = &((*ps)->_next); n = n->next(); } @@ -1168,6 +1178,10 @@ void CodeStrings::free() { // unlink the node from the list saving a pointer to the next CodeString* p = n->next(); n->set_next(NULL); + if (p != NULL) { + assert(p->_prev == n, "missing prev link"); + p->_prev = NULL; + } delete n; n = p; } @@ -1178,6 +1192,9 @@ const char* CodeStrings::add_string(const char * string) { check_valid(); CodeString* s = new CodeString(string); s->set_next(_strings); + if (_strings == NULL) { + _strings_last = s; + } _strings = s; assert(s->string() != NULL, "should have a string"); return s->string(); diff --git a/src/hotspot/share/asm/codeBuffer.hpp b/src/hotspot/share/asm/codeBuffer.hpp index 2f6b2ed4f1d..01c78fd9a2c 100644 --- a/src/hotspot/share/asm/codeBuffer.hpp +++ b/src/hotspot/share/asm/codeBuffer.hpp @@ -249,6 +249,7 @@ class CodeStrings { private: #ifndef PRODUCT CodeString* _strings; + CodeString* _strings_last; #ifdef ASSERT // Becomes true after copy-out, forbids further use. bool _defunct; // Zero bit pattern is "valid", see memset call in decode_env::decode_env @@ -262,6 +263,7 @@ class CodeStrings { void set_null_and_invalidate() { #ifndef PRODUCT _strings = NULL; + _strings_last = NULL; #ifdef ASSERT _defunct = true; #endif @@ -272,6 +274,7 @@ class CodeStrings { CodeStrings() { #ifndef PRODUCT _strings = NULL; + _strings_last = NULL; #ifdef ASSERT _defunct = false; #endif diff --git a/src/hotspot/share/utilities/vmassert_reinstall.hpp b/src/hotspot/share/utilities/vmassert_reinstall.hpp new file mode 100644 index 00000000000..32d31ac0c4f --- /dev/null +++ b/src/hotspot/share/utilities/vmassert_reinstall.hpp @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2022, 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. + * + */ + +// Intentionally no #include guard. May be included multiple times for effect. + +// See vmassert_uninstall.hpp for usage. + +// Remove possible stdlib assert macro (or any others, for that matter). +#undef assert + +// Reinstall HotSpot's assert macro, if previously defined. +#ifdef vmassert +#define assert(p, ...) vmassert(p, __VA_ARGS__) +#endif + diff --git a/src/hotspot/share/utilities/vmassert_uninstall.hpp b/src/hotspot/share/utilities/vmassert_uninstall.hpp new file mode 100644 index 00000000000..dd6d51633dd --- /dev/null +++ b/src/hotspot/share/utilities/vmassert_uninstall.hpp @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022, 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. + * + */ + +// Intentionally no #include guard. May be included multiple times for effect. + +// The files vmassert_uninstall.hpp and vmassert_reinstall.hpp provide a +// workaround for the name collision between HotSpot's assert macro and the +// Standard Library's assert macro. When including a 3rd-party header that +// uses (and so includes) the standard assert macro, wrap that inclusion with +// includes of these two files, e.g. +// +// #include "utilities/vmassert_uninstall.hpp" +// #include
+// #include "utilities/vmassert_reinstall.hpp" +// +// This removes the HotSpot macro definition while pre-processing the +// 3rd-party header, then reinstates the HotSpot macro (if previously defined) +// for following code. + +// Remove HotSpot's assert macro, if present. +#ifdef vmassert +#undef assert +#endif // vmassert + diff --git a/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java b/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java index 8840d0c5e58..8fe24820d7f 100644 --- a/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java +++ b/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 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 @@ -300,7 +300,8 @@ private static Set schemesListToSet(String list) { } static final String httpVersion = "HTTP/1.1"; - static final String acceptString = "*/*"; + static final String acceptString = + "text/html, image/gif, image/jpeg, */*; q=0.2"; // the following http request headers should NOT have their values // returned for security reasons. diff --git a/test/hotspot/gtest/gc/shared/test_memset_with_concurrent_readers.cpp b/test/hotspot/gtest/gc/shared/test_memset_with_concurrent_readers.cpp index 24f25b87af9..7a3845e336a 100644 --- a/test/hotspot/gtest/gc/shared/test_memset_with_concurrent_readers.cpp +++ b/test/hotspot/gtest/gc/shared/test_memset_with_concurrent_readers.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2022, 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 @@ -24,10 +24,13 @@ #include "precompiled.hpp" #include "gc/shared/memset_with_concurrent_readers.hpp" #include "utilities/globalDefinitions.hpp" -#include "unittest.hpp" +#include "utilities/vmassert_uninstall.hpp" #include #include +#include "utilities/vmassert_reinstall.hpp" + +#include "unittest.hpp" static unsigned line_byte(const char* line, size_t i) { return unsigned(line[i]) & 0xFF; diff --git a/test/hotspot/gtest/jfr/test_networkUtilization.cpp b/test/hotspot/gtest/jfr/test_networkUtilization.cpp index 19d6a6e2c27..42cd18356b7 100644 --- a/test/hotspot/gtest/jfr/test_networkUtilization.cpp +++ b/test/hotspot/gtest/jfr/test_networkUtilization.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2022, 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 @@ -42,11 +42,13 @@ #include "utilities/globalDefinitions.hpp" #include "utilities/growableArray.hpp" -#include "unittest.hpp" - +#include "utilities/vmassert_uninstall.hpp" #include #include #include +#include "utilities/vmassert_reinstall.hpp" + +#include "unittest.hpp" namespace { diff --git a/test/hotspot/gtest/unittest.hpp b/test/hotspot/gtest/unittest.hpp index 0494a0e2408..91edf6adba2 100644 --- a/test/hotspot/gtest/unittest.hpp +++ b/test/hotspot/gtest/unittest.hpp @@ -28,19 +28,10 @@ #include #define GTEST_DONT_DEFINE_TEST 1 -#include "gtest/gtest.h" -// gtest/gtest.h includes assert.h which will define the assert macro, but hotspot has its -// own standards incompatible assert macro that takes two parameters. -// The workaround is to undef assert and then re-define it. The re-definition -// must unfortunately be copied since debug.hpp might already have been -// included and a second include wouldn't work due to the header guards in debug.hpp. -#ifdef assert - #undef assert - #ifdef vmassert - #define assert(p, ...) vmassert(p, __VA_ARGS__) - #endif -#endif +#include "utilities/vmassert_uninstall.hpp" +#include "gtest/gtest.h" +#include "utilities/vmassert_reinstall.hpp" #define CONCAT(a, b) a ## b diff --git a/test/hotspot/jtreg/gc/stress/TestStressG1Humongous.java b/test/hotspot/jtreg/gc/stress/TestStressG1Humongous.java index 5aea51a24fe..da63e02555f 100644 --- a/test/hotspot/jtreg/gc/stress/TestStressG1Humongous.java +++ b/test/hotspot/jtreg/gc/stress/TestStressG1Humongous.java @@ -24,14 +24,41 @@ package gc.stress; /* - * @test TestStressG1Humongous + * @test * @key gc stress * @summary Stress G1 by humongous allocations in situation near OOM * @requires vm.gc.G1 * @requires !vm.flightRecorder * @library /test/lib * @modules java.base/jdk.internal.misc - * @run driver/timeout=1300 gc.stress.TestStressG1Humongous + * @run driver/timeout=180 gc.stress.TestStressG1Humongous 4 3 1.1 120 + */ + +/* + * @test + * @requires vm.gc.G1 + * @requires !vm.flightRecorder + * @library /test/lib + * @modules java.base/jdk.internal.misc + * @run driver/timeout=180 gc.stress.TestStressG1Humongous 16 5 2.1 120 + */ + +/* + * @test + * @requires vm.gc.G1 + * @requires !vm.flightRecorder + * @library /test/lib + * @modules java.base/jdk.internal.misc + * @run driver/timeout=180 gc.stress.TestStressG1Humongous 32 4 0.6 120 + */ + +/* + * @test + * @requires vm.gc.G1 + * @requires !vm.flightRecorder + * @library /test/lib + * @modules java.base/jdk.internal.misc + * @run driver/timeout=900 gc.stress.TestStressG1Humongous 1 7 0.6 600 */ import java.util.ArrayList; @@ -48,17 +75,19 @@ public class TestStressG1Humongous{ public static void main(String[] args) throws Exception { + if (args.length != 4) { + throw new IllegalArgumentException("Test expects 4 arguments"); + } + // Limit heap size on 32-bit platforms int heapSize = Platform.is32bit() ? 512 : 1024; - // Heap size, region size, threads, humongous size, timeout - run(heapSize, 4, 3, 1.1, 120); - run(heapSize, 16, 5, 2.1, 120); - run(heapSize, 32, 4, 0.6, 120); - run(heapSize, 1, 7, 0.6, 600); - } - private static void run(int heapSize, int regionSize, int threads, double humongousSize, int timeout) - throws Exception { + // Region size, threads, humongous size, and timeout passed as @run arguments + int regionSize = Integer.parseInt(args[0]); + int threads = Integer.parseInt(args[1]); + double humongousSize = Double.parseDouble(args[2]); + int timeout = Integer.parseInt(args[3]); + ArrayList options = new ArrayList<>(); Collections.addAll(options, Utils.getTestJavaOpts()); Collections.addAll(options, diff --git a/test/jdk/java/awt/List/MouseDraggedOutCauseScrollingTest/MouseDraggedOutCauseScrollingTest.html b/test/jdk/java/awt/List/MouseDraggedOutCauseScrollingTest/MouseDraggedOutCauseScrollingTest.html deleted file mode 100644 index 7049e827033..00000000000 --- a/test/jdk/java/awt/List/MouseDraggedOutCauseScrollingTest/MouseDraggedOutCauseScrollingTest.html +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - ManualYesNoTest - - - -

ManualYesNoTest
Bug ID:

- -

See the dialog box (usually in upper left corner) for instructions

- - - - diff --git a/test/jdk/java/awt/List/MouseDraggedOutCauseScrollingTest/MouseDraggedOutCauseScrollingTest.java b/test/jdk/java/awt/List/MouseDraggedOutCauseScrollingTest/MouseDraggedOutCauseScrollingTest.java index 8b509a12311..446b7a3a932 100644 --- a/test/jdk/java/awt/List/MouseDraggedOutCauseScrollingTest/MouseDraggedOutCauseScrollingTest.java +++ b/test/jdk/java/awt/List/MouseDraggedOutCauseScrollingTest/MouseDraggedOutCauseScrollingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -22,29 +22,29 @@ */ /* - test + @test @bug 6243382 8006070 @summary Dragging of mouse outside of a List and Choice area don't work properly on XAWT - @author Dmitry.Cherepanov@SUN.COM area=awt.list - @run applet/manual=yesno MouseDraggedOutCauseScrollingTest.html + @requires (os.family == "linux") + @library /java/awt/regtesthelpers + @run main/manual MouseDraggedOutCauseScrollingTest */ -import java.applet.Applet; -import java.awt.*; +import java.awt.Choice; +import java.awt.Frame; +import java.awt.GridLayout; +import java.awt.List; +import java.awt.Toolkit; -public class MouseDraggedOutCauseScrollingTest extends Applet -{ - Choice choice; - List singleList; - List multipleList; +public class MouseDraggedOutCauseScrollingTest { - public void init() - { - this.setLayout (new GridLayout (1, 3)); + static Frame createUI() { + Frame frame = new Frame("MouseDraggedOutCausesScrollingTest"); + frame.setLayout(new GridLayout(1, 3)); - choice = new Choice(); - singleList = new List(3, false); - multipleList = new List(3, true); + Choice choice = new Choice(); + List singleList = new List(3, false); + List multipleList = new List(3, true); choice.add("Choice"); for (int i = 1; i < 100; i++){ @@ -59,188 +59,66 @@ public void init() for (int i = 1; i < 100; i++) multipleList.add(""+i); - this.add(choice); - this.add(singleList); - this.add(multipleList); + frame.add(choice); + frame.add(singleList); + frame.add(multipleList); + frame.setSize(400, 100); + return frame; + } + public static void main(String[] args) throws Exception { String toolkitName = Toolkit.getDefaultToolkit().getClass().getName(); + if (!toolkitName.equals("sun.awt.X11.XToolkit")) { - String[] instructions = - { - "This test is not applicable to the current platform. Press PASS" - }; - Sysout.createDialogWithInstructions( instructions ); - } else { - String[] instructions = - { - "0) Please note, that this is only Motif/XAWT test. At first, make the applet active", - "1.1) Click on the choice", - "1.2) Press the left button of the mouse and keep on any item of the choice, for example 5", - "1.3) Drag mouse out of the area of the unfurled list, at the same time hold the X coordinate of the mouse position about the same", - "1.4) To make sure, that when the Y coordinate of the mouse position higher of the upper bound of the list then scrolling UP of the list and selected item changes on the upper. If not, the test failed", - "1.5) To make sure, that when the Y coordinate of the mouse position under of the lower bound of the list then scrolling DOWN of the list and selected item changes on the lower. If not, the test failed", - "-----------------------------------", - "2.1) Click on the single list", - "2.2) Press the left button of the mouse and keep on any item of the list, for example 5", - "2.3) Drag mouse out of the area of the unfurled list, at the same time hold the X coordinate of the mouse position about the same", - "2.4) To make sure, that when the Y coordinate of the mouse position higher of the upper bound of the list then scrolling UP of the list and selected item changes on the upper. If not, the test failed", - "2.5) To make sure, that when the Y coordinate of the mouse position under of the lower bound of the list then scrolling DOWN of the list and selected item changes on the lower. If not, the test failed", - "-----------------------------------", - "3.1) Click on the multiple list", - "3.2) Press the left button of the mouse and keep on any item of the list, for example 5", - "3.3) Drag mouse out of the area of the unfurled list, at the same time hold the X coordinate of the mouse position about the same", - "3.4) To make sure, that when the Y coordinate of the mouse position higher of the upper bound of the list then scrolling of the list NO OCCURED and selected item NO CHANGES on the upper. If not, the test failed", - "3.5) To make sure, that when the Y coordinate of the mouse position under of the lower bound of the list then scrolling of the list NO OCCURED and selected item NO CHANGES on the lower. If not, the test failed", - "4) Test passed." - }; - Sysout.createDialogWithInstructions( instructions ); + System.out.println(INAPPLICABLE); + return; } - }//End init() - - public void start () - { - setSize (400,100); - setVisible(true); - validate(); - - }// start() - -}// class ManualYesNoTest - -/**************************************************** - 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); + PassFailJFrame + .builder() + .instructions(INSTRUCTIONS) + .rows(40) + .columns(70) + .testUI(MouseDraggedOutCauseScrollingTest::createUI) + .build() + .awaitAndCheck(); } -}// TestDialog class + static final String INAPPLICABLE = "The test is not applicable to the current platform. Test PASSES."; + static final String INSTRUCTIONS = "0) Please note, that this is an XAWT/Linux only test. First, make the test window is active.\n" + + "-----------------------------------\n" + + "1.1) Click on the Choice.\n" + + "1.2) Press and hold down the left button of the mouse to select (eg) item 5 in the choice.\n" + + "1.3) Drag the mouse vertically out of the area of the open list,\n" + + " keeping the X coordinate of the mouse position about the same.\n" + + "1.4) Check that when the Y coordinate of the mouse position is higher than the upper bound of the list\n" + + " then the list continues to scrolls UP and the selected item changes at the top until you reach the topmost item.\n" + + " If not, the test failed. Press FAIL.\n" + + "1.5) Check that when the Y coordinate of the mouse position is lower than the lower bound of the list\n" + + " then the list continues to scroll DOWN and the selected item changes at the bottom until you reach the bottommost item.\n" + + " If not, the test failed. Press FAIL.\n" + + "-----------------------------------\n" + + "2.1) Click on the Single List.\n" + + "2.2) Press and hold down the left button of the mouse to select (eg) item 5 in the list.\n" + + "2.3) Drag the mouse vertically out of the area of the open list,\n" + + " keeping the X coordinate of the mouse position about the same.\n" + + "2.4) Check that when the Y coordinate of the mouse position is higher than the upper bound of the list\n" + + " then the list continues to scrolls UP and the selected item changes at the top until you reach the topmost item.\n" + + " If not, the test failed. Press FAIL.\n" + + "2.5) Check that when the Y coordinate of the mouse position is lower than the lower bound of the list\n" + + " then the list continues to scroll DOWN and the selected item changes at the bottom until you reach the bottommost item.\n" + + " If not, the test failed. Press FAIL.\n" + + "-----------------------------------\n" + + "3.1) Click on the Multiple List.\n" + + "3.2) Press and hold down the left button of the mouse to select (eg) item 5 in the list.\n" + + "3.3) Drag the mouse vertically out of the area of the open list,\n" + + " keeping the X coordinate of the mouse position about the same.\n" + + "3.4) Check that when the Y coordinate of the mouse is higher than the upper bound of the list\n" + + " that scrolling of the list DOES NOT OCCUR and the selected item IS UNCHANGED at the top.\n" + + " If not, the test failed. Press FAIL.\n" + + "3.5) Check that when the Y coordinate of the mouse is below the lower bound of the list\n" + + " that scrolling of the list DOES NOT OCCUR and the selected item IS UNCHANGED at the bottom.\n" + + " If not, the test failed. Press FAIL.\n" + + "-----------------------------------\n" + + "4) The test has now passed. Press PASS."; +} diff --git a/test/jdk/java/awt/Modal/PrintDialogsTest/PrintDialogsTest.html b/test/jdk/java/awt/Modal/PrintDialogsTest/PrintDialogsTest.html index a562b886ab0..e69de29bb2d 100644 --- a/test/jdk/java/awt/Modal/PrintDialogsTest/PrintDialogsTest.html +++ b/test/jdk/java/awt/Modal/PrintDialogsTest/PrintDialogsTest.html @@ -1,44 +0,0 @@ - - - - - PrintDialogsTest - - - - -Please select dialog modality type and parent; also select -the print auxiliary dialog to be displayed (Page Setup or Print dialog). -Then click "Start test" button. - -When the windows will appear check if modal blocking for Dialog works as expected. -Then push "Open" button on the Dialog to show the auxiliary dialog and check -if it blocks the rest of the application. Then close it and check correctness -of modal blocking behavior for the Dialog again. To close all the test -windows please push "Finish" button. - -To finish the overall test push "Pass" or "Fail" button depending on result. - - - diff --git a/test/jdk/java/awt/Modal/PrintDialogsTest/PrintDialogsTest.java b/test/jdk/java/awt/Modal/PrintDialogsTest/PrintDialogsTest.java index 989c48295b0..8a07d284a92 100644 --- a/test/jdk/java/awt/Modal/PrintDialogsTest/PrintDialogsTest.java +++ b/test/jdk/java/awt/Modal/PrintDialogsTest/PrintDialogsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2014, 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 @@ -25,21 +25,75 @@ /* * @test * @bug 8055836 8057694 8055752 - * @summary Check if Print and Page Setup dialogs lock other windows; + * @summary Check if Print and Page Setup dialogs block other windows; * check also correctness of modal behavior for other dialogs. - * - * @run applet/manual=yesno PrintDialogsTest.html + * @library /java/awt/regtesthelpers + * @run main/manual PrintDialogsTest */ -import java.applet.Applet; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.Checkbox; +import java.awt.CheckboxGroup; +import java.awt.Dialog; +import java.awt.Frame; +import java.awt.EventQueue; +import java.awt.GridLayout; +import java.awt.Label; +import java.awt.Panel; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -public class PrintDialogsTest extends Applet implements ActionListener { +public class PrintDialogsTest extends Panel implements ActionListener { + + static final String INSTRUCTIONS = + "This test is free format, which means there is no enforced or guided sequence." + "\n" + + + "Please select each of " + "\n" + + "(a) The dialog parent type." + "\n" + + "(b) The dialog modality type" + "\n" + + "(c) The print dialog type (Print dialog or Page Setup dialog)" + "\n" + + + "Once the choices have been made click the \"Start test\" button." + "\n" + + + "Three windows will appear" + "\n" + + "(1) A Frame or a Dialog - in the case you selected \"Dialog\" as the parent type" + "\n" + + "(2) a Window (ie an undecorated top-level)" + "\n" + + "(3) A dialog with two buttons \"Open\" and \"Finish\"" + "\n" + + + "Now check as follows whether modal blocking works as expected." + "\n" + + "Windows (1) and (2) contain a button which you should be able to press" + "\n" + + "ONLY if you selected \"Non-modal\", or \"Modeless\" for modality type." + "\n" + + "In other cases window (3) will block input to (1) and (2)" + "\n" + + + "Then push the \"Open\" button on the Dialog to show the printing dialog and check" + "\n" + + "if it blocks the rest of the application - ie all of windows (1), (2) and (3)" + "\n" + + "should ALWAYS be blocked when the print dialog is showing." + "\n" + + "Now cancel the printing dialog and check the correctness of modal blocking" + "\n" + + "behavior for the Dialog again." + "\n" + + "To close all the 3 test windows please push the \"Finish\" button." + "\n" + + + "Repeat all the above for different combinations, which should include" + "\n" + + "using all of the Dialog parent choices and all of the Dialog Modality types." + "\n" + + + "If any behave incorrectly, note the combination of choices and press Fail." + "\n" + + + "If all behave correctly, press Pass."; + + public static void main(String[] args) throws Exception { + + PassFailJFrame.builder() + .instructions(INSTRUCTIONS) + .rows(35) + .columns(60) + .testUI(PrintDialogsTest::createUI) + .testTimeOut(10) + .build() + .awaitAndCheck(); + } private Button btnTest; private Checkbox cbPage, cbPrint, @@ -48,6 +102,14 @@ public class PrintDialogsTest extends Applet implements ActionListener { private CheckboxGroup groupDialog, groupParent, groupModType; + private static Frame createUI() { + Frame frame = new Frame("Dialog Modality Testing"); + PrintDialogsTest test = new PrintDialogsTest(); + test.createGUI(); + frame.add(test); + frame.pack(); + return frame; + } public void actionPerformed(ActionEvent e) { @@ -99,13 +161,13 @@ private void createGUI() { setLayout(new BorderLayout()); - setSize(350, 200); Panel panel = new Panel(); - panel.setLayout(new GridLayout(18, 1)); + panel.setLayout(new GridLayout(21, 1)); btnTest = new Button("Start test"); btnTest.addActionListener(this); panel.add(btnTest); + panel.add(new Label(" ")); // spacing panel.add(new Label("Dialog parent:")); @@ -123,6 +185,7 @@ private void createGUI() { panel.add(cbHiddFrm); panel.add(cbDlg); panel.add(cbFrm); + panel.add(new Label(" ")); // spacing panel.add(new Label("Dialog modality type:")); groupModType = new CheckboxGroup(); @@ -139,7 +202,7 @@ private void createGUI() { panel.add(cbDocModal); panel.add(cbTKModal); panel.add(cbModeless); - add(panel); + panel.add(new Label(" ")); // spacing panel.add(new Label("Print dialog type:")); groupDialog = new CheckboxGroup(); @@ -148,13 +211,6 @@ private void createGUI() { panel.add(cbPage); panel.add(cbPrint); - validate(); - setVisible(true); - } - - public void start() { - try { - EventQueue.invokeAndWait(this::createGUI); - } catch (Exception e) {} + add(panel); } } diff --git a/test/jdk/jdk/jfr/event/oldobject/TestListenerLeak.java b/test/jdk/jdk/jfr/event/oldobject/TestListenerLeak.java index a275eda5171..2cb092e60b6 100644 --- a/test/jdk/jdk/jfr/event/oldobject/TestListenerLeak.java +++ b/test/jdk/jdk/jfr/event/oldobject/TestListenerLeak.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2023, 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 @@ -74,15 +74,17 @@ public void onListen() { public static void main(String[] args) throws Exception { WhiteBox.setWriteAllObjectSamples(true); - - try (Recording r = new Recording()) { - r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity"); - r.start(); - listenerLeak(); - r.stop(); - List events = Events.fromRecording(r); - if (OldObjects.countMatchingEvents(events, Stuff[].class, null, null, -1, "listenerLeak") == 0) { - throw new Exception("Could not find leak with " + Stuff[].class); + while (true) { + try (Recording r = new Recording()) { + r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity"); + r.start(); + listenerLeak(); + r.stop(); + List events = Events.fromRecording(r); + if (OldObjects.countMatchingEvents(events, Stuff[].class, null, null, -1, "listenerLeak") != 0) { + return; // Success + } + System.out.println("Could not find leak with " + Stuff[].class + ". Retrying."); } } } diff --git a/test/jdk/sun/net/www/B8185898.java b/test/jdk/sun/net/www/B8185898.java index cfa54e15a52..c78df56f723 100644 --- a/test/jdk/sun/net/www/B8185898.java +++ b/test/jdk/sun/net/www/B8185898.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 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 @@ -23,7 +23,7 @@ /** * @test - * @bug 8185898 8163921 + * @bug 8185898 8163921 8339470 * @modules java.base/sun.net.www * @library /test/lib * @run main/othervm B8185898 @@ -143,32 +143,32 @@ static void testMessageHeaderMethods() throws IOException { // {{inputString1, expectedToString1, expectedPrint1}, {...}} String[][] strings = { {"HTTP/1.1 200 OK\r\n" - + "Accept: */*\r\n" + + "Accept: text/html, image/gif, image/jpeg, */*; q=0.2\r\n" + "Connection: keep-alive\r\n" + "Host: 127.0.0.1:12345\r\n" + "User-agent: Java/12\r\n\r\nfoooo", "pairs: {null: HTTP/1.1 200 OK}" - + "{Accept: */*}" + + "{Accept: text/html, image/gif, image/jpeg, */*; q=0.2}" + "{Connection: keep-alive}" + "{Host: 127.0.0.1:12345}" + "{User-agent: Java/12}", - "Accept: */*\r\n" + "Accept: text/html, image/gif, image/jpeg, */*; q=0.2\r\n" + "Connection: keep-alive\r\n" + "Host: 127.0.0.1:12345\r\n" + "User-agent: Java/12\r\n\r\n"}, {"HTTP/1.1 200 OK\r\n" - + "Accept: */*\r\n" + + "Accept: text/html, image/gif, image/jpeg, */*; q=0.2\r\n" + "Connection: keep-alive\r\n" + "Host: 127.0.0.1:12345\r\n" + "User-agent: Java/12\r\n" + "X-Header:\r\n\r\n", "pairs: {null: HTTP/1.1 200 OK}" - + "{Accept: */*}" + + "{Accept: text/html, image/gif, image/jpeg, */*; q=0.2}" + "{Connection: keep-alive}" + "{Host: 127.0.0.1:12345}" + "{User-agent: Java/12}" + "{X-Header: }", - "Accept: */*\r\n" + "Accept: text/html, image/gif, image/jpeg, */*; q=0.2\r\n" + "Connection: keep-alive\r\n" + "Host: 127.0.0.1:12345\r\n" + "User-agent: Java/12\r\n" diff --git a/test/jdk/sun/util/calendar/zi/Month.java b/test/jdk/sun/util/calendar/zi/Month.java index cb60b8d4411..bab909f7637 100644 --- a/test/jdk/sun/util/calendar/zi/Month.java +++ b/test/jdk/sun/util/calendar/zi/Month.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -21,11 +21,6 @@ * questions. */ -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - /** * Month enum handles month related manipulation. * @@ -47,15 +42,6 @@ enum Month { private final String abbr; - private static final Map abbreviations - = new HashMap(12); - - static { - for (Month m : Month.values()) { - abbreviations.put(m.abbr, m); - } - } - private Month(String abbr) { this.abbr = abbr; } @@ -70,11 +56,22 @@ int value() { * @return the Month value */ static Month parse(String name) { - Month m = abbreviations.get(name); - if (m != null) { - return m; - } - return null; + int len = name.length(); + + if (name.regionMatches(true, 0, "January", 0, len)) return Month.JANUARY; + if (name.regionMatches(true, 0, "February", 0, len)) return Month.FEBRUARY; + if (name.regionMatches(true, 0, "March", 0, len)) return Month.MARCH; + if (name.regionMatches(true, 0, "April", 0, len)) return Month.APRIL; + if (name.regionMatches(true, 0, "May", 0, len)) return Month.MAY; + if (name.regionMatches(true, 0, "June", 0, len)) return Month.JUNE; + if (name.regionMatches(true, 0, "July", 0, len)) return Month.JULY; + if (name.regionMatches(true, 0, "August", 0, len)) return Month.AUGUST; + if (name.regionMatches(true, 0, "September", 0, len)) return Month.SEPTEMBER; + if (name.regionMatches(true, 0, "October", 0, len)) return Month.OCTOBER; + if (name.regionMatches(true, 0, "November", 0, len)) return Month.NOVEMBER; + if (name.regionMatches(true, 0, "December", 0, len)) return Month.DECEMBER; + + throw new IllegalArgumentException("Unknown month: " + name); } /** diff --git a/test/jdk/sun/util/calendar/zi/RuleDay.java b/test/jdk/sun/util/calendar/zi/RuleDay.java index bc730944b4c..9cd81c1e524 100644 --- a/test/jdk/sun/util/calendar/zi/RuleDay.java +++ b/test/jdk/sun/util/calendar/zi/RuleDay.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -21,11 +21,6 @@ * questions. */ -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - /** * RuleDay class represents the value of the "ON" field. The day of * week values start from 1 following the {@link java.util.Calendar} @@ -34,13 +29,6 @@ * @since 1.4 */ class RuleDay { - private static final Map abbreviations = new HashMap(7); - static { - for (DayOfWeek day : DayOfWeek.values()) { - abbreviations.put(day.getAbbr(), day); - } - } - private String dayName = null; private DayOfWeek dow; private boolean lastOne = false; @@ -166,13 +154,23 @@ String getDayOfWeekForSimpleTimeZone() { return sign + toString(d); } - private static DayOfWeek getDOW(String abbr) { - return abbreviations.get(abbr); + private static DayOfWeek getDOW(String name) { + int len = name.length(); + + if (name.regionMatches(true, 0, "Monday", 0, len)) return DayOfWeek.MONDAY; + if (name.regionMatches(true, 0, "Tuesday", 0, len)) return DayOfWeek.TUESDAY; + if (name.regionMatches(true, 0, "Wednesday", 0, len)) return DayOfWeek.WEDNESDAY; + if (name.regionMatches(true, 0, "Thursday", 0, len)) return DayOfWeek.THURSDAY; + if (name.regionMatches(true, 0, "Friday", 0, len)) return DayOfWeek.FRIDAY; + if (name.regionMatches(true, 0, "Saturday", 0, len)) return DayOfWeek.SATURDAY; + if (name.regionMatches(true, 0, "Sunday", 0, len)) return DayOfWeek.SUNDAY; + + throw new IllegalArgumentException("Unknown day-of-week: " + name); } /** * Converts the specified day of week value to the day-of-week - * name defined in {@link java.util.Calenda}. + * name defined in {@link java.util.Calendar}. * @param dow 1-based day of week value * @return the Calendar day of week name with "Calendar." prefix. * @throws IllegalArgumentException if the specified dow value is out of range. diff --git a/test/langtools/TEST.ROOT b/test/langtools/TEST.ROOT index da089df72a9..b5503c4f71e 100644 --- a/test/langtools/TEST.ROOT +++ b/test/langtools/TEST.ROOT @@ -22,3 +22,7 @@ useNewOptions=true # Use --patch-module instead of -Xmodule: useNewPatchModule=true + +# Path to libraries in the topmost test directory. This is needed so @library +# does not need ../../ notation to reach them +external.lib.roots = ../../ diff --git a/test/langtools/jdk/javadoc/doclet/testIOException/TestIOException.java b/test/langtools/jdk/javadoc/doclet/testIOException/TestIOException.java index 9db41724ae5..b0bfc3c4a81 100644 --- a/test/langtools/jdk/javadoc/doclet/testIOException/TestIOException.java +++ b/test/langtools/jdk/javadoc/doclet/testIOException/TestIOException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -23,9 +23,9 @@ /* * @test - * @bug 8164130 + * @bug 8164130 8334332 * @summary test IOException handling - * @library ../lib + * @library ../lib /test/lib * @modules jdk.javadoc/jdk.javadoc.internal.tool * @build JavadocTester * @run main TestIOException @@ -33,7 +33,18 @@ import java.io.File; import java.io.FileWriter; +import java.nio.file.Path; +import java.nio.file.Files; +import java.util.Map; +import jtreg.SkippedException; + +/** + * Tests IO Exception handling. + * + * Update: Windows does not permit setting folder to be readonly. + * https://support.microsoft.com/en-us/help/326549/you-cannot-view-or-change-the-read-only-or-the-system-attributes-of-fo + */ public class TestIOException extends JavadocTester { public static void main(String... args) throws Exception { @@ -45,13 +56,13 @@ public static void main(String... args) throws Exception { void testReadOnlyDirectory() { File outDir = new File("out1"); if (!outDir.mkdir()) { - throw new Error("Cannot create directory"); + throw skip(outDir, "Cannot create directory"); } if (!outDir.setReadOnly()) { - throw new Error("could not set directory read-only"); + throw skip(outDir, "could not set directory read-only"); } if (outDir.canWrite()) { - throw new Error("directory is writable"); + throw skip(outDir, "directory is writable"); } try { @@ -69,15 +80,15 @@ void testReadOnlyDirectory() { void testReadOnlyFile() throws Exception { File outDir = new File("out2"); if (!outDir.mkdir()) { - throw new Error("Cannot create directory"); + throw skip(outDir, "Cannot create directory"); } File index = new File(outDir, "index.html"); try (FileWriter fw = new FileWriter(index)) { } if (!index.setReadOnly()) { - throw new Error("could not set index read-only"); + throw skip(index, "could not set index read-only"); } if (index.canWrite()) { - throw new Error("index is writable"); + throw skip(index, "index is writable"); } try { @@ -109,13 +120,13 @@ void testReadOnlySubdirectory() throws Exception { File outDir = new File("out3"); File pkgOutDir = new File(outDir, "p"); if (!pkgOutDir.mkdirs()) { - throw new Error("Cannot create directory"); + throw skip(pkgOutDir, "Cannot create directory"); } if (!pkgOutDir.setReadOnly()) { - throw new Error("could not set directory read-only"); + throw skip(pkgOutDir, "could not set directory read-only"); } if (pkgOutDir.canWrite()) { - throw new Error("directory is writable"); + throw skip(pkgOutDir, "directory is writable"); } // run javadoc and check results @@ -153,13 +164,13 @@ void testReadOnlyDocFilesDir() throws Exception { File pkgOutDir = new File(outDir, "p"); File docFilesOutDir = new File(pkgOutDir, "doc-files"); if (!docFilesOutDir.mkdirs()) { - throw new Error("Cannot create directory"); + throw skip(docFilesOutDir, "Cannot create directory"); } if (!docFilesOutDir.setReadOnly()) { - throw new Error("could not set directory read-only"); + throw skip(docFilesOutDir, "could not set directory read-only"); } if (docFilesOutDir.canWrite()) { - throw new Error("directory is writable"); + throw skip(docFilesOutDir, "directory is writable"); } try { @@ -175,5 +186,30 @@ void testReadOnlyDocFilesDir() throws Exception { docFilesOutDir.setWritable(true); } } + + private Error skip(File f, String message) { + out.print(System.getProperty("user.name")); + out.println(f + ": " + message); + showAllAttributes(f.toPath()); + throw new SkippedException(f + ": " + message); + } + + private void showAllAttributes(Path p) { + showAttributes(p, "*"); + showAttributes(p, "posix:*"); + showAttributes(p, "dos:*"); + } + + private void showAttributes(Path p, String attributes) { + out.println("Attributes: " + attributes); + try { + Map map = Files.readAttributes(p, attributes); + map.forEach((n, v) -> out.format(" %-10s: %s%n", n, v)); + } catch (UnsupportedOperationException e) { + out.println("Attributes not available " + attributes); + } catch (Throwable t) { + out.println("Error accessing attributes " + attributes + ": " + t); + } + } }