From 3d0d0e62900653c4e395166a9ac48578b3dbc1f8 Mon Sep 17 00:00:00 2001 From: David Holmes Date: Mon, 2 Dec 2024 20:54:58 +0000 Subject: [PATCH 01/62] 8345012: os::build_agent_function_name potentially wastes a byte when allocating the buffer Reviewed-by: stuefe, shade --- src/hotspot/os/posix/os_posix.cpp | 46 --------------------- src/hotspot/os/windows/os_windows.cpp | 51 ----------------------- src/hotspot/share/runtime/os.cpp | 58 +++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 97 deletions(-) diff --git a/src/hotspot/os/posix/os_posix.cpp b/src/hotspot/os/posix/os_posix.cpp index 3ae692b9e88a0..61214a4296998 100644 --- a/src/hotspot/os/posix/os_posix.cpp +++ b/src/hotspot/os/posix/os_posix.cpp @@ -941,51 +941,6 @@ void os::naked_yield() { sched_yield(); } -// Builds a platform dependent Agent_OnLoad_ function name -// which is used to find statically linked in agents. -// Parameters: -// sym_name: Symbol in library we are looking for -// lib_name: Name of library to look in, null for shared libs. -// is_absolute_path == true if lib_name is absolute path to agent -// such as "/a/b/libL.so" -// == false if only the base name of the library is passed in -// such as "L" -char* os::build_agent_function_name(const char *sym_name, const char *lib_name, - bool is_absolute_path) { - char *agent_entry_name; - size_t len; - size_t name_len; - size_t prefix_len = strlen(JNI_LIB_PREFIX); - size_t suffix_len = strlen(JNI_LIB_SUFFIX); - const char *start; - - if (lib_name != nullptr) { - name_len = strlen(lib_name); - if (is_absolute_path) { - // Need to strip path, prefix and suffix - if ((start = strrchr(lib_name, *os::file_separator())) != nullptr) { - lib_name = ++start; - } - if (strlen(lib_name) <= (prefix_len + suffix_len)) { - return nullptr; - } - lib_name += prefix_len; - name_len = strlen(lib_name) - suffix_len; - } - } - len = (lib_name != nullptr ? name_len : 0) + strlen(sym_name) + 2; - agent_entry_name = NEW_C_HEAP_ARRAY_RETURN_NULL(char, len, mtThread); - if (agent_entry_name == nullptr) { - return nullptr; - } - strcpy(agent_entry_name, sym_name); - if (lib_name != nullptr) { - strcat(agent_entry_name, "_"); - strncat(agent_entry_name, lib_name, name_len); - } - return agent_entry_name; -} - // Sleep forever; naked call to OS-specific sleep; use with CAUTION void os::infinite_sleep() { while (true) { // sleep forever ... @@ -2231,4 +2186,3 @@ const void* os::get_saved_assert_context(const void** sigInfo) { *sigInfo = nullptr; return nullptr; } - diff --git a/src/hotspot/os/windows/os_windows.cpp b/src/hotspot/os/windows/os_windows.cpp index 45163765184ef..849fc0c29f051 100644 --- a/src/hotspot/os/windows/os_windows.cpp +++ b/src/hotspot/os/windows/os_windows.cpp @@ -5835,57 +5835,6 @@ void* os::get_default_process_handle() { return (void*)GetModuleHandle(nullptr); } -// Builds a platform dependent Agent_OnLoad_ function name -// which is used to find statically linked in agents. -// Parameters: -// sym_name: Symbol in library we are looking for -// lib_name: Name of library to look in, null for shared libs. -// is_absolute_path == true if lib_name is absolute path to agent -// such as "C:/a/b/L.dll" -// == false if only the base name of the library is passed in -// such as "L" -char* os::build_agent_function_name(const char *sym_name, const char *lib_name, - bool is_absolute_path) { - char *agent_entry_name; - size_t len; - size_t name_len; - size_t prefix_len = strlen(JNI_LIB_PREFIX); - size_t suffix_len = strlen(JNI_LIB_SUFFIX); - const char *start; - - if (lib_name != nullptr) { - len = name_len = strlen(lib_name); - if (is_absolute_path) { - // Need to strip path, prefix and suffix - if ((start = strrchr(lib_name, *os::file_separator())) != nullptr) { - lib_name = ++start; - } else { - // Need to check for drive prefix - if ((start = strchr(lib_name, ':')) != nullptr) { - lib_name = ++start; - } - } - if (len <= (prefix_len + suffix_len)) { - return nullptr; - } - lib_name += prefix_len; - name_len = strlen(lib_name) - suffix_len; - } - } - len = (lib_name != nullptr ? name_len : 0) + strlen(sym_name) + 2; - agent_entry_name = NEW_C_HEAP_ARRAY_RETURN_NULL(char, len, mtThread); - if (agent_entry_name == nullptr) { - return nullptr; - } - - strcpy(agent_entry_name, sym_name); - if (lib_name != nullptr) { - strcat(agent_entry_name, "_"); - strncat(agent_entry_name, lib_name, name_len); - } - return agent_entry_name; -} - /* All the defined signal names for Windows. diff --git a/src/hotspot/share/runtime/os.cpp b/src/hotspot/share/runtime/os.cpp index 8094261fe56e8..f631556858ff2 100644 --- a/src/hotspot/share/runtime/os.cpp +++ b/src/hotspot/share/runtime/os.cpp @@ -2481,3 +2481,61 @@ jint os::set_minimum_stack_sizes() { } return JNI_OK; } + +// Builds a platform dependent Agent_OnLoad_ function name +// which is used to find statically linked in agents. +// Parameters: +// sym_name: Symbol in library we are looking for +// lib_name: Name of library to look in, null for shared libs. +// is_absolute_path == true if lib_name is absolute path to agent +// such as "C:/a/b/L.dll" or "/a/b/libL.so" +// == false if only the base name of the library is passed in +// such as "L" +char* os::build_agent_function_name(const char *sym_name, const char *lib_name, + bool is_absolute_path) { + char *agent_entry_name; + size_t len = 0; + size_t name_len = 0; + size_t prefix_len = strlen(JNI_LIB_PREFIX); + size_t suffix_len = strlen(JNI_LIB_SUFFIX); + size_t underscore_len = 0; // optional underscore if lib_name is set + const char *start; + + if (lib_name != nullptr) { + if (is_absolute_path) { + // Need to strip path, prefix and suffix + if ((start = strrchr(lib_name, *os::file_separator())) != nullptr) { + lib_name = ++start; + } +#ifdef WINDOWS + else { // Need to check for drive prefix e.g. C:L.dll + if ((start = strchr(lib_name, ':')) != nullptr) { + lib_name = ++start; + } + } +#endif + name_len = strlen(lib_name); + if (name_len <= (prefix_len + suffix_len)) { + return nullptr; + } + lib_name += prefix_len; + name_len = strlen(lib_name) - suffix_len; + } else { + name_len = strlen(lib_name); + } + underscore_len = 1; + } + // Total buffer length to allocate - includes null terminator. + len = strlen(sym_name) + underscore_len + name_len + 1; + agent_entry_name = NEW_C_HEAP_ARRAY_RETURN_NULL(char, len, mtThread); + if (agent_entry_name == nullptr) { + return nullptr; + } + + strcpy(agent_entry_name, sym_name); + if (lib_name != nullptr) { + strcat(agent_entry_name, "_"); + strncat(agent_entry_name, lib_name, name_len); + } + return agent_entry_name; +} From 940aa7c4cf1bf770690660c8bb21fb3ddc5186e4 Mon Sep 17 00:00:00 2001 From: Sean Mullan Date: Mon, 2 Dec 2024 21:30:53 +0000 Subject: [PATCH 02/62] 8344397: Remove Security Manager dependencies from java.security and sun.security packages Reviewed-by: rriggs, hchao, weijun, alanb --- .../share/classes/java/lang/Class.java | 4 +- .../java/security/AccessControlContext.java | 8 - .../share/classes/java/security/Provider.java | 57 ++---- .../classes/java/security/SecureRandom.java | 6 +- .../share/classes/java/security/Security.java | 42 +--- .../sun/security/action/GetBooleanAction.java | 96 ---------- .../sun/security/action/GetIntegerAction.java | 165 ---------------- .../sun/security/action/GetLongAction.java | 114 ----------- .../security/action/GetPropertyAction.java | 99 +--------- .../sun/security/action/PutAllAction.java | 56 ------ .../share/classes/sun/security/ec/SunEC.java | 12 +- .../TlsRsaPremasterSecretParameterSpec.java | 8 +- .../sun/security/jca/ProviderConfig.java | 179 +++++++----------- .../sun/security/jca/ProviderList.java | 11 +- .../sun/security/provider/ConfigFile.java | 69 ++----- .../classes/sun/security/provider/DRBG.java | 7 +- .../provider/FileInputStreamPool.java | 8 +- .../classes/sun/security/provider/MD4.java | 10 +- .../sun/security/provider/SeedGenerator.java | 165 +++++++--------- .../classes/sun/security/provider/Sun.java | 23 +-- .../sun/security/provider/SunEntries.java | 38 ++-- .../provider/VerificationProvider.java | 19 +- .../sun/security/provider/certpath/OCSP.java | 6 +- .../provider/certpath/URICertStore.java | 6 +- .../sun/security/rsa/RSAKeyFactory.java | 5 +- .../classes/sun/security/rsa/SunRsaSign.java | 19 +- .../util/AbstractAlgorithmConstraints.java | 13 +- .../classes/sun/security/util/Debug.java | 6 +- .../classes/sun/security/util/DomainName.java | 23 +-- .../sun/security/util/FilePermCompat.java | 4 +- .../sun/security/util/HostnameChecker.java | 4 +- .../LazyCodeSourcePermissionCollection.java | 128 ------------- .../sun/security/util/LocalizedMessage.java | 6 +- .../sun/security/util/SecurityConstants.java | 72 +------ .../sun/security/util/SecurityProperties.java | 111 +++++++++-- .../util/SecurityProviderConstants.java | 6 +- .../security/util/SignatureFileVerifier.java | 4 +- .../sun/security/provider/NativePRNG.java | 138 ++++++-------- .../internal/ObjectFactoriesFilter.java | 4 +- .../classes/sun/security/krb5/Config.java | 4 +- .../sun/security/krb5/Credentials.java | 2 +- .../sun/security/krb5/PrincipalName.java | 2 +- .../internal/ccache/FileCredentialsCache.java | 2 +- test/jdk/sun/security/action/Generify.java | 29 --- .../GetLongAction/ReturnNullIfNoDefault.java | 54 ------ 45 files changed, 407 insertions(+), 1437 deletions(-) delete mode 100644 src/java.base/share/classes/sun/security/action/GetBooleanAction.java delete mode 100644 src/java.base/share/classes/sun/security/action/GetIntegerAction.java delete mode 100644 src/java.base/share/classes/sun/security/action/GetLongAction.java delete mode 100644 src/java.base/share/classes/sun/security/action/PutAllAction.java delete mode 100644 src/java.base/share/classes/sun/security/util/LazyCodeSourcePermissionCollection.java delete mode 100644 test/jdk/sun/security/action/GetLongAction/ReturnNullIfNoDefault.java diff --git a/src/java.base/share/classes/java/lang/Class.java b/src/java.base/share/classes/java/lang/Class.java index 771084384c805..23b8ac3fb9093 100644 --- a/src/java.base/share/classes/java/lang/Class.java +++ b/src/java.base/share/classes/java/lang/Class.java @@ -53,6 +53,7 @@ import java.lang.reflect.TypeVariable; import java.lang.constant.Constable; import java.net.URL; +import java.security.AllPermission; import java.security.Permissions; import java.security.ProtectionDomain; import java.util.ArrayList; @@ -89,7 +90,6 @@ import sun.reflect.generics.repository.MethodRepository; import sun.reflect.generics.repository.ConstructorRepository; import sun.reflect.generics.scope.ClassScope; -import sun.security.util.SecurityConstants; import sun.reflect.annotation.*; import sun.reflect.misc.ReflectUtil; @@ -2720,7 +2720,7 @@ private static class Holder { private static final ProtectionDomain allPermDomain; static { Permissions perms = new Permissions(); - perms.add(SecurityConstants.ALL_PERMISSION); + perms.add(new AllPermission()); allPermDomain = new ProtectionDomain(null, perms); } } diff --git a/src/java.base/share/classes/java/security/AccessControlContext.java b/src/java.base/share/classes/java/security/AccessControlContext.java index 6c73e6339fb71..01c7244fe2c65 100644 --- a/src/java.base/share/classes/java/security/AccessControlContext.java +++ b/src/java.base/share/classes/java/security/AccessControlContext.java @@ -44,14 +44,6 @@ public final class AccessControlContext { private ProtectionDomain[] context; - // isPrivileged and isAuthorized are referenced by the VM - do not remove - // or change their names - private boolean isPrivileged; - private boolean isAuthorized = false; - - // Note: This field is directly used by the virtual machine - // native codes. Don't touch it. - private AccessControlContext privilegedContext; @SuppressWarnings("removal") private DomainCombiner combiner = null; diff --git a/src/java.base/share/classes/java/security/Provider.java b/src/java.base/share/classes/java/security/Provider.java index 7012bcc9eebac..da3f53b963241 100644 --- a/src/java.base/share/classes/java/security/Provider.java +++ b/src/java.base/share/classes/java/security/Provider.java @@ -345,12 +345,6 @@ public String toString() { return name + " version " + versionStr; } - /* - * override the following methods to ensure that provider - * information can only be changed if the caller has the appropriate - * permissions. - */ - /** * Clears this {@code Provider} so that it no longer contains the properties * used to look up facilities implemented by the {@code Provider}. @@ -359,7 +353,7 @@ public String toString() { */ @Override public synchronized void clear() { - check("clearProviderProperties."+name); + checkInitialized(); if (debug != null) { debug.println("Remove " + name + " provider properties"); } @@ -376,7 +370,7 @@ public synchronized void clear() { */ @Override public synchronized void load(InputStream inStream) throws IOException { - check("putProviderProperty."+name); + checkInitialized(); if (debug != null) { debug.println("Load " + name + " provider properties"); } @@ -394,7 +388,7 @@ public synchronized void load(InputStream inStream) throws IOException { */ @Override public synchronized void putAll(Map t) { - check("putProviderProperty."+name); + checkInitialized(); if (debug != null) { debug.println("Put all " + name + " provider properties"); } @@ -461,7 +455,7 @@ public Collection values() { */ @Override public synchronized Object put(Object key, Object value) { - check("putProviderProperty."+name); + checkInitialized(); if (debug != null) { debug.println("Set " + name + " provider property [" + key + "/" + value +"]"); @@ -478,7 +472,7 @@ public synchronized Object put(Object key, Object value) { */ @Override public synchronized Object putIfAbsent(Object key, Object value) { - check("putProviderProperty."+name); + checkInitialized(); if (debug != null) { debug.println("Set " + name + " provider property [" + key + "/" + value +"]"); @@ -494,7 +488,7 @@ public synchronized Object putIfAbsent(Object key, Object value) { */ @Override public synchronized Object remove(Object key) { - check("removeProviderProperty."+name); + checkInitialized(); if (debug != null) { debug.println("Remove " + name + " provider property " + key); } @@ -509,7 +503,7 @@ public synchronized Object remove(Object key) { */ @Override public synchronized boolean remove(Object key, Object value) { - check("removeProviderProperty."+name); + checkInitialized(); if (debug != null) { debug.println("Remove " + name + " provider property " + key); } @@ -525,7 +519,7 @@ public synchronized boolean remove(Object key, Object value) { @Override public synchronized boolean replace(Object key, Object oldValue, Object newValue) { - check("putProviderProperty." + name); + checkInitialized(); if (debug != null) { debug.println("Replace " + name + " provider property " + key); } @@ -540,7 +534,7 @@ public synchronized boolean replace(Object key, Object oldValue, */ @Override public synchronized Object replace(Object key, Object value) { - check("putProviderProperty." + name); + checkInitialized(); if (debug != null) { debug.println("Replace " + name + " provider property " + key); } @@ -558,7 +552,7 @@ public synchronized Object replace(Object key, Object value) { @Override public synchronized void replaceAll(BiFunction function) { - check("putProviderProperty." + name); + checkInitialized(); if (debug != null) { debug.println("ReplaceAll " + name + " provider property "); } @@ -575,8 +569,7 @@ public synchronized void replaceAll(BiFunction remappingFunction) { - check("putProviderProperty." + name); - check("removeProviderProperty." + name); + checkInitialized(); if (debug != null) { debug.println("Compute " + name + " provider property " + key); } @@ -594,8 +587,7 @@ public synchronized Object compute(Object key, BiFunction mappingFunction) { - check("putProviderProperty." + name); - check("removeProviderProperty." + name); + checkInitialized(); if (debug != null) { debug.println("ComputeIfAbsent " + name + " provider property " + key); @@ -613,8 +605,7 @@ public synchronized Object computeIfAbsent(Object key, public synchronized Object computeIfPresent(Object key, BiFunction remappingFunction) { - check("putProviderProperty." + name); - check("removeProviderProperty." + name); + checkInitialized(); if (debug != null) { debug.println("ComputeIfPresent " + name + " provider property " + key); @@ -635,8 +626,7 @@ public synchronized Object computeIfPresent(Object key, public synchronized Object merge(Object key, Object value, BiFunction remappingFunction) { - check("putProviderProperty." + name); - check("removeProviderProperty." + name); + checkInitialized(); if (debug != null) { debug.println("Merge " + name + " provider property " + key); } @@ -694,15 +684,6 @@ private void checkInitialized() { } } - private void check(String directive) { - checkInitialized(); - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkSecurityAccess(directive); - } - } - // legacyMap changed since last call to getServices() private transient volatile boolean legacyChanged; // serviceMap changed since last call to getServices() @@ -789,8 +770,6 @@ private static boolean checkLegacy(Object key) { /** * Copies all the mappings from the specified Map to this provider. - * Internal method to be called AFTER the security check has been - * performed. */ private void implPutAll(Map t) { for (Map.Entry e : t.entrySet()) { @@ -1239,7 +1218,7 @@ public Set getServices() { * @since 1.5 */ protected void putService(Service s) { - check("putProviderProperty." + name); + checkInitialized(); if (debug != null) { debug.println(name + ".putService(): " + s); } @@ -1303,7 +1282,7 @@ Service getDefaultSecureRandomService() { private void putPropertyStrings(Service s) { String type = s.getType(); String algorithm = s.getAlgorithm(); - // use super() to avoid permission check and other processing + // use super() to avoid other processing super.put(type + "." + algorithm, s.getClassName()); for (String alias : s.getAliases()) { super.put(ALIAS_PREFIX + type + "." + alias, algorithm); @@ -1321,7 +1300,7 @@ private void putPropertyStrings(Service s) { private void removePropertyStrings(Service s) { String type = s.getType(); String algorithm = s.getAlgorithm(); - // use super() to avoid permission check and other processing + // use super() to avoid other processing super.remove(type + "." + algorithm); for (String alias : s.getAliases()) { super.remove(ALIAS_PREFIX + type + "." + alias); @@ -1346,7 +1325,7 @@ private void removePropertyStrings(Service s) { * @since 1.5 */ protected void removeService(Service s) { - check("removeProviderProperty." + name); + checkInitialized(); if (debug != null) { debug.println(name + ".removeService(): " + s); } diff --git a/src/java.base/share/classes/java/security/SecureRandom.java b/src/java.base/share/classes/java/security/SecureRandom.java index 734f25e6615a7..e6cc1134c09b6 100644 --- a/src/java.base/share/classes/java/security/SecureRandom.java +++ b/src/java.base/share/classes/java/security/SecureRandom.java @@ -942,11 +942,7 @@ private static final class StrongPatternHolder { public static SecureRandom getInstanceStrong() throws NoSuchAlgorithmException { - @SuppressWarnings("removal") - String property = AccessController.doPrivileged( - (PrivilegedAction) () -> Security.getProperty( - "securerandom.strongAlgorithms")); - + String property = Security.getProperty("securerandom.strongAlgorithms"); if (property == null || property.isEmpty()) { throw new NoSuchAlgorithmException( "Null/empty securerandom.strongAlgorithms Security Property"); diff --git a/src/java.base/share/classes/java/security/Security.java b/src/java.base/share/classes/java/security/Security.java index aab793b98e98e..6969fe8a8e142 100644 --- a/src/java.base/share/classes/java/security/Security.java +++ b/src/java.base/share/classes/java/security/Security.java @@ -312,14 +312,7 @@ private static void debugLoad(boolean start, Object source) { } static { - // doPrivileged here because there are multiple - // things in initialize that might require privs. - // (the FileInputStream call and the File.exists call, etc) - @SuppressWarnings("removal") - var dummy = AccessController.doPrivileged((PrivilegedAction) () -> { - initialize(); - return null; - }); + initialize(); // Set up JavaSecurityPropertiesAccess in SharedSecrets SharedSecrets.setJavaSecurityPropertiesAccess(new JavaSecurityPropertiesAccess() { @Override @@ -475,15 +468,13 @@ public static String getAlgorithmProperty(String algName, */ public static synchronized int insertProviderAt(Provider provider, int position) { - String providerName = provider.getName(); - checkInsertProvider(providerName); ProviderList list = Providers.getFullProviderList(); ProviderList newList = ProviderList.insertAt(list, provider, position - 1); if (list == newList) { return -1; } Providers.setProviderList(newList); - return newList.getIndex(providerName) + 1; + return newList.getIndex(provider.getName()) + 1; } /** @@ -527,7 +518,6 @@ public static int addProvider(Provider provider) { * @see #addProvider */ public static synchronized void removeProvider(String name) { - check("removeProvider." + name); ProviderList list = Providers.getFullProviderList(); ProviderList newList = ProviderList.remove(list, name); Providers.setProviderList(newList); @@ -822,7 +812,6 @@ static Object[] getImpl(String algorithm, String type, Provider provider, */ public static String getProperty(String key) { SecPropLoader.checkReservedKey(key); - check("getProperty." + key); String name = props.getProperty(key); if (name != null) name = name.trim(); // could be a class name with trailing ws @@ -845,7 +834,6 @@ public static String getProperty(String key) { */ public static void setProperty(String key, String datum) { SecPropLoader.checkReservedKey(key); - check("setProperty." + key); props.put(key, datum); SecurityPropertyModificationEvent spe = new SecurityPropertyModificationEvent(); @@ -859,32 +847,6 @@ public static void setProperty(String key, String datum) { } } - private static void check(String directive) { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkSecurityAccess(directive); - } - } - - private static void checkInsertProvider(String name) { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - try { - security.checkSecurityAccess("insertProvider"); - } catch (SecurityException se1) { - try { - security.checkSecurityAccess("insertProvider." + name); - } catch (SecurityException se2) { - // throw first exception, but add second to suppressed - se1.addSuppressed(se2); - throw se1; - } - } - } - } - private static class Criteria { private final String serviceName; private final String algName; diff --git a/src/java.base/share/classes/sun/security/action/GetBooleanAction.java b/src/java.base/share/classes/sun/security/action/GetBooleanAction.java deleted file mode 100644 index d41954601e819..0000000000000 --- a/src/java.base/share/classes/sun/security/action/GetBooleanAction.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 1998, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.security.action; - -import java.security.AccessController; - -/** - * A convenience class for retrieving the boolean value of a system property - * as a privileged action. - * - *

An instance of this class can be used as the argument of - * AccessController.doPrivileged. - * - *

The following code retrieves the boolean value of the system - * property named "prop" as a privileged action: - * - *

- * boolean b = java.security.AccessController.doPrivileged
- *              (new GetBooleanAction("prop")).booleanValue();
- * 
- * - * @author Roland Schemers - * @see java.security.PrivilegedAction - * @see java.security.AccessController - * @since 1.2 - */ - -public class GetBooleanAction - implements java.security.PrivilegedAction { - private final String theProp; - - /** - * Constructor that takes the name of the system property whose boolean - * value needs to be determined. - * - * @param theProp the name of the system property. - */ - public GetBooleanAction(String theProp) { - this.theProp = theProp; - } - - /** - * Determines the boolean value of the system property whose name was - * specified in the constructor. - * - * @return the Boolean value of the system property. - */ - public Boolean run() { - return Boolean.getBoolean(theProp); - } - - /** - * Convenience method to get a property without going through doPrivileged - * if no security manager is present. This is unsafe for inclusion in a - * public API but allowable here since this class is now encapsulated. - * - * Note that this method performs a privileged action using caller-provided - * inputs. The caller of this method should take care to ensure that the - * inputs are not tainted and the returned property is not made accessible - * to untrusted code if it contains sensitive information. - * - * @param theProp the name of the system property. - */ - @SuppressWarnings("removal") - public static boolean privilegedGetProperty(String theProp) { - if (System.getSecurityManager() == null) { - return Boolean.getBoolean(theProp); - } else { - return AccessController.doPrivileged( - new GetBooleanAction(theProp)); - } - } -} diff --git a/src/java.base/share/classes/sun/security/action/GetIntegerAction.java b/src/java.base/share/classes/sun/security/action/GetIntegerAction.java deleted file mode 100644 index 2d9a598149cc7..0000000000000 --- a/src/java.base/share/classes/sun/security/action/GetIntegerAction.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 1998, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.security.action; - -import java.security.AccessController; - -/** - * A convenience class for retrieving the integer value of a system property - * as a privileged action. - * - *

An instance of this class can be used as the argument of - * AccessController.doPrivileged. - * - *

The following code retrieves the integer value of the system - * property named "prop" as a privileged action. Since it does - * not pass a default value to be used in case the property - * "prop" is not defined, it has to check the result for - * null: - * - *

- * Integer tmp = java.security.AccessController.doPrivileged
- *     (new sun.security.action.GetIntegerAction("prop"));
- * int i;
- * if (tmp != null) {
- *     i = tmp.intValue();
- * }
- * 
- * - *

The following code retrieves the integer value of the system - * property named "prop" as a privileged action, and also passes - * a default value to be used in case the property "prop" is not - * defined: - * - *

- * int i = ((Integer)java.security.AccessController.doPrivileged(
- *                         new GetIntegerAction("prop", 3))).intValue();
- * 
- * - * @author Roland Schemers - * @see java.security.PrivilegedAction - * @see java.security.AccessController - * @since 1.2 - */ - -public class GetIntegerAction - implements java.security.PrivilegedAction { - private final String theProp; - private final int defaultVal; - private final boolean defaultSet; - - /** - * Constructor that takes the name of the system property whose integer - * value needs to be determined. - * - * @param theProp the name of the system property. - */ - public GetIntegerAction(String theProp) { - this.theProp = theProp; - this.defaultVal = 0; - this.defaultSet = false; - } - - /** - * Constructor that takes the name of the system property and the default - * value of that property. - * - * @param theProp the name of the system property. - * @param defaultVal the default value. - */ - public GetIntegerAction(String theProp, int defaultVal) { - this.theProp = theProp; - this.defaultVal = defaultVal; - this.defaultSet = true; - } - - /** - * Determines the integer value of the system property whose name was - * specified in the constructor. - * - *

If there is no property of the specified name, or if the property - * does not have the correct numeric format, then an Integer - * object representing the default value that was specified in the - * constructor is returned, or null if no default value was - * specified. - * - * @return the Integer value of the property. - */ - public Integer run() { - Integer value = Integer.getInteger(theProp); - if ((value == null) && defaultSet) - return defaultVal; - return value; - } - - /** - * Convenience method to get a property without going through doPrivileged - * if no security manager is present. This is unsafe for inclusion in a - * public API but allowable here since this class is now encapsulated. - * - * Note that this method performs a privileged action using caller-provided - * inputs. The caller of this method should take care to ensure that the - * inputs are not tainted and the returned property is not made accessible - * to untrusted code if it contains sensitive information. - * - * @param theProp the name of the system property. - */ - @SuppressWarnings("removal") - public static Integer privilegedGetProperty(String theProp) { - if (System.getSecurityManager() == null) { - return Integer.getInteger(theProp); - } else { - return AccessController.doPrivileged( - new GetIntegerAction(theProp)); - } - } - - /** - * Convenience method to get a property without going through doPrivileged - * if no security manager is present. This is unsafe for inclusion in a - * public API but allowable here since this class is now encapsulated. - * - * Note that this method performs a privileged action using caller-provided - * inputs. The caller of this method should take care to ensure that the - * inputs are not tainted and the returned property is not made accessible - * to untrusted code if it contains sensitive information. - * - * @param theProp the name of the system property. - * @param defaultVal the default value. - */ - @SuppressWarnings("removal") - public static Integer privilegedGetProperty(String theProp, - int defaultVal) { - Integer value; - if (System.getSecurityManager() == null) { - value = Integer.getInteger(theProp); - } else { - value = AccessController.doPrivileged( - new GetIntegerAction(theProp)); - } - return (value != null) ? value : defaultVal; - } -} diff --git a/src/java.base/share/classes/sun/security/action/GetLongAction.java b/src/java.base/share/classes/sun/security/action/GetLongAction.java deleted file mode 100644 index 795f3af239e77..0000000000000 --- a/src/java.base/share/classes/sun/security/action/GetLongAction.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 1998, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.security.action; - -/** - * A convenience class for retrieving the Long value of a system - * property as a privileged action. - * - *

An instance of this class can be used as the argument of - * AccessController.doPrivileged. - * - *

The following code retrieves the Long value of the system - * property named "prop" as a privileged action. Since it does - * not pass a default value to be used in case the property - * "prop" is not defined, it has to check the result for - * null: - * - *

- * Long tmp = java.security.AccessController.doPrivileged
- *     (new sun.security.action.GetLongAction("prop"));
- * long l;
- * if (tmp != null) {
- *     l = tmp.longValue();
- * }
- * 
- * - *

The following code retrieves the Long value of the system - * property named "prop" as a privileged action, and also passes - * a default value to be used in case the property "prop" is not - * defined: - * - *

- * long l = java.security.AccessController.doPrivileged
- *      (new GetLongAction("prop")).longValue();
- * 
- * - * @author Roland Schemers - * @see java.security.PrivilegedAction - * @see java.security.AccessController - * @since 1.2 - */ - -public class GetLongAction implements java.security.PrivilegedAction { - private final String theProp; - private final long defaultVal; - private final boolean defaultSet; - - /** - * Constructor that takes the name of the system property whose - * Long value needs to be determined. - * - * @param theProp the name of the system property. - */ - public GetLongAction(String theProp) { - this.theProp = theProp; - this.defaultVal = 0; - this.defaultSet = false; - } - - /** - * Constructor that takes the name of the system property and the default - * value of that property. - * - * @param theProp the name of the system property. - * @param defaultVal the default value. - */ - public GetLongAction(String theProp, long defaultVal) { - this.theProp = theProp; - this.defaultVal = defaultVal; - this.defaultSet = true; - } - - /** - * Determines the Long value of the system property whose - * name was specified in the constructor. - * - *

If there is no property of the specified name, or if the property - * does not have the correct numeric format, then a Long - * object representing the default value that was specified in the - * constructor is returned, or null if no default value was - * specified. - * - * @return the Long value of the property. - */ - public Long run() { - Long value = Long.getLong(theProp); - if ((value == null) && defaultSet) - return defaultVal; - return value; - } -} diff --git a/src/java.base/share/classes/sun/security/action/GetPropertyAction.java b/src/java.base/share/classes/sun/security/action/GetPropertyAction.java index 347072de9f90d..8954c615cbae0 100644 --- a/src/java.base/share/classes/sun/security/action/GetPropertyAction.java +++ b/src/java.base/share/classes/sun/security/action/GetPropertyAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -27,9 +27,7 @@ import java.security.AccessController; import java.security.PrivilegedAction; -import java.util.Locale; import java.util.Properties; -import sun.security.util.Debug; /** * A convenience class for retrieving the string value of a system @@ -162,99 +160,4 @@ public Properties run() { ); } } - - /** - * Convenience method for fetching System property values that are timeouts. - * Accepted timeout values may be purely numeric, a numeric value - * followed by "s" (both interpreted as seconds), or a numeric value - * followed by "ms" (interpreted as milliseconds). - * - * @param prop the name of the System property - * @param def a default value (in milliseconds) - * @param dbg a Debug object, if null no debug messages will be sent - * - * @return an integer value corresponding to the timeout value in the System - * property in milliseconds. If the property value is empty, negative, - * or contains non-numeric characters (besides a trailing "s" or "ms") - * then the default value will be returned. If a negative value for - * the "def" parameter is supplied, zero will be returned if the - * property's value does not conform to the allowed syntax. - */ - public static int privilegedGetTimeoutProp(String prop, int def, Debug dbg) { - if (def < 0) { - def = 0; - } - - String rawPropVal = privilegedGetProperty(prop, "").trim(); - if (rawPropVal.length() == 0) { - return def; - } - - // Determine if "ms" or just "s" is on the end of the string. - // We may do a little surgery on the value so we'll retain - // the original value in rawPropVal for debug messages. - boolean isMillis = false; - String propVal = rawPropVal; - if (rawPropVal.toLowerCase(Locale.ROOT).endsWith("ms")) { - propVal = rawPropVal.substring(0, rawPropVal.length() - 2); - isMillis = true; - } else if (rawPropVal.toLowerCase(Locale.ROOT).endsWith("s")) { - propVal = rawPropVal.substring(0, rawPropVal.length() - 1); - } - - // Next check to make sure the string is built only from digits - if (propVal.matches("^\\d+$")) { - try { - int timeout = Integer.parseInt(propVal); - return isMillis ? timeout : timeout * 1000; - } catch (NumberFormatException nfe) { - if (dbg != null) { - dbg.println("Warning: Unexpected " + nfe + - " for timeout value " + rawPropVal + - ". Using default value of " + def + " msec."); - } - return def; - } - } else { - if (dbg != null) { - dbg.println("Warning: Incorrect syntax for timeout value " + - rawPropVal + ". Using default value of " + def + - " msec."); - } - return def; - } - } - - /** - * Convenience method for fetching System property values that are booleans. - * - * @param prop the name of the System property - * @param def a default value - * @param dbg a Debug object, if null no debug messages will be sent - * - * @return a boolean value corresponding to the value in the System property. - * If the property value is neither "true" or "false", the default value - * will be returned. - */ - public static boolean privilegedGetBooleanProp(String prop, boolean def, Debug dbg) { - String rawPropVal = privilegedGetProperty(prop, ""); - if ("".equals(rawPropVal)) { - return def; - } - - String lower = rawPropVal.toLowerCase(Locale.ROOT); - if ("true".equals(lower)) { - return true; - } else if ("false".equals(lower)) { - return false; - } else { - if (dbg != null) { - dbg.println("Warning: Unexpected value for " + prop + - ": " + rawPropVal + - ". Using default value: " + def); - } - return def; - } - } - } diff --git a/src/java.base/share/classes/sun/security/action/PutAllAction.java b/src/java.base/share/classes/sun/security/action/PutAllAction.java deleted file mode 100644 index d8b17993213e7..0000000000000 --- a/src/java.base/share/classes/sun/security/action/PutAllAction.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.security.action; - -import java.util.Map; - -import java.security.Provider; -import java.security.PrivilegedAction; - -/** - * A convenience PrivilegedAction class for setting the properties of - * a provider. See the SunRsaSign provider for a usage example. - * - * @see sun.security.rsa.SunRsaSign - * @author Andreas Sterbenz - * @since 1.5 - */ -public class PutAllAction implements PrivilegedAction { - - private final Provider provider; - private final Map map; - - public PutAllAction(Provider provider, Map map) { - this.provider = provider; - this.map = map; - } - - public Void run() { - provider.putAll(map); - return null; - } - -} diff --git a/src/java.base/share/classes/sun/security/ec/SunEC.java b/src/java.base/share/classes/sun/security/ec/SunEC.java index 7f8c4dba00250..ce38ffe9f53e5 100644 --- a/src/java.base/share/classes/sun/security/ec/SunEC.java +++ b/src/java.base/share/classes/sun/security/ec/SunEC.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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,10 +25,8 @@ package sun.security.ec; -import java.security.AccessController; import java.security.InvalidParameterException; import java.security.NoSuchAlgorithmException; -import java.security.PrivilegedAction; import java.security.Provider; import java.security.ProviderException; import java.util.HashMap; @@ -180,15 +178,9 @@ public Object newInstance(Object ctrParamObj) } } - @SuppressWarnings("removal") public SunEC() { super("SunEC", PROVIDER_VER, "Sun Elliptic Curve provider"); - AccessController.doPrivileged(new PrivilegedAction() { - public Void run() { - putEntries(); - return null; - } - }); + putEntries(); } void putEntries() { diff --git a/src/java.base/share/classes/sun/security/internal/spec/TlsRsaPremasterSecretParameterSpec.java b/src/java.base/share/classes/sun/security/internal/spec/TlsRsaPremasterSecretParameterSpec.java index 21b9db9790911..fa19acfaeb695 100644 --- a/src/java.base/share/classes/sun/security/internal/spec/TlsRsaPremasterSecretParameterSpec.java +++ b/src/java.base/share/classes/sun/security/internal/spec/TlsRsaPremasterSecretParameterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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,8 +25,6 @@ package sun.security.internal.spec; -import sun.security.action.GetBooleanAction; - import java.security.spec.AlgorithmParameterSpec; /** @@ -54,8 +52,8 @@ public class TlsRsaPremasterSecretParameterSpec * Default is "false" (old behavior) for compatibility reasons in * SSLv3/TLSv1. Later protocols (TLSv1.1+) do not use this property. */ - private static final boolean rsaPreMasterSecretFix = GetBooleanAction - .privilegedGetProperty("com.sun.net.ssl.rsaPreMasterSecretFix"); + private static final boolean rsaPreMasterSecretFix = + Boolean.getBoolean("com.sun.net.ssl.rsaPreMasterSecretFix"); private final int clientVersion; private final int serverVersion; diff --git a/src/java.base/share/classes/sun/security/jca/ProviderConfig.java b/src/java.base/share/classes/sun/security/jca/ProviderConfig.java index ace87630dac8c..ce954b3b6a5fc 100644 --- a/src/java.base/share/classes/sun/security/jca/ProviderConfig.java +++ b/src/java.base/share/classes/sun/security/jca/ProviderConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -94,23 +94,11 @@ final class ProviderConfig { // avoid if not available (pre Solaris 10) to reduce startup time // or if disabled via system property private void checkSunPKCS11Solaris() { - @SuppressWarnings("removal") - Boolean o = AccessController.doPrivileged( - new PrivilegedAction() { - public Boolean run() { - File file = new File("/usr/lib/libpkcs11.so"); - if (file.exists() == false) { - return Boolean.FALSE; - } - if ("false".equalsIgnoreCase(System.getProperty - ("sun.security.pkcs11.enable-solaris"))) { - return Boolean.FALSE; - } - return Boolean.TRUE; - } - }); - if (o == Boolean.FALSE) { - tries = MAX_LOAD_TRIES; + File file = new File("/usr/lib/libpkcs11.so"); + if (file.exists() == false || + ("false".equalsIgnoreCase(System.getProperty + ("sun.security.pkcs11.enable-solaris")))) { + tries = MAX_LOAD_TRIES; } } @@ -190,28 +178,22 @@ Provider getProvider() { case "Apple", "apple.security.AppleProvider" -> { // Reflection is needed for compile time as the class // is not available for non-macosx systems - @SuppressWarnings("removal") - var tmp = AccessController.doPrivileged( - new PrivilegedAction() { - public Provider run() { - try { - Class c = Class.forName( - "apple.security.AppleProvider"); - if (Provider.class.isAssignableFrom(c)) { - @SuppressWarnings("deprecation") - Object tmp = c.newInstance(); - return (Provider) tmp; - } - } catch (Exception ex) { - if (debug != null) { - debug.println("Error loading provider Apple"); - ex.printStackTrace(); - } - } - return null; - } - }); - yield tmp; + Provider ap = null; + try { + Class c = Class.forName( + "apple.security.AppleProvider"); + if (Provider.class.isAssignableFrom(c)) { + @SuppressWarnings("deprecation") + Object tmp = c.newInstance(); + ap = (Provider) tmp; + } + } catch (Exception ex) { + if (debug != null) { + debug.println("Error loading provider Apple"); + ex.printStackTrace(); + } + } + yield ap; } default -> { if (isLoading) { @@ -240,83 +222,69 @@ public Provider run() { /** * Load and instantiate the Provider described by this class. * - * NOTE use of doPrivileged(). - * * @return null if the Provider could not be loaded * * @throws ProviderException if executing the Provider's constructor * throws a ProviderException. All other Exceptions are ignored. */ - @SuppressWarnings("removal") private Provider doLoadProvider() { - return AccessController.doPrivileged(new PrivilegedAction() { - public Provider run() { + if (debug != null) { + debug.println("Loading provider " + ProviderConfig.this); + } + try { + Provider p = ProviderLoader.INSTANCE.load(provName); + if (p != null) { + if (hasArgument()) { + p = p.configure(argument); + } if (debug != null) { - debug.println("Loading provider " + ProviderConfig.this); + debug.println("Loaded provider " + p.getName()); } - try { - Provider p = ProviderLoader.INSTANCE.load(provName); - if (p != null) { - if (hasArgument()) { - p = p.configure(argument); - } - if (debug != null) { - debug.println("Loaded provider " + p.getName()); - } - } else { - if (debug != null) { - debug.println("Error loading provider " + - ProviderConfig.this); - } - disableLoad(); - } - return p; - } catch (Exception e) { - if (e instanceof ProviderException) { - // pass up - throw e; - } else { - if (debug != null) { - debug.println("Error loading provider " + - ProviderConfig.this); - e.printStackTrace(); - } - disableLoad(); - return null; - } - } catch (ExceptionInInitializerError err) { - // no sufficient permission to initialize provider class - if (debug != null) { - debug.println("Error loading provider " + ProviderConfig.this); - err.printStackTrace(); - } - disableLoad(); - return null; + } else { + if (debug != null) { + debug.println("Error loading provider " + + ProviderConfig.this); } + disableLoad(); + } + return p; + } catch (Exception e) { + if (e instanceof ProviderException) { + // pass up + throw e; + } else { + if (debug != null) { + debug.println("Error loading provider " + + ProviderConfig.this); + e.printStackTrace(); + } + disableLoad(); + return null; } - }); + } catch (ExceptionInInitializerError err) { + // unable to initialize provider class + if (debug != null) { + debug.println("Error loading provider " + ProviderConfig.this); + err.printStackTrace(); + } + disableLoad(); + return null; + } } /** * Perform property expansion of the provider value. - * - * NOTE use of doPrivileged(). */ - @SuppressWarnings("removal") private static String expand(final String value) { // shortcut if value does not contain any properties if (value.contains("${") == false) { return value; } - return AccessController.doPrivileged(new PrivilegedAction() { - public String run() { - try { - return PropertyExpander.expand(value); - } catch (GeneralSecurityException e) { - throw new ProviderException(e); - } - } - }); + try { + return PropertyExpander.expand(value); + } catch (GeneralSecurityException e) { + throw new ProviderException(e); + } } // Inner class for loading security providers listed in java.security file @@ -356,9 +324,9 @@ public Provider load(String pn) { if (pName.equals(pn)) { return p; } - } catch (SecurityException | ServiceConfigurationError | + } catch (ServiceConfigurationError | InvalidParameterException ex) { - // if provider loading fail due to security permission, + // if provider loading failed // log it and move on to next provider if (debug != null) { debug.println("Encountered " + ex + @@ -385,6 +353,7 @@ public Provider load(String pn) { } } + @SuppressWarnings("deprecation") // Class.newInstance private Provider legacyLoad(String classname) { if (debug != null) { @@ -403,15 +372,7 @@ private Provider legacyLoad(String classname) { return null; } - @SuppressWarnings("removal") - Provider p = AccessController.doPrivileged - (new PrivilegedExceptionAction() { - @SuppressWarnings("deprecation") // Class.newInstance - public Provider run() throws Exception { - return (Provider) provClass.newInstance(); - } - }); - return p; + return (Provider) provClass.newInstance(); } catch (Exception e) { Throwable t; if (e instanceof InvocationTargetException) { @@ -429,7 +390,7 @@ public Provider run() throws Exception { } return null; } catch (ExceptionInInitializerError | NoClassDefFoundError err) { - // no sufficient permission to access/initialize provider class + // unable to access/initialize provider class if (debug != null) { debug.println("Error loading legacy provider " + classname); err.printStackTrace(); diff --git a/src/java.base/share/classes/sun/security/jca/ProviderList.java b/src/java.base/share/classes/sun/security/jca/ProviderList.java index 033ad2e9210c4..b83571405434e 100644 --- a/src/java.base/share/classes/sun/security/jca/ProviderList.java +++ b/src/java.base/share/classes/sun/security/jca/ProviderList.java @@ -27,8 +27,6 @@ import java.util.*; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.security.Provider; import java.security.Provider.Service; import java.security.Security; @@ -87,15 +85,8 @@ public Service getService(String type, String algorithm) { // construct a ProviderList from the security properties // (static provider configuration in the java.security file) - @SuppressWarnings("removal") static ProviderList fromSecurityProperties() { - // doPrivileged() because of Security.getProperty() - return AccessController.doPrivileged( - new PrivilegedAction() { - public ProviderList run() { - return new ProviderList(); - } - }); + return new ProviderList(); } public static ProviderList add(ProviderList providerList, Provider p) { diff --git a/src/java.base/share/classes/sun/security/provider/ConfigFile.java b/src/java.base/share/classes/sun/security/provider/ConfigFile.java index 775e36c61baa6..3642463ade875 100644 --- a/src/java.base/share/classes/sun/security/provider/ConfigFile.java +++ b/src/java.base/share/classes/sun/security/provider/ConfigFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2022, 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 @@ -29,15 +29,10 @@ import java.net.MalformedURLException; import java.net.URI; import java.net.URL; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; import java.security.Security; import java.security.URIParameter; import java.text.MessageFormat; import java.util.*; -import javax.security.auth.AuthPermission; import javax.security.auth.login.AppConfigurationEntry; import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag; import javax.security.auth.login.Configuration; @@ -159,34 +154,18 @@ public Spi(URI uri) { } } - @SuppressWarnings("removal") public Spi(final Configuration.Parameters params) throws IOException { - // call in a doPrivileged - // - // We have already passed the Configuration.getInstance - // security check. Also, this class is not freely accessible - // (it is in the "sun" package). - - try { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Void run() throws IOException { - if (params == null) { - init(); - } else { - if (!(params instanceof URIParameter)) { - throw new IllegalArgumentException - ("Unrecognized parameter: " + params); - } - URIParameter uriParam = (URIParameter)params; - url = uriParam.getURI().toURL(); - init(); - } - return null; - } - }); - } catch (PrivilegedActionException pae) { - throw (IOException)pae.getException(); + if (params == null) { + init(); + } else { + if (!(params instanceof URIParameter)) { + throw new IllegalArgumentException + ("Unrecognized parameter: " + params); + } + URIParameter uriParam = (URIParameter)params; + url = uriParam.getURI().toURL(); + init(); } // if init() throws some other RuntimeException, @@ -198,8 +177,6 @@ public Void run() throws IOException { * configured URL. * * @throws IOException if the Configuration can not be initialized - * @throws SecurityException if the caller does not have permission - * to initialize the Configuration */ private void init() throws IOException { @@ -377,31 +354,15 @@ private void init(URL config, /** * Refresh and reload the Configuration by re-reading all the * login configurations. - * - * @throws SecurityException if the caller does not have permission - * to refresh the Configuration. */ - @SuppressWarnings("removal") @Override public synchronized void engineRefresh() { - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPermission( - new AuthPermission("refreshLoginConfiguration")); + try { + init(); + } catch (IOException ioe) { + throw new SecurityException(ioe.getLocalizedMessage(), ioe); } - - AccessController.doPrivileged(new PrivilegedAction() { - public Void run() { - try { - init(); - } catch (IOException ioe) { - throw new SecurityException(ioe.getLocalizedMessage(), - ioe); - } - return null; - } - }); } private void readConfig(Reader reader, diff --git a/src/java.base/share/classes/sun/security/provider/DRBG.java b/src/java.base/share/classes/sun/security/provider/DRBG.java index 01958285e430a..a340a866068cf 100644 --- a/src/java.base/share/classes/sun/security/provider/DRBG.java +++ b/src/java.base/share/classes/sun/security/provider/DRBG.java @@ -27,9 +27,7 @@ import java.io.IOException; import java.io.InvalidObjectException; -import java.security.AccessController; import java.security.DrbgParameters; -import java.security.PrivilegedAction; import java.security.SecureRandomParameters; import java.security.SecureRandomSpi; import java.security.Security; @@ -93,10 +91,7 @@ public DRBG(SecureRandomParameters params) { byte[] nonce = null; // Can be configured with a security property - - @SuppressWarnings("removal") - String config = AccessController.doPrivileged((PrivilegedAction) - () -> Security.getProperty(PROP_NAME)); + String config = Security.getProperty(PROP_NAME); if (config != null && !config.isEmpty()) { for (String part : config.split(",")) { diff --git a/src/java.base/share/classes/sun/security/provider/FileInputStreamPool.java b/src/java.base/share/classes/sun/security/provider/FileInputStreamPool.java index 67ad6946806b9..a0aae674d6902 100644 --- a/src/java.base/share/classes/sun/security/provider/FileInputStreamPool.java +++ b/src/java.base/share/classes/sun/security/provider/FileInputStreamPool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 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 @@ -65,9 +65,6 @@ class FileInputStreamPool { * @throws FileNotFoundException if the file does not exist, is a directory * rather than a regular file, or for some * other reason cannot be opened for reading. - * @throws SecurityException if a security manager exists and its - * checkRead method denies read - * access to the file. */ static InputStream getInputStream(File file) throws IOException { @@ -78,9 +75,6 @@ static InputStream getInputStream(File file) throws IOException { } // canonicalize the path - // (this also checks the read permission on the file if SecurityManager - // is present, so no checking is needed later when we just return the - // already opened stream) File cfile = file.getCanonicalFile(); // check if it exists in pool diff --git a/src/java.base/share/classes/sun/security/provider/MD4.java b/src/java.base/share/classes/sun/security/provider/MD4.java index 80cd85a837873..97b8a39c0d628 100644 --- a/src/java.base/share/classes/sun/security/provider/MD4.java +++ b/src/java.base/share/classes/sun/security/provider/MD4.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -69,13 +69,7 @@ public final class MD4 extends DigestBase { @java.io.Serial private static final long serialVersionUID = -8850464997518327965L; }; - @SuppressWarnings("removal") - var dummy = AccessController.doPrivileged(new PrivilegedAction() { - public Void run() { - md4Provider.put("MessageDigest.MD4", "sun.security.provider.MD4"); - return null; - } - }); + md4Provider.put("MessageDigest.MD4", "sun.security.provider.MD4"); } public static MessageDigest getInstance() { diff --git a/src/java.base/share/classes/sun/security/provider/SeedGenerator.java b/src/java.base/share/classes/sun/security/provider/SeedGenerator.java index b4c9355bccf55..892afced83eb1 100644 --- a/src/java.base/share/classes/sun/security/provider/SeedGenerator.java +++ b/src/java.base/share/classes/sun/security/provider/SeedGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -149,7 +149,6 @@ public static void generateSeed(byte[] result) { /** * Retrieve some system information, hashed. */ - @SuppressWarnings("removal") static byte[] getSystemEntropy() { final MessageDigest md; @@ -164,57 +163,48 @@ static byte[] getSystemEntropy() { byte b =(byte)System.currentTimeMillis(); md.update(b); - java.security.AccessController.doPrivileged - (new java.security.PrivilegedAction<>() { - @Override - public Void run() { - try { - // System properties can change from machine to machine - Properties p = System.getProperties(); - for (String s: p.stringPropertyNames()) { - md.update(s.getBytes()); - md.update(p.getProperty(s).getBytes()); - } + try { + // System properties can change from machine to machine + Properties p = System.getProperties(); + for (String s: p.stringPropertyNames()) { + md.update(s.getBytes()); + md.update(p.getProperty(s).getBytes()); + } - // Include network adapter names (and a Mac address) - addNetworkAdapterInfo(md); - - // The temporary dir - File f = new File(p.getProperty("java.io.tmpdir")); - int count = 0; - try ( - DirectoryStream stream = - Files.newDirectoryStream(f.toPath())) { - // We use a Random object to choose what file names - // should be used. Otherwise, on a machine with too - // many files, the same first 1024 files always get - // used. Any, We make sure the first 512 files are - // always used. - Random r = new Random(); - for (Path entry: stream) { - if (count < 512 || r.nextBoolean()) { - md.update(entry.getFileName() - .toString().getBytes()); - } - if (count++ > 1024) { - break; - } - } - } - } catch (Exception ex) { - md.update((byte)ex.hashCode()); + // Include network adapter names (and a Mac address) + addNetworkAdapterInfo(md); + + // The temporary dir + File f = new File(p.getProperty("java.io.tmpdir")); + int count = 0; + try (DirectoryStream stream = + Files.newDirectoryStream(f.toPath())) { + // We use a Random object to choose what file names + // should be used. Otherwise, on a machine with too + // many files, the same first 1024 files always get + // used. Any, We make sure the first 512 files are + // always used. + Random r = new Random(); + for (Path entry: stream) { + if (count < 512 || r.nextBoolean()) { + md.update(entry.getFileName().toString().getBytes()); } + if (count++ > 1024) { + break; + } + } + } + } catch (Exception ex) { + md.update((byte)ex.hashCode()); + } - // get Runtime memory stats - Runtime rt = Runtime.getRuntime(); - byte[] memBytes = longToByteArray(rt.totalMemory()); - md.update(memBytes, 0, memBytes.length); - memBytes = longToByteArray(rt.freeMemory()); - md.update(memBytes, 0, memBytes.length); + // get Runtime memory stats + Runtime rt = Runtime.getRuntime(); + byte[] memBytes = longToByteArray(rt.totalMemory()); + md.update(memBytes, 0, memBytes.length); + memBytes = longToByteArray(rt.freeMemory()); + md.update(memBytes, 0, memBytes.length); - return null; - } - }); return md.digest(); } @@ -293,29 +283,19 @@ private static class ThreadedSeedGenerator extends SeedGenerator , e); } - final ThreadGroup[] finalsg = new ThreadGroup[1]; - @SuppressWarnings("removal") - Thread t = java.security.AccessController.doPrivileged - (new java.security.PrivilegedAction<>() { - @Override - public Thread run() { - ThreadGroup parent, group = - Thread.currentThread().getThreadGroup(); - while ((parent = group.getParent()) != null) { - group = parent; - } - finalsg[0] = new ThreadGroup - (group, "SeedGenerator ThreadGroup"); - Thread newT = new Thread(finalsg[0], - ThreadedSeedGenerator.this, - "SeedGenerator Thread", - 0, - false); - newT.setPriority(Thread.MIN_PRIORITY); - newT.setDaemon(true); - return newT; - } - }); + ThreadGroup[] finalsg = new ThreadGroup[1]; + ThreadGroup parent, group = Thread.currentThread().getThreadGroup(); + while ((parent = group.getParent()) != null) { + group = parent; + } + finalsg[0] = new ThreadGroup(group, "SeedGenerator ThreadGroup"); + Thread t = new Thread(finalsg[0], + ThreadedSeedGenerator.this, + "SeedGenerator Thread", + 0, + false); + t.setPriority(Thread.MIN_PRIORITY); + t.setDaemon(true); seedGroup = finalsg[0]; t.start(); } @@ -502,34 +482,25 @@ static class URLSeedGenerator extends SeedGenerator { init(); } - @SuppressWarnings("removal") private void init() throws IOException { @SuppressWarnings("deprecation") - final URL device = new URL(deviceName); + URL device = new URL(deviceName); try { - seedStream = java.security.AccessController.doPrivileged - (new java.security.PrivilegedExceptionAction<>() { - @Override - public InputStream run() throws IOException { - /* - * return a shared InputStream for file URLs and - * avoid buffering. - * The URL.openStream() call wraps InputStream in a - * BufferedInputStream which - * can buffer up to 8K bytes. This read is a - * performance issue for entropy sources which - * can be slow to replenish. - */ - if (device.getProtocol().equalsIgnoreCase("file")) { - File deviceFile = - SunEntries.getDeviceFile(device); - return FileInputStreamPool - .getInputStream(deviceFile); - } else { - return device.openStream(); - } - } - }); + /* + * return a shared InputStream for file URLs and + * avoid buffering. + * The URL.openStream() call wraps InputStream in a + * BufferedInputStream which + * can buffer up to 8K bytes. This read is a + * performance issue for entropy sources which + * can be slow to replenish. + */ + if (device.getProtocol().equalsIgnoreCase("file")) { + File deviceFile = SunEntries.getDeviceFile(device); + seedStream = FileInputStreamPool.getInputStream(deviceFile); + } else { + seedStream = device.openStream(); + } } catch (Exception e) { throw new IOException( "Failed to open " + deviceName, e.getCause()); diff --git a/src/java.base/share/classes/sun/security/provider/Sun.java b/src/java.base/share/classes/sun/security/provider/Sun.java index 9c441216ceead..fbd19ef633e06 100644 --- a/src/java.base/share/classes/sun/security/provider/Sun.java +++ b/src/java.base/share/classes/sun/security/provider/Sun.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -47,7 +47,6 @@ public final class Sun extends Provider { "PKIX CertPathBuilder; LDAP, Collection CertStores, JavaPolicy Policy; " + "JavaLoginConfig Configuration)"; - @SuppressWarnings("removal") public Sun() { /* We are the SUN provider */ super("SUN", PROVIDER_VER, INFO); @@ -55,24 +54,8 @@ public Sun() { Provider p = this; Iterator serviceIter = new SunEntries(p).iterator(); - // if there is no security manager installed, put directly into - // the provider - if (System.getSecurityManager() == null) { - putEntries(serviceIter); - } else { - AccessController.doPrivileged(new PrivilegedAction() { - @Override - public Void run() { - putEntries(serviceIter); - return null; - } - }); - } - } - - void putEntries(Iterator i) { - while (i.hasNext()) { - putService(i.next()); + while (serviceIter.hasNext()) { + putService(serviceIter.next()); } } } diff --git a/src/java.base/share/classes/sun/security/provider/SunEntries.java b/src/java.base/share/classes/sun/security/provider/SunEntries.java index 36278ae445f16..9f5e3447aeb56 100644 --- a/src/java.base/share/classes/sun/security/provider/SunEntries.java +++ b/src/java.base/share/classes/sun/security/provider/SunEntries.java @@ -30,8 +30,6 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.security.Provider; import java.security.Security; import java.util.HashMap; @@ -39,7 +37,6 @@ import java.util.LinkedHashSet; import jdk.internal.util.StaticProperty; -import sun.security.action.GetBooleanAction; import static sun.security.util.SecurityProviderConstants.getAliases; @@ -345,29 +342,24 @@ private void addWithAlias(Provider p, String type, String algo, String cn, private static final String PROP_RNDSOURCE = "securerandom.source"; private static final boolean useLegacyDSA = - GetBooleanAction.privilegedGetProperty - ("jdk.security.legacyDSAKeyPairGenerator"); + Boolean.getBoolean("jdk.security.legacyDSAKeyPairGenerator"); static final String URL_DEV_RANDOM = "file:/dev/random"; static final String URL_DEV_URANDOM = "file:/dev/urandom"; - @SuppressWarnings("removal") - private static final String seedSource = AccessController.doPrivileged( - new PrivilegedAction() { - - @Override - public String run() { - String egdSource = System.getProperty(PROP_EGD, ""); - if (egdSource.length() != 0) { - return egdSource; - } - egdSource = Security.getProperty(PROP_RNDSOURCE); - if (egdSource == null) { - return ""; - } - return egdSource; - } - }); + private static final String seedSource = getOverridableSeedSource(); + + private static String getOverridableSeedSource() { + String egdSource = System.getProperty(PROP_EGD, ""); + if (egdSource.length() != 0) { + return egdSource; + } + egdSource = Security.getProperty(PROP_RNDSOURCE); + if (egdSource == null) { + return ""; + } + return egdSource; + } static { DEF_SECURE_RANDOM_ALGO = (NativePRNG.isAvailable() && @@ -386,8 +378,6 @@ static String getSeedSource() { * URISyntaxException we make a best effort for backwards * compatibility. e.g. space character in deviceName string. * - * Method called within PrivilegedExceptionAction block. - * * Moved from SeedGenerator to avoid initialization problems with * signed providers. */ diff --git a/src/java.base/share/classes/sun/security/provider/VerificationProvider.java b/src/java.base/share/classes/sun/security/provider/VerificationProvider.java index 5734a6f4c3bdd..7f5959b8e77f9 100644 --- a/src/java.base/share/classes/sun/security/provider/VerificationProvider.java +++ b/src/java.base/share/classes/sun/security/provider/VerificationProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -61,7 +61,6 @@ public final class VerificationProvider extends Provider { ACTIVE = b; } - @SuppressWarnings("removal") public VerificationProvider() { super("SunJarVerification", PROVIDER_VER, "Jar Verification Provider"); // register all algorithms normally registered by the Sun and SunRsaSign @@ -75,20 +74,8 @@ public VerificationProvider() { Iterator rsaIter = new SunRsaSignEntries(p).iterator(); - // if there is no security manager installed, put directly into - // the provider - if (System.getSecurityManager() == null) { - putEntries(sunIter); - putEntries(rsaIter); - } else { - AccessController.doPrivileged(new PrivilegedAction() { - public Void run() { - putEntries(sunIter); - putEntries(rsaIter); - return null; - } - }); - } + putEntries(sunIter); + putEntries(rsaIter); } void putEntries(Iterator i) { diff --git a/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java b/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java index 6f1f7b6ad737a..a32d88605c574 100644 --- a/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java +++ b/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java @@ -38,10 +38,10 @@ import java.util.List; import java.util.Map; -import sun.security.action.GetPropertyAction; import sun.security.util.Debug; import sun.security.util.Event; import sun.security.util.IOUtils; +import sun.security.util.SecurityProperties; import sun.security.x509.AccessDescription; import sun.security.x509.AuthorityInfoAccessExtension; import sun.security.x509.GeneralName; @@ -114,7 +114,7 @@ public final class OCSP { */ private static int initializeTimeout(String prop, int def) { int timeoutVal = - GetPropertyAction.privilegedGetTimeoutProp(prop, def, debug); + SecurityProperties.getTimeoutSystemProp(prop, def, debug); if (debug != null) { debug.println(prop + " set to " + timeoutVal + " milliseconds"); } @@ -123,7 +123,7 @@ private static int initializeTimeout(String prop, int def) { private static boolean initializeBoolean(String prop, boolean def) { boolean value = - GetPropertyAction.privilegedGetBooleanProp(prop, def, debug); + SecurityProperties.getBooleanSystemProp(prop, def, debug); if (debug != null) { debug.println(prop + " set to " + value); } diff --git a/src/java.base/share/classes/sun/security/provider/certpath/URICertStore.java b/src/java.base/share/classes/sun/security/provider/certpath/URICertStore.java index 44f11cb098550..28729a56dbdcd 100644 --- a/src/java.base/share/classes/sun/security/provider/certpath/URICertStore.java +++ b/src/java.base/share/classes/sun/security/provider/certpath/URICertStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -51,12 +51,12 @@ import java.util.List; import java.util.Locale; -import sun.security.action.GetPropertyAction; import sun.security.x509.AccessDescription; import sun.security.x509.GeneralNameInterface; import sun.security.x509.URIName; import sun.security.util.Cache; import sun.security.util.Debug; +import sun.security.util.SecurityProperties; /** * A CertStore that retrieves Certificates or @@ -175,7 +175,7 @@ class URICertStore extends CertStoreSpi { */ private static int initializeTimeout(String prop, int def) { int timeoutVal = - GetPropertyAction.privilegedGetTimeoutProp(prop, def, debug); + SecurityProperties.getTimeoutSystemProp(prop, def, debug); if (debug != null) { debug.println(prop + " set to " + timeoutVal + " milliseconds"); } diff --git a/src/java.base/share/classes/sun/security/rsa/RSAKeyFactory.java b/src/java.base/share/classes/sun/security/rsa/RSAKeyFactory.java index 6a9cf6edbf8e7..c6fa1cf8980d1 100644 --- a/src/java.base/share/classes/sun/security/rsa/RSAKeyFactory.java +++ b/src/java.base/share/classes/sun/security/rsa/RSAKeyFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -32,7 +32,6 @@ import java.security.spec.*; import java.util.Arrays; -import sun.security.action.GetPropertyAction; import sun.security.rsa.RSAUtil.KeyType; /** @@ -91,7 +90,7 @@ public class RSAKeyFactory extends KeyFactorySpi { public static final int MAX_RESTRICTED_EXPLEN = 64; private static final boolean restrictExpLen = - "true".equalsIgnoreCase(GetPropertyAction.privilegedGetProperty( + "true".equalsIgnoreCase(System.getProperty( "sun.security.rsa.restrictRSAExponent", "true")); static RSAKeyFactory getInstance(KeyType type) { diff --git a/src/java.base/share/classes/sun/security/rsa/SunRsaSign.java b/src/java.base/share/classes/sun/security/rsa/SunRsaSign.java index 642b97933d5f7..664881ba6af96 100644 --- a/src/java.base/share/classes/sun/security/rsa/SunRsaSign.java +++ b/src/java.base/share/classes/sun/security/rsa/SunRsaSign.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -43,26 +43,11 @@ public final class SunRsaSign extends Provider { @java.io.Serial private static final long serialVersionUID = 866040293550393045L; - @SuppressWarnings("removal") public SunRsaSign() { super("SunRsaSign", PROVIDER_VER, "Sun RSA signature provider"); Provider p = this; - Iterator serviceIter = new SunRsaSignEntries(p).iterator(); - - if (System.getSecurityManager() == null) { - putEntries(serviceIter); - } else { - AccessController.doPrivileged(new PrivilegedAction() { - @Override - public Void run() { - putEntries(serviceIter); - return null; - } - }); - } - } - void putEntries(Iterator i) { + Iterator i = new SunRsaSignEntries(p).iterator(); while (i.hasNext()) { putService(i.next()); } diff --git a/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java b/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java index 28f32742a6127..dc5b1aafb2017 100644 --- a/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java +++ b/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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,9 +25,7 @@ package sun.security.util; -import java.security.AccessController; import java.security.AlgorithmConstraints; -import java.security.PrivilegedAction; import java.security.Security; import java.util.Arrays; import java.util.Collections; @@ -48,14 +46,7 @@ protected AbstractAlgorithmConstraints(AlgorithmDecomposer decomposer) { // Get algorithm constraints from the specified security property. static Set getAlgorithms(String propertyName) { - @SuppressWarnings("removal") - String property = AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public String run() { - return Security.getProperty(propertyName); - } - }); + String property = Security.getProperty(propertyName); String[] algorithmsInProperty = null; if (property != null && !property.isEmpty()) { diff --git a/src/java.base/share/classes/sun/security/util/Debug.java b/src/java.base/share/classes/sun/security/util/Debug.java index 9f344601e7e38..59bc810ca575a 100644 --- a/src/java.base/share/classes/sun/security/util/Debug.java +++ b/src/java.base/share/classes/sun/security/util/Debug.java @@ -34,7 +34,6 @@ import java.util.regex.Pattern; import java.util.regex.Matcher; import java.util.Locale; -import sun.security.action.GetPropertyAction; /** * A utility class for debugging. @@ -54,10 +53,9 @@ public class Debug { private static final String THREAD_OPTION = "+thread"; static { - args = GetPropertyAction.privilegedGetProperty("java.security.debug"); + args = System.getProperty("java.security.debug"); - String args2 = GetPropertyAction - .privilegedGetProperty("java.security.auth.debug"); + String args2 = System.getProperty("java.security.auth.debug"); if (args == null) { args = args2; diff --git a/src/java.base/share/classes/sun/security/util/DomainName.java b/src/java.base/share/classes/sun/security/util/DomainName.java index 5182ad1b5caf7..53a646c8102ed 100644 --- a/src/java.base/share/classes/sun/security/util/DomainName.java +++ b/src/java.base/share/classes/sun/security/util/DomainName.java @@ -32,8 +32,6 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; @@ -205,21 +203,12 @@ private static Rules createRules(String tld) { } private static InputStream getPubSuffixStream() { - @SuppressWarnings("removal") - InputStream is = AccessController.doPrivileged( - new PrivilegedAction<>() { - @Override - public InputStream run() { - File f = new File(StaticProperty.javaHome(), - "lib/security/public_suffix_list.dat"); - try { - return new FileInputStream(f); - } catch (FileNotFoundException e) { - return null; - } - } - } - ); + InputStream is = null; + File f = new File(System.getProperty("java.home"), + "lib/security/public_suffix_list.dat"); + try { + is = new FileInputStream(f); + } catch (FileNotFoundException e) { } if (is == null) { if (SSLLogger.isOn && SSLLogger.isOn("ssl") && SSLLogger.isOn("trustmanager")) { diff --git a/src/java.base/share/classes/sun/security/util/FilePermCompat.java b/src/java.base/share/classes/sun/security/util/FilePermCompat.java index 1bba80df544a3..72db4eb93bc05 100644 --- a/src/java.base/share/classes/sun/security/util/FilePermCompat.java +++ b/src/java.base/share/classes/sun/security/util/FilePermCompat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, 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 @@ -40,7 +40,7 @@ public class FilePermCompat { public static final boolean compat; static { - String flag = SecurityProperties.privilegedGetOverridable( + String flag = SecurityProperties.getOverridableProperty( "jdk.io.permissionsUseCanonicalPath"); if (flag == null) { flag = "false"; diff --git a/src/java.base/share/classes/sun/security/util/HostnameChecker.java b/src/java.base/share/classes/sun/security/util/HostnameChecker.java index 71a491813eb96..1374bc6d53521 100644 --- a/src/java.base/share/classes/sun/security/util/HostnameChecker.java +++ b/src/java.base/share/classes/sun/security/util/HostnameChecker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -153,7 +153,7 @@ private static void matchIP(String expectedIP, X509Certificate cert) InetAddress.getByName(ipAddress))) { return; } - } catch (UnknownHostException | SecurityException e) {} + } catch (UnknownHostException e) {} } } } diff --git a/src/java.base/share/classes/sun/security/util/LazyCodeSourcePermissionCollection.java b/src/java.base/share/classes/sun/security/util/LazyCodeSourcePermissionCollection.java deleted file mode 100644 index 68a1f70bb0161..0000000000000 --- a/src/java.base/share/classes/sun/security/util/LazyCodeSourcePermissionCollection.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.security.util; - -import java.io.File; -import java.io.FilePermission; -import java.io.IOException; -import java.net.URL; -import java.security.CodeSource; -import java.security.Permission; -import java.security.PermissionCollection; -import java.util.Enumeration; - -/** - * This {@code PermissionCollection} implementation delegates to another - * {@code PermissionCollection}, taking care to lazily add the permission needed - * to read from the given {@code CodeSource} at first use, i.e., when either of - * {@link #elements}, {@link #implies} or {@link #toString} is called, or when - * the collection is serialized. - */ -public final class LazyCodeSourcePermissionCollection - extends PermissionCollection -{ - @java.io.Serial - private static final long serialVersionUID = -6727011328946861783L; - private final PermissionCollection perms; - private final CodeSource cs; - private volatile boolean permissionAdded; - - public LazyCodeSourcePermissionCollection(PermissionCollection perms, - CodeSource cs) { - this.perms = perms; - this.cs = cs; - } - - private void ensureAdded() { - if (!permissionAdded) { - synchronized(perms) { - if (permissionAdded) - return; - - // open connection to determine the permission needed - URL location = cs.getLocation(); - if (location != null) { - try { - Permission p = location.openConnection().getPermission(); - if (p != null) { - // for directories then need recursive access - if (p instanceof FilePermission) { - String path = p.getName(); - if (path.endsWith(File.separator)) { - path += "-"; - p = new FilePermission(path, - SecurityConstants.FILE_READ_ACTION); - } - } - perms.add(p); - } - } catch (IOException ioe) { - } - } - if (isReadOnly()) { - perms.setReadOnly(); - } - permissionAdded = true; - } - } - } - - @Override - public void add(Permission permission) { - if (isReadOnly()) - throw new SecurityException( - "attempt to add a Permission to a readonly PermissionCollection"); - perms.add(permission); - } - - @Override - public boolean implies(Permission permission) { - ensureAdded(); - return perms.implies(permission); - } - - @Override - public Enumeration elements() { - ensureAdded(); - return perms.elements(); - } - - @Override - public String toString() { - ensureAdded(); - return perms.toString(); - } - - /** - * On serialization, initialize and replace with the underlying - * permissions. This removes the laziness on deserialization. - */ - @java.io.Serial - private Object writeReplace() { - ensureAdded(); - return perms; - } -} diff --git a/src/java.base/share/classes/sun/security/util/LocalizedMessage.java b/src/java.base/share/classes/sun/security/util/LocalizedMessage.java index 99742b3b80f68..ffe092a6b6d4b 100644 --- a/src/java.base/share/classes/sun/security/util/LocalizedMessage.java +++ b/src/java.base/share/classes/sun/security/util/LocalizedMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -49,8 +49,8 @@ public class LocalizedMessage { /** * A LocalizedMessage can be instantiated with a key and formatted with * arguments later in the style of MessageFormat. This organization - * allows the actual formatting (and associated permission checks) to be - * avoided unless the resulting string is needed. + * allows the actual formatting to be avoided unless the resulting string + * is needed. * @param key */ public LocalizedMessage(String key) { diff --git a/src/java.base/share/classes/sun/security/util/SecurityConstants.java b/src/java.base/share/classes/sun/security/util/SecurityConstants.java index 9d49bbba0a1a7..34f80faa3ab36 100644 --- a/src/java.base/share/classes/sun/security/util/SecurityConstants.java +++ b/src/java.base/share/classes/sun/security/util/SecurityConstants.java @@ -25,12 +25,7 @@ package sun.security.util; -import java.lang.reflect.ReflectPermission; -import java.net.NetPermission; -import java.net.SocketPermission; import java.security.AllPermission; -import java.security.SecurityPermission; -import sun.security.action.GetPropertyAction; /** * Permission constants and string constants used to create permissions @@ -63,72 +58,9 @@ private SecurityConstants () { // Permission constants used in the various checkPermission() calls in JDK. - // java.lang.Class, java.lang.SecurityManager, java.lang.System, - // java.net.URLConnection, java.security.AllPermission, java.security.Policy, - // sun.security.provider.PolicyFile + // java.net.URLConnection, java.security.AllPermission public static final AllPermission ALL_PERMISSION = new AllPermission(); - // java.net.URL - public static final NetPermission SPECIFY_HANDLER_PERMISSION = - new NetPermission("specifyStreamHandler"); - - // java.net.ServerSocket, java.net.Socket - public static final NetPermission SET_SOCKETIMPL_PERMISSION = - new NetPermission("setSocketImpl"); - - // java.lang.SecurityManager, sun.applet.AppletPanel - public static final RuntimePermission CREATE_CLASSLOADER_PERMISSION = - new RuntimePermission("createClassLoader"); - - // java.lang.SecurityManager - public static final RuntimePermission CHECK_MEMBER_ACCESS_PERMISSION = - new RuntimePermission("accessDeclaredMembers"); - - // java.lang.SecurityManager, sun.applet.AppletSecurity - public static final RuntimePermission MODIFY_THREAD_PERMISSION = - new RuntimePermission("modifyThread"); - - // java.lang.SecurityManager, sun.applet.AppletSecurity - public static final RuntimePermission MODIFY_THREADGROUP_PERMISSION = - new RuntimePermission("modifyThreadGroup"); - - // java.lang.Class - public static final RuntimePermission GET_PD_PERMISSION = - new RuntimePermission("getProtectionDomain"); - - // java.lang.Thread - public static final RuntimePermission GET_STACK_TRACE_PERMISSION = - new RuntimePermission("getStackTrace"); - - // java.lang.Thread - public static final RuntimePermission SUBCLASS_IMPLEMENTATION_PERMISSION = - new RuntimePermission("enableContextClassLoaderOverride"); - - // java.security.AccessControlContext - public static final SecurityPermission CREATE_ACC_PERMISSION = - new SecurityPermission("createAccessControlContext"); - - // java.security.AccessControlContext - public static final SecurityPermission GET_COMBINER_PERMISSION = - new SecurityPermission("getDomainCombiner"); - - // java.security.Policy, java.security.ProtectionDomain - public static final SecurityPermission GET_POLICY_PERMISSION = - new SecurityPermission ("getPolicy"); - - // java.lang.SecurityManager - public static final SocketPermission LOCAL_LISTEN_PERMISSION = - new SocketPermission("localhost:0", SOCKET_LISTEN_ACTION); - public static final String PROVIDER_VER = - GetPropertyAction.privilegedGetProperty("java.specification.version"); - - // java.lang.reflect.AccessibleObject - public static final ReflectPermission ACCESS_PERMISSION = - new ReflectPermission("suppressAccessChecks"); - - // sun.reflect.ReflectionFactory - public static final RuntimePermission REFLECTION_FACTORY_ACCESS_PERMISSION = - new RuntimePermission("reflectionFactoryAccess"); - + System.getProperty("java.specification.version"); } diff --git a/src/java.base/share/classes/sun/security/util/SecurityProperties.java b/src/java.base/share/classes/sun/security/util/SecurityProperties.java index a07c9b743fc62..98bc71d829bec 100644 --- a/src/java.base/share/classes/sun/security/util/SecurityProperties.java +++ b/src/java.base/share/classes/sun/security/util/SecurityProperties.java @@ -26,10 +26,12 @@ package sun.security.util; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.security.Security; +import java.util.Locale; +/** + * Utility methods for retrieving security and system properties. + */ public class SecurityProperties { public static final boolean INCLUDE_JAR_NAME_IN_EXCEPTIONS @@ -42,15 +44,6 @@ public class SecurityProperties { * @param propName the name of the system or security property * @return the value of the system or security property */ - @SuppressWarnings("removal") - public static String privilegedGetOverridable(String propName) { - if (System.getSecurityManager() == null) { - return getOverridableProperty(propName); - } else { - return AccessController.doPrivileged((PrivilegedAction) () -> getOverridableProperty(propName)); - } - } - public static String getOverridableProperty(String propName) { String val = System.getProperty(propName); if (val == null) { @@ -69,7 +62,7 @@ public static String getOverridableProperty(String propName) { * contains refName, false otherwise */ public static boolean includedInExceptions(String refName) { - String val = privilegedGetOverridable("jdk.includeInExceptions"); + String val = getOverridableProperty("jdk.includeInExceptions"); if (val == null) { return false; } @@ -83,4 +76,98 @@ public static boolean includedInExceptions(String refName) { } return false; } + + /** + * Convenience method for fetching System property values that are timeouts. + * Accepted timeout values may be purely numeric, a numeric value + * followed by "s" (both interpreted as seconds), or a numeric value + * followed by "ms" (interpreted as milliseconds). + * + * @param prop the name of the System property + * @param def a default value (in milliseconds) + * @param dbg a Debug object, if null no debug messages will be sent + * + * @return an integer value corresponding to the timeout value in the System + * property in milliseconds. If the property value is empty, negative, + * or contains non-numeric characters (besides a trailing "s" or "ms") + * then the default value will be returned. If a negative value for + * the "def" parameter is supplied, zero will be returned if the + * property's value does not conform to the allowed syntax. + */ + public static int getTimeoutSystemProp(String prop, int def, Debug dbg) { + if (def < 0) { + def = 0; + } + + String rawPropVal = System.getProperty(prop, "").trim(); + if (rawPropVal.length() == 0) { + return def; + } + + // Determine if "ms" or just "s" is on the end of the string. + // We may do a little surgery on the value so we'll retain + // the original value in rawPropVal for debug messages. + boolean isMillis = false; + String propVal = rawPropVal; + if (rawPropVal.toLowerCase(Locale.ROOT).endsWith("ms")) { + propVal = rawPropVal.substring(0, rawPropVal.length() - 2); + isMillis = true; + } else if (rawPropVal.toLowerCase(Locale.ROOT).endsWith("s")) { + propVal = rawPropVal.substring(0, rawPropVal.length() - 1); + } + + // Next check to make sure the string is built only from digits + if (propVal.matches("^\\d+$")) { + try { + int timeout = Integer.parseInt(propVal); + return isMillis ? timeout : timeout * 1000; + } catch (NumberFormatException nfe) { + if (dbg != null) { + dbg.println("Warning: Unexpected " + nfe + + " for timeout value " + rawPropVal + + ". Using default value of " + def + " msec."); + } + return def; + } + } else { + if (dbg != null) { + dbg.println("Warning: Incorrect syntax for timeout value " + + rawPropVal + ". Using default value of " + def + + " msec."); + } + return def; + } + } + + /** + * Convenience method for fetching System property values that are booleans. + * + * @param prop the name of the System property + * @param def a default value + * @param dbg a Debug object, if null no debug messages will be sent + * + * @return a boolean value corresponding to the value in the System property. + * If the property value is neither "true" or "false", the default value + * will be returned. + */ + public static boolean getBooleanSystemProp(String prop, boolean def, Debug dbg) { + String rawPropVal = System.getProperty(prop, ""); + if ("".equals(rawPropVal)) { + return def; + } + + String lower = rawPropVal.toLowerCase(Locale.ROOT); + if ("true".equals(lower)) { + return true; + } else if ("false".equals(lower)) { + return false; + } else { + if (dbg != null) { + dbg.println("Warning: Unexpected value for " + prop + + ": " + rawPropVal + + ". Using default value: " + def); + } + return def; + } + } } diff --git a/src/java.base/share/classes/sun/security/util/SecurityProviderConstants.java b/src/java.base/share/classes/sun/security/util/SecurityProviderConstants.java index 66c88cd63a970..3ae9375fae195 100644 --- a/src/java.base/share/classes/sun/security/util/SecurityProviderConstants.java +++ b/src/java.base/share/classes/sun/security/util/SecurityProviderConstants.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -34,7 +34,6 @@ import java.security.NoSuchAlgorithmException; import javax.crypto.Cipher; import javax.crypto.spec.DHParameterSpec; -import sun.security.action.GetPropertyAction; /** * Various constants such as version number, default key length, used by @@ -175,8 +174,7 @@ public static final int getDefAESKeySize() { "jdk.security.defaultKeySize"; static { - String keyLengthStr = GetPropertyAction.privilegedGetProperty - (KEY_LENGTH_PROP); + String keyLengthStr = System.getProperty(KEY_LENGTH_PROP); int dsaKeySize = 2048; int rsaKeySize = 3072; int rsaSsaPssKeySize = rsaKeySize; // default to same value as RSA diff --git a/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java b/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java index 1576388b65322..7accd3cbf10bb 100644 --- a/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java +++ b/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java @@ -37,7 +37,6 @@ import java.util.jar.Manifest; import jdk.internal.util.ArraysSupport; -import sun.security.action.GetIntegerAction; import sun.security.jca.Providers; import sun.security.pkcs.PKCS7; import sun.security.pkcs.SignerInfo; @@ -847,8 +846,7 @@ private static int initializeMaxSigFileSize() { * the maximum allowed number of bytes for the signature-related files * in a JAR file. */ - int tmp = GetIntegerAction.privilegedGetProperty( - "jdk.jar.maxSignatureFileSize", 16000000); + int tmp = Integer.getInteger("jdk.jar.maxSignatureFileSize", 16000000); if (tmp < 0 || tmp > MAX_ARRAY_SIZE) { if (debug != null) { debug.println("The default signature file size of 16000000 bytes " + diff --git a/src/java.base/unix/classes/sun/security/provider/NativePRNG.java b/src/java.base/unix/classes/sun/security/provider/NativePRNG.java index edc5197df2c0a..a814746d96016 100644 --- a/src/java.base/unix/classes/sun/security/provider/NativePRNG.java +++ b/src/java.base/unix/classes/sun/security/provider/NativePRNG.java @@ -126,75 +126,68 @@ private static URL getEgdUrl() { /** * Create a RandomIO object for all I/O of this Variant type. */ - @SuppressWarnings("removal") private static RandomIO initIO(final Variant v) { - return AccessController.doPrivileged( - new PrivilegedAction<>() { - @Override - public RandomIO run() { - - File seedFile; - File nextFile; - - switch(v) { - case MIXED: - URL egdUrl; - File egdFile = null; - - if ((egdUrl = getEgdUrl()) != null) { - try { - egdFile = SunEntries.getDeviceFile(egdUrl); - } catch (IOException e) { - // Swallow, seedFile is still null - } - } - // Try egd first. - if ((egdFile != null) && egdFile.canRead()) { - seedFile = egdFile; - } else { - // fall back to /dev/random. - seedFile = new File(NAME_RANDOM); - } - nextFile = new File(NAME_URANDOM); - break; - - case BLOCKING: - seedFile = new File(NAME_RANDOM); - nextFile = new File(NAME_RANDOM); - break; - - case NONBLOCKING: - seedFile = new File(NAME_URANDOM); - nextFile = new File(NAME_URANDOM); - break; - - default: - // Shouldn't happen! - return null; - } + File seedFile; + File nextFile; - if (debug != null) { - debug.println("NativePRNG." + v + - " seedFile: " + seedFile + - " nextFile: " + nextFile); - } + switch(v) { + case MIXED: + URL egdUrl; + File egdFile = null; - if (!seedFile.canRead() || !nextFile.canRead()) { - if (debug != null) { - debug.println("NativePRNG." + v + - " Couldn't read Files."); - } - return null; - } - - try { - return new RandomIO(seedFile, nextFile); - } catch (Exception e) { - return null; - } + if ((egdUrl = getEgdUrl()) != null) { + try { + egdFile = SunEntries.getDeviceFile(egdUrl); + } catch (IOException e) { + // Swallow, seedFile is still null } - }); + } + + // Try egd first. + if ((egdFile != null) && egdFile.canRead()) { + seedFile = egdFile; + } else { + // fall back to /dev/random. + seedFile = new File(NAME_RANDOM); + } + nextFile = new File(NAME_URANDOM); + break; + + case BLOCKING: + seedFile = new File(NAME_RANDOM); + nextFile = new File(NAME_RANDOM); + break; + + case NONBLOCKING: + seedFile = new File(NAME_URANDOM); + nextFile = new File(NAME_URANDOM); + break; + + default: + // Shouldn't happen! + return null; + } + + if (debug != null) { + debug.println("NativePRNG." + v + + " seedFile: " + seedFile + + " nextFile: " + nextFile); + } + + if (!seedFile.canRead() || !nextFile.canRead()) { + if (debug != null) { + debug.println("NativePRNG." + v + + " Couldn't read Files."); + } + return null; + } + + try { + return new RandomIO(seedFile, nextFile); + } catch (Exception e) { + return null; + } } // return whether the NativePRNG is available @@ -457,22 +450,15 @@ private byte[] implGenerateSeed(int numBytes) { // supply random bytes to the OS // write to "seed" if possible // always add the seed to our mixing random - @SuppressWarnings("removal") private void implSetSeed(byte[] seed) { synchronized (LOCK_SET_SEED) { if (seedOutInitialized == false) { seedOutInitialized = true; - seedOut = AccessController.doPrivileged( - new PrivilegedAction<>() { - @Override - public OutputStream run() { - try { - return new FileOutputStream(seedFile, true); - } catch (Exception e) { - return null; - } - } - }); + try { + seedOut = new FileOutputStream(seedFile, true); + } catch (Exception e) { + seedOut = null; + } } if (seedOut != null) { try { diff --git a/src/java.naming/share/classes/com/sun/naming/internal/ObjectFactoriesFilter.java b/src/java.naming/share/classes/com/sun/naming/internal/ObjectFactoriesFilter.java index a80b59927d3d9..c7d50778d7bfa 100644 --- a/src/java.naming/share/classes/com/sun/naming/internal/ObjectFactoriesFilter.java +++ b/src/java.naming/share/classes/com/sun/naming/internal/ObjectFactoriesFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -220,7 +220,7 @@ private static ConfiguredFilter initializeFilter(String filterPropertyName, // Get security or system property value private static String getFilterPropertyValue(String propertyName, String defaultValue) { - String propVal = SecurityProperties.privilegedGetOverridable(propertyName); + String propVal = SecurityProperties.getOverridableProperty(propertyName); return propVal != null ? propVal : defaultValue; } } diff --git a/src/java.security.jgss/share/classes/sun/security/krb5/Config.java b/src/java.security.jgss/share/classes/sun/security/krb5/Config.java index a9ea9d23eb11c..c92a106850ba6 100644 --- a/src/java.security.jgss/share/classes/sun/security/krb5/Config.java +++ b/src/java.security.jgss/share/classes/sun/security/krb5/Config.java @@ -72,7 +72,7 @@ public class Config { static { String disableReferralsProp = - SecurityProperties.privilegedGetOverridable( + SecurityProperties.getOverridableProperty( "sun.security.krb5.disableReferrals"); if (disableReferralsProp != null) { DISABLE_REFERRALS = "true".equalsIgnoreCase(disableReferralsProp); @@ -82,7 +82,7 @@ public class Config { int maxReferralsValue = 5; String maxReferralsProp = - SecurityProperties.privilegedGetOverridable( + SecurityProperties.getOverridableProperty( "sun.security.krb5.maxReferrals"); try { maxReferralsValue = Integer.parseInt(maxReferralsProp); diff --git a/src/java.security.jgss/share/classes/sun/security/krb5/Credentials.java b/src/java.security.jgss/share/classes/sun/security/krb5/Credentials.java index 9482177c17410..f9076a9b0dd6c 100644 --- a/src/java.security.jgss/share/classes/sun/security/krb5/Credentials.java +++ b/src/java.security.jgss/share/classes/sun/security/krb5/Credentials.java @@ -67,7 +67,7 @@ public class Credentials { private static boolean alreadyTried = false; public static final boolean S4U2PROXY_ACCEPT_NON_FORWARDABLE - = "true".equalsIgnoreCase(SecurityProperties.privilegedGetOverridable( + = "true".equalsIgnoreCase(SecurityProperties.getOverridableProperty( "jdk.security.krb5.s4u2proxy.acceptNonForwardableServiceTicket")); private Credentials proxy = null; diff --git a/src/java.security.jgss/share/classes/sun/security/krb5/PrincipalName.java b/src/java.security.jgss/share/classes/sun/security/krb5/PrincipalName.java index 9bee88eab9beb..400843ff41742 100644 --- a/src/java.security.jgss/share/classes/sun/security/krb5/PrincipalName.java +++ b/src/java.security.jgss/share/classes/sun/security/krb5/PrincipalName.java @@ -109,7 +109,7 @@ public class PrincipalName implements Cloneable { private static final boolean NAME_CASE_SENSITIVE_IN_MATCH = "true".equalsIgnoreCase( - SecurityProperties.privilegedGetOverridable( + SecurityProperties.getOverridableProperty( "jdk.security.krb5.name.case.sensitive")); diff --git a/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java b/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java index 8599ffd81b8f9..a5b128f7129de 100644 --- a/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java +++ b/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java @@ -358,7 +358,7 @@ public sun.security.krb5.Credentials getInitialCreds() { } boolean force; - String prop = SecurityProperties.privilegedGetOverridable( + String prop = SecurityProperties.getOverridableProperty( "jdk.security.krb5.default.initiate.credential"); if (prop == null) { prop = "always-impersonate"; diff --git a/test/jdk/sun/security/action/Generify.java b/test/jdk/sun/security/action/Generify.java index 09cbb3fbb4235..4ddbc299a47a1 100644 --- a/test/jdk/sun/security/action/Generify.java +++ b/test/jdk/sun/security/action/Generify.java @@ -35,37 +35,8 @@ public class Generify { public static void main(String[] args) throws Exception { - long larg = 1234567890L; - - System.setProperty("boolean", "true"); - System.setProperty("integer", "9"); - System.setProperty("long", Long.toString(larg)); System.setProperty("property", "propertyvalue"); - Boolean b = AccessController.doPrivileged - (new GetBooleanAction("boolean")); - if (b.booleanValue() == true) { - System.out.println("boolean test passed"); - } else { - throw new SecurityException("boolean test failed"); - } - - Integer i = AccessController.doPrivileged - (new GetIntegerAction("integer")); - if (i.intValue() == 9) { - System.out.println("integer test passed"); - } else { - throw new SecurityException("integer test failed"); - } - - Long l = AccessController.doPrivileged - (new GetLongAction("long")); - if (l.longValue() == larg) { - System.out.println("long test passed"); - } else { - throw new SecurityException("long test failed"); - } - String prop = AccessController.doPrivileged (new GetPropertyAction("property")); if (prop.equals("propertyvalue")) { diff --git a/test/jdk/sun/security/action/GetLongAction/ReturnNullIfNoDefault.java b/test/jdk/sun/security/action/GetLongAction/ReturnNullIfNoDefault.java deleted file mode 100644 index be46557501929..0000000000000 --- a/test/jdk/sun/security/action/GetLongAction/ReturnNullIfNoDefault.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 1998, 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 4173993 - * @summary Make sure "null" is returned if property does not exist (or has - * wrong numeric format) and no default has been specified. - * @modules java.base/sun.security.action - */ - -import sun.security.action.*; - -public class ReturnNullIfNoDefault { - - public static void main(String[] args) throws Exception { - long larg = 1234567890L; - - GetLongAction ac = new GetLongAction("test"); - if (ac.run() != null) - throw new Exception("Returned value is not null"); - - ac = new GetLongAction("test", larg); - long ret = ((Long)ac.run()).longValue(); - if (ret != larg) - throw new Exception("Returned value differs from default"); - - System.setProperty("test", Long.toString(larg)); - ac = new GetLongAction("test"); - ret = ((Long)ac.run()).longValue(); - if (ret != larg) - throw new Exception("Returned value differs from property"); - } -} From 3a3bcd53d0b9aa55dcbc15de4d8278ce3258b31e Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Mon, 2 Dec 2024 22:26:20 +0000 Subject: [PATCH 03/62] 8344800: Add W3C DTDs and XSDs to the JDK built-in Catalog Reviewed-by: lancea, rriggs --- make/modules/java.xml/Java.gmk | 2 +- .../internal/impl/XMLEntityManager.java | 6 +- .../xml/internal/jdkcatalog/JDKCatalog.xml | 119 +- .../jdkcatalog/w3c/dtd/schema10/XMLSchema.dtd | 513 +++ .../jdkcatalog/w3c/dtd/schema10/datatypes.dtd | 222 ++ .../jdkcatalog/w3c/dtd/xhtml10/xhtml-lat1.ent | 196 ++ .../w3c/dtd/xhtml10/xhtml-special.ent | 80 + .../w3c/dtd/xhtml10/xhtml-symbol.ent | 237 ++ .../w3c/dtd/xhtml10/xhtml1-frameset.dtd | 1235 +++++++ .../w3c/dtd/xhtml10/xhtml1-strict.dtd | 978 ++++++ .../w3c/dtd/xhtml10/xhtml1-transitional.dtd | 1201 +++++++ .../w3c/dtd/xhtml11/xhtml-attribs-1.mod | 142 + .../w3c/dtd/xhtml11/xhtml-base-1.mod | 53 + .../w3c/dtd/xhtml11/xhtml-bdo-1.mod | 47 + .../w3c/dtd/xhtml11/xhtml-blkphras-1.mod | 164 + .../w3c/dtd/xhtml11/xhtml-blkpres-1.mod | 40 + .../w3c/dtd/xhtml11/xhtml-blkstruct-1.mod | 57 + .../w3c/dtd/xhtml11/xhtml-charent-1.mod | 39 + .../w3c/dtd/xhtml11/xhtml-csismap-1.mod | 114 + .../w3c/dtd/xhtml11/xhtml-datatypes-1.mod | 103 + .../w3c/dtd/xhtml11/xhtml-edit-1.mod | 66 + .../w3c/dtd/xhtml11/xhtml-events-1.mod | 135 + .../w3c/dtd/xhtml11/xhtml-form-1.mod | 292 ++ .../w3c/dtd/xhtml11/xhtml-framework-1.mod | 97 + .../w3c/dtd/xhtml11/xhtml-hypertext-1.mod | 54 + .../w3c/dtd/xhtml11/xhtml-image-1.mod | 51 + .../w3c/dtd/xhtml11/xhtml-inlphras-1.mod | 203 ++ .../w3c/dtd/xhtml11/xhtml-inlpres-1.mod | 138 + .../w3c/dtd/xhtml11/xhtml-inlstruct-1.mod | 62 + .../w3c/dtd/xhtml11/xhtml-inlstyle-1.mod | 34 + .../w3c/dtd/xhtml11/xhtml-legacy-1.mod | 400 +++ .../w3c/dtd/xhtml11/xhtml-link-1.mod | 59 + .../w3c/dtd/xhtml11/xhtml-list-1.mod | 129 + .../w3c/dtd/xhtml11/xhtml-meta-1.mod | 47 + .../w3c/dtd/xhtml11/xhtml-object-1.mod | 60 + .../w3c/dtd/xhtml11/xhtml-param-1.mod | 48 + .../w3c/dtd/xhtml11/xhtml-pres-1.mod | 38 + .../w3c/dtd/xhtml11/xhtml-qname-1.mod | 318 ++ .../w3c/dtd/xhtml11/xhtml-ruby-1.mod | 242 ++ .../w3c/dtd/xhtml11/xhtml-script-1.mod | 67 + .../w3c/dtd/xhtml11/xhtml-ssismap-1.mod | 32 + .../w3c/dtd/xhtml11/xhtml-struct-1.mod | 136 + .../w3c/dtd/xhtml11/xhtml-style-1.mod | 48 + .../w3c/dtd/xhtml11/xhtml-table-1.mod | 333 ++ .../w3c/dtd/xhtml11/xhtml-text-1.mod | 52 + .../w3c/dtd/xhtml11/xhtml11-model-1.mod | 250 ++ .../jdkcatalog/w3c/dtd/xhtml11/xhtml11.dtd | 323 ++ .../w3c/dtd/xmlspec2_10/xmlspec.dtd | 2778 ++++++++++++++++ .../w3c/xsd/schema10/XMLSchema-datatypes.xsd | 154 + .../jdkcatalog/w3c/xsd/schema10/XMLSchema.xsd | 2364 ++++++++++++++ .../w3c/xsd/xhtml10/xhtml1-frameset.xsd | 2847 +++++++++++++++++ .../w3c/xsd/xhtml10/xhtml1-strict.xsd | 2211 +++++++++++++ .../w3c/xsd/xhtml10/xhtml1-transitional.xsd | 2755 ++++++++++++++++ .../w3c/xsd/xhtml11/xhtml-attribs-1.xsd | 73 + .../w3c/xsd/xhtml11/xhtml-base-1.xsd | 36 + .../w3c/xsd/xhtml11/xhtml-bdo-1.xsd | 71 + .../w3c/xsd/xhtml11/xhtml-blkphras-1.xsd | 160 + .../w3c/xsd/xhtml11/xhtml-blkpres-1.xsd | 37 + .../w3c/xsd/xhtml11/xhtml-blkstruct-1.xsd | 49 + .../w3c/xsd/xhtml11/xhtml-copyright-1.xsd | 29 + .../w3c/xsd/xhtml11/xhtml-csismap-1.xsd | 96 + .../w3c/xsd/xhtml11/xhtml-datatypes-1.xsd | 242 ++ .../w3c/xsd/xhtml11/xhtml-edit-1.xsd | 39 + .../w3c/xsd/xhtml11/xhtml-events-1.xsd | 130 + .../w3c/xsd/xhtml11/xhtml-form-1.xsd | 327 ++ .../w3c/xsd/xhtml11/xhtml-framework-1.xsd | 66 + .../w3c/xsd/xhtml11/xhtml-hypertext-1.xsd | 47 + .../w3c/xsd/xhtml11/xhtml-image-1.xsd | 46 + .../w3c/xsd/xhtml11/xhtml-inlphras-1.xsd | 163 + .../w3c/xsd/xhtml11/xhtml-inlpres-1.xsd | 39 + .../w3c/xsd/xhtml11/xhtml-inlstruct-1.xsd | 50 + .../w3c/xsd/xhtml11/xhtml-inlstyle-1.xsd | 27 + .../w3c/xsd/xhtml11/xhtml-link-1.xsd | 45 + .../w3c/xsd/xhtml11/xhtml-list-1.xsd | 99 + .../w3c/xsd/xhtml11/xhtml-meta-1.xsd | 54 + .../w3c/xsd/xhtml11/xhtml-notations-1.xsd | 69 + .../w3c/xsd/xhtml11/xhtml-object-1.xsd | 76 + .../w3c/xsd/xhtml11/xhtml-param-1.xsd | 51 + .../w3c/xsd/xhtml11/xhtml-pres-1.xsd | 51 + .../w3c/xsd/xhtml11/xhtml-ruby-1.xsd | 170 + .../w3c/xsd/xhtml11/xhtml-script-1.xsd | 71 + .../w3c/xsd/xhtml11/xhtml-ssismap-1.xsd | 43 + .../w3c/xsd/xhtml11/xhtml-struct-1.xsd | 130 + .../w3c/xsd/xhtml11/xhtml-style-1.xsd | 53 + .../w3c/xsd/xhtml11/xhtml-table-1.xsd | 272 ++ .../w3c/xsd/xhtml11/xhtml-target-1.xsd | 49 + .../w3c/xsd/xhtml11/xhtml-text-1.xsd | 67 + .../w3c/xsd/xhtml11/xhtml11-model-1.xsd | 716 +++++ .../w3c/xsd/xhtml11/xhtml11-modules-1.xsd | 605 ++++ .../jdkcatalog/w3c/xsd/xhtml11/xhtml11.xsd | 104 + .../w3c/xsd/xhtml11/xml-events-1.xsd | 73 + .../xsd/xhtml11/xml-events-copyright-1.xsd | 34 + .../jdkcatalog/w3c/xsd/xmlNS2001/xml.xsd | 117 + src/java.xml/share/classes/module-info.java | 96 +- src/java.xml/share/legal/schema10part1.md | 51 + src/java.xml/share/legal/schema10part2.md | 50 + src/java.xml/share/legal/xhtml10.md | 57 + src/java.xml/share/legal/xhtml10schema.md | 150 + src/java.xml/share/legal/xhtml11.md | 68 + src/java.xml/share/legal/xhtml11schema.md | 60 + src/java.xml/share/legal/xmlspec.md | 63 + src/java.xml/share/legal/xmlxsd.md | 43 + .../unittest/catalog/CatalogSupport2.java | 4 +- .../unittest/catalog/CatalogSupport3.java | 4 +- .../unittest/catalog/CatalogSupportBase.java | 11 +- .../jaxp/unittest/catalog/val_test_dtd.xsd | 19 + 106 files changed, 27706 insertions(+), 17 deletions(-) create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/schema10/XMLSchema.dtd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/schema10/datatypes.dtd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml-lat1.ent create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml-special.ent create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml-symbol.ent create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml1-frameset.dtd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml1-strict.dtd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml1-transitional.dtd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-attribs-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-base-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-bdo-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-blkphras-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-blkpres-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-blkstruct-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-charent-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-csismap-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-datatypes-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-edit-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-events-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-form-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-framework-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-hypertext-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-image-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlphras-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlpres-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlstruct-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlstyle-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-legacy-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-link-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-list-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-meta-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-object-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-param-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-pres-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-qname-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-ruby-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-script-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-ssismap-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-struct-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-style-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-table-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-text-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml11-model-1.mod create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml11.dtd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xmlspec2_10/xmlspec.dtd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/schema10/XMLSchema-datatypes.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/schema10/XMLSchema.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml10/xhtml1-frameset.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml10/xhtml1-strict.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml10/xhtml1-transitional.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-attribs-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-base-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-bdo-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-blkphras-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-blkpres-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-blkstruct-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-copyright-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-csismap-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-datatypes-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-edit-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-events-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-form-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-framework-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-hypertext-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-image-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlphras-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlpres-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlstruct-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlstyle-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-link-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-list-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-meta-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-notations-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-object-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-param-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-pres-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-ruby-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-script-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-ssismap-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-struct-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-style-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-table-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-target-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-text-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml11-model-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml11-modules-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml11.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xml-events-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xml-events-copyright-1.xsd create mode 100644 src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xmlNS2001/xml.xsd create mode 100644 src/java.xml/share/legal/schema10part1.md create mode 100644 src/java.xml/share/legal/schema10part2.md create mode 100644 src/java.xml/share/legal/xhtml10.md create mode 100644 src/java.xml/share/legal/xhtml10schema.md create mode 100644 src/java.xml/share/legal/xhtml11.md create mode 100644 src/java.xml/share/legal/xhtml11schema.md create mode 100644 src/java.xml/share/legal/xmlspec.md create mode 100644 src/java.xml/share/legal/xmlxsd.md create mode 100644 test/jaxp/javax/xml/jaxp/unittest/catalog/val_test_dtd.xsd diff --git a/make/modules/java.xml/Java.gmk b/make/modules/java.xml/Java.gmk index 22c1dde2c2b17..0c174f2113e84 100644 --- a/make/modules/java.xml/Java.gmk +++ b/make/modules/java.xml/Java.gmk @@ -27,5 +27,5 @@ DISABLED_WARNINGS_java += dangling-doc-comments lossy-conversions this-escape DOCLINT += -Xdoclint:all/protected \ '-Xdoclint/package:$(call CommaList, javax.xml.catalog javax.xml.datatype \ javax.xml.transform javax.xml.validation javax.xml.xpath)' -COPY += .dtd .xsd .xml +COPY += .dtd .xsd .xml .ent .mod CLEAN += .properties diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java index aa7b62151d1ed..3b08dd7e89b3e 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java @@ -1209,11 +1209,12 @@ public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) th // Step 1: custom Entity resolver XMLInputSource xmlInputSource = null; - + boolean resolveByResolver = false; if (fEntityResolver != null) { resourceIdentifier.setBaseSystemId(baseSystemId); resourceIdentifier.setExpandedSystemId(expandedSystemId); xmlInputSource = fEntityResolver.resolveEntity(resourceIdentifier); + resolveByResolver = xmlInputSource != null; } // Step 2: custom catalog if specified @@ -1229,7 +1230,8 @@ public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) th } // Step 3: use the default JDK Catalog Resolver if Step 2's resolve is continue - if (xmlInputSource == null + if ((xmlInputSource == null || (!resolveByResolver && xmlInputSource.getSystemId() != null + && xmlInputSource.getSystemId().equals(literalSystemId))) && (publicId != null || literalSystemId != null) && JdkXmlUtils.isResolveContinue(fCatalogFeatures)) { initJdkCatalogResolver(); diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/JDKCatalog.xml b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/JDKCatalog.xml index 3919dd4981d75..74ba003250150 100644 --- a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/JDKCatalog.xml +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/JDKCatalog.xml @@ -1,7 +1,7 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/schema10/XMLSchema.dtd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/schema10/XMLSchema.dtd new file mode 100644 index 0000000000000..64aa2d9701924 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/schema10/XMLSchema.dtd @@ -0,0 +1,513 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +%xs-datatypes; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/schema10/datatypes.dtd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/schema10/datatypes.dtd new file mode 100644 index 0000000000000..f9352bae1c4f7 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/schema10/datatypes.dtd @@ -0,0 +1,222 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml-lat1.ent b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml-lat1.ent new file mode 100644 index 0000000000000..ffee223eb1056 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml-lat1.ent @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml-special.ent b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml-special.ent new file mode 100644 index 0000000000000..ca358b2fec722 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml-special.ent @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml-symbol.ent b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml-symbol.ent new file mode 100644 index 0000000000000..63c2abfa6f450 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml-symbol.ent @@ -0,0 +1,237 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml1-frameset.dtd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml1-frameset.dtd new file mode 100644 index 0000000000000..d814a6f37edbb --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml1-frameset.dtd @@ -0,0 +1,1235 @@ + + + + + +%HTMLlat1; + + +%HTMLsymbol; + + +%HTMLspecial; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml1-strict.dtd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml1-strict.dtd new file mode 100644 index 0000000000000..b449108daf98d --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml1-strict.dtd @@ -0,0 +1,978 @@ + + + + + +%HTMLlat1; + + +%HTMLsymbol; + + +%HTMLspecial; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml1-transitional.dtd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml1-transitional.dtd new file mode 100644 index 0000000000000..c62c02a5fa03c --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml1-transitional.dtd @@ -0,0 +1,1201 @@ + + + + + +%HTMLlat1; + + +%HTMLsymbol; + + +%HTMLspecial; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-attribs-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-attribs-1.mod new file mode 100644 index 0000000000000..178da950ed38b --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-attribs-1.mod @@ -0,0 +1,142 @@ + + + + + + + + + +]]> + + + + +]]> + + + + +]]> + + + + + + + + +]]> + + + + + + + + + + + +]]> + + +]]> + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-base-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-base-1.mod new file mode 100644 index 0000000000000..ba47b40fdd851 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-base-1.mod @@ -0,0 +1,53 @@ + + + + + + + + + + + + +]]> + + + +]]> + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-bdo-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-bdo-1.mod new file mode 100644 index 0000000000000..062de5cb8dc6e --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-bdo-1.mod @@ -0,0 +1,47 @@ + + + + + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-blkphras-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-blkphras-1.mod new file mode 100644 index 0000000000000..9172463960cc0 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-blkphras-1.mod @@ -0,0 +1,164 @@ + + + + + + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + + + + +]]> + + + +]]> + + + + +]]> + + + +]]> + + + + +]]> + + + +]]> + + + + +]]> + + + +]]> + + + + +]]> + + + +]]> + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-blkpres-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-blkpres-1.mod new file mode 100644 index 0000000000000..c342f8b2016b1 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-blkpres-1.mod @@ -0,0 +1,40 @@ + + + + + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-blkstruct-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-blkstruct-1.mod new file mode 100644 index 0000000000000..ce6a95c2e53a3 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-blkstruct-1.mod @@ -0,0 +1,57 @@ + + + + + + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-charent-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-charent-1.mod new file mode 100644 index 0000000000000..824c3ed262a8d --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-charent-1.mod @@ -0,0 +1,39 @@ + + + + + + + +%xhtml-lat1; + + +%xhtml-symbol; + + +%xhtml-special; + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-csismap-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-csismap-1.mod new file mode 100644 index 0000000000000..2bae98cce1f0a --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-csismap-1.mod @@ -0,0 +1,114 @@ + + + + + + + + + + +]]> + + + + + + +]]> + + + + + + + + + + + + + + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-datatypes-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-datatypes-1.mod new file mode 100644 index 0000000000000..dde43e83e19c2 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-datatypes-1.mod @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-edit-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-edit-1.mod new file mode 100644 index 0000000000000..b2a328e474ef2 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-edit-1.mod @@ -0,0 +1,66 @@ + + + + + + + + + + + + +]]> + + + +]]> + + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-events-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-events-1.mod new file mode 100644 index 0000000000000..03fd46cbb5c01 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-events-1.mod @@ -0,0 +1,135 @@ + + + + + + + + + + +]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-form-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-form-1.mod new file mode 100644 index 0000000000000..de68a757dcbf4 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-form-1.mod @@ -0,0 +1,292 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +]]> + + + +]]> + + + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + + + +]]> + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-framework-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-framework-1.mod new file mode 100644 index 0000000000000..7d9d9729dacc5 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-framework-1.mod @@ -0,0 +1,97 @@ + + + + + + + + +%xhtml-arch.mod;]]> + + + +%xhtml-notations.mod;]]> + + + +%xhtml-datatypes.mod;]]> + + + +%xhtml-xlink.mod; + + + +%xhtml-qname.mod;]]> + + + +%xhtml-events.mod;]]> + + + +%xhtml-attribs.mod;]]> + + + +%xhtml-model.redecl; + + + +%xhtml-model.mod;]]> + + + +%xhtml-charent.mod;]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-hypertext-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-hypertext-1.mod new file mode 100644 index 0000000000000..7a7d8caebd69f --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-hypertext-1.mod @@ -0,0 +1,54 @@ + + + + + + + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-image-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-image-1.mod new file mode 100644 index 0000000000000..856176181a990 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-image-1.mod @@ -0,0 +1,51 @@ + + + + + + + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlphras-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlphras-1.mod new file mode 100644 index 0000000000000..d749b2e38bec3 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlphras-1.mod @@ -0,0 +1,203 @@ + + + + + + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlpres-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlpres-1.mod new file mode 100644 index 0000000000000..8717d54ed44b3 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlpres-1.mod @@ -0,0 +1,138 @@ + + + + + + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlstruct-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlstruct-1.mod new file mode 100644 index 0000000000000..3d43d28756333 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlstruct-1.mod @@ -0,0 +1,62 @@ + + + + + + + + + + + + + +]]> + + + +]]> + + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlstyle-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlstyle-1.mod new file mode 100644 index 0000000000000..305680ff60cab --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlstyle-1.mod @@ -0,0 +1,34 @@ + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-legacy-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-legacy-1.mod new file mode 100644 index 0000000000000..c4eee72790a37 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-legacy-1.mod @@ -0,0 +1,400 @@ + + + + + + + + + + + + + + + + +]]> + + + +]]> + + + + + + + +]]> + + + +]]> + + + + + + + +]]> + + + +]]> + + + + + + + +]]> + + + +]]> + + + + + + + +]]> + + + +]]> + + + + + + + +]]> + + + +]]> + + + + + + + + +]]> + + + +]]> + + + + + + + + +]]> + + + +]]> + + + + + + + +]]> + + + +]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +%xhtml-frames.mod;]]> + + + + + +%xhtml-iframe.mod;]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-link-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-link-1.mod new file mode 100644 index 0000000000000..2b4f92c7d854d --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-link-1.mod @@ -0,0 +1,59 @@ + + + + + + + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-list-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-list-1.mod new file mode 100644 index 0000000000000..6c85f205f823d --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-list-1.mod @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-meta-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-meta-1.mod new file mode 100644 index 0000000000000..24a0b228061c7 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-meta-1.mod @@ -0,0 +1,47 @@ + + + + + + + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-object-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-object-1.mod new file mode 100644 index 0000000000000..0d14cc51d6644 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-object-1.mod @@ -0,0 +1,60 @@ + + + + + + + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-param-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-param-1.mod new file mode 100644 index 0000000000000..c101bedd3d6c3 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-param-1.mod @@ -0,0 +1,48 @@ + + + + + + + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-pres-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-pres-1.mod new file mode 100644 index 0000000000000..6a2f34de325a7 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-pres-1.mod @@ -0,0 +1,38 @@ + + + + + + + + +%xhtml-inlpres.mod;]]> + + + +%xhtml-blkpres.mod;]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-qname-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-qname-1.mod new file mode 100644 index 0000000000000..c7586a53c7055 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-qname-1.mod @@ -0,0 +1,318 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +]]> + + + + +%xhtml-qname-extra.mod; + + + + + + + + + +]]> + + + + + + + + + + + + + + + + + + + +]]> + + + + + + + +]]> + + + + +%xhtml-qname.redecl; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-ruby-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-ruby-1.mod new file mode 100644 index 0000000000000..68931769c2e5e --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-ruby-1.mod @@ -0,0 +1,242 @@ + + + + + + + + + + + + + + + + + + + + + + + +]]> + +]]> + + + +]]> + + + + + + + + + + + + + +]]> + + + + + + +]]> + + + + + + +]]> +]]> + + + + + + + +]]> + + + + + + + + +]]> + + + + +]]> +]]> + + + + + + +]]> +]]> + + + + + + + + + + +]]> + + + + + +]]> + + + + + +]]> +]]> + + + + + +]]> + + + + + +]]> + + + + + +]]> +]]> +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-script-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-script-1.mod new file mode 100644 index 0000000000000..aa702f1f01471 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-script-1.mod @@ -0,0 +1,67 @@ + + + + + + + + + + + + +]]> + + + +]]> + + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-ssismap-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-ssismap-1.mod new file mode 100644 index 0000000000000..4e2b8d7ed6350 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-ssismap-1.mod @@ -0,0 +1,32 @@ + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-struct-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-struct-1.mod new file mode 100644 index 0000000000000..4bb420ee7b151 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-struct-1.mod @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + +]]> + + + +]]> + + + + + + + +]]> + + + + + + +]]> + + + + + + + +]]> + + + +]]> + + + + + + + +]]> + + + +]]> + + + + + + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-style-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-style-1.mod new file mode 100644 index 0000000000000..3105b2a47307f --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-style-1.mod @@ -0,0 +1,48 @@ + + + + + + + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-table-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-table-1.mod new file mode 100644 index 0000000000000..3fc03608f1db6 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-table-1.mod @@ -0,0 +1,333 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + + + + + + + +]]> + + + +]]> + + + + + + + + +]]> + + + +]]> + + + + + + + + +]]> + + + +]]> + + + + + + + + +]]> + + + +]]> + + + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-text-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-text-1.mod new file mode 100644 index 0000000000000..07ccb81a7fe9f --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-text-1.mod @@ -0,0 +1,52 @@ + + + + + + + + +%xhtml-inlstruct.mod;]]> + + + +%xhtml-inlphras.mod;]]> + + + +%xhtml-blkstruct.mod;]]> + + + +%xhtml-blkphras.mod;]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml11-model-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml11-model-1.mod new file mode 100644 index 0000000000000..229e9a9d0a262 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml11-model-1.mod @@ -0,0 +1,250 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml11.dtd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml11.dtd new file mode 100644 index 0000000000000..8f14c406cfb2e --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml11.dtd @@ -0,0 +1,323 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]]> + + + + + + +%xhtml-inlstyle.mod;]]> + + + + + + + + +%xhtml-datatypes.mod;]]> + + + + + + +%xhtml-framework.mod;]]> + + + + +]]> + + + + +%xhtml-text.mod;]]> + + + + +%xhtml-hypertext.mod;]]> + + + + +%xhtml-list.mod;]]> + + + + + + +%xhtml-edit.mod;]]> + + + + +%xhtml-bdo.mod;]]> + + + + + + +%xhtml-ruby.mod;]]> + + + + +%xhtml-pres.mod;]]> + + + + +%xhtml-link.mod;]]> + + + + +%xhtml-meta.mod;]]> + + + + +%xhtml-base.mod;]]> + + + + +%xhtml-script.mod;]]> + + + + +%xhtml-style.mod;]]> + + + + +%xhtml-image.mod;]]> + + + + +%xhtml-csismap.mod;]]> + + + + +%xhtml-ssismap.mod;]]> + + + + +%xhtml-param.mod;]]> + + + + +%xhtml-object.mod;]]> + + + + +%xhtml-table.mod;]]> + + + + +%xhtml-form.mod;]]> + + + + +%xhtml-legacy.mod;]]> + + + + +%xhtml-struct.mod;]]> + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xmlspec2_10/xmlspec.dtd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xmlspec2_10/xmlspec.dtd new file mode 100644 index 0000000000000..f720913be4494 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xmlspec2_10/xmlspec.dtd @@ -0,0 +1,2778 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]]> + + +]]> + + + + + + + + + +]]> + + + + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + + + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + + +]]> + + +]]> + + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + + + +]]> + + + + +]]> + + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + + + + + + +]]> + + +]]> + + + + + + + + +]]> + + + +]]> + + + + +]]> + + + +]]> + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + + + + + +]]> + + +]]> + + + + + +]]> + + + +]]> + + + + +]]> + + +]]> + + + + + +]]> + + +]]> + + + + + + +]]> + + +]]> + + + + + + + +]]> + + +]]> + + + + + +]]> + + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + +]]> + + + +]]> + + + + +]]> + + + +]]> + + + + + + +]]> + + + + +]]> + + + + + + + + + + +]]> + + +]]> + + + + + + +]]> + + + + +]]> + + + + + + +]]> + + + + +]]> + + + + +]]> + + +]]> + + + + + +]]> + + +]]> + + + + + + + + + + +]]> + + + +]]> + + + + +]]> + + + +]]> + + + + +]]> + + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + + + + + +]]> + + +]]> + + + + +]]> + + + +]]> + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + + + + + +]]> + + +]]> + + + + + + +]]> + + +]]> + + + + + + + + + + + + + + + + + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]]> + + +]]> + + + + + + + +]]> + + +]]> + + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + + + +]]> + + +]]> + + + + + + + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + + +]]> + + + +]]> + + +]]> + + + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + + + +]]> + + +]]> + + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + + + +]]> + + + +]]> + + + + +]]> + + + +]]> + + + + + + +]]> + + +]]> + + + + + +]]> + + +]]> + + + + + + +]]> + + +]]> + + + + +]]> + + + +]]> + + + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + + + +]]> + + + + +]]> + + + +]]> + + + + + + +]]> + + + + +]]> + + + + + + +]]> + + +]]> + + + + + + +]]> + + + + +]]> + + + + + + +]]> + + + + +]]> + + + + + + +]]> + + + + +]]> + + + + + + + + + + + +]]> + + +]]> + + +]]> + + +]]> + + +]]> + + +]]> + + +]]> + + +]]> + + +]]> + + +]]> + + +]]> + + +]]> + + +]]> + + + +]]> + + +]]> + + +]]> + + +]]> + + + +]]> + + +]]> + + +]]> + + +]]> + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/schema10/XMLSchema-datatypes.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/schema10/XMLSchema-datatypes.xsd new file mode 100644 index 0000000000000..574949db19c49 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/schema10/XMLSchema-datatypes.xsd @@ -0,0 +1,154 @@ + + + + +]> + + + Note this schema is NOT a normative schema - - + It contains types derived from all the builtin simple type definitions + with the same local name but in a distinct namespace, for use + by applications which do no wish to import the full XMLSchema + schema. Since derivation is not symmetric, unexpected results may + follow from mixing references to these definitions with references + to the definitions in the XMLSchema namespace. For example, + although dt:positiveInteger is derived from xs:integer, the converse + does not hold. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/schema10/XMLSchema.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/schema10/XMLSchema.xsd new file mode 100644 index 0000000000000..169ade092547c --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/schema10/XMLSchema.xsd @@ -0,0 +1,2364 @@ + + + + + + + + + + + Part 1 version: Id: structures.xsd,v 1.2 2004/01/15 11:34:25 ht Exp + Part 2 version: Id: datatypes.xsd,v 1.3 2004/01/23 18:11:13 ht Exp + + + + + + The schema corresponding to this document is normative, + with respect to the syntactic constraints it expresses in the + XML Schema language. The documentation (within <documentation> elements) + below, is not normative, but rather highlights important aspects of + the W3C Recommendation of which this is a part + + + + + The simpleType element and all of its members are defined + towards the end of this schema document + + + + + + Get access to the xml: attribute groups for xml:lang + as declared on 'schema' and 'documentation' below + + + + + + + + This type is extended by almost all schema types + to allow attributes from other namespaces to be + added to user schemas. + + + + + + + + + + + + + This type is extended by all types which allow annotation + other than <schema> itself + + + + + + + + + + + + + + + + This group is for the + elements which occur freely at the top level of schemas. + All of their types are based on the "annotated" type by extension. + + + + + + + + + + + + + This group is for the + elements which can self-redefine (see <redefine> below). + + + + + + + + + + + + + A utility type, not for public use + + + + + + + + + + + A utility type, not for public use + + + + + + + + + + + A utility type, not for public use + + #all or (possibly empty) subset of {extension, restriction} + + + + + + + + + + + + + + + + + A utility type, not for public use + + + + + + + + + + + + + A utility type, not for public use + + #all or (possibly empty) subset of {extension, restriction, list, union} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + for maxOccurs + + + + + + + + + + + + for all particles + + + + + + + for element, group and attributeGroup, + which both define and reference + + + + + + + + 'complexType' uses this + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This branch is short for + <complexContent> + <restriction base="xs:anyType"> + ... + </restriction> + </complexContent> + + + + + + + + + + + + + + + Will be restricted to required or forbidden + + + + + + Not allowed if simpleContent child is chosen. + May be overriden by setting on complexContent child. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This choice is added simply to + make this a valid restriction per the REC + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Overrides any setting on complexType parent. + + + + + + + + + + + + + + + This choice is added simply to + make this a valid restriction per the REC + + + + + + + + + + + + + + + + + No typeDefParticle group reference + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A utility type, not for public use + + #all or (possibly empty) subset of {substitution, extension, + restriction} + + + + + + + + + + + + + + + + + + + + + + + + + The element element can be used either + at the top level to define an element-type binding globally, + or within a content model to either reference a globally-defined + element or type or declare an element-type binding locally. + The ref form is not allowed at the top level. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + group type for explicit groups, named top-level groups and + group references + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + group type for the three kinds of group + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This choice with min/max is here to + avoid a pblm with the Elt:All/Choice/Seq + Particle derivation constraint + + + + + + + + + + restricted max/min + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Only elements allowed inside + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + simple type for the value of the 'namespace' attr of + 'any' and 'anyAttribute' + + + + Value is + ##any - - any non-conflicting WFXML/attribute at all + + ##other - - any non-conflicting WFXML/attribute from + namespace other than targetNS + + ##local - - any unqualified non-conflicting WFXML/attribute + + one or - - any non-conflicting WFXML/attribute from + more URI the listed namespaces + references + (space separated) + + ##targetNamespace or ##local may appear in the above list, to + refer to the targetNamespace of the enclosing + schema or an absent targetNamespace respectively + + + + + + A utility type, not for public use + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A subset of XPath expressions for use +in selectors + A utility type, not for public +use + + + + The following pattern is intended to allow XPath + expressions per the following EBNF: + Selector ::= Path ( '|' Path )* + Path ::= ('.//')? Step ( '/' Step )* + Step ::= '.' | NameTest + NameTest ::= QName | '*' | NCName ':' '*' + child:: is also allowed + + + + + + + + + + + + + + + + + + + + + + + A subset of XPath expressions for use +in fields + A utility type, not for public +use + + + + The following pattern is intended to allow XPath + expressions per the same EBNF as for selector, + with the following change: + Path ::= ('.//')? ( Step '/' )* ( Step | '@' NameTest ) + + + + + + + + + + + + + + + + + + + + + + + + + + + The three kinds of identity constraints, all with + type of or derived from 'keybase'. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A utility type, not for public use + + A public identifier, per ISO 8879 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + notations for use within XML Schema schemas + + + + + + + + + Not the real urType, but as close an approximation as we can + get in the XML representation + + + + + + + + + + First the built-in primitive datatypes. These definitions are for + information only, the real built-in definitions are magic. + + + + For each built-in datatype in this schema (both primitive and + derived) can be uniquely addressed via a URI constructed + as follows: + 1) the base URI is the URI of the XML Schema namespace + 2) the fragment identifier is the name of the datatype + + For example, to address the int datatype, the URI is: + + http://www.w3.org/2001/XMLSchema#int + + Additionally, each facet definition element can be uniquely + addressed via a URI constructed as follows: + 1) the base URI is the URI of the XML Schema namespace + 2) the fragment identifier is the name of the facet + + For example, to address the maxInclusive facet, the URI is: + + http://www.w3.org/2001/XMLSchema#maxInclusive + + Additionally, each facet usage in a built-in datatype definition + can be uniquely addressed via a URI constructed as follows: + 1) the base URI is the URI of the XML Schema namespace + 2) the fragment identifier is the name of the datatype, followed + by a period (".") followed by the name of the facet + + For example, to address the usage of the maxInclusive facet in + the definition of int, the URI is: + + http://www.w3.org/2001/XMLSchema#int.maxInclusive + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NOTATION cannot be used directly in a schema; rather a type + must be derived from it by specifying at least one enumeration + facet whose value is the name of a NOTATION declared in the + schema. + + + + + + + + + + Now the derived primitive types + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + pattern specifies the content of section 2.12 of XML 1.0e2 + and RFC 3066 (Revised version of RFC 1766). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + pattern matches production 7 from the XML spec + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + pattern matches production 5 from the XML spec + + + + + + + + + + + + + + + pattern matches production 4 from the Namespaces in XML spec + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A utility type, not for public use + + + + + + + + + + + + + + + + + + + + + + #all or (possibly empty) subset of {restriction, union, list} + + + A utility type, not for public use + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Can be restricted to required or forbidden + + + + + + + + + + + + + + + + + + Required at the top level + + + + + + + + + + + + + + + + + + + Forbidden when nested + + + + + + + + + + + + + + + + + + + We should use a substitution group for facets, but + that's ruled out because it would allow users to + add their own, which we're not ready for yet. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + base attribute and simpleType child are mutually + exclusive, but one or other is required + + + + + + + + + + + + + + + + itemType attribute and simpleType child are mutually + exclusive, but one or other is required + + + + + + + + + + + + + + + + + + memberTypes attribute must be non-empty or there must be + at least one simpleType child + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml10/xhtml1-frameset.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml10/xhtml1-frameset.xsd new file mode 100644 index 0000000000000..0518a6145dd08 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml10/xhtml1-frameset.xsd @@ -0,0 +1,2847 @@ + + + + + + XHTML 1.0 (Second Edition) Frameset in XML Schema + + This is the same as HTML 4 Frameset except for + changes due to the differences between XML and SGML. + + Namespace = http://www.w3.org/1999/xhtml + + For further information, see: http://www.w3.org/TR/xhtml1 + + Copyright (c) 1998-2002 W3C (MIT, INRIA, Keio), + All Rights Reserved. + + The DTD version is identified by the PUBLIC and SYSTEM identifiers: + + PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" + SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd" + + $Id: xhtml1-frameset.xsd,v 1.5 2002/08/28 09:53:29 mimasa Exp $ + + + + + + + + ================ Character mnemonic entities ========================= + + XHTML entity sets are identified by the PUBLIC and SYSTEM identifiers: + + PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN" + SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent" + + PUBLIC "-//W3C//ENTITIES Special for XHTML//EN" + SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent" + + PUBLIC "-//W3C//ENTITIES Symbols for XHTML//EN" + SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent" + + + + + + ================== Imported Names ==================================== + + + + + + + media type, as per [RFC2045] + + + + + + + + + comma-separated list of media types, as per [RFC2045] + + + + + + + + + a character encoding, as per [RFC2045] + + + + + + + + + a space separated list of character encodings, as per [RFC2045] + + + + + + + + + a language code, as per [RFC3066] + + + + + + + + + a single character, as per section 2.2 of [XML] + + + + + + + + + + + one or more digits + + + + + + + + + + + tabindex attribute specifies the position of the current element + in the tabbing order for the current document. This value must be + a number between 0 and 32767. User agents should ignore leading zeros. + + + + + + + + + + + + space-separated list of link types + + + + + + + + + single or comma-separated list of media descriptors + + + + + + + + + + + a Uniform Resource Identifier, see [RFC2396] + + + + + + + + + a space separated list of Uniform Resource Identifiers + + + + + + + + + date and time information. ISO date format + + + + + + + + + script expression + + + + + + + + + style sheet data + + + + + + + + + used for titles etc. + + + + + + + + + render in this frame + + + + + + + + + + + nn for pixels or nn% for percentage length + + + + + + + + + + + pixel, percentage, or relative + + + + + + + + + + + comma-separated list of MultiLength + + + + + + + + + + + integer representing length in pixels + + + + + + + + these are used for image maps + + + + + + + + + + + + + + + + comma separated list of lengths + + + + + + + + + + + used for object, applet, img, input and iframe + + + + + + + + + + + + + + + a color using sRGB: #RRGGBB as Hex values + + There are also 16 widely known color names with their sRGB values: + + Black = #000000 Green = #008000 + Silver = #C0C0C0 Lime = #00FF00 + Gray = #808080 Olive = #808000 + White = #FFFFFF Yellow = #FFFF00 + Maroon = #800000 Navy = #000080 + Red = #FF0000 Blue = #0000FF + Purple = #800080 Teal = #008080 + Fuchsia= #FF00FF Aqua = #00FFFF + + + + + + + + + + =================== Generic Attributes =============================== + + + + + + + core attributes common to most elements + id document-wide unique id + class space separated list of classes + style associated style info + title advisory title/amplification + + + + + + + + + + + + internationalization attributes + lang language code (backwards compatible) + xml:lang language code (as per XML 1.0 spec) + dir direction for weak/neutral text + + + + + + + + + + + + + + + + + + attributes for common UI events + onclick a pointer button was clicked + ondblclick a pointer button was double clicked + onmousedown a pointer button was pressed down + onmouseup a pointer button was released + onmousemove a pointer was moved onto the element + onmouseout a pointer was moved away from the element + onkeypress a key was pressed and released + onkeydown a key was pressed down + onkeyup a key was released + + + + + + + + + + + + + + + + + + attributes for elements that can get the focus + accesskey accessibility key character + tabindex position in tabbing order + onfocus the element got the focus + onblur the element lost the focus + + + + + + + + + + + + + + + + + + text alignment for p, div, h1-h6. The default is + align="left" for ltr headings, "right" for rtl + + + + + + + + + + + + + + + + + =================== Text Elements ==================================== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + these can only occur at block level + + + + + + + + + + + + + these can only occur at block level + + + + + + + + + + + + + + + + + + + + + + "Inline" covers inline or "text-level" element + + + + + + + + + + + ================== Block level elements ============================== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + "Flow" mixes block and inline and is used for list items etc. + + + + + + + + + + + + + ================== Content models for exclusions ===================== + + + + + + + a elements use "Inline" excluding a + + + + + + + + + + + + + + + pre uses "Inline" excluding img, object, applet, big, small, + sub, sup, font, or basefont + + + + + + + + + + + + + + + + form uses "Flow" excluding form + + + + + + + + + + + + + button uses "Flow" but excludes a, form, form controls, iframe + + + + + + + + + + + + + + + + + + + + + + + + + ================ Document Structure ================================== + + + + + + + + + + + + + + + + + ================ Document Head ======================================= + + + + + + + + + + + + + + + + + + + + content model is "head.misc" combined with a single + title and an optional base element in any order + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The title element is not considered part of the flow of text. + It should be displayed, for example as the page header or + window title. Exactly one title is required per document. + + + + + + + + + + + + document base URI + + + + + + + + + + + + + generic metainformation + + + + + + + + + + + + + + + + Relationship values can be used in principle: + + a) for document specific toolbars/menus when used + with the link element in document head e.g. + start, contents, previous, next, index, end, help + b) to link to a separate style sheet (rel="stylesheet") + c) to make a link to a script (rel="script") + d) by stylesheets to control how collections of + html nodes are rendered into printed documents + e) to make a link to a printable version of this document + e.g. a PostScript or PDF version (rel="alternate" media="print") + + + + + + + + + + + + + + + + + + + style info, which may include CDATA sections + + + + + + + + + + + + + + + + script statements, which may include CDATA sections + + + + + + + + + + + + + + + + + + + + + + + alternate content container for non script-based rendering + + + + + + + + + + + + + + ======================= Frames ======================================= + + + + + + + only one noframes element permitted per document + + + + + + + + + + + + + + + + + + + reserved frame names start with "_" otherwise starts with letter + + + + + + + tiled window within frameset + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + inline subwindow + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + alternate content container for non frame-based rendering + + + + + + + + + + + + + =================== Document Body ==================================== + + + + + + + + + + + + + + + + + + + + + + + + + generic language/style container + + + + + + + + + + + + + + + =================== Paragraphs ======================================= + + + + + + + + + + + + + + + + + =================== Headings ========================================= + + There are six levels of headings from h1 (the most important) + to h6 (the least important). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + =================== Lists ============================================ + + + + + + + Unordered list bullet styles + + + + + + + + + + + + + Unordered list + + + + + + + + + + + + + + + + + + + + + + Ordered list numbering style + + 1 arabic numbers 1, 2, 3, ... + a lower alpha a, b, c, ... + A upper alpha A, B, C, ... + i lower roman i, ii, iii, ... + I upper roman I, II, III, ... + + The style is applied to the sequence number which by default + is reset to 1 for the first list item in an ordered list. + + + + + + + + + Ordered (numbered) list + + + + + + + + + + + + + + + + + + + + + + + single column list (DEPRECATED) + + + + + + + + + + + + + + + + + + + + + multiple column list (DEPRECATED) + + + + + + + + + + + + + + + + + + + + + LIStyle is constrained to: "(ULStyle|OLStyle)" + + + + + + + + + list item + + + + + + + + + + + + + + + + definition lists - dt for term, dd for its definition + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + =================== Address ========================================== + + + + + + + information on author + + + + + + + + + + + + + + + =================== Horizontal Rule ================================== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + =================== Preformatted Text ================================ + + + + + + + content is "Inline" excluding + "img|object|applet|big|small|sub|sup|font|basefont" + + + + + + + + + + + + + + + + =================== Block-like Quotes ================================ + + + + + + + + + + + + + + + + + =================== Text alignment =================================== + + + + + + + center content + + + + + + + + + + + + + + =================== Inserted/Deleted Text ============================ + + ins/del are allowed in block and inline content, but its + inappropriate to include block content within an ins element + occurring in inline content. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ================== The Anchor Element ================================ + + + + + + + content is "Inline" except that anchors shouldn't be nested + + + + + + + + + + + + + + + + + + + + + + + + + ===================== Inline Elements ================================ + + + + + + + generic language/style container + + + + + + + + + + + + + + + I18N BiDi over-ride + + + + + + + + + + + + + + + + + + + + + + + + + + forced line break + + + + + + + + + + + + + + + + + + + + + emphasis + + + + + + + + + + + + + + + strong emphasis + + + + + + + + + + + + + + + definitional + + + + + + + + + + + + + + + program code + + + + + + + + + + + + + + + sample + + + + + + + + + + + + + + + something user would type + + + + + + + + + + + + + + + variable + + + + + + + + + + + + + + + citation + + + + + + + + + + + + + + + abbreviation + + + + + + + + + + + + + + + acronym + + + + + + + + + + + + + + + inlined quote + + + + + + + + + + + + + + + + subscript + + + + + + + + + + + + + + + superscript + + + + + + + + + + + + + + + fixed pitch font + + + + + + + + + + + + + + + italic font + + + + + + + + + + + + + + + bold font + + + + + + + + + + + + + + + bigger font + + + + + + + + + + + + + + + smaller font + + + + + + + + + + + + + + + underline + + + + + + + + + + + + + + + strike-through + + + + + + + + + + + + + + + strike-through + + + + + + + + + + + + + + + base font size + + + + + + + + + + + + + + local change to font + + + + + + + + + + + + + + + + + + ==================== Object ====================================== + + object is used to embed objects as part of HTML pages. + param elements should precede other content. Parameters + can also be expressed as attribute/value pairs on the + object element itself when brevity is desired. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + param is used to supply a named property value. + In XML it would seem natural to follow RDF and support an + abbreviated syntax where the param elements are replaced + by attribute value pairs on the object start tag. + + + + + + + + + + + + + + + + + + + + + + =================== Java applet ================================== + + One of code or object attributes must be present. + Place param elements before other content. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + =================== Images =========================================== + + To avoid accessibility problems for people who aren't + able to see the image, you should provide a text + description using the alt and longdesc attributes. + In addition, avoid the use of server-side image maps. + + + + + + + + + + + + + + + + usemap points to a map element which may be in this document + or an external document, although the latter is not widely supported + + + + + + + + + + + + + + + + + + + + ================== Client-side image maps ============================ + + These can be placed in the same document or grouped in a + separate document although this isn't yet widely supported + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ================ Forms =============================================== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Each label must not contain more than ONE field + Label elements shouldn't be nested. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + form control + + + + + + + + + + the name attribute is required for all but submit & reset + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + option selector + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + option group + + + + + + + + + + + + + + + + + + + + + + selectable choice + + + + + + + + + + + + + + + + + + + + + + + + + + + multi-line text field + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The fieldset element is used to group form fields. + Only one legend element should occur in the content + and if present should only be preceded by whitespace. + + NOTE: this content model is different from the XHTML 1.0 DTD, + closer to the intended content model in HTML4 DTD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + fieldset label + + + + + + + + + + + + + + + + + Content is "Flow" excluding a, form and form controls + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + single-line text input control (DEPRECATED) + + + + + + + + + + + + ======================= Tables ======================================= + + Derived from IETF HTML table standard, see [RFC1942] + + + + + + + The border attribute sets the thickness of the frame around the + table. The default units are screen pixels. + + The frame attribute specifies which parts of the frame around + the table should be rendered. The values are not the same as + CALS to avoid a name clash with the valign attribute. + + + + + + + + + + + + + + + + + + + The rules attribute defines which rules to draw between cells: + + If rules is absent then assume: + "none" if border is absent or border="0" otherwise "all" + + + + + + + + + + + + + + + horizontal placement of table relative to document + + + + + + + + + + + + + horizontal alignment attributes for cell contents + + char alignment char, e.g. char=":" + charoff offset for alignment char + + + + + + + + + + + + + + + + + + + + + vertical alignment attributes for cell contents + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Use thead to duplicate headers when breaking table + across page boundaries, or for static headers when + tbody sections are rendered in scrolling panel. + + Use tfoot to duplicate footers when breaking table + across page boundaries, or for static footers when + tbody sections are rendered in scrolling panel. + + Use multiple tbody sections when rules are needed + between groups of table rows. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + colgroup groups a set of col elements. It allows you to group + several semantically related columns together. + + + + + + + + + + + + + + + + + + col elements define the alignment properties for cells in + one or more columns. + + The width attribute specifies the width of the columns, e.g. + + width=64 width in screen pixels + width=0.5* relative width of 0.5 + + The span attribute causes the attributes of one + col element to apply to more than one column. + + + + + + + + + + + + + + + + + + + + + + + + + + + + Scope is simpler than headers attribute for common tables + + + + + + + + + + + + + th is for headers, td for data and for cells acting as both + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml10/xhtml1-strict.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml10/xhtml1-strict.xsd new file mode 100644 index 0000000000000..93b80b6678826 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml10/xhtml1-strict.xsd @@ -0,0 +1,2211 @@ + + + + + + XHTML 1.0 (Second Edition) Strict in XML Schema + + This is the same as HTML 4 Strict except for + changes due to the differences between XML and SGML. + + Namespace = http://www.w3.org/1999/xhtml + + For further information, see: http://www.w3.org/TR/xhtml1 + + Copyright (c) 1998-2002 W3C (MIT, INRIA, Keio), + All Rights Reserved. + + The DTD version is identified by the PUBLIC and SYSTEM identifiers: + + PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" + + $Id: xhtml1-strict.xsd,v 1.2 2002/08/28 08:05:44 mimasa Exp $ + + + + + + + + ================ Character mnemonic entities ========================= + + XHTML entity sets are identified by the PUBLIC and SYSTEM identifiers: + + PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN" + SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent" + + PUBLIC "-//W3C//ENTITIES Special for XHTML//EN" + SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent" + + PUBLIC "-//W3C//ENTITIES Symbols for XHTML//EN" + SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent" + + + + + + ================== Imported Names ==================================== + + + + + + + media type, as per [RFC2045] + + + + + + + + + comma-separated list of media types, as per [RFC2045] + + + + + + + + + a character encoding, as per [RFC2045] + + + + + + + + + a space separated list of character encodings, as per [RFC2045] + + + + + + + + + a language code, as per [RFC3066] + + + + + + + + + a single character, as per section 2.2 of [XML] + + + + + + + + + + + one or more digits + + + + + + + + + + + tabindex attribute specifies the position of the current element + in the tabbing order for the current document. This value must be + a number between 0 and 32767. User agents should ignore leading zeros. + + + + + + + + + + + + space-separated list of link types + + + + + + + + + single or comma-separated list of media descriptors + + + + + + + + + + + a Uniform Resource Identifier, see [RFC2396] + + + + + + + + + a space separated list of Uniform Resource Identifiers + + + + + + + + + date and time information. ISO date format + + + + + + + + + script expression + + + + + + + + + style sheet data + + + + + + + + + used for titles etc. + + + + + + + + + nn for pixels or nn% for percentage length + + + + + + + + + + + pixel, percentage, or relative + + + + + + + + + + + integer representing length in pixels + + + + + + + + these are used for image maps + + + + + + + + + + + + + + + + comma separated list of lengths + + + + + + + + + + =================== Generic Attributes =============================== + + + + + + + core attributes common to most elements + id document-wide unique id + class space separated list of classes + style associated style info + title advisory title/amplification + + + + + + + + + + + + internationalization attributes + lang language code (backwards compatible) + xml:lang language code (as per XML 1.0 spec) + dir direction for weak/neutral text + + + + + + + + + + + + + + + + + + attributes for common UI events + onclick a pointer button was clicked + ondblclick a pointer button was double clicked + onmousedown a pointer button was pressed down + onmouseup a pointer button was released + onmousemove a pointer was moved onto the element + onmouseout a pointer was moved away from the element + onkeypress a key was pressed and released + onkeydown a key was pressed down + onkeyup a key was released + + + + + + + + + + + + + + + + + + attributes for elements that can get the focus + accesskey accessibility key character + tabindex position in tabbing order + onfocus the element got the focus + onblur the element lost the focus + + + + + + + + + + + + + + + + + =================== Text Elements ==================================== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + these can only occur at block level + + + + + + + + + + + + + + + + + + + + + + "Inline" covers inline or "text-level" elements + + + + + + + + + + + ================== Block level elements ============================== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + "Flow" mixes block and inline and is used for list items etc. + + + + + + + + + + + + + ================== Content models for exclusions ===================== + + + + + + + a elements use "Inline" excluding a + + + + + + + + + + + + + + + pre uses "Inline" excluding big, small, sup or sup + + + + + + + + + + + + + + + + form uses "Block" excluding form + + + + + + + + + + + + button uses "Flow" but excludes a, form and form controls + + + + + + + + + + + + + + + + + + + ================ Document Structure ================================== + + + + + + + + + + + + + + + + + ================ Document Head ======================================= + + + + + + + + + + + + + + + + + + + content model is "head.misc" combined with a single + title and an optional base element in any order + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The title element is not considered part of the flow of text. + It should be displayed, for example as the page header or + window title. Exactly one title is required per document. + + + + + + + + + + + + document base URI + + + + + + + + + + + + generic metainformation + + + + + + + + + + + + + + + + Relationship values can be used in principle: + + a) for document specific toolbars/menus when used + with the link element in document head e.g. + start, contents, previous, next, index, end, help + b) to link to a separate style sheet (rel="stylesheet") + c) to make a link to a script (rel="script") + d) by stylesheets to control how collections of + html nodes are rendered into printed documents + e) to make a link to a printable version of this document + e.g. a PostScript or PDF version (rel="alternate" media="print") + + + + + + + + + + + + + + + + + + style info, which may include CDATA sections + + + + + + + + + + + + + + + + script statements, which may include CDATA sections + + + + + + + + + + + + + + + + + + + + + + alternate content container for non script-based rendering + + + + + + + + + + + + + + =================== Document Body ==================================== + + + + + + + + + + + + + + + + + + + generic language/style container + + + + + + + + + + + + + + =================== Paragraphs ======================================= + + + + + + + + + + + + + + + + =================== Headings ========================================= + + There are six levels of headings from h1 (the most important) + to h6 (the least important). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + =================== Lists ============================================ + + + + + + + Unordered list + + + + + + + + + + + + + + Ordered (numbered) list + + + + + + + + + + + + + + list item + + + + + + + + + + + + + + definition lists - dt for term, dd for its definition + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + =================== Address ========================================== + + + + + + + information on author + + + + + + + + + + + + + + =================== Horizontal Rule ================================== + + + + + + + + + + + + =================== Preformatted Text ================================ + + + + + + + content is "Inline" excluding "img|object|big|small|sub|sup" + + + + + + + + + + + + + + + =================== Block-like Quotes ================================ + + + + + + + + + + + + + + + + + =================== Inserted/Deleted Text ============================ + + ins/del are allowed in block and inline content, but its + inappropriate to include block content within an ins element + occurring in inline content. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ================== The Anchor Element ================================ + + + + + + + content is "Inline" except that anchors shouldn't be nested + + + + + + + + + + + + + + + + + + + + + + + + ===================== Inline Elements ================================ + + + + + + + generic language/style container + + + + + + + + + + + + + + + I18N BiDi over-ride + + + + + + + + + + + + + + + + + + + + + + + + + + forced line break + + + + + + + + + + + emphasis + + + + + + + + + + + + + + + strong emphasis + + + + + + + + + + + + + + + definitional + + + + + + + + + + + + + + + program code + + + + + + + + + + + + + + + sample + + + + + + + + + + + + + + + something user would type + + + + + + + + + + + + + + + variable + + + + + + + + + + + + + + + citation + + + + + + + + + + + + + + + abbreviation + + + + + + + + + + + + + + + acronym + + + + + + + + + + + + + + + inlined quote + + + + + + + + + + + + + + + + subscript + + + + + + + + + + + + + + + superscript + + + + + + + + + + + + + + + fixed pitch font + + + + + + + + + + + + + + + italic font + + + + + + + + + + + + + + + bold font + + + + + + + + + + + + + + + bigger font + + + + + + + + + + + + + + + smaller font + + + + + + + + + + + + + + ==================== Object ====================================== + + object is used to embed objects as part of HTML pages. + param elements should precede other content. Parameters + can also be expressed as attribute/value pairs on the + object element itself when brevity is desired. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + param is used to supply a named property value. + In XML it would seem natural to follow RDF and support an + abbreviated syntax where the param elements are replaced + by attribute value pairs on the object start tag. + + + + + + + + + + + + + + + + + + + + + + =================== Images =========================================== + + To avoid accessibility problems for people who aren't + able to see the image, you should provide a text + description using the alt and longdesc attributes. + In addition, avoid the use of server-side image maps. + Note that in this DTD there is no name attribute. That + is only available in the transitional and frameset DTD. + + + + + + + + + + + + + + + usemap points to a map element which may be in this document + or an external document, although the latter is not widely supported + + + + + + + + + + + + + + + + ================== Client-side image maps ============================ + + These can be placed in the same document or grouped in a + separate document although this isn't yet widely supported + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ================ Forms =============================================== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Each label must not contain more than ONE field + Label elements shouldn't be nested. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + form control + + + + + + + + + + the name attribute is required for all but submit & reset + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + option selector + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + option group + + + + + + + + + + + + + + + + + + + + + + selectable choice + + + + + + + + + + + + + + + + + + + + + + + + + + + multi-line text field + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The fieldset element is used to group form fields. + Only one legend element should occur in the content + and if present should only be preceded by whitespace. + + NOTE: this content model is different from the XHTML 1.0 DTD, + closer to the intended content model in HTML4 DTD + + + + + + + + + + + + + + + + + + + + fieldset label + + + + + + + + + + + + + + + + Content is "Flow" excluding a, form and form controls + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ======================= Tables ======================================= + + Derived from IETF HTML table standard, see [RFC1942] + + + + + + + The border attribute sets the thickness of the frame around the + table. The default units are screen pixels. + + The frame attribute specifies which parts of the frame around + the table should be rendered. The values are not the same as + CALS to avoid a name clash with the valign attribute. + + + + + + + + + + + + + + + + + + + The rules attribute defines which rules to draw between cells: + + If rules is absent then assume: + "none" if border is absent or border="0" otherwise "all" + + + + + + + + + + + + + + + horizontal alignment attributes for cell contents + + char alignment char, e.g. char=':' + charoff offset for alignment char + + + + + + + + + + + + + + + + + + + + + vertical alignment attributes for cell contents + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Use thead to duplicate headers when breaking table + across page boundaries, or for static headers when + tbody sections are rendered in scrolling panel. + + Use tfoot to duplicate footers when breaking table + across page boundaries, or for static footers when + tbody sections are rendered in scrolling panel. + + Use multiple tbody sections when rules are needed + between groups of table rows. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + colgroup groups a set of col elements. It allows you to group + several semantically related columns together. + + + + + + + + + + + + + + + + + + col elements define the alignment properties for cells in + one or more columns. + + The width attribute specifies the width of the columns, e.g. + + width=64 width in screen pixels + width=0.5* relative width of 0.5 + + The span attribute causes the attributes of one + col element to apply to more than one column. + + + + + + + + + + + + + + + + + + + + + + + + + + + Scope is simpler than headers attribute for common tables + + + + + + + + + + + + + th is for headers, td for data and for cells acting as both + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml10/xhtml1-transitional.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml10/xhtml1-transitional.xsd new file mode 100644 index 0000000000000..8ce44fb9aff62 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml10/xhtml1-transitional.xsd @@ -0,0 +1,2755 @@ + + + + + + XHTML 1.0 (Second Edition) Transitional in XML Schema + + This is the same as HTML 4 Transitional except for + changes due to the differences between XML and SGML. + + Namespace = http://www.w3.org/1999/xhtml + + For further information, see: http://www.w3.org/TR/xhtml1 + + Copyright (c) 1998-2002 W3C (MIT, INRIA, Keio), + All Rights Reserved. + + The DTD version is identified by the PUBLIC and SYSTEM identifiers: + + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" + + $Id: xhtml1-transitional.xsd,v 1.5 2002/08/28 09:53:29 mimasa Exp $ + + + + + + + + ================ Character mnemonic entities ========================= + + XHTML entity sets are identified by the PUBLIC and SYSTEM identifiers: + + PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN" + SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent" + + PUBLIC "-//W3C//ENTITIES Special for XHTML//EN" + SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent" + + PUBLIC "-//W3C//ENTITIES Symbols for XHTML//EN" + SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent" + + + + + + ================== Imported Names ==================================== + + + + + + + media type, as per [RFC2045] + + + + + + + + + comma-separated list of media types, as per [RFC2045] + + + + + + + + + a character encoding, as per [RFC2045] + + + + + + + + + a space separated list of character encodings, as per [RFC2045] + + + + + + + + + a language code, as per [RFC3066] + + + + + + + + + a single character, as per section 2.2 of [XML] + + + + + + + + + + + one or more digits + + + + + + + + + + + tabindex attribute specifies the position of the current element + in the tabbing order for the current document. This value must be + a number between 0 and 32767. User agents should ignore leading zeros. + + + + + + + + + + + + space-separated list of link types + + + + + + + + + single or comma-separated list of media descriptors + + + + + + + + + + + a Uniform Resource Identifier, see [RFC2396] + + + + + + + + + a space separated list of Uniform Resource Identifiers + + + + + + + + + date and time information. ISO date format + + + + + + + + + script expression + + + + + + + + + style sheet data + + + + + + + + + used for titles etc. + + + + + + + + + render in this frame + + + + + + + + + + + nn for pixels or nn% for percentage length + + + + + + + + + + + pixel, percentage, or relative + + + + + + + + + + + integer representing length in pixels + + + + + + + + these are used for image maps + + + + + + + + + + + + + + + + comma separated list of lengths + + + + + + + + + + + used for object, applet, img, input and iframe + + + + + + + + + + + + + + + a color using sRGB: #RRGGBB as Hex values + + There are also 16 widely known color names with their sRGB values: + + Black = #000000 Green = #008000 + Silver = #C0C0C0 Lime = #00FF00 + Gray = #808080 Olive = #808000 + White = #FFFFFF Yellow = #FFFF00 + Maroon = #800000 Navy = #000080 + Red = #FF0000 Blue = #0000FF + Purple = #800080 Teal = #008080 + Fuchsia= #FF00FF Aqua = #00FFFF + + + + + + + + + + =================== Generic Attributes =============================== + + + + + + + core attributes common to most elements + id document-wide unique id + class space separated list of classes + style associated style info + title advisory title/amplification + + + + + + + + + + + + internationalization attributes + lang language code (backwards compatible) + xml:lang language code (as per XML 1.0 spec) + dir direction for weak/neutral text + + + + + + + + + + + + + + + + + + attributes for common UI events + onclick a pointer button was clicked + ondblclick a pointer button was double clicked + onmousedown a pointer button was pressed down + onmouseup a pointer button was released + onmousemove a pointer was moved onto the element + onmouseout a pointer was moved away from the element + onkeypress a key was pressed and released + onkeydown a key was pressed down + onkeyup a key was released + + + + + + + + + + + + + + + + + + attributes for elements that can get the focus + accesskey accessibility key character + tabindex position in tabbing order + onfocus the element got the focus + onblur the element lost the focus + + + + + + + + + + + + + + + + + + text alignment for p, div, h1-h6. The default is + align="left" for ltr headings, "right" for rtl + + + + + + + + + + + + + + + + + =================== Text Elements ==================================== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + these can only occur at block level + + + + + + + + + + + + + these can only occur at block level + + + + + + + + + + + + + + + + + + + + + + "Inline" covers inline or "text-level" element + + + + + + + + + + + ================== Block level elements ============================== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + "Flow" mixes block and inline and is used for list items etc. + + + + + + + + + + + + + ================== Content models for exclusions ===================== + + + + + + + a elements use "Inline" excluding a + + + + + + + + + + + + + + + pre uses "Inline" excluding img, object, applet, big, small, + font, or basefont + + + + + + + + + + + + + + + + form uses "Flow" excluding form + + + + + + + + + + + + + button uses "Flow" but excludes a, form, form controls, iframe + + + + + + + + + + + + + + + + + + + + + + + + + ================ Document Structure ================================== + + + + + + + + + + + + + + + + + ================ Document Head ======================================= + + + + + + + + + + + + + + + + + + + + content model is "head.misc" combined with a single + title and an optional base element in any order + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The title element is not considered part of the flow of text. + It should be displayed, for example as the page header or + window title. Exactly one title is required per document. + + + + + + + + + + + + document base URI + + + + + + + + + + + + + generic metainformation + + + + + + + + + + + + + + + + Relationship values can be used in principle: + + a) for document specific toolbars/menus when used + with the link element in document head e.g. + start, contents, previous, next, index, end, help + b) to link to a separate style sheet (rel="stylesheet") + c) to make a link to a script (rel="script") + d) by stylesheets to control how collections of + html nodes are rendered into printed documents + e) to make a link to a printable version of this document + e.g. a PostScript or PDF version (rel="alternate" media="print") + + + + + + + + + + + + + + + + + + + style info, which may include CDATA sections + + + + + + + + + + + + + + + + script statements, which may include CDATA sections + + + + + + + + + + + + + + + + + + + + + + + alternate content container for non script-based rendering + + + + + + + + + + + + + + ======================= Frames ======================================= + + + + + + + inline subwindow + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + alternate content container for non frame-based rendering + + + + + + + + + + + + + + =================== Document Body ==================================== + + + + + + + + + + + + + + + + + + + + + + + + + generic language/style container + + + + + + + + + + + + + + + =================== Paragraphs ======================================= + + + + + + + + + + + + + + + + + =================== Headings ========================================= + + There are six levels of headings from h1 (the most important) + to h6 (the least important). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + =================== Lists ============================================ + + + + + + + Unordered list bullet styles + + + + + + + + + + + + + Unordered list + + + + + + + + + + + + + + + + + + + + + + Ordered list numbering style + + 1 arabic numbers 1, 2, 3, ... + a lower alpha a, b, c, ... + A upper alpha A, B, C, ... + i lower roman i, ii, iii, ... + I upper roman I, II, III, ... + + The style is applied to the sequence number which by default + is reset to 1 for the first list item in an ordered list. + + + + + + + + + Ordered (numbered) list + + + + + + + + + + + + + + + + + + + + + + + single column list (DEPRECATED) + + + + + + + + + + + + + + + + + + + + + multiple column list (DEPRECATED) + + + + + + + + + + + + + + + + + + + + + LIStyle is constrained to: "(ULStyle|OLStyle)" + + + + + + + + + list item + + + + + + + + + + + + + + + + definition lists - dt for term, dd for its definition + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + =================== Address ========================================== + + + + + + + information on author + + + + + + + + + + + + + + + =================== Horizontal Rule ================================== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + =================== Preformatted Text ================================ + + + + + + + content is "Inline" excluding + "img|object|applet|big|small|sub|sup|font|basefont" + + + + + + + + + + + + + + + + =================== Block-like Quotes ================================ + + + + + + + + + + + + + + + + + =================== Text alignment =================================== + + + + + + + center content + + + + + + + + + + + + + + =================== Inserted/Deleted Text ============================ + + ins/del are allowed in block and inline content, but its + inappropriate to include block content within an ins element + occurring in inline content. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ================== The Anchor Element ================================ + + + + + + + content is "Inline" except that anchors shouldn't be nested + + + + + + + + + + + + + + + + + + + + + + + + + ===================== Inline Elements ================================ + + + + + + + generic language/style container + + + + + + + + + + + + + + + I18N BiDi over-ride + + + + + + + + + + + + + + + + + + + + + + + + + + forced line break + + + + + + + + + + + + + + + + + + + + + emphasis + + + + + + + + + + + + + + + strong emphasis + + + + + + + + + + + + + + + definitional + + + + + + + + + + + + + + + program code + + + + + + + + + + + + + + + sample + + + + + + + + + + + + + + + something user would type + + + + + + + + + + + + + + + variable + + + + + + + + + + + + + + + citation + + + + + + + + + + + + + + + abbreviation + + + + + + + + + + + + + + + acronym + + + + + + + + + + + + + + + inlined quote + + + + + + + + + + + + + + + + subscript + + + + + + + + + + + + + + + superscript + + + + + + + + + + + + + + + fixed pitch font + + + + + + + + + + + + + + + italic font + + + + + + + + + + + + + + + bold font + + + + + + + + + + + + + + + bigger font + + + + + + + + + + + + + + + smaller font + + + + + + + + + + + + + + + underline + + + + + + + + + + + + + + + strike-through + + + + + + + + + + + + + + + strike-through + + + + + + + + + + + + + + + base font size + + + + + + + + + + + + + + local change to font + + + + + + + + + + + + + + + + + + ==================== Object ====================================== + + object is used to embed objects as part of HTML pages. + param elements should precede other content. Parameters + can also be expressed as attribute/value pairs on the + object element itself when brevity is desired. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + param is used to supply a named property value. + In XML it would seem natural to follow RDF and support an + abbreviated syntax where the param elements are replaced + by attribute value pairs on the object start tag. + + + + + + + + + + + + + + + + + + + + + + =================== Java applet ================================== + + One of code or object attributes must be present. + Place param elements before other content. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + =================== Images =========================================== + + To avoid accessibility problems for people who aren't + able to see the image, you should provide a text + description using the alt and longdesc attributes. + In addition, avoid the use of server-side image maps. + + + + + + + + + + + + + + + + usemap points to a map element which may be in this document + or an external document, although the latter is not widely supported + + + + + + + + + + + + + + + + + + + + ================== Client-side image maps ============================ + + These can be placed in the same document or grouped in a + separate document although this isn't yet widely supported + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ================ Forms =============================================== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Each label must not contain more than ONE field + Label elements shouldn't be nested. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + form control + + + + + + + + + + the name attribute is required for all but submit & reset + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + option selector + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + option group + + + + + + + + + + + + + + + + + + + + + + selectable choice + + + + + + + + + + + + + + + + + + + + + + + + + + + multi-line text field + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The fieldset element is used to group form fields. + Only one legend element should occur in the content + and if present should only be preceded by whitespace. + + NOTE: this content model is different from the XHTML 1.0 DTD, + closer to the intended content model in HTML4 DTD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + fieldset label + + + + + + + + + + + + + + + + + Content is "Flow" excluding a, form and form controls + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + single-line text input control (DEPRECATED) + + + + + + + + + + + + ======================= Tables ======================================= + + Derived from IETF HTML table standard, see [RFC1942] + + + + + + + The border attribute sets the thickness of the frame around the + table. The default units are screen pixels. + + The frame attribute specifies which parts of the frame around + the table should be rendered. The values are not the same as + CALS to avoid a name clash with the valign attribute. + + + + + + + + + + + + + + + + + + + The rules attribute defines which rules to draw between cells: + + If rules is absent then assume: + "none" if border is absent or border="0" otherwise "all" + + + + + + + + + + + + + + + horizontal placement of table relative to document + + + + + + + + + + + + + horizontal alignment attributes for cell contents + + char alignment char, e.g. char=':' + charoff offset for alignment char + + + + + + + + + + + + + + + + + + + + + vertical alignment attributes for cell contents + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Use thead to duplicate headers when breaking table + across page boundaries, or for static headers when + tbody sections are rendered in scrolling panel. + + Use tfoot to duplicate footers when breaking table + across page boundaries, or for static footers when + tbody sections are rendered in scrolling panel. + + Use multiple tbody sections when rules are needed + between groups of table rows. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + colgroup groups a set of col elements. It allows you to group + several semantically related columns together. + + + + + + + + + + + + + + + + + + col elements define the alignment properties for cells in + one or more columns. + + The width attribute specifies the width of the columns, e.g. + + width=64 width in screen pixels + width=0.5* relative width of 0.5 + + The span attribute causes the attributes of one + col element to apply to more than one column. + + + + + + + + + + + + + + + + + + + + + + + + + + + + Scope is simpler than headers attribute for common tables + + + + + + + + + + + + + th is for headers, td for data and for cells acting as both + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-attribs-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-attribs-1.xsd new file mode 100644 index 0000000000000..f07528a9ef1bf --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-attribs-1.xsd @@ -0,0 +1,73 @@ + + + + + + + This is the XML Schema common attributes module for XHTML + $Id: xhtml-attribs-1.xsd,v 1.9 2009/11/18 17:59:51 ahby Exp $ + + + + + + + + This import brings in the XML namespace attributes + The module itself does not provide the schemaLocation + and expects the driver schema to provide the + actual SchemaLocation. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-base-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-base-1.xsd new file mode 100644 index 0000000000000..a23df79d4e1ba --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-base-1.xsd @@ -0,0 +1,36 @@ + + + + + + + Base element + This is the XML Schema Base Element module for XHTML + + * base + + This module declares the base element type and its attributes, + used to define a base URI against which relative URIs in the + document will be resolved. + + $Id: xhtml-base-1.xsd,v 1.2 2005/09/26 22:54:53 ahby Exp $ + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-bdo-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-bdo-1.xsd new file mode 100644 index 0000000000000..15251c61cca02 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-bdo-1.xsd @@ -0,0 +1,71 @@ + + + + + + Bidirectional Override (bdo) Element + This is the XML Schema BDO Element module for XHTML + + This modules declares the element 'bdo' and 'dir' attributes, + Used to override the Unicode bidirectional algorithm for selected + fragments of text. + Bidirectional text support includes both the bdo element and + the 'dir' attribute. + + $Id: xhtml-bdo-1.xsd,v 1.6 2009/11/18 17:59:51 ahby Exp $ + + + + + + + + This import brings in the XML namespace attributes + The module itself does not provide the schemaLocation + and expects the driver schema to provide the + actual SchemaLocation. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-blkphras-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-blkphras-1.xsd new file mode 100644 index 0000000000000..9a795f8f0ce4c --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-blkphras-1.xsd @@ -0,0 +1,160 @@ + + + + + + + + + This is the XML Schema Block Phrasal support module for XHTML + $Id: xhtml-blkphras-1.xsd,v 1.7 2008/07/05 04:11:00 ahby Exp $ + + + + + + Block Phrasal + This module declares the elements and their attributes used to + support block-level phrasal markup. + This is the XML Schema block phrasal elements module for XHTML + + * address, blockquote, pre, h1, h2, h3, h4, h5, h6 + + + + + + + This import brings in the XML namespace attributes + The module itself does not provide the schemaLocation + and expects the driver schema to provide the + actual SchemaLocation. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-blkpres-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-blkpres-1.xsd new file mode 100644 index 0000000000000..cf42303a686ce --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-blkpres-1.xsd @@ -0,0 +1,37 @@ + + + + + + This is the XML SchemaBlock presentation element module for XHTML + $Id: xhtml-blkpres-1.xsd,v 1.2 2005/09/26 22:54:53 ahby Exp $ + + + + + Block Presentational Elements + + * hr + + This module declares the elements and their attributes used to + support block-level presentational markup. + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-blkstruct-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-blkstruct-1.xsd new file mode 100644 index 0000000000000..1e658580e7a3a --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-blkstruct-1.xsd @@ -0,0 +1,49 @@ + + + + + + Block Structural + + * div, p + + This module declares the elements and their attributes used to + support block-level structural markup. + + This is the XML Schema Block Structural module for XHTML + $Id: xhtml-blkstruct-1.xsd,v 1.3 2005/09/26 22:54:53 ahby Exp $ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-copyright-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-copyright-1.xsd new file mode 100644 index 0000000000000..24c84fd476d2d --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-copyright-1.xsd @@ -0,0 +1,29 @@ + + + + + + This is XHTML, a reformulation of HTML as a modular XML application + The Extensible HyperText Markup Language (XHTML) + Copyright ©1998-2005 World Wide Web Consortium + (Massachusetts Institute of Technology, European Research Consortium + for Informatics and Mathematics, Keio University). + All Rights Reserved. + + Permission to use, copy, modify and distribute the XHTML Schema + modules and their accompanying xs:documentation for any purpose + and without fee is hereby granted in perpetuity, provided that the above + copyright notice and this paragraph appear in all copies. + The copyright holders make no representation about the suitability of + these XML Schema modules for any purpose. + + They are provided "as is" without expressed or implied warranty. + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-csismap-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-csismap-1.xsd new file mode 100644 index 0000000000000..42f802d0f7989 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-csismap-1.xsd @@ -0,0 +1,96 @@ + + + + + + + Client-side Image Maps + This is the XML Schema Client-side Image Maps module for XHTML + + * area, map + + This module declares elements and attributes to support client-side + image maps. + + $Id: xhtml-csismap-1.xsd,v 1.3 2009/09/30 15:12:48 ahby Exp $ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-datatypes-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-datatypes-1.xsd new file mode 100644 index 0000000000000..ab7bac0ee858c --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-datatypes-1.xsd @@ -0,0 +1,242 @@ + + + + + XHTML Datatypes + This is the XML Schema datatypes module for XHTML + + Defines containers for the XHTML datatypes, many of + these imported from other specifications and standards. + + $Id: xhtml-datatypes-1.xsd,v 1.12 2009/09/30 15:12:48 ahby Exp $ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-edit-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-edit-1.xsd new file mode 100644 index 0000000000000..44380b23e0ef8 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-edit-1.xsd @@ -0,0 +1,39 @@ + + + + + + + Editing Elements + This is the XML Schema Editing Markup module for XHTML + + * ins, del + + This module declares element types and attributes used to indicate + inserted and deleted content while editing a document. + + $Id: xhtml-edit-1.xsd,v 1.2 2005/09/26 22:54:53 ahby Exp $ + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-events-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-events-1.xsd new file mode 100644 index 0000000000000..381f6dd506881 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-events-1.xsd @@ -0,0 +1,130 @@ + + + + + + + This is the XML Schema Intrinsic Events module for XHTML + $Id: xhtml-events-1.xsd,v 1.4 2005/09/26 22:54:53 ahby Exp $ + + + + + + Intrinsic Event Attributes + These are the event attributes defined in HTML 4, + Section 18.2.3 "Intrinsic Events". + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-form-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-form-1.xsd new file mode 100644 index 0000000000000..d7a970f4f238f --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-form-1.xsd @@ -0,0 +1,327 @@ + + + + + + + Forms + This is the XML Schema Forms module for XHTML + + * form, label, input, select, optgroup, option, + textarea, fieldset, legend, button + + This module declares markup to provide support for online + forms, based on the features found in HTML 4.0 forms. + + + $Id: xhtml-form-1.xsd,v 1.4 2009/09/30 15:22:38 ahby Exp $ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-framework-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-framework-1.xsd new file mode 100644 index 0000000000000..05b906d44806c --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-framework-1.xsd @@ -0,0 +1,66 @@ + + + + + This is the XML Schema Modular Framework support module for XHTML + $Id: xhtml-framework-1.xsd,v 1.5 2005/09/26 23:37:47 ahby Exp $ + + + + + + XHTML Modular Framework + This required module instantiates the necessary modules + needed to support the XHTML modularization framework. + + The Schema modules instantiated are: + + notations + + datatypes + + common attributes + + character entities + + + + + + + + This module defines XHTML Attribute DataTypes + + + + + + + + This module defines Common attributes for XHTML + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-hypertext-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-hypertext-1.xsd new file mode 100644 index 0000000000000..2f4c81bc89578 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-hypertext-1.xsd @@ -0,0 +1,47 @@ + + + + + + + Hypertext Module + This is the XML Schema Hypertext module for XHTML + + * a + + This module declares the anchor ('a') element type, which + defines the source of a hypertext link. The destination + (or link 'target') is identified via its 'id' attribute + rather than the 'name' attribute as was used in HTML. + + $Id: xhtml-hypertext-1.xsd,v 1.4 2005/09/26 23:37:47 ahby Exp $ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-image-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-image-1.xsd new file mode 100644 index 0000000000000..4d6e9ab1645f4 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-image-1.xsd @@ -0,0 +1,46 @@ + + + + + + + Images + This is the XML Schema Images module for XHTML + + * img + + This module provides markup to support basic image embedding. + + To avoid problems with text-only UAs as well as to make + image content understandable and navigable to users of + non-visual UAs, you need to provide a description with + the 'alt' attribute, and avoid server-side image maps. + + + $Id: xhtml-image-1.xsd,v 1.3 2009/09/30 15:22:38 ahby Exp $ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlphras-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlphras-1.xsd new file mode 100644 index 0000000000000..919c59de3b332 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlphras-1.xsd @@ -0,0 +1,163 @@ + + + + + + + This is the XML Schema Inline Phrasal support module for XHTML + $Id: xhtml-inlphras-1.xsd,v 1.4 2005/09/26 22:54:53 ahby Exp $ + + + + + + Inline Phrasal. + This module declares the elements and their attributes used to + support inline-level phrasal markup. + This is the XML Schema Inline Phrasal module for XHTML + + * abbr, acronym, cite, code, dfn, em, kbd, q, samp, strong, var + + $Id: xhtml-inlphras-1.xsd,v 1.4 2005/09/26 22:54:53 ahby Exp $ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlpres-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlpres-1.xsd new file mode 100644 index 0000000000000..a053447c284e9 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlpres-1.xsd @@ -0,0 +1,39 @@ + + + + + + This is the XML Schema Inline Presentation element module for XHTML + $Id: xhtml-inlpres-1.xsd,v 1.2 2005/09/26 22:54:53 ahby Exp $ + + + + + + Inline Presentational Elements + + * b, big, i, small, sub, sup, tt + + This module declares the elements and their attributes used to + support inline-level presentational markup. + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlstruct-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlstruct-1.xsd new file mode 100644 index 0000000000000..635eb5f193dd1 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlstruct-1.xsd @@ -0,0 +1,50 @@ + + + + + + This is the XML Schema Inline Structural support module for XHTML + $Id: xhtml-inlstruct-1.xsd,v 1.4 2005/09/26 22:54:53 ahby Exp $ + + + + + + Inline Structural. + This module declares the elements and their attributes + used to support inline-level structural markup. + This is the XML Schema Inline Structural element module for XHTML + + * br, span + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlstyle-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlstyle-1.xsd new file mode 100644 index 0000000000000..ef93c2dcefac4 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlstyle-1.xsd @@ -0,0 +1,27 @@ + + + + + + Inline Style module + This is the XML Schema Inline Style module for XHTML + + * styloe attribute + + This module declares the 'style' attribute, used to support inline + style markup. + + $Id: xhtml-inlstyle-1.xsd,v 1.2 2005/09/26 22:54:53 ahby Exp $ + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-link-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-link-1.xsd new file mode 100644 index 0000000000000..f210d84a11d26 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-link-1.xsd @@ -0,0 +1,45 @@ + + + + + + This is the XML Schema Link Element module for XHTML + $Id: xhtml-link-1.xsd,v 1.2 2005/09/26 22:54:53 ahby Exp $ + + + + + + Link element + + * link + + This module declares the link element type and its attributes, + which could (in principle) be used to define document-level links + to external resources. + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-list-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-list-1.xsd new file mode 100644 index 0000000000000..cc22ba88f603d --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-list-1.xsd @@ -0,0 +1,99 @@ + + + + + + List Module + This is the XML Schema Lists module for XHTML + List Module Elements + + * dl, dt, dd, ol, ul, li + + This module declares the list-oriented element types + and their attributes. + $Id: xhtml-list-1.xsd,v 1.2 2005/09/26 22:54:53 ahby Exp $ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-meta-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-meta-1.xsd new file mode 100644 index 0000000000000..010137b37da84 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-meta-1.xsd @@ -0,0 +1,54 @@ + + + + + + + This is the XML Schema Metainformation module for XHTML + $Id: xhtml-meta-1.xsd,v 1.3 2008/07/05 04:11:00 ahby Exp $ + + + + + + Meta Information + + * meta + + This module declares the meta element type and its attributes, + used to provide declarative document metainformation. + + + + + + + This import brings in the XML namespace attributes + The module itself does not provide the schemaLocation + and expects the driver schema to provide the + actual SchemaLocation. + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-notations-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-notations-1.xsd new file mode 100644 index 0000000000000..8ca35cd6ff8ba --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-notations-1.xsd @@ -0,0 +1,69 @@ + + + + + + Notations module + This is the XML Schema module for data type notations for XHTML + $Id: xhtml-notations-1.xsd,v 1.5 2005/09/26 22:54:53 ahby Exp $ + + + + + + Notations module + Defines the XHTML notations, many of these imported from + other specifications and standards. When an existing FPI is + known, it is incorporated here. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-object-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-object-1.xsd new file mode 100644 index 0000000000000..a32efb0fa964f --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-object-1.xsd @@ -0,0 +1,76 @@ + + + + + + + This is the XML Schema Embedded Object module for XHTML + $Id: xhtml-object-1.xsd,v 1.2 2005/09/26 22:54:53 ahby Exp $ + + + + + + This module declares the object element type and its attributes, + used to embed external objects as part of XHTML pages. In the + document, place param elements prior to the object elements + that require their content. + + Note that use of this module requires instantiation of the + Param Element Module prior to this module. + + Elements defined here: + + * object (param) + + + + + + + Param module + + Elements defined here: + * param + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-param-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-param-1.xsd new file mode 100644 index 0000000000000..ba34ff41290ae --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-param-1.xsd @@ -0,0 +1,51 @@ + + + + + + This is the XML Schema Param Element module for XHTML + $Id: xhtml-param-1.xsd,v 1.3 2005/09/26 22:54:53 ahby Exp $ + + + + + + Parameters for Java Applets and Embedded Objects + + * param + + This module provides declarations for the param element, + used to provide named property values for the applet + and object elements. + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-pres-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-pres-1.xsd new file mode 100644 index 0000000000000..bc36fc48f7740 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-pres-1.xsd @@ -0,0 +1,51 @@ + + + + + + This is the XML Schema Presentation module for XHTML + This is a REQUIRED module. + $Id: xhtml-pres-1.xsd,v 1.2 2005/09/26 22:54:53 ahby Exp $ + + + + + + Presentational Elements + + This module defines elements and their attributes for + simple presentation-related markup. + + Elements defined here: + + * hr + * b, big, i, small, sub, sup, tt + + + + + + + Block Presentational module + Elements defined here: + + * hr + + + + + + + Inline Presentational module + Elements defined here: + + * b, big, i, small, sub, sup, tt + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-ruby-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-ruby-1.xsd new file mode 100644 index 0000000000000..666f81bd2b93d --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-ruby-1.xsd @@ -0,0 +1,170 @@ + + + + + + This is the Ruby module for XHTML + $Id: xhtml-ruby-1.xsd,v 1.7 2010/05/02 17:22:08 ahby Exp $ + + + + + + + "Ruby" are short runs of text alongside the base text, typically + used in East Asian documents to indicate pronunciation or to + provide a short annotation. The full specification for Ruby is here: + + http://www.w3.org/TR/2001/REC-ruby-20010531/ + + This module defines "Ruby " or "complex Ruby" as described + in the specification: + + http://www.w3.org/TR/2001/REC-ruby-20010531/#complex + + Simple or Basic Ruby are defined in a separate module. + + This module declares the elements and their attributes used to + support complex ruby annotation markup. Elements defined here + * ruby, rbc, rtc, rb, rt, rp + + This module expects the document model to define the + following content models + + InlNoRuby.mix + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-script-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-script-1.xsd new file mode 100644 index 0000000000000..5ba6e20e036ee --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-script-1.xsd @@ -0,0 +1,71 @@ + + + + + + This is the XML Schema Scripting module for XHTML + $Id: xhtml-script-1.xsd,v 1.5 2006/09/11 08:50:41 ahby Exp $ + + + + + + Scripting + + * script, noscript + + This module declares element types and attributes used to provide + support for executable scripts as well as an alternate content + container where scripts are not supported. + + + + + + + This import brings in the XML namespace attributes + The module itself does not provide the schemaLocation + and expects the driver schema to provide the + actual SchemaLocation. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-ssismap-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-ssismap-1.xsd new file mode 100644 index 0000000000000..4e120107ebaab --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-ssismap-1.xsd @@ -0,0 +1,43 @@ + + + + + + This is the XML Schema Server-side Image Maps module for XHTML + $Id: xhtml-ssismap-1.xsd,v 1.3 2005/09/26 22:54:53 ahby Exp $ + + + + + + Server-side Image Maps + + This adds the 'ismap' attribute to the img element to + support server-side processing of a user selection. + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-struct-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-struct-1.xsd new file mode 100644 index 0000000000000..a0d21300e8965 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-struct-1.xsd @@ -0,0 +1,130 @@ + + + + + + This is the XML Schema Document Structure module for XHTML + Document Structure + + * title, head, body, html + + The Structure Module defines the major structural elements and + their attributes. + + $Id: xhtml-struct-1.xsd,v 1.11 2009/09/30 14:13:35 ahby Exp $ + + + + + + + + This import brings in the XML namespace attributes + The module itself does not provide the schemaLocation + and expects the driver schema to provide the + actual SchemaLocation. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-style-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-style-1.xsd new file mode 100644 index 0000000000000..c20da4a7088fa --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-style-1.xsd @@ -0,0 +1,53 @@ + + + + + + + This is the XML Schema Stylesheets module for XHTML + $Id: xhtml-style-1.xsd,v 1.5 2006/09/11 10:14:57 ahby Exp $ + + + + + + Stylesheets + + * style + + This module declares the style element type and its attributes, + used to embed stylesheet information in the document head element. + + + + + + + This import brings in the XML namespace attributes + The module itself does not provide the schemaLocation + and expects the driver schema to provide the + actual SchemaLocation. + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-table-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-table-1.xsd new file mode 100644 index 0000000000000..ec76db3ca8b3f --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-table-1.xsd @@ -0,0 +1,272 @@ + + + + + + + This is the XML Schema Tables module for XHTML + $Id: xhtml-table-1.xsd,v 1.3 2005/09/26 22:54:53 ahby Exp $ + + + + + + Tables + + * table, caption, thead, tfoot, tbody, colgroup, col, tr, th, td + + This module declares element types and attributes used to provide + table markup similar to HTML 4.0, including features that enable + better accessibility for non-visual user agents. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-target-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-target-1.xsd new file mode 100644 index 0000000000000..d8f2770d28e2b --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-target-1.xsd @@ -0,0 +1,49 @@ + + + + + + This is the XML Schema Target module for XHTML + $Id: xhtml-target-1.xsd,v 1.3 2007/04/03 18:27:01 ahby Exp $ + + + + + + + Target + + * target + + This module declares the 'target' attribute used for opening windows + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-text-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-text-1.xsd new file mode 100644 index 0000000000000..432bdad7ac3cf --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-text-1.xsd @@ -0,0 +1,67 @@ + + + + + + Textual Content + This is the XML Schema Text module for XHTML + + The Text module includes declarations for all core + text container elements and their attributes. + + + block phrasal + + block structural + + inline phrasal + + inline structural + + $Id: xhtml-text-1.xsd,v 1.2 2005/09/26 22:54:53 ahby Exp $ + + + + + + + + Block Phrasal module + Elements defined here: + + * address, blockquote, pre, h1, h2, h3, h4, h5, h6 + + + + + + + Block Structural module + Elements defined here: + + * div, p + + + + + + + Inline Phrasal module + Elements defined here: + + * abbr, acronym, cite, code, dfn, em, kbd, q, samp, strong, var + + + + + + + Inline Structural module + Elements defined here: + + * br,span + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml11-model-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml11-model-1.xsd new file mode 100644 index 0000000000000..a1c138d84882e --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml11-model-1.xsd @@ -0,0 +1,716 @@ + + + + + + This is the XML Schema module of common content models for XHTML11 + + $Id: xhtml11-model-1.xsd,v 1.9 2009/02/03 15:14:49 ahby Exp $ + + + + + + XHTML Document Model + This module describes the groupings of elements/attributes + that make up common content models for XHTML elements. + XHTML has following basic content models: + xhtml.Inline.mix; character-level elements + xhtml.Block.mix; block-like elements, e.g., paragraphs and lists + xhtml.Flow.mix; any block or inline elements + xhtml.HeadOpts.mix; Head Elements + xhtml.InlinePre.mix; Special class for pre content model + xhtml.InlineNoAnchor.mix; Content model for Anchor + + Any groups declared in this module may be used to create + element content models, but the above are considered 'global' + (insofar as that term applies here). XHTML has the + following Attribute Groups + xhtml.Core.extra.attrib + xhtml.I18n.extra.attrib + xhtml.Common.extra + + The above attribute Groups are considered Global + + + + + Extended I18n attribute + + + + + "dir" Attribute from Bi Directional Text (bdo) Module + + + + + + + + Extended Common Attributes + + + + + "style" attribute from Inline Style Module + + + + + + + Attributes from Events Module + + + + + + + Extend Core Attributes + + + + + Extended Global Core Attributes + + + + + Extended Global I18n attributes + + + + + Extended Global Common Attributes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml11-modules-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml11-modules-1.xsd new file mode 100644 index 0000000000000..676706760a535 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml11-modules-1.xsd @@ -0,0 +1,605 @@ + + + + + + + This schema includes all modules for XHTML1.1 Document Type. + $Id: xhtml11-modules-1.xsd,v 1.10 2009/02/03 15:14:49 ahby Exp $ + + + + + + This schema includes all modules (and redefinitions) + for XHTML1.1 Document Type. + XHTML1.1 Document Type includes the following Modules + + XHTML Core modules (Required for XHTML Family Conformance) + + text + + hypertext + + lists + + structure + + Other XHTML modules + + Edit + + Bdo + + Presentational + + Link + + Meta + + Base + + Scripting + + Style + + Image + + Applet + + Object + + Param (Applet/Object modules require Param Module) + + Tables + + Target + + Forms + + Client side image maps + + Server side image maps + + + + + + + Schema Framework Component Modules: + + notations + + datatypes + + common attributes + + character entities + + + + + + + + Text module + + The Text module includes declarations for all core + text container elements and their attributes. + + + block phrasal + + block structural + + inline phrasal + + inline structural + + Elements defined here: + * address, blockquote, pre, h1, h2, h3, h4, h5, h6 + * div, p + * abbr, acronym, cite, code, dfn, em, kbd, q, samp, strong, var + * br, span + + + + + + + + Hypertext module + + Elements defined here: + * a + + + + + + + + + Redefinition by Client Side Image Map Module + + + + + + + Redefinition by XHTML Event Attribute Module + + + + + + + Target Module - A Attribute Additions + + + + + + + + + Lists module + + Elements defined here: + * dt, dd, dl, ol, ul, li + + + + + + + + Structural module + + Elements defined here: + * title, head, body, html + + + + + + + Redefinition by the XHTML11 Markup (for value of version attr) + + + + + + + + + Original Body Attlist + + + + + + + Redefinition by XHTML Event Attribute Module + + + + + + + + + Edit module + + Elements defined here: + * ins, del + + + + + + + + Bidirectional element module + + Elements defined here: + * bdo + + + + + + + + Presentational module + + Elements defined here: + * hr, b, big, i, small,sub, sup, tt + + + + + + + + Link module + + Elements defined here: + * link + + + + + + + Changes to XHTML Link Attlist + + + + + + Original Link Attributes (declared in Link Module) + + + + + + + XHTML Target Module - Attribute additions + + + + + + + + + Meta module + + Elements defined here: + * meta + + + + + + + + Base module + + Elements defined here: + * base + + + + + + + Changes to XHTML base Attlist + + + + + + Original Base Attributes (declared in Base Module) + + + + + + + XHTML Target Module - Attribute additions + + + + + + + + + Scripting module + + Elements defined here: + * script, noscript + + + + + + + + Style module + + Elements defined here: + * style + + + + + + + + Style attribute module + + Attribute defined here: + * style + + + + + + + + Image module + + Elements defined here: + * img + + + + + + + + Original Image Attributes (in Image Module) + + + + + + + Redefinition by Client Side Image Map Module + + + + + + + Redefinition by Server Side Image Module + + + + + + + + + Client-side mage maps module + + Elements defined here: + * area, map + + + + + + + + Original Area Attributes (in CSI Module) + + + + + + + Redefinition by Events Attribute Module + + + + + + + Target Module - Area Attribute Additions + + + + + + + + + Server-side image maps module + + Attributes defined here: + * ismap on img + + + + + + + + Object module + + Elements defined here: + * object + + + + + + + + Original Object Attlist + + + + + + + Redefinition by Client Image Map Module + + + + + + + + + Param module + + Elements defined here: + * param + + + + + + + Tables module + + Elements defined here: + * table, caption, thead, tfoot, tbody, colgroup, col, tr, th, td + + + + + + + + Forms module + + Elements defined here: + * form, label, input, select, optgroup, option, + * textarea, fieldset, legend, button + + + + + + + Changes to XHTML Form Attlist + + + + + + Original Form Attributes (declared in Forms Module) + + + + + + + XHTML Events Module - Attribute additions + + + + + + + XHTML Target Module - Attribute additions + + + + + + + + Changes to XHTML Form Input Element + + + + + + Original Input Attributes (in Forms Module) + + + + + + + Redefinition by Client Side Image Map Module + + + + + + + Redefinition by Server Side Image Map Module + + + + + + + Redefinition by Event Attribute Module + + + + + + + + + Original Label Attributes (in Forms Module) + + + + + + + Redefinition by Event Attribute Module + + + + + + + + + Original Select Attributes (in Forms Module) + + + + + + + Redefinition by Event Attribute Module + + + + + + + + + Original TextArea Attributes (in Forms Module) + + + + + + + Redefinition by Event Attribute Module + + + + + + + + + Original Button Attributes (in Forms Module) + + + + + + + Redefinition by Event Attribute Module + + + + + + + + + Ruby module + + Elements defined here: + * ruby, rbc, rtc, rb, rt, rp + + Note that either Ruby or Basic Ruby should be used but not both + + + + + + + + XHTML Events Modules + + Attributes defined here: + XHTML Event Types + + + + + + + + XHTML Target Attribute Module + + Attributes defined here: + target + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml11.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml11.xsd new file mode 100644 index 0000000000000..341699935d278 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml11.xsd @@ -0,0 +1,104 @@ + + + + + This is the XML Schema driver for XHTML 1.1. + Please use this namespace for XHTML elements: + + "http://www.w3.org/1999/xhtml" + + $Id: xhtml11.xsd,v 1.7 2009/02/03 15:14:49 ahby Exp $ + + + + + + This is XHTML, a reformulation of HTML as a modular XML application + The Extensible HyperText Markup Language (XHTML) + Copyright ©1998-2007 World Wide Web Consortium + (Massachusetts Institute of Technology, European Research Consortium + for Informatics and Mathematics, Keio University). + All Rights Reserved. + + Permission to use, copy, modify and distribute the XHTML Schema + modules and their accompanying xs:documentation for any purpose + and without fee is hereby granted in perpetuity, provided that the above + copyright notice and this paragraph appear in all copies. + The copyright holders make no representation about the suitability of + these XML Schema modules for any purpose. + + They are provided "as is" without expressed or implied warranty. + + + + + This is the Schema Driver file for XHTML1.1 + Document Type + + This schema + + imports external schemas (xml.xsd) + + refedines (and include)s schema modules for XHTML1.1 Document Type. + + includes Schema for Named content model for the + XHTML1.1 Document Type + + XHTML1.1 Document Type includes the following Modules + XHTML Core modules (Required for XHTML Family Conformance) + + text + + hypertext + + lists + + structure + Other XHTML modules + + Edit + + Bdo + + Presentational + + Link + + Meta + + Base + + Scripting + + Style + + Image + + Applet + + Object + + Param (Applet/Object modules require Param Module) + + Tables + + Forms + + Client side image maps + + Server side image maps + + Ruby + + + + + + This import brings in the XML namespace attributes + The XML attributes are used by various modules. + + + + + + + Document Model module for the XHTML1.1 Document Type. + This schema file defines all named models used by XHTML + Modularization Framework for XHTML1.1 Document Type + + + + + + + Schema that includes all modules (and redefinitions) + for XHTML1.1 Document Type. + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xml-events-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xml-events-1.xsd new file mode 100644 index 0000000000000..0d53b8a52a2bb --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xml-events-1.xsd @@ -0,0 +1,73 @@ + + + + + + This is the XML Schema for XML Events + + URI: http://www.w3.org/MarkUp/SCHEMA/xml-events-1.xsd + $Id: xml-events-1.xsd,v 1.8 2004/11/22 17:09:15 ahby Exp $ + + + + + + + XML Events element listener + + This module defines the listener element for XML Events. + This element can be used to define event listeners. This + module relies upon the XmlEvents.attlist attribute group + defined in xml-events-attribs-1.xsd. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xml-events-copyright-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xml-events-copyright-1.xsd new file mode 100644 index 0000000000000..ebe0e9240030e --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xml-events-copyright-1.xsd @@ -0,0 +1,34 @@ + + + + + + This is XML Events, a generalized event model for XML-based + markup languages. + + Copyright 2001-2003 World Wide Web Consortium + (Massachusetts Institute of Technology, European Research + Consortium for Informatics and Mathematics, Keio University). + All Rights Reserved. + + Permission to use, copy, modify and distribute the + XML Events Schema modules and their accompanying xs:documentation + for any purpose and without fee is hereby granted in perpetuity, + provided that the above copyright notice and this paragraph appear + in all copies. + + The copyright holders make no representation about the suitability of + these XML Schema modules for any purpose. + + They are provided "as is" without expressed or implied warranty. + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xmlNS2001/xml.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xmlNS2001/xml.xsd new file mode 100644 index 0000000000000..cd234ef748a89 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xmlNS2001/xml.xsd @@ -0,0 +1,117 @@ + + + + + + + See http://www.w3.org/XML/1998/namespace.html and + http://www.w3.org/TR/REC-xml for information about this namespace. + + This schema document describes the XML namespace, in a form + suitable for import by other schema documents. + + Note that local names in this namespace are intended to be defined + only by the World Wide Web Consortium or its subgroups. The + following names are currently defined in this namespace and should + not be used with conflicting semantics by any Working Group, + specification, or document instance: + + base (as an attribute name): denotes an attribute whose value + provides a URI to be used as the base for interpreting any + relative URIs in the scope of the element on which it + appears; its value is inherited. This name is reserved + by virtue of its definition in the XML Base specification. + + lang (as an attribute name): denotes an attribute whose value + is a language code for the natural language of the content of + any element; its value is inherited. This name is reserved + by virtue of its definition in the XML specification. + + space (as an attribute name): denotes an attribute whose + value is a keyword indicating what whitespace processing + discipline is intended for the content of the element; its + value is inherited. This name is reserved by virtue of its + definition in the XML specification. + + Father (in any context at all): denotes Jon Bosak, the chair of + the original XML Working Group. This name is reserved by + the following decision of the W3C XML Plenary and + XML Coordination groups: + + In appreciation for his vision, leadership and dedication + the W3C XML Plenary on this 10th day of February, 2000 + reserves for Jon Bosak in perpetuity the XML name + xml:Father + + + + + This schema defines attributes and an attribute group + suitable for use by + schemas wishing to allow xml:base, xml:lang or xml:space attributes + on elements they define. + + To enable this, such a schema must import this schema + for the XML namespace, e.g. as follows: + <schema . . .> + . . . + <import namespace="http://www.w3.org/XML/1998/namespace" + schemaLocation="http://www.w3.org/2001/03/xml.xsd"/> + + Subsequently, qualified reference to any of the attributes + or the group defined below will have the desired effect, e.g. + + <type . . .> + . . . + <attributeGroup ref="xml:specialAttrs"/> + + will define a type which will schema-validate an instance + element with any of those attributes + + + + In keeping with the XML Schema WG's standard versioning + policy, this schema document will persist at + http://www.w3.org/2001/03/xml.xsd. + At the date of issue it can also be found at + http://www.w3.org/2001/xml.xsd. + The schema document at that URI may however change in the future, + in order to remain compatible with the latest version of XML Schema + itself. In other words, if the XML Schema namespace changes, the version + of this document at + http://www.w3.org/2001/xml.xsd will change + accordingly; the version at + http://www.w3.org/2001/03/xml.xsd will not change. + + + + + + In due course, we should install the relevant ISO 2- and 3-letter + codes as the enumerated possible values . . . + + + + + + + + + + + + + + + See http://www.w3.org/TR/xmlbase/ for + information about this attribute. + + + + + + + + + + \ No newline at end of file diff --git a/src/java.xml/share/classes/module-info.java b/src/java.xml/share/classes/module-info.java index e5c421261b082..a12fd3e8f4536 100644 --- a/src/java.xml/share/classes/module-info.java +++ b/src/java.xml/share/classes/module-info.java @@ -417,11 +417,97 @@ * * *

JDK built-in Catalog

- * The JDK has a built-in catalog that hosts the following DTDs defined by the Java Platform: - *
    - *
  • DTD for {@link java.util.prefs.Preferences java.util.prefs.Preferences}, preferences.dtd
  • - *
  • DTD for {@link java.util.Properties java.util.Properties}, properties.dtd
  • - *
+ * The JDK has a built-in catalog that hosts DTDs and XSDs list in the following table. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
DTDs and XSDs in JDK built-in Catalog
SourceFiles
+ * {@link java.util.prefs.Preferences java.util.prefs.Preferences} + * preferences.dtd + *
+ * {@link java.util.Properties java.util.Properties} + * properties.dtd + *
+ * XML Schema Part 1: Structures Second Edition
+ * XML Schema Part 2: Datatypes Second Edition + *
+ * XMLSchema.dtd
+ * datatypes.dtd
+ * XMLSchema.xsd
+ * datatypes.xsd + *
+ * XHTML™ 1.0 The Extensible HyperText Markup Language + * + * xhtml1-frameset.dtd
+ * xhtml1-strict.dtd
+ * xhtml1-transitional.dtd + *
+ * XHTML™ 1.0 in XML Schema + * + * xhtml1-frameset.xsd
+ * xhtml1-strict.xsd
+ * xhtml1-transitional.xsd + *
+ * XHTML™ 1.1 - Module-based XHTML - Second Edition + * + * xhtml11.dtd + *
+ * XHTML 1.1 XML Schema Definition + * + * xhtml11.xsd + *
+ * XML DTD for W3C specifications + * + * xmlspec.dtd + *
+ * The "xml:" Namespace + * + * xml.xsd + *
*

* The catalog is loaded once when the first JAXP processor factory is created. * diff --git a/src/java.xml/share/legal/schema10part1.md b/src/java.xml/share/legal/schema10part1.md new file mode 100644 index 0000000000000..bd7498b9e4727 --- /dev/null +++ b/src/java.xml/share/legal/schema10part1.md @@ -0,0 +1,51 @@ +## XML Schema Part 1: Structures Second Edition + +### W3C Software and Document license +

+Software and Document license - 2023 version
+
+Copied from:  https://www.w3.org/copyright/software-license-2023
+
+License
+
+By obtaining and/or copying this work, you (the licensee) agree that you have
+read, understood, and will comply with the following terms and conditions.
+
+Permission to copy, modify, and distribute this work, with or without modification,
+for any purpose and without fee or royalty is hereby granted, provided that you
+include the following on ALL copies of the work or portions thereof, including
+modifications:
+
+    The full text of this NOTICE in a location viewable to users of the
+    redistributed or derivative work.
+    Any pre-existing intellectual property disclaimers, notices, or terms and
+    conditions. If none exist, the W3C software and document short notice should
+    be included.
+    Notice of any changes or modifications, through a copyright statement on the
+    new code or document such as "This software or document includes material
+    copied from or derived from [title and URI of the W3C document]. Copyright ©
+    [$year-of-document] World Wide Web Consortium.
+    https://www.w3.org/copyright/software-license-2023/"
+
+Disclaimers
+
+THIS WORK IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF
+MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE
+SOFTWARE OR DOCUMENT WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
+TRADEMARKS OR OTHER RIGHTS.
+
+COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENT.
+
+The name and trademarks of copyright holders may NOT be used in advertising or
+publicity pertaining to the work without specific, written prior permission.
+Title to copyright in this work will at all times remain with copyright holders.
+
+------
+
+Copyright © 2004 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability,
+trademark and document use rules apply.
+
+
+
diff --git a/src/java.xml/share/legal/schema10part2.md b/src/java.xml/share/legal/schema10part2.md new file mode 100644 index 0000000000000..601b06db18be7 --- /dev/null +++ b/src/java.xml/share/legal/schema10part2.md @@ -0,0 +1,50 @@ +## XML Schema Part 2: Datatypes Second Edition + +### W3C Software and Document license +
+Software and Document license - 2023 version
+
+Copied from:  https://www.w3.org/copyright/software-license-2023
+
+License
+
+By obtaining and/or copying this work, you (the licensee) agree that you have
+read, understood, and will comply with the following terms and conditions.
+
+Permission to copy, modify, and distribute this work, with or without modification,
+for any purpose and without fee or royalty is hereby granted, provided that you
+include the following on ALL copies of the work or portions thereof, including
+modifications:
+
+    The full text of this NOTICE in a location viewable to users of the
+    redistributed or derivative work.
+    Any pre-existing intellectual property disclaimers, notices, or terms and
+    conditions. If none exist, the W3C software and document short notice should
+    be included.
+    Notice of any changes or modifications, through a copyright statement on the
+    new code or document such as "This software or document includes material
+    copied from or derived from [title and URI of the W3C document]. Copyright ©
+    [$year-of-document] World Wide Web Consortium.
+    https://www.w3.org/copyright/software-license-2023/"
+
+Disclaimers
+
+THIS WORK IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF
+MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE
+SOFTWARE OR DOCUMENT WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
+TRADEMARKS OR OTHER RIGHTS.
+
+COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENT.
+
+The name and trademarks of copyright holders may NOT be used in advertising or
+publicity pertaining to the work without specific, written prior permission.
+Title to copyright in this work will at all times remain with copyright holders.
+
+------
+
+Copyright © 2004 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability,
+trademark and document use rules apply.
+
+
diff --git a/src/java.xml/share/legal/xhtml10.md b/src/java.xml/share/legal/xhtml10.md new file mode 100644 index 0000000000000..765584b6c3818 --- /dev/null +++ b/src/java.xml/share/legal/xhtml10.md @@ -0,0 +1,57 @@ +## XHTMLâ„¢ 1.0 The Extensible HyperText Markup Language + +### W3C Software Notice and License +
+W3C(R) SOFTWARE NOTICE AND LICENSE
+
+Copyright (c) 1994-2002 World Wide Web Consortium, (Massachusetts
+Institute of Technology, Institut National de Recherche en
+Informatique et en Automatique, Keio University). All Rights
+Reserved. http://www.w3.org/Consortium/Legal/
+
+This W3C work (including software, documents, or other related items)
+is being provided by the copyright holders under the following
+license. By obtaining, using and/or copying this work, you (the
+licensee) agree that you have read, understood, and will comply with
+the following terms and conditions:
+
+Permission to use, copy, modify, and distribute this software and its
+documentation, with or without modification, for any purpose and
+without fee or royalty is hereby granted, provided that you include
+the following on ALL copies of the software and documentation or
+portions thereof, including modifications, that you make:
+
+    The full text of this NOTICE in a location viewable to users of
+    the redistributed or derivative work.
+
+    Any pre-existing intellectual property disclaimers, notices, or
+    terms and conditions. If none exist, a short notice of the following
+    form (hypertext is preferred, text is permitted) should be used within
+    the body of any redistributed or derivative code: "Copyright (C)
+    [$date-of-software] World Wide Web Consortium, (Massachusetts
+    Institute of Technology, Institut National de Recherche en
+    Informatique et en Automatique, Keio University). All Rights
+    Reserved. http://www.w3.org/Consortium/Legal/"
+
+    Notice of any changes or modifications to the W3C files, including
+    the date changes were made. (We recommend you provide URIs to the
+    location from which the code is derived.)
+
+THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT
+HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED,
+INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS
+FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR
+DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
+TRADEMARKS OR OTHER RIGHTS.
+
+COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL
+OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR
+DOCUMENTATION.
+
+The name and trademarks of copyright holders may NOT be used in
+advertising or publicity pertaining to the software without specific,
+written prior permission. Title to copyright in this software and any
+associated documentation will at all times remain with copyright
+holders.
+
+
diff --git a/src/java.xml/share/legal/xhtml10schema.md b/src/java.xml/share/legal/xhtml10schema.md new file mode 100644 index 0000000000000..b638568755163 --- /dev/null +++ b/src/java.xml/share/legal/xhtml10schema.md @@ -0,0 +1,150 @@ +## XHTML™ 1.0 in XML Schema + +### W3C® Intellectual Rights Notice and Legal Disclaimers +
+Copyright © 1994-2002 W3C ® (Massachusetts Institute of Technology,
+Institut National de Recherche en Informatique et en Automatique, Keio University),
+All Rights Reserved.
+
+World Wide Web Consortium (W3C®) web site pages may contain other proprietary
+notices and copyright information, the terms of which must be observed and
+followed. Specific notices do exist for W3C documents and software. Also, there
+are specific usage policies associated with some of the W3C Icons. Please see
+our Intellectual Rights FAQ for common questions about using materials from our site.
+
+Notice and Disclaimers
+
+1. Unless otherwise noted, all materials contained in this Site are copyrighted
+and may not be used except as provided in these terms and conditions or in the
+copyright notice (documents and software) or other proprietary notice provided
+with the relevant materials.
+
+2. The materials contained in the Site may be downloaded or copied provided that
+ALL copies retain the copyright and any other proprietary notices contained on
+the materials. No material may be modified, edited or taken out of context such
+that its use creates a false or misleading statement or impression as to the
+positions, statements or actions of W3C.
+
+3. The name and trademarks of copyright holders may NOT be used in advertising
+or publicity pertaining to the Web site, its content, specifications, or
+software without specific, written prior permission. Title to copyright in
+Web site documents will at all times remain with copyright holders. Use of W3C
+trademarks and service marks is covered by the W3C Trademark and Servicemark
+License.
+
+4. Caches of W3C materials should comply with the "maximum time to live"
+information provided with the materials. After such materials have expired
+they should not be served from caches without first validating the contents
+of the W3C Site. Organizations that want to mirror W3C content must abide by
+the W3C Mirroring Policy.
+
+W3C®Trademarks and Generic Terms
+Trademarks owned by W3C host institutions on behalf of W3C and generic terms
+used by the W3C
+
+5. The trademarks, logos, and service marks (collectively the "Trademarks")
+displayed on the Site are registered and unregistered Trademarks of the
+Massachusetts Institute of Technology (MIT), Institut National de Recherche
+en Informatique et en Automatique (INRIA), or Keio University (Keio). All use
+of the W3C Trademarks is governed by the W3C Trademark and Servicemark License.
+No additional rights are granted by implication, estoppel, or otherwise. Terms
+which claimed as generic are not governed by any W3C license and are used as
+common descriptors by the W3C.
+
+The following is a list of W3C terms claimed as a trademark or generic term
+by MIT, INRIA, and/or Keio on behalf of the W3C:
+
+    W3C®, World Wide Web Consortium  (registered in numerous countries)
+    Amayaâ„¢, a Web Browser
+    CSSâ„¢, Cascading Style Sheets Specification
+    DOMâ„¢, Document Object Model
+    HTML (generic), HyperText Markup Language
+    HTTP (generic), Hypertext Transfer Protocol
+    MathMLâ„¢, Mathematical Markup Language
+    Metadata (generic)
+    P3Pâ„¢, Platform for Privacy Preferences Project
+    PICSâ„¢, Platform for Internet Content Selection
+    RDF (generic), Resource Description Framework
+    SMILâ„¢, Synchronized Multimedia Integration Language
+    SVGâ„¢, Scalable Vector Graphics
+    WAIâ„¢, Web Accessibility Initiative
+    XENC (generic), XML Encryption
+    XHTMLâ„¢, The Extensible HyperText Markup Language
+    XML (generic), Extensible Markup Language
+    XSLâ„¢,  Extensible Stylesheet Language
+
+    ACSSâ„¢, Aural Cascading Style Sheets
+    DSigâ„¢, Digital Signature Initiative
+    JEPIâ„¢, Joint Electronic Payment Initiative
+    Jigsawâ„¢
+    PICSRulesâ„¢
+    WebFontsâ„¢
+
+The absence of a product or service name or logo from this list does not
+constitute a waiver of MIT's, INRIA's, or Keio's trademark or other intellectual
+rights concerning that name or logo.
+
+Any questions concerning the use, status, or standing of W3C trademarks should
+be directed to: site-policy@w3.org or to W3C (c/o Joseph Reagle), Laboratory
+for Computer Science NE43-358, Massachusetts Institute of Technology, 200
+Technology Square, Cambridge, MA 02139.
+
+Non-W3C Trademarks; Member Trademarks
+
+The trademarks, logos, and service marks not owned on behalf of the W3C and
+that are displayed on the Site are the registered and unregistered marks of
+their respective owners. No rights are granted by the W3C to use such marks,
+whether by implication, estoppel, or otherwise.
+
+"METADATA" is a trademark of the Metadata Company. W3C uses the term "metadata"
+in a descriptive sense, meaning "data about data". W3C is not in any way
+affiliated with the Metadata Company.
+Legal Disclaimers
+
+6. W3C has not reviewed any or all of the web sites linked to this Site and is
+not responsible for the content of any off-site pages or any other web sites
+linked to this Site. Please understand that any non-W3C web site is independent
+from W3C, and W3C has no control over the content on that web site.
+In addition, a link to a non-W3C web site does not mean that W3C endorses or
+accepts any responsibility for the content, or the use, of such site. It is
+the user's responsibility to take precautions to ensure that whatever is
+selected is free of such items as viruses, worms, Trojan horses and other
+items of a destructive nature.
+
+7. Information W3C publishes on its Site may contain references or cross
+references to W3C specifications, projects, programs and services that are
+not announced or available in your country. Such references do not imply that
+W3C intends to announce such specifications, projects, programs or services
+in your country.
+
+8. Information on this Site may contain technical inaccuracies or typographical
+errors. Information may be changed or updated without notice. W3C may make
+improvements and/or changes in the materials contained in or described on this
+site at any time without notice. W3C may also make changes in these Terms and
+Conditions without notice. User is bound by such revisions and should therefore
+periodically visit this page to review the then current Terms and Conditions.
+
+9. Limitation on Warranties.
+
+ALL MATERIALS ON THE W3C SITE ARE PROVIDED "AS IS." W3C, MIT, INRIA, AND KEIO
+MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT
+LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
+TITLE OR NON-INFRINGEMENT. AS TO DOCUMENTS AND GRAPHICS PUBLISHED ON THIS SITE,
+W3C, MIT, INRIA, AND KEIO MAKE NO REPRESENTATION OR WARRANTY THAT THE CONTENTS
+OF SUCH DOCUMENT OR GRAPHICS ARE FREE FROM ERROR OR SUITABLE FOR ANY PURPOSE;
+NOR THAT IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY
+PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
+
+Please note that some jurisdictions may not allow the exclusion of implied
+ warranties, so some of the above exclusions may not apply to you.
+
+10. Limitation on Liability.
+
+IN NO EVENT WILL W3C, MIT, INRIA, AND KEIO BE LIABLE TO ANY PARTY FOR ANY
+DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES FOR ANY USE OF THIS SITE,
+OR ON ANY OTHER HYPERLINKED WEB SITE, INCLUDING, WITHOUT LIMITATION, ANY LOST
+PROFITS, BUSINESS INTERRUPTION, LOSS OF PROGRAMS OR OTHER DATA ON YOUR
+INFORMATION HANDLING SYSTEM OR OTHERWISE, EVEN IF W3C, MIT, INRIA, OR KEIO
+IS EXPRESSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+
+
diff --git a/src/java.xml/share/legal/xhtml11.md b/src/java.xml/share/legal/xhtml11.md new file mode 100644 index 0000000000000..b447a5ac9e4f0 --- /dev/null +++ b/src/java.xml/share/legal/xhtml11.md @@ -0,0 +1,68 @@ +## XHTMLâ„¢ 1.1 - Module-based XHTML - Second Edition + +### W3C Document license +
+From: https://www.w3.org/copyright/document-license-2023
+
+Copied 10/15/2024
+
+License
+
+By using and/or copying this document, or the W3C document from which this
+statement is linked, you (the licensee) agree that you have read, understood,
+and will comply with the following terms and conditions:
+
+Permission to copy, and distribute the contents of this document, or the W3C
+document from which this statement is linked, in any medium for any purpose
+and without fee or royalty is hereby granted, provided that you include the
+following on ALL copies of the document, or portions thereof, that you use:
+
+    A link or URL to the original W3C document.
+    The pre-existing copyright notice of the original author, or if it doesn't
+    exist, a notice (hypertext is preferred, but a textual representation is
+    permitted) of the form: "Copyright © [$date-of-document] World Wide Web
+    Consortium. https://www.w3.org/copyright/document-license-2023/"
+    If it exists, the STATUS of the W3C document.
+
+When space permits, inclusion of the full text of this NOTICE should be provided.
+We request that authorship attribution be provided in any software, documents,
+or other items or products that you create pursuant to the implementation of the
+contents of this document, or any portion thereof.
+
+No right to create modifications or derivatives of W3C documents is granted
+pursuant to this license, except as follows: To facilitate implementation of
+the technical specifications set forth in this document, anyone may prepare
+and distribute derivative works and portions of this document in software,
+in supporting materials accompanying software, and in documentation of software,
+PROVIDED that all such works include the notice below. HOWEVER, the publication
+of derivative works of this document for use as a technical specification is
+expressly prohibited.
+
+In addition, "Code Components" —Web IDL in sections clearly marked as Web IDL;
+and W3C-defined markup (HTML, CSS, etc.) and computer programming language code
+clearly marked as code examples— are licensed under the W3C Software License.
+
+The notice is:
+
+"Copyright © 2023 W3C®. This software or document includes material copied from
+or derived from [title and URI of the W3C document]."
+
+Disclaimers §anchor
+
+THIS DOCUMENT IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS
+OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, OR TITLE;
+THAT THE CONTENTS OF THE DOCUMENT ARE SUITABLE FOR ANY PURPOSE; NOR THAT THE
+IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY PATENTS,
+COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
+
+COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE DOCUMENT OR THE PERFORMANCE
+OR IMPLEMENTATION OF THE CONTENTS THEREOF.
+
+The name and trademarks of copyright holders may NOT be used in advertising or
+publicity pertaining to this document or its contents without specific, written
+prior permission. Title to copyright in this document will at all times remain
+with copyright holders.
+
+
diff --git a/src/java.xml/share/legal/xhtml11schema.md b/src/java.xml/share/legal/xhtml11schema.md new file mode 100644 index 0000000000000..c7a2f0efda4f4 --- /dev/null +++ b/src/java.xml/share/legal/xhtml11schema.md @@ -0,0 +1,60 @@ +## XHTML 1.1 XML Schema Definition + +### W3C® SOFTWARE NOTICE AND LICENSE +
+http://www.w3.org/Consortium/Legal/copyright-software-19980720
+
+W3C® SOFTWARE NOTICE AND LICENSE
+
+Copyright © 1994-2002 World Wide Web Consortium, (Massachusetts Institute of
+Technology, Institut National de Recherche en Informatique et en Automatique,
+Keio University). All Rights Reserved. http://www.w3.org/Consortium/Legal/
+
+This W3C work (including software, documents, or other related items) is
+being provided by the copyright holders under the following license. By
+obtaining, using and/or copying this work, you (the licensee) agree that you
+have read, understood, and will comply with the following terms and conditions:
+Permission to use, copy, modify, and distribute this software and its
+documentation, with or without modification,  for any purpose and without fee
+or royalty is hereby granted, provided that you include the following on ALL
+copies of the software and documentation or portions thereof, including
+modifications, that you make:
+
+1.      The full text of this NOTICE in a location viewable to users of the
+redistributed or derivative work.
+
+2.      Any pre-existing intellectual property disclaimers, notices, or terms
+and conditions. If none exist, a short notice of the following form (hypertext
+is preferred, text is permitted) should be used within the body of any
+redistributed or derivative code: "Copyright © [$date-of-software] World Wide
+Web Consortium, (Massachusetts Institute of Technology, Institut National de
+Recherche en Informatique et en Automatique, Keio University). All Rights
+Reserved. http://www.w3.org/Consortium/Legal/"
+
+3.      Notice of any changes or modifications to the W3C files, including the
+date changes were made. (We recommend you provide URIs to the location from
+which the code is derived.)
+
+THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE
+NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
+TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT
+THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY
+PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
+COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
+
+The name and trademarks of copyright holders may NOT be used in advertising or
+publicity pertaining to the software without specific, written prior permission.
+Title to copyright in this software and any associated documentation will at all
+times remain with copyright holders.
+
+The formulation of W3C's notice and license became active on August 14 1998 so
+as to improve compatibility with GPL. This version ensures that W3C software
+licensing terms are no more restrictive than GPL and consequently W3C software
+may be distributed in GPL packages. See the older formulation for the policy
+prior to this date. Please see our Copyright FAQ for common questions about
+using materials from our site, including specific terms and conditions for
+packages like libwww, Amaya, and Jigsaw. Other questions about this notice can
+be directed to site-policy@w3.org.
+
+
diff --git a/src/java.xml/share/legal/xmlspec.md b/src/java.xml/share/legal/xmlspec.md new file mode 100644 index 0000000000000..bfb7d4f6ed380 --- /dev/null +++ b/src/java.xml/share/legal/xmlspec.md @@ -0,0 +1,63 @@ +## XML DTD for W3C specifications + +### W3C Software Notice and License +
+W3C(R) SOFTWARE NOTICE AND LICENSE
+
+Copyright (c) 1994-2002 World Wide Web Consortium, (Massachusetts
+Institute of Technology, Institut National de Recherche en
+Informatique et en Automatique, Keio University). All Rights
+Reserved. http://www.w3.org/Consortium/Legal/
+
+This W3C work (including software, documents, or other related items)
+is being provided by the copyright holders under the following
+license. By obtaining, using and/or copying this work, you (the
+licensee) agree that you have read, understood, and will comply with
+the following terms and conditions:
+
+Permission to use, copy, modify, and distribute this software and its
+documentation, with or without modification, for any purpose and
+without fee or royalty is hereby granted, provided that you include
+the following on ALL copies of the software and documentation or
+portions thereof, including modifications, that you make:
+
+    The full text of this NOTICE in a location viewable to users of
+    the redistributed or derivative work.
+
+    Any pre-existing intellectual property disclaimers, notices, or
+    terms and conditions. If none exist, a short notice of the following
+    form (hypertext is preferred, text is permitted) should be used within
+    the body of any redistributed or derivative code: "Copyright (C)
+    [$date-of-software] World Wide Web Consortium, (Massachusetts
+    Institute of Technology, Institut National de Recherche en
+    Informatique et en Automatique, Keio University). All Rights
+    Reserved. http://www.w3.org/Consortium/Legal/"
+
+    Notice of any changes or modifications to the W3C files, including
+    the date changes were made. (We recommend you provide URIs to the
+    location from which the code is derived.)
+
+THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT
+HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED,
+INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS
+FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR
+DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
+TRADEMARKS OR OTHER RIGHTS.
+
+COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL
+OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR
+DOCUMENTATION.
+
+The name and trademarks of copyright holders may NOT be used in
+advertising or publicity pertaining to the software without specific,
+written prior permission. Title to copyright in this software and any
+associated documentation will at all times remain with copyright
+holders.
+
+----------
+
+COPYRIGHT:
+
+  Copyright (C) 2000, 2001, 2002, 2003 Sun Microsystems, Inc. All Rights Reserved.
+
+
diff --git a/src/java.xml/share/legal/xmlxsd.md b/src/java.xml/share/legal/xmlxsd.md new file mode 100644 index 0000000000000..163e26e9f7725 --- /dev/null +++ b/src/java.xml/share/legal/xmlxsd.md @@ -0,0 +1,43 @@ +## The "xml:" Namespace + +### W3C Software and Document license +
+From: https://www.w3.org/copyright/software-license-2023/
+Copied on 2024/10/15
+
+License
+
+By obtaining and/or copying this work, you (the licensee) agree that you have
+read, understood, and will comply with the following terms and conditions.
+
+Permission to copy, modify, and distribute this work, with or without modification,
+for any purpose and without fee or royalty is hereby granted, provided that you
+include the following on ALL copies of the work or portions thereof, including
+modifications:
+
+    The full text of this NOTICE in a location viewable to users of the
+    redistributed or derivative work.
+    Any pre-existing intellectual property disclaimers, notices, or terms and
+    conditions. If none exist, the W3C software and document short notice should
+    be included.
+    Notice of any changes or modifications, through a copyright statement on the
+    new code or document such as "This software or document includes material
+    copied from or derived from [title and URI of the W3C document]. Copyright ©
+    [$year-of-document] World Wide Web Consortium.
+    https://www.w3.org/copyright/software-license-2023/"
+
+Disclaimers §anchor
+
+THIS WORK IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF
+MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE
+SOFTWARE OR DOCUMENT WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
+TRADEMARKS OR OTHER RIGHTS.
+
+COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENT.
+
+The name and trademarks of copyright holders may NOT be used in advertising or
+publicity pertaining to the work without specific, written prior permission.
+Title to copyright in this work will at all times remain with copyright holders.
+
diff --git a/test/jaxp/javax/xml/jaxp/unittest/catalog/CatalogSupport2.java b/test/jaxp/javax/xml/jaxp/unittest/catalog/CatalogSupport2.java index 5bd748c3d870f..ecb88de193283 100644 --- a/test/jaxp/javax/xml/jaxp/unittest/catalog/CatalogSupport2.java +++ b/test/jaxp/javax/xml/jaxp/unittest/catalog/CatalogSupport2.java @@ -51,7 +51,7 @@ /* * @test - * @bug 8158084 8162438 8162442 8163535 8166220 + * @bug 8158084 8162438 8162442 8163535 8166220 8344800 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest * @run testng/othervm catalog.CatalogSupport2 * @summary extends CatalogSupport tests, verifies that the use of the Catalog may @@ -234,7 +234,7 @@ public Object[][] getDataSchemaC() { return new Object[][]{ // for resolving DTD in xsd - {false, true, xml_catalog, xsd_xmlSchema, null}, + {false, true, xml_catalog, xsd_val_test_dtd, null}, // for resolving xsd import {false, true, xml_catalog, xsd_xmlSchema_import, null}, // for resolving xsd include diff --git a/test/jaxp/javax/xml/jaxp/unittest/catalog/CatalogSupport3.java b/test/jaxp/javax/xml/jaxp/unittest/catalog/CatalogSupport3.java index 0b2c019869994..4d44ce80fe644 100644 --- a/test/jaxp/javax/xml/jaxp/unittest/catalog/CatalogSupport3.java +++ b/test/jaxp/javax/xml/jaxp/unittest/catalog/CatalogSupport3.java @@ -51,7 +51,7 @@ /* * @test - * @bug 8158084 8162438 8162442 8163535 8166220 + * @bug 8158084 8162438 8162442 8163535 8166220 8344800 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest * @run testng/othervm catalog.CatalogSupport3 * @summary extends CatalogSupport tests, verifies that the use of the Catalog may @@ -236,7 +236,7 @@ public Object[][] getDataSchemaC() { return new Object[][]{ // for resolving DTD in xsd - {true, false, xml_catalog, xsd_xmlSchema, null}, + {true, false, xml_catalog, xsd_val_test_dtd, null}, // for resolving xsd import {true, false, xml_catalog, xsd_xmlSchema_import, null}, // for resolving xsd include diff --git a/test/jaxp/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java b/test/jaxp/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java index e22c1edf6c295..faa260b275e04 100644 --- a/test/jaxp/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java +++ b/test/jaxp/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, 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 @@ -126,7 +126,7 @@ protected void setUp() { // For the xsd import and include String xsd_xmlSchema, dtd_xmlSchema, dtd_datatypes; String xsd_xmlSchema_import, xsd_xml; - String xml_val_test, xml_val_test_id, xsd_val_test; + String xml_val_test, xml_val_test_id, xsd_val_test, xsd_val_test_dtd; String xsd_include_company, xsd_include_person, xsd_include_product; String xsl_include, xsl_includeDTD, xsl_import_html, xsl_include_header, xsl_include_footer; @@ -254,6 +254,7 @@ void initFiles() { xml_val_test = filepath + "/val_test.xml"; xml_val_test_id = "file://" + slash + xml_val_test; xsd_val_test = filepath + "/val_test.xsd"; + xsd_val_test_dtd = Paths.get(filepath + "val_test_dtd.xsd").toUri().toASCIIString(); xml_xsl = "\n" + "\n" + @@ -375,7 +376,11 @@ public void testValidation(boolean setUseCatalog, boolean useCatalog, String cat factory.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), catalog); } - Schema schema = factory.newSchema(new StreamSource(new StringReader(xsd))); + if (xsd.endsWith(".xsd")) { + Schema schema = factory.newSchema(new StreamSource(xsd)); + } else { + Schema schema = factory.newSchema(new StreamSource(new StringReader(xsd))); + } success("XMLSchema.dtd and datatypes.dtd are resolved."); } diff --git a/test/jaxp/javax/xml/jaxp/unittest/catalog/val_test_dtd.xsd b/test/jaxp/javax/xml/jaxp/unittest/catalog/val_test_dtd.xsd new file mode 100644 index 0000000000000..1c320079e173e --- /dev/null +++ b/test/jaxp/javax/xml/jaxp/unittest/catalog/val_test_dtd.xsd @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + From 1997e89ddf9fba7c6eea6c96bd0b5426576d4460 Mon Sep 17 00:00:00 2001 From: William Kemper Date: Mon, 2 Dec 2024 22:54:53 +0000 Subject: [PATCH 04/62] 8345346: Shenandoah: Description of ShenandoahGCMode still refers to incremental update mode Reviewed-by: ysr --- src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp b/src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp index 4239fc37a267b..a9c5e47c5c2bd 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp @@ -134,7 +134,6 @@ "GC mode to use. Among other things, this defines which " \ "barriers are in in use. Possible values are:" \ " satb - snapshot-at-the-beginning concurrent GC (three pass mark-evac-update);" \ - " iu - incremental-update concurrent GC (three pass mark-evac-update);" \ " passive - stop the world GC only (either degenerated or full);" \ " generational - generational concurrent GC") \ \ @@ -183,7 +182,7 @@ range(0,100) \ \ product(uintx, ShenandoahInitFreeThreshold, 70, EXPERIMENTAL, \ - "When less than this amount of memory is free within the" \ + "When less than this amount of memory is free within the " \ "heap or generation, trigger a learning cycle if we are " \ "in learning mode. Learning mode happens during initialization " \ "and following a drastic state change, such as following a " \ From 68b1b94d1be686037e2aaef57c0d9adc594fac7a Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Mon, 2 Dec 2024 22:55:53 +0000 Subject: [PATCH 05/62] 8344904: Interned strings in old classes are not stored in CDS archive Reviewed-by: dholmes, ccheung --- src/hotspot/share/cds/metaspaceShared.cpp | 4 +- src/hotspot/share/oops/constantPool.cpp | 38 +++++++--- src/hotspot/share/oops/constantPool.hpp | 1 + .../OldClassWithStaticString.jasm | 49 +++++++++++++ .../sharedStrings/StaticStringInOldClass.java | 72 +++++++++++++++++++ 5 files changed, 153 insertions(+), 11 deletions(-) create mode 100644 test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/OldClassWithStaticString.jasm create mode 100644 test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/StaticStringInOldClass.java diff --git a/src/hotspot/share/cds/metaspaceShared.cpp b/src/hotspot/share/cds/metaspaceShared.cpp index 3ea2f54cfa9fb..3571f11bb6e36 100644 --- a/src/hotspot/share/cds/metaspaceShared.cpp +++ b/src/hotspot/share/cds/metaspaceShared.cpp @@ -1014,9 +1014,7 @@ void VM_PopulateDumpSharedSpace::dump_java_heap_objects(GrowableArray* k Klass* k = klasses->at(i); if (k->is_instance_klass()) { InstanceKlass* ik = InstanceKlass::cast(k); - if (ik->is_linked()) { - ik->constants()->add_dumped_interned_strings(); - } + ik->constants()->add_dumped_interned_strings(); } } if (_extra_interned_strings != nullptr) { diff --git a/src/hotspot/share/oops/constantPool.cpp b/src/hotspot/share/oops/constantPool.cpp index 31644f33797f8..22896d9e00fb1 100644 --- a/src/hotspot/share/oops/constantPool.cpp +++ b/src/hotspot/share/oops/constantPool.cpp @@ -53,6 +53,7 @@ #include "oops/array.hpp" #include "oops/constantPool.inline.hpp" #include "oops/cpCache.inline.hpp" +#include "oops/fieldStreams.inline.hpp" #include "oops/instanceKlass.hpp" #include "oops/klass.inline.hpp" #include "oops/objArrayKlass.hpp" @@ -61,6 +62,7 @@ #include "oops/typeArrayOop.inline.hpp" #include "prims/jvmtiExport.hpp" #include "runtime/atomic.hpp" +#include "runtime/fieldDescriptor.inline.hpp" #include "runtime/handles.inline.hpp" #include "runtime/init.hpp" #include "runtime/javaCalls.hpp" @@ -403,18 +405,38 @@ void ConstantPool::find_required_hidden_classes() { } void ConstantPool::add_dumped_interned_strings() { - objArrayOop rr = resolved_references(); - if (rr != nullptr) { - int rr_len = rr->length(); - for (int i = 0; i < rr_len; i++) { - oop p = rr->obj_at(i); - if (java_lang_String::is_instance(p) && - !ArchiveHeapWriter::is_string_too_large_to_archive(p)) { - HeapShared::add_to_dumped_interned_strings(p); + InstanceKlass* ik = pool_holder(); + if (!ik->is_linked()) { + // resolved_references() doesn't exist yet, so we have no resolved CONSTANT_String entries. However, + // some static final fields may have default values that were initialized when the class was parsed. + // We need to enter those into the CDS archive strings table. + for (JavaFieldStream fs(ik); !fs.done(); fs.next()) { + if (fs.access_flags().is_static()) { + fieldDescriptor& fd = fs.field_descriptor(); + if (fd.field_type() == T_OBJECT) { + int offset = fd.offset(); + check_and_add_dumped_interned_string(ik->java_mirror()->obj_field(offset)); + } + } + } + } else { + objArrayOop rr = resolved_references(); + if (rr != nullptr) { + int rr_len = rr->length(); + for (int i = 0; i < rr_len; i++) { + check_and_add_dumped_interned_string(rr->obj_at(i)); } } } } + +void ConstantPool::check_and_add_dumped_interned_string(oop obj) { + if (obj != nullptr && java_lang_String::is_instance(obj) && + !ArchiveHeapWriter::is_string_too_large_to_archive(obj)) { + HeapShared::add_to_dumped_interned_strings(obj); + } +} + #endif #if INCLUDE_CDS diff --git a/src/hotspot/share/oops/constantPool.hpp b/src/hotspot/share/oops/constantPool.hpp index 9ada3e29d49b0..935151c7cda7d 100644 --- a/src/hotspot/share/oops/constantPool.hpp +++ b/src/hotspot/share/oops/constantPool.hpp @@ -162,6 +162,7 @@ class ConstantPool : public Metadata { assert(is_within_bounds(cp_index), "index out of bounds"); return (jdouble*) &base()[cp_index]; } + static void check_and_add_dumped_interned_string(oop obj); ConstantPool(Array* tags); ConstantPool(); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/OldClassWithStaticString.jasm b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/OldClassWithStaticString.jasm new file mode 100644 index 0000000000000..d36f0e1d21245 --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/OldClassWithStaticString.jasm @@ -0,0 +1,49 @@ +/* + * Copyright (c) 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. + * + */ + +/* + +// Compiled from this source, but we want the version to be 49.0 to use the old verifier. + +class OldClassWithStaticString { + static final String s = "xxxx123yyyy456"; + static final String t = "OldClassWithStaticString"; +} + +*/ + +public super class OldClassWithStaticString + version 49:0 +{ + public static final Field s:"Ljava/lang/String;" = String "xxxx123yyyy456"; + public static final Field t:"Ljava/lang/String;" = String "OldClassWithStaticString"; + + Method "":"()V" + stack 1 locals 1 + { + aload_0; + invokespecial Method java/lang/Object."":"()V"; + return; + } +} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/StaticStringInOldClass.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/StaticStringInOldClass.java new file mode 100644 index 0000000000000..f282b0c664dcb --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/StaticStringInOldClass.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 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 8344904 + * @summary make sure all interned strings in old classes are archived. + * @requires vm.cds.write.archived.java.heap + * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds + * @build OldClassWithStaticString + * @build StaticStringInOldClass + * @run driver jdk.test.lib.helpers.ClassFileInstaller + * -jar StaticStringInOldClass.jar StaticStringInOldClass StaticStringInOldClassApp OldClassWithStaticString + * @run driver StaticStringInOldClass + */ + +import java.lang.reflect.Field; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.helpers.ClassFileInstaller; + +public class StaticStringInOldClass { + static final String appClass = StaticStringInOldClassApp.class.getName(); + static String[] classes = { + appClass, + OldClassWithStaticString.class.getName(), + }; + + public static void main(String[] args) throws Exception { + String appJar = ClassFileInstaller.getJarPath("StaticStringInOldClass.jar"); + OutputAnalyzer output; + output = TestCommon.testDump(appJar, TestCommon.list(classes)); + output = TestCommon.exec(appJar, appClass); + TestCommon.checkExec(output, "Hello"); + } +} + +class StaticStringInOldClassApp { + static String a = "xxxx123"; + public static void main(String args[]) throws Exception { + System.out.println("Hello"); + String x = (a + "yyyy456").intern(); + Class c = OldClassWithStaticString.class; + Field f = c.getField("s"); + String y = (String)(f.get(null)); + if (x != y) { + throw new RuntimeException("Interned strings not equal: " + + "\"" + x + "\" @ " + System.identityHashCode(x) + " vs " + + "\"" + y + "\" @ " + System.identityHashCode(y)); + } + } +} From 5958463cadb04560ec85d9af972255bfe6dcc2f2 Mon Sep 17 00:00:00 2001 From: Chen Liang Date: Mon, 2 Dec 2024 23:49:57 +0000 Subject: [PATCH 06/62] 8343377: Performance regression in reflective invocation of native methods Reviewed-by: mchung --- .../reflect/DirectMethodHandleAccessor.java | 2 +- .../reflect/MethodHandleAccessorFactory.java | 62 +++++++++++---- .../java/lang/reflect/NativeMethodInvoke.java | 79 +++++++++++++++++++ 3 files changed, 126 insertions(+), 17 deletions(-) create mode 100644 test/micro/org/openjdk/bench/java/lang/reflect/NativeMethodInvoke.java diff --git a/src/java.base/share/classes/jdk/internal/reflect/DirectMethodHandleAccessor.java b/src/java.base/share/classes/jdk/internal/reflect/DirectMethodHandleAccessor.java index 54f0c7c563d47..e6c5aa5db2edd 100644 --- a/src/java.base/share/classes/jdk/internal/reflect/DirectMethodHandleAccessor.java +++ b/src/java.base/share/classes/jdk/internal/reflect/DirectMethodHandleAccessor.java @@ -47,7 +47,7 @@ class DirectMethodHandleAccessor extends MethodAccessorImpl { * Creates a MethodAccessorImpl for a non-native method. */ static MethodAccessorImpl methodAccessor(Method method, MethodHandle target) { - assert !Modifier.isNative(method.getModifiers()); + assert !MethodHandleAccessorFactory.isSignaturePolymorphicMethod(method); return new DirectMethodHandleAccessor(method, target, false); } diff --git a/src/java.base/share/classes/jdk/internal/reflect/MethodHandleAccessorFactory.java b/src/java.base/share/classes/jdk/internal/reflect/MethodHandleAccessorFactory.java index 3a367272315e1..93a208662d572 100644 --- a/src/java.base/share/classes/jdk/internal/reflect/MethodHandleAccessorFactory.java +++ b/src/java.base/share/classes/jdk/internal/reflect/MethodHandleAccessorFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 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 @@ -28,6 +28,7 @@ import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; +import java.lang.invoke.VarHandle; import java.lang.reflect.Constructor; import java.lang.reflect.Executable; import java.lang.reflect.Field; @@ -209,7 +210,7 @@ static FieldAccessorImpl newFieldAccessor(Field field, boolean isReadOnly) { } private static MethodHandle getDirectMethod(Method method, boolean callerSensitive) throws IllegalAccessException { - var mtype = methodType(method.getReturnType(), method.getParameterTypes()); + var mtype = methodType(method.getReturnType(), reflectionFactory.getExecutableSharedParameterTypes(method)); var isStatic = Modifier.isStatic(method.getModifiers()); var dmh = isStatic ? JLIA.findStatic(method.getDeclaringClass(), method.getName(), mtype) : JLIA.findVirtual(method.getDeclaringClass(), method.getName(), mtype); @@ -231,7 +232,7 @@ private static MethodHandle getDirectMethod(Method method, boolean callerSensiti private static MethodHandle findCallerSensitiveAdapter(Method method) throws IllegalAccessException { String name = method.getName(); // append a Class parameter - MethodType mtype = methodType(method.getReturnType(), method.getParameterTypes()) + MethodType mtype = methodType(method.getReturnType(), reflectionFactory.getExecutableSharedParameterTypes(method)) .appendParameterTypes(Class.class); boolean isStatic = Modifier.isStatic(method.getModifiers()); @@ -347,36 +348,39 @@ static void ensureClassInitialized(Class defc) { * Native accessor, i.e. VM reflection implementation, is used if one of * the following conditions is met: * 1. during VM early startup before method handle support is fully initialized - * 2. a Java native method - * 3. -Djdk.reflect.useNativeAccessorOnly=true is set + * 2. -Djdk.reflect.useNativeAccessorOnly=true is set + * 3. a signature polymorphic method * 4. the member takes a variable number of arguments and the last parameter * is not an array (see details below) * 5. the member's method type has an arity >= 255 * + * Conditions 3-5 are due to the restrictions of method handles. * Otherwise, direct invocation of method handles is used. */ private static boolean useNativeAccessor(Executable member) { if (!VM.isJavaLangInvokeInited()) return true; - if (Modifier.isNative(member.getModifiers())) + if (ReflectionFactory.useNativeAccessorOnly()) // for testing only return true; - if (ReflectionFactory.useNativeAccessorOnly()) // for testing only + // java.lang.invoke cannot find the underlying native stubs of signature + // polymorphic methods that core reflection must invoke. + // Fall back to use the native implementation instead. + if (member instanceof Method method && isSignaturePolymorphicMethod(method)) return true; - // MethodHandle::withVarargs on a member with varargs modifier bit set - // verifies that the last parameter of the member must be an array type. - // The JVMS does not require the last parameter descriptor of the method descriptor - // is an array type if the ACC_VARARGS flag is set in the access_flags item. - // Hence the reflection implementation does not check the last parameter type - // if ACC_VARARGS flag is set. Workaround this by invoking through - // the native accessor. + // For members with ACC_VARARGS bit set, MethodHandles produced by lookup + // always have variable arity set and hence the last parameter of the member + // must be an array type. Such restriction does not exist in core reflection + // and the JVM, which always use fixed-arity invocations. Fall back to use + // the native implementation instead. int paramCount = member.getParameterCount(); if (member.isVarArgs() && - (paramCount == 0 || !(member.getParameterTypes()[paramCount-1].isArray()))) { + (paramCount == 0 || !(reflectionFactory.getExecutableSharedParameterTypes(member)[paramCount-1].isArray()))) { return true; } + // A method handle cannot be created if its type has an arity >= 255 // as the method handle's invoke method consumes an extra argument // of the method handle itself. Fall back to use the native implementation. @@ -396,7 +400,7 @@ private static boolean useNativeAccessor(Executable member) { */ private static int slotCount(Executable member) { int slots = 0; - Class[] ptypes = member.getParameterTypes(); + Class[] ptypes = reflectionFactory.getExecutableSharedParameterTypes(member); for (Class ptype : ptypes) { if (ptype == double.class || ptype == long.class) { slots++; @@ -406,6 +410,31 @@ private static int slotCount(Executable member) { (Modifier.isStatic(member.getModifiers()) ? 0 : 1); } + /** + * Signature-polymorphic methods. Lookup has special rules for these methods, + * but core reflection must observe them as they are declared, and reflective + * invocation must invoke the native method stubs that throw UOE. + * + * @param method the method to check + * @return {@code true} if this method is signature polymorphic + * @jls 15.12.3 Compile-Time Step 3: Is the Chosen Method Appropriate? + * @jvms 2.9.3 Signature Polymorphic Methods + */ + public static boolean isSignaturePolymorphicMethod(Method method) { + // ACC_NATIVE and ACC_VARARGS + if (!method.isVarArgs() || !Modifier.isNative(method.getModifiers())) { + return false; + } + // Declared in MethodHandle or VarHandle + var declaringClass = method.getDeclaringClass(); + if (declaringClass != MethodHandle.class && declaringClass != VarHandle.class) { + return false; + } + // Single parameter of declared type Object[] + Class[] parameters = reflectionFactory.getExecutableSharedParameterTypes(method); + return parameters.length == 1 && parameters[0] == Object[].class; + } + /* * Delay initializing these static fields until java.lang.invoke is fully initialized. */ @@ -414,4 +443,5 @@ static class LazyStaticHolder { } private static final Unsafe UNSAFE = Unsafe.getUnsafe(); + private static final ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory(); } diff --git a/test/micro/org/openjdk/bench/java/lang/reflect/NativeMethodInvoke.java b/test/micro/org/openjdk/bench/java/lang/reflect/NativeMethodInvoke.java new file mode 100644 index 0000000000000..b48cef5803741 --- /dev/null +++ b/test/micro/org/openjdk/bench/java/lang/reflect/NativeMethodInvoke.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 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. + */ +package org.openjdk.bench.java.lang.reflect; + +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.Warmup; +import org.openjdk.jmh.infra.Blackhole; + +import java.lang.reflect.Method; +import java.util.concurrent.TimeUnit; + +/** + * Benchmark for regression in native method invocation. + */ +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@State(Scope.Thread) +@Warmup(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 5, time = 2, timeUnit = TimeUnit.SECONDS) +@Fork(3) +public class NativeMethodInvoke { + + private Method objectHashCode; + private Method threadCurrentThread; + + private Object[] objects; + + @Setup + public void setup() throws ReflectiveOperationException { + objects = new Object[]{ + 1, 5L, + 5.6d, 23.11f, + Boolean.TRUE, 'd' + }; + + objectHashCode = Object.class.getDeclaredMethod("hashCode"); + threadCurrentThread = Thread.class.getDeclaredMethod("currentThread"); + } + + @Benchmark + public void objectHashCode(Blackhole bh) throws ReflectiveOperationException { + for (var obj : objects) { + bh.consume(objectHashCode.invoke(obj)); + } + } + + @Benchmark + public Object threadCurrentThread() throws ReflectiveOperationException { + return threadCurrentThread.invoke(null); + } +} From 3f6c04247ff6ad69330bc219ed26944852954e85 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Tue, 3 Dec 2024 00:12:50 +0000 Subject: [PATCH 07/62] 8345143: Remove uses of SecurityManager in the java.desktop module Reviewed-by: azvegint, honkar --- .../classes/com/apple/eio/FileManager.java | 33 ------------------- .../com/sun/beans/finder/ClassFinder.java | 4 +-- .../com/sun/beans/introspect/ClassInfo.java | 6 +--- .../com/sun/java/swing/plaf/gtk/GTKStyle.java | 1 - .../com/sun/media/sound/AudioSynthesizer.java | 4 --- .../com/sun/media/sound/SoftSynthesizer.java | 7 ++-- .../share/classes/java/awt/Font.java | 23 ++----------- .../share/classes/java/awt/Window.java | 17 +++------- .../share/classes/java/beans/Beans.java | 17 +--------- .../classes/java/beans/Introspector.java | 5 --- .../java/beans/PropertyEditorManager.java | 10 ------ .../javax/imageio/spi/IIORegistry.java | 19 ++--------- .../classes/javax/sound/midi/Synthesizer.java | 4 +-- .../javax/swing/DefaultListCellRenderer.java | 17 +++------- .../classes/javax/swing/FocusManager.java | 4 --- .../share/classes/javax/swing/JFrame.java | 7 ---- .../classes/javax/swing/JInternalFrame.java | 8 ++--- .../share/classes/javax/swing/JTable.java | 5 --- .../share/classes/javax/swing/Popup.java | 10 +----- .../share/classes/javax/swing/TimerQueue.java | 1 - .../share/classes/javax/swing/UIDefaults.java | 2 -- .../plaf/basic/BasicComboBoxRenderer.java | 8 +---- .../javax/swing/plaf/basic/BasicLabelUI.java | 12 ------- .../javax/swing/plaf/metal/MetalLabelUI.java | 13 -------- .../javax/swing/plaf/metal/MetalSliderUI.java | 23 +++---------- .../swing/table/DefaultTableCellRenderer.java | 7 +--- .../javax/swing/text/DefaultCaret.java | 2 -- .../javax/swing/text/DefaultFormatter.java | 2 -- .../javax/swing/text/NumberFormatter.java | 2 -- .../share/classes/sun/awt/OSInfo.java | 4 +-- .../share/classes/sun/awt/SunToolkit.java | 11 ------- .../sun/awt/util/PerformanceLogger.java | 4 +-- .../classes/sun/swing/SwingUtilities2.java | 14 -------- test/jdk/lib/client/ExtendedRobot.java | 5 --- 34 files changed, 33 insertions(+), 278 deletions(-) diff --git a/src/java.desktop/macosx/classes/com/apple/eio/FileManager.java b/src/java.desktop/macosx/classes/com/apple/eio/FileManager.java index 2f847416d216b..7ace8d90c7c2a 100644 --- a/src/java.desktop/macosx/classes/com/apple/eio/FileManager.java +++ b/src/java.desktop/macosx/classes/com/apple/eio/FileManager.java @@ -130,11 +130,6 @@ public static int OSTypeToInt(String type) { * @since 1.4 */ public static void setFileTypeAndCreator(String filename, int type, int creator) throws IOException { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkWrite(filename); - } _setFileTypeAndCreator(filename, type, creator); } private static native void _setFileTypeAndCreator(String filename, int type, int creator) throws IOException; @@ -145,11 +140,6 @@ public static void setFileTypeAndCreator(String filename, int type, int creator) * @since 1.4 */ public static void setFileType(String filename, int type) throws IOException { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkWrite(filename); - } _setFileType(filename, type); } private static native void _setFileType(String filename, int type) throws IOException; @@ -160,11 +150,6 @@ public static void setFileType(String filename, int type) throws IOException { * @since 1.4 */ public static void setFileCreator(String filename, int creator) throws IOException { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkWrite(filename); - } _setFileCreator(filename, creator); } private static native void _setFileCreator(String filename, int creator) throws IOException; @@ -175,11 +160,6 @@ public static void setFileCreator(String filename, int creator) throws IOExcepti * @since 1.4 */ public static int getFileType(String filename) throws IOException { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkRead(filename); - } return _getFileType(filename); } private static native int _getFileType(String filename) throws IOException; @@ -190,11 +170,6 @@ public static int getFileType(String filename) throws IOException { * @since 1.4 */ public static int getFileCreator(String filename) throws IOException { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkRead(filename); - } return _getFileCreator(filename); } private static native int _getFileCreator(String filename) throws IOException; @@ -358,10 +333,6 @@ public static boolean moveToTrash(final File file) throws FileNotFoundException if (file == null) throw new FileNotFoundException(); final String fileName = file.getAbsolutePath(); - @SuppressWarnings("removal") - final SecurityManager security = System.getSecurityManager(); - if (security != null) security.checkDelete(fileName); - return _moveToTrash(fileName); } @@ -382,10 +353,6 @@ public static boolean revealInFinder(final File file) throws FileNotFoundExcepti if (file == null || !file.exists()) throw new FileNotFoundException(); final String fileName = file.getAbsolutePath(); - @SuppressWarnings("removal") - final SecurityManager security = System.getSecurityManager(); - if (security != null) security.checkRead(fileName); - return _revealInFinder(fileName); } diff --git a/src/java.desktop/share/classes/com/sun/beans/finder/ClassFinder.java b/src/java.desktop/share/classes/com/sun/beans/finder/ClassFinder.java index cdd022fcaf783..a8299458757e8 100644 --- a/src/java.desktop/share/classes/com/sun/beans/finder/ClassFinder.java +++ b/src/java.desktop/share/classes/com/sun/beans/finder/ClassFinder.java @@ -64,7 +64,7 @@ public static Class findClass(String name) throws ClassNotFoundException { return Class.forName(name, false, loader); } - } catch (ClassNotFoundException | SecurityException exception) { + } catch (ClassNotFoundException exception) { // use current class loader instead } return Class.forName(name); @@ -95,7 +95,7 @@ public static Class findClass(String name, ClassLoader loader) throws ClassNo if (loader != null) { try { return Class.forName(name, false, loader); - } catch (ClassNotFoundException | SecurityException exception) { + } catch (ClassNotFoundException exception) { // use default class loader instead } } diff --git a/src/java.desktop/share/classes/com/sun/beans/introspect/ClassInfo.java b/src/java.desktop/share/classes/com/sun/beans/introspect/ClassInfo.java index dce0469c7c9f3..6578011ccca73 100644 --- a/src/java.desktop/share/classes/com/sun/beans/introspect/ClassInfo.java +++ b/src/java.desktop/share/classes/com/sun/beans/introspect/ClassInfo.java @@ -45,11 +45,7 @@ public static ClassInfo get(Class type) { if (type == null) { return DEFAULT; } - try { - return CACHE.get(type); - } catch (SecurityException exception) { - return DEFAULT; - } + return CACHE.get(type); } public static void clear() { diff --git a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java index b9c2ce914d4ae..cc7a1333b643b 100644 --- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java +++ b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java @@ -27,7 +27,6 @@ import java.awt.*; import java.lang.reflect.*; -import java.security.*; import java.util.*; import javax.swing.*; import javax.swing.plaf.*; diff --git a/src/java.desktop/share/classes/com/sun/media/sound/AudioSynthesizer.java b/src/java.desktop/share/classes/com/sun/media/sound/AudioSynthesizer.java index 4f01291c22d2a..b0afee9871a41 100644 --- a/src/java.desktop/share/classes/com/sun/media/sound/AudioSynthesizer.java +++ b/src/java.desktop/share/classes/com/sun/media/sound/AudioSynthesizer.java @@ -89,8 +89,6 @@ public interface AudioSynthesizer extends Synthesizer { * * @throws MidiUnavailableException thrown if the synthesizer cannot be * opened due to resource restrictions. - * @throws SecurityException thrown if the synthesizer cannot be - * opened due to security restrictions. * * @see #close * @see #isOpen @@ -119,8 +117,6 @@ void open(SourceDataLine line, Map info) * * @throws MidiUnavailableException thrown if the synthesizer cannot be * opened due to resource restrictions. - * @throws SecurityException thrown if the synthesizer cannot be - * opened due to security restrictions. * * @see #close * @see #isOpen diff --git a/src/java.desktop/share/classes/com/sun/media/sound/SoftSynthesizer.java b/src/java.desktop/share/classes/com/sun/media/sound/SoftSynthesizer.java index 4c33416e4709a..6aaddb3e484c9 100644 --- a/src/java.desktop/share/classes/com/sun/media/sound/SoftSynthesizer.java +++ b/src/java.desktop/share/classes/com/sun/media/sound/SoftSynthesizer.java @@ -1111,7 +1111,7 @@ public void open(SourceDataLine line, Map info) throws MidiUnava line = testline; } else { // can throw LineUnavailableException, - // IllegalArgumentException, SecurityException + // IllegalArgumentException line = AudioSystem.getSourceDataLine(getFormat()); } } @@ -1122,7 +1122,7 @@ public void open(SourceDataLine line, Map info) throws MidiUnava int bufferSize = getFormat().getFrameSize() * (int)(getFormat().getFrameRate() * (latency/1000000f)); // can throw LineUnavailableException, - // IllegalArgumentException, SecurityException + // IllegalArgumentException line.open(getFormat(), bufferSize); // Remember that we opened that line @@ -1166,8 +1166,7 @@ public void open(SourceDataLine line, Map info) throws MidiUnava weakstream.sourceDataLine = sourceDataLine; } - } catch (final LineUnavailableException | SecurityException - | IllegalArgumentException e) { + } catch (final LineUnavailableException | IllegalArgumentException e) { if (isOpen()) { close(); } diff --git a/src/java.desktop/share/classes/java/awt/Font.java b/src/java.desktop/share/classes/java/awt/Font.java index 4de614737077e..bbd6ee83e51b7 100644 --- a/src/java.desktop/share/classes/java/awt/Font.java +++ b/src/java.desktop/share/classes/java/awt/Font.java @@ -893,23 +893,8 @@ public static Font getFont(Map attributes) { * If a thread can create temp files anyway, no point in counting * font bytes. */ - @SuppressWarnings("removal") private static boolean hasTempPermission() { - - if (System.getSecurityManager() == null) { - return true; - } - File f = null; - boolean hasPerm = false; - try { - f = Files.createTempFile("+~JT", ".tmp").toFile(); - f.delete(); - f = null; - hasPerm = true; - } catch (Throwable t) { - /* inc. any kind of SecurityException */ - } - return hasPerm; + return true; } @@ -1757,11 +1742,7 @@ public static Font decode(String str) { * @see #decode(String) */ public static Font getFont(String nm, Font font) { - String str = null; - try { - str =System.getProperty(nm); - } catch(SecurityException e) { - } + String str = System.getProperty(nm); if (str == null) { return font; } diff --git a/src/java.desktop/share/classes/java/awt/Window.java b/src/java.desktop/share/classes/java/awt/Window.java index 9d12b0cd3c0f0..4e576f3dc9ea9 100644 --- a/src/java.desktop/share/classes/java/awt/Window.java +++ b/src/java.desktop/share/classes/java/awt/Window.java @@ -598,10 +598,7 @@ private void ownedInit(Window owner) { if (owner != null) { owner.addOwnedWindow(weakThis); if (owner.isAlwaysOnTop()) { - try { - setAlwaysOnTop(true); - } catch (SecurityException ignore) { - } + setAlwaysOnTop(true); } } @@ -1305,10 +1302,7 @@ public void toBack() { // to insure that it cannot be overridden by client subclasses. final void toBack_NoClientCode() { if(isAlwaysOnTop()) { - try { - setAlwaysOnTop(false); - }catch(SecurityException e) { - } + setAlwaysOnTop(false); } if (visible) { WindowPeer peer = (WindowPeer)this.peer; @@ -2191,10 +2185,7 @@ private void setOwnedWindowsAlwaysOnTop(boolean alwaysOnTop) { for (WeakReference ref : ownedWindowArray) { Window window = ref.get(); if (window != null) { - try { - window.setAlwaysOnTop(alwaysOnTop); - } catch (SecurityException ignore) { - } + window.setAlwaysOnTop(alwaysOnTop); } } } @@ -3032,7 +3023,7 @@ private void readObject(ObjectInputStream s) setModalExclusionType(et); // since 6.0 boolean aot = f.get("alwaysOnTop", false); if(aot) { - setAlwaysOnTop(aot); // since 1.5; subject to permission check + setAlwaysOnTop(aot); } shape = (Shape)f.get("shape", null); opacity = (Float)f.get("opacity", 1.0f); diff --git a/src/java.desktop/share/classes/java/beans/Beans.java b/src/java.desktop/share/classes/java/beans/Beans.java index e35a751a42ef3..5320d12ecd2a3 100644 --- a/src/java.desktop/share/classes/java/beans/Beans.java +++ b/src/java.desktop/share/classes/java/beans/Beans.java @@ -189,12 +189,7 @@ public static Object instantiate(ClassLoader cls, String beanName, // Note that calls on the system class loader will // look in the bootstrap class loader first. if (cls == null) { - try { - cls = ClassLoader.getSystemClassLoader(); - } catch (SecurityException ex) { - // We're not allowed to access the system class loader. - // Drop through. - } + cls = ClassLoader.getSystemClassLoader(); } // Try to find a serialized object with this name @@ -438,11 +433,6 @@ public static boolean isGuiAvailable() { */ public static void setDesignTime(boolean isDesignTime) { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPropertiesAccess(); - } ThreadGroupContext.getContext().setDesignTime(isDesignTime); } @@ -454,11 +444,6 @@ public static void setDesignTime(boolean isDesignTime) { */ public static void setGuiAvailable(boolean isGuiAvailable) { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPropertiesAccess(); - } ThreadGroupContext.getContext().setGuiAvailable(isGuiAvailable); } } diff --git a/src/java.desktop/share/classes/java/beans/Introspector.java b/src/java.desktop/share/classes/java/beans/Introspector.java index 7dfd2e60a8e47..c526190808e1e 100644 --- a/src/java.desktop/share/classes/java/beans/Introspector.java +++ b/src/java.desktop/share/classes/java/beans/Introspector.java @@ -335,11 +335,6 @@ public static String[] getBeanInfoSearchPath() { */ public static void setBeanInfoSearchPath(String[] path) { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPropertiesAccess(); - } ThreadGroupContext.getContext().getBeanInfoFinder().setPackages(path); } diff --git a/src/java.desktop/share/classes/java/beans/PropertyEditorManager.java b/src/java.desktop/share/classes/java/beans/PropertyEditorManager.java index d6cb76e058c74..b776e3f3615cd 100644 --- a/src/java.desktop/share/classes/java/beans/PropertyEditorManager.java +++ b/src/java.desktop/share/classes/java/beans/PropertyEditorManager.java @@ -71,11 +71,6 @@ public PropertyEditorManager() {} * @param editorClass the class object of the editor class */ public static void registerEditor(Class targetType, Class editorClass) { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPropertiesAccess(); - } ThreadGroupContext.getContext().getPropertyEditorFinder().register(targetType, editorClass); } @@ -109,11 +104,6 @@ public static String[] getEditorSearchPath() { * @param path Array of package names. */ public static void setEditorSearchPath(String[] path) { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPropertiesAccess(); - } ThreadGroupContext.getContext().getPropertyEditorFinder().setPackages(path); } } diff --git a/src/java.desktop/share/classes/javax/imageio/spi/IIORegistry.java b/src/java.desktop/share/classes/javax/imageio/spi/IIORegistry.java index 1ea7146ae4ae3..09fa1eb202b6c 100644 --- a/src/java.desktop/share/classes/javax/imageio/spi/IIORegistry.java +++ b/src/java.desktop/share/classes/javax/imageio/spi/IIORegistry.java @@ -162,7 +162,6 @@ private void registerStandardSpis() { * @see javax.imageio.ImageIO#scanForPlugins * @see ClassLoader#getResources */ - @SuppressWarnings("removal") public void registerApplicationClasspathSpis() { // FIX: load only from application classpath @@ -175,22 +174,8 @@ public void registerApplicationClasspathSpis() { Iterator riter = ServiceLoader.load(c, loader).iterator(); while (riter.hasNext()) { - try { - // Note that the next() call is required to be inside - // the try/catch block; see 6342404. - IIOServiceProvider r = riter.next(); - registerServiceProvider(r); - } catch (ServiceConfigurationError err) { - if (System.getSecurityManager() != null) { - // In the applet case, we will catch the error so - // registration of other plugins can proceed - err.printStackTrace(); - } else { - // In the application case, we will throw the - // error to indicate app/system misconfiguration - throw err; - } - } + IIOServiceProvider r = riter.next(); + registerServiceProvider(r); } } } diff --git a/src/java.desktop/share/classes/javax/sound/midi/Synthesizer.java b/src/java.desktop/share/classes/javax/sound/midi/Synthesizer.java index c353fb7f390a2..055f3f1066b6f 100644 --- a/src/java.desktop/share/classes/javax/sound/midi/Synthesizer.java +++ b/src/java.desktop/share/classes/javax/sound/midi/Synthesizer.java @@ -345,10 +345,8 @@ public interface Synthesizer extends MidiDevice { * * @throws MidiUnavailableException if the receiver is cannot be opened, * usually because the MIDI device is in use by another application - * @throws SecurityException if the receiver cannot be opened due to - * security restrictions */ - // abstract void open() throws MidiUnavailableException, SecurityException; + // abstract void open() throws MidiUnavailableException; /** * Closes the receiver. diff --git a/src/java.desktop/share/classes/javax/swing/DefaultListCellRenderer.java b/src/java.desktop/share/classes/javax/swing/DefaultListCellRenderer.java index a0750a13bfaa2..628c8f6e68c06 100644 --- a/src/java.desktop/share/classes/javax/swing/DefaultListCellRenderer.java +++ b/src/java.desktop/share/classes/javax/swing/DefaultListCellRenderer.java @@ -82,7 +82,6 @@ public class DefaultListCellRenderer extends JLabel * getListCellRendererComponent method and set the border * of the returned component directly. */ - private static final Border SAFE_NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1); private static final Border DEFAULT_NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1); /** * No focus border @@ -100,20 +99,14 @@ public DefaultListCellRenderer() { setName("List.cellRenderer"); } - @SuppressWarnings("removal") private Border getNoFocusBorder() { Border border = DefaultLookup.getBorder(this, ui, "List.cellNoFocusBorder"); - if (System.getSecurityManager() != null) { - if (border != null) return border; - return SAFE_NO_FOCUS_BORDER; - } else { - if (border != null && - (noFocusBorder == null || - noFocusBorder == DEFAULT_NO_FOCUS_BORDER)) { - return border; - } - return noFocusBorder; + if (border != null && + (noFocusBorder == null || + noFocusBorder == DEFAULT_NO_FOCUS_BORDER)) { + return border; } + return noFocusBorder; } public Component getListCellRendererComponent( diff --git a/src/java.desktop/share/classes/javax/swing/FocusManager.java b/src/java.desktop/share/classes/javax/swing/FocusManager.java index 9aa923efafbda..5e9ca85afcefd 100644 --- a/src/java.desktop/share/classes/javax/swing/FocusManager.java +++ b/src/java.desktop/share/classes/javax/swing/FocusManager.java @@ -99,10 +99,6 @@ public static FocusManager getCurrentManager() { * @see java.awt.DefaultKeyboardFocusManager */ public static void setCurrentManager(FocusManager aFocusManager) { - // Note: This method is not backward-compatible with 1.3 and earlier - // releases. It now throws a SecurityException in an applet, whereas - // in previous releases, it did not. This issue was discussed at - // length, and ultimately approved by Hans. KeyboardFocusManager toSet = (aFocusManager instanceof DelegatingDefaultFocusManager) ? ((DelegatingDefaultFocusManager)aFocusManager).getDelegate() diff --git a/src/java.desktop/share/classes/javax/swing/JFrame.java b/src/java.desktop/share/classes/javax/swing/JFrame.java index 1e4c9a1bf761e..8bde7e18f03b7 100644 --- a/src/java.desktop/share/classes/javax/swing/JFrame.java +++ b/src/java.desktop/share/classes/javax/swing/JFrame.java @@ -380,13 +380,6 @@ public void setDefaultCloseOperation(int operation) { + " DISPOSE_ON_CLOSE, or EXIT_ON_CLOSE"); } - if (operation == EXIT_ON_CLOSE) { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkExit(0); - } - } if (this.defaultCloseOperation != operation) { int oldValue = this.defaultCloseOperation; this.defaultCloseOperation = operation; diff --git a/src/java.desktop/share/classes/javax/swing/JInternalFrame.java b/src/java.desktop/share/classes/javax/swing/JInternalFrame.java index e7d0eec76fb3c..2f4ab1dcc1d8c 100644 --- a/src/java.desktop/share/classes/javax/swing/JInternalFrame.java +++ b/src/java.desktop/share/classes/javax/swing/JInternalFrame.java @@ -1781,12 +1781,8 @@ public void dispose() { isClosed = true; } fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_CLOSED); - try { - java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent( - new sun.awt.UngrabEvent(this)); - } catch (SecurityException e) { - this.dispatchEvent(new sun.awt.UngrabEvent(this)); - } + java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent( + new sun.awt.UngrabEvent(this)); } /** diff --git a/src/java.desktop/share/classes/javax/swing/JTable.java b/src/java.desktop/share/classes/javax/swing/JTable.java index 0ff490d45eac9..77d787172cf61 100644 --- a/src/java.desktop/share/classes/javax/swing/JTable.java +++ b/src/java.desktop/share/classes/javax/swing/JTable.java @@ -5560,7 +5560,6 @@ public boolean stopCellEditing() { return super.stopCellEditing(); } - SwingUtilities2.checkAccess(constructor.getModifiers()); value = constructor.newInstance(new Object[]{s}); } catch (Exception e) { @@ -5584,7 +5583,6 @@ public Component getTableCellEditorComponent(JTable table, Object value, if (type == Object.class) { type = String.class; } - SwingUtilities2.checkAccess(type.getModifiers()); constructor = type.getConstructor(argTypes); } catch (Exception e) { @@ -6366,9 +6364,6 @@ public boolean print(PrintMode printMode, } } - // Get a PrinterJob. - // Do this before anything with side-effects since it may throw a - // security exception - in which case we don't want to do anything else. final PrinterJob job = PrinterJob.getPrinterJob(); if (isEditing()) { diff --git a/src/java.desktop/share/classes/javax/swing/Popup.java b/src/java.desktop/share/classes/javax/swing/Popup.java index acc69f82fe3e8..3d4329915bba2 100644 --- a/src/java.desktop/share/classes/javax/swing/Popup.java +++ b/src/java.desktop/share/classes/javax/swing/Popup.java @@ -242,15 +242,7 @@ static class HeavyWeightWindow extends JWindow implements ModalExclude { // Popups are typically transient and most likely won't benefit // from true double buffering. Turn it off here. getRootPane().setUseTrueDoubleBuffering(false); - // Try to set "always-on-top" for the popup window. - // Applets usually don't have sufficient permissions to do it. - // In this case simply ignore the exception. - try { - setAlwaysOnTop(true); - } catch (SecurityException se) { - // setAlwaysOnTop is restricted, - // the exception is ignored - } + setAlwaysOnTop(true); } public void update(Graphics g) { diff --git a/src/java.desktop/share/classes/javax/swing/TimerQueue.java b/src/java.desktop/share/classes/javax/swing/TimerQueue.java index 249593caa7e02..44dc0c6e6af07 100644 --- a/src/java.desktop/share/classes/javax/swing/TimerQueue.java +++ b/src/java.desktop/share/classes/javax/swing/TimerQueue.java @@ -179,7 +179,6 @@ public void run() { // Allow run other threads on systems without kernel threads timer.getLock().newCondition().awaitNanos(1); - } catch (SecurityException ignore) { } finally { timer.getLock().unlock(); } diff --git a/src/java.desktop/share/classes/javax/swing/UIDefaults.java b/src/java.desktop/share/classes/javax/swing/UIDefaults.java index 53eb870d3e61d..13bd6e723b4f6 100644 --- a/src/java.desktop/share/classes/javax/swing/UIDefaults.java +++ b/src/java.desktop/share/classes/javax/swing/UIDefaults.java @@ -1141,7 +1141,6 @@ public Object createValue(final UIDefaults table) { } } c = Class.forName(className, true, (ClassLoader)cl); - SwingUtilities2.checkAccess(c.getModifiers()); if (methodName != null) { Class[] types = getClassArray(args); Method m = c.getMethod(methodName, types); @@ -1149,7 +1148,6 @@ public Object createValue(final UIDefaults table) { } else { Class[] types = getClassArray(args); Constructor constructor = c.getConstructor(types); - SwingUtilities2.checkAccess(constructor.getModifiers()); return constructor.newInstance(args); } } catch(Exception e) { diff --git a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboBoxRenderer.java b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboBoxRenderer.java index 06539e15ff131..a4c95f02c8667 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboBoxRenderer.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboBoxRenderer.java @@ -57,7 +57,6 @@ public class BasicComboBoxRenderer extends JLabel * the setBorder method. */ protected static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1); - private static final Border SAFE_NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1); /** * Constructs a new instance of {@code BasicComboBoxRenderer}. @@ -68,13 +67,8 @@ public BasicComboBoxRenderer() { setBorder(getNoFocusBorder()); } - @SuppressWarnings("removal") private static Border getNoFocusBorder() { - if (System.getSecurityManager() != null) { - return SAFE_NO_FOCUS_BORDER; - } else { - return noFocusBorder; - } + return noFocusBorder; } public Dimension getPreferredSize() { diff --git a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLabelUI.java b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLabelUI.java index 68847cb1ebb99..fab31c78d740d 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLabelUI.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLabelUI.java @@ -66,7 +66,6 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener * name in defaults table under the key "LabelUI". */ protected static BasicLabelUI labelUI = new BasicLabelUI(); - private static final Object BASIC_LABEL_UI_KEY = new Object(); private Rectangle paintIconR = new Rectangle(); private Rectangle paintTextR = new Rectangle(); @@ -466,18 +465,7 @@ protected void uninstallKeyboardActions(JLabel c) { * @param c a component * @return an instance of {@code BasicLabelUI} */ - @SuppressWarnings("removal") public static ComponentUI createUI(JComponent c) { - if (System.getSecurityManager() != null) { - AppContext appContext = AppContext.getAppContext(); - BasicLabelUI safeBasicLabelUI = - (BasicLabelUI) appContext.get(BASIC_LABEL_UI_KEY); - if (safeBasicLabelUI == null) { - safeBasicLabelUI = new BasicLabelUI(); - appContext.put(BASIC_LABEL_UI_KEY, safeBasicLabelUI); - } - return safeBasicLabelUI; - } return labelUI; } diff --git a/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLabelUI.java b/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLabelUI.java index 3578f2fc2109e..d3b7b4a836c1f 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLabelUI.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLabelUI.java @@ -54,8 +54,6 @@ public class MetalLabelUI extends BasicLabelUI */ protected static MetalLabelUI metalLabelUI = new MetalLabelUI(); - private static final Object METAL_LABEL_UI_KEY = new Object(); - /** * Constructs a {@code MetalLabelUI}. */ @@ -67,18 +65,7 @@ public MetalLabelUI() {} * @param c a component * @return an instance of {@code MetalLabelUI} */ - @SuppressWarnings("removal") public static ComponentUI createUI(JComponent c) { - if (System.getSecurityManager() != null) { - AppContext appContext = AppContext.getAppContext(); - MetalLabelUI safeMetalLabelUI = - (MetalLabelUI) appContext.get(METAL_LABEL_UI_KEY); - if (safeMetalLabelUI == null) { - safeMetalLabelUI = new MetalLabelUI(); - appContext.put(METAL_LABEL_UI_KEY, safeMetalLabelUI); - } - return safeMetalLabelUI; - } return metalLabelUI; } diff --git a/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalSliderUI.java b/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalSliderUI.java index c31ee81c729e6..bdded64b788fd 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalSliderUI.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalSliderUI.java @@ -105,9 +105,6 @@ public class MetalSliderUI extends BasicSliderUI { */ protected static Icon vertThumbIcon; - private static Icon SAFE_HORIZ_THUMB_ICON; - private static Icon SAFE_VERT_THUMB_ICON; - /** * Property for {@code JSlider.isFilled}. */ @@ -130,31 +127,19 @@ public MetalSliderUI() { super( null ); } - @SuppressWarnings("removal") private static Icon getHorizThumbIcon() { - if (System.getSecurityManager() != null) { - return SAFE_HORIZ_THUMB_ICON; - } else { - return horizThumbIcon; - } + return horizThumbIcon; } - @SuppressWarnings("removal") private static Icon getVertThumbIcon() { - if (System.getSecurityManager() != null) { - return SAFE_VERT_THUMB_ICON; - } else { - return vertThumbIcon; - } + return vertThumbIcon; } public void installUI( JComponent c ) { trackWidth = ((Integer)UIManager.get( "Slider.trackWidth" )).intValue(); tickLength = safeLength = ((Integer)UIManager.get( "Slider.majorTickLength" )).intValue(); - horizThumbIcon = SAFE_HORIZ_THUMB_ICON = - UIManager.getIcon( "Slider.horizontalThumbIcon" ); - vertThumbIcon = SAFE_VERT_THUMB_ICON = - UIManager.getIcon( "Slider.verticalThumbIcon" ); + horizThumbIcon = UIManager.getIcon( "Slider.horizontalThumbIcon" ); + vertThumbIcon = UIManager.getIcon( "Slider.verticalThumbIcon" ); super.installUI( c ); diff --git a/src/java.desktop/share/classes/javax/swing/table/DefaultTableCellRenderer.java b/src/java.desktop/share/classes/javax/swing/table/DefaultTableCellRenderer.java index 28e324166b598..8b4d7bec2c048 100644 --- a/src/java.desktop/share/classes/javax/swing/table/DefaultTableCellRenderer.java +++ b/src/java.desktop/share/classes/javax/swing/table/DefaultTableCellRenderer.java @@ -93,7 +93,6 @@ public class DefaultTableCellRenderer extends JLabel * getTableCellRendererComponent method and set the border * of the returned component directly. */ - private static final Border SAFE_NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1); private static final Border DEFAULT_NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1); /** * A border without focus. @@ -117,13 +116,9 @@ public DefaultTableCellRenderer() { setName("Table.cellRenderer"); } - @SuppressWarnings("removal") private Border getNoFocusBorder() { Border border = DefaultLookup.getBorder(this, ui, "Table.cellNoFocusBorder"); - if (System.getSecurityManager() != null) { - if (border != null) return border; - return SAFE_NO_FOCUS_BORDER; - } else if (border != null) { + if (border != null) { if (noFocusBorder == null || noFocusBorder == DEFAULT_NO_FOCUS_BORDER) { return border; } diff --git a/src/java.desktop/share/classes/javax/swing/text/DefaultCaret.java b/src/java.desktop/share/classes/javax/swing/text/DefaultCaret.java index bed18fc3fc3dd..81edfd1f5043a 100644 --- a/src/java.desktop/share/classes/javax/swing/text/DefaultCaret.java +++ b/src/java.desktop/share/classes/javax/swing/text/DefaultCaret.java @@ -1431,8 +1431,6 @@ private Clipboard getSystemSelection() { return component.getToolkit().getSystemSelection(); } catch (HeadlessException he) { // do nothing... there is no system clipboard - } catch (SecurityException se) { - // do nothing... there is no allowed system clipboard } return null; } diff --git a/src/java.desktop/share/classes/javax/swing/text/DefaultFormatter.java b/src/java.desktop/share/classes/javax/swing/text/DefaultFormatter.java index 38ea1cda125ba..a0f6a963926ae 100644 --- a/src/java.desktop/share/classes/javax/swing/text/DefaultFormatter.java +++ b/src/java.desktop/share/classes/javax/swing/text/DefaultFormatter.java @@ -247,7 +247,6 @@ public Object stringToValue(String string) throws ParseException { Constructor cons; try { - SwingUtilities2.checkAccess(vc.getModifiers()); cons = vc.getConstructor(new Class[]{String.class}); } catch (NoSuchMethodException nsme) { @@ -256,7 +255,6 @@ public Object stringToValue(String string) throws ParseException { if (cons != null) { try { - SwingUtilities2.checkAccess(cons.getModifiers()); return cons.newInstance(new Object[] { string }); } catch (Throwable ex) { throw new ParseException("Error creating instance", 0); diff --git a/src/java.desktop/share/classes/javax/swing/text/NumberFormatter.java b/src/java.desktop/share/classes/javax/swing/text/NumberFormatter.java index f3e9a8d2a58d1..8abc78e5ade19 100644 --- a/src/java.desktop/share/classes/javax/swing/text/NumberFormatter.java +++ b/src/java.desktop/share/classes/javax/swing/text/NumberFormatter.java @@ -436,11 +436,9 @@ private Object toggleSign(boolean positive) throws ParseException { valueClass = value.getClass(); } try { - SwingUtilities2.checkAccess(valueClass.getModifiers()); Constructor cons = valueClass.getConstructor( new Class[] { String.class }); if (cons != null) { - SwingUtilities2.checkAccess(cons.getModifiers()); return cons.newInstance(new Object[]{string}); } } catch (Throwable ex) { } diff --git a/src/java.desktop/share/classes/sun/awt/OSInfo.java b/src/java.desktop/share/classes/sun/awt/OSInfo.java index 509bac362f22d..b278032c45fc8 100644 --- a/src/java.desktop/share/classes/sun/awt/OSInfo.java +++ b/src/java.desktop/share/classes/sun/awt/OSInfo.java @@ -64,7 +64,7 @@ and so the method getWindowsVersion() will return the constant for known OS. private static final Map windowsVersionMap = new HashMap(); // Cache the OSType for getOSType() - private static final OSType CURRENT_OSTYPE = getOSTypeImpl(); // No DoPriv needed + private static final OSType CURRENT_OSTYPE = getOSTypeImpl(); static { @@ -101,7 +101,7 @@ private static OSType getOSTypeImpl() { }; } - public static WindowsVersion getWindowsVersion() throws SecurityException { + public static WindowsVersion getWindowsVersion() { String osVersion = System.getProperty(OS_VERSION); if (osVersion == null) { diff --git a/src/java.desktop/share/classes/sun/awt/SunToolkit.java b/src/java.desktop/share/classes/sun/awt/SunToolkit.java index b630148f809e8..9bf805a580899 100644 --- a/src/java.desktop/share/classes/sun/awt/SunToolkit.java +++ b/src/java.desktop/share/classes/sun/awt/SunToolkit.java @@ -701,7 +701,6 @@ static Image getImageFromHash(Toolkit tk, URL url) { static Image getImageFromHash(Toolkit tk, String filename) { - checkPermissions(filename); synchronized (fileImgCache) { Image img = (Image)fileImgCache.get(filename); if (img == null) { @@ -757,7 +756,6 @@ protected Image getImageWithResolutionVariant(URL url, @Override public Image createImage(String filename) { - checkPermissions(filename); return createImage(new FileImageSource(filename)); } @@ -870,7 +868,6 @@ protected static boolean imageCached(URL url) { protected static boolean imageExists(String filename) { if (filename != null) { - checkPermissions(filename); return new File(filename).exists(); } return false; @@ -888,14 +885,6 @@ protected static boolean imageExists(URL url) { return false; } - private static void checkPermissions(String filename) { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkRead(filename); - } - } - /** * Scans {@code imageList} for best-looking image of specified dimensions. * Image can be scaled and/or padded with transparency. diff --git a/src/java.desktop/share/classes/sun/awt/util/PerformanceLogger.java b/src/java.desktop/share/classes/sun/awt/util/PerformanceLogger.java index 303b57626d6f6..c942ec4e8f89e 100644 --- a/src/java.desktop/share/classes/sun/awt/util/PerformanceLogger.java +++ b/src/java.desktop/share/classes/sun/awt/util/PerformanceLogger.java @@ -126,9 +126,7 @@ public class PerformanceLogger { /** * Returns status of whether logging is enabled or not. This is - * provided as a convenience method so that users do not have to - * perform the same GetPropertyAction check as above to determine whether - * to enable performance logging. + * provided as a convenience method. */ public static boolean loggingEnabled() { return perfLoggingOn; diff --git a/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java b/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java index 181d2d5d33b46..20a07c608a070 100644 --- a/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java +++ b/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java @@ -1462,20 +1462,6 @@ public static boolean canAccessSystemClipboard() { return !GraphicsEnvironment.isHeadless(); } - /** - * Utility method that throws SecurityException if SecurityManager is set - * and modifiers are not public - * - * @param modifiers a set of modifiers - */ - @SuppressWarnings("removal") - public static void checkAccess(int modifiers) { - if (System.getSecurityManager() != null - && !Modifier.isPublic(modifiers)) { - throw new SecurityException("Resource is not accessible"); - } - } - public static String displayPropertiesToCSS(Font font, Color fg) { StringBuilder rule = new StringBuilder("body {"); if (font != null) { diff --git a/test/jdk/lib/client/ExtendedRobot.java b/test/jdk/lib/client/ExtendedRobot.java index 3f77da887503e..1bcf8e18dfa7c 100644 --- a/test/jdk/lib/client/ExtendedRobot.java +++ b/test/jdk/lib/client/ExtendedRobot.java @@ -57,11 +57,6 @@ public class ExtendedRobot extends Robot { private final int syncDelay = DEFAULT_SYNC_DELAY; - //TODO: uncomment three lines below after moving functionality to java.awt.Robot - //{ - // syncDelay = AccessController.doPrivileged(new GetIntegerAction("java.awt.robotdelay", DEFAULT_SYNC_DELAY)); - //} - /** * Constructs an ExtendedRobot object in the coordinate system of the primary screen. * From d88c7b365afec04c4d1fa089e088c9bbd76c596d Mon Sep 17 00:00:00 2001 From: Jaikiran Pai Date: Tue, 3 Dec 2024 02:31:26 +0000 Subject: [PATCH 08/62] 8345279: Mistake in javadoc of javax.sql.rowset.BaseRowSet#setBigDecimal Reviewed-by: darcy, lancea, iris --- .../share/classes/javax/sql/rowset/BaseRowSet.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/java.sql.rowset/share/classes/javax/sql/rowset/BaseRowSet.java b/src/java.sql.rowset/share/classes/javax/sql/rowset/BaseRowSet.java index 20a76e38b2ed2..9ec28f926ec38 100644 --- a/src/java.sql.rowset/share/classes/javax/sql/rowset/BaseRowSet.java +++ b/src/java.sql.rowset/share/classes/javax/sql/rowset/BaseRowSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -1892,7 +1892,7 @@ public void setDouble(int parameterIndex, double x) throws SQLException { /** * Sets the designated parameter to the given - * java.lang.BigDecimal value. The driver converts this to + * java.math.BigDecimal value. The driver converts this to * an SQL NUMERIC value when it sends it to the database. *

* The parameter value set by this method is stored internally and From 325366ee1d72377c04344aa77f51f7c6d78b65d7 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Tue, 3 Dec 2024 02:32:17 +0000 Subject: [PATCH 09/62] 8345141: Remove uses of SecurityManager in ShellFolder related classes Reviewed-by: azvegint, honkar --- .../classes/sun/awt/shell/ShellFolder.java | 2 +- .../sun/awt/shell/ShellFolderManager.java | 42 +--------- .../share/classes/sun/swing/FilePane.java | 28 +++---- .../sun/awt/shell/Win32ShellFolder2.java | 14 +--- .../awt/shell/Win32ShellFolderManager2.java | 77 ++----------------- 5 files changed, 25 insertions(+), 138 deletions(-) diff --git a/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java b/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java index ee0f32d91c0ee..af1b7c74b59a0 100644 --- a/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java +++ b/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java @@ -232,7 +232,7 @@ public Image getIcon(int width, int height) { managerClass = null; } // swallow the exceptions below and use default shell folder - } catch (ClassNotFoundException | SecurityException | NullPointerException e) { + } catch (ClassNotFoundException | NullPointerException e) { } if (managerClass == null) { diff --git a/src/java.desktop/share/classes/sun/awt/shell/ShellFolderManager.java b/src/java.desktop/share/classes/sun/awt/shell/ShellFolderManager.java index 868a5bb3910b6..10d0b53928519 100644 --- a/src/java.desktop/share/classes/sun/awt/shell/ShellFolderManager.java +++ b/src/java.desktop/share/classes/sun/awt/shell/ShellFolderManager.java @@ -28,8 +28,6 @@ import java.io.File; import java.io.FileNotFoundException; import java.util.concurrent.Callable; -import java.util.stream.Stream; - /** * @author Michael Martak @@ -70,13 +68,13 @@ public Object get(String key) { // Return the default shellfolder for a new filechooser File homeDir = new File(System.getProperty("user.home")); try { - return checkFile(createShellFolder(homeDir)); + return createShellFolder(homeDir); } catch (FileNotFoundException e) { - return checkFile(homeDir); + return homeDir; } } else if (key.equals("roots")) { // The root(s) of the displayable hierarchy - return checkFiles(File.listRoots()); + return File.listRoots(); } else if (key.equals("fileChooserComboBoxFolders")) { // Return an array of ShellFolders representing the list to // show by default in the file chooser's combobox @@ -86,44 +84,12 @@ public Object get(String key) { // folders, such as Desktop, Documents, History, Network, Home, etc. // This is used in the shortcut panel of the filechooser on Windows 2000 // and Windows Me - return checkFiles(new File[] { (File)get("fileChooserDefaultFolder") }); + return new File[] { (File)get("fileChooserDefaultFolder") }; } return null; } - private static File checkFile(File f) { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - return (sm == null || f == null) ? f : checkFile(f, sm); - } - - private static File checkFile(File f, @SuppressWarnings("removal") SecurityManager sm) { - try { - sm.checkRead(f.getPath()); - if (f instanceof ShellFolder) { - ShellFolder sf = (ShellFolder)f; - if (sf.isLink()) { - sm.checkRead(sf.getLinkLocation().getPath()); - } - } - return f; - } catch (SecurityException | FileNotFoundException e) { - return null; - } - } - - private static File[] checkFiles(File[] fs) { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - return (sm == null || fs == null) ? fs : checkFiles(Stream.of(fs), sm); - } - - private static File[] checkFiles(Stream fs, @SuppressWarnings("removal") SecurityManager sm) { - return fs.filter(f -> f != null && checkFile(f, sm) != null) - .toArray(File[]::new); - } - /** * Does {@code dir} represent a "computer" such as a node on the network, or * "My Computer" on the desktop. diff --git a/src/java.desktop/share/classes/sun/swing/FilePane.java b/src/java.desktop/share/classes/sun/swing/FilePane.java index 395cf058b7d6f..052e7a96ac431 100644 --- a/src/java.desktop/share/classes/sun/swing/FilePane.java +++ b/src/java.desktop/share/classes/sun/swing/FilePane.java @@ -2119,24 +2119,20 @@ public boolean canWrite(File f) { return false; } - try { - if (f instanceof ShellFolder) { - return f.canWrite(); - } else { - if (usesShellFolder(getFileChooser())) { - try { - return ShellFolder.getShellFolder(f).canWrite(); - } catch (FileNotFoundException ex) { - // File doesn't exist - return false; - } - } else { - // Ordinary file - return f.canWrite(); + if (f instanceof ShellFolder) { + return f.canWrite(); + } else { + if (usesShellFolder(getFileChooser())) { + try { + return ShellFolder.getShellFolder(f).canWrite(); + } catch (FileNotFoundException ex) { + // File doesn't exist + return false; } + } else { + // Ordinary file + return f.canWrite(); } - } catch (SecurityException e) { - return false; } } diff --git a/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java b/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java index 24e2bb45df8f3..0a4fb12cda6c7 100644 --- a/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java +++ b/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java @@ -666,13 +666,6 @@ public String call() throws IOException { return getFileSystemPath0(csidl); } }, IOException.class); - if (path != null) { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkRead(path); - } - } return path; } @@ -750,11 +743,6 @@ private native long getEnumObjects(long pIShellFolder, boolean isDesktop, * {@code null} if this shellfolder does not denote a directory. */ public File[] listFiles(final boolean includeHiddenFiles) { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkRead(getPath()); - } try { File[] files = invoke(new Callable() { @@ -813,7 +801,7 @@ && pidlsEqual(pIShellFolder, childPIDL, personal.disposer.relativePIDL)) { } }, InterruptedException.class); - return Win32ShellFolderManager2.checkFiles(files); + return files; } catch (InterruptedException e) { return new File[0]; } diff --git a/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java b/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java index 810b25b55fde6..53653f07f34b1 100644 --- a/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java +++ b/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java @@ -42,7 +42,6 @@ import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import java.util.stream.Stream; import sun.awt.OSInfo; import sun.awt.util.ThreadGroupUtils; @@ -167,9 +166,6 @@ static Win32ShellFolder2 getDesktop() { if (desktop == null) { try { desktop = new Win32ShellFolder2(DESKTOP); - } catch (final SecurityException ignored) { - // Ignore, the message may have sensitive information, not - // accessible other ways } catch (IOException | InterruptedException e) { if (log.isLoggable(PlatformLogger.Level.WARNING)) { log.warning("Cannot access 'Desktop'", e); @@ -183,9 +179,6 @@ static Win32ShellFolder2 getDrives() { if (drives == null) { try { drives = new Win32ShellFolder2(DRIVES); - } catch (final SecurityException ignored) { - // Ignore, the message may have sensitive information, not - // accessible other ways } catch (IOException | InterruptedException e) { if (log.isLoggable(PlatformLogger.Level.WARNING)) { log.warning("Cannot access 'Drives'", e); @@ -202,9 +195,6 @@ static Win32ShellFolder2 getRecent() { if (path != null) { recent = createShellFolder(getDesktop(), new File(path)); } - } catch (final SecurityException ignored) { - // Ignore, the message may have sensitive information, not - // accessible other ways } catch (InterruptedException | IOException e) { if (log.isLoggable(PlatformLogger.Level.WARNING)) { log.warning("Cannot access 'Recent'", e); @@ -218,9 +208,6 @@ static Win32ShellFolder2 getNetwork() { if (network == null) { try { network = new Win32ShellFolder2(NETWORK); - } catch (final SecurityException ignored) { - // Ignore, the message may have sensitive information, not - // accessible other ways } catch (IOException | InterruptedException e) { if (log.isLoggable(PlatformLogger.Level.WARNING)) { log.warning("Cannot access 'Network'", e); @@ -244,9 +231,6 @@ static Win32ShellFolder2 getPersonal() { personal.setIsPersonal(); } } - } catch (final SecurityException ignored) { - // Ignore, the message may have sensitive information, not - // accessible other ways } catch (InterruptedException | IOException e) { if (log.isLoggable(PlatformLogger.Level.WARNING)) { log.warning("Cannot access 'Personal'", e); @@ -287,7 +271,7 @@ public Object get(String key) { if (file == null) { file = getDesktop(); } - return checkFile(file); + return file; } else if (key.equals("roots")) { // Should be "History" and "Desktop" ? if (roots == null) { @@ -298,11 +282,11 @@ public Object get(String key) { roots = (File[])super.get(key); } } - return checkFiles(roots); + return roots; } else if (key.equals("fileChooserComboBoxFolders")) { Win32ShellFolder2 desktop = getDesktop(); - if (desktop != null && checkFile(desktop) != null) { + if (desktop != null) { ArrayList folders = new ArrayList(); Win32ShellFolder2 drives = getDrives(); @@ -313,7 +297,7 @@ public Object get(String key) { folders.add(desktop); // Add all second level folders - File[] secondLevelFolders = checkFiles(desktop.listFiles()); + File[] secondLevelFolders = desktop.listFiles(); Arrays.sort(secondLevelFolders); for (File secondLevelFolder : secondLevelFolders) { Win32ShellFolder2 folder = (Win32ShellFolder2) secondLevelFolder; @@ -321,7 +305,7 @@ public Object get(String key) { folders.add(folder); // Add third level for "My Computer" if (folder.equals(drives)) { - File[] thirdLevelFolders = checkFiles(folder.listFiles()); + File[] thirdLevelFolders = folder.listFiles(); if (thirdLevelFolders != null && thirdLevelFolders.length > 0) { List thirdLevelFoldersList = Arrays.asList(thirdLevelFolders); @@ -331,7 +315,7 @@ public Object get(String key) { } } } - return checkFiles(folders); + return folders.toArray(new File[folders.size()]); } else { return super.get(key); } @@ -374,7 +358,7 @@ public Object get(String key) { } } } - return checkFiles(folders); + return folders.toArray(new File[folders.size()]); } else if (key.startsWith("fileChooserIcon ")) { String name = key.substring(key.indexOf(" ") + 1); @@ -421,53 +405,6 @@ public Object get(String key) { return null; } - private static File checkFile(File file) { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - return (sm == null || file == null) ? file : checkFile(file, sm); - } - - private static File checkFile(File file, @SuppressWarnings("removal") SecurityManager sm) { - try { - sm.checkRead(file.getPath()); - - if (file instanceof Win32ShellFolder2) { - Win32ShellFolder2 f = (Win32ShellFolder2)file; - if (f.isLink()) { - Win32ShellFolder2 link = (Win32ShellFolder2)f.getLinkLocation(); - if (link != null) - sm.checkRead(link.getPath()); - } - } - return file; - } catch (SecurityException se) { - return null; - } - } - - static File[] checkFiles(File[] files) { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - if (sm == null || files == null || files.length == 0) { - return files; - } - return checkFiles(Arrays.stream(files), sm); - } - - private static File[] checkFiles(List files) { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - if (sm == null || files.isEmpty()) { - return files.toArray(new File[files.size()]); - } - return checkFiles(files.stream(), sm); - } - - private static File[] checkFiles(Stream filesStream, @SuppressWarnings("removal") SecurityManager sm) { - return filesStream.filter((file) -> checkFile(file, sm) != null) - .toArray(File[]::new); - } - /** * Does {@code dir} represent a "computer" such as a node on the network, or * "My Computer" on the desktop. From 24983dd4c107f11032969e3c079fd0ee07098583 Mon Sep 17 00:00:00 2001 From: Jaikiran Pai Date: Tue, 3 Dec 2024 02:34:20 +0000 Subject: [PATCH 10/62] 7038838: Unspecified NPE in java.net.IDN methods Reviewed-by: liach, dfuchs --- src/java.base/share/classes/java/net/IDN.java | 3 ++ test/jdk/java/net/IDNTest.java | 48 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 test/jdk/java/net/IDNTest.java diff --git a/src/java.base/share/classes/java/net/IDN.java b/src/java.base/share/classes/java/net/IDN.java index 6f11643264f8c..0aaac84076607 100644 --- a/src/java.base/share/classes/java/net/IDN.java +++ b/src/java.base/share/classes/java/net/IDN.java @@ -66,6 +66,9 @@ * Applications are responsible for taking adequate security measures when using * international domain names. * + *

Unless otherwise specified, passing a {@code null} argument to any method + * in this class will cause a {@link NullPointerException} to be thrown. + * * @spec https://www.rfc-editor.org/info/rfc1122 * RFC 1122: Requirements for Internet Hosts - Communication Layers * @spec https://www.rfc-editor.org/info/rfc1123 diff --git a/test/jdk/java/net/IDNTest.java b/test/jdk/java/net/IDNTest.java new file mode 100644 index 0000000000000..aa58e472bf36b --- /dev/null +++ b/test/jdk/java/net/IDNTest.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 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.net.IDN; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +/* + * @test + * @bug 7038838 + * @summary verify the behaviour of the methods on java.net.IDN class + * @run junit IDNTest + */ +public class IDNTest { + + /* + * Verify that various methods on the IDN class throw a NullPointerException + * for any null parameter. + */ + @Test + public void testNullPointerException() throws Exception { + assertThrows(NullPointerException.class, () -> IDN.toASCII(null)); + assertThrows(NullPointerException.class, () -> IDN.toASCII(null, 0)); + assertThrows(NullPointerException.class, () -> IDN.toUnicode(null)); + assertThrows(NullPointerException.class, () -> IDN.toUnicode(null, 0)); + } +} \ No newline at end of file From 40ae4699622cca72830acd146b7b5c4efd5a43ec Mon Sep 17 00:00:00 2001 From: Jaikiran Pai Date: Tue, 3 Dec 2024 02:36:14 +0000 Subject: [PATCH 11/62] 8235786: Javadoc for com/sun/net/httpserver/HttpExchange.java#setAttribute is unclear Reviewed-by: dfuchs, michaelm --- .../com/sun/net/httpserver/HttpExchange.java | 19 ++- .../net/httpserver/ExchangeAttributeTest.java | 130 +++++++++++++++--- 2 files changed, 126 insertions(+), 23 deletions(-) diff --git a/src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpExchange.java b/src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpExchange.java index ea2845f56f56c..ebcbaa3a773db 100644 --- a/src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpExchange.java +++ b/src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpExchange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -233,22 +233,29 @@ protected HttpExchange() { public abstract String getProtocol(); /** - * {@link Filter} modules may store arbitrary objects with {@code HttpExchange} - * instances as an out-of-band communication mechanism. Other filters + * Returns the attribute's value from this exchange's + * {@linkplain HttpContext#getAttributes() context attributes}. + * + * @apiNote {@link Filter} modules may store arbitrary objects as attributes through + * {@code HttpExchange} instances as an out-of-band communication mechanism. Other filters * or the exchange handler may then access these objects. * *

Each {@code Filter} class will document the attributes which they make * available. * * @param name the name of the attribute to retrieve - * @return the attribute object, or {@code null} if it does not exist + * @return the attribute's value or {@code null} if either the attribute isn't set + * or the attribute value is {@code null} * @throws NullPointerException if name is {@code null} */ public abstract Object getAttribute(String name); /** - * {@link Filter} modules may store arbitrary objects with {@code HttpExchange} - * instances as an out-of-band communication mechanism. Other filters + * Sets an attribute with the given {@code name} and {@code value} in this exchange's + * {@linkplain HttpContext#getAttributes() context attributes}. + * + * @apiNote {@link Filter} modules may store arbitrary objects as attributes through + * {@code HttpExchange} instances as an out-of-band communication mechanism. Other filters * or the exchange handler may then access these objects. * *

Each {@code Filter} class will document the attributes which they make diff --git a/test/jdk/com/sun/net/httpserver/ExchangeAttributeTest.java b/test/jdk/com/sun/net/httpserver/ExchangeAttributeTest.java index 2ce3dfd016d00..84c7837e0b33d 100644 --- a/test/jdk/com/sun/net/httpserver/ExchangeAttributeTest.java +++ b/test/jdk/com/sun/net/httpserver/ExchangeAttributeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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,16 +23,19 @@ /* * @test - * @bug 8288109 + * @bug 8288109 8235786 * @summary Tests for HttpExchange set/getAttribute * @library /test/lib * @run junit/othervm ExchangeAttributeTest */ +import com.sun.net.httpserver.Filter; +import com.sun.net.httpserver.HttpContext; import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpServer; import jdk.test.lib.net.URIBuilder; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -53,44 +56,87 @@ public class ExchangeAttributeTest { - static final InetAddress LOOPBACK_ADDR = InetAddress.getLoopbackAddress(); - static final boolean ENABLE_LOGGING = true; - static final Logger logger = Logger.getLogger("com.sun.net.httpserver"); + private static final InetAddress LOOPBACK_ADDR = InetAddress.getLoopbackAddress(); + private static final boolean ENABLE_LOGGING = true; + private static final Logger logger = Logger.getLogger("com.sun.net.httpserver"); + + private static HttpServer server; @BeforeAll - public static void setup() { + public static void setup() throws Exception { if (ENABLE_LOGGING) { ConsoleHandler ch = new ConsoleHandler(); logger.setLevel(Level.ALL); ch.setLevel(Level.ALL); logger.addHandler(ch); } + server = HttpServer.create(new InetSocketAddress(LOOPBACK_ADDR, 0), 10); + server.createContext("/normal", new AttribHandler()); + final HttpContext filteredCtx = server.createContext("/filtered", new AttribHandler()); + filteredCtx.getFilters().add(new AttributeAddingFilter()); + server.start(); + System.out.println("Server started at " + server.getAddress()); + } + + @AfterAll + public static void afterAll() { + if (server != null) { + System.out.println("Stopping server " + server.getAddress()); + server.stop(0); + } } + /* + * Verifies that HttpExchange.setAttribute() allows for null value. + */ @Test - public void testExchangeAttributes() throws Exception { - var handler = new AttribHandler(); - var server = HttpServer.create(new InetSocketAddress(LOOPBACK_ADDR,0), 10); - server.createContext("/", handler); - server.start(); - try { - var client = HttpClient.newBuilder().proxy(NO_PROXY).build(); - var request = HttpRequest.newBuilder(uri(server, "")).build(); + public void testNullAttributeValue() throws Exception { + try (var client = HttpClient.newBuilder().proxy(NO_PROXY).build()) { + var request = HttpRequest.newBuilder(uri(server, "/normal", null)).build(); var response = client.send(request, HttpResponse.BodyHandlers.ofString()); assertEquals(200, response.statusCode()); - } finally { - server.stop(0); + } + } + + /* + * Verifies that an attribute set on one exchange is accessible to another exchange that + * belongs to the same HttpContext. + */ + @Test + public void testSharedAttribute() throws Exception { + try (var client = HttpClient.newBuilder().proxy(NO_PROXY).build()) { + final var firstReq = HttpRequest.newBuilder(uri(server, "/filtered", "firstreq")) + .build(); + System.out.println("issuing request " + firstReq); + final var firstResp = client.send(firstReq, HttpResponse.BodyHandlers.ofString()); + assertEquals(200, firstResp.statusCode()); + + // issue the second request + final var secondReq = HttpRequest.newBuilder(uri(server, "/filtered", "secondreq")) + .build(); + System.out.println("issuing request " + secondReq); + final var secondResp = client.send(secondReq, HttpResponse.BodyHandlers.ofString()); + assertEquals(200, secondResp.statusCode()); + + // verify that the filter was invoked for both the requests. the filter internally + // does the setAttribute() and getAttribute() and asserts that the attribute value + // set by the first exchange was available through the second exchange. + assertTrue(AttributeAddingFilter.filteredFirstReq, "Filter wasn't invoked for " + + firstReq.uri()); + assertTrue(AttributeAddingFilter.filteredSecondReq, "Filter wasn't invoked for " + + secondReq.uri()); } } // --- infra --- - static URI uri(HttpServer server, String path) throws URISyntaxException { + static URI uri(HttpServer server, String path, String query) throws URISyntaxException { return URIBuilder.newBuilder() .scheme("http") .loopback() .port(server.getAddress().getPort()) .path(path) + .query(query) .build(); } @@ -112,4 +158,54 @@ public void handle(HttpExchange exchange) throws IOException { } } } + + private static final class AttributeAddingFilter extends Filter { + + private static final String ATTR_NAME ="foo-bar"; + private static final String ATTR_VAL ="hello-world"; + private static volatile boolean filteredFirstReq; + private static volatile boolean filteredSecondReq; + + @Override + public void doFilter(final HttpExchange exchange, final Chain chain) throws IOException { + if (exchange.getRequestURI().getQuery().contains("firstreq")) { + filteredFirstReq = true; + // add a request attribute through the exchange, for this first request + // and at the same time verify that the attribute doesn't already exist + final Object attrVal = exchange.getAttribute(ATTR_NAME); + if (attrVal != null) { + throw new IOException("attribute " + ATTR_NAME + " with value: " + attrVal + + " unexpectedly present in exchange: " + exchange.getRequestURI()); + } + // set the value + exchange.setAttribute(ATTR_NAME, ATTR_VAL); + System.out.println(exchange.getRequestURI() + " set attribute " + + ATTR_NAME + "=" + ATTR_VAL); + } else if (exchange.getRequestURI().getQuery().contains("secondreq")) { + filteredSecondReq = true; + // verify the attribute is already set and the value is the expected one. + final Object attrVal = exchange.getAttribute(ATTR_NAME); + if (attrVal == null) { + throw new IOException("attribute " + ATTR_NAME + " is missing in exchange: " + + exchange.getRequestURI()); + } + if (!ATTR_VAL.equals(attrVal)) { + throw new IOException("unexpected value: " + attrVal + " for attribute " + + ATTR_NAME + " in exchange: " + exchange.getRequestURI()); + } + System.out.println(exchange.getRequestURI() + " found attribute " + + ATTR_NAME + "=" + attrVal); + } else { + // unexpected request + throw new IOException("unexpected request " + exchange.getRequestURI()); + } + // let the request proceed + chain.doFilter(exchange); + } + + @Override + public String description() { + return "AttributeAddingFilter"; + } + } } From e023addf701ce4321040c96bd501355ece75a05c Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Tue, 3 Dec 2024 03:19:10 +0000 Subject: [PATCH 12/62] 8345297: test/jdk/javax/swing/Action/8133039/bug8133039.java fails in ubuntu22.04 Reviewed-by: azvegint --- test/jdk/javax/swing/Action/8133039/bug8133039.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/jdk/javax/swing/Action/8133039/bug8133039.java b/test/jdk/javax/swing/Action/8133039/bug8133039.java index f36b1b1ab10f8..48de406aaaf02 100644 --- a/test/jdk/javax/swing/Action/8133039/bug8133039.java +++ b/test/jdk/javax/swing/Action/8133039/bug8133039.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -39,8 +39,8 @@ * @bug 8133039 * @summary Provide public API to sun.swing.UIAction#isEnabled(Object) * @modules java.desktop/sun.swing - * @author Alexander Scherbatiy */ + public class bug8133039 { private static volatile int ACTION_PERFORMED_CALLS = 0; @@ -91,6 +91,7 @@ private static void testPopupAction() throws Exception { Robot robot = new Robot(); robot.setAutoDelay(100); robot.waitForIdle(); + robot.delay(1000); robot.keyPress(KeyEvent.VK_A); robot.keyRelease(KeyEvent.VK_A); From a3b58ee5cd1ec0ea78649d4128d272458b05eb13 Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Tue, 3 Dec 2024 04:06:39 +0000 Subject: [PATCH 13/62] 8339983: [s390x] secondary_super_cache does not scale well: C1 and interpreter Reviewed-by: lucy, aph --- src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp | 4 +- src/hotspot/cpu/s390/c1_Runtime1_s390.cpp | 7 +- src/hotspot/cpu/s390/macroAssembler_s390.cpp | 359 ++++++++++++++---- src/hotspot/cpu/s390/macroAssembler_s390.hpp | 59 ++- src/hotspot/cpu/s390/s390.ad | 50 ++- src/hotspot/cpu/s390/stubGenerator_s390.cpp | 8 +- 6 files changed, 379 insertions(+), 108 deletions(-) diff --git a/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp b/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp index 213aa5efe1ef8..dee64d3db265c 100644 --- a/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp @@ -2539,13 +2539,11 @@ void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, L } else { bool need_slow_path = !k->is_loaded() || ((int) k->super_check_offset() == in_bytes(Klass::secondary_super_cache_offset())); - intptr_t super_check_offset = k->is_loaded() ? k->super_check_offset() : -1L; __ load_klass(klass_RInfo, obj); // Perform the fast part of the checking logic. __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, (need_slow_path ? success_target : nullptr), - failure_target, nullptr, - RegisterOrConstant(super_check_offset)); + failure_target, nullptr); if (need_slow_path) { // Call out-of-line instance of __ check_klass_subtype_slow_path(...): address a = Runtime1::entry_for (C1StubId::slow_subtype_check_id); diff --git a/src/hotspot/cpu/s390/c1_Runtime1_s390.cpp b/src/hotspot/cpu/s390/c1_Runtime1_s390.cpp index 8b30adb478559..0ada76ccef780 100644 --- a/src/hotspot/cpu/s390/c1_Runtime1_s390.cpp +++ b/src/hotspot/cpu/s390/c1_Runtime1_s390.cpp @@ -557,7 +557,12 @@ OopMapSet* Runtime1::generate_code_for(C1StubId id, StubAssembler* sasm) { __ z_lg(Rsubklass, 0*BytesPerWord + FrameMap::first_available_sp_in_frame + frame_size, Z_SP); __ z_lg(Rsuperklass, 1*BytesPerWord + FrameMap::first_available_sp_in_frame + frame_size, Z_SP); - __ check_klass_subtype_slow_path(Rsubklass, Rsuperklass, Rarray_ptr, Rlength, nullptr, &miss); + __ check_klass_subtype_slow_path(Rsubklass, + Rsuperklass, + Rarray_ptr /* temp_reg */, + Rlength /* temp2_reg */, + nullptr /* L_success */, + &miss /* L_failure */); // Match falls through here. i = 0; diff --git a/src/hotspot/cpu/s390/macroAssembler_s390.cpp b/src/hotspot/cpu/s390/macroAssembler_s390.cpp index 9e1c5cbced364..aacfb894c72d8 100644 --- a/src/hotspot/cpu/s390/macroAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/macroAssembler_s390.cpp @@ -2981,21 +2981,15 @@ void MacroAssembler::check_klass_subtype_fast_path(Register sub_klass, Label* L_success, Label* L_failure, Label* L_slow_path, - RegisterOrConstant super_check_offset) { + Register super_check_offset) { + // Input registers must not overlap. + assert_different_registers(sub_klass, super_klass, temp1_reg, super_check_offset); - const int sc_offset = in_bytes(Klass::secondary_super_cache_offset()); const int sco_offset = in_bytes(Klass::super_check_offset_offset()); - - bool must_load_sco = (super_check_offset.constant_or_zero() == -1); - bool need_slow_path = (must_load_sco || - super_check_offset.constant_or_zero() == sc_offset); + bool must_load_sco = ! super_check_offset->is_valid(); // Input registers must not overlap. - assert_different_registers(sub_klass, super_klass, temp1_reg); - if (super_check_offset.is_register()) { - assert_different_registers(sub_klass, super_klass, - super_check_offset.as_register()); - } else if (must_load_sco) { + if (must_load_sco) { assert(temp1_reg != noreg, "supply either a temp or a register offset"); } @@ -3006,9 +3000,7 @@ void MacroAssembler::check_klass_subtype_fast_path(Register sub_klass, if (L_success == nullptr) { L_success = &L_fallthrough; label_nulls++; } if (L_failure == nullptr) { L_failure = &L_fallthrough; label_nulls++; } if (L_slow_path == nullptr) { L_slow_path = &L_fallthrough; label_nulls++; } - assert(label_nulls <= 1 || - (L_slow_path == &L_fallthrough && label_nulls <= 2 && !need_slow_path), - "at most one null in the batch, usually"); + assert(label_nulls <= 1 || (L_slow_path == &L_fallthrough && label_nulls <= 2), "at most one null in the batch, usually"); BLOCK_COMMENT("check_klass_subtype_fast_path {"); // If the pointers are equal, we are done (e.g., String[] elements). @@ -3023,10 +3015,12 @@ void MacroAssembler::check_klass_subtype_fast_path(Register sub_klass, // Check the supertype display, which is uint. if (must_load_sco) { z_llgf(Rsuper_check_offset, sco_offset, super_klass); - super_check_offset = RegisterOrConstant(Rsuper_check_offset); + super_check_offset = Rsuper_check_offset; } + Address super_check_addr(sub_klass, super_check_offset, 0); z_cg(super_klass, super_check_addr); // compare w/ displayed supertype + branch_optimized(Assembler::bcondEqual, *L_success); // This check has worked decisively for primary supers. // Secondary supers are sought in the super_cache ('super_cache_addr'). @@ -3044,46 +3038,27 @@ void MacroAssembler::check_klass_subtype_fast_path(Register sub_klass, if (&(label) == &L_fallthrough) { /*do nothing*/ } \ else { branch_optimized(Assembler::bcondAlways, label); } /*omit semicolon*/ - if (super_check_offset.is_register()) { - branch_optimized(Assembler::bcondEqual, *L_success); - z_cfi(super_check_offset.as_register(), sc_offset); - if (L_failure == &L_fallthrough) { - branch_optimized(Assembler::bcondEqual, *L_slow_path); - } else { - branch_optimized(Assembler::bcondNotEqual, *L_failure); - final_jmp(*L_slow_path); - } - } else if (super_check_offset.as_constant() == sc_offset) { - // Need a slow path; fast failure is impossible. - if (L_slow_path == &L_fallthrough) { - branch_optimized(Assembler::bcondEqual, *L_success); - } else { - branch_optimized(Assembler::bcondNotEqual, *L_slow_path); - final_jmp(*L_success); - } + z_cfi(super_check_offset, in_bytes(Klass::secondary_super_cache_offset())); + if (L_failure == &L_fallthrough) { + branch_optimized(Assembler::bcondEqual, *L_slow_path); } else { - // No slow path; it's a fast decision. - if (L_failure == &L_fallthrough) { - branch_optimized(Assembler::bcondEqual, *L_success); - } else { - branch_optimized(Assembler::bcondNotEqual, *L_failure); - final_jmp(*L_success); - } + branch_optimized(Assembler::bcondNotEqual, *L_failure); + final_jmp(*L_slow_path); } bind(L_fallthrough); -#undef local_brc #undef final_jmp BLOCK_COMMENT("} check_klass_subtype_fast_path"); // fallthru (to slow path) } -void MacroAssembler::check_klass_subtype_slow_path(Register Rsubklass, - Register Rsuperklass, - Register Rarray_ptr, // tmp - Register Rlength, // tmp - Label* L_success, - Label* L_failure) { +void MacroAssembler::check_klass_subtype_slow_path_linear(Register Rsubklass, + Register Rsuperklass, + Register Rarray_ptr, // tmp + Register Rlength, // tmp + Label* L_success, + Label* L_failure, + bool set_cond_codes /* unused */) { // Input registers must not overlap. // Also check for R1 which is explicitly used here. assert_different_registers(Z_R1, Rsubklass, Rsuperklass, Rarray_ptr, Rlength); @@ -3106,7 +3081,7 @@ void MacroAssembler::check_klass_subtype_slow_path(Register Rsubklass, NearLabel loop_iterate, loop_count, match; - BLOCK_COMMENT("check_klass_subtype_slow_path {"); + BLOCK_COMMENT("check_klass_subtype_slow_path_linear {"); z_lg(Rarray_ptr, ss_offset, Rsubklass); load_and_test_int(Rlength, Address(Rarray_ptr, length_offset)); @@ -3134,18 +3109,151 @@ void MacroAssembler::check_klass_subtype_slow_path(Register Rsubklass, branch_optimized(Assembler::bcondAlways, *L_failure); // Got a hit. Return success (zero result). Set cache. - // Cache load doesn't happen here. For speed it is directly emitted by the compiler. + // Cache load doesn't happen here. For speed, it is directly emitted by the compiler. BIND(match); - z_stg(Rsuperklass, sc_offset, Rsubklass); // Save result to cache. - + if (UseSecondarySupersCache) { + z_stg(Rsuperklass, sc_offset, Rsubklass); // Save result to cache. + } final_jmp(*L_success); // Exit to the surrounding code. BIND(L_fallthrough); -#undef local_brc #undef final_jmp + BLOCK_COMMENT("} check_klass_subtype_slow_path_linear"); +} + +// If Register r is invalid, remove a new register from +// available_regs, and add new register to regs_to_push. +Register MacroAssembler::allocate_if_noreg(Register r, + RegSetIterator &available_regs, + RegSet ®s_to_push) { + if (!r->is_valid()) { + r = *available_regs++; + regs_to_push += r; + } + return r; +} + +// check_klass_subtype_slow_path_table() looks for super_klass in the +// hash table belonging to super_klass, branching to L_success or +// L_failure as appropriate. This is essentially a shim which +// allocates registers as necessary and then calls +// lookup_secondary_supers_table() to do the work. Any of the temp +// regs may be noreg, in which case this logic will choose some +// registers push and pop them from the stack. +void MacroAssembler::check_klass_subtype_slow_path_table(Register sub_klass, + Register super_klass, + Register temp_reg, + Register temp2_reg, + Register temp3_reg, + Register temp4_reg, + Register result_reg, + Label* L_success, + Label* L_failure, + bool set_cond_codes) { + BLOCK_COMMENT("check_klass_subtype_slow_path_table {"); + + RegSet temps = RegSet::of(temp_reg, temp2_reg, temp3_reg, temp4_reg); + + assert_different_registers(sub_klass, super_klass, temp_reg, temp2_reg, temp4_reg); + + Label L_fallthrough; + int label_nulls = 0; + if (L_success == nullptr) { L_success = &L_fallthrough; label_nulls++; } + if (L_failure == nullptr) { L_failure = &L_fallthrough; label_nulls++; } + assert(label_nulls <= 1, "at most one null in the batch"); + + RegSetIterator available_regs + // Z_R0 will be used to hold Z_R15(Z_SP) while pushing a new frame, So don't use that here. + // Z_R1 will be used to hold r_bitmap in lookup_secondary_supers_table_var, so can't be used + // Z_R2, Z_R3, Z_R4 will be used in secondary_supers_verify, for the failure reporting + = (RegSet::range(Z_R0, Z_R15) - temps - sub_klass - super_klass - Z_R1_scratch - Z_R0_scratch - Z_R2 - Z_R3 - Z_R4).begin(); + + RegSet pushed_regs; + + temp_reg = allocate_if_noreg(temp_reg, available_regs, pushed_regs); + temp2_reg = allocate_if_noreg(temp2_reg, available_regs, pushed_regs); + temp3_reg = allocate_if_noreg(temp3_reg, available_regs, pushed_regs);; + temp4_reg = allocate_if_noreg(temp4_reg, available_regs, pushed_regs); + result_reg = allocate_if_noreg(result_reg, available_regs, pushed_regs); + + const int frame_size = pushed_regs.size() * BytesPerWord + frame::z_abi_160_size; + + // Push & save registers + { + int i = 0; + save_return_pc(); + push_frame(frame_size); + + for (auto it = pushed_regs.begin(); *it != noreg; i++) { + z_stg(*it++, i * BytesPerWord + frame::z_abi_160_size, Z_SP); + } + assert(i * BytesPerWord + frame::z_abi_160_size == frame_size, "sanity"); + } + + lookup_secondary_supers_table_var(sub_klass, + super_klass, + temp_reg, temp2_reg, temp3_reg, temp4_reg, result_reg); + + // NOTE: Condition Code should not be altered before jump instruction below !!!! + z_cghi(result_reg, 0); + + { + int i = 0; + for (auto it = pushed_regs.begin(); *it != noreg; ++i) { + z_lg(*it++, i * BytesPerWord + frame::z_abi_160_size, Z_SP); + } + assert(i * BytesPerWord + frame::z_abi_160_size == frame_size, "sanity"); + pop_frame(); + restore_return_pc(); + } + + // NB! Callers may assume that, when set_cond_codes is true, this + // code sets temp2_reg to a nonzero value. + if (set_cond_codes) { + z_lghi(temp2_reg, 1); + } + + branch_optimized(bcondNotEqual, *L_failure); + + if(L_success != &L_fallthrough) { + z_bru(*L_success); + } + + bind(L_fallthrough); + BLOCK_COMMENT("} check_klass_subtype_slow_path_table"); +} + +void MacroAssembler::check_klass_subtype_slow_path(Register sub_klass, + Register super_klass, + Register temp_reg, + Register temp2_reg, + Label* L_success, + Label* L_failure, + bool set_cond_codes) { + BLOCK_COMMENT("check_klass_subtype_slow_path {"); + if (UseSecondarySupersTable) { + check_klass_subtype_slow_path_table(sub_klass, + super_klass, + temp_reg, + temp2_reg, + /*temp3*/noreg, + /*temp4*/noreg, + /*result*/noreg, + L_success, + L_failure, + set_cond_codes); + } else { + check_klass_subtype_slow_path_linear(sub_klass, + super_klass, + temp_reg, + temp2_reg, + L_success, + L_failure, + set_cond_codes); + } BLOCK_COMMENT("} check_klass_subtype_slow_path"); } @@ -3206,17 +3314,17 @@ do { \ } while(0) // Note: this method also kills Z_R1_scratch register on machines older than z15 -void MacroAssembler::lookup_secondary_supers_table(Register r_sub_klass, - Register r_super_klass, - Register r_temp1, - Register r_temp2, - Register r_temp3, - Register r_temp4, - Register r_result, - u1 super_klass_slot) { +void MacroAssembler::lookup_secondary_supers_table_const(Register r_sub_klass, + Register r_super_klass, + Register r_temp1, + Register r_temp2, + Register r_temp3, + Register r_temp4, + Register r_result, + u1 super_klass_slot) { NearLabel L_done, L_failure; - BLOCK_COMMENT("lookup_secondary_supers_table {"); + BLOCK_COMMENT("lookup_secondary_supers_table_const {"); const Register r_array_base = r_temp1, @@ -3291,7 +3399,7 @@ void MacroAssembler::lookup_secondary_supers_table(Register r_sub_klass, z_lghi(r_result, 1); bind(L_done); - BLOCK_COMMENT("} lookup_secondary_supers_table"); + BLOCK_COMMENT("} lookup_secondary_supers_table_const"); if (VerifySecondarySupers) { verify_secondary_supers_table(r_sub_klass, r_super_klass, r_result, @@ -3299,6 +3407,116 @@ void MacroAssembler::lookup_secondary_supers_table(Register r_sub_klass, } } +// At runtime, return 0 in result if r_super_klass is a superclass of +// r_sub_klass, otherwise return nonzero. Use this version of +// lookup_secondary_supers_table() if you don't know ahead of time +// which superclass will be searched for. Used by interpreter and +// runtime stubs. It is larger and has somewhat greater latency than +// the version above, which takes a constant super_klass_slot. +void MacroAssembler::lookup_secondary_supers_table_var(Register r_sub_klass, + Register r_super_klass, + Register temp1, + Register temp2, + Register temp3, + Register temp4, + Register result) { + assert_different_registers(r_sub_klass, r_super_klass, temp1, temp2, temp3, temp4, result, Z_R1_scratch); + + Label L_done, L_failure; + + BLOCK_COMMENT("lookup_secondary_supers_table_var {"); + + const Register + r_array_index = temp3, + slot = temp4, // NOTE: "slot" can't be Z_R0 otherwise z_sllg and z_rllg instructions below will mess up!!!! + r_bitmap = Z_R1_scratch; + + z_llgc(slot, Address(r_super_klass, Klass::hash_slot_offset())); + + // Initialize r_result with 0 (indicating success). If searching fails, r_result will be loaded + // with 1 (failure) at the end of this method. + clear_reg(result, true /* whole_reg */, false /* set_cc */); // result = 0 + + z_lg(r_bitmap, Address(r_sub_klass, Klass::secondary_supers_bitmap_offset())); + + // First check the bitmap to see if super_klass might be present. If + // the bit is zero, we are certain that super_klass is not one of + // the secondary supers. + z_xilf(slot, (u1)(Klass::SECONDARY_SUPERS_TABLE_SIZE - 1)); // slot ^ 63 === 63 - slot (mod 64) + z_sllg(r_array_index, r_bitmap, /*d2 = */ 0, /* b2 = */ slot); + + testbit(r_array_index, Klass::SECONDARY_SUPERS_TABLE_SIZE - 1); + branch_optimized(bcondAllZero, L_failure); + + const Register + r_array_base = temp1, + r_array_length = temp2; + + // Get the first array index that can contain super_klass into r_array_index. + // NOTE: Z_R1_scratch is holding bitmap (look above for r_bitmap). So let's try to save it. + // On the other hand, r_array_base/temp1 is free at current moment (look at the load operation below). + pop_count_long(r_array_index, r_array_index, temp1); // kills r_array_base/temp1 on machines older than z15 + + // The value i in r_array_index is >= 1, so even though r_array_base + // points to the length, we don't need to adjust it to point to the data. + assert(Array::base_offset_in_bytes() == wordSize, "Adjust this code"); + assert(Array::length_offset_in_bytes() == 0, "Adjust this code"); + + // We will consult the secondary-super array. + z_lg(r_array_base, Address(r_sub_klass, in_bytes(Klass::secondary_supers_offset()))); + + // NB! r_array_index is off by 1. It is compensated by keeping r_array_base off by 1 word. + z_sllg(r_array_index, r_array_index, LogBytesPerWord); // scale, r_array_index is loaded by popcnt above + + z_cg(r_super_klass, Address(r_array_base, r_array_index)); + branch_optimized(bcondEqual, L_done); // found a match + + // Note: this is a small hack: + // + // The operation "(slot ^ 63) === 63 - slot (mod 64)" has already been performed above. + // Since we lack a rotate-right instruction, we achieve the same effect by rotating left + // by "64 - slot" positions. This produces the result equivalent to a right rotation by "slot" positions. + // + // => initial slot value + // => slot = 63 - slot // done above with that z_xilf instruction + // => slot = 64 - slot // need to do for rotating right by "slot" positions + // => slot = 64 - (63 - slot) + // => slot = slot - 63 + 64 + // => slot = slot + 1 + // + // So instead of rotating-left by 64-slot times, we can, for now, just rotate left by slot+1 and it would be fine. + + // Linear probe. Rotate the bitmap so that the next bit to test is + // in Bit 1. + z_aghi(slot, 1); // slot = slot + 1 + + z_rllg(r_bitmap, r_bitmap, /*d2=*/ 0, /*b2=*/ slot); + testbit(r_bitmap, 1); + branch_optimized(bcondAllZero, L_failure); + + // The slot we just inspected is at secondary_supers[r_array_index - 1]. + // The next slot to be inspected, by the logic we're about to call, + // is secondary_supers[r_array_index]. Bits 0 and 1 in the bitmap + // have been checked. + lookup_secondary_supers_table_slow_path(r_super_klass, r_array_base, r_array_index, + r_bitmap, /*temp=*/ r_array_length, result, /*is_stub*/false); + + // pass whatever we got from slow path + z_bru(L_done); + + bind(L_failure); + z_lghi(result, 1); // load 1 to represent failure + + bind(L_done); + + BLOCK_COMMENT("} lookup_secondary_supers_table_var"); + + if (VerifySecondarySupers) { + verify_secondary_supers_table(r_sub_klass, r_super_klass, result, + temp1, temp2, temp3); + } +} + // Called by code generated by check_klass_subtype_slow_path // above. This is called when there is a collision in the hashed // lookup in the secondary supers array. @@ -3306,15 +3524,18 @@ void MacroAssembler::lookup_secondary_supers_table_slow_path(Register r_super_kl Register r_array_base, Register r_array_index, Register r_bitmap, + Register r_temp, Register r_result, - Register r_temp1) { - assert_different_registers(r_super_klass, r_array_base, r_array_index, r_bitmap, r_result, r_temp1); + bool is_stub) { + assert_different_registers(r_super_klass, r_array_base, r_array_index, r_bitmap, r_result, r_temp); const Register - r_array_length = r_temp1, + r_array_length = r_temp, r_sub_klass = noreg; - LOOKUP_SECONDARY_SUPERS_TABLE_REGISTERS; + if(is_stub) { + LOOKUP_SECONDARY_SUPERS_TABLE_REGISTERS; + } BLOCK_COMMENT("lookup_secondary_supers_table_slow_path {"); NearLabel L_done, L_failure; @@ -3343,8 +3564,10 @@ void MacroAssembler::lookup_secondary_supers_table_slow_path(Register r_super_kl { // This is conventional linear probing, but instead of terminating // when a null entry is found in the table, we maintain a bitmap // in which a 0 indicates missing entries. - // The check above guarantees there are 0s in the bitmap, so the loop - // eventually terminates. + // As long as the bitmap is not completely full, + // array_length == popcount(bitmap). The array_length check above + // guarantees there are 0s in the bitmap, so the loop eventually + // terminates. #ifdef ASSERT // r_result is set to 0 by lookup_secondary_supers_table. @@ -3417,8 +3640,6 @@ void MacroAssembler::verify_secondary_supers_table(Register r_sub_klass, const Register r_one = Z_R0_scratch; z_lghi(r_one, 1); // for locgr down there, to a load result for failure - LOOKUP_SECONDARY_SUPERS_TABLE_REGISTERS; - BLOCK_COMMENT("verify_secondary_supers_table {"); Label L_passed, L_failure; diff --git a/src/hotspot/cpu/s390/macroAssembler_s390.hpp b/src/hotspot/cpu/s390/macroAssembler_s390.hpp index 7806fef3ce8ba..91703fac994af 100644 --- a/src/hotspot/cpu/s390/macroAssembler_s390.hpp +++ b/src/hotspot/cpu/s390/macroAssembler_s390.hpp @@ -694,7 +694,7 @@ class MacroAssembler: public Assembler { Label* L_success, Label* L_failure, Label* L_slow_path, - RegisterOrConstant super_check_offset = RegisterOrConstant(-1)); + Register super_check_offset = noreg); // The rest of the type check; must be wired to a corresponding fast path. // It does not repeat the fast path logic, so don't use it standalone. @@ -706,25 +706,62 @@ class MacroAssembler: public Assembler { Register Rarray_ptr, // tmp Register Rlength, // tmp Label* L_success, - Label* L_failure); + Label* L_failure, + bool set_cond_codes = false); + + void check_klass_subtype_slow_path_linear(Register sub_klass, + Register super_klass, + Register temp_reg, + Register temp2_reg, + Label* L_success, + Label* L_failure, + bool set_cond_codes = false); + + void check_klass_subtype_slow_path_table(Register sub_klass, + Register super_klass, + Register temp_reg, + Register temp2_reg, + Register temp3_reg, + Register temp4_reg, + Register result_reg, + Label* L_success, + Label* L_failure, + bool set_cond_codes = false); + + // If r is valid, return r. + // If r is invalid, remove a register r2 from available_regs, add r2 + // to regs_to_push, then return r2. + Register allocate_if_noreg(const Register r, + RegSetIterator &available_regs, + RegSet ®s_to_push); void repne_scan(Register r_addr, Register r_value, Register r_count, Register r_scratch); - void lookup_secondary_supers_table(Register r_sub_klass, - Register r_super_klass, - Register r_temp1, - Register r_temp2, - Register r_temp3, - Register r_temp4, - Register r_result, - u1 super_klass_slot); + // Secondary subtype checking + void lookup_secondary_supers_table_var(Register sub_klass, + Register r_super_klass, + Register temp1, + Register temp2, + Register temp3, + Register temp4, + Register result); + + void lookup_secondary_supers_table_const(Register r_sub_klass, + Register r_super_klass, + Register r_temp1, + Register r_temp2, + Register r_temp3, + Register r_temp4, + Register r_result, + u1 super_klass_slot); void lookup_secondary_supers_table_slow_path(Register r_super_klass, Register r_array_base, Register r_array_index, Register r_bitmap, + Register r_temp, Register r_result, - Register r_temp1); + bool is_stub); void verify_secondary_supers_table(Register r_sub_klass, Register r_super_klass, diff --git a/src/hotspot/cpu/s390/s390.ad b/src/hotspot/cpu/s390/s390.ad index e1a98139992f8..0f1d98d54b929 100644 --- a/src/hotspot/cpu/s390/s390.ad +++ b/src/hotspot/cpu/s390/s390.ad @@ -9979,8 +9979,9 @@ instruct ShouldNotReachHere() %{ instruct partialSubtypeCheck(rarg1RegP index, rarg2RegP sub, rarg3RegP super, flagsReg pcc, rarg4RegP scratch1, rarg5RegP scratch2) %{ match(Set index (PartialSubtypeCheck sub super)); + predicate(!UseSecondarySupersTable); effect(KILL pcc, KILL scratch1, KILL scratch2); - ins_cost(10 * DEFAULT_COST); + ins_cost(20 * DEFAULT_COST); // slightly larger than the next version // TODO: s390 port size(FIXED_SIZE); format %{ " CALL PartialSubtypeCheck\n" %} ins_encode %{ @@ -9991,21 +9992,45 @@ instruct partialSubtypeCheck(rarg1RegP index, rarg2RegP sub, rarg3RegP super, fl ins_pipe(pipe_class_dummy); %} +// Two versions of partialSubtypeCheck, both used when we need to +// search for a super class in the secondary supers array. The first +// is used when we don't know _a priori_ the class being searched +// for. The second, far more common, is used when we do know: this is +// used for instanceof, checkcast, and any case where C2 can determine +// it by constant propagation. +instruct partialSubtypeCheckVarSuper(rarg2RegP sub, rarg3RegP super, + r11TempRegP result, + rarg1RegP temp1, rarg4RegP temp2, rarg5RegP temp3, r10TempRegP temp4, + flagsReg pcc) %{ + match(Set result (PartialSubtypeCheck sub super)); + predicate(UseSecondarySupersTable); + effect(KILL pcc, TEMP temp1, TEMP temp2, TEMP temp3, TEMP temp4); + ins_cost(10 * DEFAULT_COST); // slightly larger than the next version + format %{ "partialSubtypeCheck $result, $sub, $super" %} + ins_encode %{ + __ lookup_secondary_supers_table_var($sub$$Register, $super$$Register, + $temp1$$Register, $temp2$$Register, $temp3$$Register, $temp4$$Register, + $result$$Register); + %} + ins_pipe(pipe_class_dummy); +%} + + instruct partialSubtypeCheckConstSuper(rarg2RegP sub, rarg1RegP super, immP super_con, r11TempRegP result, rarg5RegP temp1, rarg4RegP temp2, rarg3RegP temp3, r10TempRegP temp4, flagsReg pcc) %{ match(Set result (PartialSubtypeCheck sub (Binary super super_con))); predicate(UseSecondarySupersTable); effect(KILL pcc, TEMP temp1, TEMP temp2, TEMP temp3, TEMP temp4); - ins_cost(7 * DEFAULT_COST); // needs to be less than competing nodes + ins_cost(5 * DEFAULT_COST); // smaller than the next version format %{ "partialSubtypeCheck $result, $sub, $super, $super_con" %} ins_encode %{ u1 super_klass_slot = ((Klass*)$super_con$$constant)->hash_slot(); if (InlineSecondarySupersTest) { - __ lookup_secondary_supers_table($sub$$Register, $super$$Register, - $temp1$$Register, $temp2$$Register, $temp3$$Register, - $temp4$$Register, $result$$Register, super_klass_slot); + __ lookup_secondary_supers_table_const($sub$$Register, $super$$Register, + $temp1$$Register, $temp2$$Register, $temp3$$Register, + $temp4$$Register, $result$$Register, super_klass_slot); } else { AddressLiteral stub_address(StubRoutines::lookup_secondary_supers_table_stub(super_klass_slot)); __ load_const_optimized(Z_ARG4, stub_address); @@ -10017,21 +10042,6 @@ instruct partialSubtypeCheckConstSuper(rarg2RegP sub, rarg1RegP super, immP supe ins_pipe(pipe_class_dummy); %} -instruct partialSubtypeCheck_vs_zero(flagsReg pcc, rarg2RegP sub, rarg3RegP super, immP0 zero, - rarg1RegP index, rarg4RegP scratch1, rarg5RegP scratch2) %{ - match(Set pcc (CmpI (PartialSubtypeCheck sub super) zero)); - effect(KILL scratch1, KILL scratch2, KILL index); - ins_cost(10 * DEFAULT_COST); - // TODO: s390 port size(FIXED_SIZE); - format %{ "CALL PartialSubtypeCheck_vs_zero\n" %} - ins_encode %{ - AddressLiteral stub_address(StubRoutines::zarch::partial_subtype_check()); - __ load_const_optimized(Z_ARG4, stub_address); - __ z_basr(Z_R14, Z_ARG4); - %} - ins_pipe(pipe_class_dummy); -%} - // ============================================================================ // inlined locking and unlocking diff --git a/src/hotspot/cpu/s390/stubGenerator_s390.cpp b/src/hotspot/cpu/s390/stubGenerator_s390.cpp index dd9ed4c95462b..9e33cd3abe88a 100644 --- a/src/hotspot/cpu/s390/stubGenerator_s390.cpp +++ b/src/hotspot/cpu/s390/stubGenerator_s390.cpp @@ -635,9 +635,9 @@ class StubGenerator: public StubCodeGenerator { r_result = Z_R11; address start = __ pc(); - __ lookup_secondary_supers_table(r_sub_klass, r_super_klass, - r_array_base, r_array_length, r_array_index, - r_bitmap, r_result, super_klass_index); + __ lookup_secondary_supers_table_const(r_sub_klass, r_super_klass, + r_array_base, r_array_length, r_array_index, + r_bitmap, r_result, super_klass_index); __ z_br(Z_R14); @@ -659,7 +659,7 @@ class StubGenerator: public StubCodeGenerator { r_result = Z_R11; __ lookup_secondary_supers_table_slow_path(r_super_klass, r_array_base, - r_array_index, r_bitmap, r_result, r_temp1); + r_array_index, r_bitmap, r_temp1, r_result, /* is_stub */ true); __ z_br(Z_R14); From 4ac2e477b9bb9995047718b7d8df36c3dc739a9d Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Tue, 3 Dec 2024 04:54:51 +0000 Subject: [PATCH 14/62] 8343800: Cleanup definition of NULL_WORD Reviewed-by: dholmes, kvn --- .../share/utilities/globalDefinitions.hpp | 3 +++ .../share/utilities/globalDefinitions_gcc.hpp | 18 ------------------ .../utilities/globalDefinitions_visCPP.hpp | 6 ------ 3 files changed, 3 insertions(+), 24 deletions(-) diff --git a/src/hotspot/share/utilities/globalDefinitions.hpp b/src/hotspot/share/utilities/globalDefinitions.hpp index 25af626c6286b..ccd3106b471a2 100644 --- a/src/hotspot/share/utilities/globalDefinitions.hpp +++ b/src/hotspot/share/utilities/globalDefinitions.hpp @@ -560,6 +560,9 @@ const jfloat min_jfloat = jfloat_cast(min_jintFloat); const jint max_jintFloat = (jint)(0x7f7fffff); const jfloat max_jfloat = jfloat_cast(max_jintFloat); +// A named constant for the integral representation of a Java null. +const intptr_t NULL_WORD = 0; + //---------------------------------------------------------------------------------------------------- // JVM spec restrictions diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp index e5decbcd53693..863e588d18032 100644 --- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp +++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp @@ -71,24 +71,6 @@ #include #endif // LINUX || _ALLBSD_SOURCE -// NULL vs NULL_WORD: -// On Linux NULL is defined as a special type '__null'. Assigning __null to -// integer variable will cause gcc warning. Use NULL_WORD in places where a -// pointer is stored as integer value. On some platforms, sizeof(intptr_t) > -// sizeof(void*), so here we want something which is integer type, but has the -// same size as a pointer. -#ifdef __GNUC__ - #ifdef _LP64 - #define NULL_WORD 0L - #else - // Cast 0 to intptr_t rather than int32_t since they are not the same type - // on platforms such as Mac OS X. - #define NULL_WORD ((intptr_t)0) - #endif -#else - #define NULL_WORD NULL -#endif - // checking for nanness #if defined(__APPLE__) inline int g_isnan(double f) { return isnan(f); } diff --git a/src/hotspot/share/utilities/globalDefinitions_visCPP.hpp b/src/hotspot/share/utilities/globalDefinitions_visCPP.hpp index 237d12baa6da8..5f26a082d7cb0 100644 --- a/src/hotspot/share/utilities/globalDefinitions_visCPP.hpp +++ b/src/hotspot/share/utilities/globalDefinitions_visCPP.hpp @@ -72,12 +72,6 @@ // 64-bit integer-suffix (LL) instead. #define NULL 0LL -// NULL vs NULL_WORD: -// On Linux NULL is defined as a special type '__null'. Assigning __null to -// integer variable will cause gcc warning. Use NULL_WORD in places where a -// pointer is stored as integer value. -#define NULL_WORD NULL - typedef int64_t ssize_t; // Non-standard stdlib-like stuff: From 3eb54615783562f24e61983dfcc3cb823b27b0eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Volkan=20Yaz=C4=B1c=C4=B1?= Date: Tue, 3 Dec 2024 06:59:06 +0000 Subject: [PATCH 15/62] 8343791: Socket.connect API should document whether the socket will be closed when hostname resolution fails or another error occurs Reviewed-by: dfuchs, alanb --- .../share/classes/java/net/Socket.java | 56 ++++-- .../share/classes/sun/nio/ch/Net.java | 25 +-- .../classes/sun/nio/ch/NioSocketImpl.java | 5 +- .../classes/sun/nio/ch/SocketAdaptor.java | 11 +- test/jdk/java/net/Socket/ConnectFailTest.java | 171 ++++++++++++++++++ 5 files changed, 226 insertions(+), 42 deletions(-) create mode 100644 test/jdk/java/net/Socket/ConnectFailTest.java diff --git a/src/java.base/share/classes/java/net/Socket.java b/src/java.base/share/classes/java/net/Socket.java index 83c0dec682ca1..929e99b530339 100644 --- a/src/java.base/share/classes/java/net/Socket.java +++ b/src/java.base/share/classes/java/net/Socket.java @@ -454,6 +454,7 @@ private Socket(SocketAddress address, SocketAddress localAddr, boolean stream) throws IOException { Objects.requireNonNull(address); + assert address instanceof InetSocketAddress; // create the SocketImpl and the underlying socket SocketImpl impl = createImpl(); @@ -463,16 +464,13 @@ private Socket(SocketAddress address, SocketAddress localAddr, boolean stream) this.state = SOCKET_CREATED; try { - if (localAddr != null) + if (localAddr != null) { bind(localAddr); - connect(address); - } catch (IOException | IllegalArgumentException e) { - try { - close(); - } catch (IOException ce) { - e.addSuppressed(ce); } - throw e; + connect(address); + } catch (Throwable throwable) { + closeSuppressingExceptions(throwable); + throw throwable; } } @@ -571,6 +569,10 @@ void setConnected() { /** * Connects this socket to the server. * + *

If the endpoint is an unresolved {@link InetSocketAddress}, or the + * connection cannot be established, then the socket is closed, and an + * {@link IOException} is thrown. + * *

This method is {@linkplain Thread#interrupt() interruptible} in the * following circumstances: *

    @@ -589,6 +591,8 @@ void setConnected() { * @param endpoint the {@code SocketAddress} * @throws IOException if an error occurs during the connection, the socket * is already connected or the socket is closed + * @throws UnknownHostException if the endpoint is an unresolved + * {@link InetSocketAddress} * @throws java.nio.channels.IllegalBlockingModeException * if this socket has an associated channel, * and the channel is in non-blocking mode @@ -605,6 +609,11 @@ public void connect(SocketAddress endpoint) throws IOException { * A timeout of zero is interpreted as an infinite timeout. The connection * will then block until established or an error occurs. * + *

    If the endpoint is an unresolved {@link InetSocketAddress}, the + * connection cannot be established, or the timeout expires before the + * connection is established, then the socket is closed, and an + * {@link IOException} is thrown. + * *

    This method is {@linkplain Thread#interrupt() interruptible} in the * following circumstances: *

      @@ -625,6 +634,8 @@ public void connect(SocketAddress endpoint) throws IOException { * @throws IOException if an error occurs during the connection, the socket * is already connected or the socket is closed * @throws SocketTimeoutException if timeout expires before connecting + * @throws UnknownHostException if the endpoint is an unresolved + * {@link InetSocketAddress} * @throws java.nio.channels.IllegalBlockingModeException * if this socket has an associated channel, * and the channel is in non-blocking mode @@ -644,26 +655,25 @@ public void connect(SocketAddress endpoint, int timeout) throws IOException { if (isClosed(s)) throw new SocketException("Socket is closed"); if (isConnected(s)) - throw new SocketException("already connected"); + throw new SocketException("Already connected"); if (!(endpoint instanceof InetSocketAddress epoint)) throw new IllegalArgumentException("Unsupported address type"); + if (epoint.isUnresolved()) { + var uhe = new UnknownHostException(epoint.getHostName()); + closeSuppressingExceptions(uhe); + throw uhe; + } + InetAddress addr = epoint.getAddress(); - int port = epoint.getPort(); checkAddress(addr, "connect"); try { getImpl().connect(epoint, timeout); - } catch (SocketTimeoutException e) { - throw e; - } catch (InterruptedIOException e) { - Thread thread = Thread.currentThread(); - if (thread.isVirtual() && thread.isInterrupted()) { - close(); - throw new SocketException("Closed by interrupt"); - } - throw e; + } catch (IOException error) { + closeSuppressingExceptions(error); + throw error; } // connect will bind the socket if not previously bound @@ -1589,6 +1599,14 @@ public boolean getReuseAddress() throws SocketException { return ((Boolean) (getImpl().getOption(SocketOptions.SO_REUSEADDR))).booleanValue(); } + private void closeSuppressingExceptions(Throwable parentException) { + try { + close(); + } catch (IOException exception) { + parentException.addSuppressed(exception); + } + } + /** * Closes this socket. *

      diff --git a/src/java.base/share/classes/sun/nio/ch/Net.java b/src/java.base/share/classes/sun/nio/ch/Net.java index 03dcf04a50f37..5c922aff676b9 100644 --- a/src/java.base/share/classes/sun/nio/ch/Net.java +++ b/src/java.base/share/classes/sun/nio/ch/Net.java @@ -40,6 +40,7 @@ import java.net.StandardSocketOptions; import java.net.UnknownHostException; import java.nio.channels.AlreadyBoundException; +import java.nio.channels.AlreadyConnectedException; import java.nio.channels.ClosedChannelException; import java.nio.channels.NotYetBoundException; import java.nio.channels.NotYetConnectedException; @@ -166,6 +167,8 @@ else if (x instanceof NotYetConnectedException) nx = newSocketException("Socket is not connected"); else if (x instanceof AlreadyBoundException) nx = newSocketException("Already bound"); + else if (x instanceof AlreadyConnectedException) + nx = newSocketException("Already connected"); else if (x instanceof NotYetBoundException) nx = newSocketException("Socket is not bound yet"); else if (x instanceof UnsupportedAddressTypeException) @@ -190,32 +193,12 @@ private static SocketException newSocketException(String msg) { return new SocketException(msg); } - static void translateException(Exception x, - boolean unknownHostForUnresolved) - throws IOException - { + static void translateException(Exception x) throws IOException { if (x instanceof IOException ioe) throw ioe; - // Throw UnknownHostException from here since it cannot - // be thrown as a SocketException - if (unknownHostForUnresolved && - (x instanceof UnresolvedAddressException)) - { - throw new UnknownHostException(); - } translateToSocketException(x); } - static void translateException(Exception x) - throws IOException - { - translateException(x, false); - } - - private static InetSocketAddress getLoopbackAddress(int port) { - return new InetSocketAddress(InetAddress.getLoopbackAddress(), port); - } - private static final InetAddress ANY_LOCAL_INET4ADDRESS; private static final InetAddress ANY_LOCAL_INET6ADDRESS; private static final InetAddress INET4_LOOPBACK_ADDRESS; diff --git a/src/java.base/share/classes/sun/nio/ch/NioSocketImpl.java b/src/java.base/share/classes/sun/nio/ch/NioSocketImpl.java index 40bc3156680a4..7c64d6721e2c7 100644 --- a/src/java.base/share/classes/sun/nio/ch/NioSocketImpl.java +++ b/src/java.base/share/classes/sun/nio/ch/NioSocketImpl.java @@ -599,8 +599,11 @@ protected void connect(SocketAddress remote, int millis) throws IOException { } } catch (IOException ioe) { close(); - if (ioe instanceof InterruptedIOException) { + if (ioe instanceof SocketTimeoutException) { throw ioe; + } else if (ioe instanceof InterruptedIOException) { + assert Thread.currentThread().isVirtual(); + throw new SocketException("Closed by interrupt"); } else { throw SocketExceptions.of(ioe, isa); } diff --git a/src/java.base/share/classes/sun/nio/ch/SocketAdaptor.java b/src/java.base/share/classes/sun/nio/ch/SocketAdaptor.java index cbcfd79378c3b..d8ed1cfb675e9 100644 --- a/src/java.base/share/classes/sun/nio/ch/SocketAdaptor.java +++ b/src/java.base/share/classes/sun/nio/ch/SocketAdaptor.java @@ -35,6 +35,7 @@ import java.net.SocketException; import java.net.SocketOption; import java.net.StandardSocketOptions; +import java.net.UnknownHostException; import java.nio.channels.SocketChannel; import java.util.Set; @@ -85,6 +86,14 @@ public void connect(SocketAddress remote) throws IOException { public void connect(SocketAddress remote, int timeout) throws IOException { if (remote == null) throw new IllegalArgumentException("connect: The address can't be null"); + if (remote instanceof InetSocketAddress isa && isa.isUnresolved()) { + if (!sc.isOpen()) + throw new SocketException("Socket is closed"); + if (sc.isConnected()) + throw new SocketException("Already connected"); + close(); + throw new UnknownHostException(remote.toString()); + } if (timeout < 0) throw new IllegalArgumentException("connect: timeout can't be negative"); try { @@ -95,7 +104,7 @@ public void connect(SocketAddress remote, int timeout) throws IOException { sc.blockingConnect(remote, Long.MAX_VALUE); } } catch (Exception e) { - Net.translateException(e, true); + Net.translateException(e); } } diff --git a/test/jdk/java/net/Socket/ConnectFailTest.java b/test/jdk/java/net/Socket/ConnectFailTest.java new file mode 100644 index 0000000000000..7cc46ce4a4dd6 --- /dev/null +++ b/test/jdk/java/net/Socket/ConnectFailTest.java @@ -0,0 +1,171 @@ +/* + * Copyright (c) 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 jdk.test.lib.Utils; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import java.io.IOException; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.SocketException; +import java.net.UnknownHostException; +import java.nio.channels.SocketChannel; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/* + * @test + * @bug 8343791 + * @summary verifies that `connect()` failures throw the expected exception and leave socket in the expected state + * @library /test/lib + * @run junit ConnectFailTest + */ +class ConnectFailTest { + + private static final int DEAD_SERVER_PORT = 0xDEAD; + + private static final InetSocketAddress REFUSING_SOCKET_ADDRESS = Utils.refusingEndpoint(); + + private static final InetSocketAddress UNRESOLVED_ADDRESS = + InetSocketAddress.createUnresolved("no.such.host", DEAD_SERVER_PORT); + + @Test + void testUnresolvedAddress() { + assertTrue(UNRESOLVED_ADDRESS.isUnresolved()); + } + + /** + * Verifies that an unbound socket is closed when {@code connect()} fails. + */ + @ParameterizedTest + @MethodSource("sockets") + void testUnboundSocket(Socket socket) throws IOException { + try (socket) { + assertFalse(socket.isBound()); + assertFalse(socket.isConnected()); + assertThrows(IOException.class, () -> socket.connect(REFUSING_SOCKET_ADDRESS)); + assertTrue(socket.isClosed()); + } + } + + /** + * Verifies that a bound socket is closed when {@code connect()} fails. + */ + @ParameterizedTest + @MethodSource("sockets") + void testBoundSocket(Socket socket) throws IOException { + try (socket) { + socket.bind(new InetSocketAddress(0)); + assertTrue(socket.isBound()); + assertFalse(socket.isConnected()); + assertThrows(IOException.class, () -> socket.connect(REFUSING_SOCKET_ADDRESS)); + assertTrue(socket.isClosed()); + } + } + + /** + * Verifies that a connected socket is not closed when {@code connect()} fails. + */ + @ParameterizedTest + @MethodSource("sockets") + void testConnectedSocket(Socket socket) throws Throwable { + try (socket; ServerSocket serverSocket = createEphemeralServerSocket()) { + socket.connect(serverSocket.getLocalSocketAddress()); + try (Socket _ = serverSocket.accept()) { + assertTrue(socket.isBound()); + assertTrue(socket.isConnected()); + SocketException exception = assertThrows( + SocketException.class, + () -> socket.connect(REFUSING_SOCKET_ADDRESS)); + assertEquals("Already connected", exception.getMessage()); + assertFalse(socket.isClosed()); + } + } + } + + /** + * Verifies that an unbound socket is closed when {@code connect()} is invoked using an unresolved address. + */ + @ParameterizedTest + @MethodSource("sockets") + void testUnboundSocketWithUnresolvedAddress(Socket socket) throws IOException { + try (socket) { + assertFalse(socket.isBound()); + assertFalse(socket.isConnected()); + assertThrows(UnknownHostException.class, () -> socket.connect(UNRESOLVED_ADDRESS)); + assertTrue(socket.isClosed()); + } + } + + /** + * Verifies that a bound socket is closed when {@code connect()} is invoked using an unresolved address. + */ + @ParameterizedTest + @MethodSource("sockets") + void testBoundSocketWithUnresolvedAddress(Socket socket) throws IOException { + try (socket) { + socket.bind(new InetSocketAddress(0)); + assertTrue(socket.isBound()); + assertFalse(socket.isConnected()); + assertThrows(UnknownHostException.class, () -> socket.connect(UNRESOLVED_ADDRESS)); + assertTrue(socket.isClosed()); + } + } + + /** + * Verifies that a connected socket is not closed when {@code connect()} is invoked using an unresolved address. + */ + @ParameterizedTest + @MethodSource("sockets") + void testConnectedSocketWithUnresolvedAddress(Socket socket) throws Throwable { + try (socket; ServerSocket serverSocket = createEphemeralServerSocket()) { + socket.connect(serverSocket.getLocalSocketAddress()); + try (Socket _ = serverSocket.accept()) { + assertTrue(socket.isBound()); + assertTrue(socket.isConnected()); + assertThrows(IOException.class, () -> socket.connect(UNRESOLVED_ADDRESS)); + assertFalse(socket.isClosed()); + } + } + } + + static List sockets() throws Exception { + Socket socket = new Socket(); + @SuppressWarnings("resource") + Socket channelSocket = SocketChannel.open().socket(); + return List.of(socket, channelSocket); + } + + private static ServerSocket createEphemeralServerSocket() throws IOException { + return new ServerSocket(0, 0, InetAddress.getLoopbackAddress()); + } + +} From 5c8cb2edcb0a919bfcad11b3f2cb399402915a0c Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Tue, 3 Dec 2024 07:24:46 +0000 Subject: [PATCH 16/62] 8337199: Add jcmd Thread.vthread_scheduler and Thread.vthread_pollers diagnostic commands Reviewed-by: dholmes, kevinw --- src/hotspot/share/classfile/vmSymbols.hpp | 7 +- .../share/services/diagnosticCommand.cpp | 48 ++++++- .../share/services/diagnosticCommand.hpp | 27 ++++ .../share/classes/java/lang/System.java | 5 + .../classes/java/lang/VirtualThread.java | 10 +- .../jdk/internal/access/JavaLangAccess.java | 6 + .../jdk/internal/vm/JcmdVThreadCommands.java | 112 +++++++++++++++ .../share/classes/sun/nio/ch/Poller.java | 30 +++- src/jdk.jcmd/share/man/jcmd.md | 11 ++ .../src/share/conf/common.properties | 6 +- .../dcmd/thread/VThreadCommandsTest.java | 133 ++++++++++++++++++ 11 files changed, 383 insertions(+), 12 deletions(-) create mode 100644 src/java.base/share/classes/jdk/internal/vm/JcmdVThreadCommands.java create mode 100644 test/hotspot/jtreg/serviceability/dcmd/thread/VThreadCommandsTest.java diff --git a/src/hotspot/share/classfile/vmSymbols.hpp b/src/hotspot/share/classfile/vmSymbols.hpp index 6a6f7754c509e..46c156a54452a 100644 --- a/src/hotspot/share/classfile/vmSymbols.hpp +++ b/src/hotspot/share/classfile/vmSymbols.hpp @@ -739,10 +739,15 @@ class SerializeClosure; template(toFileURL_signature, "(Ljava/lang/String;)Ljava/net/URL;") \ template(url_array_classloader_void_signature, "([Ljava/net/URL;Ljava/lang/ClassLoader;)V") \ \ - /* Thread.dump_to_file jcmd */ \ + /* jcmd Thread.dump_to_file */ \ template(jdk_internal_vm_ThreadDumper, "jdk/internal/vm/ThreadDumper") \ template(dumpThreads_name, "dumpThreads") \ template(dumpThreadsToJson_name, "dumpThreadsToJson") \ + \ + /* jcmd Thread.vthread_scheduler and Thread.vthread_pollers */ \ + template(jdk_internal_vm_JcmdVThreadCommands, "jdk/internal/vm/JcmdVThreadCommands") \ + template(printScheduler_name, "printScheduler") \ + template(printPollers_name, "printPollers") \ /*end*/ diff --git a/src/hotspot/share/services/diagnosticCommand.cpp b/src/hotspot/share/services/diagnosticCommand.cpp index b081ce29e26ce..e4dff47c84f1d 100644 --- a/src/hotspot/share/services/diagnosticCommand.cpp +++ b/src/hotspot/share/services/diagnosticCommand.cpp @@ -128,6 +128,8 @@ void DCmd::register_dcmds(){ #endif // INCLUDE_JVMTI DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); + DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); + DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); @@ -1073,13 +1075,6 @@ void ThreadDumpToFileDCmd::dumpToFile(Symbol* name, Symbol* signature, const cha Symbol* sym = vmSymbols::jdk_internal_vm_ThreadDumper(); Klass* k = SystemDictionary::resolve_or_fail(sym, true, CHECK); - InstanceKlass* ik = InstanceKlass::cast(k); - if (HAS_PENDING_EXCEPTION) { - java_lang_Throwable::print(PENDING_EXCEPTION, output()); - output()->cr(); - CLEAR_PENDING_EXCEPTION; - return; - } // invoke the ThreadDump method to dump to file JavaValue result(T_OBJECT); @@ -1110,6 +1105,45 @@ void ThreadDumpToFileDCmd::dumpToFile(Symbol* name, Symbol* signature, const cha output()->print_raw((const char*)addr, ba->length()); } +// Calls a static no-arg method on jdk.internal.vm.JcmdVThreadCommands that returns a byte[] with +// the output. If the method completes successfully then the bytes are copied to the output stream. +// If the method fails then the exception is printed to the output stream. +static void execute_vthread_command(Symbol* method_name, outputStream* output, TRAPS) { + ResourceMark rm(THREAD); + HandleMark hm(THREAD); + + Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::jdk_internal_vm_JcmdVThreadCommands(), true, CHECK); + + JavaValue result(T_OBJECT); + JavaCallArguments args; + JavaCalls::call_static(&result, + k, + method_name, + vmSymbols::void_byte_array_signature(), + &args, + THREAD); + if (HAS_PENDING_EXCEPTION) { + java_lang_Throwable::print(PENDING_EXCEPTION, output); + output->cr(); + CLEAR_PENDING_EXCEPTION; + return; + } + + // copy the bytes to the output stream + oop res = cast_to_oop(result.get_jobject()); + typeArrayOop ba = typeArrayOop(res); + jbyte* addr = typeArrayOop(res)->byte_at_addr(0); + output->print_raw((const char*)addr, ba->length()); +} + +void VThreadSchedulerDCmd::execute(DCmdSource source, TRAPS) { + execute_vthread_command(vmSymbols::printScheduler_name(), output(), CHECK); +} + +void VThreadPollersDCmd::execute(DCmdSource source, TRAPS) { + execute_vthread_command(vmSymbols::printPollers_name(), output(), CHECK); +} + CompilationMemoryStatisticDCmd::CompilationMemoryStatisticDCmd(outputStream* output, bool heap) : DCmdWithParser(output, heap), _human_readable("-H", "Human readable format", "BOOLEAN", false, "false"), diff --git a/src/hotspot/share/services/diagnosticCommand.hpp b/src/hotspot/share/services/diagnosticCommand.hpp index 30b2be2a61b68..83e818e16d299 100644 --- a/src/hotspot/share/services/diagnosticCommand.hpp +++ b/src/hotspot/share/services/diagnosticCommand.hpp @@ -776,6 +776,33 @@ class ThreadDumpToFileDCmd : public DCmdWithParser { virtual void execute(DCmdSource source, TRAPS); }; +class VThreadSchedulerDCmd : public DCmd { +public: + VThreadSchedulerDCmd(outputStream* output, bool heap) : DCmd(output, heap) { } + static const char* name() { + return "Thread.vthread_scheduler"; + } + static const char* description() { + return "Print the virtual thread scheduler, and the delayed task schedulers that support " + "virtual threads doing timed operations."; + } + static const char* impact() { return "Low"; } + virtual void execute(DCmdSource source, TRAPS); +}; + +class VThreadPollersDCmd : public DCmd { +public: + VThreadPollersDCmd(outputStream* output, bool heap) : DCmd(output, heap) { } + static const char* name() { + return "Thread.vthread_pollers"; + } + static const char* description() { + return "Print the I/O pollers that support virtual threads doing blocking network I/O operations."; + } + static const char* impact() { return "Low"; } + virtual void execute(DCmdSource source, TRAPS); +}; + class CompilationMemoryStatisticDCmd: public DCmdWithParser { protected: DCmdArgument _human_readable; diff --git a/src/java.base/share/classes/java/lang/System.java b/src/java.base/share/classes/java/lang/System.java index e5e8d4df27a93..11c77d48bf01c 100644 --- a/src/java.base/share/classes/java/lang/System.java +++ b/src/java.base/share/classes/java/lang/System.java @@ -55,6 +55,7 @@ import java.util.ResourceBundle; import java.util.Set; import java.util.concurrent.Executor; +import java.util.concurrent.ScheduledExecutorService; import java.util.function.Supplier; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Stream; @@ -2304,6 +2305,10 @@ public Executor virtualThreadDefaultScheduler() { return VirtualThread.defaultScheduler(); } + public Stream virtualThreadDelayedTaskSchedulers() { + return VirtualThread.delayedTaskSchedulers(); + } + public StackWalker newStackWalkerInstance(Set options, ContinuationScope contScope, Continuation continuation) { diff --git a/src/java.base/share/classes/java/lang/VirtualThread.java b/src/java.base/share/classes/java/lang/VirtualThread.java index 1f8e1941c1d90..dc8c6a852d047 100644 --- a/src/java.base/share/classes/java/lang/VirtualThread.java +++ b/src/java.base/share/classes/java/lang/VirtualThread.java @@ -24,6 +24,7 @@ */ package java.lang; +import java.util.Arrays; import java.util.Locale; import java.util.Objects; import java.util.concurrent.CountDownLatch; @@ -32,12 +33,12 @@ import java.util.concurrent.ForkJoinPool; import java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory; import java.util.concurrent.ForkJoinTask; -import java.util.concurrent.ForkJoinWorkerThread; import java.util.concurrent.Future; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; import jdk.internal.event.VirtualThreadEndEvent; import jdk.internal.event.VirtualThreadStartEvent; import jdk.internal.event.VirtualThreadSubmitFailedEvent; @@ -192,6 +193,13 @@ static Executor defaultScheduler() { return DEFAULT_SCHEDULER; } + /** + * Returns a stream of the delayed task schedulers used to support timed operations. + */ + static Stream delayedTaskSchedulers() { + return Arrays.stream(DELAYED_TASK_SCHEDULERS); + } + /** * Returns the continuation scope used for virtual threads. */ diff --git a/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java b/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java index 62ce8020d802f..f4ba247caf113 100644 --- a/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java +++ b/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java @@ -45,6 +45,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executor; import java.util.concurrent.RejectedExecutionException; +import java.util.concurrent.ScheduledExecutorService; import java.util.stream.Stream; import jdk.internal.loader.NativeLibraries; @@ -595,6 +596,11 @@ public interface JavaLangAccess { */ Executor virtualThreadDefaultScheduler(); + /** + * Returns a stream of the delayed task schedulers used for virtual threads. + */ + Stream virtualThreadDelayedTaskSchedulers(); + /** * Creates a new StackWalker */ diff --git a/src/java.base/share/classes/jdk/internal/vm/JcmdVThreadCommands.java b/src/java.base/share/classes/jdk/internal/vm/JcmdVThreadCommands.java new file mode 100644 index 0000000000000..66ac6c2aca9fc --- /dev/null +++ b/src/java.base/share/classes/jdk/internal/vm/JcmdVThreadCommands.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2023, 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.internal.vm; + +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.stream.IntStream; +import jdk.internal.access.JavaLangAccess; +import jdk.internal.access.SharedSecrets; +import sun.nio.ch.Poller; + +/** + * The implementation for the jcmd Thread.vthread_* diagnostic commands. These methods are + * called from the "Attach Listener" thread. + */ +public class JcmdVThreadCommands { + private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess(); + + private JcmdVThreadCommands() { } + + /** + * Invoked by the VM to print the virtual scheduler to a byte[]. + */ + private static byte[] printScheduler() { + StringBuilder sb = new StringBuilder(); + + // virtual thread scheduler + sb.append(JLA.virtualThreadDefaultScheduler()) + .append(System.lineSeparator()); + + // break + sb.append(System.lineSeparator()); + + // delayed task schedulers + sb.append("Delayed task schedulers:").append(System.lineSeparator()); + var delayedTaskSchedulers = JLA.virtualThreadDelayedTaskSchedulers().toList(); + IntStream.range(0, delayedTaskSchedulers.size()) + .forEach(i -> sb.append('[') + .append(i) + .append("] ") + .append(delayedTaskSchedulers.get(i)) + .append(System.lineSeparator())); + + return sb.toString().getBytes(StandardCharsets.UTF_8); + } + + /** + * Invoked by the VM to print the I/O pollers to a byte[]. + */ + private static byte[] printPollers() { + StringBuilder sb = new StringBuilder(); + + Poller masterPoller = Poller.masterPoller(); + List readPollers = Poller.readPollers(); + List writePollers = Poller.writePollers(); + + if (masterPoller != null) { + sb.append("Master I/O poller:") + .append(System.lineSeparator()) + .append(masterPoller) + .append(System.lineSeparator()); + + // break + sb.append(System.lineSeparator()); + } + + sb.append("Read I/O pollers:"); + sb.append(System.lineSeparator()); + IntStream.range(0, readPollers.size()) + .forEach(i -> sb.append('[') + .append(i) + .append("] ") + .append(readPollers.get(i)) + .append(System.lineSeparator())); + + // break + sb.append(System.lineSeparator()); + + sb.append("Write I/O pollers:"); + sb.append(System.lineSeparator()); + IntStream.range(0, writePollers.size()) + .forEach(i -> sb.append('[') + .append(i) + .append("] ") + .append(writePollers.get(i)) + .append(System.lineSeparator())); + + return sb.toString().getBytes(StandardCharsets.UTF_8); + } +} diff --git a/src/java.base/share/classes/sun/nio/ch/Poller.java b/src/java.base/share/classes/sun/nio/ch/Poller.java index d25dfec7f4221..4a2cb4d8fdf82 100644 --- a/src/java.base/share/classes/sun/nio/ch/Poller.java +++ b/src/java.base/share/classes/sun/nio/ch/Poller.java @@ -36,6 +36,7 @@ import java.util.concurrent.locks.LockSupport; import java.util.function.BooleanSupplier; import jdk.internal.misc.InnocuousThread; +import jdk.internal.vm.annotation.Stable; /** * Polls file descriptors. Virtual threads invoke the poll method to park @@ -53,6 +54,9 @@ public abstract class Poller { } } + // the poller or sub-poller thread + private @Stable Thread owner; + // maps file descriptors to parked Thread private final Map map = new ConcurrentHashMap<>(); @@ -238,6 +242,7 @@ private void wakeup(int fdVal) { * descriptor that is polled. */ private void pollerLoop() { + owner = Thread.currentThread(); try { for (;;) { poll(-1); @@ -258,6 +263,7 @@ private void pollerLoop() { */ private void subPollerLoop(Poller masterPoller) { assert Thread.currentThread().isVirtual(); + owner = Thread.currentThread(); try { int polled = 0; for (;;) { @@ -282,7 +288,8 @@ public int registered() { @Override public String toString() { - return Objects.toIdentityString(this) + " [registered = " + registered() + "]"; + return String.format("%s [registered = %d, owner = %s]", + Objects.toIdentityString(this), registered(), owner); } /** @@ -442,4 +449,25 @@ private void startPlatformThread(String name, Runnable task) { } } } + + /** + * Return the master poller or null if there is no master poller. + */ + public static Poller masterPoller() { + return POLLERS.masterPoller(); + } + + /** + * Return the list of read pollers. + */ + public static List readPollers() { + return POLLERS.readPollers(); + } + + /** + * Return the list of write pollers. + */ + public static List writePollers() { + return POLLERS.writePollers(); + } } diff --git a/src/jdk.jcmd/share/man/jcmd.md b/src/jdk.jcmd/share/man/jcmd.md index 2d2e08bc9f500..4e67e7a450230 100644 --- a/src/jdk.jcmd/share/man/jcmd.md +++ b/src/jdk.jcmd/share/man/jcmd.md @@ -737,6 +737,17 @@ The following commands are available: - `-e`: (Optional) Print extended thread information (BOOLEAN, false) - `-l`: (Optional) Prints `java.util.concurrent` locks (BOOLEAN, false) +`Thread.vthread_scheduler` +: Print the virtual thread scheduler, and the delayed task schedulers that support + virtual threads doing timed operations. + + Impact: Low + +`Thread.vthread_pollers` +: Print the I/O pollers that support virtual threads doing blocking network I/O operations. + + Impact: Low + `VM.cds` \[*arguments*\] : Dump a static or dynamic shared archive that includes all currently loaded classes. diff --git a/test/failure_handler/src/share/conf/common.properties b/test/failure_handler/src/share/conf/common.properties index dd51dc1add91a..5cd2c1c13ca89 100644 --- a/test/failure_handler/src/share/conf/common.properties +++ b/test/failure_handler/src/share/conf/common.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2015, 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 @@ -34,7 +34,7 @@ onTimeout=\ jcmd.vm.classloader_stats jcmd.vm.stringtable \ jcmd.vm.symboltable jcmd.vm.uptime jcmd.vm.dynlibs \ jcmd.vm.system_properties jcmd.vm.info \ - jcmd.gc.heap_info jcmd.gc.class_histogram jcmd.gc.finalizer_info jcmd.thread.dump_to_file \ + jcmd.gc.heap_info jcmd.gc.class_histogram jcmd.gc.finalizer_info jcmd.thread.dump_to_file jcmd.thread.vthread_scheduler \ jstack jhsdb.jstack.live.default jhsdb.jstack.live.mixed jinfo.app=jinfo @@ -61,6 +61,8 @@ jcmd.thread.dump_to_file.args=%p Thread.dump_to_file -format=json JavaThread.dum jcmd.thread.dump_to_file.params.repeat=6 jcmd.thread.dump_to_file.params.successArtifacts=JavaThread.dump.%p.%iterCount +jcmd.thread.vthread_scheduler.args=%p Thread.vthread_scheduler + jstack.app=jstack jstack.args=-e -l %p jstack.params.repeat=6 diff --git a/test/hotspot/jtreg/serviceability/dcmd/thread/VThreadCommandsTest.java b/test/hotspot/jtreg/serviceability/dcmd/thread/VThreadCommandsTest.java new file mode 100644 index 0000000000000..de2b72496124b --- /dev/null +++ b/test/hotspot/jtreg/serviceability/dcmd/thread/VThreadCommandsTest.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2023, 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 8337199 + * @summary Basic test for jcmd Thread.vthread_scheduler and Thread.vthread_pollers + * @requires vm.continuations + * @modules jdk.jcmd + * @library /test/lib + * @run junit/othervm VThreadCommandsTest + */ + +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.SocketTimeoutException; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.Executors; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.ForkJoinWorkerThread; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.atomic.AtomicBoolean; +import java.lang.management.ManagementFactory; +import jdk.management.VirtualThreadSchedulerMXBean; + +import jdk.test.lib.dcmd.PidJcmdExecutor; +import jdk.test.lib.process.OutputAnalyzer; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +class VThreadCommandsTest { + + /** + * Thread.vthread_scheduler + */ + @Test + void testVThreadScheduler() { + // ensure default scheduler and timeout schedulers are initialized + Thread.startVirtualThread(() -> { }); + + jcmd("Thread.vthread_scheduler") + .shouldContain(Objects.toIdentityString(defaultScheduler())) + .shouldContain("Delayed task schedulers:") + .shouldContain("[0] " + ScheduledThreadPoolExecutor.class.getName()); + } + + /** + * Thread.vthread_pollers + */ + @Test + void testVThreadPollers() throws Exception { + // do blocking I/O op on a virtual thread to ensure poller mechanism is initialized + try (var executor = Executors.newVirtualThreadPerTaskExecutor()) { + executor.submit(() -> { + try (var listener = new ServerSocket()) { + InetAddress lb = InetAddress.getLoopbackAddress(); + listener.bind(new InetSocketAddress(lb, 0)); + listener.setSoTimeout(200); + try (Socket s = listener.accept()) { + System.err.format("Connection from %s ??%n", s.getRemoteSocketAddress()); + } catch (SocketTimeoutException e) { + // expected + } + } + return null; + }).get(); + } + + jcmd("Thread.vthread_pollers") + .shouldContain("Read I/O pollers:") + .shouldContain("Write I/O pollers:") + .shouldMatch("^\\[0\\] sun\\.nio\\.ch\\..+ \\[registered = [\\d]+, owner = .+\\]$"); + } + + private OutputAnalyzer jcmd(String cmd) { + return new PidJcmdExecutor().execute(cmd); + } + + /** + * Returns the virtual thread default scheduler. This implementation works by finding + * all FJ worker threads and mapping them to their pool. VirtualThreadSchedulerMXBean + * is used to temporarily changing target parallelism to an "unique" value, make it + * possbile to find the right pool. + */ + private ForkJoinPool defaultScheduler() { + var done = new AtomicBoolean(); + Thread vthread = Thread.startVirtualThread(() -> { + while (!done.get()) { + Thread.onSpinWait(); + } + }); + var bean = ManagementFactory.getPlatformMXBean(VirtualThreadSchedulerMXBean.class); + int parallelism = bean.getParallelism(); + try { + bean.setParallelism(133); + return Thread.getAllStackTraces() + .keySet() + .stream() + .filter(ForkJoinWorkerThread.class::isInstance) + .map(t -> ((ForkJoinWorkerThread) t).getPool()) + .filter(p -> p.getParallelism() == 133) + .findAny() + .orElseThrow(); + } finally { + bean.setParallelism(parallelism); + done.set(true); + } + } +} From 659f70b37079ea2a54ebaaad5f47ce9600982d8d Mon Sep 17 00:00:00 2001 From: Andrey Turbanov Date: Tue, 3 Dec 2024 07:26:01 +0000 Subject: [PATCH 17/62] 8343418: Unnecessary Hashtable usage in CSS.htmlAttrToCssAttrMap Reviewed-by: honkar, aivanov --- .../classes/javax/swing/text/html/CSS.java | 101 +++++++++--------- 1 file changed, 53 insertions(+), 48 deletions(-) diff --git a/src/java.desktop/share/classes/javax/swing/text/html/CSS.java b/src/java.desktop/share/classes/javax/swing/text/html/CSS.java index 8239565a53f21..ef422a8d4e957 100644 --- a/src/java.desktop/share/classes/javax/swing/text/html/CSS.java +++ b/src/java.desktop/share/classes/javax/swing/text/html/CSS.java @@ -38,6 +38,7 @@ import java.util.ArrayList; import java.util.Enumeration; import java.util.Hashtable; +import java.util.Map; import java.util.Objects; import javax.swing.ImageIcon; @@ -1089,7 +1090,7 @@ private static int getTableBorder(AttributeSet tableAttr) { * Therefore, the value associated with each HTML.Attribute. * key ends up being an array of CSS.Attribute.* objects. */ - private static final Hashtable htmlAttrToCssAttrMap = new Hashtable(20); + private static final Map htmlAttrToCssAttrMap; /** * The hashtable and static initialization that follows sets @@ -1113,53 +1114,57 @@ private static int getTableBorder(AttributeSet tableAttr) { valueMap.put(Value.allValues[i].toString(), Value.allValues[i]); } - - htmlAttrToCssAttrMap.put(HTML.Attribute.COLOR, - new CSS.Attribute[]{CSS.Attribute.COLOR}); - htmlAttrToCssAttrMap.put(HTML.Attribute.TEXT, - new CSS.Attribute[]{CSS.Attribute.COLOR}); - htmlAttrToCssAttrMap.put(HTML.Attribute.CLEAR, - new CSS.Attribute[]{CSS.Attribute.CLEAR}); - htmlAttrToCssAttrMap.put(HTML.Attribute.BACKGROUND, - new CSS.Attribute[]{CSS.Attribute.BACKGROUND_IMAGE}); - htmlAttrToCssAttrMap.put(HTML.Attribute.BGCOLOR, - new CSS.Attribute[]{CSS.Attribute.BACKGROUND_COLOR}); - htmlAttrToCssAttrMap.put(HTML.Attribute.WIDTH, - new CSS.Attribute[]{CSS.Attribute.WIDTH}); - htmlAttrToCssAttrMap.put(HTML.Attribute.HEIGHT, - new CSS.Attribute[]{CSS.Attribute.HEIGHT}); - htmlAttrToCssAttrMap.put(HTML.Attribute.BORDER, - new CSS.Attribute[]{CSS.Attribute.BORDER_TOP_WIDTH, CSS.Attribute.BORDER_RIGHT_WIDTH, CSS.Attribute.BORDER_BOTTOM_WIDTH, CSS.Attribute.BORDER_LEFT_WIDTH}); - htmlAttrToCssAttrMap.put(HTML.Attribute.CELLPADDING, - new CSS.Attribute[]{CSS.Attribute.PADDING}); - htmlAttrToCssAttrMap.put(HTML.Attribute.CELLSPACING, - new CSS.Attribute[]{CSS.Attribute.BORDER_SPACING}); - htmlAttrToCssAttrMap.put(HTML.Attribute.MARGINWIDTH, - new CSS.Attribute[]{CSS.Attribute.MARGIN_LEFT, - CSS.Attribute.MARGIN_RIGHT}); - htmlAttrToCssAttrMap.put(HTML.Attribute.MARGINHEIGHT, - new CSS.Attribute[]{CSS.Attribute.MARGIN_TOP, - CSS.Attribute.MARGIN_BOTTOM}); - htmlAttrToCssAttrMap.put(HTML.Attribute.HSPACE, - new CSS.Attribute[]{CSS.Attribute.PADDING_LEFT, - CSS.Attribute.PADDING_RIGHT}); - htmlAttrToCssAttrMap.put(HTML.Attribute.VSPACE, - new CSS.Attribute[]{CSS.Attribute.PADDING_BOTTOM, - CSS.Attribute.PADDING_TOP}); - htmlAttrToCssAttrMap.put(HTML.Attribute.FACE, - new CSS.Attribute[]{CSS.Attribute.FONT_FAMILY}); - htmlAttrToCssAttrMap.put(HTML.Attribute.SIZE, - new CSS.Attribute[]{CSS.Attribute.FONT_SIZE}); - htmlAttrToCssAttrMap.put(HTML.Attribute.VALIGN, - new CSS.Attribute[]{CSS.Attribute.VERTICAL_ALIGN}); - htmlAttrToCssAttrMap.put(HTML.Attribute.ALIGN, - new CSS.Attribute[]{CSS.Attribute.VERTICAL_ALIGN, - CSS.Attribute.TEXT_ALIGN, - CSS.Attribute.FLOAT}); - htmlAttrToCssAttrMap.put(HTML.Attribute.TYPE, - new CSS.Attribute[]{CSS.Attribute.LIST_STYLE_TYPE}); - htmlAttrToCssAttrMap.put(HTML.Attribute.NOWRAP, - new CSS.Attribute[]{CSS.Attribute.WHITE_SPACE}); + htmlAttrToCssAttrMap = Map.ofEntries( + Map.entry(HTML.Attribute.COLOR, + new CSS.Attribute[]{CSS.Attribute.COLOR}), + Map.entry(HTML.Attribute.TEXT, + new CSS.Attribute[]{CSS.Attribute.COLOR}), + Map.entry(HTML.Attribute.CLEAR, + new CSS.Attribute[]{CSS.Attribute.CLEAR}), + Map.entry(HTML.Attribute.BACKGROUND, + new CSS.Attribute[]{CSS.Attribute.BACKGROUND_IMAGE}), + Map.entry(HTML.Attribute.BGCOLOR, + new CSS.Attribute[]{CSS.Attribute.BACKGROUND_COLOR}), + Map.entry(HTML.Attribute.WIDTH, + new CSS.Attribute[]{CSS.Attribute.WIDTH}), + Map.entry(HTML.Attribute.HEIGHT, + new CSS.Attribute[]{CSS.Attribute.HEIGHT}), + Map.entry(HTML.Attribute.BORDER, + new CSS.Attribute[]{CSS.Attribute.BORDER_TOP_WIDTH, + CSS.Attribute.BORDER_RIGHT_WIDTH, + CSS.Attribute.BORDER_BOTTOM_WIDTH, + CSS.Attribute.BORDER_LEFT_WIDTH}), + Map.entry(HTML.Attribute.CELLPADDING, + new CSS.Attribute[]{CSS.Attribute.PADDING}), + Map.entry(HTML.Attribute.CELLSPACING, + new CSS.Attribute[]{CSS.Attribute.BORDER_SPACING}), + Map.entry(HTML.Attribute.MARGINWIDTH, + new CSS.Attribute[]{CSS.Attribute.MARGIN_LEFT, + CSS.Attribute.MARGIN_RIGHT}), + Map.entry(HTML.Attribute.MARGINHEIGHT, + new CSS.Attribute[]{CSS.Attribute.MARGIN_TOP, + CSS.Attribute.MARGIN_BOTTOM}), + Map.entry(HTML.Attribute.HSPACE, + new CSS.Attribute[]{CSS.Attribute.PADDING_LEFT, + CSS.Attribute.PADDING_RIGHT}), + Map.entry(HTML.Attribute.VSPACE, + new CSS.Attribute[]{CSS.Attribute.PADDING_BOTTOM, + CSS.Attribute.PADDING_TOP}), + Map.entry(HTML.Attribute.FACE, + new CSS.Attribute[]{CSS.Attribute.FONT_FAMILY}), + Map.entry(HTML.Attribute.SIZE, + new CSS.Attribute[]{CSS.Attribute.FONT_SIZE}), + Map.entry(HTML.Attribute.VALIGN, + new CSS.Attribute[]{CSS.Attribute.VERTICAL_ALIGN}), + Map.entry(HTML.Attribute.ALIGN, + new CSS.Attribute[]{CSS.Attribute.VERTICAL_ALIGN, + CSS.Attribute.TEXT_ALIGN, + CSS.Attribute.FLOAT}), + Map.entry(HTML.Attribute.TYPE, + new CSS.Attribute[]{CSS.Attribute.LIST_STYLE_TYPE}), + Map.entry(HTML.Attribute.NOWRAP, + new CSS.Attribute[]{CSS.Attribute.WHITE_SPACE}) + ); // initialize StyleConstants mapping styleConstantToCssMap.put(StyleConstants.FontFamily, From 8dada7373fbe195abcc8b2ea7f876f3df6fee821 Mon Sep 17 00:00:00 2001 From: Per Minborg Date: Tue, 3 Dec 2024 08:28:04 +0000 Subject: [PATCH 18/62] 8345120: A likely bug in StringSupport::chunkedStrlenShort Reviewed-by: mcimadamore --- .../foreign/AbstractMemorySegmentImpl.java | 4 + .../foreign/SegmentBulkOperations.java | 62 ++-- .../jdk/internal/foreign/StringSupport.java | 318 +++++++++--------- test/jdk/java/foreign/TestStringEncoding.java | 59 +++- .../java/lang/foreign/InternalStrLen.java | 33 +- 5 files changed, 271 insertions(+), 205 deletions(-) diff --git a/src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java b/src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java index 97417efaa8ca3..a52881b047b18 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java +++ b/src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java @@ -889,23 +889,27 @@ public void setAtIndex(AddressLayout layout, long index, MemorySegment value) { layout.varHandle().set((MemorySegment)this, index * layout.byteSize(), value); } + @ForceInline @Override public String getString(long offset) { return getString(offset, sun.nio.cs.UTF_8.INSTANCE); } + @ForceInline @Override public String getString(long offset, Charset charset) { Objects.requireNonNull(charset); return StringSupport.read(this, offset, charset); } + @ForceInline @Override public void setString(long offset, String str) { Objects.requireNonNull(str); setString(offset, str, sun.nio.cs.UTF_8.INSTANCE); } + @ForceInline @Override public void setString(long offset, String str, Charset charset) { Objects.requireNonNull(charset); diff --git a/src/java.base/share/classes/jdk/internal/foreign/SegmentBulkOperations.java b/src/java.base/share/classes/jdk/internal/foreign/SegmentBulkOperations.java index d928f8fc425fe..068db1bf593c6 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/SegmentBulkOperations.java +++ b/src/java.base/share/classes/jdk/internal/foreign/SegmentBulkOperations.java @@ -28,7 +28,6 @@ import jdk.internal.misc.ScopedMemoryAccess; import jdk.internal.util.Architecture; import jdk.internal.util.ArraysSupport; -import jdk.internal.util.ByteArrayLittleEndian; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.annotation.Stable; @@ -50,6 +49,7 @@ public final class SegmentBulkOperations { private SegmentBulkOperations() {} private static final ScopedMemoryAccess SCOPED_MEMORY_ACCESS = ScopedMemoryAccess.getScopedMemoryAccess(); + private static final long LONG_MASK = ~7L; // The last three bits are zero // All the threshold values below MUST be a power of two and should preferably be // greater or equal to 2^3. @@ -75,21 +75,21 @@ public static MemorySegment fill(AbstractMemorySegmentImpl dst, byte value) { int offset = 0; // 0...0X...X000 final int limit = (int) (dst.length & (NATIVE_THRESHOLD_FILL - 8)); - for (; offset < limit; offset += 8) { + for (; offset < limit; offset += Long.BYTES) { SCOPED_MEMORY_ACCESS.putLongUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + offset, longValue, !Architecture.isLittleEndian()); } int remaining = (int) dst.length - limit; // 0...0X00 - if (remaining >= 4) { + if (remaining >= Integer.BYTES) { SCOPED_MEMORY_ACCESS.putIntUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + offset, (int) longValue, !Architecture.isLittleEndian()); - offset += 4; - remaining -= 4; + offset += Integer.BYTES; + remaining -= Integer.BYTES; } // 0...00X0 - if (remaining >= 2) { + if (remaining >= Short.BYTES) { SCOPED_MEMORY_ACCESS.putShortUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + offset, (short) longValue, !Architecture.isLittleEndian()); - offset += 2; - remaining -= 2; + offset += Short.BYTES; + remaining -= Short.BYTES; } // 0...000X if (remaining == 1) { @@ -123,26 +123,26 @@ public static void copy(AbstractMemorySegmentImpl src, long srcOffset, // is an overlap, we could tolerate one particular direction of overlap (but not the other). // 0...0X...X000 - final int limit = (int) (size & (NATIVE_THRESHOLD_COPY - 8)); + final int limit = (int) (size & (NATIVE_THRESHOLD_COPY - Long.BYTES)); int offset = 0; - for (; offset < limit; offset += 8) { + for (; offset < limit; offset += Long.BYTES) { final long v = SCOPED_MEMORY_ACCESS.getLongUnaligned(src.sessionImpl(), src.unsafeGetBase(), src.unsafeGetOffset() + srcOffset + offset, !Architecture.isLittleEndian()); SCOPED_MEMORY_ACCESS.putLongUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstOffset + offset, v, !Architecture.isLittleEndian()); } int remaining = (int) size - offset; // 0...0X00 - if (remaining >= 4) { + if (remaining >= Integer.BYTES) { final int v = SCOPED_MEMORY_ACCESS.getIntUnaligned(src.sessionImpl(), src.unsafeGetBase(),src.unsafeGetOffset() + srcOffset + offset, !Architecture.isLittleEndian()); SCOPED_MEMORY_ACCESS.putIntUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstOffset + offset, v, !Architecture.isLittleEndian()); - offset += 4; - remaining -= 4; + offset += Integer.BYTES; + remaining -= Integer.BYTES; } // 0...00X0 - if (remaining >= 2) { + if (remaining >= Short.BYTES) { final short v = SCOPED_MEMORY_ACCESS.getShortUnaligned(src.sessionImpl(), src.unsafeGetBase(), src.unsafeGetOffset() + srcOffset + offset, !Architecture.isLittleEndian()); SCOPED_MEMORY_ACCESS.putShortUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstOffset + offset, v, !Architecture.isLittleEndian()); - offset += 2; - remaining -=2; + offset += Short.BYTES; + remaining -= Short.BYTES; } // 0...000X if (remaining == 1) { @@ -202,9 +202,9 @@ public static int contentHash(AbstractMemorySegmentImpl segment, long fromOffset return 1; } int result = 1; - final long longBytes = length & ((1L << 62) - 8); + final long longBytes = length & LONG_MASK; final long limit = fromOffset + longBytes; - for (; fromOffset < limit; fromOffset += 8) { + for (; fromOffset < limit; fromOffset += Long.BYTES) { long val = SCOPED_MEMORY_ACCESS.getLongUnaligned(segment.sessionImpl(), segment.unsafeGetBase(), segment.unsafeGetOffset() + fromOffset, !Architecture.isLittleEndian()); result = result * POWERS_OF_31[7] + ((byte) (val >>> 56)) * POWERS_OF_31[6] @@ -218,24 +218,24 @@ public static int contentHash(AbstractMemorySegmentImpl segment, long fromOffset } int remaining = (int) (length - longBytes); // 0...0X00 - if (remaining >= 4) { + if (remaining >= Integer.BYTES) { int val = SCOPED_MEMORY_ACCESS.getIntUnaligned(segment.sessionImpl(), segment.unsafeGetBase(), segment.unsafeGetOffset() + fromOffset, !Architecture.isLittleEndian()); result = result * POWERS_OF_31[3] + ((byte) (val >>> 24)) * POWERS_OF_31[2] + ((byte) (val >>> 16)) * POWERS_OF_31[1] + ((byte) (val >>> 8)) * POWERS_OF_31[0] + ((byte) val); - fromOffset += 4; - remaining -= 4; + fromOffset += Integer.BYTES; + remaining -= Integer.BYTES; } // 0...00X0 - if (remaining >= 2) { + if (remaining >= Short.BYTES) { short val = SCOPED_MEMORY_ACCESS.getShortUnaligned(segment.sessionImpl(), segment.unsafeGetBase(), segment.unsafeGetOffset() + fromOffset, !Architecture.isLittleEndian()); result = result * POWERS_OF_31[1] + ((byte) (val >>> 8)) * POWERS_OF_31[0] + ((byte) val); - fromOffset += 2; - remaining -= 2; + fromOffset += Short.BYTES; + remaining -= Short.BYTES; } // 0...000X if (remaining == 1) { @@ -288,7 +288,7 @@ private static long mismatch(AbstractMemorySegmentImpl src, long srcFromOffset, long start, int length, boolean srcAndDstBytesDiffer) { int offset = 0; final int limit = length & (NATIVE_THRESHOLD_MISMATCH - 8); - for (; offset < limit; offset += 8) { + for (; offset < limit; offset += Long.BYTES) { final long s = SCOPED_MEMORY_ACCESS.getLongUnaligned(src.sessionImpl(), src.unsafeGetBase(), src.unsafeGetOffset() + srcFromOffset + offset, false); final long d = SCOPED_MEMORY_ACCESS.getLongUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstFromOffset + offset, false); if (s != d) { @@ -298,24 +298,24 @@ private static long mismatch(AbstractMemorySegmentImpl src, long srcFromOffset, int remaining = length - offset; // 0...0X00 - if (remaining >= 4) { + if (remaining >= Integer.BYTES) { final int s = SCOPED_MEMORY_ACCESS.getIntUnaligned(src.sessionImpl(), src.unsafeGetBase(), src.unsafeGetOffset() + srcFromOffset + offset, false); final int d = SCOPED_MEMORY_ACCESS.getIntUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstFromOffset + offset, false); if (s != d) { return start + offset + mismatch(s, d); } - offset += 4; - remaining -= 4; + offset += Integer.BYTES; + remaining -= Integer.BYTES; } // 0...00X0 - if (remaining >= 2) { + if (remaining >= Short.BYTES) { final short s = SCOPED_MEMORY_ACCESS.getShortUnaligned(src.sessionImpl(), src.unsafeGetBase(), src.unsafeGetOffset() + srcFromOffset + offset, false); final short d = SCOPED_MEMORY_ACCESS.getShortUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstFromOffset + offset, false); if (s != d) { return start + offset + mismatch(s, d); } - offset += 2; - remaining -= 2; + offset += Short.BYTES; + remaining -= Short.BYTES; } // 0...000X if (remaining == 1) { diff --git a/src/java.base/share/classes/jdk/internal/foreign/StringSupport.java b/src/java.base/share/classes/jdk/internal/foreign/StringSupport.java index 78550c56136d5..8f182f3b33845 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/StringSupport.java +++ b/src/java.base/share/classes/jdk/internal/foreign/StringSupport.java @@ -27,8 +27,10 @@ import jdk.internal.access.JavaLangAccess; import jdk.internal.access.SharedSecrets; -import jdk.internal.foreign.abi.SharedUtils; +import jdk.internal.misc.ScopedMemoryAccess; +import jdk.internal.util.Architecture; import jdk.internal.util.ArraysSupport; +import jdk.internal.vm.annotation.ForceInline; import java.lang.foreign.MemorySegment; import java.nio.charset.Charset; @@ -40,11 +42,14 @@ */ public final class StringSupport { - static final JavaLangAccess JAVA_LANG_ACCESS = SharedSecrets.getJavaLangAccess(); + private static final JavaLangAccess JAVA_LANG_ACCESS = SharedSecrets.getJavaLangAccess(); + private static final ScopedMemoryAccess SCOPED_MEMORY_ACCESS = ScopedMemoryAccess.getScopedMemoryAccess(); + private static final long LONG_MASK = ~7L; // The last three bits are zero private StringSupport() {} - public static String read(MemorySegment segment, long offset, Charset charset) { + @ForceInline + public static String read(AbstractMemorySegmentImpl segment, long offset, Charset charset) { return switch (CharsetKind.of(charset)) { case SINGLE_BYTE -> readByte(segment, offset, charset); case DOUBLE_BYTE -> readShort(segment, offset, charset); @@ -52,7 +57,8 @@ public static String read(MemorySegment segment, long offset, Charset charset) { }; } - public static void write(MemorySegment segment, long offset, Charset charset, String string) { + @ForceInline + public static void write(AbstractMemorySegmentImpl segment, long offset, Charset charset, String string) { switch (CharsetKind.of(charset)) { case SINGLE_BYTE -> writeByte(segment, offset, charset, string); case DOUBLE_BYTE -> writeShort(segment, offset, charset, string); @@ -60,111 +66,183 @@ public static void write(MemorySegment segment, long offset, Charset charset, St } } - private static String readByte(MemorySegment segment, long offset, Charset charset) { - long len = chunkedStrlenByte(segment, offset); - byte[] bytes = new byte[(int)len]; - MemorySegment.copy(segment, JAVA_BYTE, offset, bytes, 0, (int)len); + @ForceInline + private static String readByte(AbstractMemorySegmentImpl segment, long offset, Charset charset) { + final int len = strlenByte(segment, offset, segment.byteSize()); + final byte[] bytes = new byte[len]; + MemorySegment.copy(segment, JAVA_BYTE, offset, bytes, 0, len); return new String(bytes, charset); } - private static void writeByte(MemorySegment segment, long offset, Charset charset, String string) { + @ForceInline + private static void writeByte(AbstractMemorySegmentImpl segment, long offset, Charset charset, String string) { int bytes = copyBytes(string, segment, charset, offset); segment.set(JAVA_BYTE, offset + bytes, (byte)0); } - private static String readShort(MemorySegment segment, long offset, Charset charset) { - long len = chunkedStrlenShort(segment, offset); - byte[] bytes = new byte[(int)len]; - MemorySegment.copy(segment, JAVA_BYTE, offset, bytes, 0, (int)len); + @ForceInline + private static String readShort(AbstractMemorySegmentImpl segment, long offset, Charset charset) { + int len = strlenShort(segment, offset, segment.byteSize()); + byte[] bytes = new byte[len]; + MemorySegment.copy(segment, JAVA_BYTE, offset, bytes, 0, len); return new String(bytes, charset); } - private static void writeShort(MemorySegment segment, long offset, Charset charset, String string) { + @ForceInline + private static void writeShort(AbstractMemorySegmentImpl segment, long offset, Charset charset, String string) { int bytes = copyBytes(string, segment, charset, offset); segment.set(JAVA_SHORT_UNALIGNED, offset + bytes, (short)0); } - private static String readInt(MemorySegment segment, long offset, Charset charset) { - long len = strlenInt(segment, offset); - byte[] bytes = new byte[(int)len]; - MemorySegment.copy(segment, JAVA_BYTE, offset, bytes, 0, (int)len); + @ForceInline + private static String readInt(AbstractMemorySegmentImpl segment, long offset, Charset charset) { + int len = strlenInt(segment, offset, segment.byteSize()); + byte[] bytes = new byte[len]; + MemorySegment.copy(segment, JAVA_BYTE, offset, bytes, 0, len); return new String(bytes, charset); } - private static void writeInt(MemorySegment segment, long offset, Charset charset, String string) { + @ForceInline + private static void writeInt(AbstractMemorySegmentImpl segment, long offset, Charset charset, String string) { int bytes = copyBytes(string, segment, charset, offset); segment.set(JAVA_INT_UNALIGNED, offset + bytes, 0); } /** - * {@return the shortest distance beginning at the provided {@code start} - * to the encountering of a zero byte in the provided {@code segment}} + * {@return the index of the first zero byte beginning at the provided + * {@code fromOffset} to the encountering of a zero byte in the provided + * {@code segment} checking bytes before the {@code toOffset}} *

      - * The method divides the region of interest into three distinct regions: - *

        - *
      • head (access made on a byte-by-byte basis) (if any)
      • - *
      • body (access made with eight bytes at a time at physically 64-bit-aligned memory) (if any)
      • - *
      • tail (access made on a byte-by-byte basis) (if any)
      • - *
      - *

      - * The body is using a heuristic method to determine if a long word - * contains a zero byte. The method might have false positives but - * never false negatives. + * The method is using a heuristic method to determine if a long word contains a + * zero byte. The method might have false positives but never false negatives. *

      * This method is inspired by the `glibc/string/strlen.c` implementation * - * @param segment to examine - * @param start from where examination shall begin + * @param segment to examine + * @param fromOffset from where examination shall begin (inclusive) + * @param toOffset to where examination shall end (exclusive) * @throws IllegalArgumentException if the examined region contains no zero bytes * within a length that can be accepted by a String */ - public static int chunkedStrlenByte(MemorySegment segment, long start) { - - // Handle the first unaligned "head" bytes separately - int headCount = (int)SharedUtils.remainsToAlignment(segment.address() + start, Long.BYTES); - - int offset = 0; - for (; offset < headCount; offset++) { - byte curr = segment.get(JAVA_BYTE, start + offset); - if (curr == 0) { - return offset; + @ForceInline + public static int strlenByte(final AbstractMemorySegmentImpl segment, + final long fromOffset, + final long toOffset) { + final long length = toOffset - fromOffset; + segment.checkBounds(fromOffset, length); + if (length == 0) { + // The state has to be checked explicitly for zero-length segments + segment.scope.checkValidState(); + throw nullNotFound(segment, fromOffset, toOffset); + } + final long longBytes = length & LONG_MASK; + final long longLimit = fromOffset + longBytes; + long offset = fromOffset; + for (; offset < longLimit; offset += Long.BYTES) { + long val = SCOPED_MEMORY_ACCESS.getLongUnaligned(segment.sessionImpl(), segment.unsafeGetBase(), segment.unsafeGetOffset() + offset, !Architecture.isLittleEndian()); + if (mightContainZeroByte(val)) { + for (int j = 0; j < Long.BYTES; j++) { + if (SCOPED_MEMORY_ACCESS.getByte(segment.sessionImpl(), segment.unsafeGetBase(), segment.unsafeGetOffset() + offset + j) == 0) { + return requireWithinStringSize(offset + j - fromOffset, segment, fromOffset, toOffset); + } + } + } + } + // Handle the tail + for (; offset < toOffset; offset++) { + byte val = SCOPED_MEMORY_ACCESS.getByte(segment.sessionImpl(), segment.unsafeGetBase(), segment.unsafeGetOffset() + offset); + if (val == 0) { + return requireWithinStringSize(offset - fromOffset, segment, fromOffset, toOffset); } } + throw nullNotFound(segment, fromOffset, toOffset); + } - // We are now on a long-aligned boundary so this is the "body" - int bodyCount = bodyCount(segment.byteSize() - start - headCount); - - for (; offset < bodyCount; offset += Long.BYTES) { - // We know we are `long` aligned so, we can save on alignment checking here - long curr = segment.get(JAVA_LONG_UNALIGNED, start + offset); - // Is this a candidate? - if (mightContainZeroByte(curr)) { - for (int j = 0; j < 8; j++) { - if (segment.get(JAVA_BYTE, start + offset + j) == 0) { - return offset + j; + @ForceInline + public static int strlenShort(final AbstractMemorySegmentImpl segment, + final long fromOffset, + final long toOffset) { + final long length = toOffset - fromOffset; + segment.checkBounds(fromOffset, length); + if (length == 0) { + segment.scope.checkValidState(); + throw nullNotFound(segment, fromOffset, toOffset); + } + final long longBytes = length & LONG_MASK; + final long longLimit = fromOffset + longBytes; + long offset = fromOffset; + for (; offset < longLimit; offset += Long.BYTES) { + long val = SCOPED_MEMORY_ACCESS.getLongUnaligned(segment.sessionImpl(), segment.unsafeGetBase(), segment.unsafeGetOffset() + offset, !Architecture.isLittleEndian()); + if (mightContainZeroShort(val)) { + for (int j = 0; j < Long.BYTES; j += Short.BYTES) { + if (SCOPED_MEMORY_ACCESS.getShortUnaligned(segment.sessionImpl(), segment.unsafeGetBase(), segment.unsafeGetOffset() + offset + j, !Architecture.isLittleEndian()) == 0) { + return requireWithinStringSize(offset + j - fromOffset, segment, fromOffset, toOffset); } } } } + // Handle the tail + // Prevent over scanning as we step by 2 + final long endScan = toOffset & ~1; // The last bit is zero + for (; offset < endScan; offset += Short.BYTES) { + short val = SCOPED_MEMORY_ACCESS.getShortUnaligned(segment.sessionImpl(), segment.unsafeGetBase(), segment.unsafeGetOffset() + offset, !Architecture.isLittleEndian()); + if (val == 0) { + return requireWithinStringSize(offset - fromOffset, segment, fromOffset, toOffset); + } + } + throw nullNotFound(segment, fromOffset, toOffset); + } - // Handle the "tail" - return requireWithinArraySize((long) offset + strlenByte(segment, start + offset)); + @ForceInline + public static int strlenInt(final AbstractMemorySegmentImpl segment, + final long fromOffset, + final long toOffset) { + final long length = toOffset - fromOffset; + segment.checkBounds(fromOffset, length); + if (length == 0) { + segment.scope.checkValidState(); + throw nullNotFound(segment, fromOffset, toOffset); + } + final long longBytes = length & LONG_MASK; + final long longLimit = fromOffset + longBytes; + long offset = fromOffset; + for (; offset < longLimit; offset += Long.BYTES) { + long val = SCOPED_MEMORY_ACCESS.getLongUnaligned(segment.sessionImpl(), segment.unsafeGetBase(), segment.unsafeGetOffset() + offset, !Architecture.isLittleEndian()); + if (mightContainZeroInt(val)) { + for (int j = 0; j < Long.BYTES; j += Integer.BYTES) { + if (SCOPED_MEMORY_ACCESS.getIntUnaligned(segment.sessionImpl(), segment.unsafeGetBase(), segment.unsafeGetOffset() + offset + j, !Architecture.isLittleEndian()) == 0) { + return requireWithinStringSize(offset + j - fromOffset, segment, fromOffset, toOffset); + } + } + } + } + // Handle the tail + // Prevent over scanning as we step by 4 + final long endScan = toOffset & ~3; // The last two bit are zero + for (; offset < endScan; offset += Integer.BYTES) { + int val = SCOPED_MEMORY_ACCESS.getIntUnaligned(segment.sessionImpl(), segment.unsafeGetBase(), segment.unsafeGetOffset() + offset, !Architecture.isLittleEndian()); + if (val == 0) { + return requireWithinStringSize(offset - fromOffset, segment, fromOffset, toOffset); + } + } + throw nullNotFound(segment, fromOffset, toOffset); } - /* Bits 63 and N * 8 (N = 1..7) of this number are zero. Call these bits - the "holes". Note that there is a hole just to the left of - each byte, with an extra at the end: + /* + Bits 63 and N * 8 (N = 1..7) of this number are zero. Call these bits + the "holes". Note that there is a hole just to the left of + each byte, with an extra at the end: - bits: 01111110 11111110 11111110 11111110 11111110 11111110 11111110 11111111 - bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE FFFFFFFF GGGGGGGG HHHHHHHH + bits: 01111110 11111110 11111110 11111110 11111110 11111110 11111110 11111111 + bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE FFFFFFFF GGGGGGGG HHHHHHHH - The 1-bits make sure that carries propagate to the next 0-bit. - The 0-bits provide holes for carries to fall into. + The 1-bits make sure that carries propagate to the next 0-bit. + The 0-bits provide holes for carries to fall into. */ private static final long HIMAGIC_FOR_BYTES = 0x8080_8080_8080_8080L; private static final long LOMAGIC_FOR_BYTES = 0x0101_0101_0101_0101L; - static boolean mightContainZeroByte(long l) { + private static boolean mightContainZeroByte(long l) { return ((l - LOMAGIC_FOR_BYTES) & (~l) & HIMAGIC_FOR_BYTES) != 0; } @@ -175,99 +253,40 @@ static boolean mightContainZeroShort(long l) { return ((l - LOMAGIC_FOR_SHORTS) & (~l) & HIMAGIC_FOR_SHORTS) != 0; } - static int requireWithinArraySize(long size) { - if (size > ArraysSupport.SOFT_MAX_ARRAY_LENGTH) { - throw newIaeStringTooLarge(); - } - return (int) size; - } - - static int bodyCount(long remaining) { - return (int) Math.min( - // Make sure we do not wrap around - Integer.MAX_VALUE - Long.BYTES, - // Remaining bytes to consider - remaining) - & -Long.BYTES; // Mask 0xFFFFFFF8 - } + private static final long HIMAGIC_FOR_INTS = 0x8000_0000_8000_0000L; + private static final long LOMAGIC_FOR_INTS = 0x0000_0001_0000_0001L; - private static int strlenByte(MemorySegment segment, long start) { - for (int offset = 0; offset < ArraysSupport.SOFT_MAX_ARRAY_LENGTH; offset += 1) { - byte curr = segment.get(JAVA_BYTE, start + offset); - if (curr == 0) { - return offset; - } - } - throw newIaeStringTooLarge(); + static boolean mightContainZeroInt(long l) { + return ((l - LOMAGIC_FOR_INTS) & (~l) & HIMAGIC_FOR_INTS) != 0; } - /** - * {@return the shortest distance beginning at the provided {@code start} - * to the encountering of a zero short in the provided {@code segment}} - *

      - * Note: The inspected region must be short aligned. - * - * @see #chunkedStrlenByte(MemorySegment, long) for more information - * - * @param segment to examine - * @param start from where examination shall begin - * @throws IllegalArgumentException if the examined region contains no zero shorts - * within a length that can be accepted by a String - */ - public static int chunkedStrlenShort(MemorySegment segment, long start) { - - // Handle the first unaligned "head" bytes separately - int headCount = (int)SharedUtils.remainsToAlignment(segment.address() + start, Long.BYTES); - int offset = 0; - for (; offset < headCount; offset += Short.BYTES) { - short curr = segment.get(JAVA_SHORT_UNALIGNED, start + offset); - if (curr == 0) { - return offset; - } - } - - // We are now on a long-aligned boundary so this is the "body" - int bodyCount = bodyCount(segment.byteSize() - start - headCount); - - for (; offset < bodyCount; offset += Long.BYTES) { - // We know we are `long` aligned so, we can save on alignment checking here - long curr = segment.get(JAVA_LONG_UNALIGNED, start + offset); - // Is this a candidate? - if (mightContainZeroShort(curr)) { - for (int j = 0; j < Long.BYTES; j += Short.BYTES) { - if (segment.get(JAVA_SHORT_UNALIGNED, start + offset + j) == 0) { - return offset + j; - } - } - } + private static int requireWithinStringSize(long size, + AbstractMemorySegmentImpl segment, + long fromOffset, + long toOffset) { + if (size > ArraysSupport.SOFT_MAX_ARRAY_LENGTH) { + throw stringTooLarge(segment, fromOffset, toOffset); } + return (int) size; + } - // Handle the "tail" - return requireWithinArraySize((long) offset + strlenShort(segment, start + offset)); + private static IllegalArgumentException stringTooLarge(AbstractMemorySegmentImpl segment, + long fromOffset, + long toOffset) { + return new IllegalArgumentException("String too large: " + exceptionInfo(segment, fromOffset, toOffset)); } - private static int strlenShort(MemorySegment segment, long start) { - for (int offset = 0; offset < ArraysSupport.SOFT_MAX_ARRAY_LENGTH; offset += Short.BYTES) { - short curr = segment.get(JAVA_SHORT_UNALIGNED, start + offset); - if (curr == (short)0) { - return offset; - } - } - throw newIaeStringTooLarge(); + private static IndexOutOfBoundsException nullNotFound(AbstractMemorySegmentImpl segment, + long fromOffset, + long toOffset) { + return new IndexOutOfBoundsException("No null terminator found: " + exceptionInfo(segment, fromOffset, toOffset)); } - // The gain of using `long` wide operations for `int` is lower than for the two other `byte` and `short` variants - // so, there is only one method for ints. - public static int strlenInt(MemorySegment segment, long start) { - for (int offset = 0; offset < ArraysSupport.SOFT_MAX_ARRAY_LENGTH; offset += Integer.BYTES) { - // We are guaranteed to be aligned here so, we can use unaligned access. - int curr = segment.get(JAVA_INT_UNALIGNED, start + offset); - if (curr == 0) { - return offset; - } - } - throw newIaeStringTooLarge(); + private static String exceptionInfo(AbstractMemorySegmentImpl segment, + long fromOffset, + long toOffset) { + return segment + " using region [" + fromOffset + ", " + toOffset + ")"; } public enum CharsetKind { @@ -323,9 +342,4 @@ public static int copyBytes(String string, MemorySegment segment, Charset charse public static void copyToSegmentRaw(String string, MemorySegment segment, long offset) { JAVA_LANG_ACCESS.copyToSegmentRaw(string, segment, offset); } - - private static IllegalArgumentException newIaeStringTooLarge() { - return new IllegalArgumentException("String too large"); - } - } diff --git a/test/jdk/java/foreign/TestStringEncoding.java b/test/jdk/java/foreign/TestStringEncoding.java index 4caef6fbd09b4..94732943b9d36 100644 --- a/test/jdk/java/foreign/TestStringEncoding.java +++ b/test/jdk/java/foreign/TestStringEncoding.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 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 @@ -39,6 +39,7 @@ import java.util.Random; import java.util.function.UnaryOperator; +import jdk.internal.foreign.AbstractMemorySegmentImpl; import jdk.internal.foreign.StringSupport; import org.testng.annotations.*; @@ -53,6 +54,20 @@ public class TestStringEncoding { + @Test + public void emptySegment() { + for (Charset charset : standardCharsets()) { + for (Arena arena : arenas()) { + try (arena) { + var segment = arena.allocate(0); + var e = expectThrows(IndexOutOfBoundsException.class, () -> + segment.getString(0, charset)); + assertTrue(e.getMessage().contains("No null terminator found")); + } + } + } + } + @Test(dataProvider = "strings") public void testStrings(String testString) { for (Charset charset : Charset.availableCharsets().values()) { @@ -87,7 +102,6 @@ public void testStrings(String testString) { } } - @Test(dataProvider = "strings") public void testStringsHeap(String testString) { for (Charset charset : singleByteCharsets()) { @@ -198,8 +212,9 @@ public void testOffset(String testString) { try (arena) { MemorySegment inSegment = arena.allocateFrom(testString, charset); for (int i = 0; i < 3; i++) { + String expected = testString.substring(i); String actual = inSegment.getString(i, charset); - assertEquals(actual, testString.substring(i)); + assertEquals(actual, expected); } } } @@ -249,6 +264,32 @@ public void segmentationFault() { } } + // This test ensures that we do not address outside the segment even though there + // are odd bytes at the end. + @Test(dataProvider = "strings") + public void offBoundaryTrailingBytes(String testString) { + if (testString.length() < 3 || !containsOnlyRegularCharacters(testString)) { + return; + } + for (var charset : standardCharsets()) { + for (var arena: arenas()) { + try (arena) { + MemorySegment strSegment = arena.allocateFrom(testString, charset); + // Add an odd byte at the end + MemorySegment inSegment = arena.allocate(strSegment.byteSize() + 1); + // Make sure there are no null-terminators so that we will try to scan + // the entire segment. + inSegment.fill((byte) 1); + for (int i = 0; i < 4; i++) { + final int offset = i; + var e = expectThrows(IndexOutOfBoundsException.class, () -> inSegment.getString(offset, charset)); + assertTrue(e.getMessage().contains("No null terminator found")); + } + } + } + } + } + private static final int TEST_LENGTH_MAX = 277; private Random deterministicRandom() { @@ -271,9 +312,15 @@ public void chunked_strlen_byte() { } segment.setAtIndex(JAVA_BYTE, len, (byte) 0); for (int j = 0; j < len; j++) { - int actual = StringSupport.chunkedStrlenByte(segment, j); + int actual = StringSupport.strlenByte((AbstractMemorySegmentImpl) segment, j, segment.byteSize()); assertEquals(actual, len - j); } + // Test end offset + for (int j = 0; j < len - 1; j++) { + final long toOffset = j; + expectThrows(IndexOutOfBoundsException.class, () -> + StringSupport.strlenByte((AbstractMemorySegmentImpl) segment, 0, toOffset)); + } } } } @@ -295,7 +342,7 @@ public void chunked_strlen_short() { } segment.setAtIndex(JAVA_SHORT, len, (short) 0); for (int j = 0; j < len; j++) { - int actual = StringSupport.chunkedStrlenShort(segment, j * Short.BYTES); + int actual = StringSupport.strlenShort((AbstractMemorySegmentImpl) segment, j * Short.BYTES, segment.byteSize()); assertEquals(actual, (len - j) * Short.BYTES); } } @@ -319,7 +366,7 @@ public void strlen_int() { } segment.setAtIndex(JAVA_INT, len, 0); for (int j = 0; j < len; j++) { - int actual = StringSupport.strlenInt(segment, j * Integer.BYTES); + int actual = StringSupport.strlenInt((AbstractMemorySegmentImpl) segment, j * Integer.BYTES, segment.byteSize()); assertEquals(actual, (len - j) * Integer.BYTES); } } diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/InternalStrLen.java b/test/micro/org/openjdk/bench/java/lang/foreign/InternalStrLen.java index 2db15bfe2652d..b7867efd77109 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/InternalStrLen.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/InternalStrLen.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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,6 +22,8 @@ */ package org.openjdk.bench.java.lang.foreign; +import jdk.internal.foreign.AbstractMemorySegmentImpl; +import jdk.internal.foreign.StringSupport; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; @@ -43,20 +45,20 @@ import java.util.stream.Stream; import static java.lang.foreign.ValueLayout.*; -import static jdk.internal.foreign.StringSupport.*; @BenchmarkMode(Mode.AverageTime) @Warmup(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(Scope.Benchmark) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3, jvmArgs = {"--add-exports=java.base/jdk.internal.foreign=ALL-UNNAMED", "--enable-native-access=ALL-UNNAMED", "--enable-preview"}) +@Fork(value = 3, jvmArgs = {"--add-exports=java.base/jdk.internal.foreign=ALL-UNNAMED", + "--enable-native-access=ALL-UNNAMED"}) public class InternalStrLen { - private MemorySegment singleByteSegment; - private MemorySegment singleByteSegmentMisaligned; - private MemorySegment doubleByteSegment; - private MemorySegment quadByteSegment; + private AbstractMemorySegmentImpl singleByteSegment; + private AbstractMemorySegmentImpl singleByteSegmentMisaligned; + private AbstractMemorySegmentImpl doubleByteSegment; + private AbstractMemorySegmentImpl quadByteSegment; @Param({"1", "4", "16", "251", "1024"}) int size; @@ -64,10 +66,9 @@ public class InternalStrLen { @Setup public void setup() { var arena = Arena.ofAuto(); - singleByteSegment = arena.allocate((size + 1L) * Byte.BYTES); - singleByteSegmentMisaligned = arena.allocate((size + 1L) * Byte.BYTES); - doubleByteSegment = arena.allocate((size + 1L) * Short.BYTES); - quadByteSegment = arena.allocate((size + 1L) * Integer.BYTES); + singleByteSegment = (AbstractMemorySegmentImpl) arena.allocate((size + 1L) * Byte.BYTES); + doubleByteSegment = (AbstractMemorySegmentImpl) arena.allocate((size + 1L) * Short.BYTES); + quadByteSegment = (AbstractMemorySegmentImpl) arena.allocate((size + 1L) * Integer.BYTES); Stream.of(singleByteSegment, doubleByteSegment, quadByteSegment) .forEach(s -> IntStream.range(0, (int) s.byteSize() - 1) .forEach(i -> s.set( @@ -78,7 +79,7 @@ public void setup() { singleByteSegment.set(ValueLayout.JAVA_BYTE, singleByteSegment.byteSize() - Byte.BYTES, (byte) 0); doubleByteSegment.set(ValueLayout.JAVA_SHORT, doubleByteSegment.byteSize() - Short.BYTES, (short) 0); quadByteSegment.set(ValueLayout.JAVA_INT, quadByteSegment.byteSize() - Integer.BYTES, 0); - singleByteSegmentMisaligned = arena.allocate(singleByteSegment.byteSize() + 1). + singleByteSegmentMisaligned = (AbstractMemorySegmentImpl) arena.allocate(singleByteSegment.byteSize() + 1). asSlice(1); MemorySegment.copy(singleByteSegment, 0, singleByteSegmentMisaligned, 0, singleByteSegment.byteSize()); } @@ -105,22 +106,22 @@ public int elementQuad() { @Benchmark public int chunkedSingle() { - return chunkedStrlenByte(singleByteSegment, 0); + return StringSupport.strlenByte(singleByteSegment, 0, singleByteSegment.byteSize()); } @Benchmark public int chunkedSingleMisaligned() { - return chunkedStrlenByte(singleByteSegmentMisaligned, 0); + return StringSupport.strlenByte(singleByteSegmentMisaligned, 0, singleByteSegment.byteSize()); } @Benchmark public int chunkedDouble() { - return chunkedStrlenShort(doubleByteSegment, 0); + return StringSupport.strlenShort(doubleByteSegment, 0, doubleByteSegment.byteSize()); } @Benchmark public int changedElementQuad() { - return strlenInt(quadByteSegment, 0); + return StringSupport.strlenInt(quadByteSegment, 0, quadByteSegment.byteSize()); } // These are the legacy methods From c330b90b9f43f80c322153585fa78704358f0224 Mon Sep 17 00:00:00 2001 From: Nizar Benalla Date: Tue, 3 Dec 2024 09:06:07 +0000 Subject: [PATCH 19/62] 8343780: Add since checker tests to the Tools area modules and add missing @since to jdk.jfr Reviewed-by: cstein, egahlin --- .../share/classes/jdk/jfr/Recording.java | 1 + .../JavaScriptingCheckSince.java | 30 +++++++++++++++++++ .../jdk.dynalink/JdkDynalinkCheckSince.java | 30 +++++++++++++++++++ .../jdk.jartool/JdkJartoolCheckSince.java | 30 +++++++++++++++++++ .../modules/jdk.jlink/JdkJlinkCheckSince.java | 30 +++++++++++++++++++ .../jdk.jsobject/JdkJsobjectCheckSince.java | 30 +++++++++++++++++++ 6 files changed, 151 insertions(+) create mode 100644 test/jdk/tools/sincechecker/modules/java.scripting/JavaScriptingCheckSince.java create mode 100644 test/jdk/tools/sincechecker/modules/jdk.dynalink/JdkDynalinkCheckSince.java create mode 100644 test/jdk/tools/sincechecker/modules/jdk.jartool/JdkJartoolCheckSince.java create mode 100644 test/jdk/tools/sincechecker/modules/jdk.jlink/JdkJlinkCheckSince.java create mode 100644 test/jdk/tools/sincechecker/modules/jdk.jsobject/JdkJsobjectCheckSince.java diff --git a/src/jdk.jfr/share/classes/jdk/jfr/Recording.java b/src/jdk.jfr/share/classes/jdk/jfr/Recording.java index f1dcadf8b6818..6168ddb28329f 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/Recording.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/Recording.java @@ -97,6 +97,7 @@ public Map toMap() { * support, or if the file repository can't be created or accessed) * * @see jdk.jfr + * @since 11 */ public Recording(Map settings) { Objects.requireNonNull(settings, "settings"); diff --git a/test/jdk/tools/sincechecker/modules/java.scripting/JavaScriptingCheckSince.java b/test/jdk/tools/sincechecker/modules/java.scripting/JavaScriptingCheckSince.java new file mode 100644 index 0000000000000..06458b07907e4 --- /dev/null +++ b/test/jdk/tools/sincechecker/modules/java.scripting/JavaScriptingCheckSince.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 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 8343780 + * @summary Test for `@since` in java.scripting module + * @library /test/lib /test/jdk/tools/sincechecker + * @run main SinceChecker java.scripting + */ diff --git a/test/jdk/tools/sincechecker/modules/jdk.dynalink/JdkDynalinkCheckSince.java b/test/jdk/tools/sincechecker/modules/jdk.dynalink/JdkDynalinkCheckSince.java new file mode 100644 index 0000000000000..5d38713eb0a79 --- /dev/null +++ b/test/jdk/tools/sincechecker/modules/jdk.dynalink/JdkDynalinkCheckSince.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 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 8343780 + * @summary Test for `@since` in jdk.dynalik module + * @library /test/lib /test/jdk/tools/sincechecker + * @run main SinceChecker jdk.dynalink + */ diff --git a/test/jdk/tools/sincechecker/modules/jdk.jartool/JdkJartoolCheckSince.java b/test/jdk/tools/sincechecker/modules/jdk.jartool/JdkJartoolCheckSince.java new file mode 100644 index 0000000000000..628aa8d2f34c8 --- /dev/null +++ b/test/jdk/tools/sincechecker/modules/jdk.jartool/JdkJartoolCheckSince.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 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 8343780 + * @summary Test for `@since` in jdk.jartool module + * @library /test/lib /test/jdk/tools/sincechecker + * @run main SinceChecker jdk.jartool + */ diff --git a/test/jdk/tools/sincechecker/modules/jdk.jlink/JdkJlinkCheckSince.java b/test/jdk/tools/sincechecker/modules/jdk.jlink/JdkJlinkCheckSince.java new file mode 100644 index 0000000000000..effeb778a3adb --- /dev/null +++ b/test/jdk/tools/sincechecker/modules/jdk.jlink/JdkJlinkCheckSince.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 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 8343780 + * @summary Test for `@since` in jdk.jlink module + * @library /test/lib /test/jdk/tools/sincechecker + * @run main SinceChecker jdk.jlink + */ diff --git a/test/jdk/tools/sincechecker/modules/jdk.jsobject/JdkJsobjectCheckSince.java b/test/jdk/tools/sincechecker/modules/jdk.jsobject/JdkJsobjectCheckSince.java new file mode 100644 index 0000000000000..705c7259b71db --- /dev/null +++ b/test/jdk/tools/sincechecker/modules/jdk.jsobject/JdkJsobjectCheckSince.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 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 8343780 + * @summary Test for `@since` in jdk.jsobject module + * @library /test/lib /test/jdk/tools/sincechecker + * @run main SinceChecker jdk.jsobject + */ From ec93cc50988c4bd58bf599e007d09824702720b2 Mon Sep 17 00:00:00 2001 From: Aggelos Biboudis Date: Tue, 3 Dec 2024 09:18:58 +0000 Subject: [PATCH 20/62] 8343932: Error when parsing qualified generic type test pattern in switch Reviewed-by: jlahoda --- .../sun/tools/javac/parser/JavacParser.java | 2 +- .../tools/javac/patterns/T8343932.java | 57 +++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 test/langtools/tools/javac/patterns/T8343932.java diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java index c55c2db98def9..a02945dee3c49 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java @@ -3428,7 +3428,7 @@ PatternResult analyzePattern(int lookahead) { case GTGT: typeDepth--; case GT: typeDepth--; - if (typeDepth == 0) { + if (typeDepth == 0 && !peekToken(lookahead, DOT)) { return peekToken(lookahead, LAX_IDENTIFIER) || peekToken(lookahead, tk -> tk == LPAREN) ? PatternResult.PATTERN : PatternResult.EXPRESSION; diff --git a/test/langtools/tools/javac/patterns/T8343932.java b/test/langtools/tools/javac/patterns/T8343932.java new file mode 100644 index 0000000000000..346d0d6f79c2a --- /dev/null +++ b/test/langtools/tools/javac/patterns/T8343932.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 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 8343932 + * @summary Error when parsing qualified generic type test pattern in switch + * @compile T8343932.java + */ +public class T8343932 { + abstract sealed class J permits X.S, A {} + final class A extends J {} + + public class X { + final class S extends J { + abstract sealed class J permits XX.SS, AA {} + final class AA extends J {} + + public class XX { + final class SS extends J {} + } + } + + static int test(J ji) { + return switch (ji) { + case A a -> 42; + case X.S e -> 4200; // level 1 + }; + } + + static int test(X.S.J ji) { + return switch (ji) { + case X.S.AA a -> 42; + case X.S.XX.SS e -> 4200; // level 2 + }; + } + } +} \ No newline at end of file From 077b8422bb5bf70fb6201b71911741e2aff9a520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eirik=20Bj=C3=B8rsn=C3=B8s?= Date: Tue, 3 Dec 2024 09:53:37 +0000 Subject: [PATCH 21/62] 8345074: java.net.InterfaceAddress constructor could be made private Reviewed-by: jpai --- src/java.base/share/classes/java/net/InterfaceAddress.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/java.base/share/classes/java/net/InterfaceAddress.java b/src/java.base/share/classes/java/net/InterfaceAddress.java index f5b76ec9f90ce..979ed9cc7f53f 100644 --- a/src/java.base/share/classes/java/net/InterfaceAddress.java +++ b/src/java.base/share/classes/java/net/InterfaceAddress.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -42,10 +42,9 @@ public class InterfaceAddress { private short maskLength = 0; /* - * Package private constructor. Can't be built directly, instances are - * obtained through the NetworkInterface class. + * This constructor is called via JNI in NetworkInterface.c */ - InterfaceAddress() { + private InterfaceAddress() { } /** From 63af2f42b7abe9504897d7c3f3b4cc0b57123694 Mon Sep 17 00:00:00 2001 From: Axel Boldt-Christmas Date: Tue, 3 Dec 2024 10:42:23 +0000 Subject: [PATCH 22/62] 8344414: ZGC: Another division by zero in rule_major_allocation_rate Reviewed-by: eosterlund, stefank --- src/hotspot/share/gc/z/zDirector.cpp | 33 +++++++++++++++++----------- src/hotspot/share/gc/z/zStat.cpp | 7 ++++-- src/hotspot/share/gc/z/zStat.hpp | 4 ++-- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/hotspot/share/gc/z/zDirector.cpp b/src/hotspot/share/gc/z/zDirector.cpp index 3c0cb660206a2..48e426f068aa6 100644 --- a/src/hotspot/share/gc/z/zDirector.cpp +++ b/src/hotspot/share/gc/z/zDirector.cpp @@ -33,6 +33,8 @@ #include "gc/z/zStat.hpp" #include "logging/log.hpp" +#include + ZDirector* ZDirector::_director; constexpr double one_in_1000 = 3.290527; @@ -453,16 +455,22 @@ static double calculate_extra_young_gc_time(const ZDirectorStats& stats) { // relocation headroom into account to avoid in-place relocation. const size_t old_used = stats._old_stats._general._used; const size_t old_live = stats._old_stats._stat_heap._live_at_mark_end; - const size_t old_garbage = old_used - old_live; + const double old_garbage = double(old_used - old_live); const double young_gc_time = gc_time(stats._young_stats); // Calculate how much memory young collections are predicted to free. - const size_t reclaimed_per_young_gc = stats._young_stats._stat_heap._reclaimed_avg; + const double reclaimed_per_young_gc = stats._young_stats._stat_heap._reclaimed_avg; // Calculate current YC time and predicted YC time after an old collection. - const double current_young_gc_time_per_bytes_freed = double(young_gc_time) / double(reclaimed_per_young_gc); - const double potential_young_gc_time_per_bytes_freed = double(young_gc_time) / double(reclaimed_per_young_gc + old_garbage); + const double current_young_gc_time_per_bytes_freed = young_gc_time / reclaimed_per_young_gc; + const double potential_young_gc_time_per_bytes_freed = young_gc_time / (reclaimed_per_young_gc + old_garbage); + + if (current_young_gc_time_per_bytes_freed == std::numeric_limits::infinity()) { + // Young collection's are not reclaiming any memory. Return infinity as a signal + // to trigger an old collection, regardless of the amount of old garbage. + return std::numeric_limits::infinity(); + } // Calculate extra time per young collection inflicted by *not* doing an // old collection that frees up memory in the old generation. @@ -483,13 +491,12 @@ static bool rule_major_allocation_rate(const ZDirectorStats& stats) { const double young_gc_time = gc_time(stats._young_stats); // Calculate how much memory collections are predicted to free. - const size_t reclaimed_per_young_gc = stats._young_stats._stat_heap._reclaimed_avg; - const size_t reclaimed_per_old_gc = stats._old_stats._stat_heap._reclaimed_avg; + const double reclaimed_per_young_gc = stats._young_stats._stat_heap._reclaimed_avg; + const double reclaimed_per_old_gc = stats._old_stats._stat_heap._reclaimed_avg; // Calculate the GC cost for each reclaimed byte - const double current_young_gc_time_per_bytes_freed = double(young_gc_time) / double(reclaimed_per_young_gc); - const double current_old_gc_time_per_bytes_freed = reclaimed_per_old_gc == 0 ? std::numeric_limits::infinity() - : (double(old_gc_time) / double(reclaimed_per_old_gc)); + const double current_young_gc_time_per_bytes_freed = young_gc_time / reclaimed_per_young_gc; + const double current_old_gc_time_per_bytes_freed = old_gc_time / reclaimed_per_old_gc; // Calculate extra time per young collection inflicted by *not* doing an // old collection that frees up memory in the old generation. @@ -531,10 +538,10 @@ static double calculate_young_to_old_worker_ratio(const ZDirectorStats& stats) { const double young_gc_time = gc_time(stats._young_stats); const double old_gc_time = gc_time(stats._old_stats); - const size_t reclaimed_per_young_gc = stats._young_stats._stat_heap._reclaimed_avg; - const size_t reclaimed_per_old_gc = stats._old_stats._stat_heap._reclaimed_avg; - const double current_young_bytes_freed_per_gc_time = double(reclaimed_per_young_gc) / double(young_gc_time); - const double current_old_bytes_freed_per_gc_time = double(reclaimed_per_old_gc) / double(old_gc_time); + const double reclaimed_per_young_gc = stats._young_stats._stat_heap._reclaimed_avg; + const double reclaimed_per_old_gc = stats._old_stats._stat_heap._reclaimed_avg; + const double current_young_bytes_freed_per_gc_time = reclaimed_per_young_gc / young_gc_time; + const double current_old_bytes_freed_per_gc_time = reclaimed_per_old_gc / old_gc_time; if (current_young_bytes_freed_per_gc_time == 0.0) { if (current_old_bytes_freed_per_gc_time == 0.0) { diff --git a/src/hotspot/share/gc/z/zStat.cpp b/src/hotspot/share/gc/z/zStat.cpp index 56b3590960f7c..96cfa7d3a3718 100644 --- a/src/hotspot/share/gc/z/zStat.cpp +++ b/src/hotspot/share/gc/z/zStat.cpp @@ -46,6 +46,8 @@ #include "utilities/debug.hpp" #include "utilities/ticks.hpp" +#include + #define ZSIZE_FMT SIZE_FORMAT "M(%.0f%%)" #define ZSIZE_ARGS_WITH_MAX(size, max) ((size) / M), (percent_of(size, max)) #define ZSIZE_ARGS(size) ZSIZE_ARGS_WITH_MAX(size, ZStatHeap::max_capacity()) @@ -1849,8 +1851,9 @@ void ZStatHeap::at_relocate_end(const ZPageAllocatorStats& stats, bool record_st } } -size_t ZStatHeap::reclaimed_avg() { - return (size_t)_reclaimed_bytes.davg(); +double ZStatHeap::reclaimed_avg() { + // Make sure the reclaimed average is greater than 0.0 to avoid division by zero. + return _reclaimed_bytes.davg() + std::numeric_limits::denorm_min(); } size_t ZStatHeap::max_capacity() { diff --git a/src/hotspot/share/gc/z/zStat.hpp b/src/hotspot/share/gc/z/zStat.hpp index d7fff6d7b8e13..d169385791890 100644 --- a/src/hotspot/share/gc/z/zStat.hpp +++ b/src/hotspot/share/gc/z/zStat.hpp @@ -588,7 +588,7 @@ class ZStatReferences : public AllStatic { struct ZStatHeapStats { size_t _live_at_mark_end; size_t _used_at_relocate_end; - size_t _reclaimed_avg; + double _reclaimed_avg; }; // @@ -699,7 +699,7 @@ class ZStatHeap { size_t stalls_at_relocate_start() const; size_t stalls_at_relocate_end() const; - size_t reclaimed_avg(); + double reclaimed_avg(); ZStatHeapStats stats(); From 8cad0431ff17992fadbb593319ad3821b32e3b7e Mon Sep 17 00:00:00 2001 From: Jorn Vernee Date: Tue, 3 Dec 2024 12:28:17 +0000 Subject: [PATCH 23/62] 8336768: Allow captureCallState and critical linker options to be combined Reviewed-by: mcimadamore --- .../classes/java/lang/foreign/Linker.java | 2 - .../internal/foreign/abi/CallingSequence.java | 6 +- .../foreign/abi/CallingSequenceBuilder.java | 15 +++- .../internal/foreign/abi/DowncallLinker.java | 3 +- .../internal/foreign/abi/LinkerOptions.java | 6 +- .../foreign/abi/NativeEntryPoint.java | 31 +++++-- .../foreign/abi/fallback/FallbackLinker.java | 9 +- .../foreign/abi/fallback/LibFallback.java | 5 +- .../native/libfallbackLinker/fallbackLinker.c | 26 ++++-- test/jdk/java/foreign/TestIllegalLink.java | 5 -- .../TestCaptureCallState.java | 83 ++++++++++++------- .../java/foreign/critical/TestCritical.java | 56 ++++++++----- test/jdk/java/foreign/critical/libCritical.c | 5 ++ .../passheapsegment/TestPassHeapSegment.java | 16 +++- 14 files changed, 180 insertions(+), 88 deletions(-) diff --git a/src/java.base/share/classes/java/lang/foreign/Linker.java b/src/java.base/share/classes/java/lang/foreign/Linker.java index bfa205e2fadf3..c8e4cf4746b69 100644 --- a/src/java.base/share/classes/java/lang/foreign/Linker.java +++ b/src/java.base/share/classes/java/lang/foreign/Linker.java @@ -852,8 +852,6 @@ static Option firstVariadicArg(int index) { * // use errno * } * } - *

      - * This linker option can not be combined with {@link #critical}. * * @param capturedState the names of the values to save * @throws IllegalArgumentException if at least one of the provided diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/CallingSequence.java b/src/java.base/share/classes/jdk/internal/foreign/abi/CallingSequence.java index e301f6921678e..5aad4ccc890dc 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/CallingSequence.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/CallingSequence.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -195,6 +195,10 @@ public boolean needsTransition() { return !linkerOptions.isCritical(); } + public boolean usingAddressPairs() { + return linkerOptions.allowsHeapAccess(); + } + public int numLeadingParams() { return 2 + (linkerOptions.hasCapturedCallState() ? 1 : 0); // 2 for addr, allocator } diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/CallingSequenceBuilder.java b/src/java.base/share/classes/jdk/internal/foreign/abi/CallingSequenceBuilder.java index f24de62c807a4..a03c20d317349 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/CallingSequenceBuilder.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/CallingSequenceBuilder.java @@ -108,9 +108,18 @@ public CallingSequence build() { MethodType calleeMethodType; if (!forUpcall) { if (linkerOptions.hasCapturedCallState()) { - addArgumentBinding(0, MemorySegment.class, ValueLayout.ADDRESS, List.of( - Binding.unboxAddress(), - Binding.vmStore(abi.capturedStateStorage(), long.class))); + if (linkerOptions.allowsHeapAccess()) { + addArgumentBinding(0, MemorySegment.class, ValueLayout.ADDRESS, List.of( + Binding.dup(), + Binding.segmentBase(), + Binding.vmStore(abi.capturedStateStorage(), Object.class), + Binding.segmentOffsetAllowHeap(), + Binding.vmStore(null, long.class))); + } else { + addArgumentBinding(0, MemorySegment.class, ValueLayout.ADDRESS, List.of( + Binding.unboxAddress(), + Binding.vmStore(abi.capturedStateStorage(), long.class))); + } } addArgumentBinding(0, MemorySegment.class, ValueLayout.ADDRESS, List.of( Binding.unboxAddress(), diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/DowncallLinker.java b/src/java.base/share/classes/jdk/internal/foreign/abi/DowncallLinker.java index 627de9f076562..2df30edb32626 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/DowncallLinker.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/DowncallLinker.java @@ -84,7 +84,8 @@ public MethodHandle getBoundMethodHandle() { leafType, callingSequence.needsReturnBuffer(), callingSequence.capturedStateMask(), - callingSequence.needsTransition() + callingSequence.needsTransition(), + callingSequence.usingAddressPairs() ); MethodHandle handle = JLIA.nativeMethodHandle(nep); diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/LinkerOptions.java b/src/java.base/share/classes/jdk/internal/foreign/abi/LinkerOptions.java index fcc98ecccc071..9a19b5a8511aa 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/LinkerOptions.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/LinkerOptions.java @@ -63,11 +63,7 @@ private static LinkerOptions forShared(BiConsumer 1 != needsReturnBuffer) { throw new AssertionError("Multiple register return, but needsReturnBuffer was false"); } - checkType(methodType, needsReturnBuffer, capturedStateMask); + checkMethodType(methodType, needsReturnBuffer, capturedStateMask, usingAddressPairs); CacheKey key = new CacheKey(methodType, abi, Arrays.asList(argMoves), Arrays.asList(returnMoves), needsReturnBuffer, capturedStateMask, needsTransition); @@ -80,14 +81,26 @@ public static NativeEntryPoint make(ABIDescriptor abi, }); } - private static void checkType(MethodType methodType, boolean needsReturnBuffer, int savedValueMask) { - if (methodType.parameterType(0) != long.class) { - throw new AssertionError("Address expected as first param: " + methodType); + private static void checkMethodType(MethodType methodType, boolean needsReturnBuffer, int savedValueMask, + boolean usingAddressPairs) { + int checkIdx = 0; + checkParamType(methodType, checkIdx++, long.class, "Function address"); + if (needsReturnBuffer) { + checkParamType(methodType, checkIdx++, long.class, "Return buffer address"); } - int checkIdx = 1; - if ((needsReturnBuffer && methodType.parameterType(checkIdx++) != long.class) - || (savedValueMask != 0 && methodType.parameterType(checkIdx) != long.class)) { - throw new AssertionError("return buffer and/or preserved value address expected: " + methodType); + if (savedValueMask != 0) { // capturing call state + if (usingAddressPairs) { + checkParamType(methodType, checkIdx++, Object.class, "Capture state heap base"); + checkParamType(methodType, checkIdx, long.class, "Capture state offset"); + } else { + checkParamType(methodType, checkIdx, long.class, "Capture state address"); + } + } + } + + private static void checkParamType(MethodType methodType, int checkIdx, Class expectedType, String name) { + if (methodType.parameterType(checkIdx) != expectedType) { + throw new AssertionError(name + " expected at index " + checkIdx + ": " + methodType); } } diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/FallbackLinker.java b/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/FallbackLinker.java index ad5e4b97175fb..54906d9fef2ed 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/FallbackLinker.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/FallbackLinker.java @@ -163,8 +163,14 @@ private static Object doDowncall(SegmentAllocator returnAllocator, Object[] args acquiredSessions.add(targetImpl); MemorySegment capturedState = null; + Object captureStateHeapBase = null; if (invData.capturedStateMask() != 0) { capturedState = SharedUtils.checkCaptureSegment((MemorySegment) args[argStart++]); + if (!invData.allowsHeapAccess) { + SharedUtils.checkNative(capturedState); + } else { + captureStateHeapBase = capturedState.heapBase().orElse(null); + } MemorySessionImpl capturedStateImpl = ((AbstractMemorySegmentImpl) capturedState).sessionImpl(); capturedStateImpl.acquire0(); acquiredSessions.add(capturedStateImpl); @@ -199,7 +205,8 @@ private static Object doDowncall(SegmentAllocator returnAllocator, Object[] args retSeg = (invData.returnLayout() instanceof GroupLayout ? returnAllocator : arena).allocate(invData.returnLayout); } - LibFallback.doDowncall(invData.cif, target, retSeg, argPtrs, capturedState, invData.capturedStateMask(), + LibFallback.doDowncall(invData.cif, target, retSeg, argPtrs, + captureStateHeapBase, capturedState, invData.capturedStateMask(), heapBases, args.length); Reference.reachabilityFence(invData.cif()); diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/LibFallback.java b/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/LibFallback.java index b68b1ed4bad6d..6fe8dd5f91ccf 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/LibFallback.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/LibFallback.java @@ -90,10 +90,11 @@ private static boolean tryLoadLibrary() { * @see jdk.internal.foreign.abi.CapturableState */ static void doDowncall(MemorySegment cif, MemorySegment target, MemorySegment retPtr, MemorySegment argPtrs, - MemorySegment capturedState, int capturedStateMask, + Object captureStateHeapBase, MemorySegment capturedState, int capturedStateMask, Object[] heapBases, int numArgs) { doDowncall(cif.address(), target.address(), retPtr == null ? 0 : retPtr.address(), argPtrs.address(), + captureStateHeapBase, capturedState == null ? 0 : capturedState.address(), capturedStateMask, heapBases, numArgs); } @@ -212,7 +213,7 @@ private static void checkStatus(int code) { private static native int createClosure(long cif, Object userData, long[] ptrs); private static native void freeClosure(long closureAddress, long globalTarget); private static native void doDowncall(long cif, long fn, long rvalue, long avalues, - long capturedState, int capturedStateMask, + Object captureStateHeapBase, long capturedState, int capturedStateMask, Object[] heapBases, int numArgs); private static native int ffi_prep_cif(long cif, int abi, int nargs, long rtype, long atypes); diff --git a/src/java.base/share/native/libfallbackLinker/fallbackLinker.c b/src/java.base/share/native/libfallbackLinker/fallbackLinker.c index 2ee64fb05bc7a..1548fb49e268b 100644 --- a/src/java.base/share/native/libfallbackLinker/fallbackLinker.c +++ b/src/java.base/share/native/libfallbackLinker/fallbackLinker.c @@ -112,12 +112,16 @@ static void do_capture_state(int32_t* value_ptr, int captured_state_mask) { JNIEXPORT void JNICALL Java_jdk_internal_foreign_abi_fallback_LibFallback_doDowncall(JNIEnv* env, jclass cls, jlong cif, jlong fn, jlong rvalue, - jlong avalues, jlong jcaptured_state, jint captured_state_mask, + jlong avalues, + jarray capture_state_heap_base, jlong captured_state_offset, + jint captured_state_mask, jarray heapBases, jint numArgs) { void** carrays; + int capture_state_hb_offset = numArgs; + int32_t* captured_state_addr = jlong_to_ptr(captured_state_offset); if (heapBases != NULL) { void** aptrs = jlong_to_ptr(avalues); - carrays = malloc(sizeof(void*) * numArgs); + carrays = malloc(sizeof(void*) * (numArgs + 1)); for (int i = 0; i < numArgs; i++) { jarray hb = (jarray) (*env)->GetObjectArrayElement(env, heapBases, i); if (hb != NULL) { @@ -130,10 +134,20 @@ Java_jdk_internal_foreign_abi_fallback_LibFallback_doDowncall(JNIEnv* env, jclas *((void**)aptrs[i]) = arrayPtr + offset; } } + if (capture_state_heap_base != NULL) { + jboolean isCopy; + jbyte* arrayPtr = (*env)->GetPrimitiveArrayCritical(env, capture_state_heap_base, &isCopy); + carrays[capture_state_hb_offset] = arrayPtr; + captured_state_addr = (int32_t*) (arrayPtr + captured_state_offset); + } } ffi_call(jlong_to_ptr(cif), jlong_to_ptr(fn), jlong_to_ptr(rvalue), jlong_to_ptr(avalues)); + if (captured_state_mask != 0) { + do_capture_state(captured_state_addr, captured_state_mask); + } + if (heapBases != NULL) { for (int i = 0; i < numArgs; i++) { jarray hb = (jarray) (*env)->GetObjectArrayElement(env, heapBases, i); @@ -141,13 +155,11 @@ Java_jdk_internal_foreign_abi_fallback_LibFallback_doDowncall(JNIEnv* env, jclas (*env)->ReleasePrimitiveArrayCritical(env, hb, carrays[i], JNI_COMMIT); } } + if (capture_state_heap_base != NULL) { + (*env)->ReleasePrimitiveArrayCritical(env, capture_state_heap_base, carrays[capture_state_hb_offset], JNI_COMMIT); + } free(carrays); } - - if (captured_state_mask != 0) { - int32_t* captured_state = jlong_to_ptr(jcaptured_state); - do_capture_state(captured_state, captured_state_mask); - } } static void do_upcall(ffi_cif* cif, void* ret, void** args, void* user_data) { diff --git a/test/jdk/java/foreign/TestIllegalLink.java b/test/jdk/java/foreign/TestIllegalLink.java index b5052b4346c7e..2a9d5ad37826d 100644 --- a/test/jdk/java/foreign/TestIllegalLink.java +++ b/test/jdk/java/foreign/TestIllegalLink.java @@ -192,11 +192,6 @@ public static Object[][] types() { NO_OPTIONS, "has unexpected size" }, - { - FunctionDescriptor.ofVoid(), - new Linker.Option[]{Linker.Option.critical(false), Linker.Option.captureCallState("errno")}, - "Incompatible linker options: captureCallState, critical" - }, })); for (ValueLayout illegalLayout : List.of(C_CHAR, ValueLayout.JAVA_CHAR, C_BOOL, C_SHORT, C_FLOAT)) { diff --git a/test/jdk/java/foreign/capturecallstate/TestCaptureCallState.java b/test/jdk/java/foreign/capturecallstate/TestCaptureCallState.java index 51c91ce0f961a..a1bf1183fb59a 100644 --- a/test/jdk/java/foreign/capturecallstate/TestCaptureCallState.java +++ b/test/jdk/java/foreign/capturecallstate/TestCaptureCallState.java @@ -61,12 +61,18 @@ public class TestCaptureCallState extends NativeTestHelper { } } - private record SaveValuesCase(String nativeTarget, FunctionDescriptor nativeDesc, String threadLocalName, Consumer resultCheck) {} + private record SaveValuesCase(String nativeTarget, FunctionDescriptor nativeDesc, String threadLocalName, + Consumer resultCheck, boolean critical) {} @Test(dataProvider = "cases") public void testSavedThreadLocal(SaveValuesCase testCase) throws Throwable { - Linker.Option stl = Linker.Option.captureCallState(testCase.threadLocalName()); - MethodHandle handle = downcallHandle(testCase.nativeTarget(), testCase.nativeDesc(), stl); + List options = new ArrayList<>(); + options.add(Linker.Option.captureCallState(testCase.threadLocalName())); + if (testCase.critical()) { + options.add(Linker.Option.critical(false)); + } + MethodHandle handle = downcallHandle(testCase.nativeTarget(), testCase.nativeDesc(), + options.toArray(Linker.Option[]::new)); StructLayout capturedStateLayout = Linker.Option.captureStateLayout(); VarHandle errnoHandle = capturedStateLayout.varHandle(groupElement(testCase.threadLocalName())); @@ -86,9 +92,14 @@ public void testSavedThreadLocal(SaveValuesCase testCase) throws Throwable { @Test(dataProvider = "invalidCaptureSegmentCases") public void testInvalidCaptureSegment(MemorySegment captureSegment, - Class expectedExceptionType, String expectedExceptionMessage) { - Linker.Option stl = Linker.Option.captureCallState("errno"); - MethodHandle handle = downcallHandle("set_errno_V", FunctionDescriptor.ofVoid(C_INT), stl); + Class expectedExceptionType, String expectedExceptionMessage, + Linker.Option[] extraOptions) { + List options = new ArrayList<>(); + options.add(Linker.Option.captureCallState("errno")); + for (Linker.Option extra : extraOptions) { + options.add(extra); + } + MethodHandle handle = downcallHandle("set_errno_V", FunctionDescriptor.ofVoid(C_INT), options.toArray(Linker.Option[]::new)); try { int testValue = 42; @@ -103,32 +114,39 @@ public void testInvalidCaptureSegment(MemorySegment captureSegment, public static Object[][] cases() { List cases = new ArrayList<>(); - cases.add(new SaveValuesCase("set_errno_V", FunctionDescriptor.ofVoid(JAVA_INT), "errno", o -> {})); - cases.add(new SaveValuesCase("set_errno_I", FunctionDescriptor.of(JAVA_INT, JAVA_INT), "errno", o -> assertEquals((int) o, 42))); - cases.add(new SaveValuesCase("set_errno_D", FunctionDescriptor.of(JAVA_DOUBLE, JAVA_INT), "errno", o -> assertEquals((double) o, 42.0))); - - cases.add(structCase("SL", Map.of(JAVA_LONG.withName("x"), 42L))); - cases.add(structCase("SLL", Map.of(JAVA_LONG.withName("x"), 42L, - JAVA_LONG.withName("y"), 42L))); - cases.add(structCase("SLLL", Map.of(JAVA_LONG.withName("x"), 42L, - JAVA_LONG.withName("y"), 42L, - JAVA_LONG.withName("z"), 42L))); - cases.add(structCase("SD", Map.of(JAVA_DOUBLE.withName("x"), 42D))); - cases.add(structCase("SDD", Map.of(JAVA_DOUBLE.withName("x"), 42D, - JAVA_DOUBLE.withName("y"), 42D))); - cases.add(structCase("SDDD", Map.of(JAVA_DOUBLE.withName("x"), 42D, - JAVA_DOUBLE.withName("y"), 42D, - JAVA_DOUBLE.withName("z"), 42D))); - - if (IS_WINDOWS) { - cases.add(new SaveValuesCase("SetLastError", FunctionDescriptor.ofVoid(JAVA_INT), "GetLastError", o -> {})); - cases.add(new SaveValuesCase("WSASetLastError", FunctionDescriptor.ofVoid(JAVA_INT), "WSAGetLastError", o -> {})); + for (boolean critical : new boolean[]{ true, false }) { + cases.add(new SaveValuesCase("set_errno_V", FunctionDescriptor.ofVoid(JAVA_INT), + "errno", o -> {}, critical)); + cases.add(new SaveValuesCase("set_errno_I", FunctionDescriptor.of(JAVA_INT, JAVA_INT), + "errno", o -> assertEquals((int) o, 42), critical)); + cases.add(new SaveValuesCase("set_errno_D", FunctionDescriptor.of(JAVA_DOUBLE, JAVA_INT), + "errno", o -> assertEquals((double) o, 42.0), critical)); + + cases.add(structCase("SL", Map.of(JAVA_LONG.withName("x"), 42L), critical)); + cases.add(structCase("SLL", Map.of(JAVA_LONG.withName("x"), 42L, + JAVA_LONG.withName("y"), 42L), critical)); + cases.add(structCase("SLLL", Map.of(JAVA_LONG.withName("x"), 42L, + JAVA_LONG.withName("y"), 42L, + JAVA_LONG.withName("z"), 42L), critical)); + cases.add(structCase("SD", Map.of(JAVA_DOUBLE.withName("x"), 42D), critical)); + cases.add(structCase("SDD", Map.of(JAVA_DOUBLE.withName("x"), 42D, + JAVA_DOUBLE.withName("y"), 42D), critical)); + cases.add(structCase("SDDD", Map.of(JAVA_DOUBLE.withName("x"), 42D, + JAVA_DOUBLE.withName("y"), 42D, + JAVA_DOUBLE.withName("z"), 42D), critical)); + + if (IS_WINDOWS) { + cases.add(new SaveValuesCase("SetLastError", FunctionDescriptor.ofVoid(JAVA_INT), + "GetLastError", o -> {}, critical)); + cases.add(new SaveValuesCase("WSASetLastError", FunctionDescriptor.ofVoid(JAVA_INT), + "WSAGetLastError", o -> {}, critical)); + } } return cases.stream().map(tc -> new Object[] {tc}).toArray(Object[][]::new); } - static SaveValuesCase structCase(String name, Map fields) { + static SaveValuesCase structCase(String name, Map fields, boolean critical) { StructLayout layout = MemoryLayout.structLayout(fields.keySet().toArray(MemoryLayout[]::new)); Consumer check = o -> {}; @@ -139,16 +157,19 @@ static SaveValuesCase structCase(String name, Map fields) check = check.andThen(o -> assertEquals(fieldHandle.get(o, 0L), value)); } - return new SaveValuesCase("set_errno_" + name, FunctionDescriptor.of(layout, JAVA_INT), "errno", check); + return new SaveValuesCase("set_errno_" + name, FunctionDescriptor.of(layout, JAVA_INT), + "errno", check, critical); } @DataProvider public static Object[][] invalidCaptureSegmentCases() { return new Object[][]{ - {Arena.ofAuto().allocate(1), IndexOutOfBoundsException.class, ".*Out of bound access on segment.*"}, - {MemorySegment.NULL, IllegalArgumentException.class, ".*Capture segment is NULL.*"}, + {Arena.ofAuto().allocate(1), IndexOutOfBoundsException.class, ".*Out of bound access on segment.*", new Linker.Option[0]}, + {MemorySegment.NULL, IllegalArgumentException.class, ".*Capture segment is NULL.*", new Linker.Option[0]}, {Arena.ofAuto().allocate(Linker.Option.captureStateLayout().byteSize() + 3).asSlice(3), // misaligned - IllegalArgumentException.class, ".*Target offset incompatible with alignment constraints.*"}, + IllegalArgumentException.class, ".*Target offset incompatible with alignment constraints.*", new Linker.Option[0]}, + {MemorySegment.ofArray(new byte[(int) Linker.Option.captureStateLayout().byteSize()]), // misaligned + IllegalArgumentException.class, ".*Target offset incompatible with alignment constraints.*", new Linker.Option[0]}, }; } } diff --git a/test/jdk/java/foreign/critical/TestCritical.java b/test/jdk/java/foreign/critical/TestCritical.java index ab5d6017abaac..85aa962383b9b 100644 --- a/test/jdk/java/foreign/critical/TestCritical.java +++ b/test/jdk/java/foreign/critical/TestCritical.java @@ -45,12 +45,16 @@ import java.util.ArrayList; import java.util.List; import java.util.function.IntFunction; +import java.util.stream.Collectors; import java.util.stream.Stream; import static org.testng.Assert.assertEquals; public class TestCritical extends NativeTestHelper { + static final MemoryLayout CAPTURE_STATE_LAYOUT = Linker.Option.captureStateLayout(); + static final VarHandle ERRNO_HANDLE = CAPTURE_STATE_LAYOUT.varHandle(MemoryLayout.PathElement.groupElement("errno")); + static { System.loadLibrary("Critical"); } @@ -87,11 +91,16 @@ public void testWithReturnBuffer() throws Throwable { } public record AllowHeapCase(IntFunction newArraySegment, ValueLayout elementLayout, - String fName, FunctionDescriptor fDesc, boolean readOnly) {} + String fName, FunctionDescriptor fDesc, boolean readOnly, boolean captureErrno) {} @Test(dataProvider = "allowHeapCases") public void testAllowHeap(AllowHeapCase testCase) throws Throwable { - MethodHandle handle = downcallHandle(testCase.fName(), testCase.fDesc(), Linker.Option.critical(true)); + List options = new ArrayList<>(); + options.add(Linker.Option.critical(true)); + if (testCase.captureErrno()) { + options.add(Linker.Option.captureCallState("errno")); + } + MethodHandle handle = downcallHandle(testCase.fName(), testCase.fDesc(), options.toArray(Linker.Option[]::new)); int elementCount = 10; MemorySegment heapSegment = testCase.newArraySegment().apply(elementCount); if (testCase.readOnly()) { @@ -101,29 +110,36 @@ public void testAllowHeap(AllowHeapCase testCase) throws Throwable { try (Arena arena = Arena.ofConfined()) { TestValue[] tvs = genTestArgs(testCase.fDesc(), arena); - Object[] args = Stream.of(tvs).map(TestValue::value).toArray(); + List args = Stream.of(tvs).map(TestValue::value).collect(Collectors.toCollection(ArrayList::new)); + MemorySegment captureSegment = testCase.captureErrno() + ? MemorySegment.ofArray(new int[((int) CAPTURE_STATE_LAYOUT.byteSize() + 3) / 4]) + : null; // inject our custom last three arguments - args[args.length - 1] = (int) sequence.byteSize(); + args.set(args.size() - 1, (int) sequence.byteSize()); TestValue sourceSegment = genTestValue(sequence, arena); - args[args.length - 2] = sourceSegment.value(); - args[args.length - 3] = heapSegment; + args.set(args.size() - 2, sourceSegment.value()); + args.set(args.size() - 3, heapSegment); + if (testCase.captureErrno()) { + args.add(0, captureSegment); + } if (handle.type().parameterType(0) == SegmentAllocator.class) { - Object[] newArgs = new Object[args.length + 1]; - newArgs[0] = arena; - System.arraycopy(args, 0, newArgs, 1, args.length); - args = newArgs; + args.add(0, arena); } Object o = handle.invokeWithArguments(args); - if (o != null) { tvs[0].check(o); } // check that writes went through to array sourceSegment.check(heapSegment); + + if (testCase.captureErrno()) { + int errno = (int) ERRNO_HANDLE.get(captureSegment, 0L); + assertEquals(errno, 42); + } } } @@ -149,14 +165,16 @@ public Object[][] allowHeapCases() { List cases = new ArrayList<>(); - for (HeapSegmentFactory hsf : HeapSegmentFactory.values()) { - cases.add(new AllowHeapCase(hsf.newArray, hsf.elementLayout, "test_allow_heap_void", voidDesc, false)); - cases.add(new AllowHeapCase(hsf.newArray, hsf.elementLayout, "test_allow_heap_int", intDesc, false)); - cases.add(new AllowHeapCase(hsf.newArray, hsf.elementLayout, "test_allow_heap_return_buffer", L2Desc, false)); - cases.add(new AllowHeapCase(hsf.newArray, hsf.elementLayout, "test_allow_heap_imr", L3Desc, false)); - cases.add(new AllowHeapCase(hsf.newArray, hsf.elementLayout, "test_allow_heap_void_stack", stackDesc, false)); - // readOnly - cases.add(new AllowHeapCase(hsf.newArray, hsf.elementLayout, "test_allow_heap_void", voidDesc, true)); + for (boolean doCapture : new boolean[]{ true, false }) { + for (HeapSegmentFactory hsf : HeapSegmentFactory.values()) { + cases.add(new AllowHeapCase(hsf.newArray, hsf.elementLayout, "test_allow_heap_void", voidDesc, false, doCapture)); + cases.add(new AllowHeapCase(hsf.newArray, hsf.elementLayout, "test_allow_heap_int", intDesc, false, doCapture)); + cases.add(new AllowHeapCase(hsf.newArray, hsf.elementLayout, "test_allow_heap_return_buffer", L2Desc, false, doCapture)); + cases.add(new AllowHeapCase(hsf.newArray, hsf.elementLayout, "test_allow_heap_imr", L3Desc, false, doCapture)); + cases.add(new AllowHeapCase(hsf.newArray, hsf.elementLayout, "test_allow_heap_void_stack", stackDesc, false, doCapture)); + // readOnly + cases.add(new AllowHeapCase(hsf.newArray, hsf.elementLayout, "test_allow_heap_void", voidDesc, true, doCapture)); + } } return cases.stream().map(e -> new Object[]{ e }).toArray(Object[][]::new); diff --git a/test/jdk/java/foreign/critical/libCritical.c b/test/jdk/java/foreign/critical/libCritical.c index cc03db3c43cfd..c901df0a36893 100644 --- a/test/jdk/java/foreign/critical/libCritical.c +++ b/test/jdk/java/foreign/critical/libCritical.c @@ -53,12 +53,14 @@ EXPORT void test_allow_heap_void(unsigned char* heapArr, unsigned char* nativeAr for (int i = 0; i < numBytes; i++) { heapArr[i] = nativeArr[i]; } + errno = 42; } EXPORT int test_allow_heap_int(int a0, unsigned char* heapArr, unsigned char* nativeArr, int numBytes) { for (int i = 0; i < numBytes; i++) { heapArr[i] = nativeArr[i]; } + errno = 42; return a0; } @@ -71,6 +73,7 @@ EXPORT struct L2 test_allow_heap_return_buffer(struct L2 a0, unsigned char* heap for (int i = 0; i < numBytes; i++) { heapArr[i] = nativeArr[i]; } + errno = 42; return a0; } @@ -84,6 +87,7 @@ EXPORT struct L3 test_allow_heap_imr(struct L3 a0, unsigned char* heapArr, unsig for (int i = 0; i < numBytes; i++) { heapArr[i] = nativeArr[i]; } + errno = 42; return a0; } @@ -94,4 +98,5 @@ EXPORT void test_allow_heap_void_stack(long long a0, long long a1, long long a2, for (int i = 0; i < numBytes; i++) { heapArr[i] = nativeArr[i]; } + errno = 42; } diff --git a/test/jdk/java/foreign/passheapsegment/TestPassHeapSegment.java b/test/jdk/java/foreign/passheapsegment/TestPassHeapSegment.java index fadcdf1ba2446..375c672a60695 100644 --- a/test/jdk/java/foreign/passheapsegment/TestPassHeapSegment.java +++ b/test/jdk/java/foreign/passheapsegment/TestPassHeapSegment.java @@ -31,8 +31,7 @@ import org.testng.annotations.Test; import java.io.IOException; -import java.lang.foreign.FunctionDescriptor; -import java.lang.foreign.MemorySegment; +import java.lang.foreign.*; import java.lang.invoke.MethodHandle; import static java.lang.foreign.ValueLayout.ADDRESS; @@ -51,6 +50,19 @@ public void testNoHeapArgs() throws Throwable { handle.invoke(segment); // should throw } + @Test(expectedExceptions = IllegalArgumentException.class, + expectedExceptionsMessageRegExp = ".*Heap segment not allowed.*") + public void testNoHeapCaptureCallState() throws Throwable { + MethodHandle handle = downcallHandle("test_args", FunctionDescriptor.ofVoid(ADDRESS), + Linker.Option.captureCallState("errno")); + try (Arena arena = Arena.ofConfined()) { + assert Linker.Option.captureStateLayout().byteAlignment() % 4 == 0; + MemorySegment captureHeap = MemorySegment.ofArray(new int[(int) Linker.Option.captureStateLayout().byteSize() / 4]); + MemorySegment segment = arena.allocateFrom(C_CHAR, new byte[]{ 0, 1, 2 }); + handle.invoke(captureHeap, segment); // should throw for captureHeap + } + } + @Test(dataProvider = "specs") public void testNoHeapReturns(boolean spec) throws IOException, InterruptedException { runInNewProcess(Runner.class, spec) From 65b5a2e3e4f9882adca587b9fed90223b93302a0 Mon Sep 17 00:00:00 2001 From: Daniel Skantz Date: Tue, 3 Dec 2024 13:32:28 +0000 Subject: [PATCH 24/62] 8345158: IGV: local scheduling should not place successors before predecessors Reviewed-by: rcastanedalo, chagedorn --- .../hotspot/igv/servercompiler/ServerCompilerScheduler.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/IdealGraphVisualizer/ServerCompiler/src/main/java/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java b/src/utils/IdealGraphVisualizer/ServerCompiler/src/main/java/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java index 378e3bb6d40ec..95a0b71c16df3 100644 --- a/src/utils/IdealGraphVisualizer/ServerCompiler/src/main/java/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java +++ b/src/utils/IdealGraphVisualizer/ServerCompiler/src/main/java/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java @@ -382,7 +382,7 @@ private void scheduleLocal() { }; private List scheduleBlock(Collection nodes) { - List schedule = new ArrayList<>(); + LinkedHashSet schedule = new LinkedHashSet(); // Initialize ready priority queue with nodes without predecessors. Queue ready = new PriorityQueue<>(schedulePriority); @@ -407,7 +407,7 @@ private List scheduleBlock(Collection nodes) { } boolean allPredsScheduled = true; for (Node p : s.preds) { - if (!visited.contains(p)) { + if (!schedule.contains(p.inputNode)) { allPredsScheduled = false; break; } @@ -419,7 +419,7 @@ private List scheduleBlock(Collection nodes) { } } assert(schedule.size() == nodes.size()); - return schedule; + return new ArrayList(schedule); } // Return latest block that dominates all successors of n, or null if any From dfa5620ff3d57b71ccaf09ca8e71fa85d93ceb00 Mon Sep 17 00:00:00 2001 From: Per Minborg Date: Tue, 3 Dec 2024 13:32:48 +0000 Subject: [PATCH 25/62] 8345164: Remove residual --enable-preview in FFM tests and benchmarks Reviewed-by: mcimadamore, jvernee --- .../TestEnableNativeAccessJarManifest.java | 5 ++--- .../openjdk/bench/java/lang/foreign/ToJavaStringTest.java | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/test/jdk/java/foreign/enablenativeaccess/TestEnableNativeAccessJarManifest.java b/test/jdk/java/foreign/enablenativeaccess/TestEnableNativeAccessJarManifest.java index d75e827fbc631..abd793b31da2e 100644 --- a/test/jdk/java/foreign/enablenativeaccess/TestEnableNativeAccessJarManifest.java +++ b/test/jdk/java/foreign/enablenativeaccess/TestEnableNativeAccessJarManifest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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,7 +21,7 @@ * questions. */ -/** +/* * @test * @summary Basic test for Enable-Native-Access attribute in the * manifest of a main application JAR @@ -78,7 +78,6 @@ public void testEnableNativeAccessInJarManifest(String action, String cls, Resul // java -jar test.jar List command = new ArrayList<>(List.of( - "--enable-preview", "-Djava.library.path=" + System.getProperty("java.library.path") )); command.addAll(vmArgs); diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/ToJavaStringTest.java b/test/micro/org/openjdk/bench/java/lang/foreign/ToJavaStringTest.java index 02b1a47d03fe2..7a0639b29bb12 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/ToJavaStringTest.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/ToJavaStringTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 @@ -43,7 +43,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(Scope.Benchmark) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3, jvmArgs = { "--enable-native-access=ALL-UNNAMED", "--enable-preview", "-Djava.library.path=micro/native" }) +@Fork(value = 3, jvmArgs = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) public class ToJavaStringTest { private MemorySegment strSegment; From eac00f6d112b24b62b067a1e9cee342ab07ef021 Mon Sep 17 00:00:00 2001 From: Per Minborg Date: Tue, 3 Dec 2024 14:32:22 +0000 Subject: [PATCH 26/62] 8345396: Fix headers after JDK-8345164 Reviewed-by: rriggs --- .../enablenativeaccess/TestEnableNativeAccessJarManifest.java | 2 +- .../org/openjdk/bench/java/lang/foreign/ToJavaStringTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/jdk/java/foreign/enablenativeaccess/TestEnableNativeAccessJarManifest.java b/test/jdk/java/foreign/enablenativeaccess/TestEnableNativeAccessJarManifest.java index abd793b31da2e..aa923b5a623fb 100644 --- a/test/jdk/java/foreign/enablenativeaccess/TestEnableNativeAccessJarManifest.java +++ b/test/jdk/java/foreign/enablenativeaccess/TestEnableNativeAccessJarManifest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/ToJavaStringTest.java b/test/micro/org/openjdk/bench/java/lang/foreign/ToJavaStringTest.java index 7a0639b29bb12..f38a14811585b 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/ToJavaStringTest.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/ToJavaStringTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, 2024 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 From fcf185c8b425a6984eb145c3127f97e811d345d7 Mon Sep 17 00:00:00 2001 From: Roger Riggs Date: Tue, 3 Dec 2024 14:59:30 +0000 Subject: [PATCH 27/62] 8345325: SM cleanup of GetPropertyAction in java.base Reviewed-by: alanb, lancea, naoto, mchung --- .../share/classes/java/lang/ScopedValue.java | 3 +- .../classes/java/lang/StackStreamFactory.java | 10 +- .../share/classes/java/lang/ThreadLocal.java | 3 +- .../java/lang/invoke/MethodHandleNatives.java | 5 +- .../classes/jdk/internal/vm/Continuation.java | 5 +- .../jdk/internal/vm/ThreadContainers.java | 5 +- .../security/action/GetPropertyAction.java | 163 ------------------ .../util/calendar/LocalGregorianCalendar.java | 6 +- .../provider/LocaleProviderAdapter.java | 3 +- .../util/locale/provider/LocaleResources.java | 3 +- test/jdk/sun/security/action/Generify.java | 48 ------ 11 files changed, 13 insertions(+), 241 deletions(-) delete mode 100644 src/java.base/share/classes/sun/security/action/GetPropertyAction.java delete mode 100644 test/jdk/sun/security/action/Generify.java diff --git a/src/java.base/share/classes/java/lang/ScopedValue.java b/src/java.base/share/classes/java/lang/ScopedValue.java index ac9b598b53165..3730326ee3cc2 100644 --- a/src/java.base/share/classes/java/lang/ScopedValue.java +++ b/src/java.base/share/classes/java/lang/ScopedValue.java @@ -38,7 +38,6 @@ import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.annotation.Hidden; import jdk.internal.vm.ScopedValueContainer; -import sun.security.action.GetPropertyAction; /** * A value that may be safely and efficiently shared to methods without using method @@ -740,7 +739,7 @@ private static final class Cache { static { final String propertyName = "java.lang.ScopedValue.cacheSize"; - var sizeString = GetPropertyAction.privilegedGetProperty(propertyName, "16"); + var sizeString = System.getProperty(propertyName, "16"); var cacheSize = Integer.valueOf(sizeString); if (cacheSize < 2 || cacheSize > MAX_CACHE_SIZE) { cacheSize = MAX_CACHE_SIZE; diff --git a/src/java.base/share/classes/java/lang/StackStreamFactory.java b/src/java.base/share/classes/java/lang/StackStreamFactory.java index e2ec089e30d89..404a74e96c7ef 100644 --- a/src/java.base/share/classes/java/lang/StackStreamFactory.java +++ b/src/java.base/share/classes/java/lang/StackStreamFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -45,7 +45,6 @@ import java.util.stream.StreamSupport; import jdk.internal.vm.Continuation; import jdk.internal.vm.ContinuationScope; -import sun.security.action.GetPropertyAction; import static java.lang.StackStreamFactory.WalkerState.*; @@ -82,13 +81,8 @@ private StackStreamFactory() {} @Native private static final int SHOW_HIDDEN_FRAMES = 0x20; // LambdaForms are hidden by the VM @Native private static final int FILL_LIVE_STACK_FRAMES = 0x100; - /* - * For Throwable to use StackWalker, set useNewThrowable to true. - * Performance work and extensive testing is needed to replace the - * VM built-in backtrace filled in Throwable with the StackWalker. - */ static final boolean isDebug = - "true".equals(GetPropertyAction.privilegedGetProperty("stackwalk.debug")); + "true".equals(System.getProperty("stackwalk.debug")); static StackFrameTraverser makeStackTraverser(StackWalker walker, Function, ? extends T> function) diff --git a/src/java.base/share/classes/java/lang/ThreadLocal.java b/src/java.base/share/classes/java/lang/ThreadLocal.java index 8a9aa7998fd44..fae322d2b738c 100644 --- a/src/java.base/share/classes/java/lang/ThreadLocal.java +++ b/src/java.base/share/classes/java/lang/ThreadLocal.java @@ -33,7 +33,6 @@ import jdk.internal.misc.CarrierThreadLocal; import jdk.internal.misc.TerminatingThreadLocal; -import sun.security.action.GetPropertyAction; /** * This class provides thread-local variables. These variables differ from @@ -804,7 +803,7 @@ private void expungeStaleEntries() { * a stack trace should be printed when a virtual thread sets a thread local. */ private static boolean traceVirtualThreadLocals() { - String propValue = GetPropertyAction.privilegedGetProperty("jdk.traceVirtualThreadLocals"); + String propValue = System.getProperty("jdk.traceVirtualThreadLocals"); return (propValue != null) && (propValue.isEmpty() || Boolean.parseBoolean(propValue)); } diff --git a/src/java.base/share/classes/java/lang/invoke/MethodHandleNatives.java b/src/java.base/share/classes/java/lang/invoke/MethodHandleNatives.java index 4ffbf82631760..0743b3362f21d 100644 --- a/src/java.base/share/classes/java/lang/invoke/MethodHandleNatives.java +++ b/src/java.base/share/classes/java/lang/invoke/MethodHandleNatives.java @@ -28,11 +28,9 @@ import jdk.internal.misc.VM; import jdk.internal.ref.CleanerFactory; import sun.invoke.util.Wrapper; -import sun.security.action.GetPropertyAction; import java.lang.invoke.MethodHandles.Lookup; import java.lang.reflect.Field; -import java.util.Properties; import static java.lang.invoke.MethodHandleNatives.Constants.*; import static java.lang.invoke.MethodHandleStatics.TRACE_METHOD_LINKAGE; @@ -707,8 +705,7 @@ static boolean canBeCalledVirtual(MemberName symbolicRef, Class definingClass static final boolean USE_SOFT_CACHE; static { - Properties props = GetPropertyAction.privilegedGetProperties(); USE_SOFT_CACHE = Boolean.parseBoolean( - props.getProperty("java.lang.invoke.MethodHandleNatives.USE_SOFT_CACHE", "true")); + System.getProperty("java.lang.invoke.MethodHandleNatives.USE_SOFT_CACHE", "true")); } } diff --git a/src/java.base/share/classes/jdk/internal/vm/Continuation.java b/src/java.base/share/classes/jdk/internal/vm/Continuation.java index 05a32cc3b21fe..a97f9ac9ea47d 100644 --- a/src/java.base/share/classes/jdk/internal/vm/Continuation.java +++ b/src/java.base/share/classes/jdk/internal/vm/Continuation.java @@ -28,7 +28,6 @@ import jdk.internal.misc.Unsafe; import jdk.internal.vm.annotation.DontInline; import jdk.internal.vm.annotation.IntrinsicCandidate; -import sun.security.action.GetPropertyAction; import java.util.EnumSet; import java.util.Set; @@ -51,7 +50,7 @@ public class Continuation { StackChunk.init(); // ensure StackChunk class is initialized - String value = GetPropertyAction.privilegedGetProperty("jdk.preserveScopedValueCache"); + String value = System.getProperty("jdk.preserveScopedValueCache"); PRESERVE_SCOPED_VALUE_CACHE = (value == null) || Boolean.parseBoolean(value); } @@ -503,7 +502,7 @@ private void dump() { } private static boolean isEmptyOrTrue(String property) { - String value = GetPropertyAction.privilegedGetProperty(property); + String value = System.getProperty(property); if (value == null) return false; return value.isEmpty() || Boolean.parseBoolean(value); diff --git a/src/java.base/share/classes/jdk/internal/vm/ThreadContainers.java b/src/java.base/share/classes/jdk/internal/vm/ThreadContainers.java index e1672febc3c1a..aeae6b365207c 100644 --- a/src/java.base/share/classes/jdk/internal/vm/ThreadContainers.java +++ b/src/java.base/share/classes/jdk/internal/vm/ThreadContainers.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 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 @@ -33,7 +33,6 @@ import java.util.stream.Stream; import jdk.internal.access.JavaLangAccess; import jdk.internal.access.SharedSecrets; -import sun.security.action.GetPropertyAction; /** * This class consists exclusively of static methods to support groupings of threads. @@ -52,7 +51,7 @@ public class ThreadContainers { private static final ReferenceQueue QUEUE = new ReferenceQueue<>(); static { - String s = GetPropertyAction.privilegedGetProperty("jdk.trackAllThreads"); + String s = System.getProperty("jdk.trackAllThreads"); if (s == null || s.isEmpty() || Boolean.parseBoolean(s)) { TRACK_ALL_THREADS = true; ROOT_CONTAINER = new RootContainer.TrackingRootContainer(); diff --git a/src/java.base/share/classes/sun/security/action/GetPropertyAction.java b/src/java.base/share/classes/sun/security/action/GetPropertyAction.java deleted file mode 100644 index 8954c615cbae0..0000000000000 --- a/src/java.base/share/classes/sun/security/action/GetPropertyAction.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 1998, 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. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.security.action; - -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.Properties; - -/** - * A convenience class for retrieving the string value of a system - * property as a privileged action. - * - *

      An instance of this class can be used as the argument of - * AccessController.doPrivileged. - * - *

      The following code retrieves the value of the system - * property named "prop" as a privileged action: - * - *

      - * String s = java.security.AccessController.doPrivileged
      - *                      (new GetPropertyAction("prop"));
      - * 
      - * - * @author Roland Schemers - * @see java.security.PrivilegedAction - * @see java.security.AccessController - * @since 1.2 - */ - -public class GetPropertyAction implements PrivilegedAction { - private final String theProp; - private final String defaultVal; - - /** - * Constructor that takes the name of the system property whose - * string value needs to be determined. - * - * @param theProp the name of the system property. - */ - public GetPropertyAction(String theProp) { - this.theProp = theProp; - this.defaultVal = null; - } - - /** - * Constructor that takes the name of the system property and the default - * value of that property. - * - * @param theProp the name of the system property. - * @param defaultVal the default value. - */ - public GetPropertyAction(String theProp, String defaultVal) { - this.theProp = theProp; - this.defaultVal = defaultVal; - } - - /** - * Determines the string value of the system property whose - * name was specified in the constructor. - * - * @return the string value of the system property, - * or the default value if there is no property with that key. - */ - public String run() { - String value = System.getProperty(theProp); - return (value == null) ? defaultVal : value; - } - - /** - * Convenience method to get a property without going through doPrivileged - * if no security manager is present. This is unsafe for inclusion in a - * public API but allowable here since this class is now encapsulated. - * - * Note that this method performs a privileged action using caller-provided - * inputs. The caller of this method should take care to ensure that the - * inputs are not tainted and the returned property is not made accessible - * to untrusted code if it contains sensitive information. - * - * @param theProp the name of the system property. - */ - @SuppressWarnings("removal") - public static String privilegedGetProperty(String theProp) { - if (System.getSecurityManager() == null) { - return System.getProperty(theProp); - } else { - return AccessController.doPrivileged( - new GetPropertyAction(theProp)); - } - } - - /** - * Convenience method to get a property without going through doPrivileged - * if no security manager is present. This is unsafe for inclusion in a - * public API but allowable here since this class is now encapsulated. - * - * Note that this method performs a privileged action using caller-provided - * inputs. The caller of this method should take care to ensure that the - * inputs are not tainted and the returned property is not made accessible - * to untrusted code if it contains sensitive information. - * - * @param theProp the name of the system property. - * @param defaultVal the default value. - */ - @SuppressWarnings("removal") - public static String privilegedGetProperty(String theProp, - String defaultVal) { - if (System.getSecurityManager() == null) { - return System.getProperty(theProp, defaultVal); - } else { - return AccessController.doPrivileged( - new GetPropertyAction(theProp, defaultVal)); - } - } - - /** - * Convenience method to call System.getProperties without - * having to go through doPrivileged if no security manager is present. - * This is unsafe for inclusion in a public API but allowable here since - * this class is now encapsulated. - * - * Note that this method performs a privileged action, and callers of - * this method should take care to ensure that the returned properties - * are not made accessible to untrusted code since it may contain - * sensitive information. - */ - @SuppressWarnings("removal") - public static Properties privilegedGetProperties() { - if (System.getSecurityManager() == null) { - return System.getProperties(); - } else { - return AccessController.doPrivileged( - new PrivilegedAction() { - public Properties run() { - return System.getProperties(); - } - } - ); - } - } -} diff --git a/src/java.base/share/classes/sun/util/calendar/LocalGregorianCalendar.java b/src/java.base/share/classes/sun/util/calendar/LocalGregorianCalendar.java index b9d520d4083e1..850f198c8b145 100644 --- a/src/java.base/share/classes/sun/util/calendar/LocalGregorianCalendar.java +++ b/src/java.base/share/classes/sun/util/calendar/LocalGregorianCalendar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -28,7 +28,6 @@ import java.util.TimeZone; import java.util.regex.Matcher; import java.util.regex.Pattern; -import sun.security.action.GetPropertyAction; /** * @@ -146,8 +145,7 @@ static LocalGregorianCalendar getLocalGregorianCalendar(String name) { } // Append an era to the predefined eras if it's given by the property. - String prop = GetPropertyAction - .privilegedGetProperty("jdk.calendar.japanese.supplemental.era"); + String prop = System.getProperty("jdk.calendar.japanese.supplemental.era"); if (prop != null) { Era era = parseEraEntry(prop); if (era != null) { diff --git a/src/java.base/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java b/src/java.base/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java index a027191e45f13..5e7a4c719d160 100644 --- a/src/java.base/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java +++ b/src/java.base/share/classes/sun/util/locale/provider/LocaleProviderAdapter.java @@ -48,7 +48,6 @@ import java.util.spi.LocaleNameProvider; import java.util.spi.LocaleServiceProvider; import java.util.spi.TimeZoneNameProvider; -import sun.security.action.GetPropertyAction; import sun.text.spi.JavaTimeDateTimePatternProvider; import sun.util.spi.CalendarProvider; @@ -115,7 +114,7 @@ public String getTextResourcesPackage() { adapterCache = new ConcurrentHashMap<>(); static { - String order = GetPropertyAction.privilegedGetProperty("java.locale.providers"); + String order = System.getProperty("java.locale.providers"); ArrayList typeList = new ArrayList<>(); String invalidTypeMessage = null; String compatWarningMessage = null; diff --git a/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java b/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java index ee6ec0f72baa8..4ae0275fddad1 100644 --- a/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java +++ b/src/java.base/share/classes/sun/util/locale/provider/LocaleResources.java @@ -63,7 +63,6 @@ import java.util.stream.Stream; import jdk.internal.util.StaticProperty; -import sun.security.action.GetPropertyAction; import sun.util.resources.LocaleData; import sun.util.resources.OpenListResourceBundle; import sun.util.resources.ParallelListResourceBundle; @@ -899,7 +898,7 @@ String getCacheKey() { } private static final boolean TRACE_ON = Boolean.parseBoolean( - GetPropertyAction.privilegedGetProperty("locale.resources.debug", "false")); + System.getProperty("locale.resources.debug", "false")); public static void trace(String format, Object... params) { if (TRACE_ON) { diff --git a/test/jdk/sun/security/action/Generify.java b/test/jdk/sun/security/action/Generify.java deleted file mode 100644 index 4ddbc299a47a1..0000000000000 --- a/test/jdk/sun/security/action/Generify.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2004, 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 5057136 - * @summary Generify sun.security.action.GetPropertyAction and friends - * @modules java.base/sun.security.action - */ - -import java.security.*; -import sun.security.action.*; - -public class Generify { - - public static void main(String[] args) throws Exception { - - System.setProperty("property", "propertyvalue"); - - String prop = AccessController.doPrivileged - (new GetPropertyAction("property")); - if (prop.equals("propertyvalue")) { - System.out.println("property test passed"); - } else { - throw new SecurityException("property test failed"); - } - } -} From 8647c00114385f74939bf705c9c07e709f41a18d Mon Sep 17 00:00:00 2001 From: Alexey Ivanov Date: Tue, 3 Dec 2024 15:00:47 +0000 Subject: [PATCH 28/62] 8342602: Remove JButton/PressedButtonRightClickTest test Reviewed-by: dnguyen, prr --- .../JButton/PressedButtonRightClickTest.java | 147 ------------------ test/jdk/javax/swing/JButton/bug4490179.java | 2 +- 2 files changed, 1 insertion(+), 148 deletions(-) delete mode 100644 test/jdk/javax/swing/JButton/PressedButtonRightClickTest.java diff --git a/test/jdk/javax/swing/JButton/PressedButtonRightClickTest.java b/test/jdk/javax/swing/JButton/PressedButtonRightClickTest.java deleted file mode 100644 index 8f3da452c21e4..0000000000000 --- a/test/jdk/javax/swing/JButton/PressedButtonRightClickTest.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * 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 - * 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.AWTException; -import java.awt.BorderLayout; -import java.awt.EventQueue; -import java.awt.Point; -import java.awt.Robot; -import java.awt.event.InputEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.SwingUtilities; - -/* - * @test - * @key headful - * @bug 8049069 - * @summary Tests whether right mouse click releases a pressed JButton - */ - -public class PressedButtonRightClickTest { - - private static Robot testRobot; - private static JFrame myFrame; - private static JButton myButton; - - public static void main(String[] args) throws Throwable { - - SwingUtilities.invokeAndWait(PressedButtonRightClickTest::constructTestUI); - - try { - testRobot = new Robot(); - } catch (AWTException ex) { - throw new RuntimeException("Exception in Robot creation"); - } - - testRobot.waitForIdle(); - testRobot.delay(500); - - // Method performing auto test operation - try { - test(); - } finally { - EventQueue.invokeAndWait(PressedButtonRightClickTest::disposeTestUI); - } - } - - private static void test() { - Point loc = myFrame.getLocationOnScreen(); - - testRobot.mouseMove((loc.x + 100), (loc.y + 100)); - - // Press the left mouse button - System.out.println("press BUTTON1_DOWN_MASK"); - testRobot.mousePress(InputEvent.BUTTON1_DOWN_MASK); - myButton.setText("Left button pressed"); - testRobot.delay(500); - - // Press the right mouse button - System.out.println("press BUTTON3_DOWN_MASK"); - testRobot.mousePress(InputEvent.BUTTON3_DOWN_MASK); - myButton.setText("Left button pressed + Right button pressed"); - testRobot.delay(500); - - // Release the right mouse button - System.out.println("release BUTTON3_DOWN_MASK"); - testRobot.mouseRelease(InputEvent.BUTTON3_DOWN_MASK); - myButton.setText("Right button released"); - testRobot.waitForIdle(); - testRobot.delay(500); - - // Test whether the button is still pressed - boolean pressed = myButton.getModel().isPressed(); - System.out.println("release BUTTON1_DOWN_MASK"); - testRobot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); - if (!pressed) { - disposeTestUI(); - throw new RuntimeException("Test Failed!"); - } - } - - private static void disposeTestUI() { - myFrame.setVisible(false); - myFrame.dispose(); - } - - public static void constructTestUI() { - myFrame = new JFrame(); - myFrame.setLayout(new BorderLayout()); - myButton = new JButton("Whatever"); - myButton.addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - System.out.println(e); - } - - @Override - public void mousePressed(MouseEvent e) { - System.out.println(e); - } - - @Override - public void mouseReleased(MouseEvent e) { - System.out.println(e); - } - - @Override - public void mouseEntered(MouseEvent e) { - System.out.println(e); - } - - @Override - public void mouseExited(MouseEvent e) { - System.out.println(e); - } - }); - myFrame.add(myButton, BorderLayout.CENTER); - myFrame.setSize(400, 300); - myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - myFrame.setLocationRelativeTo(null); - myFrame.setVisible(true); - } -} - diff --git a/test/jdk/javax/swing/JButton/bug4490179.java b/test/jdk/javax/swing/JButton/bug4490179.java index e36e01e2d95bf..bf2df9e7bcc55 100644 --- a/test/jdk/javax/swing/JButton/bug4490179.java +++ b/test/jdk/javax/swing/JButton/bug4490179.java @@ -23,7 +23,7 @@ /* * @test - * @bug 4490179 + * @bug 4490179 8049069 * @summary Tests that JButton only responds to left mouse clicks. * @key headful * @run main bug4490179 From caf053b3ad53e4ce86d07adee6d71ea1ff3e8965 Mon Sep 17 00:00:00 2001 From: Alexey Ivanov Date: Tue, 3 Dec 2024 15:05:13 +0000 Subject: [PATCH 29/62] 8337287: Update image in javax.swing.text.Document.insert Reviewed-by: serb, prr, abhiscxk --- .../classes/javax/swing/text/Document.java | 35 ++-- .../swing/text/doc-files/Document-insert.gif | Bin 3747 -> 0 bytes .../swing/text/doc-files/Document-insert.svg | 150 ++++++++++++++++++ 3 files changed, 171 insertions(+), 14 deletions(-) delete mode 100644 src/java.desktop/share/classes/javax/swing/text/doc-files/Document-insert.gif create mode 100644 src/java.desktop/share/classes/javax/swing/text/doc-files/Document-insert.svg diff --git a/src/java.desktop/share/classes/javax/swing/text/Document.java b/src/java.desktop/share/classes/javax/swing/text/Document.java index c9658aa3b2150..801d6bcbbc3e7 100644 --- a/src/java.desktop/share/classes/javax/swing/text/Document.java +++ b/src/java.desktop/share/classes/javax/swing/text/Document.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -471,24 +471,31 @@ public interface Document { public void remove(int offs, int len) throws BadLocationException; /** - * Inserts a string of content. This will cause a DocumentEvent - * of type DocumentEvent.EventType.INSERT to be sent to the - * registered DocumentListeners, unless an exception is thrown. - * The DocumentEvent will be delivered by calling the - * insertUpdate method on the DocumentListener. - * The offset and length of the generated DocumentEvent - * will indicate what change was actually made to the Document. - *

      + * For example, if the document contains the text + * ‘The brown fox’, + * calling {@code insert(4, "quick ", null)} will insert the word + * ‘quick’ and the following space into the text, + * and all the marks at 4 and above will be moved by 6 (the number + * of inserted characters). + *

      Diagram shows insertion of 'quick' in 'The quick brown fox' *

      - * If the Document structure changed as result of the insertion, - * the details of what Elements were inserted and removed in + * If the {@code Document} structure changed as result of the insertion, + * the details of what {@code Element}s were inserted and removed in * response to the change will also be contained in the generated - * DocumentEvent. It is up to the implementation of a Document + * {@code DocumentEvent}. It is up to the implementation of a {@code Document} * to decide how the structure should change in response to an * insertion. *

      - * If the Document supports undo/redo, an UndoableEditEvent will + * If the {@code Document} supports undo/redo, an {@code UndoableEditEvent} will * also be generated. * * @param offset the offset into the document to insert the content >= 0. @@ -496,7 +503,7 @@ public interface Document { * will move. * @param str the string to insert * @param a the attributes to associate with the inserted - * content. This may be null if there are no attributes. + * content. This may be {@code null} if there are no attributes. * @throws BadLocationException the given insert position is not a valid * position within the document * @see javax.swing.event.DocumentEvent diff --git a/src/java.desktop/share/classes/javax/swing/text/doc-files/Document-insert.gif b/src/java.desktop/share/classes/javax/swing/text/doc-files/Document-insert.gif deleted file mode 100644 index 7e943ce77aaf70c2fe0bf2933ddd77c846f857fa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3747 zcmbu)i9geg1Hkd`W@C#qQ%KUBxzk*8HYQABlAMJ{B;=8!*(k#>a^E9{Iku%Db01O4 zRj5aigeZp6;d~_f{eFML@AC(|U$2if-U?&r(+pw(ZvlYM=UZA@Mn*=it*xb`q&Pb} z&&jErzN8~^|i2!yt_Hl0rQ^Yd$OZ%3g}{G$MkM(gP4(9zKm6B8p6iSqLDFJHd& z_xJz!@ng?)Pe4>adS$wZsEC`to34p&WKyJ*j8t4+oRXRn))vct%0BOUzG9U!F?#uJxzPtnfIxIZE!%?IELhiGIWju-`dXf- zC@j4Z4u!(+WgY^Q&FKY?Rr#|gY=7VzTAQj#~;01^K%<0>TdUF&3 zuvKs1#X)<{hnCRip^8{61q>A!5No|ut_pNb^ofG%%Ks+x$|h2;QszLdAu-~OnxWbc zzYG^K_hPUCSOF$T!~ahZ7b{y+X6|94LC*t)WQkT~Xu35tzibU(oq5&K@_n`^LHLAy zXY0>}fn0U3kV*4wNUr)mqD`unVpgv53k>Sps1{ zbigOs9RI0;1|V!IV^4ux$Wi|+U+KYfIX0E5ekA=jUusG^ zEK__T$gKB%1;kXt&xnYrlU!T7d>BP}e9wxufEGMCY+?z;f*#nO ze^&ES4Jw;pQa^+_;S;8FjL&X_n9K%$0mNOkd!U+!WR}I=TBZ9=0DvZ1EJh^Gd_a^) zz6K7SpoV_v^u~T=h}R#)&X_TBu%!|Z?-tAvgUc-l zuj^iun2&>&#=OqDbkyYIEW4NVL()0{lYFg4+g{NDavd3SNGs*Sz<8FRn)??=Xr=S0KaCu^SAxQ}JV z!^WB2jlZvNFmQkWLEs$`jT6J+GkYte0`=Y7xO$3DXdHT*KIq940HBM4J^Q^56r2hL zy0i2U9AF!2dTw^@sgUM=!$<-^DYsO{oB@hX0pFi`MTIpzL2^z-kkIrR#n5i#8qF_q zp5A97d1i-hcLWc=lBWrk<=u%*l|rCKP~@TVt?BdF_VD`K0I?={YCm`v0&qGjYp)@ zvq112$4v5paX>NjjPWi9mKdxkm957-WB)kPhV~hi-(+~|flXG1iMPix*2n;EkDd{*C9I2Z%VB>;%*BTY-!!-thzBD$1zSg+9k){I^2k}8 zq1QhnHkc#tRcx%Mj%DX;RJEQ~wRMr^OXfe`sCK-mYIkh~Nq@6Z!>?DhC+>=r{@SQz z{7@w%+m2UCZ?bHh!F`u<$7|G{0#<{SPPInK*4!+P>+J+n3;DNoZ#2ktEt1nos`)fcBA{*p9C zJV$Reu){R2p7d}Sa&ImzY^w9o5q|$Fte~OnkH%j(b@!(^&0LD9X5b&r)LZGNK;*!@ z?5;LU1+YLEgr5t#eE%&`#0Qx_X_?F=LO(59sdnZ+!@G)!_-psHwPIdq1l|;0KEEy5 zD`j>3YWCgBip)b}-(H2}stcy>Q<<83bIGRfvJWv?L&p<8S(z-xWp2*M}2S6^qj8X;kzKP@VYDKPo_wA!wdUe;*1Ks|Se%IU` zc|Wl{$W>fryvqMt!kA%jv_!N;?|vrR;Mj~H$t2~ zeCVoK)aySVVrQWL_Tl!k~+t_8|4IK^;-06bG3v zdJd6b{U5*bKNzp@ood_OHl4St7BX2fI%NEh_!X+lbIyX70cL6i%Z9qz-t|4PJE$(Z zd8O85#^byGJGT95$Nl!zk2=h0p;Nc&m!?-O_^nf$k`sP{(97V)Pfv$^nh zf+lmI{Kj1Y6jl#r2K;nO=w7K8G>0J(V6i^(cWJ5HJkuvX9^z&KeRo|BkXq}fWmCL> zfr)OZfa+N2*R1@LzY(JT{WH;szmUwy7ZH6fmbbq8l64dY6}=yWl zJLx+pituf(De30wzCRhYu%(+fp>{y!Dp~ie2TniT;QXGPpZH@U{uB#z5)0NM-r*U5_mas?{ikn+Yk5QBl@twg7EI>> zOnibcJj(=0Gvnt*`6NdTE>Vw6s^y0pMx9lVpNzuST59PUfe1$2!)j}_2`97@L|nr4 z2ksc}Bv}>38qpFiB#W9yCG-1Fzi*_*5tHT`jT)VdTW}UPs7dNJ=R5;wVHYX=2{Bm5 zq}N*(C65fTW$kF)R-#H4P@0_T*?$_&#ZskiyiqYfYzdNpAcZk$89OOT#5B@{ z%ru(KNp7^v;gXT`H_IslH8 zl~$PYM$cOmyi{d+#?M-iQ;O&x$qc?{N?-%#uH3&F zMe!it4azz%B(RDq``JnvVr{Z~M!U*R5R#REEF@i3GI?h0jJXZF9wqByQ?PUU7%oU@ zE{s`JzEo5GiJ;Q8O+3=pT}6)dCK&@X!m!3y+k)zx-Q1l)^x62lX|V z!#U-!)C!sQ3R&CWhnv?+1uw`ORUUV)R4#T@DXu)yRH-5DsI^;p@CXxKOwe^_LL-?N zX@XHZ^UpZbY{kKR$O&sy_0zG+N{xUgJK3~Xt-P+X4 + + + + + + + + + + + + Before Insert + + + + + + 4 + + After Insert + + + + T + + h + + e + + + + + + + q + + u + + i + + c + + k + + + + + + + b + + r + + o + + w + + n + + + + f + + o + + x + + + + + + 10 + + From ba5093935ddedfecaaa80d3107dc0d84d4d18756 Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Tue, 3 Dec 2024 15:44:00 +0000 Subject: [PATCH 30/62] 8341649: Regressions with large metaspace apps after 8338526 Reviewed-by: liach, stuefe --- .../classes/java/lang/invoke/InvokerBytecodeGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java b/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java index ffd368f47c1c0..cbcd4a7b43397 100644 --- a/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java +++ b/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java @@ -248,7 +248,7 @@ private byte[] classFileSetup(Consumer config) { return ClassFile.of().build(classEntry, pool, new Consumer<>() { @Override public void accept(ClassBuilder clb) { - clb.withFlags(ACC_ABSTRACT | ACC_SUPER) + clb.withFlags(ACC_FINAL | ACC_SUPER) .withSuperclass(INVOKER_SUPER_DESC) .with(SourceFileAttribute.of(clb.constantPool().utf8Entry(SOURCE_PREFIX + name))); config.accept(clb); From 2be27e1545a36628eef063d5a20c5e1f23e5c9ec Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Tue, 3 Dec 2024 15:56:32 +0000 Subject: [PATCH 31/62] 8345393: ProblemList java/util/concurrent/locks/StampedLock/OOMEInStampedLock.java on generic-all JTREG_TEST_THREAD_FACTORY=Virtual Reviewed-by: alanb --- test/jdk/ProblemList-Virtual.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/jdk/ProblemList-Virtual.txt b/test/jdk/ProblemList-Virtual.txt index d7692b578cd04..eabac31ca3465 100644 --- a/test/jdk/ProblemList-Virtual.txt +++ b/test/jdk/ProblemList-Virtual.txt @@ -44,6 +44,8 @@ javax/management/remote/mandatory/connection/DeadLockTest.java 8309069 windows-x javax/management/remote/mandatory/connection/ConnectionTest.java 8308352 windows-x64 +java/util/concurrent/locks/StampedLock/OOMEInStampedLock.java 8345266 generic-all + ########## ## Tests incompatible with virtual test thread factory. ## There is no goal to run all test with virtual test thread factory. From 60bd73a5957f26742e3c326cca0b45395b9470af Mon Sep 17 00:00:00 2001 From: Matias Saavedra Silva Date: Tue, 3 Dec 2024 16:18:38 +0000 Subject: [PATCH 32/62] 8342089: Require --enable-native-access to be the same between CDS dump time and run time Reviewed-by: ccheung, dholmes --- src/hotspot/share/cds/cdsConfig.cpp | 4 +- src/hotspot/share/cds/metaspaceShared.cpp | 8 +- src/hotspot/share/classfile/modules.cpp | 141 +++++++++++------- src/hotspot/share/classfile/modules.hpp | 14 +- src/hotspot/share/runtime/arguments.cpp | 35 +++-- src/hotspot/share/runtime/arguments.hpp | 6 +- .../AOTClassLinkingVMOptions.java | 2 +- .../appcds/jigsaw/addmods/AddmodsOption.java | 8 +- .../jigsaw/module/EnableNativeAccessCDS.java | 133 +++++++++++++++++ .../appcds/jigsaw/module/ModuleOption.java | 6 +- 10 files changed, 263 insertions(+), 94 deletions(-) create mode 100644 test/hotspot/jtreg/runtime/cds/appcds/jigsaw/module/EnableNativeAccessCDS.java diff --git a/src/hotspot/share/cds/cdsConfig.cpp b/src/hotspot/share/cds/cdsConfig.cpp index ba5d12e645052..6ab77bf000746 100644 --- a/src/hotspot/share/cds/cdsConfig.cpp +++ b/src/hotspot/share/cds/cdsConfig.cpp @@ -250,9 +250,7 @@ void CDSConfig::init_shared_archive_paths() { } void CDSConfig::check_internal_module_property(const char* key, const char* value) { - if (Arguments::is_internal_module_property(key) && - !Arguments::is_module_path_property(key) && - !Arguments::is_add_modules_property(key)) { + if (Arguments::is_incompatible_cds_internal_module_property(key)) { stop_using_optimized_module_handling(); log_info(cds)("optimized module handling: disabled due to incompatible property: %s=%s", key, value); } diff --git a/src/hotspot/share/cds/metaspaceShared.cpp b/src/hotspot/share/cds/metaspaceShared.cpp index 3571f11bb6e36..ba17ccddb5219 100644 --- a/src/hotspot/share/cds/metaspaceShared.cpp +++ b/src/hotspot/share/cds/metaspaceShared.cpp @@ -423,8 +423,7 @@ void MetaspaceShared::write_method_handle_intrinsics() { void MetaspaceShared::early_serialize(SerializeClosure* soc) { int tag = 0; soc->do_tag(--tag); - CDS_JAVA_HEAP_ONLY(Modules::serialize(soc);) - CDS_JAVA_HEAP_ONLY(Modules::serialize_addmods_names(soc);) + CDS_JAVA_HEAP_ONLY(Modules::serialize_archived_module_info(soc);) soc->do_tag(666); } @@ -567,10 +566,7 @@ class StaticArchiveBuilder : public ArchiveBuilder { char* VM_PopulateDumpSharedSpace::dump_early_read_only_tables() { ArchiveBuilder::OtherROAllocMark mark; - // Write module name into archive - CDS_JAVA_HEAP_ONLY(Modules::dump_main_module_name();) - // Write module names from --add-modules into archive - CDS_JAVA_HEAP_ONLY(Modules::dump_addmods_names();) + CDS_JAVA_HEAP_ONLY(Modules::dump_archived_module_info()); DumpRegion* ro_region = ArchiveBuilder::current()->ro_region(); char* start = ro_region->top(); diff --git a/src/hotspot/share/classfile/modules.cpp b/src/hotspot/share/classfile/modules.cpp index 2a8f8bd2424cc..9c430e77d099e 100644 --- a/src/hotspot/share/classfile/modules.cpp +++ b/src/hotspot/share/classfile/modules.cpp @@ -562,13 +562,55 @@ void Modules::verify_archived_modules() { char* Modules::_archived_main_module_name = nullptr; char* Modules::_archived_addmods_names = nullptr; +char* Modules::_archived_native_access_flags = nullptr; void Modules::dump_main_module_name() { const char* module_name = Arguments::get_property("jdk.module.main"); if (module_name != nullptr) { _archived_main_module_name = ArchiveBuilder::current()->ro_strdup(module_name); } - ArchivePtrMarker::mark_pointer(&_archived_main_module_name); +} + +void Modules::check_archived_flag_consistency(char* archived_flag, const char* runtime_flag, const char* property) { + log_info(cds)("%s %s", property, + archived_flag != nullptr ? archived_flag : "(null)"); + bool disable = false; + if (runtime_flag == nullptr) { + if (archived_flag != nullptr) { + log_info(cds)("Mismatched values for property %s: %s specified during dump time but not during runtime", property, archived_flag); + disable = true; + } + } else { + if (archived_flag == nullptr) { + log_info(cds)("Mismatched values for property %s: %s specified during runtime but not during dump time", property, runtime_flag); + disable = true; + } else if (strcmp(runtime_flag, archived_flag) != 0) { + log_info(cds)("Mismatched values for property %s: runtime %s dump time %s", property, runtime_flag, archived_flag); + disable = true; + } + } + + if (disable) { + log_info(cds)("Disabling optimized module handling"); + CDSConfig::stop_using_optimized_module_handling(); + } + log_info(cds)("optimized module handling: %s", CDSConfig::is_using_optimized_module_handling() ? "enabled" : "disabled"); + log_info(cds)("full module graph: %s", CDSConfig::is_using_full_module_graph() ? "enabled" : "disabled"); +} + +void Modules::dump_archived_module_info() { + // Write module name into archive + CDS_JAVA_HEAP_ONLY(Modules::dump_main_module_name();) + // Write module names from --add-modules into archive + CDS_JAVA_HEAP_ONLY(Modules::dump_addmods_names();) + // Write native enable-native-access flag into archive + CDS_JAVA_HEAP_ONLY(Modules::dump_native_access_flag()); +} + +void Modules::serialize_archived_module_info(SerializeClosure* soc) { + CDS_JAVA_HEAP_ONLY(Modules::serialize(soc);) + CDS_JAVA_HEAP_ONLY(Modules::serialize_addmods_names(soc);) + CDS_JAVA_HEAP_ONLY(Modules::serialize_native_access_flags(soc);) } void Modules::serialize(SerializeClosure* soc) { @@ -577,89 +619,71 @@ void Modules::serialize(SerializeClosure* soc) { const char* runtime_main_module = Arguments::get_property("jdk.module.main"); log_info(cds)("_archived_main_module_name %s", _archived_main_module_name != nullptr ? _archived_main_module_name : "(null)"); - bool disable = false; - if (runtime_main_module == nullptr) { - if (_archived_main_module_name != nullptr) { - log_info(cds)("Module %s specified during dump time but not during runtime", _archived_main_module_name); - disable = true; - } - } else { - if (_archived_main_module_name == nullptr) { - log_info(cds)("Module %s specified during runtime but not during dump time", runtime_main_module); - disable = true; - } else if (strcmp(runtime_main_module, _archived_main_module_name) != 0) { - log_info(cds)("Mismatched modules: runtime %s dump time %s", runtime_main_module, _archived_main_module_name); - disable = true; - } - } - if (disable) { - log_info(cds)("Disabling optimized module handling"); - CDSConfig::stop_using_optimized_module_handling(); - } - log_info(cds)("optimized module handling: %s", CDSConfig::is_using_optimized_module_handling() ? "enabled" : "disabled"); - log_info(cds)("full module graph: %s", CDSConfig::is_using_full_module_graph() ? "enabled" : "disabled"); + check_archived_flag_consistency(_archived_main_module_name, runtime_main_module, "jdk.module.main"); // Don't hold onto the pointer, in case we might decide to unmap the archive. _archived_main_module_name = nullptr; } } +void Modules::dump_native_access_flag() { + const char* native_access_names = get_native_access_flags_as_sorted_string(); + if (native_access_names != nullptr) { + _archived_native_access_flags = ArchiveBuilder::current()->ro_strdup(native_access_names); + } +} + +const char* Modules::get_native_access_flags_as_sorted_string() { + return get_numbered_property_as_sorted_string("jdk.module.enable.native.access"); +} + +void Modules::serialize_native_access_flags(SerializeClosure* soc) { + soc->do_ptr(&_archived_native_access_flags); + if (soc->reading()) { + check_archived_flag_consistency(_archived_native_access_flags, get_native_access_flags_as_sorted_string(), "jdk.module.enable.native.access"); + + // Don't hold onto the pointer, in case we might decide to unmap the archive. + _archived_native_access_flags = nullptr; + } +} + void Modules::dump_addmods_names() { - unsigned int count = Arguments::addmods_count(); const char* addmods_names = get_addmods_names_as_sorted_string(); if (addmods_names != nullptr) { _archived_addmods_names = ArchiveBuilder::current()->ro_strdup(addmods_names); } - ArchivePtrMarker::mark_pointer(&_archived_addmods_names); +} + +const char* Modules::get_addmods_names_as_sorted_string() { + return get_numbered_property_as_sorted_string("jdk.module.addmods"); } void Modules::serialize_addmods_names(SerializeClosure* soc) { soc->do_ptr(&_archived_addmods_names); if (soc->reading()) { - bool disable = false; - if (_archived_addmods_names[0] != '\0') { - if (Arguments::addmods_count() == 0) { - log_info(cds)("--add-modules module name(s) found in archive but not specified during runtime: %s", - _archived_addmods_names); - disable = true; - } else { - const char* addmods_names = get_addmods_names_as_sorted_string(); - if (strcmp((const char*)_archived_addmods_names, addmods_names) != 0) { - log_info(cds)("Mismatched --add-modules module name(s)."); - log_info(cds)(" dump time: %s runtime: %s", _archived_addmods_names, addmods_names); - disable = true; - } - } - } else { - if (Arguments::addmods_count() > 0) { - log_info(cds)("--add-modules module name(s) specified during runtime but not found in archive: %s", - get_addmods_names_as_sorted_string()); - disable = true; - } - } - if (disable) { - log_info(cds)("Disabling optimized module handling"); - CDSConfig::stop_using_optimized_module_handling(); - } - log_info(cds)("optimized module handling: %s", CDSConfig::is_using_optimized_module_handling() ? "enabled" : "disabled"); - log_info(cds)("full module graph: %s", CDSConfig::is_using_full_module_graph() ? "enabled" : "disabled"); + check_archived_flag_consistency(_archived_addmods_names, get_addmods_names_as_sorted_string(), "jdk.module.addmods"); // Don't hold onto the pointer, in case we might decide to unmap the archive. _archived_addmods_names = nullptr; } } -const char* Modules::get_addmods_names_as_sorted_string() { +const char* Modules::get_numbered_property_as_sorted_string(const char* property) { ResourceMark rm; - const int max_digits = 3; + // theoretical string size limit for decimal int, but the following loop will end much sooner due to + // OS command-line size limit. + const int max_digits = 10; const int extra_symbols_count = 2; // includes '.', '\0' - size_t prop_len = strlen("jdk.module.addmods") + max_digits + extra_symbols_count; + size_t prop_len = strlen(property) + max_digits + extra_symbols_count; char* prop_name = resource_allocate_bytes(prop_len); GrowableArray list; - for (unsigned int i = 0; i < Arguments::addmods_count(); i++) { - jio_snprintf(prop_name, prop_len, "jdk.module.addmods.%d", i); + for (unsigned int i = 0;; i++) { + jio_snprintf(prop_name, prop_len, "%s.%d", property, i); const char* prop_value = Arguments::get_property(prop_name); + if (prop_value == nullptr) { + break; + } char* p = resource_allocate_bytes(strlen(prop_value) + 1); strcpy(p, prop_value); while (*p == ',') p++; // skip leading commas @@ -695,11 +719,12 @@ const char* Modules::get_addmods_names_as_sorted_string() { if (strcmp(m, last_string) != 0) { // filter out duplicates st.print("%s%s", prefix, m); last_string = m; - prefix = "\n"; + prefix = ","; } } - return (const char*)os::strdup(st.as_string()); // Example: "java.base,java.compiler" + const char* result = (const char*)os::strdup(st.as_string()); // Example: "java.base,java.compiler" + return strcmp(result, "") != 0 ? result : nullptr; } void Modules::define_archived_modules(Handle h_platform_loader, Handle h_system_loader, TRAPS) { diff --git a/src/hotspot/share/classfile/modules.hpp b/src/hotspot/share/classfile/modules.hpp index 3ef6f57a57b4c..03069bd345209 100644 --- a/src/hotspot/share/classfile/modules.hpp +++ b/src/hotspot/share/classfile/modules.hpp @@ -1,5 +1,5 @@ /* -* Copyright (c) 2016, 2023, 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 @@ -59,15 +59,25 @@ class Modules : AllStatic { static void define_archived_modules(Handle h_platform_loader, Handle h_system_loader, TRAPS) NOT_CDS_JAVA_HEAP_RETURN; static void verify_archived_modules() NOT_CDS_JAVA_HEAP_RETURN; + static void dump_archived_module_info() NOT_CDS_JAVA_HEAP_RETURN; + static void serialize_archived_module_info(SerializeClosure* soc) NOT_CDS_JAVA_HEAP_RETURN; static void dump_main_module_name() NOT_CDS_JAVA_HEAP_RETURN; static void serialize(SerializeClosure* soc) NOT_CDS_JAVA_HEAP_RETURN; + static void check_archived_flag_consistency(char* archived_flag, const char* runtime_flag, const char* property) NOT_CDS_JAVA_HEAP_RETURN; + + static void dump_native_access_flag() NOT_CDS_JAVA_HEAP_RETURN; + static const char* get_native_access_flags_as_sorted_string() NOT_CDS_JAVA_HEAP_RETURN_(nullptr); + static void serialize_native_access_flags(SerializeClosure* soc) NOT_CDS_JAVA_HEAP_RETURN; + static void dump_addmods_names() NOT_CDS_JAVA_HEAP_RETURN; - static void serialize_addmods_names(SerializeClosure* soc) NOT_CDS_JAVA_HEAP_RETURN; static const char* get_addmods_names_as_sorted_string() NOT_CDS_JAVA_HEAP_RETURN_(nullptr); + static void serialize_addmods_names(SerializeClosure* soc) NOT_CDS_JAVA_HEAP_RETURN; + static const char* get_numbered_property_as_sorted_string(const char* property) NOT_CDS_JAVA_HEAP_RETURN_(nullptr); #if INCLUDE_CDS_JAVA_HEAP static char* _archived_main_module_name; static char* _archived_addmods_names; + static char* _archived_native_access_flags; #endif // Provides the java.lang.Module for the unnamed module defined diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index 1917108519eaf..8df81ca0f94ce 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -320,33 +320,40 @@ static bool matches_property_suffix(const char* option, const char* property, si // any of the reserved module properties. // property should be passed without the leading "-D". bool Arguments::is_internal_module_property(const char* property) { - if (strncmp(property, MODULE_PROPERTY_PREFIX, MODULE_PROPERTY_PREFIX_LEN) == 0) { + return internal_module_property_helper(property, false); +} + +// Returns true if property is one of those recognized by is_internal_module_property() but +// is not supported by CDS archived full module graph. +bool Arguments::is_incompatible_cds_internal_module_property(const char* property) { + return internal_module_property_helper(property, true); +} + +bool Arguments::internal_module_property_helper(const char* property, bool check_for_cds) { + if (strncmp(property, MODULE_PROPERTY_PREFIX, MODULE_PROPERTY_PREFIX_LEN) == 0) { const char* property_suffix = property + MODULE_PROPERTY_PREFIX_LEN; if (matches_property_suffix(property_suffix, ADDEXPORTS, ADDEXPORTS_LEN) || matches_property_suffix(property_suffix, ADDREADS, ADDREADS_LEN) || matches_property_suffix(property_suffix, ADDOPENS, ADDOPENS_LEN) || matches_property_suffix(property_suffix, PATCH, PATCH_LEN) || - matches_property_suffix(property_suffix, ADDMODS, ADDMODS_LEN) || matches_property_suffix(property_suffix, LIMITMODS, LIMITMODS_LEN) || - matches_property_suffix(property_suffix, PATH, PATH_LEN) || matches_property_suffix(property_suffix, UPGRADE_PATH, UPGRADE_PATH_LEN) || - matches_property_suffix(property_suffix, ILLEGAL_NATIVE_ACCESS, ILLEGAL_NATIVE_ACCESS_LEN) || - matches_property_suffix(property_suffix, ENABLE_NATIVE_ACCESS, ENABLE_NATIVE_ACCESS_LEN)) { + matches_property_suffix(property_suffix, ILLEGAL_NATIVE_ACCESS, ILLEGAL_NATIVE_ACCESS_LEN)) { return true; } + + if (!check_for_cds) { + // CDS notes: these properties are supported by CDS archived full module graph. + if (matches_property_suffix(property_suffix, PATH, PATH_LEN) || + matches_property_suffix(property_suffix, ADDMODS, ADDMODS_LEN) || + matches_property_suffix(property_suffix, ENABLE_NATIVE_ACCESS, ENABLE_NATIVE_ACCESS_LEN)) { + return true; + } + } } return false; } -bool Arguments::is_add_modules_property(const char* key) { - return (strcmp(key, MODULE_PROPERTY_PREFIX ADDMODS) == 0); -} - -// Return true if the key matches the --module-path property name ("jdk.module.path"). -bool Arguments::is_module_path_property(const char* key) { - return (strcmp(key, MODULE_PROPERTY_PREFIX PATH) == 0); -} - // Process java launcher properties. void Arguments::process_sun_java_launcher_properties(JavaVMInitArgs* args) { // See if sun.java.launcher or sun.java.launcher.is_altjvm is defined. diff --git a/src/hotspot/share/runtime/arguments.hpp b/src/hotspot/share/runtime/arguments.hpp index 0b4d89f3ad2f2..cac0296b32771 100644 --- a/src/hotspot/share/runtime/arguments.hpp +++ b/src/hotspot/share/runtime/arguments.hpp @@ -365,6 +365,8 @@ class Arguments : AllStatic { static const char* handle_aliases_and_deprecation(const char* arg); static size_t _default_SharedBaseAddress; // The default value specified in globals.hpp + static bool internal_module_property_helper(const char* property, bool check_for_cds); + public: // Parses the arguments, first phase static jint parse(const JavaVMInitArgs* args); @@ -463,9 +465,7 @@ class Arguments : AllStatic { static int PropertyList_readable_count(SystemProperty* pl); static bool is_internal_module_property(const char* option); - static bool is_add_modules_property(const char* key); - static unsigned int addmods_count() { return _addmods_count; } - static bool is_module_path_property(const char* key); + static bool is_incompatible_cds_internal_module_property(const char* property); // Miscellaneous System property value getter and setters. static void set_dll_dir(const char *value) { _sun_boot_library_path->set_value(value); } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AOTClassLinkingVMOptions.java b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AOTClassLinkingVMOptions.java index 05fdf7c06d650..0d75d16d2b04e 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AOTClassLinkingVMOptions.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/aotClassLinking/AOTClassLinkingVMOptions.java @@ -125,7 +125,7 @@ static void modulePathTests() throws Exception { "--module-path", goodModulePath + "/bad", "--add-modules", CDSModulePathUtils.TEST_MODULE, CDSModulePathUtils.MAIN_CLASS) - .assertAbnormalExit("Mismatched --add-modules module name(s)", + .assertAbnormalExit("Mismatched values for property jdk.module.addmods", "CDS archive has aot-linked classes. It cannot be used when archived full module graph is not used."); } } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addmods/AddmodsOption.java b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addmods/AddmodsOption.java index 2d8f90e61fe20..7ce3e37cc8a93 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addmods/AddmodsOption.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addmods/AddmodsOption.java @@ -80,8 +80,8 @@ public static void main(String[] args) throws Exception { "-m", moduleOption, "-version"); oa.shouldHaveExitValue(0) - .shouldContain("Mismatched --add-modules module name(s).") - .shouldContain("dump time: jdk.jconsole runtime: jdk.incubator.vector") + .shouldContain("Mismatched values for property jdk.module.addmods") + .shouldContain("runtime jdk.incubator.vector dump time jdk.jconsole") .shouldContain(subgraphCannotBeUsed); // no module specified during runtime @@ -89,7 +89,7 @@ public static void main(String[] args) throws Exception { loggingOption, "-version"); oa.shouldHaveExitValue(0) - .shouldContain("Module jdk.httpserver specified during dump time but not during runtime") + .shouldContain("jdk.httpserver specified during dump time but not during runtime") .shouldContain(subgraphCannotBeUsed); // dump an archive without the --add-modules option @@ -109,7 +109,7 @@ public static void main(String[] args) throws Exception { "-m", moduleOption, "-version"); oa.shouldHaveExitValue(0) - .shouldContain("--add-modules module name(s) specified during runtime but not found in archive: jdk.jconsole") + .shouldContain("jdk.jconsole specified during runtime but not during dump time") // version of the jdk.httpserver module, e.g. java 22-ea .shouldMatch(versionPattern) .shouldContain(subgraphCannotBeUsed); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/module/EnableNativeAccessCDS.java b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/module/EnableNativeAccessCDS.java new file mode 100644 index 0000000000000..10c4000649b18 --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/module/EnableNativeAccessCDS.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 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 8342089 + * @summary Test consistency of --enable-native-access option for CDS dump time and runtime + * @requires vm.cds.write.archived.java.heap + * @requires vm.flagless + * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds + * @run driver EnableNativeAccessCDS + */ + +import jdk.test.lib.process.OutputAnalyzer; + +public class EnableNativeAccessCDS { + public static void main(String[] args) throws Exception { + final String module0 = "java.base"; + final String module1 = "jdk.httpserver"; + final String disabledOptimizedModule = "Disabling optimized module handling"; + final String loggingOption = "-Xlog:cds=debug"; + + String archiveName = TestCommon.getNewArchiveName("native-access"); + TestCommon.setCurrentArchiveName(archiveName); + + // dump a base archive with --enable-native-access=java.base + OutputAnalyzer oa = TestCommon.dumpBaseArchive( + archiveName, + loggingOption, + "--enable-native-access", module0, + "-version"); + oa.shouldHaveExitValue(0); + + // same module specified during runtime + oa = TestCommon.execCommon( + loggingOption, + "--enable-native-access", module0, + "-version"); + oa.shouldHaveExitValue(0) + .shouldContain("use_full_module_graph = true"); + + // different module specified during runtime + oa = TestCommon.execCommon( + loggingOption, + "--enable-native-access", module1, + "-version"); + oa.shouldHaveExitValue(0) + .shouldContain("Mismatched values for property jdk.module.enable.native.access: runtime jdk.httpserver dump time java.base") + .shouldContain(disabledOptimizedModule); + + // no module specified during runtime + oa = TestCommon.execCommon( + loggingOption, + "-version"); + oa.shouldHaveExitValue(0) + .shouldContain("Mismatched values for property jdk.module.enable.native.access: java.base specified during dump time but not during runtime") + .shouldContain(disabledOptimizedModule); + + // dump an archive without --enable-native-access option + archiveName = TestCommon.getNewArchiveName("no-native-access-modules"); + TestCommon.setCurrentArchiveName(archiveName); + oa = TestCommon.dumpBaseArchive( + archiveName, + loggingOption, + "-version"); + oa.shouldHaveExitValue(0); + + // run with --enable-native-access + oa = TestCommon.execCommon( + loggingOption, + "--enable-native-access", module0, + "-version"); + oa.shouldHaveExitValue(0) + .shouldContain("Mismatched values for property jdk.module.enable.native.access: java.base specified during runtime but not during dump time") + .shouldContain(disabledOptimizedModule); + + // dump an archive with multiple modules with native access + archiveName = TestCommon.getNewArchiveName("multiple-native-access-modules"); + TestCommon.setCurrentArchiveName(archiveName); + oa = TestCommon.dumpBaseArchive( + archiveName, + loggingOption, + "--enable-native-access", module0 + "," + module1, + "-version"); + oa.shouldHaveExitValue(0); + + // same module specified during runtime but in a different order + oa = TestCommon.execCommon( + loggingOption, + "--enable-native-access", module1 + "," + module0, + "-version"); + oa.shouldHaveExitValue(0) + .shouldContain("use_full_module_graph = true"); + + // same module specified during runtime but specifying --enable-native-access twice + oa = TestCommon.execCommon( + loggingOption, + "--enable-native-access", module0, + "--enable-native-access", module1, + "-version"); + oa.shouldHaveExitValue(0) + .shouldContain("use_full_module_graph = true"); + + // run with only one same module + oa = TestCommon.execCommon( + loggingOption, + "--enable-native-access", module0, + "-version"); + oa.shouldHaveExitValue(0) + .shouldContain("Mismatched values for property jdk.module.enable.native.access: runtime java.base dump time java.base,jdk.httpserver") + .shouldContain(disabledOptimizedModule); + } +} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/module/ModuleOption.java b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/module/ModuleOption.java index fa4fa5321eeb1..d9dcd59343077 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/module/ModuleOption.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/module/ModuleOption.java @@ -70,7 +70,7 @@ public static void main(String[] args) throws Exception { "-m", "jdk.compiler/com.sun.tools.javac.Main", "-version"); oa.shouldHaveExitValue(0) - .shouldContain("Mismatched modules: runtime jdk.compiler dump time jdk.httpserver") + .shouldContain("Mismatched values for property jdk.module.main: runtime jdk.compiler dump time jdk.httpserver") .shouldContain(subgraphCannotBeUsed); // no module specified during runtime @@ -78,7 +78,7 @@ public static void main(String[] args) throws Exception { loggingOption, "-version"); oa.shouldHaveExitValue(0) - .shouldContain("Module jdk.httpserver specified during dump time but not during runtime") + .shouldContain("Mismatched values for property jdk.module.main: jdk.httpserver specified during dump time but not during runtime") .shouldContain(subgraphCannotBeUsed); // dump an archive without the module option @@ -96,7 +96,7 @@ public static void main(String[] args) throws Exception { "-m", moduleOption, "-version"); oa.shouldHaveExitValue(0) - .shouldContain("Module jdk.httpserver specified during runtime but not during dump time") + .shouldContain("Mismatched values for property jdk.module.main: jdk.httpserver specified during runtime but not during dump time") // version of the jdk.httpserver module, e.g. java 22-ea .shouldMatch(versionPattern) .shouldContain(subgraphCannotBeUsed); From 3eaa7615cd7dc67eb78fb0a8f89d4e6662a0db37 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Tue, 3 Dec 2024 16:19:51 +0000 Subject: [PATCH 33/62] 8342086: FileInputStream.available() fails with "Incorrect function" for "nul" path (win) Reviewed-by: alanb --- .../windows/native/libjava/io_util_md.c | 12 +----- .../java/io/FileInputStream/Available.java | 39 ++++++++++++------- 2 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/java.base/windows/native/libjava/io_util_md.c b/src/java.base/windows/native/libjava/io_util_md.c index 4709bbbae240e..bae9803a564a3 100644 --- a/src/java.base/windows/native/libjava/io_util_md.c +++ b/src/java.base/windows/native/libjava/io_util_md.c @@ -342,16 +342,8 @@ handleNonSeekAvailable(FD fd, long *pbytes) { return FALSE; } - if (! PeekNamedPipe(han, NULL, 0, NULL, pbytes, NULL)) { - /* PeekNamedPipe fails when at EOF. In that case we - * simply make *pbytes = 0 which is consistent with the - * behavior we get on Solaris when an fd is at EOF. - * The only alternative is to raise and Exception, - * which isn't really warranted. - */ - if (GetLastError() != ERROR_BROKEN_PIPE) { - return FALSE; - } + if (!PeekNamedPipe(han, NULL, 0, NULL, pbytes, NULL)) { + // If PeekNamedPipe fails, set the number of available bytes to zero. *pbytes = 0; } return TRUE; diff --git a/test/jdk/java/io/FileInputStream/Available.java b/test/jdk/java/io/FileInputStream/Available.java index 8759d8d1d27c9..e5b5b8825d3db 100644 --- a/test/jdk/java/io/FileInputStream/Available.java +++ b/test/jdk/java/io/FileInputStream/Available.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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,25 +23,38 @@ /* * @test - * @bug 4129479 - * @summary Test if available would throw an IOException - * when the stream is closed. + * @bug 4129479 8342086 + * @summary Test that available throws an IOException if the stream is + * closed, and that available works correctly with the NUL + * device on Windows + * @run junit Available */ -import java.io.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledOnOs; +import org.junit.jupiter.api.condition.OS; +import static org.junit.jupiter.api.Assertions.*; public class Available { - public static void main(String args[]) throws Exception { + @Test + void throwAfterClose() throws IOException { File file = new File(System.getProperty("test.src", "."), "Available.java"); FileInputStream fis = new FileInputStream(file); fis.close(); - try { - fis.available(); - throw new Exception - ("available should throw an exception after stream is closed"); - } - catch (IOException e) { - } + assertThrows(IOException.class, () -> fis.available()); + } + + @Test + @EnabledOnOs(OS.WINDOWS) + void nulDevice() throws IOException { + File file = new File("nul"); + FileInputStream fis = new FileInputStream(file); + int n = fis.available(); + assertEquals(0, n, "available() returned non-zero value"); } } From 3c60f0b2bb75150d49da9ab94d88b767275de5e2 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 3 Dec 2024 16:28:41 +0000 Subject: [PATCH 34/62] 8345296: AArch64: VM crashes with SIGILL when prctl is disallowed Reviewed-by: eastigeevich, phh, aph --- src/hotspot/cpu/aarch64/vm_version_aarch64.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp b/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp index cf16fe3a08d56..87c7862e2503d 100644 --- a/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp @@ -444,7 +444,19 @@ void VM_Version::initialize() { } if (UseSVE > 0) { - _initial_sve_vector_length = get_current_sve_vector_length(); + int vl = get_current_sve_vector_length(); + if (vl < 0) { + warning("Unable to get SVE vector length on this system. " + "Disabling SVE. Specify -XX:UseSVE=0 to shun this warning."); + FLAG_SET_DEFAULT(UseSVE, 0); + } else if ((vl == 0) || ((vl % FloatRegister::sve_vl_min) != 0) || !is_power_of_2(vl)) { + warning("Detected SVE vector length (%d) should be a power of two and a multiple of %d. " + "Disabling SVE. Specify -XX:UseSVE=0 to shun this warning.", + vl, FloatRegister::sve_vl_min); + FLAG_SET_DEFAULT(UseSVE, 0); + } else { + _initial_sve_vector_length = vl; + } } // This machine allows unaligned memory accesses From e1910f2d19fce5cc78058154c7ddaaa8718973dc Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Tue, 3 Dec 2024 16:31:05 +0000 Subject: [PATCH 35/62] 8345397: Remove from g1HeapRegionRemSet.cpp Reviewed-by: shade --- src/hotspot/share/gc/g1/g1HeapRegionRemSet.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/hotspot/share/gc/g1/g1HeapRegionRemSet.cpp b/src/hotspot/share/gc/g1/g1HeapRegionRemSet.cpp index fe1590b94a839..c1343fd7dbffc 100644 --- a/src/hotspot/share/gc/g1/g1HeapRegionRemSet.cpp +++ b/src/hotspot/share/gc/g1/g1HeapRegionRemSet.cpp @@ -22,8 +22,6 @@ * */ -#include - #include "precompiled.hpp" #include "gc/g1/g1BlockOffsetTable.inline.hpp" #include "gc/g1/g1CardSetContainers.inline.hpp" From e9f6ba05264ecb2f1ca3983ea503778f301bf280 Mon Sep 17 00:00:00 2001 From: Roman Kennke Date: Tue, 3 Dec 2024 16:45:50 +0000 Subject: [PATCH 36/62] 8345293: Fix generational Shenandoah with compact headers Reviewed-by: shade, stuefe, ysr --- src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp index b2c8e0405e09b..2b34b2d5cfcf5 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.inline.hpp @@ -332,6 +332,11 @@ void ShenandoahHeap::increase_object_age(oop obj, uint additional_age) { uint ShenandoahHeap::get_object_age(oop obj) { markWord w = obj->mark(); assert(!w.is_marked(), "must not be forwarded"); + if (UseObjectMonitorTable) { + assert(LockingMode == LM_LIGHTWEIGHT, "Must use LW locking, too"); + assert(w.age() <= markWord::max_age, "Impossible!"); + return w.age(); + } if (w.has_monitor()) { w = w.monitor()->header(); } else if (w.is_being_inflated() || w.has_displaced_mark_helper()) { From 76e874c08e6434747ac4f4cb4d2e2edcde163b2a Mon Sep 17 00:00:00 2001 From: Chen Liang Date: Tue, 3 Dec 2024 16:59:57 +0000 Subject: [PATCH 37/62] 8345319: Fix the tag type in PoolEntry and AnnotationValue Reviewed-by: asotona --- .../java/lang/classfile/AnnotationValue.java | 6 ++-- .../classfile/constantpool/PoolEntry.java | 2 +- .../classfile/impl/AbstractPoolEntry.java | 36 +++++++++---------- .../classfile/impl/AnnotationImpl.java | 26 +++++++------- .../classfile/impl/AnnotationReader.java | 2 +- .../com/sun/tools/javap/AnnotationWriter.java | 13 +++---- .../AnnotationDefault/ExpectedValues.java | 4 +-- 7 files changed, 46 insertions(+), 43 deletions(-) diff --git a/src/java.base/share/classes/java/lang/classfile/AnnotationValue.java b/src/java.base/share/classes/java/lang/classfile/AnnotationValue.java index 8e92ef59a500d..45ed2fbbe8198 100644 --- a/src/java.base/share/classes/java/lang/classfile/AnnotationValue.java +++ b/src/java.base/share/classes/java/lang/classfile/AnnotationValue.java @@ -456,9 +456,11 @@ default ClassDesc classSymbol() { * * @apiNote * {@code TAG_}-prefixed constants in this class, such as {@link #TAG_INT}, - * describe the possible return values of this method. + * describe the possible return values of this method. The return type is + * {@code int} for consistency with union indicator items in other union + * structures in the {@code class} file format. */ - char tag(); + int tag(); /** * {@return an enum value for an element-value pair} diff --git a/src/java.base/share/classes/java/lang/classfile/constantpool/PoolEntry.java b/src/java.base/share/classes/java/lang/classfile/constantpool/PoolEntry.java index fdb8b497ff998..5762a92a061d7 100644 --- a/src/java.base/share/classes/java/lang/classfile/constantpool/PoolEntry.java +++ b/src/java.base/share/classes/java/lang/classfile/constantpool/PoolEntry.java @@ -98,7 +98,7 @@ public sealed interface PoolEntry * {@code TAG_}-prefixed constants in this class, such as {@link #TAG_UTF8}, * describe the possible return values of this method. */ - byte tag(); + int tag(); /** * {@return the index within the constant pool corresponding to this entry} diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractPoolEntry.java b/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractPoolEntry.java index 35b9f2dd1bb33..3e50773d59ec2 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractPoolEntry.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractPoolEntry.java @@ -104,7 +104,7 @@ public int hashCode() { return hash; } - public abstract byte tag(); + public abstract int tag(); public int width() { return 1; @@ -181,7 +181,7 @@ enum State { RAW, BYTE, CHAR, STRING } } @Override - public byte tag() { + public int tag() { return TAG_UTF8; } @@ -522,7 +522,7 @@ public static final class ClassEntryImpl extends AbstractNamedEntry implements C } @Override - public byte tag() { + public int tag() { return TAG_CLASS; } @@ -582,7 +582,7 @@ public static final class PackageEntryImpl extends AbstractNamedEntry implements } @Override - public byte tag() { + public int tag() { return TAG_PACKAGE; } @@ -613,7 +613,7 @@ public static final class ModuleEntryImpl extends AbstractNamedEntry implements } @Override - public byte tag() { + public int tag() { return TAG_MODULE; } @@ -645,7 +645,7 @@ public static final class NameAndTypeEntryImpl extends AbstractRefsEntry values) } @Override - public char tag() { + public int tag() { return TAG_ARRAY; } } @@ -201,7 +201,7 @@ public char tag() { public record OfEnumImpl(Utf8Entry className, Utf8Entry constantName) implements AnnotationValue.OfEnum { @Override - public char tag() { + public int tag() { return TAG_ENUM; } } @@ -209,7 +209,7 @@ public char tag() { public record OfAnnotationImpl(Annotation annotation) implements AnnotationValue.OfAnnotation { @Override - public char tag() { + public int tag() { return TAG_ANNOTATION; } } @@ -217,7 +217,7 @@ public char tag() { public record OfClassImpl(Utf8Entry className) implements AnnotationValue.OfClass { @Override - public char tag() { + public int tag() { return TAG_CLASS; } } diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/AnnotationReader.java b/src/java.base/share/classes/jdk/internal/classfile/impl/AnnotationReader.java index 5c4058e6dce4e..8abc221940a7b 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/AnnotationReader.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/AnnotationReader.java @@ -354,7 +354,7 @@ public static void writeTypeAnnotations(BufWriter buf, List list public static void writeAnnotationValue(BufWriterImpl buf, AnnotationValue value) { var tag = value.tag(); buf.writeU1(tag); - switch (value.tag()) { + switch (tag) { case TAG_BOOLEAN, TAG_BYTE, TAG_CHAR, TAG_DOUBLE, TAG_FLOAT, TAG_INT, TAG_LONG, TAG_SHORT, TAG_STRING -> buf.writeIndex(((AnnotationValue.OfConstant) value).constant()); case TAG_CLASS -> buf.writeIndex(((AnnotationValue.OfClass) value).className()); diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/javap/AnnotationWriter.java b/src/jdk.jdeps/share/classes/com/sun/tools/javap/AnnotationWriter.java index 66b978f252c53..d480cbb1690dd 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/javap/AnnotationWriter.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/AnnotationWriter.java @@ -225,11 +225,12 @@ private void writeIndex(PoolEntry entry, boolean resolveIndices) { } public void write(AnnotationValue value, boolean resolveIndices) { + var tagChar = (char) value.tag(); switch (value) { case AnnotationValue.OfConstant ev -> { if (resolveIndices) { var entry = ev.constant(); - switch (ev.tag()) { + switch (tagChar) { case 'B': print("(byte) "); print(constantWriter.stringValue(entry)); @@ -258,11 +259,11 @@ public void write(AnnotationValue value, boolean resolveIndices) { print("\""); break; default: - print(ev.tag() + "#" + entry.index()); + print(tagChar + "#" + entry.index()); break; } } else { - print(ev.tag() + "#" + ev.constant().index()); + print(tagChar + "#" + ev.constant().index()); } } case AnnotationValue.OfEnum ev -> { @@ -271,7 +272,7 @@ public void write(AnnotationValue value, boolean resolveIndices) { print("."); writeIndex(ev.constantName(), resolveIndices); } else { - print(ev.tag() + "#" + ev.className().index() + ".#" + print(tagChar + "#" + ev.className().index() + ".#" + ev.constantName().index()); } } @@ -280,11 +281,11 @@ public void write(AnnotationValue value, boolean resolveIndices) { print("class "); writeIndex(ev.className(), resolveIndices); } else { - print(ev.tag() + "#" + ev.className().index()); + print(tagChar + "#" + ev.className().index()); } } case AnnotationValue.OfAnnotation ev -> { - print(ev.tag()); + print(tagChar); AnnotationWriter.this.write(ev.annotation(), resolveIndices); } case AnnotationValue.OfArray ev -> { diff --git a/test/langtools/tools/javac/classfiles/attributes/AnnotationDefault/ExpectedValues.java b/test/langtools/tools/javac/classfiles/attributes/AnnotationDefault/ExpectedValues.java index 752ebc844eb87..f5e23f65e885b 100644 --- a/test/langtools/tools/javac/classfiles/attributes/AnnotationDefault/ExpectedValues.java +++ b/test/langtools/tools/javac/classfiles/attributes/AnnotationDefault/ExpectedValues.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 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 @@ -26,7 +26,7 @@ @Retention(RetentionPolicy.RUNTIME) public @interface ExpectedValues { - char tag(); + int tag(); String name(); String[] values(); } From 293323c3e210bc2a3e45a0a9bc99b55378be91d2 Mon Sep 17 00:00:00 2001 From: Dean Long Date: Tue, 3 Dec 2024 17:05:49 +0000 Subject: [PATCH 38/62] 8340141: C1: rework ciMethod::equals following 8338471 Reviewed-by: kvn, vlivanov --- src/hotspot/share/c1/c1_GraphBuilder.cpp | 2 +- src/hotspot/share/ci/ciMethod.cpp | 36 +++++++++++++----------- src/hotspot/share/ci/ciMethod.hpp | 3 +- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/hotspot/share/c1/c1_GraphBuilder.cpp b/src/hotspot/share/c1/c1_GraphBuilder.cpp index 02be6f8d49e4a..0179923bc306c 100644 --- a/src/hotspot/share/c1/c1_GraphBuilder.cpp +++ b/src/hotspot/share/c1/c1_GraphBuilder.cpp @@ -2121,7 +2121,7 @@ void GraphBuilder::invoke(Bytecodes::Code code) { } if (cha_monomorphic_target != nullptr) { - assert(!target->can_be_statically_bound() || target->equals(cha_monomorphic_target), ""); + assert(!target->can_be_statically_bound() || target == cha_monomorphic_target, ""); assert(!cha_monomorphic_target->is_abstract(), ""); if (!cha_monomorphic_target->can_be_statically_bound(actual_recv)) { // If we inlined because CHA revealed only a single target method, diff --git a/src/hotspot/share/ci/ciMethod.cpp b/src/hotspot/share/ci/ciMethod.cpp index a74a812c6a23b..80277b91d2264 100644 --- a/src/hotspot/share/ci/ciMethod.cpp +++ b/src/hotspot/share/ci/ciMethod.cpp @@ -742,6 +742,13 @@ ciMethod* ciMethod::find_monomorphic_target(ciInstanceKlass* caller, if (target() == nullptr) { return nullptr; } + + // Redefinition support. + if (this->is_old() || root_m->is_old() || target->is_old()) { + guarantee(CURRENT_THREAD_ENV->jvmti_state_changed(), "old method not detected"); + return nullptr; + } + if (target() == root_m->get_Method()) { return root_m; } @@ -781,22 +788,6 @@ bool ciMethod::can_omit_stack_trace() const { return _can_omit_stack_trace; } -// ------------------------------------------------------------------ -// ciMethod::equals -// -// Returns true if the methods are the same, taking redefined methods -// into account. -bool ciMethod::equals(const ciMethod* m) const { - if (this == m) return true; - VM_ENTRY_MARK; - Method* m1 = this->get_Method(); - Method* m2 = m->get_Method(); - if (m1->is_old()) m1 = m1->get_new_method(); - if (m2->is_old()) m2 = m2->get_new_method(); - return m1 == m2; -} - - // ------------------------------------------------------------------ // ciMethod::resolve_invoke // @@ -835,6 +826,12 @@ ciMethod* ciMethod::resolve_invoke(ciKlass* caller, ciKlass* exact_receiver, boo ciMethod* result = this; if (m != get_Method()) { + // Redefinition support. + if (this->is_old() || m->is_old()) { + guarantee(CURRENT_THREAD_ENV->jvmti_state_changed(), "old method not detected"); + return nullptr; + } + result = CURRENT_THREAD_ENV->get_method(m); } @@ -1495,3 +1492,10 @@ bool ciMethod::is_consistent_info(ciMethod* declared_method, ciMethod* resolved_ } // ------------------------------------------------------------------ +// ciMethod::is_old +// +// Return true for redefined methods +bool ciMethod::is_old() const { + ASSERT_IN_VM; + return get_Method()->is_old(); +} diff --git a/src/hotspot/share/ci/ciMethod.hpp b/src/hotspot/share/ci/ciMethod.hpp index cc524930192cd..eecd94275850a 100644 --- a/src/hotspot/share/ci/ciMethod.hpp +++ b/src/hotspot/share/ci/ciMethod.hpp @@ -360,13 +360,12 @@ class ciMethod : public ciMetadata { bool is_vector_method() const; bool is_object_initializer() const; bool is_scoped() const; + bool is_old() const; bool can_be_statically_bound(ciInstanceKlass* context) const; bool can_omit_stack_trace() const; - bool equals(const ciMethod* m) const; - // Replay data methods static void dump_name_as_ascii(outputStream* st, Method* method); void dump_name_as_ascii(outputStream* st); From 9267dfa63b1d6b3f339782d2b720055a3da8ae6a Mon Sep 17 00:00:00 2001 From: Justin Lu Date: Tue, 3 Dec 2024 17:16:09 +0000 Subject: [PATCH 39/62] 8344589: Update IANA Language Subtag Registry to Version 2024-11-19 Reviewed-by: iris, lancea, naoto --- .../share/data/lsrdata/language-subtag-registry.txt | 12 +++++++++++- .../java/util/Locale/LanguageSubtagRegistryTest.java | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/java.base/share/data/lsrdata/language-subtag-registry.txt b/src/java.base/share/data/lsrdata/language-subtag-registry.txt index 3079d77ed8b14..b00ea67e7e8ca 100644 --- a/src/java.base/share/data/lsrdata/language-subtag-registry.txt +++ b/src/java.base/share/data/lsrdata/language-subtag-registry.txt @@ -1,4 +1,4 @@ -File-Date: 2024-06-14 +File-Date: 2024-11-19 %% Type: language Subtag: aa @@ -47991,6 +47991,16 @@ Added: 2008-10-14 Prefix: kw %% Type: variant +Subtag: kleinsch +Description: Kleinschmidt orthography +Description: Allattaasitaamut +Added: 2024-07-20 +Prefix: kl +Prefix: kl-tunumiit +Comments: Orthography for Greenlandic designed by Samuel Kleinschmidt, + used from 1851 to 1973. +%% +Type: variant Subtag: kociewie Description: The Kociewie dialect of Polish Added: 2014-11-27 diff --git a/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java b/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java index cb3d4dde914ba..d143e025dd5d1 100644 --- a/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java +++ b/test/jdk/java/util/Locale/LanguageSubtagRegistryTest.java @@ -25,9 +25,9 @@ * @test * @bug 8025703 8040211 8191404 8203872 8222980 8225435 8241082 8242010 8247432 * 8258795 8267038 8287180 8302512 8304761 8306031 8308021 8313702 8318322 - * 8327631 8332424 8334418 + * 8327631 8332424 8334418 8344589 * @summary Checks the IANA language subtag registry data update - * (LSR Revision: 2024-06-14) with Locale and Locale.LanguageRange + * (LSR Revision: 2024-11-19) with Locale and Locale.LanguageRange * class methods. * @run main LanguageSubtagRegistryTest */ From 73b8b34a8c627dd31ee97f3a301bd9d92d7031ed Mon Sep 17 00:00:00 2001 From: Harshitha Onkar Date: Tue, 3 Dec 2024 17:37:16 +0000 Subject: [PATCH 40/62] 8344368: IndependenceSwingTest.java and IndependenceAWTTest.java failed: Selected text & clipboard contents differs Reviewed-by: azvegint, dnguyen, prr, kizune --- .../Independence/IndependenceAWTTest.java | 157 +++++++++-------- .../Independence/IndependenceSwingTest.java | 164 ++++++++++-------- 2 files changed, 178 insertions(+), 143 deletions(-) diff --git a/test/jdk/java/awt/datatransfer/Independence/IndependenceAWTTest.java b/test/jdk/java/awt/datatransfer/Independence/IndependenceAWTTest.java index 2ace3510d1fb9..990857182e73e 100644 --- a/test/jdk/java/awt/datatransfer/Independence/IndependenceAWTTest.java +++ b/test/jdk/java/awt/datatransfer/Independence/IndependenceAWTTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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,43 +21,67 @@ * questions. */ -import java.awt.*; -import java.awt.datatransfer.*; -import java.awt.event.*; -import java.util.Properties; /* * @test * @key headful + * @requires (os.family == "linux") * @summary To make sure that System & Primary clipboards should behave independently - * @author Jitender(jitender.singh@eng.sun.com) area=AWT - * @author dmitriy.ermashov@oracle.com * @library /lib/client * @build ExtendedRobot * @run main IndependenceAWTTest */ -public class IndependenceAWTTest { +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.EventQueue; +import java.awt.Frame; +import java.awt.HeadlessException; +import java.awt.Panel; +import java.awt.Point; +import java.awt.TextField; +import java.awt.Toolkit; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.StringSelection; +import java.awt.datatransfer.Transferable; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.InputEvent; +import java.awt.event.MouseEvent; - Frame frame; - Panel panel; - TextField tf1, tf2, tf3; - Clipboard sClip, pClip; +public class IndependenceAWTTest { + private static Frame frame; + private static TextField tf1; + private static TextField tf2; + private static TextField tf3; + private static Clipboard systemClip; + private static Clipboard primaryClip; + private static ExtendedRobot robot; + private static volatile Point ttf1Center; + private static volatile Point glideStartLocation; public static void main (String[] args) throws Exception { - new IndependenceAWTTest().doTest(); + try { + robot = new ExtendedRobot(); + EventQueue.invokeAndWait(IndependenceAWTTest::createAndShowUI); + robot.waitForIdle(); + robot.delay(1000); + test(); + } finally { + EventQueue.invokeAndWait(frame::dispose); + } } - public IndependenceAWTTest() { - - frame = new Frame(); + private static void createAndShowUI() { + frame = new Frame("IndependenceAWTTest"); frame.setSize(200, 200); // This textfield will be used to update the contents of clipboards tf1 = new TextField(); tf1.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent fe) { - tf1.setText("Clipboards_Independance_Testing"); + tf1.setText("Clipboards_Independence_Testing"); } }); @@ -65,7 +89,7 @@ public void focusGained(FocusEvent fe) { tf2 = new TextField(); tf3 = new TextField(); - panel = new Panel(); + Panel panel = new Panel(); panel.setLayout(new BorderLayout()); panel.add(tf2, BorderLayout.NORTH); @@ -73,38 +97,36 @@ public void focusGained(FocusEvent fe) { frame.add(tf1, BorderLayout.NORTH); frame.add(panel, BorderLayout.CENTER); + frame.setLocationRelativeTo(null); frame.setVisible(true); tf1.requestFocus(); } // Get System Selection i.e. Primary Clipboard - private void getPrimaryClipboard() { - Properties ps = System.getProperties(); - String operSys = ps.getProperty("os.name"); + private static void getPrimaryClipboard() { try { - pClip = Toolkit.getDefaultToolkit().getSystemSelection(); - if (pClip == null) - if ((operSys.substring(0,3)).equalsIgnoreCase("Win") || operSys.toLowerCase().contains("os x")) - System.out.println(operSys + "Operating system does not support system selection "); - else - throw new RuntimeException("Method getSystemSelection() is returning null on X11 platform"); - } catch(HeadlessException e) { + primaryClip = Toolkit.getDefaultToolkit().getSystemSelection(); + if (primaryClip == null) { + throw new RuntimeException("Method getSystemSelection() is returning null" + + " on Linux platform"); + } + } catch (HeadlessException e) { System.out.println("Headless exception thrown " + e); } } // Method to get the contents of both of the clipboards - public void getClipboardsContent() throws Exception { - sClip = Toolkit.getDefaultToolkit().getSystemClipboard(); + private static void getClipboardsContent() throws Exception { + systemClip = Toolkit.getDefaultToolkit().getSystemClipboard(); Transferable tp; Transferable ts; StringSelection content = new StringSelection(tf1.getText()); - sClip.setContents(content,content); + systemClip.setContents(content, content); - tp = pClip.getContents(this); - ts = sClip.getContents(this); + tp = primaryClip.getContents(null); + ts = systemClip.getContents(null); // Paste the contents of System clipboard on textfield tf2 while the paste the contents of // of primary clipboard on textfiled tf3 @@ -122,7 +144,7 @@ public void getClipboardsContent() throws Exception { } // Method to compare the Contents return by system & primary clipboard - public void compareText (boolean mustEqual) { + private static void compareText (boolean mustEqual) { if ((tf2.getText()).equals(tf3.getText())) { if (mustEqual) System.out.println("Selected text & clipboard contents are same\n"); @@ -136,40 +158,39 @@ public void compareText (boolean mustEqual) { } } - public void doTest() throws Exception { + private static void test() throws Exception { getPrimaryClipboard(); - ExtendedRobot robot = new ExtendedRobot(); - robot.waitForIdle(1000); - frame.setLocation(100, 100); - robot.waitForIdle(1000); - - if (pClip != null) { - Point ttf1Center = tf1.getLocationOnScreen(); - ttf1Center.translate(tf1.getWidth()/2, tf1.getHeight()/2); - - robot.glide(new Point(0, 0), ttf1Center); - robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); - robot.waitForIdle(20); - robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); - robot.waitForIdle(20); - robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); - robot.waitForIdle(20); - robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); - robot.waitForIdle(2000); - - getClipboardsContent(); - compareText(true); - - //Change the text selection to update the contents of primary clipboard - robot.mouseMove(ttf1Center); - robot.mousePress(MouseEvent.BUTTON1_MASK); - robot.delay(200); - robot.mouseMove(ttf1Center.x + 15, ttf1Center.y); - robot.mouseRelease(MouseEvent.BUTTON1_MASK); - robot.waitForIdle(2000); - - getClipboardsContent(); - compareText(false); - } + robot.waitForIdle(500); + + EventQueue.invokeAndWait(() -> { + Point center = tf1.getLocationOnScreen(); + center.translate(tf1.getWidth() / 2, tf1.getHeight() / 2); + ttf1Center = center; + + glideStartLocation = frame.getLocationOnScreen(); + glideStartLocation.x -= 10; + }); + + robot.glide(glideStartLocation, ttf1Center); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(20); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(500); + + getClipboardsContent(); + compareText(true); + + //Change the text selection to update the contents of primary clipboard + robot.mouseMove(ttf1Center); + robot.mousePress(MouseEvent.BUTTON1_DOWN_MASK); + robot.delay(20); + robot.mouseMove(ttf1Center.x + 15, ttf1Center.y); + robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(500); + + getClipboardsContent(); + compareText(false); } } diff --git a/test/jdk/java/awt/datatransfer/Independence/IndependenceSwingTest.java b/test/jdk/java/awt/datatransfer/Independence/IndependenceSwingTest.java index 4ee7dea6a545a..b2f594c13ae78 100644 --- a/test/jdk/java/awt/datatransfer/Independence/IndependenceSwingTest.java +++ b/test/jdk/java/awt/datatransfer/Independence/IndependenceSwingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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,8 +21,21 @@ * questions. */ -import javax.swing.*; -import java.awt.*; +/* + * @test + * @key headful + * @requires (os.family == "linux") + * @summary To make sure that System & Primary clipboards should behave independently + * @library /lib/client + * @build ExtendedRobot + * @run main IndependenceSwingTest + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.HeadlessException; +import java.awt.Point; +import java.awt.Toolkit; import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.StringSelection; @@ -31,40 +44,44 @@ import java.awt.event.FocusEvent; import java.awt.event.InputEvent; import java.awt.event.MouseEvent; -import java.util.Properties; -/* - * @test - * @key headful - * @summary To make sure that System & Primary clipboards should behave independently - * @author Jitender(jitender.singh@eng.sun.com) area=AWT - * @author dmitriy.ermashov@oracle.com - * @library /lib/client - * @build ExtendedRobot - * @run main IndependenceSwingTest - */ +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.SwingUtilities; public class IndependenceSwingTest { - - JFrame frame; - JPanel panel; - JTextField tf1, tf2, tf3; - Clipboard sClip, pClip; + private static JFrame frame; + private static JTextField tf1; + private static JTextField tf2; + private static JTextField tf3; + private static Clipboard systemClip; + private static Clipboard primaryClip; + private static ExtendedRobot robot; + private static volatile Point ttf1Center; + private static volatile Point glideStartLocation; public static void main (String[] args) throws Exception { - new IndependenceSwingTest().doTest(); + try { + robot = new ExtendedRobot(); + SwingUtilities.invokeAndWait(IndependenceSwingTest::createAndShowUI); + robot.waitForIdle(); + robot.delay(1000); + test(); + } finally { + SwingUtilities.invokeAndWait(frame::dispose); + } } - public IndependenceSwingTest() { - - frame = new JFrame(); + private static void createAndShowUI() { + frame = new JFrame("IndependenceSwingTest"); frame.setSize(200, 200); // This textfield will be used to update the contents of clipboards tf1 = new JTextField(); tf1.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent fe) { - tf1.setText("Clipboards_Independance_Testing"); + tf1.setText("Clipboards_Independence_Testing"); } }); @@ -72,7 +89,7 @@ public void focusGained(FocusEvent fe) { tf2 = new JTextField(); tf3 = new JTextField(); - panel = new JPanel(); + JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add(tf2, BorderLayout.NORTH); @@ -80,38 +97,36 @@ public void focusGained(FocusEvent fe) { frame.add(tf1, BorderLayout.NORTH); frame.add(panel, BorderLayout.CENTER); + frame.setLocationRelativeTo(null); frame.setVisible(true); tf1.requestFocus(); } // Get System Selection i.e. Primary Clipboard - private void getPrimaryClipboard() { - Properties ps = System.getProperties(); - String operSys = ps.getProperty("os.name"); + private static void getPrimaryClipboard() { try { - pClip = Toolkit.getDefaultToolkit().getSystemSelection(); - if (pClip == null) - if ((operSys.substring(0,3)).equalsIgnoreCase("Win") || operSys.toLowerCase().contains("os x")) - System.out.println(operSys + "Operating system does not support system selection "); - else - throw new RuntimeException("Method getSystemSelection() is returning null on X11 platform"); - } catch(HeadlessException e) { + primaryClip = Toolkit.getDefaultToolkit().getSystemSelection(); + if (primaryClip == null) { + throw new RuntimeException("Method getSystemSelection() is returning null" + + " on Linux platform"); + } + } catch (HeadlessException e) { System.out.println("Headless exception thrown " + e); } } // Method to get the contents of both of the clipboards - public void getClipboardsContent() throws Exception { - sClip = Toolkit.getDefaultToolkit().getSystemClipboard(); + private static void getClipboardsContent() throws Exception { + systemClip = Toolkit.getDefaultToolkit().getSystemClipboard(); Transferable tp; Transferable ts; StringSelection content = new StringSelection(tf1.getText()); - sClip.setContents(content,content); + systemClip.setContents(content, content); - tp = pClip.getContents(this); - ts = sClip.getContents(this); + tp = primaryClip.getContents(null); + ts = systemClip.getContents(null); // Paste the contents of System clipboard on textfield tf2 while the paste the contents of // of primary clipboard on textfiled tf3 @@ -129,7 +144,7 @@ public void getClipboardsContent() throws Exception { } // Method to compare the Contents return by system & primary clipboard - public void compareText (boolean mustEqual) { + private static void compareText (boolean mustEqual) { if ((tf2.getText()).equals(tf3.getText())) { if (mustEqual) System.out.println("Selected text & clipboard contents are same\n"); @@ -143,40 +158,39 @@ public void compareText (boolean mustEqual) { } } - public void doTest() throws Exception { + private static void test() throws Exception { getPrimaryClipboard(); - ExtendedRobot robot = new ExtendedRobot(); - robot.waitForIdle(1000); - frame.setLocation(100, 100); - robot.waitForIdle(1000); - - if (pClip != null) { - Point ttf1Center = tf1.getLocationOnScreen(); - ttf1Center.translate(tf1.getWidth()/2, tf1.getHeight()/2); - - robot.glide(new Point(0, 0), ttf1Center); - robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); - robot.waitForIdle(20); - robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); - robot.waitForIdle(20); - robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); - robot.waitForIdle(20); - robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); - robot.waitForIdle(2000); - - getClipboardsContent(); - compareText(true); - - //Change the text selection to update the contents of primary clipboard - robot.mouseMove(ttf1Center); - robot.mousePress(MouseEvent.BUTTON1_MASK); - robot.delay(200); - robot.mouseMove(ttf1Center.x + 15, ttf1Center.y); - robot.mouseRelease(MouseEvent.BUTTON1_MASK); - robot.waitForIdle(2000); - - getClipboardsContent(); - compareText(false); - } + robot.waitForIdle(500); + + SwingUtilities.invokeAndWait(() -> { + Point center = tf1.getLocationOnScreen(); + center.translate(tf1.getWidth() / 2, tf1.getHeight() / 2); + ttf1Center = center; + + glideStartLocation = frame.getLocationOnScreen(); + glideStartLocation.x -= 10; + }); + + robot.glide(glideStartLocation, ttf1Center); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(20); + robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); + robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(500); + + getClipboardsContent(); + compareText(true); + + //Change the text selection to update the contents of primary clipboard + robot.mouseMove(ttf1Center); + robot.mousePress(MouseEvent.BUTTON1_DOWN_MASK); + robot.delay(20); + robot.mouseMove(ttf1Center.x + 15, ttf1Center.y); + robot.mouseRelease(MouseEvent.BUTTON1_DOWN_MASK); + robot.waitForIdle(500); + + getClipboardsContent(); + compareText(false); } } From f37f64df8c44fffa25a0b337193d67016f8380f3 Mon Sep 17 00:00:00 2001 From: Damon Nguyen Date: Tue, 3 Dec 2024 18:18:13 +0000 Subject: [PATCH 41/62] 8343736: Test java/awt/Focus/UnaccessibleChoice/AccessibleChoiceTest.java failed: Choice can't be controlled by keyboard Reviewed-by: honkar, abhiscxk --- .../AccessibleChoiceTest.java | 97 +++++++++++-------- 1 file changed, 54 insertions(+), 43 deletions(-) diff --git a/test/jdk/java/awt/Focus/UnaccessibleChoice/AccessibleChoiceTest.java b/test/jdk/java/awt/Focus/UnaccessibleChoice/AccessibleChoiceTest.java index 7f17c1978e4ec..c30e29edd7db0 100644 --- a/test/jdk/java/awt/Focus/UnaccessibleChoice/AccessibleChoiceTest.java +++ b/test/jdk/java/awt/Focus/UnaccessibleChoice/AccessibleChoiceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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,74 +23,75 @@ import java.awt.Button; import java.awt.Choice; +import java.awt.EventQueue; import java.awt.FlowLayout; import java.awt.Frame; import java.awt.GraphicsConfiguration; import java.awt.GraphicsEnvironment; import java.awt.Point; import java.awt.Robot; -import java.awt.Window; import java.awt.event.FocusAdapter; import java.awt.event.FocusEvent; import java.awt.event.InputEvent; import java.awt.event.KeyEvent; import java.awt.image.BufferedImage; import java.io.File; -import java.io.IOException; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import javax.imageio.ImageIO; -/** +/* * @test * @bug 4478780 * @key headful * @summary Tests that Choice can be accessed and controlled by keyboard. */ -public class AccessibleChoiceTest { - //Declare things used in the test, like buttons and labels here - Frame frame = new Frame("window owner"); - Window win = new Window(frame); - Choice choice = new Choice(); - Button def = new Button("default owner"); - CountDownLatch go = new CountDownLatch(1); - - public static void main(final String[] args) throws IOException { - AccessibleChoiceTest app = new AccessibleChoiceTest(); - app.test(); - } - private void test() throws IOException { +public class AccessibleChoiceTest { + static Frame frame; + static Choice choice; + static Button button; + static volatile CountDownLatch go; + static volatile Point loc; + static volatile int bWidth; + static volatile int bHeight; + + public static void main(final String[] args) throws Exception { try { - init(); - start(); + createAndShowUI(); + test(); } finally { - if (frame != null) frame.dispose(); - if (win != null) win.dispose(); + if (frame != null) { + EventQueue.invokeAndWait(() -> frame.dispose()); + } } } - public void init() { - win.setLayout (new FlowLayout ()); - win.add(def); - def.addFocusListener(new FocusAdapter() { + public static void createAndShowUI() throws Exception { + go = new CountDownLatch(1); + EventQueue.invokeAndWait(() -> { + frame = new Frame("Accessible Choice Test Frame"); + choice = new Choice(); + button = new Button("default owner"); + frame.setLayout(new FlowLayout()); + frame.add(button); + button.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { go.countDown(); } }); - choice.add("One"); - choice.add("Two"); - win.add(choice); + choice.add("One"); + choice.add("Two"); + frame.add(choice); + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + }); } - public void start () throws IOException { - frame.setVisible(true); - win.pack(); - win.setLocation(100, 200); - win.setVisible(true); - - Robot robot = null; + public static void test() throws Exception { + Robot robot; try { robot = new Robot(); } catch (Exception ex) { @@ -98,12 +99,17 @@ public void start () throws IOException { } robot.waitForIdle(); robot.delay(1000); - robot.setAutoDelay(150); robot.setAutoWaitForIdle(true); // Focus default button and wait till it gets focus - Point loc = def.getLocationOnScreen(); - robot.mouseMove(loc.x+2, loc.y+2); + EventQueue.invokeAndWait(() -> { + loc = button.getLocationOnScreen(); + bWidth = button.getWidth(); + bHeight = button.getHeight(); + }); + robot.mouseMove(loc.x + bWidth / 2, + loc.y + bHeight / 2); + robot.delay(500); robot.mousePress(InputEvent.BUTTON1_DOWN_MASK); robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK); @@ -113,25 +119,30 @@ public void start () throws IOException { throw new RuntimeException("Interrupted !!!"); } - if (!def.isFocusOwner()) { + if (!button.isFocusOwner()) { throw new RuntimeException("Button doesn't have focus"); } + robot.delay(500); + // Press Tab key to move focus to Choice robot.keyPress(KeyEvent.VK_TAB); robot.keyRelease(KeyEvent.VK_TAB); robot.delay(500); - // Press Down key to select next item in the choice(Motif 2.1) + if (!choice.isFocusOwner()) { + throw new RuntimeException("Choice doesn't have focus"); + } + + // Press Down key to select next item in the choice // If bug exists we won't be able to do so robot.keyPress(KeyEvent.VK_DOWN); robot.keyRelease(KeyEvent.VK_DOWN); - robot.delay(500); - String osName = System.getProperty("os.name").toLowerCase(); if (osName.startsWith("mac")) { + robot.delay(500); robot.keyPress(KeyEvent.VK_DOWN); robot.keyRelease(KeyEvent.VK_DOWN); robot.delay(500); @@ -142,7 +153,7 @@ public void start () throws IOException { robot.delay(1000); // On success second item should be selected - if (choice.getSelectedItem() != choice.getItem(1)) { + if (!choice.getSelectedItem().equals(choice.getItem(1))) { // Print out os name to check if mac conditional is relevant System.err.println("Failed on os: " + osName); From 2be07b5f9d2f3f0b885feb08ff10a57824ea5748 Mon Sep 17 00:00:00 2001 From: Dmitry Markov Date: Tue, 3 Dec 2024 18:37:27 +0000 Subject: [PATCH 42/62] 8324491: Keyboard layout didn't keep its state if it was changed when dialog was active Reviewed-by: aivanov, azvegint --- .../windows/classes/sun/awt/windows/WInputMethod.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java b/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java index 1dcd4bf11af04..e893a58f9edfb 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WInputMethod.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -319,6 +319,10 @@ public void activate() { isLastFocussedActiveClient = isAc; } isActive = true; + + // Sync currentLocale with the Windows keyboard layout which could be changed + // while the component was inactive. + getLocale(); if (currentLocale != null) { setLocale(currentLocale, true); } From a49f0776eb176129f558b6fab3f50e0453f8cbcb Mon Sep 17 00:00:00 2001 From: Francisco Ferrari Bihurriet Date: Tue, 3 Dec 2024 18:44:31 +0000 Subject: [PATCH 43/62] 8345221: Replace legacy with new Provider APIs in SunNativeGSS Co-authored-by: Francisco Ferrari Bihurriet Co-authored-by: Martin Balao Reviewed-by: weijun --- .../jgss/wrapper/SunNativeProvider.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java b/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java index 00ba08f102843..2da15b8b6a6bc 100644 --- a/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java +++ b/src/java.security.jgss/share/classes/sun/security/jgss/wrapper/SunNativeProvider.java @@ -26,7 +26,6 @@ package sun.security.jgss.wrapper; import java.io.Serial; -import java.util.HashMap; import java.security.Provider; import jdk.internal.util.OperatingSystem; @@ -64,10 +63,10 @@ static void debug(String message) { System.err.println(NAME + ": " + message); } - private static final HashMap MECH_MAP = constructMechMap(); + private static final Oid[] MECH_OIDS = getMechOIDs(); @SuppressWarnings("restricted") - private static HashMap constructMechMap() { + private static Oid[] getMechOIDs() { try { // Ensure the InetAddress class is loaded before // loading j2gss. The library will access this class @@ -112,28 +111,29 @@ private static HashMap constructMechMap() { debug("Loaded GSS library: " + libName); } Oid[] mechs = GSSLibStub.indicateMechs(); - HashMap map = new HashMap<>(); - for (int i = 0; i < mechs.length; i++) { - if (DEBUG) { - debug("Native MF for " + mechs[i]); + if (DEBUG) { + for (Oid mech : mechs) { + debug("Native MF for " + mech); } - map.put("GssApiMechanism." + mechs[i], MF_CLASS); } - return map; + return mechs; } } return null; } - // initialize INSTANCE after MECH_MAP is constructed + // initialize INSTANCE after MECH_OIDS is constructed static final Provider INSTANCE = new SunNativeProvider(); public SunNativeProvider() { /* We are the Sun NativeGSS provider */ super(NAME, PROVIDER_VER, INFO); - if (MECH_MAP != null) { - putAll(MECH_MAP); + if (MECH_OIDS != null) { + for (Oid mech : MECH_OIDS) { + putService(new Service(this, "GssApiMechanism", + mech.toString(), MF_CLASS, null, null)); + } } } } From 157a4341f759931c178fdb5759dbb4b16df3dbf7 Mon Sep 17 00:00:00 2001 From: Jorn Vernee Date: Tue, 3 Dec 2024 19:58:01 +0000 Subject: [PATCH 44/62] 8345389: Bump missed copyright years for JDK-8336768 Reviewed-by: pminborg --- .../share/classes/jdk/internal/foreign/abi/LinkerOptions.java | 2 +- .../classes/jdk/internal/foreign/abi/NativeEntryPoint.java | 2 +- src/java.base/share/native/libfallbackLinker/fallbackLinker.c | 2 +- test/jdk/java/foreign/TestIllegalLink.java | 2 +- .../jdk/java/foreign/capturecallstate/TestCaptureCallState.java | 2 +- test/jdk/java/foreign/critical/TestCritical.java | 2 +- test/jdk/java/foreign/passheapsegment/TestPassHeapSegment.java | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/LinkerOptions.java b/src/java.base/share/classes/jdk/internal/foreign/abi/LinkerOptions.java index 9a19b5a8511aa..5ca410f40e2bb 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/LinkerOptions.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/LinkerOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 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 diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/NativeEntryPoint.java b/src/java.base/share/classes/jdk/internal/foreign/abi/NativeEntryPoint.java index 3926060e6bf15..abcc602791900 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/NativeEntryPoint.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/NativeEntryPoint.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 diff --git a/src/java.base/share/native/libfallbackLinker/fallbackLinker.c b/src/java.base/share/native/libfallbackLinker/fallbackLinker.c index 1548fb49e268b..5a85fedd77435 100644 --- a/src/java.base/share/native/libfallbackLinker/fallbackLinker.c +++ b/src/java.base/share/native/libfallbackLinker/fallbackLinker.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 diff --git a/test/jdk/java/foreign/TestIllegalLink.java b/test/jdk/java/foreign/TestIllegalLink.java index 2a9d5ad37826d..45239e3cb458b 100644 --- a/test/jdk/java/foreign/TestIllegalLink.java +++ b/test/jdk/java/foreign/TestIllegalLink.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 diff --git a/test/jdk/java/foreign/capturecallstate/TestCaptureCallState.java b/test/jdk/java/foreign/capturecallstate/TestCaptureCallState.java index a1bf1183fb59a..7b34ef76add45 100644 --- a/test/jdk/java/foreign/capturecallstate/TestCaptureCallState.java +++ b/test/jdk/java/foreign/capturecallstate/TestCaptureCallState.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 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 diff --git a/test/jdk/java/foreign/critical/TestCritical.java b/test/jdk/java/foreign/critical/TestCritical.java index 85aa962383b9b..60b76623b0ebb 100644 --- a/test/jdk/java/foreign/critical/TestCritical.java +++ b/test/jdk/java/foreign/critical/TestCritical.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 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 diff --git a/test/jdk/java/foreign/passheapsegment/TestPassHeapSegment.java b/test/jdk/java/foreign/passheapsegment/TestPassHeapSegment.java index 375c672a60695..4ca0eb7bb8204 100644 --- a/test/jdk/java/foreign/passheapsegment/TestPassHeapSegment.java +++ b/test/jdk/java/foreign/passheapsegment/TestPassHeapSegment.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 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 From 0664b517650c622dcf21f8bd2e3e389e7d81bbab Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Tue, 3 Dec 2024 20:32:36 +0000 Subject: [PATCH 45/62] 8344987: Test serviceability/sa/TestJhsdbJstackPrintVMLocks.java fails: NoClassDefFoundError: jdk/test/lib/Utils Reviewed-by: cjplummer --- test/hotspot/jtreg/TEST.groups | 1 + 1 file changed, 1 insertion(+) diff --git a/test/hotspot/jtreg/TEST.groups b/test/hotspot/jtreg/TEST.groups index d04ed90ae0716..d68c015496c0a 100644 --- a/test/hotspot/jtreg/TEST.groups +++ b/test/hotspot/jtreg/TEST.groups @@ -491,6 +491,7 @@ hotspot_cds_relocation = \ runtime/modules/PatchModule/PatchModuleClassList.java \ runtime/NMT \ serviceability/sa \ + -serviceability/sa/TestJhsdbJstackPrintVMLocks.java \ -runtime/cds/DeterministicDump.java hotspot_cds_verify_shared_spaces = \ From 05ee562a38bf7325becdd04f2e9d3238b95a4cb0 Mon Sep 17 00:00:00 2001 From: Severin Gehwolf Date: Tue, 3 Dec 2024 20:41:48 +0000 Subject: [PATCH 46/62] 8343839: Detect patched modules and abort run-time image link early Reviewed-by: mchung --- .../jlink/internal/ImageFileCreator.java | 42 +++---------- .../jdk/tools/jlink/internal/JRTArchive.java | 19 ++---- .../jdk/tools/jlink/internal/JlinkTask.java | 12 +++- .../RuntimeImageLinkException.java | 62 ------------------- .../tools/jlink/resources/jlink.properties | 4 +- .../jdk/tools/jlink/ImageFileCreatorTest.java | 2 +- .../runtimeImage/ModifiedFilesExitTest.java | 2 +- .../ModifiedFilesWarningTest.java | 2 +- .../PatchedJDKModuleJlinkTest.java | 6 +- 9 files changed, 30 insertions(+), 121 deletions(-) delete mode 100644 src/jdk.jlink/share/classes/jdk/tools/jlink/internal/runtimelink/RuntimeImageLinkException.java diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java index 466c5d0a14cfe..9e05fe31aa9ab 100644 --- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java +++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/ImageFileCreator.java @@ -32,6 +32,7 @@ import java.io.DataOutputStream; import java.io.IOException; import java.io.OutputStream; +import java.io.UncheckedIOException; import java.nio.ByteOrder; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -56,7 +57,6 @@ import jdk.tools.jlink.internal.runtimelink.JimageDiffGenerator.ImageResource; import jdk.tools.jlink.internal.runtimelink.ResourceDiff; import jdk.tools.jlink.internal.runtimelink.ResourcePoolReader; -import jdk.tools.jlink.internal.runtimelink.RuntimeImageLinkException; import jdk.tools.jlink.plugin.PluginException; import jdk.tools.jlink.plugin.ResourcePool; import jdk.tools.jlink.plugin.ResourcePoolBuilder; @@ -91,14 +91,11 @@ public final class ImageFileCreator { private final Map> entriesForModule = new HashMap<>(); private final ImagePluginStack plugins; private final boolean generateRuntimeImage; - private final TaskHelper helper; private ImageFileCreator(ImagePluginStack plugins, - boolean generateRuntimeImage, - TaskHelper taskHelper) { + boolean generateRuntimeImage) { this.plugins = Objects.requireNonNull(plugins); this.generateRuntimeImage = generateRuntimeImage; - this.helper = taskHelper; } /** @@ -118,24 +115,20 @@ private ImageFileCreator(ImagePluginStack plugins, public static ExecutableImage create(Set archives, ByteOrder byteOrder, ImagePluginStack plugins, - boolean generateRuntimeImage, - TaskHelper taskHelper) + boolean generateRuntimeImage) throws IOException { ImageFileCreator image = new ImageFileCreator(plugins, - generateRuntimeImage, - taskHelper); + generateRuntimeImage); try { image.readAllEntries(archives); // write to modular image image.writeImage(archives, byteOrder); - } catch (RuntimeImageLinkException e) { - // readAllEntries() might throw this exception. - // Propagate as IOException with appropriate message for - // jlink runs from the run-time image. This handles better - // error messages for the case of modified files in the run-time - // image. - throw image.newIOException(e); + } catch (UncheckedIOException e) { + // When linking from the run-time image, readAllEntries() might + // throw this exception for a modified runtime. Unpack and + // re-throw as IOException. + throw e.getCause(); } finally { // Close all archives for (Archive a : archives) { @@ -200,11 +193,6 @@ private void writeImage(Set archives, ResourcePool result = null; try (DataOutputStream out = plugins.getJImageFileOutputStream()) { result = generateJImage(allContent, writer, plugins, out, generateRuntimeImage); - } catch (RuntimeImageLinkException e) { - // Propagate as IOException with appropriate message for - // jlink runs from the run-time image. This handles better - // error messages for the case of --patch-module. - throw newIOException(e); } //Handle files. @@ -218,18 +206,6 @@ private void writeImage(Set archives, } } - private IOException newIOException(RuntimeImageLinkException e) throws IOException { - if (JlinkTask.DEBUG) { - e.printStackTrace(); - } - String message = switch (e.getReason()) { - case PATCH_MODULE -> helper.getMessage("err.runtime.link.patched.module", e.getFile()); - case MODIFIED_FILE -> helper.getMessage("err.runtime.link.modified.file", e.getFile()); - default -> throw new AssertionError("Unexpected value: " + e.getReason()); - }; - throw new IOException(message); - } - /** * Create a jimage based on content of the given ResourcePoolManager, * optionally creating a runtime that can be used for linking from the diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JRTArchive.java b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JRTArchive.java index 755afea8c60b3..df7d35ac777ea 100644 --- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JRTArchive.java +++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JRTArchive.java @@ -26,8 +26,6 @@ package jdk.tools.jlink.internal; import static jdk.tools.jlink.internal.LinkableRuntimeImage.RESPATH_PATTERN; -import static jdk.tools.jlink.internal.runtimelink.RuntimeImageLinkException.Reason.MODIFIED_FILE; -import static jdk.tools.jlink.internal.runtimelink.RuntimeImageLinkException.Reason.PATCH_MODULE; import java.io.ByteArrayInputStream; import java.io.IOException; @@ -37,7 +35,6 @@ import java.lang.module.ModuleReference; import java.nio.charset.StandardCharsets; import java.nio.file.Files; -import java.nio.file.NoSuchFileException; import java.nio.file.Path; import java.nio.file.Paths; import java.security.MessageDigest; @@ -56,7 +53,6 @@ import jdk.internal.util.OperatingSystem; import jdk.tools.jlink.internal.Archive.Entry.EntryType; import jdk.tools.jlink.internal.runtimelink.ResourceDiff; -import jdk.tools.jlink.internal.runtimelink.RuntimeImageLinkException; import jdk.tools.jlink.plugin.ResourcePoolEntry; import jdk.tools.jlink.plugin.ResourcePoolEntry.Type; @@ -223,7 +219,9 @@ private void addNonClassResources() { Path path = BASE.resolve(m.resPath); if (shaSumMismatch(path, m.hashOrTarget, m.symlink)) { if (errorOnModifiedFile) { - throw new RuntimeImageLinkException(path.toString(), MODIFIED_FILE); + String msg = taskHelper.getMessage("err.runtime.link.modified.file", path.toString()); + IOException cause = new IOException(msg); + throw new UncheckedIOException(cause); } else { taskHelper.warning("err.runtime.link.modified.file", path.toString()); } @@ -460,16 +458,7 @@ public long size() { // the underlying base path is a JrtPath with the // JrtFileSystem underneath which is able to handle // this size query. - try { - return Files.size(archive.getPath().resolve(resPath)); - } catch (NoSuchFileException file) { - // This indicates that we don't find the class in the - // modules image using the JRT FS provider. Yet, we find - // the class using the system module finder. Therefore, - // we have a patched module. Mention that module patching - // is not supported. - throw new RuntimeImageLinkException(file.getFile(), PATCH_MODULE); - } + return Files.size(archive.getPath().resolve(resPath)); } } catch (IOException e) { throw new UncheckedIOException(e); diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java index 15998d6b92959..0eda0b5d45531 100644 --- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java +++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java @@ -63,6 +63,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import jdk.internal.module.ModuleBootstrap; import jdk.internal.module.ModulePath; import jdk.internal.module.ModuleReferenceImpl; import jdk.internal.module.ModuleResolution; @@ -73,7 +74,6 @@ import jdk.tools.jlink.internal.TaskHelper.BadArgs; import jdk.tools.jlink.internal.TaskHelper.Option; import jdk.tools.jlink.internal.TaskHelper.OptionsHelper; -import jdk.tools.jlink.internal.runtimelink.RuntimeImageLinkException; import jdk.tools.jlink.plugin.PluginException; /** @@ -309,7 +309,7 @@ int run(String[] args) { } cleanupOutput(outputPath); return EXIT_ERROR; - } catch (IllegalArgumentException | ResolutionException | RuntimeImageLinkException e) { + } catch (IllegalArgumentException | ResolutionException e) { log.println(taskHelper.getMessage("error.prefix") + " " + e.getMessage()); if (DEBUG) { e.printStackTrace(log); @@ -620,6 +620,12 @@ private static ImageHelper createImageProvider(JlinkConfiguration config, String msg = taskHelper.getMessage("err.runtime.link.jdk.jlink.prohibited"); throw new IllegalArgumentException(msg); } + // Do not permit linking from run-time image when the current image + // is being patched. + if (ModuleBootstrap.patcher().hasPatches()) { + String msg = taskHelper.getMessage("err.runtime.link.patched.module"); + throw new IllegalArgumentException(msg); + } // Print info message indicating linking from the run-time image if (verbose && log != null) { @@ -1039,7 +1045,7 @@ private static record ImageHelper(Set archives, @Override public ExecutableImage retrieve(ImagePluginStack stack) throws IOException { ExecutableImage image = ImageFileCreator.create(archives, - targetPlatform.arch().byteOrder(), stack, generateRuntimeImage, taskHelper); + targetPlatform.arch().byteOrder(), stack, generateRuntimeImage); if (packagedModulesPath != null) { // copy the packaged modules to the given path Files.createDirectories(packagedModulesPath); diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/runtimelink/RuntimeImageLinkException.java b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/runtimelink/RuntimeImageLinkException.java deleted file mode 100644 index 9f54fd63476ff..0000000000000 --- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/runtimelink/RuntimeImageLinkException.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2024, Red Hat, Inc. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.tools.jlink.internal.runtimelink; - -import java.util.Objects; - -/** - * Exception thrown when linking from the run-time image - */ -public class RuntimeImageLinkException extends RuntimeException { - - private static final long serialVersionUID = -1848914673073119403L; - - public static enum Reason { - PATCH_MODULE, /* link exception due to patched module */ - MODIFIED_FILE, /* link exception due to modified file */ - } - - private final String file; - private final Reason reason; - - public RuntimeImageLinkException(String file, Reason reason) { - this.file = Objects.requireNonNull(file); - this.reason = Objects.requireNonNull(reason); - } - - public String getFile() { - return file; - } - - public Reason getReason() { - return reason; - } - - @Override - public String getMessage() { - return reason + ", file: " + file; - } -} diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties b/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties index 9e18177d9c84f..b5880a3556155 100644 --- a/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties +++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties @@ -125,8 +125,8 @@ err.runtime.link.jdk.jlink.prohibited=This JDK does not contain packaged modules err.runtime.link.packaged.mods=This JDK has no packaged modules.\ \ --keep-packaged-modules is not supported err.runtime.link.modified.file={0} has been modified -err.runtime.link.patched.module=File {0} not found in the modules image.\ -\ --patch-module is not supported when linking from the run-time image +err.runtime.link.patched.module=jlink does not support linking from the run-time image\ +\ when running on a patched runtime with --patch-module err.empty.module.path=empty module path err.jlink.version.mismatch=jlink version {0}.{1} does not match target java.base version {2}.{3} err.automatic.module:automatic module cannot be used with jlink: {0} from {1} diff --git a/test/jdk/tools/jlink/ImageFileCreatorTest.java b/test/jdk/tools/jlink/ImageFileCreatorTest.java index b6466c6a4d91d..52a878e566a2d 100644 --- a/test/jdk/tools/jlink/ImageFileCreatorTest.java +++ b/test/jdk/tools/jlink/ImageFileCreatorTest.java @@ -224,6 +224,6 @@ public void storeFiles(ResourcePool content) { ImagePluginStack stack = new ImagePluginStack(noopBuilder, Collections.emptyList(), null, false); - ImageFileCreator.create(archives, ByteOrder.nativeOrder(), stack, false, null); + ImageFileCreator.create(archives, ByteOrder.nativeOrder(), stack, false); } } diff --git a/test/jdk/tools/jlink/runtimeImage/ModifiedFilesExitTest.java b/test/jdk/tools/jlink/runtimeImage/ModifiedFilesExitTest.java index 90abe14c2148f..777ce302ce799 100644 --- a/test/jdk/tools/jlink/runtimeImage/ModifiedFilesExitTest.java +++ b/test/jdk/tools/jlink/runtimeImage/ModifiedFilesExitTest.java @@ -78,7 +78,7 @@ public boolean test(OutputAnalyzer t) { } analyzer.stdoutShouldContain(modifiedFile.toString() + " has been modified"); // Verify the error message is reasonable - analyzer.stdoutShouldNotContain("jdk.tools.jlink.internal.RunImageLinkException"); + analyzer.stdoutShouldNotContain("IOException"); analyzer.stdoutShouldNotContain("java.lang.IllegalArgumentException"); } diff --git a/test/jdk/tools/jlink/runtimeImage/ModifiedFilesWarningTest.java b/test/jdk/tools/jlink/runtimeImage/ModifiedFilesWarningTest.java index 935d80dee4fb9..c871024f37cfa 100644 --- a/test/jdk/tools/jlink/runtimeImage/ModifiedFilesWarningTest.java +++ b/test/jdk/tools/jlink/runtimeImage/ModifiedFilesWarningTest.java @@ -70,6 +70,6 @@ void testAndAssert(Path modifiedFile, Helper helper, Path initialImage) throws E // verify we get the warning message out.stdoutShouldMatch("Warning: .* has been modified"); out.stdoutShouldNotContain("java.lang.IllegalArgumentException"); - out.stdoutShouldNotContain("jdk.tools.jlink.internal.RunImageLinkException"); + out.stdoutShouldNotContain("IOException"); } } diff --git a/test/jdk/tools/jlink/runtimeImage/PatchedJDKModuleJlinkTest.java b/test/jdk/tools/jlink/runtimeImage/PatchedJDKModuleJlinkTest.java index f83c4c698f16b..d4654ec98bdc3 100644 --- a/test/jdk/tools/jlink/runtimeImage/PatchedJDKModuleJlinkTest.java +++ b/test/jdk/tools/jlink/runtimeImage/PatchedJDKModuleJlinkTest.java @@ -97,10 +97,10 @@ public boolean test(OutputAnalyzer t) { if (analyzer.getExitValue() == 0) { throw new AssertionError("Expected jlink to fail due to patched module!"); } - analyzer.stdoutShouldContain("MyJlinkPatchInteger.class not found in the modules image."); - analyzer.stdoutShouldContain("--patch-module is not supported"); + analyzer.stdoutShouldContain("jlink does not support linking from the run-time image"); + analyzer.stdoutShouldContain(" when running on a patched runtime with --patch-module"); // Verify the error message is reasonable - analyzer.stdoutShouldNotContain("jdk.tools.jlink.internal.RunImageLinkException"); + analyzer.stdoutShouldNotContain("IOException"); analyzer.stdoutShouldNotContain("java.lang.IllegalArgumentException"); } From 82e8aa62de5d6854978efd66190654f05299e523 Mon Sep 17 00:00:00 2001 From: Weijun Wang Date: Tue, 3 Dec 2024 22:41:47 +0000 Subject: [PATCH 47/62] 8345415: Rollback JDK-8301991 change on xmlsecurity_de.properties Reviewed-by: mullan --- .../resource/xmlsecurity_de.properties | 152 +++++++++--------- 1 file changed, 76 insertions(+), 76 deletions(-) diff --git a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/resource/xmlsecurity_de.properties b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/resource/xmlsecurity_de.properties index 1373f3bfa5f78..3d4306e988f7e 100644 --- a/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/resource/xmlsecurity_de.properties +++ b/src/java.xml.crypto/share/classes/com/sun/org/apache/xml/internal/security/resource/xmlsecurity_de.properties @@ -20,36 +20,36 @@ # algorithm.alreadyRegistered = URI {0} wurde bereits an die Klasse {1} gebunden -algorithm.classDoesNotExist = Kann URI {0} nicht für Klasse {1} registrieren weil sie nicht existiert +algorithm.classDoesNotExist = Kann URI {0} nicht f\u00fcr Klasse {1} registrieren weil sie nicht existiert algorithm.ClassDoesNotExist = Klasse {0} existiert nicht -algorithm.extendsWrongClass = Kann URI {0} nicht für Klasse {1} registrieren weil sie nicht von {2} abgeleitet ist -algorithms.CannotUseAlgorithmParameterSpecOnDSA = AlgorithmParameterSpec kann nicht für DSA Signaturen benutzt werden. -algorithms.CannotUseAlgorithmParameterSpecOnRSA = AlgorithmParameterSpec kann nicht für RSA Signaturen benutzt werden. -algorithms.CannotUseSecureRandomOnMAC = SecureRandom kann nicht für MAC's angewandt werden. +algorithm.extendsWrongClass = Kann URI {0} nicht f\u00fcr Klasse {1} registrieren weil sie nicht von {2} abgeleitet ist +algorithms.CannotUseAlgorithmParameterSpecOnDSA = AlgorithmParameterSpec kann nicht f\u00fcr DSA Signaturen benutzt werden. +algorithms.CannotUseAlgorithmParameterSpecOnRSA = AlgorithmParameterSpec kann nicht f\u00fcr RSA Signaturen benutzt werden. +algorithms.CannotUseSecureRandomOnMAC = SecureRandom kann nicht f\u00fcr MAC's angewandt werden. algorithms.HMACOutputLengthMax = HMACOutputLength darf nicht grosser als {0} sein algorithms.HMACOutputLengthMin = HMACOutputLength darf nicht kleiner als {0} sein -algorithms.HMACOutputLengthOnlyForHMAC = Die HMACOutputLength kann nur bei HMAC integritäts Algorithmen angegeben werden +algorithms.HMACOutputLengthOnlyForHMAC = Die HMACOutputLength kann nur bei HMAC integrit\u00e4ts Algorithmen angegeben werden algorithms.MissingRSAPSSParams = RSAPSSParams is a required Element for http://www.w3.org/2007/05/xmldsig-more#rsa-pss -algorithms.NoSuchAlgorithm = Der Algorithmus {0} ist nicht verfügbar. -algorithms.NoSuchAlgorithm = Der Algorithmus {0} ist nicht verfügbar. Original Nachricht war\: {1} +algorithms.NoSuchAlgorithm = Der Algorithmus {0} ist nicht verf\u00fcgbar. +algorithms.NoSuchAlgorithm = Der Algorithmus {0} ist nicht verf\u00fcgbar. Original Nachricht war\: {1} algorithms.NoSuchMap = Algorithmus URI "{0}" konnte auf keinen JCE Algorithmus gemappt werden algorithms.NoSuchProvider = Der angegebene Provider {0} existiert nicht. Original Nachricht war\: {1} -algorithms.operationOnlyVerification = Ein öffentlicher Schlüssel (public key) kann nur zur Verifizierung einer Signatur verwendet werden. -algorithms.WrongKeyForThisOperation = Der angegebene Schlüssel-Typ kann nicht für diese Operation verwendet werden. Angegeben wurde {0} aber ein {1} wird benötigt. +algorithms.operationOnlyVerification = Ein \u00f6ffentlicher Schl\u00fcssel (public key) kann nur zur Verifizierung einer Signatur verwendet werden. +algorithms.WrongKeyForThisOperation = Der angegebene Schl\u00fcssel-Typ kann nicht f\u00fcr diese Operation verwendet werden. Angegeben wurde {0} aber ein {1} wird ben\u00f6tigt. attributeValueIllegal = Das Attribut {0} hat den Wert {1} muss aber {2} sein. -c14n.Canonicalizer.Exception = Fehler während der Kanonisierung\: Original Nachricht war {0} -c14n.Canonicalizer.IllegalNode = Unzulässiger NodeType {0}, NodeName lautete {1} +c14n.Canonicalizer.Exception = Fehler w\u00e4hrend der Kanonisierung\: Original Nachricht war {0} +c14n.Canonicalizer.IllegalNode = Unzul\u00e4ssiger NodeType {0}, NodeName lautete {1} c14n.Canonicalizer.NoSuchCanonicalizer = Kein Kanonisierer mit dem URI {0} gefunden -c14n.Canonicalizer.ParserConfigurationException = ParserConfigurationException während der Kanonisierung\: Original Nachricht war {0} +c14n.Canonicalizer.ParserConfigurationException = ParserConfigurationException w\u00e4hrend der Kanonisierung\: Original Nachricht war {0} c14n.Canonicalizer.RelativeNamespace = Das Element {0} hat einen relativen Namespace: {1}="{2}" -c14n.Canonicalizer.SAXException = SAXException während der Kanonisierung\: Original Nachricht war {0} -c14n.Canonicalizer.TraversalNotSupported = Das DOM Dokument unterstützt keine Traversal {0} -c14n.Canonicalizer.UnsupportedEncoding = Nicht unterstützte Kodierung {0} -c14n.Canonicalizer.UnsupportedOperation = Der Kanonisierer unterstützt diese Operation nicht -c14n.XMLUtils.circumventBug2650forgotten = Die Baumstruktur wurde nicht vorbereitet für die Kanonisierung mit XMLUtils\#circumventBug2650(Document) +c14n.Canonicalizer.SAXException = SAXException w\u00e4hrend der Kanonisierung\: Original Nachricht war {0} +c14n.Canonicalizer.TraversalNotSupported = Das DOM Dokument unterst\u00fctzt keine Traversal {0} +c14n.Canonicalizer.UnsupportedEncoding = Nicht unterst\u00fctzte Kodierung {0} +c14n.Canonicalizer.UnsupportedOperation = Der Kanonisierer unterst\u00fctzt diese Operation nicht +c14n.XMLUtils.circumventBug2650forgotten = Die Baumstruktur wurde nicht vorbereitet f\u00fcr die Kanonisierung mit XMLUtils\#circumventBug2650(Document) certificate.noSki.lowVersion = Das Zertifikat dard kein SubjectKeyIdentifier enthalten da es nur ein X509v{0} ist certificate.noSki.notOctetString = Der SubjectKeyIdentifier des Zertifikates ist kein "OctetString" -certificate.noSki.null = Das Zertifikat enthält kein SubjectKeyIdentifier +certificate.noSki.null = Das Zertifikat enth\u00e4lt kein SubjectKeyIdentifier defaultNamespaceCannotBeSetHere = Standard Namespace kann hier nicht gesetzt werden ElementProxy.nullElement = Kann keinen ElementProxy aus einem null Argument erzeugen empty = {0} @@ -57,23 +57,23 @@ encryption.algorithmCannotBeUsedForEncryptedData = encryption.algorithmCannotBeU encryption.algorithmCannotEatInitParams = encryption.algorithmCannotEatInitParams encryption.algorithmCannotEncryptDecrypt = encryption.algorithmCannotEncryptDecrypt encryption.algorithmCannotWrapUnWrap = encryption.algorithmCannotWrapUnWrap -encryption.ExplicitKeySizeMismatch = Das xenc\:KeySize Element fordert eine Schlüssel-Länge von {0} bits aber der Algorithmus besitzt {1} bits -encryption.nonceLongerThanDecryptedPlaintext = Das angegebene "Nonce" ist länger als der verfügbare Plaintext. +encryption.ExplicitKeySizeMismatch = Das xenc\:KeySize Element fordert eine Schl\u00fcssel-L\u00e4nge von {0} bits aber der Algorithmus besitzt {1} bits +encryption.nonceLongerThanDecryptedPlaintext = Das angegebene "Nonce" ist l\u00e4nger als der verf\u00fcgbare Plaintext. encryption.RSAOAEP.dataHashWrong = Falscher Hash-Wert encryption.RSAOAEP.dataStartWrong = Falscher Start Input {0} encryption.RSAOAEP.dataTooShort = Zu wenig Input encryption.RSAPKCS15.blockTruncated = Block abgeschnitten encryption.RSAPKCS15.noDataInBlock = Im Block sind keine Daten enthalten encryption.RSAPKCS15.unknownBlockType = Unbekannter Block Typ -encryption.nokey = Es ist kein verschlüsselungs Schlüssel geladen und es konnte kein Schlüssel mit Hilfe der "key resolvers" gefunden werden. -endorsed.jdk1.4.0 = Leider scheint niemand unsere Installations-Anleitung zu lesen, deshalb müssen wir es über die Exception machen\: Du hast den "endorsing" Mechanismus vom JDK 1.4 nicht richtig angewandt. Schaue unter nach wie man das Problem löst. -errorMessages.InvalidDigestValueException = Ungültige Signatur\: Referen-Validierung fehlgeschlagen. -errorMessages.InvalidSignatureValueException = Ungültige Signatur\: Core Validierung fehlgeschlagen. +encryption.nokey = Es ist kein verschl\u00fcsselungs Schl\u00fcssel geladen und es konnte kein Schl\u00fcssel mit Hilfe der "key resolvers" gefunden werden. +endorsed.jdk1.4.0 = Leider scheint niemand unsere Installations-Anleitung zu lesen, deshalb m\u00fcssen wir es \u00fcber die Exception machen\: Du hast den "endorsing" Mechanismus vom JDK 1.4 nicht richtig angewandt. Schaue unter nach wie man das Problem l\u00f6st. +errorMessages.InvalidDigestValueException = Ung\u00fcltige Signatur\: Referen-Validierung fehlgeschlagen. +errorMessages.InvalidSignatureValueException = Ung\u00fcltige Signatur\: Core Validierung fehlgeschlagen. errorMessages.IOException = Datei oder Resource kann nicht gelesen werden. -errorMessages.MissingKeyFailureException = Verifizierung fehlgeschlagen, weil der öffentliche Schlüssel (public key) nicht verfügbar ist. Resourcen via addResource() hinzufügen und erneut versuchen. -errorMessages.MissingResourceFailureException = Verifizierung fehlgeschlagen, weil Resourcen nicht verfügbar sind. Resourcen via addResource() hinzufügen und erneut versuchen. +errorMessages.MissingKeyFailureException = Verifizierung fehlgeschlagen, weil der \u00f6ffentliche Schl\u00fcssel (public key) nicht verf\u00fcgbar ist. Resourcen via addResource() hinzuf\u00fcgen und erneut versuchen. +errorMessages.MissingResourceFailureException = Verifizierung fehlgeschlagen, weil Resourcen nicht verf\u00fcgbar sind. Resourcen via addResource() hinzuf\u00fcgen und erneut versuchen. errorMessages.NoSuchAlgorithmException = Unbekannter Algorithmus {0} -errorMessages.NotYetImplementedException = Funktionalität noch nicht implementiert. +errorMessages.NotYetImplementedException = Funktionalit\u00e4t noch nicht implementiert. errorMessages.XMLSignatureException = Verifizierung aus unbekanntem Grund fehlgeschlagen. decoding.divisible.four = It should be divisible by four decoding.general = Fehler beim Decodieren @@ -84,70 +84,70 @@ FileKeyStorageImpl.NoCert.SubjName = Kein X509-Zertifikat mit SubjectName {0} ge generic.dontHaveConstructionElement = Konstruktions-Element fehlt generic.EmptyMessage = {0} generic.NotYetImplemented = {0} Leider noch nicht implementiert ;-(( -java.security.InvalidKeyException = Ungültiger Schlüssel -java.security.NoSuchProviderException = Unbekannter oder nicht unterstützter Provider -java.security.UnknownKeyType = Unbekannter oder nicht unterstützter Schlüssel-Typ {0} +java.security.InvalidKeyException = Ung\u00fcltiger Schl\u00fcssel +java.security.NoSuchProviderException = Unbekannter oder nicht unterst\u00fctzter Provider +java.security.UnknownKeyType = Unbekannter oder nicht unterst\u00fctzter Schl\u00fcssel-Typ {0} KeyInfo.error = Error loading Key Info -KeyInfo.needKeyResolver = Es müssen mehrere KeyResolver registriert sein -KeyInfo.nokey = Kann keinen Schlüssel aus {0} gewinnen -KeyInfo.noKey = Kann keinen öffentlichen Schlüssel finden -KeyInfo.wrongNumberOfObject = Benötige {0} keyObjects +KeyInfo.needKeyResolver = Es m\u00fcssen mehrere KeyResolver registriert sein +KeyInfo.nokey = Kann keinen Schl\u00fcssel aus {0} gewinnen +KeyInfo.noKey = Kann keinen \u00f6ffentlichen Schl\u00fcssel finden +KeyInfo.wrongNumberOfObject = Ben\u00f6tige {0} keyObjects KeyInfo.wrongUse = Dieses Objekt wird verwendet, um {0} zu gewinnen -keyResolver.alreadyRegistered = Die Klasse {1} wurde bereits registriert für {0} -KeyResolver.needStorageResolver = Es wird ein StorageResolver benötigt um ein Zertifikat aus {0} zu holen +keyResolver.alreadyRegistered = Die Klasse {1} wurde bereits registriert f\u00fcr {0} +KeyResolver.needStorageResolver = Es wird ein StorageResolver ben\u00f6tigt um ein Zertifikat aus {0} zu holen KeyResoverSpiImpl.cannotGetCert = Cannot get the Certificate that include or in {1} in implement class {0} KeyResoverSpiImpl.elementGeneration = Cannot make {1} element in implement class {0} KeyResoverSpiImpl.getPoublicKey = Cannot get the public key from implement class {0} KeyResoverSpiImpl.InvalidElement = Cannot set (2) Element in implement class {0} KeyResoverSpiImpl.keyStore = KeyStorage Fehler in der implementierenden Klasse {0} -KeyResoverSpiImpl.need.Element = Es wird der Typ {1} benötigt in der implementierenden Klasse {0} +KeyResoverSpiImpl.need.Element = Es wird der Typ {1} ben\u00f6tigt in der implementierenden Klasse {0} KeyResoverSpiImpl.wrongCRLElement = Cannot make CRL from {1} in implement class {0} KeyResoverSpiImpl.wrongKeyObject = Need {1} type of KeyObject for generation Element in implement class{0} KeyResoverSpiImpl.wrongNumberOfObject = Need {1} keyObject in implement class {0} -KeyStore.alreadyRegistered = Klasse {0} bereits registriert für {1} +KeyStore.alreadyRegistered = Klasse {0} bereits registriert f\u00fcr {1} KeyStore.register = {1} type class register error in class {0} -KeyStore.registerStore.register = Registrierungsfehler für Typ {0} +KeyStore.registerStore.register = Registrierungsfehler f\u00fcr Typ {0} KeyValue.IllegalArgument = Kann kein {0} aus {1} erzeugen namespacePrefixAlreadyUsedByOtherURI = Namespace {0} wird bereits von einer anderen URI {1} gebraucht notYetInitialized = Das Modul {0} ist noch nicht initialisiert prefix.AlreadyAssigned = Sie binden den Prefix {0} an den Namespace {1} aber er ist bereits an {2} zugewiesen -signature.Canonicalizer.UnknownCanonicalizer = Unbekannter Kanonisierer. Kein Handler installiert für URI {0} -signature.DSA.invalidFormat = Ungültige ASN.1 Kodierung der DSA Signatur +signature.Canonicalizer.UnknownCanonicalizer = Unbekannter Kanonisierer. Kein Handler installiert f\u00fcr URI {0} +signature.DSA.invalidFormat = Ung\u00fcltige ASN.1 Kodierung der DSA Signatur signature.Generation.signBeforeGetValue = Es muss zuerst XMLSignature.sign(java.security.PrivateKey) aufgerufen werden signature.Reference.ForbiddenResolver = Der "Resolver" {0} ist bei aktivierter "secure validation" nicht erlaubt signature.Reference.NoDigestMethod = A Signature Reference Element must contain a DigestMethod child signature.Reference.NoDigestValue = A Signature Reference Element must contain a DigestValue child signature.signatureAlgorithm = Der Algorithmus {0} ist bei aktivierter "secure validation" nicht erlaubt signature.signaturePropertyHasNoTarget = Das Target Attribut der SignatureProperty muss gesetzt sein -signature.tooManyReferences = Das Manifest enthält {0} Referenzen, bei aktivierter "secure validation" sind aber maximal {1} erlaubt -signature.tooManyTransforms = Die Referenz enthält {0} Transformationen, bei aktivierter "secure validation" sind aber maximal {1} erlaubt -signature.Transform.ErrorDuringTransform = Während der Transformation {0} trat eine {1} auf. +signature.tooManyReferences = Das Manifest enth\u00e4lt {0} Referenzen, bei aktivierter "secure validation" sind aber maximal {1} erlaubt +signature.tooManyTransforms = Die Referenz enth\u00e4lt {0} Transformationen, bei aktivierter "secure validation" sind aber maximal {1} erlaubt +signature.Transform.ErrorDuringTransform = W\u00e4hrend der Transformation {0} trat eine {1} auf. signature.Transform.ForbiddenTransform = Die Transformation {0} ist bei aktivierter "secure validation" nicht erlaubt signature.Transform.NotYetImplemented = Transform {0} noch nicht implementiert -signature.Transform.NullPointerTransform = Null pointer als URI übergeben. Programmierfehler? -signature.Transform.UnknownTransform = Unbekannte Transformation. Kein Handler installiert für URI {0} +signature.Transform.NullPointerTransform = Null pointer als URI \u00fcbergeben. Programmierfehler? +signature.Transform.UnknownTransform = Unbekannte Transformation. Kein Handler installiert f\u00fcr URI {0} signature.Util.BignumNonPositive = bigInteger.signum() muss positiv sein signature.Util.NonTextNode = Keine Text Node signature.Util.TooManyChilds = Zu viele Kind-Elemente vom Typ {0} in {1} signature.Verification.certificateError = Zertifikatsfehler signature.Verification.IndexOutOfBounds = Index {0} illegal. Es sind nur {1} Referenzen vorhanden signature.Verification.internalError = Interner Fehler -signature.Verification.InvalidDigestOrReference = Ungültiger Digest Wert der Referenz {0} +signature.Verification.InvalidDigestOrReference = Ung\u00fcltiger Digest Wert der Referenz {0} signature.Verification.InvalidElement = Current Node {0} is not permitted in this location in the Signature -signature.Verification.keyStore = Öffnen des KeyStore fehlgeschlagen +signature.Verification.keyStore = \u00d6ffnen des KeyStore fehlgeschlagen signature.Verification.MissingID = Element mit der ID {0} nicht gefunden -signature.Verification.MissingResources = Kann die externe Resource {0} nicht auflösen +signature.Verification.MissingResources = Kann die externe Resource {0} nicht aufl\u00f6sen signature.Verification.MultipleIDs = Mehrere Elemente mit der ID {0} gefunden -signature.Verification.NoSignatureElement = Input Dokument enthält kein {0} Element mit dem Namespace {1} -signature.Verification.Reference.NoInput = Die Referenz für den URI {0} hat keinen XMLSignatureInput erhalten. +signature.Verification.NoSignatureElement = Input Dokument enth\u00e4lt kein {0} Element mit dem Namespace {1} +signature.Verification.Reference.NoInput = Die Referenz f\u00fcr den URI {0} hat keinen XMLSignatureInput erhalten. signature.Verification.SignatureError = Signatur Fehler signature.XMLSignatureInput.MissingConstuctor = Kann aus der Klasse {0} keinen XMLSignatureInput erzeugen signature.XMLSignatureInput.SerializeDOM = Input mit einem DOM Dokument initialisiert. Muss mit C14N serialisiert werden -transform.Init.IllegalContextArgument = Unzulässiges Kontext Argument der Klasse {0}. Muss String, org.w3c.dom.NodeList oder java.io.InputStream sein. +transform.Init.IllegalContextArgument = Unzul\u00e4ssiges Kontext Argument der Klasse {0}. Muss String, org.w3c.dom.NodeList oder java.io.InputStream sein. transform.init.NotInitialized = transform.init.wrongURI = Initialisiert mit dem falschen URI. Das sollte nie passieren. Die Transformation implementiert {0} aber {1} wurde bei der Instantiierung verwendet. -utils.Base64.IllegalBitlength = Ungültige Byte-Länge; Muss ein vielfaches von 4 sein -utils.resolver.noClass = Keinen Resolver für URI {0} und Base {1} gefunden +utils.Base64.IllegalBitlength = Ung\u00fcltige Byte-L\u00e4nge; Muss ein vielfaches von 4 sein +utils.resolver.noClass = Keinen Resolver f\u00fcr URI {0} und Base {1} gefunden xml.WrongContent = Kann {0} nicht finden in {1} xml.WrongElement = Kann kein {0} aus einem {1} Element erzeugen xpath.funcHere.documentsDiffer = Der XPath ist nicht im selben Dokument wie der Kontext Node @@ -157,43 +157,43 @@ signature.Transform.nodeAndType = Aktuelle Node\: {0}, Typ\: {1} signature.XMLSignatureInput.nodesetReference = Das Node-Set der Referenz konnte nicht konvertieren werden transform.envelopedSignatureTransformNotInSignatureElement = Enveloped Transform konnte kein Signatur Element finden Base64Decoding = Fehler bei der Decodierung -secureProcessing.MaximumAllowedTransformsPerReference = Die Referenz enthält {0} Transformationen. Es sind aber maximal {1} erlaubt. Die Limite kann über das Konfigurations-Property "MaximumAllowedTransformsPerReference" erhöht werden. -secureProcessing.MaximumAllowedReferencesPerManifest = Das Manifest enhält {0} Referenzen. Es sind aber maximal {1} erlaubt. Die Limite kann über das Konfigurations-Property "MaximumAllowedReferencesPerManifest" erhöht werden. -secureProcessing.DoNotThrowExceptionForManifests = Signatur-Manifests werden nicht unterstützt. Das werfen dieser Exception kann durch das Konfigurations-Property "DoNotThrowExceptionForManifests" verhindert werden. -secureProcessing.AllowMD5Algorithm = Vom Einsatz des MD5 Algorithmus wird strengstens abgeraten. Trotzdem kann er über das Konfigurations-Property "AllowMD5Algorithm" erlaubt werden. -secureProcessing.AllowNotSameDocumentReferences = Externe Referenzen gefunden. Die Verarbeitung von externen Referenzen ist standardmässig ausgeschaltet. Es kann über das Konfigurations-Property "AllowNotSameDocumentReferences" aktiviert werden. -secureProcessing.MaximumAllowedXMLStructureDepth = Die Maximum erlaubte Dokumenten-Tiefe von ({0}) wurde erreicht. Die Limite kann über das Konfigurations-Property "MaximumAllowedXMLStructureDepth" erhöht werden. +secureProcessing.MaximumAllowedTransformsPerReference = Die Referenz enth\u00e4lt {0} Transformationen. Es sind aber maximal {1} erlaubt. Die Limite kann \u00fcber das Konfigurations-Property "MaximumAllowedTransformsPerReference" erh\u00f6ht werden. +secureProcessing.MaximumAllowedReferencesPerManifest = Das Manifest enh\u00e4lt {0} Referenzen. Es sind aber maximal {1} erlaubt. Die Limite kann \u00fcber das Konfigurations-Property "MaximumAllowedReferencesPerManifest" erh\u00f6ht werden. +secureProcessing.DoNotThrowExceptionForManifests = Signatur-Manifests werden nicht unterst\u00fctzt. Das werfen dieser Exception kann durch das Konfigurations-Property "DoNotThrowExceptionForManifests" verhindert werden. +secureProcessing.AllowMD5Algorithm = Vom Einsatz des MD5 Algorithmus wird strengstens abgeraten. Trotzdem kann er \u00fcber das Konfigurations-Property "AllowMD5Algorithm" erlaubt werden. +secureProcessing.AllowNotSameDocumentReferences = Externe Referenzen gefunden. Die Verarbeitung von externen Referenzen ist standardm\u00e4ssig ausgeschaltet. Es kann \u00fcber das Konfigurations-Property "AllowNotSameDocumentReferences" aktiviert werden. +secureProcessing.MaximumAllowedXMLStructureDepth = Die Maximum erlaubte Dokumenten-Tiefe von ({0}) wurde erreicht. Die Limite kann \u00fcber das Konfigurations-Property "MaximumAllowedXMLStructureDepth" erh\u00f6ht werden. secureProcessing.inputStreamLimitReached = Maximal erlaubte Anzahl bytes ({0}) erreicht. stax.duplicateActions=Doppelte Actions sind nicht erlaubt. stax.missingSecurityProperties = SecurityProperties darf nicht null sein\! stax.noOutputAction = Keine ausgehenden "Actions" definiert. -stax.noKey = Kein Schlüssel geladen und es konnte kein Schlüssel gefunden werden für {0} -stax.keyNotFound = Schlüssel nicht gefunden. -stax.unsupportedKeyValue = Kein oder ungültiger KeyValue. -stax.emptyReferenceURI = Referenz enthält kein URI Attribut. -stax.encryption.unprocessedReferences = Es wurden nicht alle Verschlüsselungs-Referenzen verarbeitet... +stax.noKey = Kein Schl\u00fcssel geladen und es konnte kein Schl\u00fcssel gefunden werden f\u00fcr {0} +stax.keyNotFound = Schl\u00fcssel nicht gefunden. +stax.unsupportedKeyValue = Kein oder ung\u00fcltiger KeyValue. +stax.emptyReferenceURI = Referenz enth\u00e4lt kein URI Attribut. +stax.encryption.unprocessedReferences = Es wurden nicht alle Verschl\u00fcsselungs-Referenzen verarbeitet... stax.signature.unprocessedReferences = Es wurden nicht alle Signatur-Referenzen verarbeitet... -stax.unsupportedToken = {0} nicht unterstützt. +stax.unsupportedToken = {0} nicht unterst\u00fctzt. stax.xmlStructureSizeExceeded = Maximal erlaubte ({0}) XML-Struktur Tiefe erreicht. stax.unexpectedXMLEvent = Unerwarteter StAX-Event\: {0} -stax.encryption.noEncAlgo = xenc\:EncryptedKey enthält kein xenc\:EncryptionMethod/@Algorithm. -stax.encryption.noCipherValue = EncryptedKey enthält kein xenc\:CipherData/xenc\:CipherValue. +stax.encryption.noEncAlgo = xenc\:EncryptedKey enth\u00e4lt kein xenc\:EncryptionMethod/@Algorithm. +stax.encryption.noCipherValue = EncryptedKey enth\u00e4lt kein xenc\:CipherData/xenc\:CipherValue. stax.unsecuredMessage = Ungesicherte Nachricht. Weder ein Signatur- noch ein EncryptedData- Element wurde gefunden. stax.signature.signedInfoMissing = SignedInfo Element fehlt. stax.signature.signatureMethodMissing = Signature method fehlt. stax.signature.canonicalizationMethodMissing = Signature canonicalization method fehlt. stax.signature.signatureValueMissing = Signature value fehlt. stax.signature.publicKeyOrCertificateMissing = Weder ein Zertifikat noch ein public-key wurde konfiguriert. -stax.encryption.encryptionKeyMissing = Kein Schlüssel für die Verschlüsselung wurde konfiguriert. -stax.unsupportedKeyTransp = Der public-key Algorithmus ist zu kurz um den symmetrischen Schlüssel zu verschlüsseln. -stax.recursiveKeyReference = Rekursive Schlüssel referenzierung detektiert. -stax.ecParametersNotSupported = ECParameters werden nicht unterstützt. +stax.encryption.encryptionKeyMissing = Kein Schl\u00fcssel f\u00fcr die Verschl\u00fcsselung wurde konfiguriert. +stax.unsupportedKeyTransp = Der public-key Algorithmus ist zu kurz um den symmetrischen Schl\u00fcssel zu verschl\u00fcsseln. +stax.recursiveKeyReference = Rekursive Schl\u00fcssel referenzierung detektiert. +stax.ecParametersNotSupported = ECParameters werden nicht unterst\u00fctzt. stax.namedCurveMissing = NamedCurve fehlt. -stax.encryption.securePartNotFound = Part zum Verschlüsseln nicht gefunden: {0} +stax.encryption.securePartNotFound = Part zum Verschl\u00fcsseln nicht gefunden: {0} stax.signature.securePartNotFound = Part zum Signieren nicht gefunden: {0} stax.multipleSignaturesNotSupported = Mehrere Signaturen werden nicht unterstützt. stax.signature.keyNameMissing = KeyName nicht konfiguriert. -stax.keyNotFoundForName = Kein Schlüssel für Schlüsselname konfiguriert: {0} -stax.keyTypeNotSupported = Key vom Typ {0} nicht für einen Key-Namenssuche unterstützt +stax.keyNotFoundForName = Kein Schl\u00fcssel für Schl\u00fcsselname konfiguriert: {0} +stax.keyTypeNotSupported = Key vom Typ {0} nicht f\u00fcr einen Key-Namenssuche unterst\u00fctzt stax.idsetbutnotgenerated = An Id attribute is specified, but Id generation is disabled stax.idgenerationdisablewithmultipleparts = Id generation must not be disabled when multiple parts need signing From 42378970e1accc67c2a152c6af2b0becacf5b4b8 Mon Sep 17 00:00:00 2001 From: Chris Plummer Date: Wed, 4 Dec 2024 00:15:30 +0000 Subject: [PATCH 48/62] 8345341: Fix incorrect log message in JDI stop002t test Reviewed-by: amenkov, lmesnik --- .../vmTestbase/nsk/jdi/ThreadReference/stop/stop002t.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/stop/stop002t.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/stop/stop002t.java index 694485e608ebe..e82b749c9059b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/stop/stop002t.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/stop/stop002t.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -180,7 +180,7 @@ private int runIt(String args[]) { log.display("TEST #5: interrupted = " + Thread.interrupted()); // We don't expect the exception to be thrown when in vthread mode. if (!vthreadMode && t instanceof MyThrowable) { - log.display("TEST #5: Caught expected exception while in loop: " + t); + log.display("TEST #5: Caught expected exception while in sleep: " + t); } else { log.complain("TEST #5: Unexpected exception caught: " + t); t.printStackTrace(); From c143138a35689605ebe44d847904e226ffcaeb74 Mon Sep 17 00:00:00 2001 From: Fei Yang Date: Wed, 4 Dec 2024 01:45:16 +0000 Subject: [PATCH 49/62] 8345351: RISC-V: Rename macro-assembler routine cmpxchg_weak to weak_cmpxchg Reviewed-by: rehn, mli --- .../riscv/gc/z/zBarrierSetAssembler_riscv.cpp | 2 +- .../cpu/riscv/macroAssembler_riscv.cpp | 2 +- .../cpu/riscv/macroAssembler_riscv.hpp | 2 +- src/hotspot/cpu/riscv/riscv.ad | 40 +++++++++---------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp b/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp index cd83eafcaeba5..dde2f1f131ff9 100644 --- a/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/gc/z/zBarrierSetAssembler_riscv.cpp @@ -286,7 +286,7 @@ void ZBarrierSetAssembler::store_barrier_medium(MacroAssembler* masm, __ relocate(barrier_Relocation::spec(), [&] { __ li16u(rtmp1, barrier_Relocation::unpatched); }, ZBarrierRelocationFormatStoreGoodBits); - __ cmpxchg_weak(rtmp2, zr, rtmp1, + __ weak_cmpxchg(rtmp2, zr, rtmp1, Assembler::int64, Assembler::relaxed /* acquire */, Assembler::relaxed /* release */, rtmp3); diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp index 3ecfd5de7259b..44b806834f987 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp @@ -3576,7 +3576,7 @@ void MacroAssembler::cmpxchg(Register addr, Register expected, bind(done); } -void MacroAssembler::cmpxchg_weak(Register addr, Register expected, +void MacroAssembler::weak_cmpxchg(Register addr, Register expected, Register new_val, enum operand_size size, Assembler::Aqrl acquire, Assembler::Aqrl release, diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp index 26a0ed3b0d188..0d28eaaf1f00f 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp @@ -1146,7 +1146,7 @@ class MacroAssembler: public Assembler { enum operand_size size, Assembler::Aqrl acquire, Assembler::Aqrl release, Register result, bool result_as_bool = false); - void cmpxchg_weak(Register addr, Register expected, + void weak_cmpxchg(Register addr, Register expected, Register new_val, enum operand_size size, Assembler::Aqrl acquire, Assembler::Aqrl release, diff --git a/src/hotspot/cpu/riscv/riscv.ad b/src/hotspot/cpu/riscv/riscv.ad index d0085125c7623..32019251bbe65 100644 --- a/src/hotspot/cpu/riscv/riscv.ad +++ b/src/hotspot/cpu/riscv/riscv.ad @@ -5744,7 +5744,7 @@ instruct weakCompareAndSwapB(iRegINoSp res, indirect mem, iRegI_R12 oldval, iReg effect(TEMP_DEF res, KILL cr, USE_KILL oldval, USE_KILL newval, TEMP tmp1, TEMP tmp2, TEMP tmp3); format %{ - "cmpxchg_weak $mem, $oldval, $newval\t# (byte, weak) if $mem == $oldval then $mem <-- $newval\n\t" + "weak_cmpxchg $mem, $oldval, $newval\t# (byte, weak) if $mem == $oldval then $mem <-- $newval\n\t" "# $res == 1 when success, #@weakCompareAndSwapB" %} @@ -5767,7 +5767,7 @@ instruct weakCompareAndSwapS(iRegINoSp res, indirect mem, iRegI_R12 oldval, iReg effect(TEMP_DEF res, KILL cr, USE_KILL oldval, USE_KILL newval, TEMP tmp1, TEMP tmp2, TEMP tmp3); format %{ - "cmpxchg_weak $mem, $oldval, $newval\t# (short, weak) if $mem == $oldval then $mem <-- $newval\n\t" + "weak_cmpxchg $mem, $oldval, $newval\t# (short, weak) if $mem == $oldval then $mem <-- $newval\n\t" "# $res == 1 when success, #@weakCompareAndSwapS" %} @@ -5787,12 +5787,12 @@ instruct weakCompareAndSwapI(iRegINoSp res, indirect mem, iRegI oldval, iRegI ne ins_cost(LOAD_COST + STORE_COST + BRANCH_COST * 2 + ALU_COST * 2); format %{ - "cmpxchg_weak $mem, $oldval, $newval\t# (int, weak) if $mem == $oldval then $mem <-- $newval\n\t" + "weak_cmpxchg $mem, $oldval, $newval\t# (int, weak) if $mem == $oldval then $mem <-- $newval\n\t" "# $res == 1 when success, #@weakCompareAndSwapI" %} ins_encode %{ - __ cmpxchg_weak(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::int32, + __ weak_cmpxchg(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::int32, /*acquire*/ Assembler::relaxed, /*release*/ Assembler::rl, $res$$Register); %} @@ -5806,12 +5806,12 @@ instruct weakCompareAndSwapL(iRegINoSp res, indirect mem, iRegL oldval, iRegL ne ins_cost(LOAD_COST + STORE_COST + BRANCH_COST * 2 + ALU_COST * 2); format %{ - "cmpxchg_weak $mem, $oldval, $newval\t# (long, weak) if $mem == $oldval then $mem <-- $newval\n\t" + "weak_cmpxchg $mem, $oldval, $newval\t# (long, weak) if $mem == $oldval then $mem <-- $newval\n\t" "# $res == 1 when success, #@weakCompareAndSwapL" %} ins_encode %{ - __ cmpxchg_weak(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::int64, + __ weak_cmpxchg(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::int64, /*acquire*/ Assembler::relaxed, /*release*/ Assembler::rl, $res$$Register); %} @@ -5826,12 +5826,12 @@ instruct weakCompareAndSwapN(iRegINoSp res, indirect mem, iRegN oldval, iRegN ne ins_cost(LOAD_COST + STORE_COST + BRANCH_COST * 2 + ALU_COST * 4); format %{ - "cmpxchg_weak $mem, $oldval, $newval\t# (narrow oop, weak) if $mem == $oldval then $mem <-- $newval\n\t" + "weak_cmpxchg $mem, $oldval, $newval\t# (narrow oop, weak) if $mem == $oldval then $mem <-- $newval\n\t" "# $res == 1 when success, #@weakCompareAndSwapN" %} ins_encode %{ - __ cmpxchg_weak(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::uint32, + __ weak_cmpxchg(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::uint32, /*acquire*/ Assembler::relaxed, /*release*/ Assembler::rl, $res$$Register); %} @@ -5846,12 +5846,12 @@ instruct weakCompareAndSwapP(iRegINoSp res, indirect mem, iRegP oldval, iRegP ne ins_cost(LOAD_COST + STORE_COST + BRANCH_COST * 2 + ALU_COST * 2); format %{ - "cmpxchg_weak $mem, $oldval, $newval\t# (ptr, weak) if $mem == $oldval then $mem <-- $newval\n\t" + "weak_cmpxchg $mem, $oldval, $newval\t# (ptr, weak) if $mem == $oldval then $mem <-- $newval\n\t" "# $res == 1 when success, #@weakCompareAndSwapP" %} ins_encode %{ - __ cmpxchg_weak(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::int64, + __ weak_cmpxchg(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::int64, /*acquire*/ Assembler::relaxed, /*release*/ Assembler::rl, $res$$Register); %} @@ -5870,7 +5870,7 @@ instruct weakCompareAndSwapBAcq(iRegINoSp res, indirect mem, iRegI_R12 oldval, i effect(TEMP_DEF res, KILL cr, USE_KILL oldval, USE_KILL newval, TEMP tmp1, TEMP tmp2, TEMP tmp3); format %{ - "cmpxchg_weak_acq $mem, $oldval, $newval\t# (byte, weak) if $mem == $oldval then $mem <-- $newval\n\t" + "weak_cmpxchg_acq $mem, $oldval, $newval\t# (byte, weak) if $mem == $oldval then $mem <-- $newval\n\t" "# $res == 1 when success, #@weakCompareAndSwapBAcq" %} @@ -5895,7 +5895,7 @@ instruct weakCompareAndSwapSAcq(iRegINoSp res, indirect mem, iRegI_R12 oldval, i effect(TEMP_DEF res, KILL cr, USE_KILL oldval, USE_KILL newval, TEMP tmp1, TEMP tmp2, TEMP tmp3); format %{ - "cmpxchg_weak_acq $mem, $oldval, $newval\t# (short, weak) if $mem == $oldval then $mem <-- $newval\n\t" + "weak_cmpxchg_acq $mem, $oldval, $newval\t# (short, weak) if $mem == $oldval then $mem <-- $newval\n\t" "# $res == 1 when success, #@weakCompareAndSwapSAcq" %} @@ -5917,12 +5917,12 @@ instruct weakCompareAndSwapIAcq(iRegINoSp res, indirect mem, iRegI oldval, iRegI ins_cost(LOAD_COST + STORE_COST + BRANCH_COST * 2 + ALU_COST * 2); format %{ - "cmpxchg_weak_acq $mem, $oldval, $newval\t# (int, weak) if $mem == $oldval then $mem <-- $newval\n\t" + "weak_cmpxchg_acq $mem, $oldval, $newval\t# (int, weak) if $mem == $oldval then $mem <-- $newval\n\t" "# $res == 1 when success, #@weakCompareAndSwapIAcq" %} ins_encode %{ - __ cmpxchg_weak(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::int32, + __ weak_cmpxchg(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::int32, /*acquire*/ Assembler::aq, /*release*/ Assembler::rl, $res$$Register); %} @@ -5938,12 +5938,12 @@ instruct weakCompareAndSwapLAcq(iRegINoSp res, indirect mem, iRegL oldval, iRegL ins_cost(LOAD_COST + STORE_COST + BRANCH_COST * 2 + ALU_COST * 2); format %{ - "cmpxchg_weak_acq $mem, $oldval, $newval\t# (long, weak) if $mem == $oldval then $mem <-- $newval\n\t" + "weak_cmpxchg_acq $mem, $oldval, $newval\t# (long, weak) if $mem == $oldval then $mem <-- $newval\n\t" "# $res == 1 when success, #@weakCompareAndSwapLAcq" %} ins_encode %{ - __ cmpxchg_weak(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::int64, + __ weak_cmpxchg(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::int64, /*acquire*/ Assembler::aq, /*release*/ Assembler::rl, $res$$Register); %} @@ -5959,12 +5959,12 @@ instruct weakCompareAndSwapNAcq(iRegINoSp res, indirect mem, iRegN oldval, iRegN ins_cost(LOAD_COST + STORE_COST + BRANCH_COST * 2 + ALU_COST * 4); format %{ - "cmpxchg_weak_acq $mem, $oldval, $newval\t# (narrow oop, weak) if $mem == $oldval then $mem <-- $newval\n\t" + "weak_cmpxchg_acq $mem, $oldval, $newval\t# (narrow oop, weak) if $mem == $oldval then $mem <-- $newval\n\t" "# $res == 1 when success, #@weakCompareAndSwapNAcq" %} ins_encode %{ - __ cmpxchg_weak(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::uint32, + __ weak_cmpxchg(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::uint32, /*acquire*/ Assembler::aq, /*release*/ Assembler::rl, $res$$Register); %} @@ -5980,12 +5980,12 @@ instruct weakCompareAndSwapPAcq(iRegINoSp res, indirect mem, iRegP oldval, iRegP ins_cost(LOAD_COST + STORE_COST + BRANCH_COST * 2 + ALU_COST * 2); format %{ - "cmpxchg_weak_acq $mem, $oldval, $newval\t# (ptr, weak) if $mem == $oldval then $mem <-- $newval\n\t" + "weak_cmpxchg_acq $mem, $oldval, $newval\t# (ptr, weak) if $mem == $oldval then $mem <-- $newval\n\t" "\t# $res == 1 when success, #@weakCompareAndSwapPAcq" %} ins_encode %{ - __ cmpxchg_weak(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::int64, + __ weak_cmpxchg(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::int64, /*acquire*/ Assembler::aq, /*release*/ Assembler::rl, $res$$Register); %} From 7ec36bb7837932959beb6ce5eb669a0553f978b6 Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Wed, 4 Dec 2024 02:28:06 +0000 Subject: [PATCH 50/62] 8343001: Adjust XSLT and XPath Extension Function Property Reviewed-by: rriggs, lancea --- .../internal/res/XSLTErrorResources.java | 9 +- .../internal/xsltc/compiler/FunctionCall.java | 83 +++++---- .../xalan/internal/xsltc/compiler/XSLTC.java | 8 +- .../xsltc/compiler/util/ErrorMessages.java | 11 +- .../xsltc/compiler/util/ErrorMsg.java | 3 +- .../internal/xsltc/runtime/ErrorMessages.java | 14 +- .../xsltc/trax/TransformerFactoryImpl.java | 5 +- .../internal/xsltc/trax/TransformerImpl.java | 7 +- .../jdk/xml/internal/JdkXmlFeatures.java | 15 +- src/java.xml/share/conf/jaxp.properties | 7 +- .../libs/jaxp/library/JAXPTestUtilities.java | 32 ++++ .../common/config/ImplProperties.java | 2 +- .../jaxp/unittest/transform/Bug6513892.java | 10 +- .../unittest/transform/ErrorListenerTest.java | 6 +- .../transform/SecureProcessingTest.java | 158 ++++++++---------- .../unittest/transform/XSLTFunctionsTest.java | 111 ++++++------ .../javax/xml/jaxp/common/8032908/XSLT.java | 6 +- .../javax/xml/jaxp/parsers/8024707/XSLT.java | 6 +- .../transform/8004476/XSLTExFuncTest.java | 8 +- 19 files changed, 268 insertions(+), 233 deletions(-) diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources.java index e5b8aeabfd20a..a1f1a8a070519 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/res/XSLTErrorResources.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -31,7 +31,7 @@ * Array. You also need to update MAX_CODE for error strings * and MAX_WARNING for warnings ( Needed for only information * purpose ) - * @LastModified: May 2022 + * @LastModified: Dec 2024 */ public class XSLTErrorResources extends ListResourceBundle { @@ -1197,7 +1197,10 @@ public Object[][] getContents() "Cannot set the feature ''{0}'' on this TransformerFactory."}, { ER_EXTENSION_ELEMENT_NOT_ALLOWED_IN_SECURE_PROCESSING, - "Use of the extension element ''{0}'' is not allowed when the secure processing feature is set to true."}, + "Use of the extension function ''{0}'' is not allowed when extension " + + "functions are disabled by the secure processing feature or " + + "the property ''jdk.xml.enableExtensionFunctions''. " + + "To enable extension functions, set ''jdk.xml.enableExtensionFunctions'' to ''true''."}, { ER_NAMESPACE_CONTEXT_NULL_NAMESPACE, "Cannot get the prefix for a null namespace uri."}, diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java index cd7c9e4983433..2cf491d96f5ae 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/FunctionCall.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -62,7 +62,7 @@ * @author Morten Jorgensen * @author Erwin Bolwidt * @author Todd Miller - * @LastModified: Nov 2017 + * @LastModified: Dec 2024 */ class FunctionCall extends Expression { @@ -958,12 +958,12 @@ public boolean isExtension() { * after stripping its namespace or null * if no such methods exist. */ - private List findMethods() { + private List findMethods() throws TypeCheckError { - List result = null; - final String namespace = _fname.getNamespace(); + List result = null; + final String namespace = _fname.getNamespace(); - if (_className != null && _className.length() > 0) { + if (_className != null && _className.length() > 0) { final int nArgs = _arguments.size(); try { if (_clazz == null) { @@ -971,48 +971,45 @@ private List findMethods() { final boolean isExtensionFunctionEnabled = getXSLTC() .getFeature(JdkXmlFeatures.XmlFeature.ENABLE_EXTENSION_FUNCTION); - //Check if FSP and SM - only then process with loading - if (namespace != null && isSecureProcessing - && isExtensionFunctionEnabled - && (namespace.startsWith(JAVA_EXT_XALAN) - || namespace.startsWith(JAVA_EXT_XSLTC) - || namespace.startsWith(JAVA_EXT_XALAN_OLD) - || namespace.startsWith(XALAN_CLASSPACKAGE_NAMESPACE))) { - _clazz = getXSLTC().loadExternalFunction(_className); + // the property has the precedence + if (isExtensionFunctionEnabled) { + if (getXSLTC().hasExtensionClassLoader()) { + _clazz = getXSLTC().loadExternalFunction(_className); + } else { + _clazz = ObjectFactory.findProviderClass(_className, true); + } + if (_clazz == null) { + final ErrorMsg msg + = new ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR, _className); + getParser().reportError(Constants.ERROR, msg); + return null; + } } else { - _clazz = ObjectFactory.findProviderClass(_className, true); + throw new TypeCheckError(ErrorMsg.UNSUPPORTED_EXT_FUNC_ERR, _className); } - - if (_clazz == null) { - final ErrorMsg msg = - new ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR, _className); - getParser().reportError(Constants.ERROR, msg); } - } - - final String methodName = _fname.getLocalPart(); - final Method[] methods = _clazz.getMethods(); - - for (int i = 0; i < methods.length; i++) { - final int mods = methods[i].getModifiers(); - // Is it public and same number of args ? - if (Modifier.isPublic(mods) - && methods[i].getName().equals(methodName) - && methods[i].getParameterTypes().length == nArgs) - { - if (result == null) { - result = new ArrayList<>(); - } - result.add(methods[i]); + + final String methodName = _fname.getLocalPart(); + final Method[] methods = _clazz.getMethods(); + + for (int i = 0; i < methods.length; i++) { + final int mods = methods[i].getModifiers(); + // Is it public and same number of args ? + if (Modifier.isPublic(mods) + && methods[i].getName().equals(methodName) + && methods[i].getParameterTypes().length == nArgs) { + if (result == null) { + result = new ArrayList<>(); + } + result.add(methods[i]); + } } - } - } - catch (ClassNotFoundException e) { - final ErrorMsg msg = new ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR, _className); - getParser().reportError(Constants.ERROR, msg); + } catch (ClassNotFoundException e) { + final ErrorMsg msg = new ErrorMsg(ErrorMsg.CLASS_NOT_FOUND_ERR, _className); + getParser().reportError(Constants.ERROR, msg); } - } - return result; + } + return result; } /** diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java index 9a256efc5a1f5..52edad7c22a86 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/XSLTC.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -57,7 +57,7 @@ * @author G. Todd Miller * @author Morten Jorgensen * @author John Howard (johnh@schemasoft.com) - * @LastModified: Jan 2022 + * @LastModified: Dec 2024 */ public final class XSLTC { @@ -291,6 +291,10 @@ private void setExternalExtensionFunctions(String name, Class clazz) { } } + boolean hasExtensionClassLoader() { + return _extensionClassLoader != null; + } + /* * Function loads an external extension function. * The filtering of function types (external,internal) takes place in FunctionCall class diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages.java index c34f4fa59eb87..660d1194b3079 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages.java @@ -24,7 +24,7 @@ /** * @author Morten Jorgensen - * @LastModified: Nov 2024 + * @LastModified: Dec 2024 */ public class ErrorMessages extends ListResourceBundle { @@ -552,6 +552,15 @@ public Object[][] getContents() {ErrorMsg.DATA_CONVERSION_ERR, "Cannot convert data-type ''{0}'' to ''{1}''."}, + /* + * Note to translators: property name "jdk.xml.enableExtensionFunctions" + * and value "true" should not be translated. + */ + {ErrorMsg.UNSUPPORTED_EXT_FUNC_ERR, + "Use of the extension function ''{0}'' is not allowed when extension " + + "functions are disabled by the secure processing feature or " + + "the property ''jdk.xml.enableExtensionFunctions''. " + + "To enable extension functions, set ''jdk.xml.enableExtensionFunctions'' to ''true''."}, /* * Note to translators: "Templates" is a Java class name that should * not be translated. diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMsg.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMsg.java index c586ad2674c37..8ef4c9c86b605 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMsg.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMsg.java @@ -33,7 +33,7 @@ * @author G. Todd Miller * @author Erwin Bolwidt * @author Morten Jorgensen - * @LastModified: Nov 2024 + * @LastModified: Dec 2024 */ public final class ErrorMsg { @@ -105,6 +105,7 @@ public final class ErrorMsg { public static final String ATTR_VAL_TEMPLATE_ERR = "ATTR_VAL_TEMPLATE_ERR"; public static final String UNKNOWN_SIG_TYPE_ERR = "UNKNOWN_SIG_TYPE_ERR"; public static final String DATA_CONVERSION_ERR = "DATA_CONVERSION_ERR"; + public static final String UNSUPPORTED_EXT_FUNC_ERR = "UNSUPPORTED_EXT_FUNC_ERR"; // JAXP/TrAX error messages public static final String NO_TRANSLET_CLASS_ERR = "NO_TRANSLET_CLASS_ERR"; diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages.java index 54ecd80e55e21..453c008c0a922 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages.java @@ -1,6 +1,5 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -25,6 +24,7 @@ /** * @author Morten Jorgensen + * @LastModified: Dec 2024 */ public class ErrorMessages extends ListResourceBundle { @@ -275,10 +275,16 @@ public Object[][] getContents() "An attribute whose value must be an NCName had the value ''{0}''"}, {BasisLibrary.UNALLOWED_EXTENSION_FUNCTION_ERR, - "Use of the extension function ''{0}'' is not allowed when the secure processing feature is set to true."}, + "Use of the extension function ''{0}'' is not allowed when extension " + + "functions are disabled by the secure processing feature or " + + "the property ''jdk.xml.enableExtensionFunctions''. " + + "To enable extension functions, set ''jdk.xml.enableExtensionFunctions'' to ''true''."}, {BasisLibrary.UNALLOWED_EXTENSION_ELEMENT_ERR, - "Use of the extension element ''{0}'' is not allowed when the secure processing feature is set to true."}, + "Use of the extension element ''{0}'' is not allowed when extension " + + "functions are disabled by the secure processing feature or " + + "the property ''jdk.xml.enableExtensionFunctions''. " + + "To enable extension functions, set ''jdk.xml.enableExtensionFunctions'' to ''true''."}, }; } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java index 440df5593eafb..d9af6f4744045 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java @@ -75,7 +75,6 @@ import jdk.xml.internal.JdkXmlUtils; import jdk.xml.internal.JdkProperty.ImplPropMap; import jdk.xml.internal.JdkProperty.State; -import jdk.xml.internal.SecuritySupport; import jdk.xml.internal.TransformErrorListener; import jdk.xml.internal.XMLSecurityManager; import org.xml.sax.InputSource; @@ -88,7 +87,7 @@ * @author G. Todd Miller * @author Morten Jorgensen * @author Santiago Pericas-Geertsen - * @LastModified: Nov 2024 + * @LastModified: Dec 2024 */ public class TransformerFactoryImpl extends SAXTransformerFactory implements SourceLoader @@ -216,7 +215,7 @@ public PIParamWrapper(String media, String title, String charset) { /** *

      State of secure processing feature.

      */ - private boolean _isNotSecureProcessing = true; + private boolean _isNotSecureProcessing = false; /** *

      State of secure mode.

      */ diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java index f551024408b3a..32eaec026bf96 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -100,7 +100,7 @@ * @author Morten Jorgensen * @author G. Todd Miller * @author Santiago Pericas-Geertsen - * @LastModified: July 2023 + * @LastModified: Dec 2024 */ public final class TransformerImpl extends Transformer implements DOMCache @@ -206,7 +206,7 @@ public final class TransformerImpl extends Transformer /** * State of the secure processing feature. */ - private boolean _isSecureProcessing = false; + private boolean _isSecureProcessing = true; /** * Indicates whether 3rd party parser may be used to override the system-default @@ -292,6 +292,7 @@ protected TransformerImpl(Translet translet, Properties outputProperties, _propertiesClone = (Properties) _properties.clone(); _indentNumber = indentNumber; _tfactory = tfactory; + _isSecureProcessing = _tfactory.getFeature(XMLConstants.FEATURE_SECURE_PROCESSING); _overrideDefaultParser = _tfactory.overrideDefaultParser(); _accessExternalDTD = (String)_tfactory.getAttribute(XMLConstants.ACCESS_EXTERNAL_DTD); _securityManager = (XMLSecurityManager)_tfactory.getAttribute(JdkConstants.SECURITY_MANAGER); diff --git a/src/java.xml/share/classes/jdk/xml/internal/JdkXmlFeatures.java b/src/java.xml/share/classes/jdk/xml/internal/JdkXmlFeatures.java index b3b4258891145..e8e5c2c83ded1 100644 --- a/src/java.xml/share/classes/jdk/xml/internal/JdkXmlFeatures.java +++ b/src/java.xml/share/classes/jdk/xml/internal/JdkXmlFeatures.java @@ -52,7 +52,7 @@ public static enum XmlFeature { * function is disabled. */ ENABLE_EXTENSION_FUNCTION(ImplPropMap.ENABLEEXTFUNC, null, null, true, - null, null, true, false, true, true), + null, null, false, false, true, true), /** * The {@link javax.xml.XMLConstants.USE_CATALOG} feature. * FSP: USE_CATALOG is not enforced by FSP. @@ -382,13 +382,7 @@ public int getIndex(String propertyName) { */ private void readSystemProperties() { for (XmlFeature feature : XmlFeature.values()) { - if (!getSystemProperty(feature, feature.systemProperty())) { - //if system property is not found, try the older form if any - String oldName = feature.systemPropertyOld(); - if (oldName != null) { - getSystemProperty(feature, oldName); - } - } + getSystemProperty(feature, feature.systemProperty()); } } @@ -402,6 +396,11 @@ private void readSystemProperties() { private boolean getSystemProperty(XmlFeature feature, String sysPropertyName) { try { String value = System.getProperty(sysPropertyName); + if (value == null && feature.systemPropertyOld() != null) { + // legacy system property + value = System.getProperty(feature.systemPropertyOld()); + } + if (value != null && !value.isEmpty()) { setFeature(feature, State.SYSTEMPROPERTY, Boolean.parseBoolean(value)); return true; diff --git a/src/java.xml/share/conf/jaxp.properties b/src/java.xml/share/conf/jaxp.properties index b011586c13c6a..2b7136319cea0 100644 --- a/src/java.xml/share/conf/jaxp.properties +++ b/src/java.xml/share/conf/jaxp.properties @@ -57,11 +57,10 @@ # Extension Functions: # # This property determines whether XSLT and XPath extension functions are allowed. -# The value type is boolean and the default value is true (allowing -# extension functions). The following entry overrides the default value and -# disallows extension functions: +# The value type is boolean and the default value is false (disallowing +# extension functions). # -# jdk.xml.enableExtensionFunctions=false +jdk.xml.enableExtensionFunctions=false # # # Overriding the default parser: diff --git a/test/jaxp/javax/xml/jaxp/libs/jaxp/library/JAXPTestUtilities.java b/test/jaxp/javax/xml/jaxp/libs/jaxp/library/JAXPTestUtilities.java index 8f72543db8e3a..bc12f14dd0940 100644 --- a/test/jaxp/javax/xml/jaxp/libs/jaxp/library/JAXPTestUtilities.java +++ b/test/jaxp/javax/xml/jaxp/libs/jaxp/library/JAXPTestUtilities.java @@ -51,6 +51,7 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; +import org.testng.Assert; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -60,6 +61,9 @@ * This is an interface provide basic support for JAXP functional test. */ public class JAXPTestUtilities { + public static final String CLS_DIR = System.getProperty("test.classes"); + public static final String SRC_DIR = System.getProperty("test.src"); + public static final boolean isWindows = System.getProperty("os.name").contains("Windows"); /** * Prefix for error message. */ @@ -373,6 +377,34 @@ public interface RunnableWithException { void run() throws Exception; } + /** + * Asserts the run does not cause a Throwable. May be replaced with JUnit 5. + * @param runnable the runnable + * @param message the message if the test fails + */ + public static void assertDoesNotThrow(Assert.ThrowingRunnable runnable, String message) { + try { + runnable.run(); + } catch (Throwable t) { + Assert.fail(message + "\n Exception thrown: " + t.getMessage()); + } + } + + /** + * Returns the System identifier (URI) of the source. + * @param path the path to the source + * @return the System identifier + */ + public static String getSystemId(String path) { + if (path == null) return null; + String xmlSysId = "file://" + path; + if (isWindows) { + path = path.replace('\\', '/'); + xmlSysId = "file:///" + path; + } + return xmlSysId; + } + /** * Current test directory. */ diff --git a/test/jaxp/javax/xml/jaxp/unittest/common/config/ImplProperties.java b/test/jaxp/javax/xml/jaxp/unittest/common/config/ImplProperties.java index e72252e0f677e..4f38f9152b458 100644 --- a/test/jaxp/javax/xml/jaxp/unittest/common/config/ImplProperties.java +++ b/test/jaxp/javax/xml/jaxp/unittest/common/config/ImplProperties.java @@ -102,7 +102,7 @@ public static enum PropertyType { "0", "1000000", "3000000", "10000", "5000", "0", "1000", "10", "100", "10000"}, // default values in JDK 24 - {"true", "false", "continue", "allow", "2500", "100000", + {"false", "false", "continue", "allow", "2500", "100000", "100000", "15000", "100000", "200", "5000", "100", "1000", "10", "100", "10000"}, // default values in jaxp-strict.properties.template, since JDK 23 diff --git a/test/jaxp/javax/xml/jaxp/unittest/transform/Bug6513892.java b/test/jaxp/javax/xml/jaxp/unittest/transform/Bug6513892.java index 349e137d6644e..0d39d427e956c 100644 --- a/test/jaxp/javax/xml/jaxp/unittest/transform/Bug6513892.java +++ b/test/jaxp/javax/xml/jaxp/unittest/transform/Bug6513892.java @@ -33,28 +33,22 @@ import javax.xml.transform.stream.StreamSource; import org.testng.Assert; -import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; import org.w3c.dom.Document; /* * @test - * @bug 6513892 + * @bug 6513892 8343001 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest * @run testng/othervm transform.Bug6513892 * @summary Test the output encoding of the transform is the same as that of the redirect extension. */ public class Bug6513892 { - @BeforeClass - public void setup(){ - if (System.getSecurityManager() != null) - System.setSecurityManager(null); - } - @Test public void test0() { try { TransformerFactory tf = TransformerFactory.newInstance(); + tf.setFeature("jdk.xml.enableExtensionFunctions", true); Transformer t = tf.newTransformer(new StreamSource(getClass().getResourceAsStream("redirect.xsl"), getClass().getResource("redirect.xsl") .toString())); diff --git a/test/jaxp/javax/xml/jaxp/unittest/transform/ErrorListenerTest.java b/test/jaxp/javax/xml/jaxp/unittest/transform/ErrorListenerTest.java index dbe1dcfe00ffa..139cf2911e6f6 100644 --- a/test/jaxp/javax/xml/jaxp/unittest/transform/ErrorListenerTest.java +++ b/test/jaxp/javax/xml/jaxp/unittest/transform/ErrorListenerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 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 @@ -50,9 +50,9 @@ /* * @test - * @bug 8157830 8228854 + * @bug 8157830 8228854 8343001 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest - * @run testng/othervm transform.ErrorListenerTest + * @run testng/othervm -Djdk.xml.enableExtensionFunctions=true transform.ErrorListenerTest * @summary Verifies that ErrorListeners are handled properly */ public class ErrorListenerTest { diff --git a/test/jaxp/javax/xml/jaxp/unittest/transform/SecureProcessingTest.java b/test/jaxp/javax/xml/jaxp/unittest/transform/SecureProcessingTest.java index 1d5fa236279f3..673c3c733266f 100644 --- a/test/jaxp/javax/xml/jaxp/unittest/transform/SecureProcessingTest.java +++ b/test/jaxp/javax/xml/jaxp/unittest/transform/SecureProcessingTest.java @@ -23,114 +23,98 @@ package transform; -import java.io.InputStream; import java.io.StringWriter; - import javax.xml.XMLConstants; import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerConfigurationException; import javax.xml.transform.TransformerException; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; - +import static jaxp.library.JAXPTestUtilities.SRC_DIR; +import static jaxp.library.JAXPTestUtilities.assertDoesNotThrow; +import static jaxp.library.JAXPTestUtilities.getSystemId; import org.testng.Assert; +import org.testng.annotations.DataProvider; import org.testng.annotations.Test; +import static transform.XSLTFunctionsTest.SP_ENABLE_EXTENSION_FUNCTION_SPEC; /* * @test + * @bug 8343001 8343001 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest * @run testng/othervm transform.SecureProcessingTest - * @summary Test XSLT shall report TransformerException for unsafe xsl when FEATURE_SECURE_PROCESSING is true. + * @summary Verifies that XSLT reports TransformerException as it processes xsl + * using extension functions while FEATURE_SECURE_PROCESSING is set to true. */ public class SecureProcessingTest { - @Test - public void testSecureProcessing() { - boolean _isSecureMode = System.getSecurityManager() != null; - // SECURE_PROCESSING == false + /** + * Test state + */ + public static enum TestState { + DEFAULT, // the default state + SETFSP, // set FEATURE_SECURE_PROCESSING + SETPROPERTY; // set the enalbeExtensionFunctions property + } - // the style sheet - InputStream xslStream = this.getClass().getResourceAsStream("SecureProcessingTest.xsl"); - StreamSource xslSource = new StreamSource(xslStream); + @DataProvider(name = "extFunc") + public Object[][] getExtFuncSettings() throws Exception { + return new Object[][] { + // by default, Extension Functions are disallowed + { TestState.DEFAULT, true, null, false, TransformerException.class}, + // set FSP=true, Extension Functions are disallowed + { TestState.SETFSP, true, null, false, TransformerException.class}, + // turning off FSP does not enable Extension Functions + { TestState.SETFSP, false, null, false, TransformerException.class}, + // between FSP and the Extension Functions property (jdk.xml.enableExtensionFunctions), + // the later takes precedence + { TestState.SETPROPERTY, true, SP_ENABLE_EXTENSION_FUNCTION_SPEC, false, TransformerException.class}, + { TestState.SETPROPERTY, true, SP_ENABLE_EXTENSION_FUNCTION_SPEC, true, null}, + }; + } + /** + * Verifies the effect of FEATURE_SECURE_PROCESSING (FSP) and the precedence + * between FSP and the Extension Functions property. + * + * @param testState the state of the test + * @param fspValue the FSP value to be set + * @param property the Extension Functions property + * @param propertyValue the property value + * @param expectedThrow the expected throw if the specified DTD can not be + * resolved. + * @throws Exception if the test fails + */ + @Test(dataProvider = "extFunc") + public void testFSP(TestState testState, boolean fspValue, String property, + boolean propertyValue, Class expectedThrow) + throws Exception { + final TransformerFactory tf = TransformerFactory.newInstance(); + switch (testState) { + case DEFAULT: + break; + case SETFSP: + tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, fspValue); + break; + case SETPROPERTY: + tf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, fspValue); + tf.setFeature(property, propertyValue); + break; + } + if (expectedThrow == null) { + assertDoesNotThrow(() -> runTransform(tf), "Unexpected exception."); + } else { + Assert.assertThrows(expectedThrow, () -> runTransform(tf)); + } + } - // the xml source - InputStream xmlStream = this.getClass().getResourceAsStream("SecureProcessingTest.xml"); - StreamSource xmlSource = new StreamSource(xmlStream); + private void runTransform(TransformerFactory tf) + throws Exception { + StreamSource xslSource = new StreamSource(getSystemId(SRC_DIR + "/SecureProcessingTest.xsl")); + StreamSource xmlSource = new StreamSource(getSystemId(SRC_DIR + "/SecureProcessingTest.xml")); // the xml result StringWriter xmlResultString = new StringWriter(); StreamResult xmlResultStream = new StreamResult(xmlResultString); - - // the transformer - TransformerFactory transformerFactory = null; - Transformer transformer = null; - - // transform with a non-secure Transformer - // expect success - String xmlResult; - if (!_isSecureMode) { // jaxp secure feature can not be turned off when - // security manager is present - try { - transformerFactory = TransformerFactory.newInstance(); - transformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false); - transformer = transformerFactory.newTransformer(xslSource); - transformer.transform(xmlSource, xmlResultStream); - } catch (TransformerConfigurationException ex) { - ex.printStackTrace(); - Assert.fail(ex.toString()); - } catch (TransformerException ex) { - ex.printStackTrace(); - Assert.fail(ex.toString()); - } - - // expected success - // and the result is ... - xmlResult = xmlResultString.toString(); - System.out.println("Transformation result (SECURE_PROCESSING == false) = \"" + xmlResult + "\""); - } - - // now do same transformation but with SECURE_PROCESSING == true - // expect Exception - boolean exceptionCaught = false; - - // the style sheet - xslStream = this.getClass().getResourceAsStream("SecureProcessingTest.xsl"); - xslSource = new StreamSource(xslStream); - - // the xml source - xmlStream = this.getClass().getResourceAsStream("SecureProcessingTest.xml"); - xmlSource = new StreamSource(xmlStream); - - // the xml result - xmlResultString = new StringWriter(); - xmlResultStream = new StreamResult(xmlResultString); - - // the transformer - transformerFactory = null; - transformer = null; - - // transform with a secure Transformer - try { - transformerFactory = TransformerFactory.newInstance(); - transformerFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); - transformer = transformerFactory.newTransformer(xslSource); - transformer.transform(xmlSource, xmlResultStream); - } catch (TransformerConfigurationException ex) { - ex.printStackTrace(); - Assert.fail(ex.toString()); - } catch (TransformerException ex) { - // expected failure - System.out.println("expected failure: " + ex.toString()); - ex.printStackTrace(System.out); - exceptionCaught = true; - } - - // unexpected success? - if (!exceptionCaught) { - // and the result is ... - xmlResult = xmlResultString.toString(); - System.err.println("Transformation result (SECURE_PROCESSING == true) = \"" + xmlResult + "\""); - Assert.fail("SECURITY_PROCESSING == true, expected failure but got result: \"" + xmlResult + "\""); - } + Transformer transformer = tf.newTransformer(xslSource); + transformer.transform(xmlSource, xmlResultStream); } } diff --git a/test/jaxp/javax/xml/jaxp/unittest/transform/XSLTFunctionsTest.java b/test/jaxp/javax/xml/jaxp/unittest/transform/XSLTFunctionsTest.java index 24570c20bad70..4e5d03151a917 100644 --- a/test/jaxp/javax/xml/jaxp/unittest/transform/XSLTFunctionsTest.java +++ b/test/jaxp/javax/xml/jaxp/unittest/transform/XSLTFunctionsTest.java @@ -23,7 +23,6 @@ package transform; -import java.io.FilePermission; import java.io.StringReader; import java.io.StringWriter; import java.nio.file.Files; @@ -36,16 +35,18 @@ import javax.xml.transform.URIResolver; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; +import static jaxp.library.JAXPTestUtilities.SRC_DIR; +import static jaxp.library.JAXPTestUtilities.assertDoesNotThrow; +import static jaxp.library.JAXPTestUtilities.getSystemId; +import static jaxp.library.JAXPTestUtilities.getSystemProperty; import org.testng.Assert; +import static org.testng.Assert.assertEquals; import org.testng.annotations.DataProvider; import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; -import static jaxp.library.JAXPTestUtilities.clearSystemProperty; -import static jaxp.library.JAXPTestUtilities.setSystemProperty; -import static jaxp.library.JAXPTestUtilities.getSystemProperty; /* * @test + * @bug 8062518 8153082 8165116 8343001 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest * @compile DocumentExtFunc.java * @run testng/othervm transform.XSLTFunctionsTest @@ -53,6 +54,21 @@ */ public class XSLTFunctionsTest { + @DataProvider(name = "propertyName") + public static Object[][] getSettings() { + return new Object[][] { + // legacy property name + {ORACLE_ENABLE_EXTENSION_FUNCTION, true, true, null}, + {ORACLE_ENABLE_EXTENSION_FUNCTION, true, false, TransformerException.class}, + // legacy system property name + {SP_ENABLE_EXTENSION_FUNCTION, false, true, null}, + {SP_ENABLE_EXTENSION_FUNCTION, false, false, TransformerException.class}, + // current property and system property name + {SP_ENABLE_EXTENSION_FUNCTION_SPEC, true, true, null}, + {SP_ENABLE_EXTENSION_FUNCTION_SPEC, true, false, TransformerException.class}, + }; + } + /** * @bug 8165116 * Verifies that redirect works properly when extension function is enabled @@ -86,59 +102,50 @@ public void testRedirect(String xml, String xsl, String output, String redirect) } /** - * @bug 8161454 - * Verifies that the new / correct name is supported, as is the old / incorrect - * one for compatibility + * @bug 8161454 8343001 + * Verifies that legacy property names are continually supported for compatibility. + * + * @param property the property name + * @param isAPIProperty indicates whether the property can be set via the factory + * @param value the property value + * @param expectedThrow the expected throw if the specified DTD can not be + * resolved. + * @throws Exception if the test fails */ - @Test - public void testNameChange() { - - boolean feature; - TransformerFactory tf = TransformerFactory.newInstance(); - feature = tf.getFeature(ORACLE_ENABLE_EXTENSION_FUNCTION); - System.out.println("Default setting: " + feature); - // The default: true if no SecurityManager, false otherwise - Assert.assertTrue(feature == getDefault()); - - setSystemProperty(SP_ENABLE_EXTENSION_FUNCTION, getDefaultOpposite()); - tf = TransformerFactory.newInstance(); - feature = tf.getFeature(ORACLE_ENABLE_EXTENSION_FUNCTION); - System.out.println("After setting " + SP_ENABLE_EXTENSION_FUNCTION + ": " + feature); - clearSystemProperty(SP_ENABLE_EXTENSION_FUNCTION); - // old/incorrect name is still supported - Assert.assertTrue(feature != getDefault()); - - setSystemProperty(SP_ENABLE_EXTENSION_FUNCTION_SPEC, getDefaultOpposite()); - tf = TransformerFactory.newInstance(); - feature = tf.getFeature(ORACLE_ENABLE_EXTENSION_FUNCTION); - System.out.println("After setting " + SP_ENABLE_EXTENSION_FUNCTION_SPEC + ": " + feature); - clearSystemProperty(SP_ENABLE_EXTENSION_FUNCTION_SPEC); - // new/correct name is effective - Assert.assertTrue(feature != getDefault()); - } - - final boolean isSecure; - { - String runSecMngr = getSystemProperty("runSecMngr"); - isSecure = runSecMngr != null && runSecMngr.equals("true"); - } - - // The default: true if no SecurityManager, false otherwise - private boolean getDefault() { - if (isSecure) { - return false; + @Test(dataProvider = "propertyName") + public void testNameChange(String property, boolean isAPIProperty, + boolean value, Class expectedThrow) + throws Exception { + if (expectedThrow == null) { + assertDoesNotThrow(() -> runTransform(property, isAPIProperty, value), + "Extension Functions property is set to " + value + " but exception is thrown."); } else { - return true; + Assert.assertThrows(expectedThrow, + () -> runTransform(property, isAPIProperty, value)); } } - // Gets a String value that is opposite to the default value - private String getDefaultOpposite() { - if (isSecure) { - return "true"; - } else { - return "false"; + private void runTransform(String property, boolean isAPIProperty, boolean value) + throws Exception { + StreamSource xslSource = new StreamSource(getSystemId(SRC_DIR + "/SecureProcessingTest.xsl")); + StreamSource xmlSource = new StreamSource(getSystemId(SRC_DIR + "/SecureProcessingTest.xml")); + + // the xml result + StringWriter xmlResultString = new StringWriter(); + StreamResult xmlResultStream = new StreamResult(xmlResultString); + + if (!isAPIProperty) { + System.setProperty(property, Boolean.toString(value)); + } + TransformerFactory tf = TransformerFactory.newInstance(); + if (isAPIProperty) { + tf.setFeature(property, value); + } + Transformer transformer = tf.newTransformer(xslSource); + if (!isAPIProperty) { + System.clearProperty(property); } + transformer.transform(xmlSource, xmlResultStream); } /** diff --git a/test/jdk/javax/xml/jaxp/common/8032908/XSLT.java b/test/jdk/javax/xml/jaxp/common/8032908/XSLT.java index 22a4346edae72..d4d84bf2b9ea8 100644 --- a/test/jdk/javax/xml/jaxp/common/8032908/XSLT.java +++ b/test/jdk/javax/xml/jaxp/common/8032908/XSLT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 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 @@ -23,12 +23,12 @@ /** * @test - * @bug 8032908 8081392 + * @bug 8032908 8081392 8343001 * @summary Test if Node.getTextContent() function correctly returns children * content and also check that Node.getNodeValue() returns null value for * Element nodes * @compile TestFunc.java XSLT.java - * @run main/othervm XSLT + * @run main/othervm -Djdk.xml.enableExtensionFunctions=true XSLT */ import java.io.ByteArrayOutputStream; import javax.xml.transform.Transformer; diff --git a/test/jdk/javax/xml/jaxp/parsers/8024707/XSLT.java b/test/jdk/javax/xml/jaxp/parsers/8024707/XSLT.java index e6a03f5af683c..89cb0741cfac1 100644 --- a/test/jdk/javax/xml/jaxp/parsers/8024707/XSLT.java +++ b/test/jdk/javax/xml/jaxp/parsers/8024707/XSLT.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 @@ -23,10 +23,10 @@ /** * @test - * @bug 8024707 + * @bug 8024707 8343001 * @summary Test for XSLT extension function with 1 element sized nodelist * @compile TestFunc.java XSLT.java - * @run main/othervm XSLT + * @run main/othervm -Djdk.xml.enableExtensionFunctions=true XSLT * @author aleksej.efimov@oracle.com */ diff --git a/test/jdk/javax/xml/jaxp/transform/8004476/XSLTExFuncTest.java b/test/jdk/javax/xml/jaxp/transform/8004476/XSLTExFuncTest.java index e23a0329bbaed..dc75a7980ae91 100644 --- a/test/jdk/javax/xml/jaxp/transform/8004476/XSLTExFuncTest.java +++ b/test/jdk/javax/xml/jaxp/transform/8004476/XSLTExFuncTest.java @@ -30,7 +30,7 @@ /** * @test - * @bug 8004476 + * @bug 8004476 8343001 * @summary test XSLT extension functions * @run main/othervm XSLTExFuncTest */ @@ -77,18 +77,18 @@ public static void main(String[] args) { } /** - * by default, extension function is enabled + * As of JDK-8343001, extension function is disabled by default. */ public void testExtFunc() { TransformerFactory factory = TransformerFactory.newInstance(); try { transform(factory); - System.out.println("testExtFunc: OK"); } catch (TransformerConfigurationException e) { fail(e.getMessage()); } catch (TransformerException ex) { - fail(ex.getMessage()); + //expected since extension function is disallowed + System.out.println("testExtFunc: OK"); } } From 43b337eb438f230dbca903b56e0809fc36fcd71d Mon Sep 17 00:00:00 2001 From: Amit Kumar Date: Wed, 4 Dec 2024 03:44:41 +0000 Subject: [PATCH 51/62] 8344304: [s390x] ubsan: negation of -2147483648 cannot be represented in type 'int' Reviewed-by: lucy, dlong --- src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp | 8 +++-- src/hotspot/cpu/s390/macroAssembler_s390.cpp | 33 ++++++++++++++++++- src/hotspot/cpu/s390/macroAssembler_s390.hpp | 4 ++- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp b/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp index dee64d3db265c..bb0494dc4785a 100644 --- a/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp @@ -1532,8 +1532,12 @@ void LIR_Assembler::arith_op(LIR_Code code, LIR_Opr left, LIR_Opr right, LIR_Opr // cpu register - constant jint c = right->as_constant_ptr()->as_jint(); switch (code) { - case lir_add: __ z_agfi(lreg, c); break; - case lir_sub: __ z_agfi(lreg, -c); break; // note: -min_jint == min_jint + case lir_add: + __ add2reg_32(lreg, c); + break; + case lir_sub: + __ add2reg_32(lreg, java_negate(c)); + break; case lir_mul: __ z_msfi(lreg, c); break; default: ShouldNotReachHere(); } diff --git a/src/hotspot/cpu/s390/macroAssembler_s390.cpp b/src/hotspot/cpu/s390/macroAssembler_s390.cpp index aacfb894c72d8..c297c66b02b5e 100644 --- a/src/hotspot/cpu/s390/macroAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/macroAssembler_s390.cpp @@ -657,7 +657,7 @@ void MacroAssembler::add2reg(Register r1, int64_t imm, Register r2) { z_aghik(r1, r2, imm); return; } - z_lgr(r1, r2); + lgr_if_needed(r1, r2); z_aghi(r1, imm); return; } @@ -681,6 +681,37 @@ void MacroAssembler::add2reg(Register r1, int64_t imm, Register r2) { z_agfi(r1, imm); } +void MacroAssembler::add2reg_32(Register r1, int64_t imm, Register r2) { + assert(Immediate::is_simm32(imm), "probably an implicit conversion went wrong"); + + if (r2 == noreg) { r2 = r1; } + + // Handle special case imm == 0. + if (imm == 0) { + lr_if_needed(r1, r2); + // Nothing else to do. + return; + } + + if (Immediate::is_simm16(imm)) { + if (r1 == r2){ + z_ahi(r1, imm); + return; + } + if (VM_Version::has_DistinctOpnds()) { + z_ahik(r1, r2, imm); + return; + } + lr_if_needed(r1, r2); + z_ahi(r1, imm); + return; + } + + // imm is simm32 + lr_if_needed(r1, r2); + z_afi(r1, imm); +} + // Generic operation r := b + x + d // // Addition of several operands with address generation semantics - sort of: diff --git a/src/hotspot/cpu/s390/macroAssembler_s390.hpp b/src/hotspot/cpu/s390/macroAssembler_s390.hpp index 91703fac994af..159688128189a 100644 --- a/src/hotspot/cpu/s390/macroAssembler_s390.hpp +++ b/src/hotspot/cpu/s390/macroAssembler_s390.hpp @@ -156,7 +156,9 @@ class MacroAssembler: public Assembler { unsigned int mul_reg64_const16(Register rval, Register work, int cval); // Generic operation r1 := r2 + imm. - void add2reg(Register r1, int64_t imm, Register r2 = noreg); + void add2reg (Register r1, int64_t imm, Register r2 = noreg); + void add2reg_32(Register r1, int64_t imm, Register r2 = noreg); + // Generic operation r := b + x + d. void add2reg_with_index(Register r, int64_t d, Register x, Register b = noreg); From 447f8d49963fef59d36c464c4b31bff79ef02de3 Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Wed, 4 Dec 2024 03:48:24 +0000 Subject: [PATCH 52/62] 8345353: Test for JDK-8344800 W3C DTDs and XSDs in the built-in Catalog Reviewed-by: rriggs, lancea --- .../common/jdkcatalog/JDKCatalogTest.java | 271 ++++++++++++++++++ .../common/jdkcatalog/TestCatalog.xml | 8 + .../unittest/common/jdkcatalog/dtdtest.xml | 20 ++ .../common/jdkcatalog/testDatatypes.xml | 11 + .../common/jdkcatalog/testDatatypes.xsd | 29 ++ .../unittest/common/jdkcatalog/testXML.xml | 10 + .../unittest/common/jdkcatalog/testXML.xsd | 27 ++ .../common/jdkcatalog/testXMLSchema.xml | 6 + .../common/jdkcatalog/xhtml-frameset.xml | 14 + .../jaxp/unittest/common/jdkcatalog/xhtml.xml | 12 + .../unittest/common/jdkcatalog/xsdtest.xml | 7 + 11 files changed, 415 insertions(+) create mode 100644 test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/JDKCatalogTest.java create mode 100644 test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/TestCatalog.xml create mode 100644 test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/dtdtest.xml create mode 100644 test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/testDatatypes.xml create mode 100644 test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/testDatatypes.xsd create mode 100644 test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/testXML.xml create mode 100644 test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/testXML.xsd create mode 100644 test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/testXMLSchema.xml create mode 100644 test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/xhtml-frameset.xml create mode 100644 test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/xhtml.xml create mode 100644 test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/xsdtest.xml diff --git a/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/JDKCatalogTest.java b/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/JDKCatalogTest.java new file mode 100644 index 0000000000000..0f4c0aec2deb9 --- /dev/null +++ b/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/JDKCatalogTest.java @@ -0,0 +1,271 @@ +/* + * Copyright (c) 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. + */ +package common.jdkcatalog; + +import java.io.StringReader; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.stream.Collectors; +import javax.xml.XMLConstants; +import javax.xml.catalog.CatalogFeatures; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.transform.sax.SAXSource; +import javax.xml.validation.SchemaFactory; +import javax.xml.validation.Validator; +import org.testng.Assert; +import org.testng.Assert.ThrowingRunnable; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; +import org.xml.sax.helpers.DefaultHandler; + +/* + * @test + * @bug 8344800 8345353 + * @run testng/othervm common.jdkcatalog.JDKCatalogTest + * @summary Verifies the W3C DTDs and XSDs in the JDK built-in catalog. + */ +public class JDKCatalogTest { + static String CLS_DIR = System.getProperty("test.classes"); + static String SRC_DIR = System.getProperty("test.src"); + public static boolean isWindows = false; + static { + if (System.getProperty("os.name").contains("Windows")) { + isWindows = true; + } + }; + public static final String JDKCATALOG_RESOLVE = "jdk.xml.jdkcatalog.resolve"; + static final String PUBLIC_ID = "{{publicId}}"; + static final String SYSTEM_ID = "{{systemId}}"; + static final String XSD_LOCATION = "{{SCHEMA_LOCATION}}"; + static final String TARGET_NAMESPACE = "{{targetNamespace}}"; + static final String ROOT_ELEMENT = "{{rootElement}}"; + + /* + * DataProvider: for verifying DTDs in the JDKCatalog + * Data provided: see test testExternalDTD + */ + @DataProvider(name = "externalDTD") + public Object[][] getDTD() throws Exception { + return new Object[][]{ + // verifies the test method correctly throws an exception if the specified + // DTD can not be resolved + {"-//ORG//DTD FOO 200102//EN", "http://foo.org/2001/bar.dtd", SAXException.class}, + // this test also verifies datatypes.dtd as it's referenced in XMLSchema.dtd + {"-//W3C//DTD XMLSCHEMA 200102//EN", "http://www.w3.org/2001/XMLSchema.dtd", null}, + {"-//W3C//DTD XHTML 1.0 Frameset//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd", null}, + {"-//W3C//DTD XHTML 1.0 Strict//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd", null}, + {"-//W3C//DTD XHTML 1.0 Transitional//EN", "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd", null}, + {"-//W3C//DTD XHTML 1.1//EN", "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd", null}, + {"-//W3C//DTD Specification V2.10//EN", "http://www.w3.org/2002/xmlspec/dtd/2.10/xmlspec.dtd", null}, + }; + } + + /* + * DataProvider: for verifying XSDs in the JDKCatalog + * Data provided: see test testXSD + */ + @DataProvider(name = "getXSD") + public Object[][] getXSD() throws Exception { + return new Object[][]{ + // verifies the test method correctly throws an exception if the specified + // XSD can not be resolved + {"xsdtest.xml", "http://foo.org/2001/bar.xsd", "http://foo.org/2001/bar", "root", null, SAXException.class}, + // application XSD is resolved by a custom catalog, the W3C XSD then by the JDKCatalog + {"testXML.xml", "http://www.w3.org/2001/xml.xsd", "http://www.w3.org/XML/1998/namespace", "testXMLXSD", "TestCatalog.xml", null}, + // this test also verifies XMLSchema.dtd and xml.xsd as they are referenced + {"testXMLSchema.xml", "http://www.w3.org/2001/XMLSchema.xsd", "http://www.w3.org/2001/XMLSchema", "xs:schema", null, null}, + {"testDatatypes.xml", "http://www.w3.org/2009/XMLSchema/XMLSchema-datatypes.xsd", "http://www.w3.org/2001/XMLSchema-datatypes", "testDatatypes", "TestCatalog.xml", null}, + {"xhtml-frameset.xml", "https://www.w3.org/2002/08/xhtml/xhtml1-frameset.xsd", "http://www.w3.org/1999/xhtml", "html", null, null}, + {"xhtml.xml", "https://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd", "http://www.w3.org/1999/xhtml", "html", null, null}, + {"xhtml.xml", "https://www.w3.org/2002/08/xhtml/xhtml1-transitional.xsd", "http://www.w3.org/1999/xhtml", "html", null, null}, + {"xhtml.xml", "http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd", "http://www.w3.org/1999/xhtml", "html", null, null}, + }; + } + + /** + * Verifies that references to the W3C DTDs are resolved by the JDK built-in + * catalog. + * @param publicId the PUBLIC identifier + * @param systemId the SYSTEM identifier + * @param expectedThrow the expected throw if the specified DTD can not be + * resolved. + * @throws Exception if the test fails + */ + @Test(dataProvider = "externalDTD") + public void testExternalDTD(String publicId, String systemId, Class expectedThrow) + throws Exception { + final String xmlString = generateXMLWithDTDRef(publicId, systemId); + + if (expectedThrow == null) { + assertDoesNotThrow(() -> parseWithResolveStrict(xmlString), + "JDKCatalog shall resolve " + systemId + " but exception is thrown."); + } else { + Assert.assertThrows(expectedThrow, + () -> parseWithResolveStrict(xmlString)); + } + } + + /** + * Verifies that references to the W3C DTDs are resolved by the JDK built-in + * catalog. + * @param xmlTemplate a template used to generate an XML instance + * @param xsdLocation the XSD to be resolved + * @param targetNS the target namespace + * @param rootElement the root element + * @param catalog the custom catalog to be used to resolve XSDs used by the + * test. + * @param expectedThrow the expected throw if the specified DTD can not be + * resolved. + * @throws Exception if the test fails + */ + @Test(dataProvider = "getXSD") + public void testXSD(String xmlTemplate, String xsdLocation, String targetNS, String rootElement, String catalog, + Class expectedThrow) + throws Exception { + String xmlSrcPath = SRC_DIR + "/" + xmlTemplate; + final String xmlSrcId = getSysId(xmlSrcPath); + + final String customCatalog = getSysId((catalog != null) ? SRC_DIR + "/" + catalog : null); + + final String xmlString = generateXMLWithXSDRef(xmlSrcPath, xsdLocation, + targetNS, rootElement); + if (expectedThrow == null) { + assertDoesNotThrow(() -> validateWithResolveStrict(xmlString, xmlSrcId, customCatalog), + "JDKCatalog shall resolve " + xsdLocation + " but exception is thrown."); + } else { + Assert.assertThrows(expectedThrow, + () -> validateWithResolveStrict(xmlString, xmlSrcId, customCatalog)); + } + } + + /** + * Validate the specified XML document with jdk.xml.jdkCatalog.resolve set to strict. + * @param xml the XML document to be validated + * @param xmlSrcPathId the URI to the XML source (template in this case) + * @param customCatalog the custom catalog used to resolve local XSDs + * @throws Exception if validation fails + */ + public void validateWithResolveStrict(String xml, String xmlSrcPathId, String customCatalog) + throws Exception { + SAXSource ss = new SAXSource(new InputSource(new StringReader(xml))); + ss.setSystemId(xmlSrcPathId); + SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + schemaFactory.setProperty(JDKCATALOG_RESOLVE, "strict"); + if (customCatalog != null) { + schemaFactory.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), customCatalog); + schemaFactory.setProperty(CatalogFeatures.Feature.RESOLVE.getPropertyName(), "continue"); + } + Validator validator = schemaFactory.newSchema().newValidator(); + validator.validate(ss); + } + + /** + * Parses the XML with jdk.xml.jdkCatalog.resolve set to strict. + * @param xml the XML document to be parsed + * @throws Exception if external access is denied + */ + public void parseWithResolveStrict(String xml) + throws Exception { + SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); + saxParserFactory.setNamespaceAware(true); + XMLReader xmlReader = saxParserFactory.newSAXParser().getXMLReader(); + xmlReader.setProperty(JDKCATALOG_RESOLVE, "strict"); + xmlReader.setContentHandler(new DefaultHandler()); + xmlReader.parse(new InputSource(new StringReader(xml))); + } + + /** + * Generates an XML with the specified PUBLIC and SYSTEM identifiers. + * @param publicId the public identifier + * @param systemId the system identifier + * @return an XML + * @throws Exception if error happens + */ + private String generateXMLWithDTDRef(String publicId, String systemId) + throws Exception { + Path path = Paths.get(SRC_DIR + "/dtdtest.xml"); + String xmlString = Files.lines(path).map(line -> { + line = line.replace(PUBLIC_ID, publicId); + line = line.replace(SYSTEM_ID, systemId); + return line; + }).collect(Collectors.joining(System.lineSeparator())); + return xmlString; + } + + /** + * Generates an XML with the specified XSD location. + * @param xmlSrcPath the path to the XML source + * @param xsd the XSD location + * @return an XML + * @throws Exception if error happens + */ + private String generateXMLWithXSDRef(String xmlSrcPath, String xsd, + String targetNS, String rootElement) + throws Exception { + String xmlString = Files.lines(Paths.get(xmlSrcPath)).map(line -> { + if (line.contains(XSD_LOCATION)) { + line = line.replace(XSD_LOCATION, xsd); + } + if (line.contains(TARGET_NAMESPACE)) { + line = line.replace(TARGET_NAMESPACE, targetNS); + } + if (line.contains(ROOT_ELEMENT)) { + line = line.replace(ROOT_ELEMENT, rootElement); + } + return line; + }).collect(Collectors.joining(System.lineSeparator())); + return xmlString; + } + + /** + * Returns the System identifier (URI) of the source. + * @param path the path to the source + * @return the System identifier + */ + private String getSysId(String path) { + if (path == null) return null; + String xmlSysId = "file://" + path; + if (isWindows) { + path = path.replace('\\', '/'); + xmlSysId = "file:///" + path; + } + return xmlSysId; + } + + /** + * Asserts the run does not cause a Throwable. + * @param runnable the runnable + * @param message the message if the test fails + */ + private void assertDoesNotThrow(ThrowingRunnable runnable, String message) { + try { + runnable.run(); + } catch (Throwable t) { + Assert.fail(message + "\n Exception thrown: " + t.getMessage()); + } + } +} diff --git a/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/TestCatalog.xml b/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/TestCatalog.xml new file mode 100644 index 0000000000000..d54a4bd1c85f8 --- /dev/null +++ b/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/TestCatalog.xml @@ -0,0 +1,8 @@ + + + + + + + diff --git a/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/dtdtest.xml b/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/dtdtest.xml new file mode 100644 index 0000000000000..fd5fed4e26646 --- /dev/null +++ b/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/dtdtest.xml @@ -0,0 +1,20 @@ + + + + + + XHTML 1.0 + + + +

      + XHTML 1.0 +

      +
        +
      • + xhtml1-transition.dtd +
      • +
      + + diff --git a/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/testDatatypes.xml b/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/testDatatypes.xml new file mode 100644 index 0000000000000..11660802190ef --- /dev/null +++ b/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/testDatatypes.xml @@ -0,0 +1,11 @@ + + + + Hello, World! + 12345 + 67.78 + false + 2024-11-24 + diff --git a/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/testDatatypes.xsd b/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/testDatatypes.xsd new file mode 100644 index 0000000000000..4af92ad25c106 --- /dev/null +++ b/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/testDatatypes.xsd @@ -0,0 +1,29 @@ + + + + + + + + Get access to the type defined in datatypes + + + + + + + + + + + + + + + + + + diff --git a/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/testXML.xml b/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/testXML.xml new file mode 100644 index 0000000000000..359076f37f665 --- /dev/null +++ b/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/testXML.xml @@ -0,0 +1,10 @@ + + + + Hello, World! + diff --git a/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/testXML.xsd b/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/testXML.xsd new file mode 100644 index 0000000000000..ba761f189266c --- /dev/null +++ b/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/testXML.xsd @@ -0,0 +1,27 @@ + + + + + + + Get access to the xml: attribute groups for xml:lang + as declared on 'schema' and 'documentation' below + + + + + + + + + + + + + + + diff --git a/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/testXMLSchema.xml b/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/testXMLSchema.xml new file mode 100644 index 0000000000000..d7b13fa762b54 --- /dev/null +++ b/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/testXMLSchema.xml @@ -0,0 +1,6 @@ + + + + diff --git a/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/xhtml-frameset.xml b/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/xhtml-frameset.xml new file mode 100644 index 0000000000000..f046df8ccf9f2 --- /dev/null +++ b/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/xhtml-frameset.xml @@ -0,0 +1,14 @@ + + + + Test XHTML + + + + + + + diff --git a/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/xhtml.xml b/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/xhtml.xml new file mode 100644 index 0000000000000..9ceb61516cdc2 --- /dev/null +++ b/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/xhtml.xml @@ -0,0 +1,12 @@ + + + + Test XHTML + + +

      Test XHTML

      + + diff --git a/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/xsdtest.xml b/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/xsdtest.xml new file mode 100644 index 0000000000000..36533f880657e --- /dev/null +++ b/test/jaxp/javax/xml/jaxp/unittest/common/jdkcatalog/xsdtest.xml @@ -0,0 +1,7 @@ + +<{{rootElement}} xmlns="{{targetNamespace}}" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="{{targetNamespace}} {{SCHEMA_LOCATION}}" + xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + + From 521ed72b87d0fb1def6d94485e08be22632deef0 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Wed, 4 Dec 2024 04:28:06 +0000 Subject: [PATCH 53/62] 8345357: test/jdk/javax/swing/JRadioButton/8033699/bug8033699.java fails in ubuntu22.04 Reviewed-by: abhiscxk --- .../JRadioButton/8033699/bug8033699.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/test/jdk/javax/swing/JRadioButton/8033699/bug8033699.java b/test/jdk/javax/swing/JRadioButton/8033699/bug8033699.java index 9365e6ba45b25..699338c4b30f5 100644 --- a/test/jdk/javax/swing/JRadioButton/8033699/bug8033699.java +++ b/test/jdk/javax/swing/JRadioButton/8033699/bug8033699.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, 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 @@ -28,6 +28,7 @@ * @summary Incorrect radio button behavior when pressing tab key * @run main bug8033699 */ + import java.awt.KeyboardFocusManager; import java.awt.Robot; import java.awt.event.ActionListener; @@ -57,42 +58,50 @@ public class bug8033699 { public static void main(String[] args) throws Throwable { SwingUtilities.invokeAndWait(() -> { - changeLAF(); - createAndShowGUI(); + changeLAF(); + createAndShowGUI(); }); robot = new Robot(); - Thread.sleep(100); - robot.waitForIdle(); - robot.setAutoDelay(100); + robot.waitForIdle(); + robot.delay(1000); // tab key test grouped radio button runTest1(); + robot.delay(100); // tab key test non-grouped radio button runTest2(); + robot.delay(100); // shift tab key test grouped and non-grouped radio button runTest3(); + robot.delay(100); // left/up key test in grouped radio button runTest4(); + robot.delay(100); // down/right key test in grouped radio button runTest5(); + robot.delay(100); // tab from radio button in group to next component in the middle of button group layout runTest6(); + robot.delay(100); // tab to radio button in group from component in the middle of button group layout runTest7(); + robot.delay(100); // down key circle back to first button in grouped radio button runTest8(); + robot.delay(100); // Verify that ActionListener is called when a RadioButton is selected using arrow key. runTest9(); + robot.delay(100); SwingUtilities.invokeAndWait(() -> mainFrame.dispose()); } From e15912b804ca42446f5fc309aa44043c9209b977 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Wed, 4 Dec 2024 06:02:08 +0000 Subject: [PATCH 54/62] 8345248: Module name 'transitive' not accepted for `requires transitive` Reviewed-by: vromero --- .../sun/tools/javac/parser/JavacParser.java | 8 +- .../javac/modules/RequiresTransitiveTest.java | 103 ++++++++++++++++++ 2 files changed, 107 insertions(+), 4 deletions(-) diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java index a02945dee3c49..d975a6c927a10 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java @@ -4208,16 +4208,16 @@ List moduleDirectiveList() { while (true) { switch (token.kind) { case IDENTIFIER: - if (token.name() == names.transitive && !isTransitive) { + if (token.name() == names.transitive) { Token t1 = S.token(1); if (t1.kind == SEMI || t1.kind == DOT) { break loop; } + if (isTransitive) { + log.error(DiagnosticFlag.SYNTAX, token.pos, Errors.RepeatedModifier); + } isTransitive = true; break; - } else if (token.name() == names.transitive && isTransitive) { - log.error(DiagnosticFlag.SYNTAX, token.pos, Errors.RepeatedModifier); - break; } else { break loop; } diff --git a/test/langtools/tools/javac/modules/RequiresTransitiveTest.java b/test/langtools/tools/javac/modules/RequiresTransitiveTest.java index 6ff0dabec1ff9..03f34e9611311 100644 --- a/test/langtools/tools/javac/modules/RequiresTransitiveTest.java +++ b/test/langtools/tools/javac/modules/RequiresTransitiveTest.java @@ -23,6 +23,7 @@ /* * @test + * @bug 8345248 * @summary tests for "requires transitive" * @library /tools/lib * @modules @@ -34,6 +35,8 @@ import java.nio.file.Files; import java.nio.file.Path; +import java.util.List; +import java.util.Objects; import toolbox.JavacTask; import toolbox.Task; @@ -256,4 +259,104 @@ public void testRepeatedModifiers(Path base) throws Exception { throw new Exception("expected output not found: " + e); } } + + @Test //JDK-8345248: + public void testTransitiveModuleName(Path base) throws Exception { + Path lib = base.resolve("lib"); + Path libSrc = lib.resolve("src"); + Path transitive = libSrc.resolve("transitive"); + tb.writeJavaFiles(transitive, + """ + module transitive { + } + """ + ); + Path transitiveA = libSrc.resolve("transitive.a"); + tb.writeJavaFiles(transitiveA, + """ + module transitive.a { + } + """ + ); + + Path libClasses = lib.resolve("classes"); + Files.createDirectories(libClasses); + + new JavacTask(tb, Task.Mode.CMDLINE) + .options("--module-source-path", libSrc.toString()) + .files(findJavaFiles(libSrc)) + .outdir(libClasses) + .run() + .writeAll(); + + Path src = base.resolve("src"); + Path classes = base.resolve("classes"); + + Files.createDirectories(classes); + + tb.writeJavaFiles(src, + """ + module m { + requires transitive; + requires transitive.a; + } + """ + ); + + new JavacTask(tb, Task.Mode.CMDLINE) + .options("--module-path", libClasses.toString()) + .sourcepath(src) + .files(findJavaFiles(src)) + .outdir(classes) + .run() + .writeAll(); + + tb.writeJavaFiles(src, + """ + module m { + requires transitive transitive; + requires transitive transitive.a; + } + """ + ); + + new JavacTask(tb, Task.Mode.CMDLINE) + .options("--module-path", libClasses.toString()) + .sourcepath(src) + .files(findJavaFiles(src)) + .outdir(classes) + .run() + .writeAll(); + + tb.writeJavaFiles(src, + """ + module m { + requires transitive transitive transitive; + requires transitive transitive transitive.a; + } + """ + ); + + List log = new JavacTask(tb, Task.Mode.CMDLINE) + .options("--module-path", libClasses.toString(), + "-XDrawDiagnostics") + .sourcepath(src) + .files(findJavaFiles(src)) + .outdir(classes) + .run(Task.Expect.FAIL) + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + + List expected = List.of( + "module-info.java:2:25: compiler.err.repeated.modifier", + "module-info.java:3:25: compiler.err.repeated.modifier", + "2 errors" + ); + + if (!Objects.equals(expected, log)) { + throw new Exception("expected: " + expected + + ", but got: " + log); + } + } } From 4b928167435bbf41dd00425c927da761751ca704 Mon Sep 17 00:00:00 2001 From: Jaikiran Pai Date: Wed, 4 Dec 2024 06:36:54 +0000 Subject: [PATCH 55/62] 8345375: Improve debuggability of test/jdk/java/net/Socket/CloseAvailable.java Reviewed-by: cstein, dfuchs --- test/jdk/java/net/Socket/CloseAvailable.java | 207 +++++++++++-------- 1 file changed, 116 insertions(+), 91 deletions(-) diff --git a/test/jdk/java/net/Socket/CloseAvailable.java b/test/jdk/java/net/Socket/CloseAvailable.java index bbeb37eb8f5fc..5ff7e0c03a3d7 100644 --- a/test/jdk/java/net/Socket/CloseAvailable.java +++ b/test/jdk/java/net/Socket/CloseAvailable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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,7 +25,7 @@ * @test * @bug 4091859 8189366 * @library /test/lib - * @summary Test Socket.available() + * @summary Test Socket.getInputStream().available() * @run main CloseAvailable * @run main/othervm -Djava.net.preferIPv4Stack=true CloseAvailable */ @@ -48,110 +48,135 @@ public static void main(String[] args) throws Exception { testIOEOnClosed(false); } + /* + * Verifies that the Socket.getInputStream().available() throws an IOException + * if invoked after the socket has been closed. + */ static void testClose() throws IOException { - boolean error = true; - InetAddress addr = InetAddress.getLocalHost(); - ServerSocket ss = new ServerSocket(0, 0, addr); - int port = ss.getLocalPort(); - - Thread t = new Thread(new Thread("Close-Available-1") { - public void run() { - try { - Socket s = new Socket(addr, port); - s.close(); - } catch (Exception e) { - e.printStackTrace(); - } - } - }); - - t.start(); - - Socket soc = ss.accept(); - ss.close(); - - DataInputStream is = new DataInputStream(soc.getInputStream()); - is.close(); - + System.out.println("testClose"); + final InetAddress addr = InetAddress.getLoopbackAddress(); + final Socket acceptedSocket; + try (final ServerSocket ss = new ServerSocket(0, 0, addr)) { + System.out.println("created server socket: " + ss); + final int port = ss.getLocalPort(); + // start a thread which initiates a socket connection to the server + Thread.ofPlatform().name("Close-Available-1") + .start(() -> { + try { + final Socket s = new Socket(addr, port); + System.out.println("created socket: " + s); + s.close(); + System.out.println("closed socket: " + s); + } catch (Exception e) { + System.err.println("exception in " + Thread.currentThread().getName() + + ": " + e); + e.printStackTrace(); + } + }); + // accept the client connect + acceptedSocket = ss.accept(); + System.out.println(ss + " accepted connection " + acceptedSocket); + } // (intentionally) close the ServerSocket + + final DataInputStream is = new DataInputStream(acceptedSocket.getInputStream()); + is.close(); // close the inputstream and thus the underlying socket + System.out.println("closed inputstream of socket: " + acceptedSocket); try { - is.available(); - } - catch (IOException ex) { - error = false; + final int av = is.available(); + // available() was expected to fail but didn't + throw new AssertionError("Socket.getInputStream().available() was expected to fail on " + + acceptedSocket + " but returned " + av); + } catch (IOException ex) { + // expected IOException + System.out.println("received the expected IOException: " + ex); } - if (error) - throw new RuntimeException("Available() can be called after stream closed."); } - // Verifies consistency of `available` behaviour when EOF reached, both - // explicitly and implicitly. + /* + * Verifies consistency of Socket.getInputStream().available() behaviour when EOF reached, both + * explicitly and implicitly. + */ static void testEOF(boolean readUntilEOF) throws IOException { System.out.println("testEOF, readUntilEOF: " + readUntilEOF); - InetAddress addr = InetAddress.getLoopbackAddress(); - ServerSocket ss = new ServerSocket(); - ss.bind(new InetSocketAddress(addr, 0), 0); - int port = ss.getLocalPort(); - - try (Socket s = new Socket(addr, port)) { - s.getOutputStream().write(0x42); - s.shutdownOutput(); - - try (Socket soc = ss.accept()) { - ss.close(); - - InputStream is = soc.getInputStream(); - int b = is.read(); - assert b == 0x42; - assert !s.isClosed(); - if (readUntilEOF) { - b = is.read(); - assert b == -1; + final InetAddress addr = InetAddress.getLoopbackAddress(); + try (final ServerSocket ss = new ServerSocket()) { + ss.bind(new InetSocketAddress(addr, 0), 0); + System.out.println("server socket bound: " + ss); + final int port = ss.getLocalPort(); + try (final Socket s = new Socket(addr, port)) { + System.out.println("created socket: " + s); + s.getOutputStream().write(0x42); + s.shutdownOutput(); + + try (final Socket soc = ss.accept()) { + System.out.println("accepted socket: " + soc); + ss.close(); + System.out.println("closed server socket: " + ss); + + final InputStream is = soc.getInputStream(); + int b = is.read(); + assert b == 0x42 : "unexpected byte read: " + b; + assert !s.isClosed() : "socket " + s + " is unexpectedly closed"; + if (readUntilEOF) { + b = is.read(); + assert b == -1 : "unexpected number of bytes read: " + b; + } + + int a; + for (int i = 0; i < 100; i++) { + a = is.available(); + System.out.print(a + ", "); + if (a != 0) { + throw new RuntimeException("Unexpected non-zero available: " + a); + } + } + assert !s.isClosed() : "socket " + s + " is unexpectedly closed"; + final int more = is.read(); + assert more == -1 : "unexpected byte read: " + more; } - - int a; - for (int i = 0; i < 100; i++) { - a = is.available(); - System.out.print(a + ", "); - if (a != 0) - throw new RuntimeException("Unexpected non-zero available: " + a); - } - assert !s.isClosed(); - assert is.read() == -1; } } System.out.println("\ncomplete"); } - // Verifies IOException thrown by `available`, on a closed input stream - // that may, or may not, have reached EOF prior to closure. + /* + * Verifies IOException thrown by Socket.getInputStream().available(), on a closed input stream + * that may, or may not, have reached EOF prior to closure. + */ static void testIOEOnClosed(boolean readUntilEOF) throws IOException { System.out.println("testIOEOnClosed, readUntilEOF: " + readUntilEOF); - InetAddress addr = InetAddress.getLoopbackAddress(); - ServerSocket ss = new ServerSocket(); - ss.bind(new InetSocketAddress(addr, 0), 0); - int port = ss.getLocalPort(); - - try (Socket s = new Socket(addr, port)) { - s.getOutputStream().write(0x43); - s.shutdownOutput(); - - try (Socket soc = ss.accept()) { - ss.close(); - - InputStream is = soc.getInputStream(); - int b = is.read(); - assert b == 0x43; - assert !s.isClosed(); - if (readUntilEOF) { - b = is.read(); - assert b == -1; - } - is.close(); - try { - b = is.available(); - throw new RuntimeException("UNEXPECTED successful read: " + b); - } catch (IOException expected) { - System.out.println("caught expected IOException:" + expected); + final InetAddress addr = InetAddress.getLoopbackAddress(); + try (final ServerSocket ss = new ServerSocket()) { + ss.bind(new InetSocketAddress(addr, 0), 0); + System.out.println("server socket bound: " + ss); + final int port = ss.getLocalPort(); + + try (final Socket s = new Socket(addr, port)) { + System.out.println("created socket: " + s); + s.getOutputStream().write(0x43); + s.shutdownOutput(); + + try (final Socket soc = ss.accept()) { + System.out.println("accepted socket: " + soc); + ss.close(); + System.out.println("closed server socket: " + ss); + + final InputStream is = soc.getInputStream(); + int b = is.read(); + assert b == 0x43 : "unexpected byte read: " + b; + assert !s.isClosed() : "socket " + s + " is unexpectedly closed"; + if (readUntilEOF) { + b = is.read(); + assert b == -1 : "unexpected byte read: " + b; + } + is.close(); + System.out.println("closed inputstream of socket: " + soc); + try { + b = is.available(); + throw new RuntimeException("UNEXPECTED successful read: " + b); + } catch (IOException expected) { + System.out.println("caught expected IOException:" + expected); + } } } } From 4c33caa185ccc2f406cf2e9c4c58c3cc0a1856f8 Mon Sep 17 00:00:00 2001 From: Richard Reingruber Date: Wed, 4 Dec 2024 07:26:34 +0000 Subject: [PATCH 56/62] 8344609: Check ResourceMark nesting when allocating a GrowableArray on an alternative ResourceArea Reviewed-by: dholmes, mdoerr --- src/hotspot/share/utilities/growableArray.cpp | 13 +++++++++++++ src/hotspot/share/utilities/growableArray.hpp | 6 +++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/utilities/growableArray.cpp b/src/hotspot/share/utilities/growableArray.cpp index 60ed0a477e8e0..2fd8166ba4d4f 100644 --- a/src/hotspot/share/utilities/growableArray.cpp +++ b/src/hotspot/share/utilities/growableArray.cpp @@ -61,6 +61,10 @@ GrowableArrayNestingCheck::GrowableArrayNestingCheck(bool on_resource_area) : _nesting(on_resource_area ? Thread::current()->resource_area()->nesting() : 0) { } +GrowableArrayNestingCheck::GrowableArrayNestingCheck(Arena* arena) : + _nesting((arena->get_tag() == Arena::Tag::tag_ra) ? static_cast(arena)->nesting() : 0) { +} + void GrowableArrayNestingCheck::on_resource_area_alloc() const { // Check for insidious allocation bug: if a GrowableArray overflows, the // grown array must be allocated under the same ResourceMark as the original. @@ -70,6 +74,11 @@ void GrowableArrayNestingCheck::on_resource_area_alloc() const { } } +void GrowableArrayNestingCheck::on_arena_alloc(Arena* arena) const { + if ((arena->get_tag() == Arena::Tag::tag_ra) && (_nesting != static_cast(arena)->nesting())) { + fatal("allocation bug: GrowableArray is growing within nested ResourceMark"); + } +} void GrowableArrayMetadata::init_checks(const GrowableArrayBase* array) const { // Stack allocated arrays support all three element allocation locations if (array->allocated_on_stack_or_embedded()) { @@ -89,4 +98,8 @@ void GrowableArrayMetadata::on_resource_area_alloc_check() const { _nesting_check.on_resource_area_alloc(); } +void GrowableArrayMetadata::on_arena_alloc_check() const { + _nesting_check.on_arena_alloc(arena()); +} + #endif // ASSERT diff --git a/src/hotspot/share/utilities/growableArray.hpp b/src/hotspot/share/utilities/growableArray.hpp index 2eb8e6fd09e12..5dec089a4fba5 100644 --- a/src/hotspot/share/utilities/growableArray.hpp +++ b/src/hotspot/share/utilities/growableArray.hpp @@ -608,8 +608,10 @@ class GrowableArrayNestingCheck { public: GrowableArrayNestingCheck(bool on_resource_area); + GrowableArrayNestingCheck(Arena* arena); void on_resource_area_alloc() const; + void on_arena_alloc(Arena* arena) const; }; #endif // ASSERT @@ -649,7 +651,7 @@ class GrowableArrayMetadata { // Arena allocation GrowableArrayMetadata(Arena* arena) : _bits(bits(arena)) - debug_only(COMMA _nesting_check(false)) { + debug_only(COMMA _nesting_check(arena)) { } // CHeap allocation @@ -676,6 +678,7 @@ class GrowableArrayMetadata { void init_checks(const GrowableArrayBase* array) const; void on_resource_area_alloc_check() const; + void on_arena_alloc_check() const; #endif // ASSERT bool on_C_heap() const { return (_bits & 1) == 1; } @@ -740,6 +743,7 @@ class GrowableArray : public GrowableArrayWithAllocator> { } assert(on_arena(), "Sanity"); + debug_only(_metadata.on_arena_alloc_check()); return allocate(this->_capacity, _metadata.arena()); } From 9e2b66fb0f2b86d2c70b8ec5cce2eab123c7a9c1 Mon Sep 17 00:00:00 2001 From: Robbin Ehn Date: Wed, 4 Dec 2024 07:53:30 +0000 Subject: [PATCH 57/62] 8345178: RISC-V: Add gtests for narrow cmpxchg Reviewed-by: fyang, mli --- .../gtest/riscv/test_assembler_riscv.cpp | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) diff --git a/test/hotspot/gtest/riscv/test_assembler_riscv.cpp b/test/hotspot/gtest/riscv/test_assembler_riscv.cpp index 415f72f9a0f43..7df6c6b933ea4 100644 --- a/test/hotspot/gtest/riscv/test_assembler_riscv.cpp +++ b/test/hotspot/gtest/riscv/test_assembler_riscv.cpp @@ -260,4 +260,85 @@ TEST_VM(RiscV, cmpxchg_int32_plain_maybe_zacas) { } } +template +class NarrowCmpxchgTester { + public: + typedef TESTSIZE (*cmpxchg_func)(intptr_t addr, TESTSIZE expected, TESTSIZE new_value, TESTSIZE result, + int64_t scratch0, int64_t scratch1, int64_t scratch2); + + static TESTSIZE narrow_cmpxchg(intptr_t addr, TESTSIZE expected, TESTSIZE new_value, TESTSIZE result, bool boolean_result = false) { + BufferBlob* bb = BufferBlob::create("riscvTest", 128); + CodeBuffer code(bb); + MacroAssembler _masm(&code); + address entry = _masm.pc(); + { + _masm.cmpxchg_narrow_value(/*addr*/ c_rarg0, /*expected*/ c_rarg1, /*new_value*/c_rarg2, + ASMSIZE, Assembler::relaxed, Assembler::relaxed, + /*result*/ c_rarg3, boolean_result, c_rarg4, c_rarg5, c_rarg6); /* Uses also t0-t1, caller saved */ + _masm.mv(c_rarg0, c_rarg3); + _masm.ret(); + } + _masm.flush(); // icache invalidate + TESTSIZE ret = ((cmpxchg_func)entry)(addr, expected, new_value, result, -1, -1, -1); + BufferBlob::free(bb); + return ret; + } +}; + +template +void run_narrow_cmpxchg_tests() { + // Assume natural aligned + TESTSIZE data[8]; + TESTSIZE ret; + for (int i = 0; i < 7; i++) { + memset(data, -1, sizeof(data)); + + data[i] = 121; + ret = NarrowCmpxchgTester::narrow_cmpxchg((intptr_t)&data[i], 121, 42, /* result */ 67, false); + ASSERT_EQ(ret, 121); + ASSERT_EQ(data[i], 42); + + data[i] = 121; + ret = NarrowCmpxchgTester::narrow_cmpxchg((intptr_t)&data[i], 120, 42, /* result */ 67, false); + ASSERT_EQ(ret, 121); + ASSERT_EQ(data[i], 121); + + data[i] = 121; + ret = NarrowCmpxchgTester::narrow_cmpxchg((intptr_t)&data[i], 121, 42, /* result */ 67, true); + ASSERT_EQ(ret, 1); + ASSERT_EQ(data[i], 42); + + data[i] = 121; + ret = NarrowCmpxchgTester::narrow_cmpxchg((intptr_t)&data[i], 120, 42, /* result */ 67, true); + ASSERT_EQ(ret, 0); + ASSERT_EQ(data[i], 121); + } +} + +TEST_VM(RiscV, cmpxchg_int16_lr_sc) { + bool zacas = UseZacas; + UseZacas = false; + run_narrow_cmpxchg_tests(); + UseZacas = zacas; +} + +TEST_VM(RiscV, cmpxchg_int8_lr_sc) { + bool zacas = UseZacas; + UseZacas = false; + run_narrow_cmpxchg_tests(); + UseZacas = zacas; +} + +TEST_VM(RiscV, cmpxchg_int16_maybe_zacas) { + if (UseZacas) { + run_narrow_cmpxchg_tests(); + } +} + +TEST_VM(RiscV, cmpxchg_int8_maybe_zacas) { + if (UseZacas) { + run_narrow_cmpxchg_tests(); + } +} + #endif // RISCV From 943aa033ae3b40a65cdf157797f0a9685019dc48 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Wed, 4 Dec 2024 08:06:58 +0000 Subject: [PATCH 58/62] 8345404: [ppc64le] ProblemList TestAllocOutOfMemory.java#large Reviewed-by: mdoerr --- test/hotspot/jtreg/ProblemList.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index e09004aa58b0e..08678af706d67 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -95,7 +95,7 @@ gc/TestAlwaysPreTouchBehavior.java#G1 8334513 generic-all gc/TestAlwaysPreTouchBehavior.java#Z 8334513 generic-all gc/TestAlwaysPreTouchBehavior.java#Epsilon 8334513 generic-all gc/stress/gclocker/TestExcessGCLockerCollections.java 8229120 generic-all -gc/shenandoah/oom/TestAllocOutOfMemory.java 8344312 linux-ppc64le +gc/shenandoah/oom/TestAllocOutOfMemory.java#large 8344312 linux-ppc64le ############################################################################# From cf1eb58d6723ca3856687bf52167455eece2a260 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Wed, 4 Dec 2024 08:11:33 +0000 Subject: [PATCH 59/62] 8344935: [ubsan]: javaThread.hpp:1241:52: runtime error: load of value 9831830, which is not a valid value for type 'freeze_result' Co-authored-by: Richard Reingruber Reviewed-by: rrich, pchilanomate --- src/hotspot/share/runtime/continuationFreezeThaw.cpp | 7 ++++++- src/hotspot/share/runtime/javaThread.cpp | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/runtime/continuationFreezeThaw.cpp b/src/hotspot/share/runtime/continuationFreezeThaw.cpp index 18beb10f0b421..a6c8e64e55e73 100644 --- a/src/hotspot/share/runtime/continuationFreezeThaw.cpp +++ b/src/hotspot/share/runtime/continuationFreezeThaw.cpp @@ -256,7 +256,9 @@ class Config { using OopT = std::conditional_t; static freeze_result freeze(JavaThread* thread, intptr_t* const sp) { - return freeze_internal(thread, sp); + freeze_result res = freeze_internal(thread, sp); + JFR_ONLY(assert((res == freeze_ok) || (res == thread->last_freeze_fail_result()), "freeze failure not set")); + return res; } static freeze_result freeze_preempt(JavaThread* thread, intptr_t* const sp) { @@ -1722,6 +1724,9 @@ static inline freeze_result freeze_internal(JavaThread* current, intptr_t* const log_develop_debug(continuations)("PINNED due to critical section/hold monitor"); verify_continuation(cont.continuation()); freeze_result res = entry->is_pinned() ? freeze_pinned_cs : freeze_pinned_monitor; + if (!preempt) { + JFR_ONLY(current->set_last_freeze_fail_result(res);) + } log_develop_trace(continuations)("=== end of freeze (fail %d)", res); // Avoid Thread.yield() loops without safepoint polls. if (SafepointMechanism::should_process(current) && !preempt) { diff --git a/src/hotspot/share/runtime/javaThread.cpp b/src/hotspot/share/runtime/javaThread.cpp index fd9f75c41b424..5123ab69ff320 100644 --- a/src/hotspot/share/runtime/javaThread.cpp +++ b/src/hotspot/share/runtime/javaThread.cpp @@ -518,6 +518,10 @@ JavaThread::JavaThread(MemTag mem_tag) : _SleepEvent(ParkEvent::Allocate(this)), +#if INCLUDE_JFR + _last_freeze_fail_result(freeze_ok), +#endif + _lock_stack(this), _om_cache(this) { set_jni_functions(jni_functions()); @@ -2361,4 +2365,4 @@ void JavaThread::post_vthread_pinned_event(EventVirtualThreadPinned* event, cons event->commit(); } } -#endif \ No newline at end of file +#endif From 38927fc5900184d6231f3da08dca9fc30711816c Mon Sep 17 00:00:00 2001 From: Tom Rodriguez Date: Wed, 4 Dec 2024 08:31:55 +0000 Subject: [PATCH 60/62] 8343213: TEST_BUG: [Graal] java/lang/ref/Basic.java fails Reviewed-by: mchung --- test/jdk/java/lang/ref/Basic.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jdk/java/lang/ref/Basic.java b/test/jdk/java/lang/ref/Basic.java index deb9ec3482659..abed7fdcd6467 100644 --- a/test/jdk/java/lang/ref/Basic.java +++ b/test/jdk/java/lang/ref/Basic.java @@ -46,8 +46,8 @@ protected void finalize() { }; protected void finalize() { - Basic.finalized = true; System.err.println("Finalized " + this); + Basic.finalized = true; } public static class Sub { }; From 3d49665b85619038c082566b0bc38c0ebe5f752e Mon Sep 17 00:00:00 2001 From: Jaikiran Pai Date: Wed, 4 Dec 2024 09:23:57 +0000 Subject: [PATCH 61/62] 8345286: Remove use of SecurityManager API from misc areas Reviewed-by: alanb, kevinw, sgehwolf --- .../platform/CgroupSubsystemController.java | 19 ++-- .../platform/CgroupSubsystemFactory.java | 12 +-- .../jdk/internal/platform/CgroupUtil.java | 92 ------------------- .../platform/cgroupv2/CgroupV2Subsystem.java | 13 +-- .../share/classes/java/io/FilePermission.java | 1 - .../share/classes/java/lang/String.java | 2 - .../share/classes/java/lang/System.java | 2 - .../java/lang/invoke/ClassSpecializer.java | 1 - .../java/lang/reflect/ProxyGenerator.java | 1 - .../share/classes/java/net/URLConnection.java | 1 - .../javax/crypto/JceSecurity.java.template | 1 - .../jdk/internal/loader/NativeLibraries.java | 11 +-- .../jdk/internal/logger/LazyLoggers.java | 2 - .../jdk/internal/misc/InnocuousThread.java | 3 +- .../share/classes/jdk/internal/perf/Perf.java | 64 +------------ .../jdk/internal/perf/PerfCounter.java | 7 +- .../classes/jdk/internal/ref/Cleaner.java | 18 ++-- .../internal/reflect/ReflectionFactory.java | 17 ---- .../sun/net/www/http/KeepAliveStream.java | 1 - .../sun/management/VMManagementImpl.java | 16 +--- .../incubator/vector/VectorIntrinsics.java | 9 +- .../protocol/local/PerfDataBuffer.java | 11 +-- 22 files changed, 43 insertions(+), 261 deletions(-) delete mode 100644 src/java.base/linux/classes/jdk/internal/platform/CgroupUtil.java diff --git a/src/java.base/linux/classes/jdk/internal/platform/CgroupSubsystemController.java b/src/java.base/linux/classes/jdk/internal/platform/CgroupSubsystemController.java index 38be8628fb48e..17bc60ef86354 100644 --- a/src/java.base/linux/classes/jdk/internal/platform/CgroupSubsystemController.java +++ b/src/java.base/linux/classes/jdk/internal/platform/CgroupSubsystemController.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, 2022, Red Hat Inc. + * Copyright (c) 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 @@ -28,8 +29,8 @@ import java.io.IOException; import java.io.UncheckedIOException; import java.math.BigInteger; +import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; import java.util.Optional; @@ -61,13 +62,13 @@ public interface CgroupSubsystemController { public static String getStringValue(CgroupSubsystemController controller, String param) { if (controller == null) return null; - try { - return CgroupUtil.readStringValue(controller, param); - } - catch (IOException e) { + Path filePath = Path.of(controller.path(), param); + try (Stream lines = Files.lines(filePath)) { + Optional firstLine = lines.findFirst(); + return firstLine.orElse(null); + } catch (UncheckedIOException | IOException e) { return null; } - } /** @@ -92,8 +93,8 @@ public static long getLongValueMatchingLine(CgroupSubsystemController controller return retval; } try { - Path filePath = Paths.get(controller.path(), param); - List lines = CgroupUtil.readAllLinesPrivileged(filePath); + Path filePath = Path.of(controller.path(), param); + List lines = Files.readAllLines(filePath); for (String line : lines) { if (line.startsWith(match)) { retval = conversion.apply(line); @@ -161,7 +162,7 @@ public static double getDoubleValue(CgroupSubsystemController controller, String public static long getLongEntry(CgroupSubsystemController controller, String param, String entryname, long defaultRetval) { if (controller == null) return defaultRetval; - try (Stream lines = CgroupUtil.readFilePrivileged(Paths.get(controller.path(), param))) { + try (Stream lines = Files.lines(Path.of(controller.path(), param))) { Optional result = lines.map(line -> line.split(" ")) .filter(line -> (line.length == 2 && diff --git a/src/java.base/linux/classes/jdk/internal/platform/CgroupSubsystemFactory.java b/src/java.base/linux/classes/jdk/internal/platform/CgroupSubsystemFactory.java index 0a6d9958d11e0..d963c46f0798c 100644 --- a/src/java.base/linux/classes/jdk/internal/platform/CgroupSubsystemFactory.java +++ b/src/java.base/linux/classes/jdk/internal/platform/CgroupSubsystemFactory.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, 2022, Red Hat Inc. + * Copyright (c) 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 @@ -29,8 +30,8 @@ import java.io.UncheckedIOException; import java.lang.System.Logger; import java.lang.System.Logger.Level; +import java.nio.file.Files; import java.nio.file.Path; -import java.nio.file.Paths; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -140,7 +141,7 @@ public static Optional determineType(String mountInfo, String cgroups, String selfCgroup) throws IOException { final Map infos = new HashMap<>(); - List lines = CgroupUtil.readAllLinesPrivileged(Paths.get(cgroups)); + List lines = Files.readAllLines(Path.of(cgroups)); for (String line : lines) { if (line.startsWith("#")) { continue; @@ -180,7 +181,7 @@ public static Optional determineType(String mountInfo, // However, continuing in that case does not make sense as we'd need // information from mountinfo for the mounted controller paths which we wouldn't // find anyway in that case. - lines = CgroupUtil.readAllLinesPrivileged(Paths.get(mountInfo)); + lines = Files.readAllLines(Path.of(mountInfo)); boolean anyCgroupMounted = false; for (String line: lines) { boolean cgroupsControllerFound = amendCgroupInfos(line, infos, isCgroupsV2); @@ -196,8 +197,7 @@ public static Optional determineType(String mountInfo, // See: // setCgroupV1Path() for the action run for cgroups v1 systems // setCgroupV2Path() for the action run for cgroups v2 systems - try (Stream selfCgroupLines = - CgroupUtil.readFilePrivileged(Paths.get(selfCgroup))) { + try (Stream selfCgroupLines = Files.lines(Path.of(selfCgroup))) { Consumer action = (tokens -> setCgroupV1Path(infos, tokens)); if (isCgroupsV2) { action = (tokens -> setCgroupV2Path(infos, tokens)); @@ -311,7 +311,7 @@ private static boolean amendCgroupInfos(String mntInfoLine, String mountPath = lineMatcher.group(2); String fsType = lineMatcher.group(3); if (fsType.equals("cgroup")) { - Path p = Paths.get(mountPath); + Path p = Path.of(mountPath); String[] controllerNames = p.getFileName().toString().split(","); for (String controllerName: controllerNames) { switch (controllerName) { diff --git a/src/java.base/linux/classes/jdk/internal/platform/CgroupUtil.java b/src/java.base/linux/classes/jdk/internal/platform/CgroupUtil.java deleted file mode 100644 index dbe8a85b2b2f5..0000000000000 --- a/src/java.base/linux/classes/jdk/internal/platform/CgroupUtil.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2020, Red Hat Inc. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package jdk.internal.platform; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.security.AccessController; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; -import java.util.List; -import java.util.stream.Stream; - -public final class CgroupUtil { - - @SuppressWarnings("removal") - public static Stream readFilePrivileged(Path path) throws IOException { - try { - PrivilegedExceptionAction> pea = () -> Files.lines(path); - return AccessController.doPrivileged(pea); - } catch (PrivilegedActionException e) { - unwrapIOExceptionAndRethrow(e); - throw new InternalError(e.getCause()); - } catch (UncheckedIOException e) { - throw e.getCause(); - } - } - - static void unwrapIOExceptionAndRethrow(PrivilegedActionException pae) throws IOException { - Throwable x = pae.getCause(); - if (x instanceof IOException) - throw (IOException) x; - if (x instanceof RuntimeException) - throw (RuntimeException) x; - if (x instanceof Error) - throw (Error) x; - } - - static String readStringValue(CgroupSubsystemController controller, String param) throws IOException { - PrivilegedExceptionAction pea = () -> - Files.newBufferedReader(Paths.get(controller.path(), param)); - try (@SuppressWarnings("removal") BufferedReader bufferedReader = - AccessController.doPrivileged(pea)) { - String line = bufferedReader.readLine(); - return line; - } catch (PrivilegedActionException e) { - unwrapIOExceptionAndRethrow(e); - throw new InternalError(e.getCause()); - } catch (UncheckedIOException e) { - throw e.getCause(); - } - } - - @SuppressWarnings("removal") - public static List readAllLinesPrivileged(Path path) throws IOException { - try { - PrivilegedExceptionAction> pea = () -> Files.readAllLines(path); - return AccessController.doPrivileged(pea); - } catch (PrivilegedActionException e) { - unwrapIOExceptionAndRethrow(e); - throw new InternalError(e.getCause()); - } catch (UncheckedIOException e) { - throw e.getCause(); - } - } -} diff --git a/src/java.base/linux/classes/jdk/internal/platform/cgroupv2/CgroupV2Subsystem.java b/src/java.base/linux/classes/jdk/internal/platform/cgroupv2/CgroupV2Subsystem.java index ddb4d8e271832..aa618766b38a1 100644 --- a/src/java.base/linux/classes/jdk/internal/platform/cgroupv2/CgroupV2Subsystem.java +++ b/src/java.base/linux/classes/jdk/internal/platform/cgroupv2/CgroupV2Subsystem.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2020, 2022, Red Hat Inc. + * Copyright (c) 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 @@ -27,15 +28,16 @@ import java.io.IOException; import java.io.UncheckedIOException; -import java.nio.file.Paths; +import java.nio.file.Files; +import java.nio.file.Path; import java.util.concurrent.TimeUnit; import java.util.function.Function; import java.util.stream.Collectors; +import java.util.stream.Stream; import jdk.internal.platform.CgroupInfo; import jdk.internal.platform.CgroupSubsystem; import jdk.internal.platform.CgroupSubsystemController; -import jdk.internal.platform.CgroupUtil; public class CgroupV2Subsystem implements CgroupSubsystem { @@ -328,10 +330,9 @@ public long getBlkIOServiced() { } private long sumTokensIOStat(Function mapFunc) { - try { - return CgroupUtil.readFilePrivileged(Paths.get(unified.path(), "io.stat")) - .map(mapFunc) - .collect(Collectors.summingLong(e -> e)); + try (Stream lines = Files.lines(Path.of(unified.path(), "io.stat"))) { + return lines.map(mapFunc) + .collect(Collectors.summingLong(e -> e)); } catch (UncheckedIOException | IOException e) { return CgroupSubsystem.LONG_RETVAL_UNLIMITED; } diff --git a/src/java.base/share/classes/java/io/FilePermission.java b/src/java.base/share/classes/java/io/FilePermission.java index 30fa3978638c1..1330766b07852 100644 --- a/src/java.base/share/classes/java/io/FilePermission.java +++ b/src/java.base/share/classes/java/io/FilePermission.java @@ -283,7 +283,6 @@ public FilePermission newPermUsingAltPath(FilePermission input) { * @param mask the actions mask to use. * */ - @SuppressWarnings("removal") private void init(int mask) { if ((mask & ALL) != mask) throw new IllegalArgumentException("invalid actions mask"); diff --git a/src/java.base/share/classes/java/lang/String.java b/src/java.base/share/classes/java/lang/String.java index e497e8faa6cc2..033d32611b0f3 100644 --- a/src/java.base/share/classes/java/lang/String.java +++ b/src/java.base/share/classes/java/lang/String.java @@ -549,7 +549,6 @@ public String(byte[] bytes, int offset, int length, Charset charset) { * Important: parameter order of this method is deliberately changed in order to * disambiguate it against other similar methods of this class. */ - @SuppressWarnings("removal") private String(Charset charset, byte[] bytes, int offset, int length) { if (length == 0) { this.value = "".value; @@ -787,7 +786,6 @@ static String newStringNoRepl(byte[] src, Charset cs) throws CharacterCodingExce } } - @SuppressWarnings("removal") private static String newStringNoRepl1(byte[] src, Charset cs) { int len = src.length; if (len == 0) { diff --git a/src/java.base/share/classes/java/lang/System.java b/src/java.base/share/classes/java/lang/System.java index 11c77d48bf01c..87aca3e1ffdba 100644 --- a/src/java.base/share/classes/java/lang/System.java +++ b/src/java.base/share/classes/java/lang/System.java @@ -1379,7 +1379,6 @@ public static LoggerFinder getLoggerFinder() { private static volatile LoggerFinder service; - @SuppressWarnings("removal") static LoggerFinder accessProvider() { // We do not need to synchronize: LoggerFinderLoader will // always return the same instance, so if we don't have it, @@ -1483,7 +1482,6 @@ public static Logger getLogger(String name) { * * @since 9 */ - @SuppressWarnings("removal") @CallerSensitive public static Logger getLogger(String name, ResourceBundle bundle) { final ResourceBundle rb = Objects.requireNonNull(bundle); diff --git a/src/java.base/share/classes/java/lang/invoke/ClassSpecializer.java b/src/java.base/share/classes/java/lang/invoke/ClassSpecializer.java index 8f934d6d67c95..e03504a749b06 100644 --- a/src/java.base/share/classes/java/lang/invoke/ClassSpecializer.java +++ b/src/java.base/share/classes/java/lang/invoke/ClassSpecializer.java @@ -578,7 +578,6 @@ S loadSpecies(S speciesData) { * @param speciesData what species we are generating * @return the generated concrete TopClass class */ - @SuppressWarnings("removal") Class generateConcreteSpeciesCode(String className, ClassSpecializer.SpeciesData speciesData) { byte[] classFile = generateConcreteSpeciesCodeFile(className, speciesData); var lookup = new MethodHandles.Lookup(topClass); diff --git a/src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java b/src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java index 96e0a7e729f0c..3b34453bc3fef 100644 --- a/src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java +++ b/src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java @@ -103,7 +103,6 @@ final class ProxyGenerator { /** * debugging flag for saving generated class files */ - @SuppressWarnings("removal") private static final boolean SAVE_GENERATED_FILES = Boolean.getBoolean("jdk.proxy.ProxyGenerator.saveGeneratedFiles"); diff --git a/src/java.base/share/classes/java/net/URLConnection.java b/src/java.base/share/classes/java/net/URLConnection.java index 209b84de200f4..69f719425615a 100644 --- a/src/java.base/share/classes/java/net/URLConnection.java +++ b/src/java.base/share/classes/java/net/URLConnection.java @@ -1388,7 +1388,6 @@ private ContentHandler lookupContentHandlerClassFor(String contentType) { return UnknownContentHandler.INSTANCE; } - @SuppressWarnings("removal") private ContentHandler lookupContentHandlerViaProvider(String contentType) { ClassLoader cl = ClassLoader.getSystemClassLoader(); diff --git a/src/java.base/share/classes/javax/crypto/JceSecurity.java.template b/src/java.base/share/classes/javax/crypto/JceSecurity.java.template index 8b64b452b114e..01282394b57ad 100644 --- a/src/java.base/share/classes/javax/crypto/JceSecurity.java.template +++ b/src/java.base/share/classes/javax/crypto/JceSecurity.java.template @@ -290,7 +290,6 @@ final class JceSecurity { } } - // This is called from within an doPrivileged block. private static void setupJurisdictionPolicies() throws Exception { // Sanity check the crypto.policy Security property. Single diff --git a/src/java.base/share/classes/jdk/internal/loader/NativeLibraries.java b/src/java.base/share/classes/jdk/internal/loader/NativeLibraries.java index 02dc79f028884..44eaab0e83a6a 100644 --- a/src/java.base/share/classes/jdk/internal/loader/NativeLibraries.java +++ b/src/java.base/share/classes/jdk/internal/loader/NativeLibraries.java @@ -30,8 +30,6 @@ import java.io.File; import java.io.IOException; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.ArrayDeque; import java.util.Deque; import java.util.function.BiFunction; @@ -323,18 +321,13 @@ boolean open() { return load(this, name, isBuiltin, throwExceptionIfFail()); } - @SuppressWarnings("removal") private boolean throwExceptionIfFail() { if (loadLibraryOnlyIfPresent) return true; // If the file exists but fails to load, UnsatisfiedLinkException thrown by the VM // will include the error message from dlopen to provide diagnostic information - return AccessController.doPrivileged(new PrivilegedAction<>() { - public Boolean run() { - File file = new File(name); - return file.exists(); - } - }); + File file = new File(name); + return file.exists(); } /* diff --git a/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java b/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java index 885e2e8c4d7b4..628d768d9ceff 100644 --- a/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java +++ b/src/java.base/share/classes/jdk/internal/logger/LazyLoggers.java @@ -342,8 +342,6 @@ private static LoggerFinder accessLoggerFinder() { // no need to lock: it doesn't matter if we call // getLoggerFinder() twice - since LoggerFinder already caches // the result. - // This is just an optimization to avoid the cost of calling - // doPrivileged every time. prov = LoggerFinder.getLoggerFinder(); if (prov instanceof TemporaryLoggerFinder) return prov; provider = prov; diff --git a/src/java.base/share/classes/jdk/internal/misc/InnocuousThread.java b/src/java.base/share/classes/jdk/internal/misc/InnocuousThread.java index ca2fcf11e993f..4f7811faf343d 100644 --- a/src/java.base/share/classes/jdk/internal/misc/InnocuousThread.java +++ b/src/java.base/share/classes/jdk/internal/misc/InnocuousThread.java @@ -28,10 +28,9 @@ import java.util.concurrent.atomic.AtomicInteger; /** - * A thread that has no permissions, is not a member of any user-defined + * A thread that is not a member of any user-defined * ThreadGroup and supports the ability to erase ThreadLocals. */ -@SuppressWarnings("removal") public final class InnocuousThread extends Thread { private static final jdk.internal.misc.Unsafe UNSAFE; private static final long THREAD_LOCALS; diff --git a/src/java.base/share/classes/jdk/internal/perf/Perf.java b/src/java.base/share/classes/jdk/internal/perf/Perf.java index e764fe7927331..ada89dcf2e0cd 100644 --- a/src/java.base/share/classes/jdk/internal/perf/Perf.java +++ b/src/java.base/share/classes/jdk/internal/perf/Perf.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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,8 +25,6 @@ package jdk.internal.perf; import java.nio.ByteBuffer; -import java.security.Permission; -import java.security.PrivilegedAction; import java.io.IOException; import sun.nio.cs.UTF_8; @@ -49,7 +47,6 @@ * @author Brian Doherty * @since 1.4.2 * @see #getPerf - * @see jdk.internal.perf.Perf.GetPerfAction * @see java.nio.ByteBuffer */ public final class Perf { @@ -58,46 +55,6 @@ public final class Perf { private Perf() { } // prevent instantiation - /** - * The GetPerfAction class is a convenience class for acquiring access - * to the singleton Perf instance using the - * AccessController.doPrivileged() method. - *

      - * An instance of this class can be used as the argument to - * AccessController.doPrivileged(PrivilegedAction). - *

      Here is a suggested idiom for use of this class: - * - *

      {@code
      -     * class MyTrustedClass {
      -     *   private static final Perf perf =
      -     *       AccessController.doPrivileged(new Perf.GetPerfAction());
      -     *   ...
      -     * }
      -     * }
      - *

      - * In the presence of a security manager, the MyTrustedClass - * class in the above example will need to be granted the - * "sun.misc.Perf.getPerf" RuntimePermission - * permission in order to successfully acquire the singleton Perf instance. - *

      - * Please note that the "sun.misc.Perf.getPerf" permission - * is not a JDK specified permission. - * - * @see java.security.AccessController#doPrivileged(PrivilegedAction) - * @see java.lang.RuntimePermission - */ - public static class GetPerfAction implements PrivilegedAction - { - /** - * Run the Perf.getPerf() method in a privileged context. - * - * @see #getPerf - */ - public Perf run() { - return getPerf(); - } - } - /** * Return a reference to the singleton Perf instance. *

      @@ -106,11 +63,6 @@ public Perf run() { * for accessing the instrumentation buffer for this or another local * Java virtual machine. *

      - * If a security manager is installed, its checkPermission - * method is called with a RuntimePermission with a target - * of "sun.misc.Perf.getPerf". A security exception will result - * if the caller has not been granted this permission. - *

      * Access to the returned Perf object should be protected * by its caller and not passed on to untrusted code. This object can * be used to attach to the instrumentation buffer provided by this Java @@ -119,26 +71,12 @@ public Perf run() { * information. API's built on top of this interface may want to provide * finer grained access control to the contents of individual * instrumentation objects contained within the buffer. - *

      - * Please note that the "sun.misc.Perf.getPerf" permission - * is not a JDK specified permission. * * @return A reference to the singleton Perf instance. - * @throws SecurityException if a security manager exists and its - * checkPermission method doesn't allow access - * to the "jdk.internal.perf.Perf.getPerf"" target. - * @see java.lang.RuntimePermission * @see #attach */ public static Perf getPerf() { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - Permission perm = new RuntimePermission("jdk.internal.perf.Perf.getPerf"); - security.checkPermission(perm); - } - return instance; } diff --git a/src/java.base/share/classes/jdk/internal/perf/PerfCounter.java b/src/java.base/share/classes/jdk/internal/perf/PerfCounter.java index b0a87c207b1a9..dfe67ce849ccd 100644 --- a/src/java.base/share/classes/jdk/internal/perf/PerfCounter.java +++ b/src/java.base/share/classes/jdk/internal/perf/PerfCounter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -28,7 +28,6 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.LongBuffer; -import java.security.AccessController; /** * Performance counter support for internal JRE classes. @@ -48,9 +47,7 @@ * */ public class PerfCounter { - @SuppressWarnings("removal") - private static final Perf perf = - AccessController.doPrivileged(new Perf.GetPerfAction()); + private static final Perf perf = Perf.getPerf(); // Must match values defined in hotspot/src/share/vm/runtime/perfdata.hpp private static final int V_Constant = 1; diff --git a/src/java.base/share/classes/jdk/internal/ref/Cleaner.java b/src/java.base/share/classes/jdk/internal/ref/Cleaner.java index 3a02605577b2b..ecd1c32167ffa 100644 --- a/src/java.base/share/classes/jdk/internal/ref/Cleaner.java +++ b/src/java.base/share/classes/jdk/internal/ref/Cleaner.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -26,8 +26,6 @@ package jdk.internal.ref; import java.lang.ref.*; -import java.security.AccessController; -import java.security.PrivilegedAction; /** @@ -136,21 +134,17 @@ public static Cleaner create(Object ob, Runnable thunk) { /** * Runs this cleaner, if it has not been run before. */ - @SuppressWarnings("removal") public void clean() { if (!remove(this)) return; try { thunk.run(); } catch (final Throwable x) { - AccessController.doPrivileged(new PrivilegedAction<>() { - public Void run() { - if (System.err != null) - new Error("Cleaner terminated abnormally", x) - .printStackTrace(); - System.exit(1); - return null; - }}); + if (System.err != null) { + new Error("Cleaner terminated abnormally", x) + .printStackTrace(); + } + System.exit(1); } } } diff --git a/src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java b/src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java index 687e32cdf6165..20b390855c908 100644 --- a/src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java +++ b/src/java.base/share/classes/jdk/internal/reflect/ReflectionFactory.java @@ -41,7 +41,6 @@ import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.lang.reflect.Proxy; -import java.security.PrivilegedAction; import java.util.Set; import jdk.internal.access.JavaLangReflectAccess; @@ -75,22 +74,6 @@ private ReflectionFactory() { this.langReflectAccess = SharedSecrets.getJavaLangReflectAccess(); } - /** - * A convenience class for acquiring the capability to instantiate - * reflective objects. Use this instead of a raw call to {@link - * #getReflectionFactory} in order to avoid being limited by the - * permissions of your callers. - * - *

      An instance of this class can be used as the argument of - * AccessController.doPrivileged. - */ - public static final class GetReflectionFactoryAction - implements PrivilegedAction { - public ReflectionFactory run() { - return getReflectionFactory(); - } - } - /** * Provides the caller with the capability to instantiate reflective * objects. diff --git a/src/java.base/share/classes/sun/net/www/http/KeepAliveStream.java b/src/java.base/share/classes/sun/net/www/http/KeepAliveStream.java index 4ec81e42c3741..de7aa016ea3ab 100644 --- a/src/java.base/share/classes/sun/net/www/http/KeepAliveStream.java +++ b/src/java.base/share/classes/sun/net/www/http/KeepAliveStream.java @@ -154,7 +154,6 @@ public boolean hurry() { } } - @SuppressWarnings("removal") private static void queueForCleanup(KeepAliveCleanerEntry kace) { queue.lock(); try { diff --git a/src/java.management/share/classes/sun/management/VMManagementImpl.java b/src/java.management/share/classes/sun/management/VMManagementImpl.java index 4e2fc26c850f5..7e1e870acb4d2 100644 --- a/src/java.management/share/classes/sun/management/VMManagementImpl.java +++ b/src/java.management/share/classes/sun/management/VMManagementImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -35,8 +35,6 @@ import java.util.List; import java.util.Arrays; import java.util.Collections; -import java.security.AccessController; -import java.security.PrivilegedAction; /** * Implementation of VMManagement interface that accesses the management @@ -203,14 +201,7 @@ public synchronized List getVmArguments() { // Compilation Subsystem public String getCompilerName() { - @SuppressWarnings("removal") - String name = AccessController.doPrivileged( - new PrivilegedAction<>() { - public String run() { - return System.getProperty("sun.management.compiler"); - } - }); - return name; + return System.getProperty("sun.management.compiler"); } public native long getTotalCompileTime(); @@ -255,8 +246,7 @@ private synchronized PerfInstrumentation getPerfInstrumentation() { } // construct PerfInstrumentation object - @SuppressWarnings("removal") - Perf perf = AccessController.doPrivileged(new Perf.GetPerfAction()); + Perf perf = Perf.getPerf(); try { ByteBuffer bb = perf.attach(0); if (bb.capacity() == 0) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorIntrinsics.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorIntrinsics.java index c0e70ca58e683..266a843083a08 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorIntrinsics.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorIntrinsics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 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 @@ -26,14 +26,11 @@ import jdk.internal.vm.annotation.ForceInline; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.Objects; /*non-public*/ class VectorIntrinsics { - @SuppressWarnings("removal") - static final int VECTOR_ACCESS_OOB_CHECK = AccessController.doPrivileged((PrivilegedAction) () -> - Integer.getInteger("jdk.incubator.vector.VECTOR_ACCESS_OOB_CHECK", 2)); + static final int VECTOR_ACCESS_OOB_CHECK = + Integer.getInteger("jdk.incubator.vector.VECTOR_ACCESS_OOB_CHECK", 2); @ForceInline static void requireLength(int haveLength, int length) { diff --git a/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/PerfDataBuffer.java b/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/PerfDataBuffer.java index 056671d78413b..3c128c6b6b370 100644 --- a/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/PerfDataBuffer.java +++ b/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/protocol/local/PerfDataBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -28,12 +28,8 @@ import jdk.internal.perf.Perf; import sun.jvmstat.monitor.*; import sun.jvmstat.perfdata.monitor.*; -import java.util.*; import java.io.*; import java.nio.ByteBuffer; -import java.nio.channels.FileChannel; -import java.lang.reflect.Constructor; -import java.security.AccessController; /** * The concrete PerfDataBuffer implementation for the local: @@ -45,11 +41,8 @@ * @author Brian Doherty * @since 1.5 */ -// Suppreess unchecked conversion warning at line 34. -//@SuppressWarnings("unchecked") public class PerfDataBuffer extends AbstractPerfDataBuffer { - @SuppressWarnings("removal") - private static final Perf perf = AccessController.doPrivileged(new Perf.GetPerfAction()); + private static final Perf perf = Perf.getPerf(); /** * Create a PerfDataBuffer instance for accessing the specified From 994504c3e1440401a22ad3bdb30413f9db8a7780 Mon Sep 17 00:00:00 2001 From: Fredrik Bredberg Date: Wed, 4 Dec 2024 09:32:33 +0000 Subject: [PATCH 62/62] 8329351: Add runtime/Monitor/TestRecursiveLocking.java for recursive Java monitor stress testing Co-authored-by: Daniel D. Daugherty Reviewed-by: dcubed, coleenp, aboldtch --- test/hotspot/jtreg/TEST.groups | 3 + ...tressWrapper_TestRecursiveLocking_36M.java | 207 +++++++ .../runtime/Monitor/TestRecursiveLocking.java | 568 ++++++++++++++++++ 3 files changed, 778 insertions(+) create mode 100644 test/hotspot/jtreg/runtime/Monitor/StressWrapper_TestRecursiveLocking_36M.java create mode 100644 test/hotspot/jtreg/runtime/Monitor/TestRecursiveLocking.java diff --git a/test/hotspot/jtreg/TEST.groups b/test/hotspot/jtreg/TEST.groups index d68c015496c0a..4cb84e9f599ba 100644 --- a/test/hotspot/jtreg/TEST.groups +++ b/test/hotspot/jtreg/TEST.groups @@ -397,6 +397,8 @@ tier1_runtime = \ -runtime/Metaspace/FragmentMetaspace.java \ -runtime/Metaspace/FragmentMetaspaceSimple.java \ -runtime/MirrorFrame/Test8003720.java \ + -runtime/Monitor/StressWrapper_TestRecursiveLocking_36M.java \ + -runtime/Monitor/TestRecursiveLocking.java \ -runtime/modules/LoadUnloadModuleStress.java \ -runtime/modules/ModuleStress/ExportModuleStressTest.java \ -runtime/modules/ModuleStress/ModuleStressGC.java \ @@ -664,6 +666,7 @@ hotspot_tier2_runtime = \ -runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java \ -runtime/CompressedOops/UseCompressedOops.java \ -runtime/InvocationTests \ + -runtime/Monitor/StressWrapper_TestRecursiveLocking_36M.java \ -runtime/Thread/TestThreadDumpMonitorContention.java \ -:tier1_runtime \ -:hotspot_tier2_runtime_platform_agnostic \ diff --git a/test/hotspot/jtreg/runtime/Monitor/StressWrapper_TestRecursiveLocking_36M.java b/test/hotspot/jtreg/runtime/Monitor/StressWrapper_TestRecursiveLocking_36M.java new file mode 100644 index 0000000000000..34bf5da64d959 --- /dev/null +++ b/test/hotspot/jtreg/runtime/Monitor/StressWrapper_TestRecursiveLocking_36M.java @@ -0,0 +1,207 @@ +/* + * Copyright (c) 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 id=Xint_outer_inner + * @requires vm.flagless + * @summary Tests recursive locking in -Xint in outer then inner mode. + * @library /testlibrary /test/lib + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * + * @run main/othervm/timeout=240 -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -Xint + * -XX:LockingMode=0 + * -ms256m -mx256m + * TestRecursiveLocking 120 1 + * + * @run main/othervm/timeout=240 -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -Xint + * -XX:LockingMode=1 + * -ms256m -mx256m + * TestRecursiveLocking 120 1 + * + * @run main/othervm/timeout=240 -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -Xint + * -XX:LockingMode=2 + * -ms256m -mx256m + * TestRecursiveLocking 120 1 + */ + +/* + * @test id=Xint_alternate_AB + * @requires vm.flagless + * @summary Tests recursive locking in -Xint in alternate A and B mode. + * @library /testlibrary /test/lib + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * + * @run main/othervm/timeout=240 -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -Xint + * -XX:LockingMode=0 + * -ms256m -mx256m + * TestRecursiveLocking 120 2 + * + * @run main/othervm/timeout=240 -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -Xint + * -XX:LockingMode=1 + * -ms256m -mx256m + * TestRecursiveLocking 120 2 + * + * @run main/othervm/timeout=240 -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -Xint + * -XX:LockingMode=2 + * -ms256m -mx256m + * TestRecursiveLocking 120 2 + */ + +/* + * @test id=C1_outer_inner + * @requires vm.flagless + * @requires vm.compiler1.enabled + * @summary Tests recursive locking in C1 in outer then inner mode. + * @library /testlibrary /test/lib + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * + * @run main/othervm/timeout=240 -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:TieredStopAtLevel=1 + * -XX:LockingMode=0 + * -ms256m -mx256m + * TestRecursiveLocking 120 1 + * + * @run main/othervm/timeout=240 -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:TieredStopAtLevel=1 + * -XX:LockingMode=1 + * -ms256m -mx256m + * TestRecursiveLocking 120 1 + * + * @run main/othervm/timeout=240 -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:TieredStopAtLevel=1 + * -XX:LockingMode=2 + * -ms256m -mx256m + * TestRecursiveLocking 120 1 + */ + +/* + * @test id=C1_alternate_AB + * @requires vm.flagless + * @requires vm.compiler1.enabled + * @summary Tests recursive locking in C1 in alternate A and B mode. + * @library /testlibrary /test/lib + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * + * @run main/othervm/timeout=240 -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:TieredStopAtLevel=1 + * -XX:LockingMode=0 + * -ms256m -mx256m + * TestRecursiveLocking 120 2 + * + * @run main/othervm/timeout=240 -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:TieredStopAtLevel=1 + * -XX:LockingMode=1 + * -ms256m -mx256m + * TestRecursiveLocking 120 2 + * + * @run main/othervm/timeout=240 -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:TieredStopAtLevel=1 + * -XX:LockingMode=2 + * -ms256m -mx256m + * TestRecursiveLocking 120 2 + */ + +/* + * @test id=C2_outer_inner + * @requires vm.flagless + * @requires vm.compiler2.enabled + * @summary Tests recursive locking in C2 in outer then inner mode. + * @library /testlibrary /test/lib + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * + * @run main/othervm/timeout=240 -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:-EliminateNestedLocks + * -XX:LockingMode=0 + * -ms256m -mx256m + * TestRecursiveLocking 120 1 + * + * @run main/othervm/timeout=240 -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:-EliminateNestedLocks + * -XX:LockingMode=1 + * -ms256m -mx256m + * TestRecursiveLocking 120 1 + * + * @run main/othervm/timeout=240 -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:-EliminateNestedLocks + * -XX:LockingMode=2 + * -ms256m -mx256m + * TestRecursiveLocking 120 1 + */ + +/* + * @test id=C2_alternate_AB + * @requires vm.flagless + * @requires vm.compiler2.enabled + * @summary Tests recursive locking in C2 in alternate A and B mode. + * @library /testlibrary /test/lib + * @build jdk.test.whitebox.WhiteBox + * + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * @run main/othervm/timeout=240 -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:LockingMode=0 + * -XX:-EliminateNestedLocks + * -ms256m -mx256m + * TestRecursiveLocking 120 2 + * + * @run main/othervm/timeout=240 -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:LockingMode=1 + * -XX:-EliminateNestedLocks + * -ms256m -mx256m + * TestRecursiveLocking 120 2 + * + * @run main/othervm/timeout=240 -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:LockingMode=2 + * -XX:-EliminateNestedLocks + * -ms256m -mx256m + * TestRecursiveLocking 120 2 + */ diff --git a/test/hotspot/jtreg/runtime/Monitor/TestRecursiveLocking.java b/test/hotspot/jtreg/runtime/Monitor/TestRecursiveLocking.java new file mode 100644 index 0000000000000..f9193b6eeb592 --- /dev/null +++ b/test/hotspot/jtreg/runtime/Monitor/TestRecursiveLocking.java @@ -0,0 +1,568 @@ +/* + * Copyright (c) 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 id=Xint_outer_inner + * @requires vm.flagless + * @summary Tests recursive locking in -Xint in outer then inner mode. + * @library /testlibrary /test/lib + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * + * @run main/othervm -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -Xint + * -XX:LockingMode=0 + * -ms256m -mx256m + * TestRecursiveLocking 5 1 + * + * @run main/othervm -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -Xint + * -XX:LockingMode=1 + * -ms256m -mx256m + * TestRecursiveLocking 5 1 + * + * @run main/othervm -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -Xint + * -XX:LockingMode=2 + * -ms256m -mx256m + * TestRecursiveLocking 5 1 + */ + +/* + * @test id=Xint_alternate_AB + * @requires vm.flagless + * @summary Tests recursive locking in -Xint in alternate A and B mode. + * @library /testlibrary /test/lib + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * + * @run main/othervm -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -Xint + * -XX:LockingMode=0 + * -ms256m -mx256m + * TestRecursiveLocking 5 2 + * + * @run main/othervm -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -Xint + * -XX:LockingMode=1 + * -ms256m -mx256m + * TestRecursiveLocking 5 2 + * + * @run main/othervm -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -Xint + * -XX:LockingMode=2 + * -ms256m -mx256m + * TestRecursiveLocking 5 2 + */ + +/* + * @test id=C1_outer_inner + * @requires vm.flagless + * @requires vm.compiler1.enabled + * @summary Tests recursive locking in C1 in outer then inner mode. + * @library /testlibrary /test/lib + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * + * @run main/othervm -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:TieredStopAtLevel=1 + * -XX:LockingMode=0 + * -ms256m -mx256m + * TestRecursiveLocking 5 1 + * + * @run main/othervm -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:TieredStopAtLevel=1 + * -XX:LockingMode=1 + * -ms256m -mx256m + * TestRecursiveLocking 5 1 + * + * @run main/othervm -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:TieredStopAtLevel=1 + * -XX:LockingMode=2 + * -ms256m -mx256m + * TestRecursiveLocking 5 1 + */ + +/* + * @test id=C1_alternate_AB + * @requires vm.flagless + * @requires vm.compiler1.enabled + * @summary Tests recursive locking in C1 in alternate A and B mode. + * @library /testlibrary /test/lib + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * + * @run main/othervm -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:TieredStopAtLevel=1 + * -XX:LockingMode=0 + * -ms256m -mx256m + * TestRecursiveLocking 5 2 + * + * @run main/othervm -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:TieredStopAtLevel=1 + * -XX:LockingMode=1 + * -ms256m -mx256m + * TestRecursiveLocking 5 2 + * + * @run main/othervm -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:TieredStopAtLevel=1 + * -XX:LockingMode=2 + * -ms256m -mx256m + * TestRecursiveLocking 5 2 + */ + +/* + * @test id=C2_outer_inner + * @requires vm.flagless + * @requires vm.compiler2.enabled + * @summary Tests recursive locking in C2 in outer then inner mode. + * @library /testlibrary /test/lib + * @build jdk.test.whitebox.WhiteBox + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * + * @run main/othervm -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:-EliminateNestedLocks + * -XX:LockingMode=0 + * -ms256m -mx256m + * TestRecursiveLocking 5 1 + * + * @run main/othervm -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:-EliminateNestedLocks + * -XX:LockingMode=1 + * -ms256m -mx256m + * TestRecursiveLocking 5 1 + * + * @run main/othervm -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:-EliminateNestedLocks + * -XX:LockingMode=2 + * -ms256m -mx256m + * TestRecursiveLocking 5 1 + */ + +/* + * @test id=C2_alternate_AB + * @requires vm.flagless + * @requires vm.compiler2.enabled + * @summary Tests recursive locking in C2 in alternate A and B mode. + * @library /testlibrary /test/lib + * @build jdk.test.whitebox.WhiteBox + * + * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox + * @run main/othervm -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:LockingMode=0 + * -XX:-EliminateNestedLocks + * -ms256m -mx256m + * TestRecursiveLocking 5 2 + * + * @run main/othervm -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:LockingMode=1 + * -XX:-EliminateNestedLocks + * -ms256m -mx256m + * TestRecursiveLocking 5 2 + * + * @run main/othervm -Xbootclasspath/a:. + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI + * -XX:LockingMode=2 + * -XX:-EliminateNestedLocks + * -ms256m -mx256m + * TestRecursiveLocking 5 2 + */ + +import jdk.test.lib.Asserts; +import jdk.test.whitebox.WhiteBox; +import jtreg.SkippedException; + +public class TestRecursiveLocking { + static final WhiteBox WB = WhiteBox.getWhiteBox(); + static final int flagLockingMode = WB.getIntVMFlag("LockingMode").intValue(); + static final int constLockStackCapacity = WB.getLockStackCapacity(); + static final int LM_MONITOR = 0; + static final int LM_LEGACY = 1; + static final int LM_LIGHTWEIGHT = 2; + static final int def_mode = 2; + static final int def_n_secs = 30; + static final SyncThread syncThread = new SyncThread(); + + // This SynchronizedObject class and the OUTER followed by INNER testing + // model is adapted from runtime/lockStack/TestLockStackCapacity.java. + static class SynchronizedObject { + private int counter; + + synchronized void runInner(int depth, SynchronizedObject outer) { + counter++; + + // Legacy mode has no lock stack, i.e., there is no limit + // on recursion, so for legacy mode we can't say that + // "outer" must be inflated here, which we can say for all + // the other locking modes. + if (flagLockingMode != LM_LEGACY) { + outer.assertInflated(); + } + + // We haven't reached the stack lock capacity (recursion + // level), so we shouldn't be inflated here. Except for + // monitor mode, which is always inflated. + if (flagLockingMode != LM_MONITOR) { + assertNotInflated(); + } + if (depth == 1) { + return; + } else { + runInner(depth - 1, outer); + } + if (flagLockingMode != LM_MONITOR) { + assertNotInflated(); + } + } + + synchronized void runOuter(int depth, SynchronizedObject inner) { + counter++; + + if (flagLockingMode != LM_MONITOR) { + assertNotInflated(); + } + if (depth == 1) { + inner.runInner(constLockStackCapacity, this); + } else { + runOuter(depth - 1, inner); + } + if (flagLockingMode != LM_LEGACY) { + assertInflated(); + } + } + + // This test nests x recursive locks of INNER, in x recursive + // locks of OUTER. The number x is taken from the max number + // of elements in the lock stack. + public void runOuterInnerTest() { + final SynchronizedObject OUTER = new SynchronizedObject(); + final SynchronizedObject INNER = new SynchronizedObject(); + + // Just checking since they are new objects: + OUTER.assertNotInflated(); + INNER.assertNotInflated(); + + synchronized (OUTER) { + OUTER.counter++; + + if (flagLockingMode != LM_MONITOR) { + OUTER.assertNotInflated(); + } + INNER.assertNotInflated(); + OUTER.runOuter(constLockStackCapacity - 1, INNER); + + if (flagLockingMode != LM_LEGACY) { + OUTER.assertInflated(); + } + if (flagLockingMode != LM_MONITOR) { + INNER.assertNotInflated(); + } + } + + // Verify that the nested monitors have been properly released: + syncThread.verifyCanBeSynced(OUTER); + syncThread.verifyCanBeSynced(INNER); + + Asserts.assertEquals(OUTER.counter, constLockStackCapacity); + Asserts.assertEquals(INNER.counter, constLockStackCapacity); + } + + synchronized void runA(int depth, SynchronizedObject B) { + counter++; + + if (flagLockingMode == LM_LIGHTWEIGHT) { + // First time we lock A, A is the only one on the lock + // stack. + if (counter == 1) { + assertNotInflated(); + } else { + // Second time we want to lock A, the lock stack + // looks like this [A, B]. Lightweight locking + // doesn't allow interleaving ([A, B, A]), instead + // it inflates A and removes it from the lock + // stack. Which leaves us with only [B] on the + // lock stack. After more recursions it will grow + // to [B, B ... B]. + assertInflated(); + } + } else if (flagLockingMode == LM_MONITOR) { + assertInflated(); + } + + // Call runB() at the same depth as runA's depth: + B.runB(depth, this); + } + + synchronized void runB(int depth, SynchronizedObject A) { + counter++; + + if (flagLockingMode != LM_MONITOR) { + // Legacy tolerates endless recursions. While testing + // lightweight we don't go deeper than the size of the + // lock stack, which in this test case will be filled + // with a number of B-elements. See comment in runA() + // above for more info. + assertNotInflated(); + } else { + assertInflated(); + } + + if (depth == 1) { + // Reached LockStackCapacity in depth so we're done. + return; + } else { + A.runA(depth - 1, this); + } + } + + // This test alternates by locking A and B. + public void runAlternateABTest() { + final SynchronizedObject A = new SynchronizedObject(); + final SynchronizedObject B = new SynchronizedObject(); + + // Just checking since they are new objects: + A.assertNotInflated(); + B.assertNotInflated(); + + A.runA(constLockStackCapacity, B); + + // Verify that the nested monitors have been properly released: + syncThread.verifyCanBeSynced(A); + syncThread.verifyCanBeSynced(B); + + Asserts.assertEquals(A.counter, constLockStackCapacity); + Asserts.assertEquals(B.counter, constLockStackCapacity); + if (flagLockingMode == LM_LEGACY) { + A.assertNotInflated(); + } + // Implied else: for LM_MONITOR or LM_LIGHTWEIGHT it can be + // either inflated or not because A is not locked anymore + // and subject to deflation. + + if (flagLockingMode != LM_MONITOR) { + B.assertNotInflated(); + } + } + + void assertNotInflated() { + Asserts.assertFalse(WB.isMonitorInflated(this)); + } + + void assertInflated() { + Asserts.assertTrue(WB.isMonitorInflated(this)); + } + } + + static void usage() { + System.err.println(); + System.err.println("Usage: java TestRecursiveLocking [n_secs]"); + System.err.println(" java TestRecursiveLocking n_secs [mode]"); + System.err.println(); + System.err.println("where:"); + System.err.println(" n_secs ::= > 0"); + System.err.println(" Default n_secs is " + def_n_secs + "."); + System.err.println(" mode ::= 1 - outer and inner"); + System.err.println(" ::= 2 - alternate A and B"); + System.err.println(" Default mode is " + def_mode + "."); + System.exit(1); + } + + public static void main(String... argv) throws Exception { + int mode = def_mode; + int n_secs = def_n_secs; + + if (argv.length != 0 && argv.length != 1 && argv.length != 2) { + usage(); + } else if (argv.length > 0) { + try { + n_secs = Integer.parseInt(argv[0]); + if (n_secs <= 0) { + throw new NumberFormatException("Not > 0: '" + argv[0] + + "'"); + } + } catch (NumberFormatException nfe) { + System.err.println(); + System.err.println(nfe); + System.err.println("ERROR: '" + argv[0] + + "': invalid n_secs value."); + usage(); + } + + if (argv.length > 1) { + try { + mode = Integer.parseInt(argv[1]); + if (mode != 1 && mode != 2) { + throw new NumberFormatException("Not 1 -> 2: '" + + argv[1] + "'"); + } + } catch (NumberFormatException nfe) { + System.err.println(); + System.err.println(nfe); + System.err.println("ERROR: '" + argv[1] + + "': invalid mode value."); + usage(); + } + } + } + + System.out.println("INFO: LockingMode=" + flagLockingMode); + System.out.println("INFO: LockStackCapacity=" + constLockStackCapacity); + System.out.println("INFO: n_secs=" + n_secs); + System.out.println("INFO: mode=" + mode); + + long loopCount = 0; + long endTime = System.currentTimeMillis() + n_secs * 1000; + + syncThread.waitForStart(); + + while (System.currentTimeMillis() < endTime) { + loopCount++; + SynchronizedObject syncObj = new SynchronizedObject(); + switch (mode) { + case 1: + syncObj.runOuterInnerTest(); + break; + + case 2: + syncObj.runAlternateABTest(); + break; + + default: + throw new RuntimeException("bad mode parameter: " + mode); + } + } + + syncThread.setDone(); + try { + syncThread.join(); + } catch (InterruptedException ie) { + // This should not happen. + ie.printStackTrace(); + } + + System.out.println("INFO: main executed " + loopCount + " loops in " + + n_secs + " seconds."); + } +} + +class SyncThread extends Thread { + static final boolean verbose = false; // set to true for debugging + private boolean done = false; + private boolean haveWork = false; + private Object obj; + private Object waiter = new Object(); + + public void run() { + if (verbose) System.out.println("SyncThread: running."); + synchronized (waiter) { + // Let main know that we are running: + if (verbose) System.out.println("SyncThread: notify main running."); + waiter.notify(); + + while (!done) { + if (verbose) System.out.println("SyncThread: waiting."); + try { + waiter.wait(); + } catch (InterruptedException ie) { + // This should not happen. + ie.printStackTrace(); + } + if (haveWork) { + if (verbose) System.out.println("SyncThread: working."); + synchronized (obj) { + } + if (verbose) System.out.println("SyncThread: worked."); + haveWork = false; + waiter.notify(); + if (verbose) System.out.println("SyncThread: notified."); + } + else if (verbose) { + System.out.println("SyncThread: notified without work."); + } + } + } + if (verbose) System.out.println("SyncThread: exiting."); + } + + public void setDone() { + synchronized (waiter) { + if (verbose) System.out.println("main: set done."); + done = true; + waiter.notify(); + } + } + + public void verifyCanBeSynced(Object obj) { + synchronized (waiter) { + if (verbose) System.out.println("main: queueing up work."); + this.obj = obj; + haveWork = true; + if (verbose) System.out.println("main: notifying SyncThread."); + waiter.notify(); + if (verbose) System.out.println("main: waiting for SyncThread."); + while (haveWork) { + try { + waiter.wait(); + } catch (InterruptedException ie) { + // This should not happen. + ie.printStackTrace(); + } + } + if (verbose) System.out.println("main: waited for SyncThread."); + } + } + + public void waitForStart() { + synchronized (waiter) { + this.start(); + + // Wait for SyncThread to actually get running: + if (verbose) System.out.println("main: wait for SyncThread start."); + try { + waiter.wait(); + } catch (InterruptedException ie) { + // This should not happen. + ie.printStackTrace(); + } + if (verbose) System.out.println("main: waited for SyncThread start."); + } + } +}