aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Man Cao <manc@google.com> 2021-06-28 15:34:22 -0700
committerGravatar Man Cao <manc@google.com> 2021-06-28 15:34:22 -0700
commit32d68b7b36bb5a9bfd02ebde693f8ab5d40757af (patch)
tree7e2f02971da5f9342fa0855cca89ba26c8f201c1
parente7890729ee284fd69bc86689868251d9a9f2f59e (diff)
parente9b2c058a4ed5de29b991360f78fc1c5263c9268 (diff)
downloadjdk-pr/4600.tar.gz
jdk-pr/4600.zip
Merge remote-tracking branch 'origin/master' into 8269417pr/4600
-rw-r--r--.github/workflows/submit.yml6
-rw-r--r--src/hotspot/cpu/x86/stubGenerator_x86_64.cpp6
-rw-r--r--src/hotspot/cpu/x86/x86.ad2
-rw-r--r--src/hotspot/share/asm/register.hpp51
-rw-r--r--src/hotspot/share/classfile/placeholders.cpp24
-rw-r--r--src/hotspot/share/classfile/placeholders.hpp18
-rw-r--r--src/hotspot/share/gc/shared/genCollectedHeap.cpp6
-rw-r--r--src/hotspot/share/gc/shared/referenceProcessor.cpp16
-rw-r--r--src/hotspot/share/gc/shared/referenceProcessor.hpp9
-rw-r--r--src/hotspot/share/gc/shared/referenceProcessorPhaseTimes.cpp2
-rw-r--r--src/hotspot/share/gc/shared/workerDataArray.hpp1
-rw-r--r--src/hotspot/share/gc/shared/workerDataArray.inline.hpp10
-rw-r--r--src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp16
-rw-r--r--src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdKlassQueue.cpp24
-rw-r--r--src/hotspot/share/jfr/utilities/jfrEpochQueue.inline.hpp2
-rw-r--r--src/hotspot/share/logging/logAsyncWriter.cpp1
-rw-r--r--src/hotspot/share/opto/library_call.cpp15
-rw-r--r--src/hotspot/share/runtime/handshake.cpp4
-rw-r--r--src/hotspot/share/runtime/thread.cpp16
-rw-r--r--src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java2
-rw-r--r--src/java.base/share/classes/java/io/ObjectInputFilter.java21
-rw-r--r--src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java5
-rw-r--r--src/java.base/share/classes/java/lang/invoke/MethodHandles.java22
-rw-r--r--src/java.base/share/classes/java/lang/reflect/Proxy.java7
-rw-r--r--src/java.base/share/classes/java/net/IDN.java19
-rw-r--r--src/java.base/share/classes/java/time/chrono/HijrahChronology.java10
-rw-r--r--src/java.base/share/classes/java/time/zone/ZoneRulesProvider.java41
-rw-r--r--src/java.base/share/classes/java/util/Currency.java6
-rw-r--r--src/java.base/share/classes/java/util/concurrent/atomic/Striped64.java13
-rw-r--r--src/java.base/share/classes/jdk/internal/misc/X-ScopedMemoryAccess.java.template125
-rw-r--r--src/java.base/share/classes/sun/net/www/MimeTable.java47
-rw-r--r--src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java7
-rw-r--r--src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java39
-rw-r--r--src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java28
-rw-r--r--src/java.base/share/classes/sun/security/util/LegacyAlgorithmConstraints.java2
-rw-r--r--src/java.base/share/classes/sun/util/calendar/ZoneInfoFile.java6
-rw-r--r--src/java.base/share/man/java.188
-rw-r--r--src/java.base/unix/native/libnio/fs/UnixCopyFile.c70
-rw-r--r--src/java.desktop/share/classes/java/awt/Taskbar.java6
-rw-r--r--src/java.management/share/classes/java/lang/management/ManagementFactory.java9
-rw-r--r--src/java.management/share/classes/javax/management/modelmbean/DescriptorSupport.java27
-rw-r--r--src/java.naming/share/classes/com/sun/jndi/ldap/LdapPoolManager.java33
-rw-r--r--src/java.prefs/macosx/classes/java/util/prefs/MacOSXPreferencesFile.java6
-rw-r--r--src/java.prefs/unix/classes/java/util/prefs/FileSystemPreferences.java21
-rw-r--r--src/java.prefs/windows/classes/java/util/prefs/WindowsPreferences.java6
-rw-r--r--src/java.rmi/share/classes/sun/rmi/transport/DGCClient.java16
-rw-r--r--src/java.rmi/share/classes/sun/rmi/transport/DGCImpl.java12
-rw-r--r--src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPTransport.java26
-rw-r--r--src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Utility.java3
-rw-r--r--src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java13
-rw-r--r--src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java16
-rw-r--r--src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java2
-rw-r--r--src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java96
-rw-r--r--src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java5
-rw-r--r--src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java37
-rw-r--r--src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java9
-rw-r--r--src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java35
-rw-r--r--src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java35
-rw-r--r--src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java35
-rw-r--r--src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java35
-rw-r--r--src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java35
-rw-r--r--src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java35
-rw-r--r--src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorIntrinsics.java36
-rw-r--r--src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template35
-rw-r--r--src/jdk.javadoc/share/classes/jdk/javadoc/doclet/Reporter.java10
-rw-r--r--src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacDmgBundler.java6
-rw-r--r--src/jdk.jpackage/share/classes/jdk/jpackage/internal/RetryExecutor.java13
-rw-r--r--src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpChannelImpl.java8
-rw-r--r--src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpNet.java10
-rw-r--r--test/hotspot/jtreg/ProblemList-Xcomp.txt2
-rw-r--r--test/hotspot/jtreg/ProblemList-zgc.txt2
-rw-r--r--test/hotspot/jtreg/ProblemList.txt3
-rw-r--r--test/hotspot/jtreg/TEST.groups23
-rw-r--r--test/hotspot/jtreg/compiler/arraycopy/TestCloneAccess.java4
-rw-r--r--test/hotspot/jtreg/compiler/arraycopy/TestCloneAccessStressGCM.java3
-rw-r--r--test/hotspot/jtreg/compiler/c2/TestJumpTable.java2
-rw-r--r--test/hotspot/jtreg/compiler/c2/TestReplaceEquivPhis.java3
-rw-r--r--test/hotspot/jtreg/compiler/c2/TestShiftRightAndAccumulate.java9
-rw-r--r--test/hotspot/jtreg/compiler/codegen/ClearArrayTest.java5
-rw-r--r--test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/aarch64/AArch64TestAssembler.java39
-rw-r--r--test/hotspot/jtreg/vmTestbase/nsk/share/jpda/SocketIOPipe.java2
-rw-r--r--test/jaxp/javax/xml/jaxp/unittest/bcel/UtilityTest.java71
-rw-r--r--test/jdk/ProblemList.txt2
-rw-r--r--test/jdk/java/lang/invoke/MethodHandlesProxiesTest.java24
-rw-r--r--test/jdk/java/lang/invoke/t8150782/TestAccessClass.java30
-rw-r--r--test/jdk/java/lang/invoke/t8150782/TestFindClass.java20
-rw-r--r--test/jdk/java/lang/invoke/t8150782/p/Foo.java30
-rw-r--r--test/jdk/java/lang/invoke/t8150782/q/Bar.java37
-rw-r--r--test/jdk/java/lang/reflect/Proxy/SealedInterfaceTest.java69
-rw-r--r--test/jdk/jdk/incubator/vector/AbstractVectorLoadStoreTest.java54
-rw-r--r--test/jdk/jdk/incubator/vector/AbstractVectorTest.java14
-rw-r--r--test/jdk/jdk/incubator/vector/Byte128VectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/Byte256VectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/Byte512VectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/Byte64VectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/ByteMaxVectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/Double128VectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/Double256VectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/Double512VectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/Double64VectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/DoubleMaxVectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/Float128VectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/Float256VectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/Float512VectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/Float64VectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/FloatMaxVectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/Int128VectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/Int256VectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/Int512VectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/Int64VectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/IntMaxVectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/LoadSvmlTest.java72
-rw-r--r--test/jdk/jdk/incubator/vector/Long128VectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/Long256VectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/Long512VectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/Long64VectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/LongMaxVectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/Short128VectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/Short256VectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/Short512VectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/Short64VectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/ShortMaxVectorLoadStoreTests.java5
-rw-r--r--test/jdk/jdk/incubator/vector/templates/X-LoadStoreTest.java.template5
-rw-r--r--test/langtools/tools/javac/lambda/considerExceptionTVarInStuckExprs/ConsiderExceptionTVarsInStuckExprs.java50
-rw-r--r--test/langtools/tools/javac/patterns/DisambiguateParenthesizedPattern.java14
-rw-r--r--test/langtools/tools/javac/patterns/Exhaustiveness.java266
-rw-r--r--test/langtools/tools/javac/patterns/Guards.java29
-rw-r--r--test/langtools/tools/javac/patterns/LambdaCannotCapturePatternVariables.java72
-rw-r--r--test/langtools/tools/javac/patterns/NestedPatternVariablesBytecode.java114
-rw-r--r--test/langtools/tools/javac/patterns/RawTypeBindingWarning.java16
-rw-r--r--test/langtools/tools/javac/patterns/RawTypeBindingWarning.out7
-rw-r--r--test/langtools/tools/javac/patterns/SourceLevelChecks.java157
-rw-r--r--test/micro/org/openjdk/bench/java/security/AlgorithmConstraintsPermits.java66
133 files changed, 2110 insertions, 814 deletions
diff --git a/.github/workflows/submit.yml b/.github/workflows/submit.yml
index 7cfaf37d336..25e90e9d45d 100644
--- a/.github/workflows/submit.yml
+++ b/.github/workflows/submit.yml
@@ -172,7 +172,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt-get update
- sudo apt-get install gcc-10=10.2.0-5ubuntu1~20.04 g++-10=10.2.0-5ubuntu1~20.04 libxrandr-dev libxtst-dev libcups2-dev libasound2-dev
+ sudo apt-get install gcc-10=10.3.0-1ubuntu1~20.04 g++-10=10.3.0-1ubuntu1~20.04 libxrandr-dev libxtst-dev libcups2-dev libasound2-dev
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10
- name: Configure
@@ -487,12 +487,12 @@ jobs:
- name: Install native host dependencies
run: |
- sudo apt-get install gcc-10=10.2.0-5ubuntu1~20.04 g++-10=10.2.0-5ubuntu1~20.04 libxrandr-dev libxtst-dev libcups2-dev libasound2-dev
+ sudo apt-get install gcc-10=10.3.0-1ubuntu1~20.04 g++-10=10.3.0-1ubuntu1~20.04 libxrandr-dev libxtst-dev libcups2-dev libasound2-dev
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10
if: matrix.debian-arch == ''
- name: Install cross-compilation host dependencies
- run: sudo apt-get install gcc-10-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-flavor}}=10.2.0-5ubuntu1~20.04cross1 g++-10-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-flavor}}=10.2.0-5ubuntu1~20.04cross1
+ run: sudo apt-get install gcc-10-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-flavor}}=10.3.0-1ubuntu1~20.04cross1 g++-10-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-flavor}}=10.3.0-1ubuntu1~20.04cross1
if: matrix.debian-arch != ''
- name: Cache sysroot
diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp b/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp
index 5037ef19b0a..9a42a94cba3 100644
--- a/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp
+++ b/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp
@@ -39,6 +39,7 @@
#include "oops/objArrayKlass.hpp"
#include "oops/oop.inline.hpp"
#include "prims/methodHandles.hpp"
+#include "runtime/arguments.hpp"
#include "runtime/frame.inline.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/sharedRuntime.hpp"
@@ -7657,7 +7658,10 @@ address generate_avx_ghash_processBlocks() {
// Get svml stub routine addresses
void *libsvml = NULL;
char ebuf[1024];
- libsvml = os::dll_load(JNI_LIB_PREFIX "svml" JNI_LIB_SUFFIX, ebuf, sizeof ebuf);
+ char dll_name[JVM_MAXPATHLEN];
+ if (os::dll_locate_lib(dll_name, sizeof(dll_name), Arguments::get_dll_dir(), "svml")) {
+ libsvml = os::dll_load(dll_name, ebuf, sizeof ebuf);
+ }
if (libsvml != NULL) {
// SVML method naming convention
// All the methods are named as __svml_op<T><N>_ha_<VV>
diff --git a/src/hotspot/cpu/x86/x86.ad b/src/hotspot/cpu/x86/x86.ad
index a9971e1c4a1..5313d892b22 100644
--- a/src/hotspot/cpu/x86/x86.ad
+++ b/src/hotspot/cpu/x86/x86.ad
@@ -8062,7 +8062,7 @@ instruct vpternlog(vec dst, vec src2, vec src3, immU8 func) %{
%}
instruct vpternlog_mem(vec dst, vec src2, memory src3, immU8 func) %{
- predicate(vector_length_in_bytes(n->in(1)) > 8);
+ predicate(vector_length_in_bytes(n->in(1)->in(1)) > 8);
match(Set dst (MacroLogicV (Binary dst src2) (Binary (LoadVector src3) func)));
effect(TEMP dst);
format %{ "vpternlogd $dst,$src2,$src3,$func\t! vector ternary logic" %}
diff --git a/src/hotspot/share/asm/register.hpp b/src/hotspot/share/asm/register.hpp
index 66f58d52953..dea7e9dd3d0 100644
--- a/src/hotspot/share/asm/register.hpp
+++ b/src/hotspot/share/asm/register.hpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -45,55 +45,16 @@ class AbstractRegisterImpl {
int value() const { return (int)(intx)this; }
};
-
-//
-// Macros for use in defining Register instances. We'd like to be
-// able to simply define const instances of the RegisterImpl* for each
-// of the registers needed on a system in a header file. However many
-// compilers don't handle this very well and end up producing a
-// private definition in every file which includes the header file.
-// Along with the static constructors necessary for initialization it
-// can consume a significant amount of space in the result library.
-//
-// The following macros allow us to declare the instance in a .hpp and
-// produce an enumeration value which has the same number. Then in a
-// .cpp the the register instance can be defined using the enumeration
-// value. This avoids the use of static constructors and multiple
-// definitions per .cpp. In addition #defines for the register can be
-// produced so that the constant registers can be inlined. These
-// macros should not be used inside other macros, because you may get
-// multiple evaluations of the macros which can give bad results.
-//
-// Here are some example uses and expansions. Note that the macro
-// invocation is terminated with a ;.
-//
-// CONSTANT_REGISTER_DECLARATION(Register, G0, 0);
-//
-// extern const Register G0 ;
-// enum { G0_RegisterEnumValue = 0 } ;
-//
-// REGISTER_DECLARATION(Register, Gmethod, G5);
-//
-// extern const Register Gmethod ;
-// enum { Gmethod_RegisterEnumValue = G5_RegisterEnumValue } ;
-//
-// REGISTER_DEFINITION(Register, G0);
-//
-// const Register G0 = ( ( Register ) G0_RegisterEnumValue ) ;
-//
-
#define AS_REGISTER(type,name) ((type)name##_##type##EnumValue)
-#define CONSTANT_REGISTER_DECLARATION(type, name, value) \
-extern const type name; \
+#define CONSTANT_REGISTER_DECLARATION(type, name, value) \
+const type name = ((type)value); \
enum { name##_##type##EnumValue = (value) }
-#define REGISTER_DECLARATION(type, name, value) \
-extern const type name; \
-enum { name##_##type##EnumValue = value##_##type##EnumValue }
+#define REGISTER_DECLARATION(type, name, value) \
+const type name = ((type)value)
-#define REGISTER_DEFINITION(type, name) \
-const type name = ((type)name##_##type##EnumValue)
+#define REGISTER_DEFINITION(type, name)
#include CPU_HEADER(register)
diff --git a/src/hotspot/share/classfile/placeholders.cpp b/src/hotspot/share/classfile/placeholders.cpp
index 88b8d0fcc20..c8c75fbbf2e 100644
--- a/src/hotspot/share/classfile/placeholders.cpp
+++ b/src/hotspot/share/classfile/placeholders.cpp
@@ -43,21 +43,21 @@
// result the first thread gets.
class SeenThread: public CHeapObj<mtInternal> {
private:
- Thread *_thread;
+ JavaThread* _thread;
SeenThread* _stnext;
SeenThread* _stprev;
public:
- SeenThread(Thread *thread) {
+ SeenThread(JavaThread* thread) {
_thread = thread;
_stnext = NULL;
_stprev = NULL;
}
- Thread* thread() const { return _thread;}
- void set_thread(Thread *thread) { _thread = thread; }
+ JavaThread* thread() const { return _thread;}
+ void set_thread(JavaThread* thread) { _thread = thread; }
- SeenThread* next() const { return _stnext;}
- void set_next(SeenThread *seen) { _stnext = seen; }
- void set_prev(SeenThread *seen) { _stprev = seen; }
+ SeenThread* next() const { return _stnext;}
+ void set_next(SeenThread* seen) { _stnext = seen; }
+ void set_prev(SeenThread* seen) { _stprev = seen; }
void print_action_queue(outputStream* st) {
SeenThread* seen = this;
@@ -107,7 +107,7 @@ void PlaceholderEntry::set_threadQ(SeenThread* seenthread, PlaceholderTable::cla
// bootstrap loader support: links in a thread before load_instance_class
// definers: use as queue of define requestors, including owner of
// define token. Appends for debugging of requestor order
-void PlaceholderEntry::add_seen_thread(Thread* thread, PlaceholderTable::classloadAction action) {
+void PlaceholderEntry::add_seen_thread(JavaThread* thread, PlaceholderTable::classloadAction action) {
assert_lock_strong(SystemDictionary_lock);
SeenThread* threadEntry = new SeenThread(thread);
SeenThread* seen = actionToQueue(action);
@@ -128,7 +128,7 @@ void PlaceholderEntry::add_seen_thread(Thread* thread, PlaceholderTable::classlo
return;
}
-bool PlaceholderEntry::check_seen_thread(Thread* thread, PlaceholderTable::classloadAction action) {
+bool PlaceholderEntry::check_seen_thread(JavaThread* thread, PlaceholderTable::classloadAction action) {
assert_lock_strong(SystemDictionary_lock);
SeenThread* threadQ = actionToQueue(action);
SeenThread* seen = threadQ;
@@ -146,7 +146,7 @@ bool PlaceholderEntry::check_seen_thread(Thread* thread, PlaceholderTable::class
// SystemDictionary_lock
// ignores if cleanup has already been done
// if found, deletes SeenThread
-bool PlaceholderEntry::remove_seen_thread(Thread* thread, PlaceholderTable::classloadAction action) {
+bool PlaceholderEntry::remove_seen_thread(JavaThread* thread, PlaceholderTable::classloadAction action) {
assert_lock_strong(SystemDictionary_lock);
SeenThread* threadQ = actionToQueue(action);
SeenThread* seen = threadQ;
@@ -288,7 +288,7 @@ PlaceholderEntry* PlaceholderTable::find_and_add(unsigned int hash,
ClassLoaderData* loader_data,
classloadAction action,
Symbol* supername,
- Thread* thread) {
+ JavaThread* thread) {
assert(action != LOAD_SUPER || supername != NULL, "must have a super class name");
PlaceholderEntry* probe = get_entry(hash, name, loader_data);
if (probe == NULL) {
@@ -321,7 +321,7 @@ PlaceholderEntry* PlaceholderTable::find_and_add(unsigned int hash,
void PlaceholderTable::find_and_remove(unsigned int hash,
Symbol* name, ClassLoaderData* loader_data,
classloadAction action,
- Thread* thread) {
+ JavaThread* thread) {
assert_locked_or_safepoint(SystemDictionary_lock);
PlaceholderEntry *probe = get_entry(hash, name, loader_data);
if (probe != NULL) {
diff --git a/src/hotspot/share/classfile/placeholders.hpp b/src/hotspot/share/classfile/placeholders.hpp
index d85ac9adfdc..f96a80133bb 100644
--- a/src/hotspot/share/classfile/placeholders.hpp
+++ b/src/hotspot/share/classfile/placeholders.hpp
@@ -85,7 +85,7 @@ public:
PlaceholderEntry* find_and_add(unsigned int hash,
Symbol* name, ClassLoaderData* loader_data,
classloadAction action, Symbol* supername,
- Thread* thread);
+ JavaThread* thread);
void remove_entry(unsigned int hash,
Symbol* name, ClassLoaderData* loader_data);
@@ -94,7 +94,7 @@ public:
// If all queues are empty and definer is null, remove the PlacheholderEntry completely
void find_and_remove(unsigned int hash,
Symbol* name, ClassLoaderData* loader_data,
- classloadAction action, Thread* thread);
+ classloadAction action, JavaThread* thread);
void print_on(outputStream* st) const;
void print() const;
@@ -116,7 +116,7 @@ class PlaceholderEntry : public HashtableEntry<Symbol*, mtClass> {
private:
ClassLoaderData* _loader_data; // initiating loader
Symbol* _supername;
- Thread* _definer; // owner of define token
+ JavaThread* _definer; // owner of define token
InstanceKlass* _instanceKlass; // InstanceKlass from successful define
SeenThread* _superThreadQ; // doubly-linked queue of Threads loading a superclass for this class
SeenThread* _loadInstanceThreadQ; // loadInstance thread
@@ -130,8 +130,8 @@ class PlaceholderEntry : public HashtableEntry<Symbol*, mtClass> {
SeenThread* actionToQueue(PlaceholderTable::classloadAction action);
void set_threadQ(SeenThread* seenthread, PlaceholderTable::classloadAction action);
- void add_seen_thread(Thread* thread, PlaceholderTable::classloadAction action);
- bool remove_seen_thread(Thread* thread, PlaceholderTable::classloadAction action);
+ void add_seen_thread(JavaThread* thread, PlaceholderTable::classloadAction action);
+ bool remove_seen_thread(JavaThread* thread, PlaceholderTable::classloadAction action);
public:
// Simple accessors, used only by SystemDictionary
@@ -146,8 +146,8 @@ class PlaceholderEntry : public HashtableEntry<Symbol*, mtClass> {
if (_supername != NULL) _supername->increment_refcount();
}
- Thread* definer() const {return _definer; }
- void set_definer(Thread* definer) { _definer = definer; }
+ JavaThread* definer() const {return _definer; }
+ void set_definer(JavaThread* definer) { _definer = definer; }
InstanceKlass* instance_klass() const {return _instanceKlass; }
void set_instance_klass(InstanceKlass* ik) { _instanceKlass = ik; }
@@ -158,7 +158,7 @@ class PlaceholderEntry : public HashtableEntry<Symbol*, mtClass> {
SeenThread* loadInstanceThreadQ() const { return _loadInstanceThreadQ; }
void set_loadInstanceThreadQ(SeenThread* SeenThread) { _loadInstanceThreadQ = SeenThread; }
- SeenThread* defineThreadQ() const { return _defineThreadQ; }
+ SeenThread* defineThreadQ() const { return _defineThreadQ; }
void set_defineThreadQ(SeenThread* SeenThread) { _defineThreadQ = SeenThread; }
PlaceholderEntry* next() const {
@@ -188,7 +188,7 @@ class PlaceholderEntry : public HashtableEntry<Symbol*, mtClass> {
}
// Used for ClassCircularityError checking
- bool check_seen_thread(Thread* thread, PlaceholderTable::classloadAction action);
+ bool check_seen_thread(JavaThread* thread, PlaceholderTable::classloadAction action);
// Print method doesn't append a cr
void print_entry(outputStream* st) const;
diff --git a/src/hotspot/share/gc/shared/genCollectedHeap.cpp b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
index 2cb5996d87d..6713a73a429 100644
--- a/src/hotspot/share/gc/shared/genCollectedHeap.cpp
+++ b/src/hotspot/share/gc/shared/genCollectedHeap.cpp
@@ -488,11 +488,7 @@ void GenCollectedHeap::collect_generation(Generation* gen, bool full, size_t siz
// collect() below will enable discovery as appropriate
}
gen->collect(full, clear_soft_refs, size, is_tlab);
- if (!rp->enqueuing_is_done()) {
- rp->disable_discovery();
- } else {
- rp->set_enqueuing_is_done(false);
- }
+ rp->disable_discovery();
rp->verify_no_references_recorded();
}
diff --git a/src/hotspot/share/gc/shared/referenceProcessor.cpp b/src/hotspot/share/gc/shared/referenceProcessor.cpp
index 99ef0cbff06..bfd1e83affa 100644
--- a/src/hotspot/share/gc/shared/referenceProcessor.cpp
+++ b/src/hotspot/share/gc/shared/referenceProcessor.cpp
@@ -100,7 +100,6 @@ ReferenceProcessor::ReferenceProcessor(BoolObjectClosure* is_subject_to_discover
BoolObjectClosure* is_alive_non_header) :
_is_subject_to_discovery(is_subject_to_discovery),
_discovering_refs(false),
- _enqueuing_is_done(false),
_next_id(0),
_is_alive_non_header(is_alive_non_header)
{
@@ -199,7 +198,6 @@ ReferenceProcessorStats ReferenceProcessor::process_discovered_references(RefPro
double start_time = os::elapsedTime();
- assert(!enqueuing_is_done(), "If here enqueuing should not be complete");
// Stop treating discovered references specially.
disable_discovery();
@@ -525,7 +523,7 @@ public:
OopClosure* keep_alive,
VoidClosure* complete_gc) override {
ResourceMark rm;
- RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::SoftRefSubPhase1, _phase_times, worker_id);
+ RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::SoftRefSubPhase1, _phase_times, tracker_id(worker_id));
size_t const removed = _ref_processor.process_soft_ref_reconsider_work(_ref_processor._discoveredSoftRefs[worker_id],
_policy,
is_alive,
@@ -563,17 +561,17 @@ public:
OopClosure* keep_alive,
VoidClosure* complete_gc) override {
ResourceMark rm;
- RefProcWorkerTimeTracker t(_phase_times->phase2_worker_time_sec(), worker_id);
+ RefProcWorkerTimeTracker t(_phase_times->phase2_worker_time_sec(), tracker_id(worker_id));
{
- RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::SoftRefSubPhase2, _phase_times, worker_id);
+ RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::SoftRefSubPhase2, _phase_times, tracker_id(worker_id));
run_phase2(worker_id, _ref_processor._discoveredSoftRefs, is_alive, keep_alive, true /* do_enqueue_and_clear */, REF_SOFT);
}
{
- RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::WeakRefSubPhase2, _phase_times, worker_id);
+ RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::WeakRefSubPhase2, _phase_times, tracker_id(worker_id));
run_phase2(worker_id, _ref_processor._discoveredWeakRefs, is_alive, keep_alive, true /* do_enqueue_and_clear */, REF_WEAK);
}
{
- RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::FinalRefSubPhase2, _phase_times, worker_id);
+ RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::FinalRefSubPhase2, _phase_times, tracker_id(worker_id));
run_phase2(worker_id, _ref_processor._discoveredFinalRefs, is_alive, keep_alive, false /* do_enqueue_and_clear */, REF_FINAL);
}
// Close the reachable set; needed for collectors which keep_alive_closure do
@@ -594,7 +592,7 @@ public:
OopClosure* keep_alive,
VoidClosure* complete_gc) override {
ResourceMark rm;
- RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::FinalRefSubPhase3, _phase_times, worker_id);
+ RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::FinalRefSubPhase3, _phase_times, tracker_id(worker_id));
_ref_processor.process_final_keep_alive_work(_ref_processor._discoveredFinalRefs[worker_id], keep_alive, complete_gc);
}
};
@@ -611,7 +609,7 @@ public:
OopClosure* keep_alive,
VoidClosure* complete_gc) override {
ResourceMark rm;
- RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::PhantomRefSubPhase4, _phase_times, worker_id);
+ RefProcSubPhasesWorkerTimeTracker tt(ReferenceProcessor::PhantomRefSubPhase4, _phase_times, tracker_id(worker_id));
size_t const removed = _ref_processor.process_phantom_refs_work(_ref_processor._discoveredPhantomRefs[worker_id],
is_alive,
keep_alive,
diff --git a/src/hotspot/share/gc/shared/referenceProcessor.hpp b/src/hotspot/share/gc/shared/referenceProcessor.hpp
index f36a7bdd6ab..bd021c0d87b 100644
--- a/src/hotspot/share/gc/shared/referenceProcessor.hpp
+++ b/src/hotspot/share/gc/shared/referenceProcessor.hpp
@@ -202,7 +202,6 @@ private:
// other collectors in configuration
bool _discovery_is_mt; // true if reference discovery is MT.
- bool _enqueuing_is_done; // true if all weak references enqueued
uint _next_id; // round-robin mod _num_queues counter in
// support of work distribution
@@ -405,10 +404,6 @@ public:
// Whether we are in a phase when _processing_ is MT.
bool processing_is_mt() const;
- // whether all enqueueing of weak references is complete
- bool enqueuing_is_done() { return _enqueuing_is_done; }
- void set_enqueuing_is_done(bool v) { _enqueuing_is_done = v; }
-
// iterate over oops
void weak_oops_do(OopClosure* f); // weak roots
@@ -573,6 +568,10 @@ protected:
ReferenceProcessor& _ref_processor;
ReferenceProcessorPhaseTimes* _phase_times;
+ // Used for tracking how much time a worker spends in a (sub)phase.
+ uint tracker_id(uint worker_id) const {
+ return _ref_processor.processing_is_mt() ? worker_id : 0;
+ }
public:
RefProcTask(ReferenceProcessor& ref_processor,
ReferenceProcessorPhaseTimes* phase_times)
diff --git a/src/hotspot/share/gc/shared/referenceProcessorPhaseTimes.cpp b/src/hotspot/share/gc/shared/referenceProcessorPhaseTimes.cpp
index f17c67ccd91..bb2b0a3d185 100644
--- a/src/hotspot/share/gc/shared/referenceProcessorPhaseTimes.cpp
+++ b/src/hotspot/share/gc/shared/referenceProcessorPhaseTimes.cpp
@@ -98,7 +98,7 @@ RefProcWorkerTimeTracker::RefProcWorkerTimeTracker(WorkerDataArray<double>* work
RefProcWorkerTimeTracker::~RefProcWorkerTimeTracker() {
double result = os::elapsedTime() - _start_time;
- _worker_time->set(_worker_id, result);
+ _worker_time->set_or_add(_worker_id, result);
}
RefProcSubPhasesWorkerTimeTracker::RefProcSubPhasesWorkerTimeTracker(ReferenceProcessor::RefProcSubPhases phase,
diff --git a/src/hotspot/share/gc/shared/workerDataArray.hpp b/src/hotspot/share/gc/shared/workerDataArray.hpp
index bd4e4407d76..8908afbc8f9 100644
--- a/src/hotspot/share/gc/shared/workerDataArray.hpp
+++ b/src/hotspot/share/gc/shared/workerDataArray.hpp
@@ -67,6 +67,7 @@ private:
static T uninitialized();
void set(uint worker_i, T value);
+ void set_or_add(uint worker_i, T value);
T get(uint worker_i) const;
void add(uint worker_i, T value);
diff --git a/src/hotspot/share/gc/shared/workerDataArray.inline.hpp b/src/hotspot/share/gc/shared/workerDataArray.inline.hpp
index 216b6dafb00..3deb734f20d 100644
--- a/src/hotspot/share/gc/shared/workerDataArray.inline.hpp
+++ b/src/hotspot/share/gc/shared/workerDataArray.inline.hpp
@@ -54,6 +54,16 @@ void WorkerDataArray<T>::set(uint worker_i, T value) {
}
template <typename T>
+void WorkerDataArray<T>::set_or_add(uint worker_i, T value) {
+ assert(worker_i < _length, "Worker %d is greater than max: %d", worker_i, _length);
+ if (_data[worker_i] == uninitialized()) {
+ _data[worker_i] = value;
+ } else {
+ _data[worker_i] += value;
+ }
+}
+
+template <typename T>
T WorkerDataArray<T>::get(uint worker_i) const {
assert(worker_i < _length, "Worker %d is greater than max: %d", worker_i, _length);
return _data[worker_i];
diff --git a/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp b/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp
index 86ed4ae2e8d..918bdbc27a1 100644
--- a/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp
+++ b/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp
@@ -194,11 +194,21 @@ int ZBarrierSetC2::estimate_stub_size() const {
static void set_barrier_data(C2Access& access) {
if (ZBarrierSet::barrier_needed(access.decorators(), access.type())) {
- if (access.decorators() & ON_WEAK_OOP_REF) {
- access.set_barrier_data(ZLoadBarrierWeak);
+ uint8_t barrier_data = 0;
+
+ if (access.decorators() & ON_PHANTOM_OOP_REF) {
+ barrier_data |= ZLoadBarrierPhantom;
+ } else if (access.decorators() & ON_WEAK_OOP_REF) {
+ barrier_data |= ZLoadBarrierWeak;
} else {
- access.set_barrier_data(ZLoadBarrierStrong);
+ barrier_data |= ZLoadBarrierStrong;
+ }
+
+ if (access.decorators() & AS_NO_KEEPALIVE) {
+ barrier_data |= ZLoadBarrierNoKeepalive;
}
+
+ access.set_barrier_data(barrier_data);
}
}
diff --git a/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdKlassQueue.cpp b/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdKlassQueue.cpp
index 9b198198617..7344e2aa6b4 100644
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdKlassQueue.cpp
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdKlassQueue.cpp
@@ -67,7 +67,7 @@ static const size_t ELEMENT_SIZE = sizeof(JfrEpochQueueKlassElement);
static const size_t NARROW_ELEMENT_SIZE = sizeof(JfrEpochQueueNarrowKlassElement);
static const size_t THRESHOLD_SHIFT = 30;
-// If the upshifted traceid value is less than this threshold (1 073 741 824),
+// If the traceid value is less than this threshold (1 073 741 824),
// compress the element for more effective queue storage.
static const traceid uncompressed_threshold = ((traceid)1) << THRESHOLD_SHIFT;
@@ -121,30 +121,36 @@ static traceid read_element(const u1* pos, const Klass** klass, bool compressed)
return compressed ? read_compressed_element(pos, klass) : read_uncompressed_element(pos, klass);
}
+template <typename T>
+static inline void store_traceid(T* element, traceid id, bool uncompressed) {
+#ifdef VM_LITTLE_ENDIAN
+ id <<= METADATA_SHIFT;
+#endif
+ element->id = uncompressed ? id | UNCOMPRESSED : id;
+}
+
static void store_compressed_element(traceid id, const Klass* klass, u1* pos) {
+ assert(can_compress_element(id), "invariant");
JfrEpochQueueNarrowKlassElement* const element = new (pos) JfrEpochQueueNarrowKlassElement();
- element->id = id;
+ store_traceid(element, id, false);
element->compressed_klass = encode(klass);
}
static void store_uncompressed_element(traceid id, const Klass* klass, u1* pos) {
JfrEpochQueueKlassElement* const element = new (pos) JfrEpochQueueKlassElement();
- element->id = id | UNCOMPRESSED;
+ store_traceid(element, id, true);
element->klass = klass;
}
static void store_element(const Klass* klass, u1* pos) {
assert(pos != NULL, "invariant");
assert(klass != NULL, "invariant");
- traceid id = JfrTraceId::load_raw(klass);
-#ifdef VM_LITTLE_ENDIAN
- id <<= METADATA_SHIFT;
-#endif
+ const traceid id = JfrTraceId::load_raw(klass);
if (can_compress_element(id)) {
store_compressed_element(id, klass, pos);
- } else {
- store_uncompressed_element(id, klass, pos);
+ return;
}
+ store_uncompressed_element(id, klass, pos);
}
static void set_unloaded(const u1* pos) {
diff --git a/src/hotspot/share/jfr/utilities/jfrEpochQueue.inline.hpp b/src/hotspot/share/jfr/utilities/jfrEpochQueue.inline.hpp
index 454934a83cd..fffeeafb8a5 100644
--- a/src/hotspot/share/jfr/utilities/jfrEpochQueue.inline.hpp
+++ b/src/hotspot/share/jfr/utilities/jfrEpochQueue.inline.hpp
@@ -68,7 +68,7 @@ JfrEpochQueue<ElementPolicy>::storage_for_element(JfrEpochQueue<ElementPolicy>::
template <template <typename> class ElementPolicy>
void JfrEpochQueue<ElementPolicy>::enqueue(JfrEpochQueue<ElementPolicy>::TypePtr t) {
assert(t != NULL, "invariant");
- static size_t element_size = _policy.element_size(t);
+ size_t element_size = _policy.element_size(t);
BufferPtr buffer = storage_for_element(t, element_size);
assert(buffer != NULL, "invariant");
_policy.store_element(t, buffer);
diff --git a/src/hotspot/share/logging/logAsyncWriter.cpp b/src/hotspot/share/logging/logAsyncWriter.cpp
index f46fc1c4ec8..10605af64a7 100644
--- a/src/hotspot/share/logging/logAsyncWriter.cpp
+++ b/src/hotspot/share/logging/logAsyncWriter.cpp
@@ -46,6 +46,7 @@ void AsyncLogWriter::enqueue_locked(const AsyncLogMessage& msg) {
uint32_t* counter = _stats.add_if_absent(msg.output(), 0, &p_created);
*counter = *counter + 1;
// drop the enqueueing message.
+ os::free(msg.message());
return;
}
diff --git a/src/hotspot/share/opto/library_call.cpp b/src/hotspot/share/opto/library_call.cpp
index 7cb80d1b5f7..701d1955716 100644
--- a/src/hotspot/share/opto/library_call.cpp
+++ b/src/hotspot/share/opto/library_call.cpp
@@ -1032,6 +1032,11 @@ bool LibraryCallKit::inline_preconditions_checkIndex(BasicType bt) {
Deoptimization::Action_make_not_entrant);
}
+ if (stopped()) {
+ // Length is known to be always negative during compilation and the IR graph so far constructed is good so return success
+ return true;
+ }
+
// length is now known postive, add a cast node to make this explicit
jlong upper_bound = _gvn.type(length)->is_integer(bt)->hi_as_long();
Node* casted_length = ConstraintCastNode::make(control(), length, TypeInteger::make(0, upper_bound, Type::WidenMax, bt), bt);
@@ -1039,10 +1044,6 @@ bool LibraryCallKit::inline_preconditions_checkIndex(BasicType bt) {
replace_in_map(length, casted_length);
length = casted_length;
- if (stopped()) {
- return false;
- }
-
// Use an unsigned comparison for the range check itself
Node* rc_cmp = _gvn.transform(CmpNode::make(index, length, bt, true));
BoolTest::mask btest = BoolTest::lt;
@@ -1061,7 +1062,8 @@ bool LibraryCallKit::inline_preconditions_checkIndex(BasicType bt) {
}
if (stopped()) {
- return false;
+ // Range check is known to always fail during compilation and the IR graph so far constructed is good so return success
+ return true;
}
// index is now known to be >= 0 and < length, cast it
@@ -5343,12 +5345,11 @@ bool LibraryCallKit::inline_vectorizedMismatch() {
if (do_partial_inline) {
assert(elem_bt != T_ILLEGAL, "sanity");
- const TypeVect* vt = TypeVect::make(elem_bt, inline_limit);
-
if (Matcher::match_rule_supported_vector(Op_VectorMaskGen, inline_limit, elem_bt) &&
Matcher::match_rule_supported_vector(Op_LoadVectorMasked, inline_limit, elem_bt) &&
Matcher::match_rule_supported_vector(Op_VectorCmpMasked, inline_limit, elem_bt)) {
+ const TypeVect* vt = TypeVect::make(elem_bt, inline_limit);
Node* cmp_length = _gvn.transform(new CmpINode(length, intcon(inline_limit)));
Node* bol_gt = _gvn.transform(new BoolNode(cmp_length, BoolTest::gt));
diff --git a/src/hotspot/share/runtime/handshake.cpp b/src/hotspot/share/runtime/handshake.cpp
index 1b8f37f8e90..e2c15147c7c 100644
--- a/src/hotspot/share/runtime/handshake.cpp
+++ b/src/hotspot/share/runtime/handshake.cpp
@@ -624,8 +624,8 @@ class ThreadSelfSuspensionHandshake : public AsyncHandshakeClosure {
};
bool HandshakeState::suspend_with_handshake() {
- if (_handshakee->is_exiting() ||
- _handshakee->threadObj() == NULL) {
+ assert(_handshakee->threadObj() != NULL, "cannot suspend with a NULL threadObj");
+ if (_handshakee->is_exiting()) {
log_trace(thread, suspend)("JavaThread:" INTPTR_FORMAT " exiting", p2i(_handshakee));
return false;
}
diff --git a/src/hotspot/share/runtime/thread.cpp b/src/hotspot/share/runtime/thread.cpp
index 2d381c8349f..4ea67763e1b 100644
--- a/src/hotspot/share/runtime/thread.cpp
+++ b/src/hotspot/share/runtime/thread.cpp
@@ -1197,11 +1197,6 @@ JavaThread::~JavaThread() {
#if INCLUDE_JVMCI
if (JVMCICounterSize > 0) {
- if (jvmci_counters_include(this)) {
- for (int i = 0; i < JVMCICounterSize; i++) {
- _jvmci_old_thread_counters[i] += _jvmci_counters[i];
- }
- }
FREE_C_HEAP_ARRAY(jlong, _jvmci_counters);
}
#endif // INCLUDE_JVMCI
@@ -1457,6 +1452,17 @@ void JavaThread::exit(bool destroy_vm, ExitType exit_type) {
_timer_exit_phase3.stop();
_timer_exit_phase4.start();
}
+
+#if INCLUDE_JVMCI
+ if (JVMCICounterSize > 0) {
+ if (jvmci_counters_include(this)) {
+ for (int i = 0; i < JVMCICounterSize; i++) {
+ _jvmci_old_thread_counters[i] += _jvmci_counters[i];
+ }
+ }
+ }
+#endif // INCLUDE_JVMCI
+
// Remove from list of active threads list, and notify VM thread if we are the last non-daemon thread
Threads::remove(this, daemon);
diff --git a/src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java b/src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java
index fee6082de99..7cad5ec9c82 100644
--- a/src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java
+++ b/src/java.base/share/classes/com/sun/crypto/provider/GaloisCounterMode.java
@@ -894,7 +894,7 @@ abstract class GaloisCounterMode extends CipherSpi {
// if src is read only, then we need a copy
if (!src.isReadOnly()) {
// If using the heap, check underlying byte[] address.
- if (!src.array().equals(dst.array()) ) {
+ if (src.array() != dst.array()) {
return dst;
}
diff --git a/src/java.base/share/classes/java/io/ObjectInputFilter.java b/src/java.base/share/classes/java/io/ObjectInputFilter.java
index 069e0093ea0..f33c76cd689 100644
--- a/src/java.base/share/classes/java/io/ObjectInputFilter.java
+++ b/src/java.base/share/classes/java/io/ObjectInputFilter.java
@@ -560,7 +560,6 @@ public interface ObjectInputFilter {
* fully qualified class name of the deserialization filter factory.
* @since 9
*/
- @SuppressWarnings("removal")
final class Config {
/**
* Lock object for filter and filter factory.
@@ -628,19 +627,17 @@ public interface ObjectInputFilter {
*/
// Get the values of the system properties, if they are defined
- String factoryClassName = StaticProperty.jdkSerialFilterFactory();
- if (factoryClassName == null) {
- // Fallback to security property
- factoryClassName = AccessController.doPrivileged((PrivilegedAction<String>) () ->
+ @SuppressWarnings("removal")
+ String factoryClassName = StaticProperty.jdkSerialFilterFactory() != null
+ ? StaticProperty.jdkSerialFilterFactory()
+ : AccessController.doPrivileged((PrivilegedAction<String>) () ->
Security.getProperty(SERIAL_FILTER_FACTORY_PROPNAME));
- }
- String filterString = StaticProperty.jdkSerialFilter();
- if (filterString == null) {
- // Fallback to security property
- filterString = AccessController.doPrivileged((PrivilegedAction<String>) () ->
+ @SuppressWarnings("removal")
+ String filterString = StaticProperty.jdkSerialFilter() != null
+ ? StaticProperty.jdkSerialFilter()
+ : AccessController.doPrivileged((PrivilegedAction<String>) () ->
Security.getProperty(SERIAL_FILTER_PROPNAME));
- }
traceFilters = GetBooleanAction.privilegedGetProperty(SERIAL_FILTER_TRACE_PROPNAME);
@@ -743,6 +740,7 @@ public interface ObjectInputFilter {
*/
public static void setSerialFilter(ObjectInputFilter filter) {
Objects.requireNonNull(filter, "filter");
+ @SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(ObjectStreamConstants.SERIAL_FILTER_PERMISSION);
@@ -836,6 +834,7 @@ public interface ObjectInputFilter {
*/
public static void setSerialFilterFactory(BinaryOperator<ObjectInputFilter> filterFactory) {
Objects.requireNonNull(filterFactory, "filterFactory");
+ @SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(ObjectStreamConstants.SERIAL_FILTER_PERMISSION);
diff --git a/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java b/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java
index 7a2b6552693..4dd2b1fce7e 100644
--- a/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java
+++ b/src/java.base/share/classes/java/lang/invoke/MethodHandleProxies.java
@@ -59,7 +59,8 @@ public class MethodHandleProxies {
* even though it re-declares the {@code Object.equals} method and also
* declares default methods, such as {@code Comparator.reverse}.
* <p>
- * The interface must be public. No additional access checks are performed.
+ * The interface must be public and not {@linkplain Class#isSealed() sealed}.
+ * No additional access checks are performed.
* <p>
* The resulting instance of the required type will respond to
* invocation of the type's uniquely named method by calling
@@ -156,6 +157,8 @@ public class MethodHandleProxies {
public static <T> T asInterfaceInstance(final Class<T> intfc, final MethodHandle target) {
if (!intfc.isInterface() || !Modifier.isPublic(intfc.getModifiers()))
throw newIllegalArgumentException("not a public interface", intfc.getName());
+ if (intfc.isSealed())
+ throw newIllegalArgumentException("a sealed interface", intfc.getName());
final MethodHandle mh;
if (System.getSecurityManager() != null) {
final Class<?> caller = Reflection.getCallerClass();
diff --git a/src/java.base/share/classes/java/lang/invoke/MethodHandles.java b/src/java.base/share/classes/java/lang/invoke/MethodHandles.java
index 026486f4b21..9dcdef62dad 100644
--- a/src/java.base/share/classes/java/lang/invoke/MethodHandles.java
+++ b/src/java.base/share/classes/java/lang/invoke/MethodHandles.java
@@ -2768,6 +2768,7 @@ assertEquals("[x, y, z]", pb.command().toString());
* @throws ClassNotFoundException if the class cannot be loaded by the lookup class' loader.
* @throws IllegalAccessException if the class is not accessible, using the allowed access
* modes.
+ * @throws NullPointerException if {@code targetName} is null
* @since 9
* @jvms 5.4.3.1 Class and Interface Resolution
*/
@@ -2837,8 +2838,12 @@ assertEquals("[x, y, z]", pb.command().toString());
/**
* Determines if a class can be accessed from the lookup context defined by
* this {@code Lookup} object. The static initializer of the class is not run.
+ * If {@code targetClass} is an array class, {@code targetClass} is accessible
+ * if the element type of the array class is accessible. Otherwise,
+ * {@code targetClass} is determined as accessible as follows.
+ *
* <p>
- * If the {@code targetClass} is in the same module as the lookup class,
+ * If {@code targetClass} is in the same module as the lookup class,
* the lookup class is {@code LC} in module {@code M1} and
* the previous lookup class is in module {@code M0} or
* {@code null} if not present,
@@ -2861,7 +2866,7 @@ assertEquals("[x, y, z]", pb.command().toString());
* can access public types in all modules when the type is in a package
* that is exported unconditionally.
* <p>
- * Otherwise, the target class is in a different module from {@code lookupClass},
+ * Otherwise, {@code targetClass} is in a different module from {@code lookupClass},
* and if this lookup does not have {@code PUBLIC} access, {@code lookupClass}
* is inaccessible.
* <p>
@@ -2897,13 +2902,14 @@ assertEquals("[x, y, z]", pb.command().toString());
* @return the class that has been access-checked
* @throws IllegalAccessException if the class is not accessible from the lookup class
* and previous lookup class, if present, using the allowed access modes.
- * @throws SecurityException if a security manager is present and it
- * <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
+ * @throws SecurityException if a security manager is present and it
+ * <a href="MethodHandles.Lookup.html#secmgr">refuses access</a>
+ * @throws NullPointerException if {@code targetClass} is {@code null}
* @since 9
* @see <a href="#cross-module-lookup">Cross-module lookups</a>
*/
public Class<?> accessClass(Class<?> targetClass) throws IllegalAccessException {
- if (!VerifyAccess.isClassAccessible(targetClass, lookupClass, prevLookupClass, allowedModes)) {
+ if (!isClassAccessible(targetClass)) {
throw makeAccessException(targetClass);
}
checkSecurityManager(targetClass);
@@ -3684,7 +3690,11 @@ return mh1;
boolean isClassAccessible(Class<?> refc) {
Objects.requireNonNull(refc);
Class<?> caller = lookupClassOrNull();
- return caller == null || VerifyAccess.isClassAccessible(refc, caller, prevLookupClass, allowedModes);
+ Class<?> type = refc;
+ while (type.isArray()) {
+ type = type.getComponentType();
+ }
+ return caller == null || VerifyAccess.isClassAccessible(type, caller, prevLookupClass, allowedModes);
}
/** Check name for an illegal leading "&lt;" character. */
diff --git a/src/java.base/share/classes/java/lang/reflect/Proxy.java b/src/java.base/share/classes/java/lang/reflect/Proxy.java
index 42c37cd69ba..32aed2448b8 100644
--- a/src/java.base/share/classes/java/lang/reflect/Proxy.java
+++ b/src/java.base/share/classes/java/lang/reflect/Proxy.java
@@ -710,6 +710,10 @@ public class Proxy implements java.io.Serializable {
throw new IllegalArgumentException(intf.getName() + " is a hidden interface");
}
+ if (intf.isSealed()) {
+ throw new IllegalArgumentException(intf.getName() + " is a sealed interface");
+ }
+
/*
* Verify that the class loader resolves the name of this
* interface to the same Class object.
@@ -930,7 +934,8 @@ public class Proxy implements java.io.Serializable {
* if any of the following restrictions is violated:</a>
* <ul>
* <li>All of {@code Class} objects in the given {@code interfaces} array
- * must represent {@linkplain Class#isHidden() non-hidden} interfaces,
+ * must represent {@linkplain Class#isHidden() non-hidden} and
+ * {@linkplain Class#isSealed() non-sealed} interfaces,
* not classes or primitive types.
*
* <li>No two elements in the {@code interfaces} array may
diff --git a/src/java.base/share/classes/java/net/IDN.java b/src/java.base/share/classes/java/net/IDN.java
index d1c2065f30c..f88d0b174de 100644
--- a/src/java.base/share/classes/java/net/IDN.java
+++ b/src/java.base/share/classes/java/net/IDN.java
@@ -72,7 +72,6 @@ import jdk.internal.icu.text.UCharacterIterator;
* @since 1.6
*
*/
-@SuppressWarnings("removal")
public final class IDN {
/**
* Flag to allow processing of unassigned code points
@@ -224,19 +223,15 @@ public final class IDN {
private static StringPrep namePrep = null;
static {
- InputStream stream = null;
-
try {
final String IDN_PROFILE = "/sun/net/idn/uidna.spp";
- if (System.getSecurityManager() != null) {
- stream = AccessController.doPrivileged(new PrivilegedAction<>() {
- public InputStream run() {
- return StringPrep.class.getResourceAsStream(IDN_PROFILE);
- }
- });
- } else {
- stream = StringPrep.class.getResourceAsStream(IDN_PROFILE);
- }
+ @SuppressWarnings("removal")
+ InputStream stream = System.getSecurityManager() != null
+ ? AccessController.doPrivileged(new PrivilegedAction<>() {
+ public InputStream run() {
+ return StringPrep.class.getResourceAsStream(IDN_PROFILE);
+ }})
+ : StringPrep.class.getResourceAsStream(IDN_PROFILE);
namePrep = new StringPrep(stream);
stream.close();
diff --git a/src/java.base/share/classes/java/time/chrono/HijrahChronology.java b/src/java.base/share/classes/java/time/chrono/HijrahChronology.java
index 79f1867fe7a..f8616965150 100644
--- a/src/java.base/share/classes/java/time/chrono/HijrahChronology.java
+++ b/src/java.base/share/classes/java/time/chrono/HijrahChronology.java
@@ -202,7 +202,6 @@ import sun.util.logging.PlatformLogger;
*
* @since 1.8
*/
-@SuppressWarnings("removal")
public final class HijrahChronology extends AbstractChronology implements Serializable {
/**
@@ -291,8 +290,10 @@ public final class HijrahChronology extends AbstractChronology implements Serial
AbstractChronology.registerChrono(INSTANCE, "islamic");
// custom config chronologies
- CONF_PATH = Path.of(AccessController.doPrivileged((PrivilegedAction<String>)
- () -> System.getProperty("java.home")), "conf", "chronology");
+ @SuppressWarnings("removal")
+ String javaHome = AccessController.doPrivileged((PrivilegedAction<String>)
+ () -> System.getProperty("java.home"));
+ CONF_PATH = Path.of(javaHome, "conf", "chronology");
registerCustomChrono();
}
@@ -840,7 +841,7 @@ public final class HijrahChronology extends AbstractChronology implements Serial
};
FilePermission perm1 = new FilePermission("<<ALL FILES>>", "read");
RuntimePermission perm2 = new RuntimePermission("accessSystemModules");
- try (InputStream is = AccessController.doPrivileged(getResourceAction, null, perm1, perm2)) {
+ try (@SuppressWarnings("removal") InputStream is = AccessController.doPrivileged(getResourceAction, null, perm1, perm2)) {
if (is == null) {
throw new RuntimeException("Hijrah calendar resource not found: " + resourceName);
}
@@ -1035,6 +1036,7 @@ public final class HijrahChronology extends AbstractChronology implements Serial
* Look for Hijrah chronology variant properties files in
* <JAVA_HOME>/conf/chronology directory. Then register its chronology, if any.
*/
+ @SuppressWarnings("removal")
private static void registerCustomChrono() {
AccessController.doPrivileged(
(PrivilegedAction<Void>)() -> {
diff --git a/src/java.base/share/classes/java/time/zone/ZoneRulesProvider.java b/src/java.base/share/classes/java/time/zone/ZoneRulesProvider.java
index 0b1baf48130..194b6ccea74 100644
--- a/src/java.base/share/classes/java/time/zone/ZoneRulesProvider.java
+++ b/src/java.base/share/classes/java/time/zone/ZoneRulesProvider.java
@@ -127,7 +127,6 @@ import java.util.Collections;
*
* @since 1.8
*/
-@SuppressWarnings("removal")
public abstract class ZoneRulesProvider {
/**
@@ -147,26 +146,28 @@ public abstract class ZoneRulesProvider {
static {
// if the property java.time.zone.DefaultZoneRulesProvider is
// set then its value is the class name of the default provider
- final List<ZoneRulesProvider> loaded = new ArrayList<>();
- AccessController.doPrivileged(new PrivilegedAction<>() {
- public Object run() {
- String prop = System.getProperty("java.time.zone.DefaultZoneRulesProvider");
- if (prop != null) {
- try {
- Class<?> c = Class.forName(prop, true, ClassLoader.getSystemClassLoader());
- @SuppressWarnings("deprecation")
- ZoneRulesProvider provider = ZoneRulesProvider.class.cast(c.newInstance());
- registerProvider(provider);
- loaded.add(provider);
- } catch (Exception x) {
- throw new Error(x);
+ @SuppressWarnings("removal")
+ final List<ZoneRulesProvider> loaded =
+ AccessController.doPrivileged(new PrivilegedAction<List<ZoneRulesProvider>>() {
+ public List<ZoneRulesProvider> run() {
+ List<ZoneRulesProvider> result = new ArrayList<>();
+ String prop = System.getProperty("java.time.zone.DefaultZoneRulesProvider");
+ if (prop != null) {
+ try {
+ Class<?> c = Class.forName(prop, true, ClassLoader.getSystemClassLoader());
+ @SuppressWarnings("deprecation")
+ ZoneRulesProvider provider = ZoneRulesProvider.class.cast(c.newInstance());
+ registerProvider(provider);
+ result.add(provider);
+ } catch (Exception x) {
+ throw new Error(x);
+ }
+ } else {
+ registerProvider(new TzdbZoneRulesProvider());
+ }
+ return result;
}
- } else {
- registerProvider(new TzdbZoneRulesProvider());
- }
- return null;
- }
- });
+ });
ServiceLoader<ZoneRulesProvider> sl = ServiceLoader.load(ZoneRulesProvider.class, ClassLoader.getSystemClassLoader());
Iterator<ZoneRulesProvider> it = sl.iterator();
diff --git a/src/java.base/share/classes/java/util/Currency.java b/src/java.base/share/classes/java/util/Currency.java
index 502b597bbd8..37bbe615727 100644
--- a/src/java.base/share/classes/java/util/Currency.java
+++ b/src/java.base/share/classes/java/util/Currency.java
@@ -111,7 +111,6 @@ import sun.util.logging.PlatformLogger;
* @see java.math.BigDecimal
* @since 1.4
*/
-@SuppressWarnings("removal")
public final class Currency implements Serializable {
@java.io.Serial
@@ -210,6 +209,11 @@ public final class Currency implements Serializable {
private static final int VALID_FORMAT_VERSION = 3;
static {
+ initStatic();
+ }
+
+ @SuppressWarnings("removal")
+ private static void initStatic() {
AccessController.doPrivileged(new PrivilegedAction<>() {
@Override
public Void run() {
diff --git a/src/java.base/share/classes/java/util/concurrent/atomic/Striped64.java b/src/java.base/share/classes/java/util/concurrent/atomic/Striped64.java
index 6d0977fcdf7..61a9f4d79e9 100644
--- a/src/java.base/share/classes/java/util/concurrent/atomic/Striped64.java
+++ b/src/java.base/share/classes/java/util/concurrent/atomic/Striped64.java
@@ -47,7 +47,7 @@ import java.util.function.LongBinaryOperator;
* for classes supporting dynamic striping on 64bit values. The class
* extends Number so that concrete subclasses must publicly do so.
*/
-@SuppressWarnings({"removal","serial"})
+@SuppressWarnings("serial")
abstract class Striped64 extends Number {
/*
* This class maintains a lazily-initialized table of atomically
@@ -382,12 +382,13 @@ abstract class Striped64 extends Number {
private static final VarHandle THREAD_PROBE;
static {
try {
- MethodHandles.Lookup l = MethodHandles.lookup();
- BASE = l.findVarHandle(Striped64.class,
+ MethodHandles.Lookup l1 = MethodHandles.lookup();
+ BASE = l1.findVarHandle(Striped64.class,
"base", long.class);
- CELLSBUSY = l.findVarHandle(Striped64.class,
+ CELLSBUSY = l1.findVarHandle(Striped64.class,
"cellsBusy", int.class);
- l = java.security.AccessController.doPrivileged(
+ @SuppressWarnings("removal")
+ MethodHandles.Lookup l2 = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<>() {
public MethodHandles.Lookup run() {
try {
@@ -396,7 +397,7 @@ abstract class Striped64 extends Number {
throw new ExceptionInInitializerError(e);
}
}});
- THREAD_PROBE = l.findVarHandle(Thread.class,
+ THREAD_PROBE = l2.findVarHandle(Thread.class,
"threadLocalRandomProbe", int.class);
} catch (ReflectiveOperationException e) {
throw new ExceptionInInitializerError(e);
diff --git a/src/java.base/share/classes/jdk/internal/misc/X-ScopedMemoryAccess.java.template b/src/java.base/share/classes/jdk/internal/misc/X-ScopedMemoryAccess.java.template
index 9ca80a1296e..e478a9c38a0 100644
--- a/src/java.base/share/classes/jdk/internal/misc/X-ScopedMemoryAccess.java.template
+++ b/src/java.base/share/classes/jdk/internal/misc/X-ScopedMemoryAccess.java.template
@@ -31,10 +31,15 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.ref.Reference;
import java.io.FileDescriptor;
+import java.nio.Buffer;
+import java.nio.ByteBuffer;
+import jdk.internal.access.JavaNioAccess;
import jdk.internal.access.SharedSecrets;
+import jdk.internal.access.foreign.MemorySegmentProxy;
import jdk.internal.util.ArraysSupport;
import jdk.internal.vm.annotation.ForceInline;
+import jdk.internal.vm.vector.VectorSupport;
/**
@@ -334,6 +339,126 @@ public class ScopedMemoryAccess {
Reference.reachabilityFence(scope);
}
}
+
+ // ByteBuffer vector access ops
+
+ // Buffer access constants, to be initalized when required.
+ // Avoids a null value for NIO_ACCESS, due to class initalization dependencies
+ static final class BufferAccess {
+ // Buffer.address
+ static final long BUFFER_ADDRESS
+ = UNSAFE.objectFieldOffset(Buffer.class, "address");
+
+ // ByteBuffer.hb
+ static final long BYTE_BUFFER_HB
+ = UNSAFE.objectFieldOffset(ByteBuffer.class, "hb");
+
+ @ForceInline
+ static Object bufferBase(ByteBuffer bb) {
+ return UNSAFE.getReference(bb, BYTE_BUFFER_HB);
+ }
+
+ @ForceInline
+ static long bufferAddress(ByteBuffer bb, long offset) {
+ return UNSAFE.getLong(bb, BUFFER_ADDRESS) + offset;
+ }
+
+ static final JavaNioAccess NIO_ACCESS = SharedSecrets.getJavaNioAccess();
+
+ @ForceInline
+ static ScopedMemoryAccess.Scope scope(ByteBuffer bb) {
+ MemorySegmentProxy segmentProxy = NIO_ACCESS.bufferSegment(bb);
+ return segmentProxy != null ?
+ segmentProxy.scope() : null;
+ }
+ }
+
+ @ForceInline
+ public static
+ <V extends VectorSupport.Vector<E>, E, S extends VectorSupport.VectorSpecies<E>>
+ V loadFromByteBuffer(Class<? extends V> vmClass, Class<E> e, int length,
+ ByteBuffer bb, int offset,
+ S s,
+ VectorSupport.LoadOperation<ByteBuffer, V, E, S> defaultImpl) {
+ try {
+ return loadFromByteBufferScoped(
+ BufferAccess.scope(bb),
+ vmClass, e, length,
+ bb, offset,
+ s,
+ defaultImpl);
+ } catch (ScopedMemoryAccess.Scope.ScopedAccessError ex) {
+ throw new IllegalStateException("This segment is already closed");
+ }
+ }
+
+ @Scoped
+ @ForceInline
+ private static
+ <V extends VectorSupport.Vector<E>, E, S extends VectorSupport.VectorSpecies<E>>
+ V loadFromByteBufferScoped(ScopedMemoryAccess.Scope scope,
+ Class<? extends V> vmClass, Class<E> e, int length,
+ ByteBuffer bb, int offset,
+ S s,
+ VectorSupport.LoadOperation<ByteBuffer, V, E, S> defaultImpl) {
+ try {
+ if (scope != null) {
+ scope.checkValidState();
+ }
+
+ return VectorSupport.load(vmClass, e, length,
+ BufferAccess.bufferBase(bb), BufferAccess.bufferAddress(bb, offset),
+ bb, offset, s,
+ defaultImpl);
+ } finally {
+ Reference.reachabilityFence(scope);
+ }
+ }
+
+ @ForceInline
+ public static
+ <V extends VectorSupport.Vector<E>, E>
+ void storeIntoByteBuffer(Class<? extends V> vmClass, Class<E> e, int length,
+ V v,
+ ByteBuffer bb, int offset,
+ VectorSupport.StoreVectorOperation<ByteBuffer, V> defaultImpl) {
+ try {
+ storeIntoByteBufferScoped(
+ BufferAccess.scope(bb),
+ vmClass, e, length,
+ v,
+ bb, offset,
+ defaultImpl);
+ } catch (ScopedMemoryAccess.Scope.ScopedAccessError ex) {
+ throw new IllegalStateException("This segment is already closed");
+ }
+ }
+
+ @Scoped
+ @ForceInline
+ private static
+ <V extends VectorSupport.Vector<E>, E>
+ void storeIntoByteBufferScoped(ScopedMemoryAccess.Scope scope,
+ Class<? extends V> vmClass, Class<E> e, int length,
+ V v,
+ ByteBuffer bb, int offset,
+ VectorSupport.StoreVectorOperation<ByteBuffer, V> defaultImpl) {
+ try {
+ if (scope != null) {
+ scope.checkValidState();
+ }
+
+ VectorSupport.store(vmClass, e, length,
+ BufferAccess.bufferBase(bb), BufferAccess.bufferAddress(bb, offset),
+ v,
+ bb, offset,
+ defaultImpl);
+ } finally {
+ Reference.reachabilityFence(scope);
+ }
+ }
+
+
// typed-ops here
// Note: all the accessor methods defined below take advantage of argument type profiling
diff --git a/src/java.base/share/classes/sun/net/www/MimeTable.java b/src/java.base/share/classes/sun/net/www/MimeTable.java
index b20566bdc8b..eaf55f9b357 100644
--- a/src/java.base/share/classes/sun/net/www/MimeTable.java
+++ b/src/java.base/share/classes/sun/net/www/MimeTable.java
@@ -33,7 +33,6 @@ import java.util.Enumeration;
import java.util.Properties;
import java.util.StringTokenizer;
-@SuppressWarnings("removal")
public class MimeTable implements FileNameMap {
/** Keyed by content type, returns MimeEntries */
private Hashtable<String, MimeEntry> entries
@@ -44,28 +43,15 @@ public class MimeTable implements FileNameMap {
= new Hashtable<String, MimeEntry>();
// Will be reset if in the platform-specific data file
- private static String tempFileTemplate;
-
- static {
+ @SuppressWarnings("removal")
+ private static String tempFileTemplate =
java.security.AccessController.doPrivileged(
- new java.security.PrivilegedAction<Void>() {
- public Void run() {
- tempFileTemplate =
- System.getProperty("content.types.temp.file.template",
- "/tmp/%s");
-
- mailcapLocations = new String[] {
- System.getProperty("user.mailcap"),
- StaticProperty.userHome() + "/.mailcap",
- "/etc/mailcap",
- "/usr/etc/mailcap",
- "/usr/local/etc/mailcap",
- };
- return null;
- }
- });
- }
-
+ new java.security.PrivilegedAction<String>() {
+ public String run() {
+ return System.getProperty("content.types.temp.file.template",
+ "/tmp/%s");
+ }
+ });
private static final String filePreamble = "sun.net.www MIME content-types table";
private static final String fileMagic = "#" + filePreamble;
@@ -77,6 +63,7 @@ public class MimeTable implements FileNameMap {
private static class DefaultInstanceHolder {
static final MimeTable defaultInstance = getDefaultInstance();
+ @SuppressWarnings("removal")
static MimeTable getDefaultInstance() {
return java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<MimeTable>() {
@@ -220,7 +207,20 @@ public class MimeTable implements FileNameMap {
// For backward compatibility -- mailcap format files
// This is not currently used, but may in the future when we add ability
// to read BOTH the properties format and the mailcap format.
- protected static String[] mailcapLocations;
+ @SuppressWarnings("removal")
+ protected static String[] mailcapLocations =
+ java.security.AccessController.doPrivileged(
+ new java.security.PrivilegedAction<String[]>() {
+ public String[] run() {
+ return new String[]{
+ System.getProperty("user.mailcap"),
+ StaticProperty.userHome() + "/.mailcap",
+ "/etc/mailcap",
+ "/usr/etc/mailcap",
+ "/usr/local/etc/mailcap",
+ };
+ }
+ });
public synchronized void load() {
Properties entries = new Properties();
@@ -388,6 +388,7 @@ public class MimeTable implements FileNameMap {
properties.put("temp.file.template", tempFileTemplate);
String tag;
// Perform the property security check for user.name
+ @SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPropertyAccess("user.name");
diff --git a/src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java b/src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java
index c88c178c13e..0de7c353fe8 100644
--- a/src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java
+++ b/src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java
@@ -53,7 +53,6 @@ import sun.net.www.HeaderParser;
// policy in HttpURLConnection. A failure on baz.foo.com shouldn't
// uncache foo.com!
-@SuppressWarnings("removal")
public abstract class AuthenticationInfo extends AuthCacheValue implements Cloneable {
@java.io.Serial
@@ -70,12 +69,10 @@ public abstract class AuthenticationInfo extends AuthCacheValue implements Clone
* repeatedly, via the Authenticator. Default is false, which means that this
* behavior is switched off.
*/
- static final boolean serializeAuth;
- static {
- serializeAuth = java.security.AccessController.doPrivileged(
+ @SuppressWarnings("removal")
+ static final boolean serializeAuth = java.security.AccessController.doPrivileged(
new sun.security.action.GetBooleanAction(
"http.auth.serializeRequests")).booleanValue();
- }
/* AuthCacheValue: */
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 ce2c530f136..81b45126384 100644
--- a/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java
+++ b/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java
@@ -32,6 +32,7 @@ import java.security.Security;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.TreeSet;
import java.util.List;
import java.util.Set;
@@ -48,7 +49,7 @@ public abstract class AbstractAlgorithmConstraints
}
// Get algorithm constraints from the specified security property.
- static List<String> getAlgorithms(String propertyName) {
+ static Set<String> getAlgorithms(String propertyName) {
@SuppressWarnings("removal")
String property = AccessController.doPrivileged(
new PrivilegedAction<String>() {
@@ -73,38 +74,30 @@ public abstract class AbstractAlgorithmConstraints
// map the disabled algorithms
if (algorithmsInProperty == null) {
- return Collections.emptyList();
+ return Collections.emptySet();
}
- return new ArrayList<>(Arrays.asList(algorithmsInProperty));
+ Set<String> algorithmsInPropertySet = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);
+ algorithmsInPropertySet.addAll(Arrays.asList(algorithmsInProperty));
+ return algorithmsInPropertySet;
}
- static boolean checkAlgorithm(List<String> algorithms, String algorithm,
+ static boolean checkAlgorithm(Set<String> algorithms, String algorithm,
AlgorithmDecomposer decomposer) {
if (algorithm == null || algorithm.isEmpty()) {
throw new IllegalArgumentException("No algorithm name specified");
}
- Set<String> elements = null;
- for (String item : algorithms) {
- if (item == null || item.isEmpty()) {
- continue;
- }
-
- // check the full name
- if (item.equalsIgnoreCase(algorithm)) {
- return false;
- }
+ if (algorithms.contains(algorithm)) {
+ return false;
+ }
- // decompose the algorithm into sub-elements
- if (elements == null) {
- elements = decomposer.decompose(algorithm);
- }
+ // decompose the algorithm into sub-elements
+ Set<String> elements = decomposer.decompose(algorithm);
- // check the items of the algorithm
- for (String element : elements) {
- if (item.equalsIgnoreCase(element)) {
- return false;
- }
+ // check the element of the elements
+ for (String element : elements) {
+ if (algorithms.contains(element)) {
+ return false;
}
}
diff --git a/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java b/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java
index 13a4dcf4e6e..f7beb72cddc 100644
--- a/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java
+++ b/src/java.base/share/classes/sun/security/util/DisabledAlgorithmConstraints.java
@@ -85,6 +85,9 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
private static final String PROPERTY_DISABLED_EC_CURVES =
"jdk.disabled.namedCurves";
+ private static final Pattern INCLUDE_PATTERN = Pattern.compile("include " +
+ PROPERTY_DISABLED_EC_CURVES, Pattern.CASE_INSENSITIVE);
+
private static class CertPathHolder {
static final DisabledAlgorithmConstraints CONSTRAINTS =
new DisabledAlgorithmConstraints(PROPERTY_CERTPATH_DISABLED_ALGS);
@@ -95,7 +98,7 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
new DisabledAlgorithmConstraints(PROPERTY_JAR_DISABLED_ALGS);
}
- private final List<String> disabledAlgorithms;
+ private final Set<String> disabledAlgorithms;
private final Constraints algorithmConstraints;
public static DisabledAlgorithmConstraints certPathConstraints() {
@@ -130,21 +133,14 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
disabledAlgorithms = getAlgorithms(propertyName);
// Check for alias
- int ecindex = -1, i = 0;
for (String s : disabledAlgorithms) {
- if (s.regionMatches(true, 0,"include ", 0, 8)) {
- if (s.regionMatches(true, 8, PROPERTY_DISABLED_EC_CURVES, 0,
- PROPERTY_DISABLED_EC_CURVES.length())) {
- ecindex = i;
- break;
- }
+ Matcher matcher = INCLUDE_PATTERN.matcher(s);
+ if (matcher.matches()) {
+ disabledAlgorithms.remove(matcher.group());
+ disabledAlgorithms.addAll(
+ getAlgorithms(PROPERTY_DISABLED_EC_CURVES));
+ break;
}
- i++;
- }
- if (ecindex > -1) {
- disabledAlgorithms.remove(ecindex);
- disabledAlgorithms.addAll(ecindex,
- getAlgorithms(PROPERTY_DISABLED_EC_CURVES));
}
algorithmConstraints = new Constraints(propertyName, disabledAlgorithms);
}
@@ -332,8 +328,8 @@ public class DisabledAlgorithmConstraints extends AbstractAlgorithmConstraints {
"denyAfter\\s+(\\d{4})-(\\d{2})-(\\d{2})");
}
- public Constraints(String propertyName, List<String> constraintArray) {
- for (String constraintEntry : constraintArray) {
+ public Constraints(String propertyName, Set<String> constraintSet) {
+ for (String constraintEntry : constraintSet) {
if (constraintEntry == null || constraintEntry.isEmpty()) {
continue;
}
diff --git a/src/java.base/share/classes/sun/security/util/LegacyAlgorithmConstraints.java b/src/java.base/share/classes/sun/security/util/LegacyAlgorithmConstraints.java
index 1f0c17ccf0b..cc5547468be 100644
--- a/src/java.base/share/classes/sun/security/util/LegacyAlgorithmConstraints.java
+++ b/src/java.base/share/classes/sun/security/util/LegacyAlgorithmConstraints.java
@@ -40,7 +40,7 @@ public class LegacyAlgorithmConstraints extends AbstractAlgorithmConstraints {
public static final String PROPERTY_TLS_LEGACY_ALGS =
"jdk.tls.legacyAlgorithms";
- private final List<String> legacyAlgorithms;
+ private final Set<String> legacyAlgorithms;
public LegacyAlgorithmConstraints(String propertyName,
AlgorithmDecomposer decomposer) {
diff --git a/src/java.base/share/classes/sun/util/calendar/ZoneInfoFile.java b/src/java.base/share/classes/sun/util/calendar/ZoneInfoFile.java
index 96e186cc718..721b0ca91de 100644
--- a/src/java.base/share/classes/sun/util/calendar/ZoneInfoFile.java
+++ b/src/java.base/share/classes/sun/util/calendar/ZoneInfoFile.java
@@ -57,7 +57,6 @@ import sun.security.action.GetPropertyAction;
* <p>
* @since 1.8
*/
-@SuppressWarnings("removal")
public final class ZoneInfoFile {
/**
@@ -249,6 +248,11 @@ public final class ZoneInfoFile {
.privilegedGetProperty("sun.timezone.ids.oldmapping", "false")
.toLowerCase(Locale.ROOT);
USE_OLDMAPPING = (oldmapping.equals("yes") || oldmapping.equals("true"));
+ loadTZDB();
+ }
+
+ @SuppressWarnings("removal")
+ private static void loadTZDB() {
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
try {
diff --git a/src/java.base/share/man/java.1 b/src/java.base/share/man/java.1
index 82d5408f0f4..45e5b8476dc 100644
--- a/src/java.base/share/man/java.1
+++ b/src/java.base/share/man/java.1
@@ -4022,96 +4022,24 @@ By default, this option is disabled.
.RE
.SH REMOVED JAVA OPTIONS
.PP
-These \f[CB]java\f[R] options have been removed in JDK 17 and using them
-results in an error of:
-.RS
-.PP
-\f[CB]Unrecognized\ VM\ option\f[R] \f[I]option\-name\f[R]
-.RE
-.TP
-.B \f[CB]\-XX:+UseMembar\f[R]
-Enabled issuing membars on thread\-state transitions.
-This option was disabled by default on all platforms except ARM servers,
-where it was enabled.
-.RS
-.RE
-.TP
-.B \f[CB]\-XX:MaxPermSize=\f[R]\f[I]size\f[R]
-Sets the maximum permanent generation space size (in bytes).
-This option was deprecated in JDK 8 and superseded by the
-\f[CB]\-XX:MaxMetaspaceSize\f[R] option.
-.RS
-.RE
-.TP
-.B \f[CB]\-XX:PermSize=\f[R]\f[I]size\f[R]
-Sets the space (in bytes) allocated to the permanent generation that
-triggers a garbage collection if it\[aq]s exceeded.
-This option was deprecated in JDK 8 and superseded by the
-\f[CB]\-XX:MetaspaceSize\f[R] option.
-.RS
-.RE
-.TP
-.B \f[CB]\-XX:+TraceClassLoading\f[R]
-Enables tracing of classes as they are loaded.
-By default, this option is disabled and classes aren\[aq]t traced.
-.RS
-.PP
-The replacement Unified Logging syntax is
-\f[CB]\-Xlog:class+load=\f[R]\f[I]level\f[R].
-See \f[B]Enable Logging with the JVM Unified Logging Framework\f[R]
-.PP
-Use \f[I]level\f[R]=\f[CB]info\f[R] for regular information, or
-\f[I]level\f[R]=\f[CB]debug\f[R] for additional information.
-In Unified Logging syntax, \f[CB]\-verbose:class\f[R] equals
-\f[CB]\-Xlog:class+load=info,class+unload=info\f[R].
-.RE
-.TP
-.B \f[CB]\-XX:+TraceClassLoadingPreorder\f[R]
-Enables tracing of all loaded classes in the order in which they\[aq]re
-referenced.
-By default, this option is disabled and classes aren\[aq]t traced.
-.RS
-.PP
-The replacement Unified Logging syntax is
-\f[CB]\-Xlog:class+preorder=debug\f[R].
-See \f[B]Enable Logging with the JVM Unified Logging Framework\f[R].
-.RE
-.TP
-.B \f[CB]\-XX:+TraceClassResolution\f[R]
-Enables tracing of constant pool resolutions.
-By default, this option is disabled and constant pool resolutions
-aren\[aq]t traced.
-.RS
-.PP
-The replacement Unified Logging syntax is
-\f[CB]\-Xlog:class+resolve=debug\f[R].
-See \f[B]Enable Logging with the JVM Unified Logging Framework\f[R].
-.RE
-.TP
-.B \f[CB]\-XX:+TraceLoaderConstraints\f[R]
-Enables tracing of the loader constraints recording.
-By default, this option is disabled and loader constraints recording
-isn\[aq]t traced.
-.RS
-.PP
-The replacement Unified Logging syntax is
-\f[CB]\-Xlog:class+loader+constraints=info\f[R].
-See \f[B]Enable Logging with the JVM Unified Logging Framework\f[R].
-.RE
+No documented \f[CB]java\f[R] options have been removed in JDK 18.
.PP
For the lists and descriptions of options removed in previous releases
see the \f[I]Removed Java Options\f[R] section in:
.IP \[bu] 2
-\f[B]Java Platform, Standard Edition Tools Reference, Release 16\f[R]
+\f[B]The \f[BC]java\f[B] Command, Release 17\f[R]
+[https://docs.oracle.com/en/java/javase/17/docs/specs/man/java.html]
+.IP \[bu] 2
+\f[B]The \f[BC]java\f[B] Command, Release 16\f[R]
[https://docs.oracle.com/en/java/javase/16/docs/specs/man/java.html]
.IP \[bu] 2
-\f[B]Java Platform, Standard Edition Tools Reference, Release 15\f[R]
+\f[B]The \f[BC]java\f[B] Command, Release 15\f[R]
[https://docs.oracle.com/en/java/javase/15/docs/specs/man/java.html]
.IP \[bu] 2
-\f[B]Java Platform, Standard Edition Tools Reference, Release 14\f[R]
+\f[B]The \f[BC]java\f[B] Command, Release 14\f[R]
[https://docs.oracle.com/en/java/javase/14/docs/specs/man/java.html]
.IP \[bu] 2
-\f[B]Java Platform, Standard Edition Tools Reference, Release 13\f[R]
+\f[B]The \f[BC]java\f[B] Command, Release 13\f[R]
[https://docs.oracle.com/en/java/javase/13/docs/specs/man/java.html]
.IP \[bu] 2
\f[B]Java Platform, Standard Edition Tools Reference, Release 12\f[R]
diff --git a/src/java.base/unix/native/libnio/fs/UnixCopyFile.c b/src/java.base/unix/native/libnio/fs/UnixCopyFile.c
index 2e4e7559935..f2e4fc9cc71 100644
--- a/src/java.base/unix/native/libnio/fs/UnixCopyFile.c
+++ b/src/java.base/unix/native/libnio/fs/UnixCopyFile.c
@@ -68,6 +68,39 @@ int fcopyfile_callback(int what, int stage, copyfile_state_t state,
}
#endif
+// Transfer via user-space buffers
+void transfer(JNIEnv* env, jint dst, jint src, volatile jint* cancel)
+{
+ char buf[8192];
+
+ for (;;) {
+ ssize_t n, pos, len;
+ RESTARTABLE(read((int)src, &buf, sizeof(buf)), n);
+ if (n <= 0) {
+ if (n < 0)
+ throwUnixException(env, errno);
+ return;
+ }
+ if (cancel != NULL && *cancel != 0) {
+ throwUnixException(env, ECANCELED);
+ return;
+ }
+ pos = 0;
+ len = n;
+ do {
+ char* bufp = buf;
+ bufp += pos;
+ RESTARTABLE(write((int)dst, bufp, len), n);
+ if (n == -1) {
+ throwUnixException(env, errno);
+ return;
+ }
+ pos += n;
+ len -= n;
+ } while (len > 0);
+ }
+}
+
/**
* Transfer all bytes from src to dst within the kernel if possible (Linux),
* otherwise via user-space buffers
@@ -87,7 +120,12 @@ Java_sun_nio_fs_UnixCopyFile_transfer
do {
RESTARTABLE(sendfile64(dst, src, NULL, count), bytes_sent);
if (bytes_sent == -1) {
- throwUnixException(env, errno);
+ if (errno == EINVAL || errno == ENOSYS) {
+ // Fall back to copying via user-space buffers
+ transfer(env, dst, src, cancel);
+ } else {
+ throwUnixException(env, errno);
+ }
return;
}
if (cancel != NULL && *cancel != 0) {
@@ -114,34 +152,6 @@ Java_sun_nio_fs_UnixCopyFile_transfer
if (state != NULL)
copyfile_state_free(state);
#else
- // Transfer via user-space buffers
- char buf[8192];
-
- for (;;) {
- ssize_t n, pos, len;
- RESTARTABLE(read((int)src, &buf, sizeof(buf)), n);
- if (n <= 0) {
- if (n < 0)
- throwUnixException(env, errno);
- return;
- }
- if (cancel != NULL && *cancel != 0) {
- throwUnixException(env, ECANCELED);
- return;
- }
- pos = 0;
- len = n;
- do {
- char* bufp = buf;
- bufp += pos;
- RESTARTABLE(write((int)dst, bufp, len), n);
- if (n == -1) {
- throwUnixException(env, errno);
- return;
- }
- pos += n;
- len -= n;
- } while (len > 0);
- }
+ transfer(env, dst, src, cancel);
#endif
}
diff --git a/src/java.desktop/share/classes/java/awt/Taskbar.java b/src/java.desktop/share/classes/java/awt/Taskbar.java
index e2238b43e90..d9b95554ad3 100644
--- a/src/java.desktop/share/classes/java/awt/Taskbar.java
+++ b/src/java.desktop/share/classes/java/awt/Taskbar.java
@@ -323,7 +323,7 @@ public class Taskbar {
}
/**
- * Changes this application's icon to the provided image.
+ * Requests the system to change this application's icon to the provided {@code image}.
*
* @param image to change
* @throws SecurityException if a security manager exists and it denies the
@@ -340,6 +340,10 @@ public class Taskbar {
/**
* Obtains an image of this application's icon.
*
+ * @apiNote The returned icon image may not be equal
+ * to an image set by {@link java.awt.Taskbar#setIconImage},
+ * but should be visually similar.
+ *
* @return an image of this application's icon
* @throws SecurityException if a security manager exists and it denies the
* {@code RuntimePermission("canProcessApplicationEvents")} permission.
diff --git a/src/java.management/share/classes/java/lang/management/ManagementFactory.java b/src/java.management/share/classes/java/lang/management/ManagementFactory.java
index 7eaefc9c7ab..cba413ccf63 100644
--- a/src/java.management/share/classes/java/lang/management/ManagementFactory.java
+++ b/src/java.management/share/classes/java/lang/management/ManagementFactory.java
@@ -474,6 +474,7 @@ public class ManagementFactory {
* @see javax.management.MBeanServerFactory#createMBeanServer
*/
public static synchronized MBeanServer getPlatformMBeanServer() {
+ @SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
Permission perm = new MBeanServerPermission("createMBeanServer");
@@ -598,6 +599,7 @@ public class ManagementFactory {
// Only allow MXBean interfaces from the platform modules loaded by the
// bootstrap or platform class loader
final Class<?> cls = mxbeanInterface;
+ @SuppressWarnings("removal")
ClassLoader loader =
AccessController.doPrivileged(
(PrivilegedAction<ClassLoader>) () -> cls.getClassLoader());
@@ -885,6 +887,7 @@ public class ManagementFactory {
private static final String NOTIF_EMITTER =
"javax.management.NotificationEmitter";
+ @SuppressWarnings("removal")
private static void addMXBean(final MBeanServer mbs, String name, final Object pmo)
{
try {
@@ -920,6 +923,7 @@ public class ManagementFactory {
static {
// get all providers
+ @SuppressWarnings("removal")
List<PlatformMBeanProvider> providers = AccessController.doPrivileged(
new PrivilegedAction<List<PlatformMBeanProvider>>() {
@Override
@@ -1012,6 +1016,11 @@ public class ManagementFactory {
}
static {
+ loadNativeLib();
+ }
+
+ @SuppressWarnings("removal")
+ private static void loadNativeLib() {
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
System.loadLibrary("management");
return null;
diff --git a/src/java.management/share/classes/javax/management/modelmbean/DescriptorSupport.java b/src/java.management/share/classes/javax/management/modelmbean/DescriptorSupport.java
index 7045b3cf5c3..fc97a53d306 100644
--- a/src/java.management/share/classes/javax/management/modelmbean/DescriptorSupport.java
+++ b/src/java.management/share/classes/javax/management/modelmbean/DescriptorSupport.java
@@ -81,7 +81,7 @@ import sun.reflect.misc.ReflectUtil;
*
* @since 1.5
*/
-@SuppressWarnings({"removal","serial"}) // serialVersionUID not constant
+@SuppressWarnings("serial") // serialVersionUID not constant
public class DescriptorSupport
implements javax.management.Descriptor
{
@@ -119,16 +119,8 @@ public class DescriptorSupport
private static final ObjectStreamField[] serialPersistentFields;
private static final String serialForm;
static {
- String form = null;
- boolean compat = false;
- try {
- GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
- form = AccessController.doPrivileged(act);
- compat = "1.0".equals(form); // form may be null
- } catch (Exception e) {
- // OK: No compat with 1.0
- }
- serialForm = form;
+ serialForm = getForm();
+ boolean compat = "1.0".equals(serialForm); // serialForm may be null
if (compat) {
serialPersistentFields = oldSerialPersistentFields;
serialVersionUID = oldSerialVersionUID;
@@ -137,6 +129,19 @@ public class DescriptorSupport
serialVersionUID = newSerialVersionUID;
}
}
+
+ @SuppressWarnings("removal")
+ private static String getForm() {
+ String form = null;
+ try {
+ GetPropertyAction act = new GetPropertyAction("jmx.serial.form");
+ return AccessController.doPrivileged(act);
+ } catch (Exception e) {
+ // OK: No compat with 1.0
+ return null;
+ }
+ }
+
//
// END Serialization compatibility stuff
diff --git a/src/java.naming/share/classes/com/sun/jndi/ldap/LdapPoolManager.java b/src/java.naming/share/classes/com/sun/jndi/ldap/LdapPoolManager.java
index 7794f42514f..ef122351437 100644
--- a/src/java.naming/share/classes/com/sun/jndi/ldap/LdapPoolManager.java
+++ b/src/java.naming/share/classes/com/sun/jndi/ldap/LdapPoolManager.java
@@ -55,7 +55,6 @@ import jdk.internal.misc.InnocuousThread;
* @author Rosanna Lee
*/
-@SuppressWarnings("removal")
public final class LdapPoolManager {
private static final String DEBUG =
"com.sun.jndi.ldap.connect.pool.debug";
@@ -164,18 +163,7 @@ public final class LdapPoolManager {
}
if (idleTimeout > 0) {
- // Create cleaner to expire idle connections
- PrivilegedAction<Void> pa = new PrivilegedAction<Void>() {
- public Void run() {
- Thread t = InnocuousThread.newSystemThread(
- "LDAP PoolCleaner",
- new PoolCleaner(idleTimeout, pools));
- assert t.getContextClassLoader() == null;
- t.setDaemon(true);
- t.start();
- return null;
- }};
- AccessController.doPrivileged(pa);
+ startCleanerThread();
}
if (debug) {
@@ -183,6 +171,22 @@ public final class LdapPoolManager {
}
}
+ @SuppressWarnings("removal")
+ private static void startCleanerThread() {
+ // Create cleaner to expire idle connections
+ PrivilegedAction<Void> pa = new PrivilegedAction<Void>() {
+ public Void run() {
+ Thread t = InnocuousThread.newSystemThread(
+ "LDAP PoolCleaner",
+ new PoolCleaner(idleTimeout, pools));
+ assert t.getContextClassLoader() == null;
+ t.setDaemon(true);
+ t.start();
+ return null;
+ }};
+ AccessController.doPrivileged(pa);
+ }
+
// Cannot instantiate one of these
private LdapPoolManager() {
}
@@ -396,16 +400,19 @@ public final class LdapPoolManager {
}
}
+ @SuppressWarnings("removal")
private static final String getProperty(final String propName, final String defVal) {
PrivilegedAction<String> pa = () -> System.getProperty(propName, defVal);
return AccessController.doPrivileged(pa);
}
+ @SuppressWarnings("removal")
private static final int getInteger(final String propName, final int defVal) {
PrivilegedAction<Integer> pa = () -> Integer.getInteger(propName, defVal);
return AccessController.doPrivileged(pa);
}
+ @SuppressWarnings("removal")
private static final long getLong(final String propName, final long defVal) {
PrivilegedAction<Long> pa = () -> Long.getLong(propName, defVal);
return AccessController.doPrivileged(pa);
diff --git a/src/java.prefs/macosx/classes/java/util/prefs/MacOSXPreferencesFile.java b/src/java.prefs/macosx/classes/java/util/prefs/MacOSXPreferencesFile.java
index 3d8eba362e2..ab954513b81 100644
--- a/src/java.prefs/macosx/classes/java/util/prefs/MacOSXPreferencesFile.java
+++ b/src/java.prefs/macosx/classes/java/util/prefs/MacOSXPreferencesFile.java
@@ -76,10 +76,14 @@ import java.lang.ref.WeakReference;
it's expensive and is usually not necessary.
*/
-@SuppressWarnings("removal")
class MacOSXPreferencesFile {
static {
+ loadPrefsLib();
+ }
+
+ @SuppressWarnings("removal")
+ private static void loadPrefsLib() {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
diff --git a/src/java.prefs/unix/classes/java/util/prefs/FileSystemPreferences.java b/src/java.prefs/unix/classes/java/util/prefs/FileSystemPreferences.java
index b30a23465c5..5aafccbc487 100644
--- a/src/java.prefs/unix/classes/java/util/prefs/FileSystemPreferences.java
+++ b/src/java.prefs/unix/classes/java/util/prefs/FileSystemPreferences.java
@@ -46,10 +46,14 @@ import sun.util.logging.PlatformLogger;
* @see Preferences
* @since 1.4
*/
-@SuppressWarnings("removal")
class FileSystemPreferences extends AbstractPreferences {
static {
+ loadPrefsLib();
+ }
+
+ @SuppressWarnings("removal")
+ private static void loadPrefsLib() {
PrivilegedAction<Void> load = () -> {
System.loadLibrary("prefs");
return null;
@@ -60,6 +64,7 @@ class FileSystemPreferences extends AbstractPreferences {
/**
* Sync interval in seconds.
*/
+ @SuppressWarnings("removal")
private static final int SYNC_INTERVAL = Math.max(1,
AccessController.doPrivileged((PrivilegedAction<Integer>) () ->
Integer.getInteger("java.util.prefs.syncInterval", 30)));
@@ -111,6 +116,7 @@ class FileSystemPreferences extends AbstractPreferences {
return root;
}
+ @SuppressWarnings("removal")
private static void setupUserRoot() {
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
@@ -178,6 +184,7 @@ class FileSystemPreferences extends AbstractPreferences {
return root;
}
+ @SuppressWarnings("removal")
private static void setupSystemRoot() {
AccessController.doPrivileged(new PrivilegedAction<Void>() {
public Void run() {
@@ -445,6 +452,11 @@ class FileSystemPreferences extends AbstractPreferences {
private static Timer syncTimer = new Timer(true); // Daemon Thread
static {
+ addShutdownHook();
+ }
+
+ @SuppressWarnings("removal")
+ private static void addShutdownHook() {
// Add periodic timer task to periodically sync cached prefs
syncTimer.schedule(new TimerTask() {
public void run() {
@@ -513,6 +525,7 @@ class FileSystemPreferences extends AbstractPreferences {
* parent node and name. This constructor, called from childSpi,
* is used to make every node except for the two //roots.
*/
+ @SuppressWarnings("removal")
private FileSystemPreferences(FileSystemPreferences parent, String name) {
super(parent, name);
isUserNode = parent.isUserNode;
@@ -582,6 +595,7 @@ class FileSystemPreferences extends AbstractPreferences {
* fails, a BackingStoreException is thrown and both prefsCache and
* lastSyncTime are unaffected by the call.
*/
+ @SuppressWarnings("removal")
private void loadCache() throws BackingStoreException {
try {
AccessController.doPrivileged(
@@ -629,6 +643,7 @@ class FileSystemPreferences extends AbstractPreferences {
* and lastSyncTime will be unaffected by this call. This call will
* NEVER leave prefsFile in a corrupt state.
*/
+ @SuppressWarnings("removal")
private void writeBackCache() throws BackingStoreException {
try {
AccessController.doPrivileged(
@@ -662,6 +677,7 @@ class FileSystemPreferences extends AbstractPreferences {
return prefsCache.keySet().toArray(new String[prefsCache.size()]);
}
+ @SuppressWarnings("removal")
protected String[] childrenNamesSpi() {
return AccessController.doPrivileged(
new PrivilegedAction<String[]>() {
@@ -700,6 +716,7 @@ class FileSystemPreferences extends AbstractPreferences {
/**
* Called with file lock held (in addition to node locks).
*/
+ @SuppressWarnings("removal")
protected void removeNodeSpi() throws BackingStoreException {
try {
AccessController.doPrivileged(
@@ -734,6 +751,7 @@ class FileSystemPreferences extends AbstractPreferences {
}
}
+ @SuppressWarnings("removal")
public synchronized void sync() throws BackingStoreException {
boolean userNode = isUserNode();
boolean shared;
@@ -783,6 +801,7 @@ class FileSystemPreferences extends AbstractPreferences {
}
}
+ @SuppressWarnings("removal")
protected void syncSpi() throws BackingStoreException {
try {
AccessController.doPrivileged(
diff --git a/src/java.prefs/windows/classes/java/util/prefs/WindowsPreferences.java b/src/java.prefs/windows/classes/java/util/prefs/WindowsPreferences.java
index 788ada1f887..2979871aaac 100644
--- a/src/java.prefs/windows/classes/java/util/prefs/WindowsPreferences.java
+++ b/src/java.prefs/windows/classes/java/util/prefs/WindowsPreferences.java
@@ -44,10 +44,14 @@ import sun.util.logging.PlatformLogger;
* @since 1.4
*/
-@SuppressWarnings("removal")
class WindowsPreferences extends AbstractPreferences {
static {
+ loadPrefsLib();
+ }
+
+ @SuppressWarnings("removal")
+ private static void loadPrefsLib() {
PrivilegedAction<Void> load = () -> {
System.loadLibrary("prefs");
return null;
diff --git a/src/java.rmi/share/classes/sun/rmi/transport/DGCClient.java b/src/java.rmi/share/classes/sun/rmi/transport/DGCClient.java
index 25152e2c95e..7185f46201f 100644
--- a/src/java.rmi/share/classes/sun/rmi/transport/DGCClient.java
+++ b/src/java.rmi/share/classes/sun/rmi/transport/DGCClient.java
@@ -82,7 +82,6 @@ import java.security.ProtectionDomain;
* @author Ann Wollrath
* @author Peter Jones
*/
-@SuppressWarnings("removal")
final class DGCClient {
/** next sequence number for DGC calls (access synchronized on class) */
@@ -92,16 +91,19 @@ final class DGCClient {
private static VMID vmid = new VMID();
/** lease duration to request (usually ignored by server) */
+ @SuppressWarnings("removal")
private static final long leaseValue = // default 10 minutes
AccessController.doPrivileged((PrivilegedAction<Long>) () ->
Long.getLong("java.rmi.dgc.leaseValue", 600000));
/** maximum interval between retries of failed clean calls */
+ @SuppressWarnings("removal")
private static final long cleanInterval = // default 3 minutes
AccessController.doPrivileged((PrivilegedAction<Long>) () ->
Long.getLong("sun.rmi.dgc.cleanInterval", 180000));
/** maximum interval between complete garbage collections of local heap */
+ @SuppressWarnings("removal")
private static final long gcInterval = // default 1 hour
AccessController.doPrivileged((PrivilegedAction<Long>) () ->
Long.getLong("sun.rmi.dgc.client.gcInterval", 3600000));
@@ -122,12 +124,15 @@ final class DGCClient {
* An AccessControlContext with only socket permissions,
* suitable for an RMIClientSocketFactory.
*/
- private static final AccessControlContext SOCKET_ACC;
- static {
+ @SuppressWarnings("removal")
+ private static final AccessControlContext SOCKET_ACC = createSocketAcc();
+
+ @SuppressWarnings("removal")
+ private static AccessControlContext createSocketAcc() {
Permissions perms = new Permissions();
perms.add(new SocketPermission("*", "connect,resolve"));
ProtectionDomain[] pd = { new ProtectionDomain(null, perms) };
- SOCKET_ACC = new AccessControlContext(pd);
+ return new AccessControlContext(pd);
}
/*
@@ -251,6 +256,7 @@ final class DGCClient {
}
}
+ @SuppressWarnings("removal")
private EndpointEntry(final Endpoint endpoint) {
this.endpoint = endpoint;
try {
@@ -490,6 +496,7 @@ final class DGCClient {
*
* This method must ONLY be called while synchronized on this entry.
*/
+ @SuppressWarnings("removal")
private void setRenewTime(long newRenewTime) {
assert Thread.holdsLock(this);
@@ -515,6 +522,7 @@ final class DGCClient {
*/
private class RenewCleanThread implements Runnable {
+ @SuppressWarnings("removal")
public void run() {
do {
long timeToWait;
diff --git a/src/java.rmi/share/classes/sun/rmi/transport/DGCImpl.java b/src/java.rmi/share/classes/sun/rmi/transport/DGCImpl.java
index b6651988746..ba73610b441 100644
--- a/src/java.rmi/share/classes/sun/rmi/transport/DGCImpl.java
+++ b/src/java.rmi/share/classes/sun/rmi/transport/DGCImpl.java
@@ -64,25 +64,29 @@ import sun.rmi.server.Util;
*
* @author Ann Wollrath
*/
-@SuppressWarnings({"removal","deprecation"})
+@SuppressWarnings("deprecation")
final class DGCImpl implements DGC {
/* dgc system log */
+ @SuppressWarnings("removal")
static final Log dgcLog = Log.getLog("sun.rmi.dgc", "dgc",
LogStream.parseLevel(AccessController.doPrivileged(
(PrivilegedAction<String>) () -> System.getProperty("sun.rmi.dgc.logLevel"))));
/** lease duration to grant to clients */
+ @SuppressWarnings("removal")
private static final long leaseValue = // default 10 minutes
AccessController.doPrivileged(
(PrivilegedAction<Long>) () -> Long.getLong("java.rmi.dgc.leaseValue", 600000));
/** lease check interval; default is half of lease grant duration */
+ @SuppressWarnings("removal")
private static final long leaseCheckInterval =
AccessController.doPrivileged(
(PrivilegedAction<Long>) () -> Long.getLong("sun.rmi.dgc.checkInterval", leaseValue / 2));
/** thread pool for scheduling delayed tasks */
+ @SuppressWarnings("removal")
private static final ScheduledExecutorService scheduler =
AccessController.doPrivileged(
new RuntimeUtil.GetInstanceAction()).getScheduler();
@@ -120,6 +124,7 @@ final class DGCImpl implements DGC {
* The dgcFilter created from the value of the {@code "sun.rmi.transport.dgcFilter"}
* property.
*/
+ @SuppressWarnings("removal")
private static final ObjectInputFilter dgcFilter =
AccessController.doPrivileged((PrivilegedAction<ObjectInputFilter>)DGCImpl::initDgcFilter);
@@ -315,6 +320,11 @@ final class DGCImpl implements DGC {
}
static {
+ exportSingleton();
+ }
+
+ @SuppressWarnings("removal")
+ private static void exportSingleton() {
/*
* "Export" the singleton DGCImpl in a context isolated from
* the arbitrary current thread context.
diff --git a/src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPTransport.java b/src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPTransport.java
index 8b8f2c68b64..dba0f9f8f60 100644
--- a/src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPTransport.java
+++ b/src/java.rmi/share/classes/sun/rmi/transport/tcp/TCPTransport.java
@@ -83,21 +83,24 @@ import sun.rmi.transport.TransportConstants;
* @author Ann Wollrath
* @author Peter Jones
*/
-@SuppressWarnings({"removal","deprecation"})
+@SuppressWarnings("deprecation")
public class TCPTransport extends Transport {
/* tcp package log */
+ @SuppressWarnings("removal")
static final Log tcpLog = Log.getLog("sun.rmi.transport.tcp", "tcp",
LogStream.parseLevel(AccessController.doPrivileged(
(PrivilegedAction<String>) () -> System.getProperty("sun.rmi.transport.tcp.logLevel"))));
/** maximum number of connection handler threads */
+ @SuppressWarnings("removal")
private static final int maxConnectionThreads = // default no limit
AccessController.doPrivileged((PrivilegedAction<Integer>) () ->
Integer.getInteger("sun.rmi.transport.tcp.maxConnectionThreads",
Integer.MAX_VALUE));
/** keep alive time for idle connection handler threads */
+ @SuppressWarnings("removal")
private static final long threadKeepAliveTime = // default 1 minute
AccessController.doPrivileged((PrivilegedAction<Long>) () ->
Long.getLong("sun.rmi.transport.tcp.threadKeepAliveTime", 60000));
@@ -108,6 +111,7 @@ public class TCPTransport extends Transport {
threadKeepAliveTime, TimeUnit.MILLISECONDS,
new SynchronousQueue<Runnable>(),
new ThreadFactory() {
+ @SuppressWarnings("removal")
public Thread newThread(Runnable runnable) {
return AccessController.doPrivileged(new NewThreadAction(
runnable, "TCP Connection(idle)", true, true));
@@ -122,11 +126,14 @@ public class TCPTransport extends Transport {
threadConnectionHandler = new ThreadLocal<>();
/** an AccessControlContext with no permissions */
- private static final AccessControlContext NOPERMS_ACC;
- static {
+ @SuppressWarnings("removal")
+ private static final AccessControlContext NOPERMS_ACC = createNopermsAcc();
+
+ @SuppressWarnings("removal")
+ private static AccessControlContext createNopermsAcc() {
Permissions perms = new Permissions();
ProtectionDomain[] pd = { new ProtectionDomain(null, perms) };
- NOPERMS_ACC = new AccessControlContext(pd);
+ return new AccessControlContext(pd);
}
/** endpoints for this transport */
@@ -148,6 +155,7 @@ public class TCPTransport extends Transport {
* The maximum representable value is slightly more than 24 days
* and 20 hours.
*/
+ @SuppressWarnings("removal")
private static final int connectionReadTimeout = // default 2 hours
AccessController.doPrivileged((PrivilegedAction<Integer>) () ->
Integer.getInteger("sun.rmi.transport.tcp.readTimeout", 2 * 3600 * 1000));
@@ -298,7 +306,8 @@ public class TCPTransport extends Transport {
* Verify that the current access control context has permission to
* accept the connection being dispatched by the current thread.
*/
- protected void checkAcceptPermission(AccessControlContext acc) {
+ protected void checkAcceptPermission(@SuppressWarnings("removal") AccessControlContext acc) {
+ @SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm == null) {
return;
@@ -338,6 +347,7 @@ public class TCPTransport extends Transport {
* "port in use" will cause export to hang if an
* RMIFailureHandler is not installed.
*/
+ @SuppressWarnings("removal")
Thread t = AccessController.doPrivileged(
new NewThreadAction(new AcceptLoop(server),
"TCP Accept-" + port, true));
@@ -350,6 +360,7 @@ public class TCPTransport extends Transport {
} else {
// otherwise verify security access to existing server socket
+ @SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkListen(port);
@@ -646,11 +657,14 @@ public class TCPTransport extends Transport {
private static final int POST = 0x504f5354;
/** most recently accept-authorized AccessControlContext */
+ @SuppressWarnings("removal")
private AccessControlContext okContext;
/** cache of accept-authorized AccessControlContexts */
+ @SuppressWarnings("removal")
private Map<AccessControlContext,
Reference<AccessControlContext>> authCache;
/** security manager which authorized contexts in authCache */
+ @SuppressWarnings("removal")
private SecurityManager cacheSecurityManager = null;
private Socket socket;
@@ -669,6 +683,7 @@ public class TCPTransport extends Transport {
* Verify that the given AccessControlContext has permission to
* accept this connection.
*/
+ @SuppressWarnings("removal")
void checkAcceptPermission(SecurityManager sm,
AccessControlContext acc)
{
@@ -694,6 +709,7 @@ public class TCPTransport extends Transport {
okContext = acc;
}
+ @SuppressWarnings("removal")
public void run() {
Thread t = Thread.currentThread();
String name = t.getName();
diff --git a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Utility.java b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Utility.java
index 8577bdff728..f2ba13aeb54 100644
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Utility.java
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/Utility.java
@@ -42,7 +42,7 @@ import com.sun.org.apache.bcel.internal.util.ByteSequence;
/**
* Utility functions that do not really belong to any class in particular.
*
- * @LastModified: May 2021
+ * @LastModified: June 2021
*/
// @since 6.0 methods are no longer final
public abstract class Utility {
@@ -1461,6 +1461,7 @@ public abstract class Utility {
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
GZIPOutputStream gos = new GZIPOutputStream(baos)) {
gos.write(bytes, 0, bytes.length);
+ gos.finish();
bytes = baos.toByteArray();
}
}
diff --git a/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java b/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java
index 108d8c0fee2..15a257eca42 100644
--- a/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java
+++ b/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java
@@ -45,15 +45,18 @@ import java.util.stream.Collectors;
* The HotSpot implementation of com.sun.tools.attach.VirtualMachine.
*/
-@SuppressWarnings("removal")
public abstract class HotSpotVirtualMachine extends VirtualMachine {
- private static final long CURRENT_PID;
+ private static final long CURRENT_PID = pid();
+
+ @SuppressWarnings("removal")
+ private static long pid() {
+ PrivilegedAction<ProcessHandle> pa = () -> ProcessHandle.current();
+ return AccessController.doPrivileged(pa).pid();
+ }
+
private static final boolean ALLOW_ATTACH_SELF;
static {
- PrivilegedAction<ProcessHandle> pa = ProcessHandle::current;
- CURRENT_PID = AccessController.doPrivileged(pa).pid();
-
String s = VM.getSavedProperty("jdk.attach.allowAttachSelf");
ALLOW_ATTACH_SELF = "".equals(s) || Boolean.parseBoolean(s);
}
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
index 6567e8a6cd2..c0bfbb5d2ac 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
@@ -4064,24 +4064,19 @@ public class Attr extends JCTree.Visitor {
tree.expr.pos(), attribExpr(tree.expr, env));
Type clazztype;
JCTree typeTree;
- boolean checkRawTypes;
- if (tree.pattern.getTag() == BINDINGPATTERN) {
+ if (tree.pattern.getTag() == BINDINGPATTERN ||
+ tree.pattern.getTag() == PARENTHESIZEDPATTERN) {
attribTree(tree.pattern, env, unknownExprInfo);
clazztype = tree.pattern.type;
if (types.isSubtype(exprtype, clazztype) &&
!exprtype.isErroneous() && !clazztype.isErroneous()) {
log.error(tree.pos(), Errors.InstanceofPatternNoSubtype(exprtype, clazztype));
}
- JCBindingPattern pattern = (JCBindingPattern) tree.pattern;
- typeTree = pattern.var.vartype;
- if (!clazztype.hasTag(TYPEVAR)) {
- clazztype = chk.checkClassOrArrayType(pattern.var.vartype.pos(), clazztype);
- }
- checkRawTypes = true;
+ typeTree = TreeInfo.primaryPatternTree((JCPattern) tree.pattern).var.vartype;
} else {
clazztype = attribType(tree.pattern, env);
typeTree = tree.pattern;
- checkRawTypes = false;
+ chk.validate(typeTree, env, false);
}
if (!clazztype.hasTag(TYPEVAR)) {
clazztype = chk.checkClassOrArrayType(typeTree.pos(), clazztype);
@@ -4099,7 +4094,6 @@ public class Attr extends JCTree.Visitor {
clazztype = types.createErrorType(clazztype);
}
}
- chk.validate(typeTree, env, checkRawTypes);
chk.checkCastable(tree.expr.pos(), exprtype, clazztype);
result = check(tree, syms.booleanType, KindSelector.VAL, resultInfo);
}
@@ -4133,6 +4127,7 @@ public class Attr extends JCTree.Visitor {
annotate.annotateLater(tree.var.mods.annotations, env, v, tree.pos());
annotate.queueScanTreeAndTypeAnnotate(tree.var.vartype, env, v, tree.var.pos());
annotate.flush();
+ chk.validate(tree.var.vartype, env, true);
result = tree.type;
matchBindings = new MatchBindings(List.of(v), List.nil());
}
@@ -4140,6 +4135,7 @@ public class Attr extends JCTree.Visitor {
@Override
public void visitParenthesizedPattern(JCParenthesizedPattern tree) {
attribExpr(tree.pattern, env);
+ result = tree.type = tree.pattern.type;
}
@Override
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java
index 2822edd09e0..ca25388d5c9 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java
@@ -1217,6 +1217,7 @@ public class DeferredAttr extends JCTree.Visitor {
freeArgVars.nonEmpty()) {
stuckVars.addAll(freeArgVars);
depVars.addAll(inferenceContext.freeVarsIn(descType.getReturnType()));
+ depVars.addAll(inferenceContext.freeVarsIn(descType.getThrownTypes()));
}
scanLambdaBody(tree, descType.getReturnType());
}
@@ -1238,6 +1239,7 @@ public class DeferredAttr extends JCTree.Visitor {
tree.getOverloadKind() != JCMemberReference.OverloadKind.UNOVERLOADED) {
stuckVars.addAll(freeArgVars);
depVars.addAll(inferenceContext.freeVarsIn(descType.getReturnType()));
+ depVars.addAll(inferenceContext.freeVarsIn(descType.getThrownTypes()));
}
}
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java
index 39769687fd3..aec4177c4b4 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java
@@ -30,7 +30,7 @@ package com.sun.tools.javac.comp;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
-import java.util.function.Predicate;
+import java.util.stream.StreamSupport;
import com.sun.source.tree.LambdaExpressionTree.BodyKind;
import com.sun.tools.javac.code.*;
@@ -45,17 +45,16 @@ import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
import com.sun.tools.javac.util.JCDiagnostic.Error;
import com.sun.tools.javac.util.JCDiagnostic.Warning;
-import com.sun.tools.javac.code.Kinds.Kind;
import com.sun.tools.javac.code.Symbol.*;
import com.sun.tools.javac.tree.JCTree.*;
import static com.sun.tools.javac.code.Flags.*;
import static com.sun.tools.javac.code.Flags.BLOCK;
import static com.sun.tools.javac.code.Kinds.Kind.*;
+import com.sun.tools.javac.code.Type.TypeVar;
import static com.sun.tools.javac.code.TypeTag.BOOLEAN;
import static com.sun.tools.javac.code.TypeTag.VOID;
import com.sun.tools.javac.resources.CompilerProperties.Fragments;
-import com.sun.tools.javac.tree.JCTree.JCParenthesizedPattern;
import static com.sun.tools.javac.tree.JCTree.Tag.*;
import com.sun.tools.javac.util.JCDiagnostic.Fragment;
@@ -665,7 +664,7 @@ public class Flow {
ListBuffer<PendingExit> prevPendingExits = pendingExits;
pendingExits = new ListBuffer<>();
scan(tree.selector);
- Set<Object> constants = tree.patternSwitch ? allSwitchConstants(tree.selector) : null;
+ Set<Symbol> constants = tree.patternSwitch ? new HashSet<>() : null;
for (List<JCCase> l = tree.cases; l.nonEmpty(); l = l.tail) {
alive = Liveness.ALIVE;
JCCase c = l.head;
@@ -687,8 +686,9 @@ public class Flow {
l.tail.head.pos(),
Warnings.PossibleFallThroughIntoCase);
}
- if ((constants == null || !constants.isEmpty()) && !tree.hasTotalPattern &&
- tree.patternSwitch && !TreeInfo.isErrorEnumSwitch(tree.selector, tree.cases)) {
+ if (!tree.hasTotalPattern && tree.patternSwitch &&
+ !TreeInfo.isErrorEnumSwitch(tree.selector, tree.cases) &&
+ (constants == null || !isExhaustive(tree.selector.type, constants))) {
log.error(tree, Errors.NotExhaustiveStatement);
}
if (!tree.hasTotalPattern) {
@@ -702,7 +702,7 @@ public class Flow {
ListBuffer<PendingExit> prevPendingExits = pendingExits;
pendingExits = new ListBuffer<>();
scan(tree.selector);
- Set<Object> constants = allSwitchConstants(tree.selector);
+ Set<Symbol> constants = new HashSet<>();
Liveness prevAlive = alive;
for (List<JCCase> l = tree.cases; l.nonEmpty(); l = l.tail) {
alive = Liveness.ALIVE;
@@ -723,47 +723,83 @@ public class Flow {
}
c.completesNormally = alive != Liveness.DEAD;
}
- if ((constants == null || !constants.isEmpty()) && !tree.hasTotalPattern &&
- !TreeInfo.isErrorEnumSwitch(tree.selector, tree.cases)) {
+ if (!tree.hasTotalPattern && !TreeInfo.isErrorEnumSwitch(tree.selector, tree.cases) &&
+ !isExhaustive(tree.selector.type, constants)) {
log.error(tree, Errors.NotExhaustive);
}
alive = prevAlive;
alive = alive.or(resolveYields(tree, prevPendingExits));
}
- private Set<Object> allSwitchConstants(JCExpression selector) {
- Set<Object> constants = null;
- TypeSymbol selectorSym = selector.type.tsym;
- if ((selectorSym.flags() & ENUM) != 0) {
- constants = new HashSet<>();
- Predicate<Symbol> enumConstantFilter =
- s -> (s.flags() & ENUM) != 0 && s.kind == Kind.VAR;
- for (Symbol s : selectorSym.members().getSymbols(enumConstantFilter)) {
- constants.add(s.name);
- }
- } else if (selectorSym.isAbstract() && selectorSym.isSealed() && selectorSym.kind == Kind.TYP) {
- constants = new HashSet<>();
- constants.addAll(((ClassSymbol) selectorSym).permitted);
- }
- return constants;
- }
-
- private void handleConstantCaseLabel(Set<Object> constants, JCCaseLabel pat) {
+ private void handleConstantCaseLabel(Set<Symbol> constants, JCCaseLabel pat) {
if (constants != null) {
if (pat.isExpression()) {
JCExpression expr = (JCExpression) pat;
- if (expr.hasTag(IDENT))
- constants.remove(((JCIdent) expr).name);
+ if (expr.hasTag(IDENT) && ((JCIdent) expr).sym.isEnum())
+ constants.add(((JCIdent) expr).sym);
} else if (pat.isPattern()) {
PatternPrimaryType patternType = TreeInfo.primaryPatternType((JCPattern) pat);
if (patternType.unconditional()) {
- constants.remove(patternType.type().tsym);
+ constants.add(patternType.type().tsym);
}
}
}
}
+ private void transitiveCovers(Set<Symbol> covered) {
+ List<Symbol> todo = List.from(covered);
+ while (todo.nonEmpty()) {
+ Symbol sym = todo.head;
+ todo = todo.tail;
+ switch (sym.kind) {
+ case VAR -> {
+ Iterable<Symbol> constants = sym.owner
+ .members()
+ .getSymbols(s -> s.isEnum() &&
+ s.kind == VAR);
+ boolean hasAll = StreamSupport.stream(constants.spliterator(), false)
+ .allMatch(covered::contains);
+
+ if (hasAll && covered.add(sym.owner)) {
+ todo = todo.prepend(sym.owner);
+ }
+ }
+
+ case TYP -> {
+ for (Type sup : types.directSupertypes(sym.type)) {
+ if (sup.tsym.kind == TYP && sup.tsym.isAbstract() && sup.tsym.isSealed()) {
+ boolean hasAll = ((ClassSymbol) sup.tsym).permitted
+ .stream()
+ .allMatch(covered::contains);
+
+ if (hasAll && covered.add(sup.tsym)) {
+ todo = todo.prepend(sup.tsym);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private boolean isExhaustive(Type seltype, Set<Symbol> covered) {
+ transitiveCovers(covered);
+ return switch (seltype.getTag()) {
+ case CLASS -> {
+ if (seltype.isCompound()) {
+ if (seltype.isIntersection()) {
+ yield ((Type.IntersectionClassType) seltype).getComponents().stream().anyMatch(t -> isExhaustive(t, covered));
+ }
+ yield false;
+ }
+ yield covered.contains(seltype.tsym);
+ }
+ case TYPEVAR -> isExhaustive(((TypeVar) seltype).getUpperBound(), covered);
+ default -> false;
+ };
+ }
+
public void visitTry(JCTry tree) {
ListBuffer<PendingExit> prevPendingExits = pendingExits;
pendingExits = new ListBuffer<>();
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java
index 16c2fdbf2a5..7040e8875e0 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransPatterns.java
@@ -186,12 +186,14 @@ public class TransPatterns extends TreeTranslator {
//=>
//(let T' N$temp = E; N$temp instanceof typeof($pattern) && <desugared $pattern>)
//note the pattern desugaring performs binding variable assignments
- Symbol exprSym = TreeInfo.symbol(tree.expr);
Type tempType = tree.expr.type.hasTag(BOT) ?
syms.objectType
: tree.expr.type;
VarSymbol prevCurrentValue = currentValue;
try {
+ JCExpression translatedExpr = translate(tree.expr);
+ Symbol exprSym = TreeInfo.symbol(translatedExpr);
+
if (exprSym != null &&
exprSym.kind == Kind.VAR &&
exprSym.owner.kind.matches(Kinds.KindSelector.VAL_MTH)) {
@@ -203,7 +205,6 @@ public class TransPatterns extends TreeTranslator {
currentMethodSym);
}
- JCExpression translatedExpr = translate(tree.expr);
Type principalType = principalType((JCPattern) tree.pattern);
result = makeBinary(Tag.AND,
makeTypeTest(make.Ident(currentValue), make.Type(principalType)),
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 e095694c4d2..4e695bd8f3f 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
@@ -764,26 +764,26 @@ public class JavacParser implements Parser {
*/
public JCPattern parsePattern(int pos, JCModifiers mods, JCExpression parsedType, boolean inInstanceOf) {
+ JCPattern pattern;
if (token.kind == LPAREN && parsedType == null) {
int startPos = token.pos;
accept(LPAREN);
JCPattern p = parsePattern(token.pos, null, null, false);
accept(RPAREN);
- return toP(F.at(startPos).ParenthesizedPattern(p));
+ pattern = toP(F.at(startPos).ParenthesizedPattern(p));
} else {
- JCPattern pattern;
JCExpression e = parsedType == null ? term(EXPR | TYPE | NOLAMBDA) : parsedType;
mods = mods != null ? mods : F.at(token.pos).Modifiers(0);
JCVariableDecl var = toP(F.at(token.pos).VarDef(mods, ident(), e, null));
pattern = toP(F.at(pos).BindingPattern(var));
- if (!inInstanceOf && token.kind == AMPAMP) {
- checkSourceLevel(Feature.PATTERN_SWITCH);
- nextToken();
- JCExpression guard = term(EXPR | NOLAMBDA);
- pattern = F.at(pos).GuardPattern(pattern, guard);
- }
- return pattern;
}
+ if (!inInstanceOf && token.kind == AMPAMP) {
+ checkSourceLevel(Feature.PATTERN_SWITCH);
+ nextToken();
+ JCExpression guard = term(EXPR | NOLAMBDA);
+ pattern = F.at(pos).GuardPattern(pattern, guard);
+ }
+ return pattern;
}
/**
@@ -1694,12 +1694,16 @@ public class JavacParser implements Parser {
* method reference or a binary expression. To disambiguate, look for a
* matching '&gt;' and see if the subsequent terminal is either '.' or '::'.
*/
- @SuppressWarnings("fallthrough")
ParensResult analyzeParens() {
+ return analyzeParens(0);
+ }
+
+ @SuppressWarnings("fallthrough")
+ ParensResult analyzeParens(int startLookahead) {
int depth = 0;
boolean type = false;
ParensResult defaultResult = ParensResult.PARENS;
- outer: for (int lookahead = 0; ; lookahead++) {
+ outer: for (int lookahead = startLookahead; ; lookahead++) {
TokenKind tk = S.token(lookahead).kind;
switch (tk) {
case COMMA:
@@ -1725,7 +1729,7 @@ public class JavacParser implements Parser {
}
break;
case LPAREN:
- if (lookahead != 0) {
+ if (lookahead != startLookahead) {
// '(' in a non-starting position -> parens
return ParensResult.PARENS;
} else if (peekToken(lookahead, RPAREN)) {
@@ -3065,15 +3069,12 @@ public class JavacParser implements Parser {
} else {
if (token.kind == LPAREN) {
int lookahead = 0;
- Token ahead;
- while ((ahead = S.token(lookahead)).kind != EOF && ahead.kind != RPAREN && ahead.kind != AMPAMP) {
+ while (S.token(lookahead + 1).kind == LPAREN) {
lookahead++;
}
- Token twoBack;
- boolean pattern = S.token(lookahead - 1).kind == IDENTIFIER &&
- ((twoBack = S.token(lookahead - 2)).kind == IDENTIFIER ||
- twoBack.kind == GT || twoBack.kind == GTGT || twoBack.kind == GTGTGT);
+ boolean pattern = analyzeParens(lookahead) == ParensResult.EXPLICIT_LAMBDA;
if (pattern) {
+ checkSourceLevel(token.pos, Feature.PATTERN_SWITCH);
return parsePattern(token.pos, null, null, false);
} else {
return term(EXPR | TYPE | NOLAMBDA);
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java
index faa690e6d77..531c9d120fb 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java
@@ -1367,6 +1367,15 @@ public class TreeInfo {
};
}
+ public static JCBindingPattern primaryPatternTree(JCPattern pat) {
+ return switch (pat.getTag()) {
+ case BINDINGPATTERN -> (JCBindingPattern) pat;
+ case GUARDPATTERN -> primaryPatternTree(((JCGuardPattern) pat).patt);
+ case PARENTHESIZEDPATTERN -> primaryPatternTree(((JCParenthesizedPattern) pat).pattern);
+ default -> throw new AssertionError();
+ };
+ }
+
public record PatternPrimaryType(Type type, boolean unconditional) {}
}
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java
index b759b67003d..c7613b2ff14 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java
@@ -33,6 +33,7 @@ import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.UnaryOperator;
+import jdk.internal.misc.ScopedMemoryAccess;
import jdk.internal.misc.Unsafe;
import jdk.internal.vm.annotation.ForceInline;
import jdk.internal.vm.vector.VectorSupport;
@@ -3562,15 +3563,14 @@ public abstract class ByteVector extends AbstractVector<Byte> {
final
ByteVector fromByteBuffer0Template(ByteBuffer bb, int offset) {
ByteSpecies vsp = vspecies();
- return VectorSupport.load(
- vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
- bufferBase(bb), bufferAddress(bb, offset),
- bb, offset, vsp,
- (buf, off, s) -> {
- ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
- return s.ldOp(wb, off,
- (wb_, o, i) -> wb_.get(o + i * 1));
- });
+ return ScopedMemoryAccess.loadFromByteBuffer(
+ vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
+ bb, offset, vsp,
+ (buf, off, s) -> {
+ ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
+ return s.ldOp(wb, off,
+ (wb_, o, i) -> wb_.get(o + i * 1));
+ });
}
// Unchecked storing operations in native byte order.
@@ -3613,15 +3613,14 @@ public abstract class ByteVector extends AbstractVector<Byte> {
final
void intoByteBuffer0(ByteBuffer bb, int offset) {
ByteSpecies vsp = vspecies();
- VectorSupport.store(
- vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
- bufferBase(bb), bufferAddress(bb, offset),
- this, bb, offset,
- (buf, off, v) -> {
- ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
- v.stOp(wb, off,
- (wb_, o, i, e) -> wb_.put(o + i * 1, e));
- });
+ ScopedMemoryAccess.storeIntoByteBuffer(
+ vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
+ this, bb, offset,
+ (buf, off, v) -> {
+ ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
+ v.stOp(wb, off,
+ (wb_, o, i, e) -> wb_.put(o + i * 1, e));
+ });
}
// End of low-level memory operations.
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java
index 2eaf3e9fb64..9dadb3f7b03 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java
@@ -33,6 +33,7 @@ import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.UnaryOperator;
+import jdk.internal.misc.ScopedMemoryAccess;
import jdk.internal.misc.Unsafe;
import jdk.internal.vm.annotation.ForceInline;
import jdk.internal.vm.vector.VectorSupport;
@@ -3173,15 +3174,14 @@ public abstract class DoubleVector extends AbstractVector<Double> {
final
DoubleVector fromByteBuffer0Template(ByteBuffer bb, int offset) {
DoubleSpecies vsp = vspecies();
- return VectorSupport.load(
- vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
- bufferBase(bb), bufferAddress(bb, offset),
- bb, offset, vsp,
- (buf, off, s) -> {
- ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
- return s.ldOp(wb, off,
- (wb_, o, i) -> wb_.getDouble(o + i * 8));
- });
+ return ScopedMemoryAccess.loadFromByteBuffer(
+ vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
+ bb, offset, vsp,
+ (buf, off, s) -> {
+ ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
+ return s.ldOp(wb, off,
+ (wb_, o, i) -> wb_.getDouble(o + i * 8));
+ });
}
// Unchecked storing operations in native byte order.
@@ -3224,15 +3224,14 @@ public abstract class DoubleVector extends AbstractVector<Double> {
final
void intoByteBuffer0(ByteBuffer bb, int offset) {
DoubleSpecies vsp = vspecies();
- VectorSupport.store(
- vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
- bufferBase(bb), bufferAddress(bb, offset),
- this, bb, offset,
- (buf, off, v) -> {
- ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
- v.stOp(wb, off,
- (wb_, o, i, e) -> wb_.putDouble(o + i * 8, e));
- });
+ ScopedMemoryAccess.storeIntoByteBuffer(
+ vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
+ this, bb, offset,
+ (buf, off, v) -> {
+ ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
+ v.stOp(wb, off,
+ (wb_, o, i, e) -> wb_.putDouble(o + i * 8, e));
+ });
}
// End of low-level memory operations.
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java
index a3ae114c2df..1841b3e0dec 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java
@@ -33,6 +33,7 @@ import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.UnaryOperator;
+import jdk.internal.misc.ScopedMemoryAccess;
import jdk.internal.misc.Unsafe;
import jdk.internal.vm.annotation.ForceInline;
import jdk.internal.vm.vector.VectorSupport;
@@ -3160,15 +3161,14 @@ public abstract class FloatVector extends AbstractVector<Float> {
final
FloatVector fromByteBuffer0Template(ByteBuffer bb, int offset) {
FloatSpecies vsp = vspecies();
- return VectorSupport.load(
- vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
- bufferBase(bb), bufferAddress(bb, offset),
- bb, offset, vsp,
- (buf, off, s) -> {
- ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
- return s.ldOp(wb, off,
- (wb_, o, i) -> wb_.getFloat(o + i * 4));
- });
+ return ScopedMemoryAccess.loadFromByteBuffer(
+ vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
+ bb, offset, vsp,
+ (buf, off, s) -> {
+ ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
+ return s.ldOp(wb, off,
+ (wb_, o, i) -> wb_.getFloat(o + i * 4));
+ });
}
// Unchecked storing operations in native byte order.
@@ -3211,15 +3211,14 @@ public abstract class FloatVector extends AbstractVector<Float> {
final
void intoByteBuffer0(ByteBuffer bb, int offset) {
FloatSpecies vsp = vspecies();
- VectorSupport.store(
- vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
- bufferBase(bb), bufferAddress(bb, offset),
- this, bb, offset,
- (buf, off, v) -> {
- ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
- v.stOp(wb, off,
- (wb_, o, i, e) -> wb_.putFloat(o + i * 4, e));
- });
+ ScopedMemoryAccess.storeIntoByteBuffer(
+ vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
+ this, bb, offset,
+ (buf, off, v) -> {
+ ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
+ v.stOp(wb, off,
+ (wb_, o, i, e) -> wb_.putFloat(o + i * 4, e));
+ });
}
// End of low-level memory operations.
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java
index 053283161fe..f23cdfa1149 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java
@@ -33,6 +33,7 @@ import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.UnaryOperator;
+import jdk.internal.misc.ScopedMemoryAccess;
import jdk.internal.misc.Unsafe;
import jdk.internal.vm.annotation.ForceInline;
import jdk.internal.vm.vector.VectorSupport;
@@ -3269,15 +3270,14 @@ public abstract class IntVector extends AbstractVector<Integer> {
final
IntVector fromByteBuffer0Template(ByteBuffer bb, int offset) {
IntSpecies vsp = vspecies();
- return VectorSupport.load(
- vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
- bufferBase(bb), bufferAddress(bb, offset),
- bb, offset, vsp,
- (buf, off, s) -> {
- ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
- return s.ldOp(wb, off,
- (wb_, o, i) -> wb_.getInt(o + i * 4));
- });
+ return ScopedMemoryAccess.loadFromByteBuffer(
+ vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
+ bb, offset, vsp,
+ (buf, off, s) -> {
+ ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
+ return s.ldOp(wb, off,
+ (wb_, o, i) -> wb_.getInt(o + i * 4));
+ });
}
// Unchecked storing operations in native byte order.
@@ -3320,15 +3320,14 @@ public abstract class IntVector extends AbstractVector<Integer> {
final
void intoByteBuffer0(ByteBuffer bb, int offset) {
IntSpecies vsp = vspecies();
- VectorSupport.store(
- vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
- bufferBase(bb), bufferAddress(bb, offset),
- this, bb, offset,
- (buf, off, v) -> {
- ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
- v.stOp(wb, off,
- (wb_, o, i, e) -> wb_.putInt(o + i * 4, e));
- });
+ ScopedMemoryAccess.storeIntoByteBuffer(
+ vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
+ this, bb, offset,
+ (buf, off, v) -> {
+ ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
+ v.stOp(wb, off,
+ (wb_, o, i, e) -> wb_.putInt(o + i * 4, e));
+ });
}
// End of low-level memory operations.
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java
index 11a468cf10b..c1c1aea390a 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java
@@ -33,6 +33,7 @@ import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.UnaryOperator;
+import jdk.internal.misc.ScopedMemoryAccess;
import jdk.internal.misc.Unsafe;
import jdk.internal.vm.annotation.ForceInline;
import jdk.internal.vm.vector.VectorSupport;
@@ -3172,15 +3173,14 @@ public abstract class LongVector extends AbstractVector<Long> {
final
LongVector fromByteBuffer0Template(ByteBuffer bb, int offset) {
LongSpecies vsp = vspecies();
- return VectorSupport.load(
- vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
- bufferBase(bb), bufferAddress(bb, offset),
- bb, offset, vsp,
- (buf, off, s) -> {
- ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
- return s.ldOp(wb, off,
- (wb_, o, i) -> wb_.getLong(o + i * 8));
- });
+ return ScopedMemoryAccess.loadFromByteBuffer(
+ vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
+ bb, offset, vsp,
+ (buf, off, s) -> {
+ ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
+ return s.ldOp(wb, off,
+ (wb_, o, i) -> wb_.getLong(o + i * 8));
+ });
}
// Unchecked storing operations in native byte order.
@@ -3223,15 +3223,14 @@ public abstract class LongVector extends AbstractVector<Long> {
final
void intoByteBuffer0(ByteBuffer bb, int offset) {
LongSpecies vsp = vspecies();
- VectorSupport.store(
- vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
- bufferBase(bb), bufferAddress(bb, offset),
- this, bb, offset,
- (buf, off, v) -> {
- ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
- v.stOp(wb, off,
- (wb_, o, i, e) -> wb_.putLong(o + i * 8, e));
- });
+ ScopedMemoryAccess.storeIntoByteBuffer(
+ vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
+ this, bb, offset,
+ (buf, off, v) -> {
+ ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
+ v.stOp(wb, off,
+ (wb_, o, i, e) -> wb_.putLong(o + i * 8, e));
+ });
}
// End of low-level memory operations.
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java
index 4c0891ac76d..a2ee13e6319 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java
@@ -33,6 +33,7 @@ import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.UnaryOperator;
+import jdk.internal.misc.ScopedMemoryAccess;
import jdk.internal.misc.Unsafe;
import jdk.internal.vm.annotation.ForceInline;
import jdk.internal.vm.vector.VectorSupport;
@@ -3549,15 +3550,14 @@ public abstract class ShortVector extends AbstractVector<Short> {
final
ShortVector fromByteBuffer0Template(ByteBuffer bb, int offset) {
ShortSpecies vsp = vspecies();
- return VectorSupport.load(
- vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
- bufferBase(bb), bufferAddress(bb, offset),
- bb, offset, vsp,
- (buf, off, s) -> {
- ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
- return s.ldOp(wb, off,
- (wb_, o, i) -> wb_.getShort(o + i * 2));
- });
+ return ScopedMemoryAccess.loadFromByteBuffer(
+ vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
+ bb, offset, vsp,
+ (buf, off, s) -> {
+ ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
+ return s.ldOp(wb, off,
+ (wb_, o, i) -> wb_.getShort(o + i * 2));
+ });
}
// Unchecked storing operations in native byte order.
@@ -3600,15 +3600,14 @@ public abstract class ShortVector extends AbstractVector<Short> {
final
void intoByteBuffer0(ByteBuffer bb, int offset) {
ShortSpecies vsp = vspecies();
- VectorSupport.store(
- vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
- bufferBase(bb), bufferAddress(bb, offset),
- this, bb, offset,
- (buf, off, v) -> {
- ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
- v.stOp(wb, off,
- (wb_, o, i, e) -> wb_.putShort(o + i * 2, e));
- });
+ ScopedMemoryAccess.storeIntoByteBuffer(
+ vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
+ this, bb, offset,
+ (buf, off, v) -> {
+ ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
+ v.stOp(wb, off,
+ (wb_, o, i, e) -> wb_.putShort(o + i * 2, e));
+ });
}
// End of low-level memory operations.
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 e6811c6246c..bada3487379 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
@@ -24,33 +24,11 @@
*/
package jdk.incubator.vector;
-import jdk.internal.misc.Unsafe;
import jdk.internal.vm.annotation.ForceInline;
-import java.nio.Buffer;
-import java.nio.ByteBuffer;
import java.util.Objects;
/*non-public*/ class VectorIntrinsics {
- static final Unsafe U = Unsafe.getUnsafe();
-
- static final long BUFFER_ADDRESS
- = U.objectFieldOffset(Buffer.class, "address");
-
- // Buffer.limit
- static final long BUFFER_LIMIT
- = U.objectFieldOffset(Buffer.class, "limit");
-
- // ByteBuffer.hb
- static final long BYTE_BUFFER_HB
- = U.objectFieldOffset(ByteBuffer.class, "hb");
-
- // ByteBuffer.isReadOnly
- static final long BYTE_BUFFER_IS_READ_ONLY
- = U.objectFieldOffset(ByteBuffer.class, "isReadOnly");
-
- /* ============================================================================ */
-
static final int VECTOR_ACCESS_OOB_CHECK = Integer.getInteger("jdk.incubator.vector.VECTOR_ACCESS_OOB_CHECK", 2);
@ForceInline
@@ -133,18 +111,4 @@ import java.util.Objects;
return Math.floorMod(index, Math.abs(size));
}
}
-
- /* ============================================================================ */
-
- /*package-private*/
- @ForceInline
- static Object bufferBase(ByteBuffer bb) {
- return U.getReference(bb, BYTE_BUFFER_HB);
- }
-
- /*package-private*/
- @ForceInline
- static long bufferAddress(ByteBuffer bb, long offset) {
- return U.getLong(bb, BUFFER_ADDRESS) + offset;
- }
}
diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template
index 04979dcbc57..2fb3ae856cf 100644
--- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template
+++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template
@@ -33,6 +33,7 @@ import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.UnaryOperator;
+import jdk.internal.misc.ScopedMemoryAccess;
import jdk.internal.misc.Unsafe;
import jdk.internal.vm.annotation.ForceInline;
import jdk.internal.vm.vector.VectorSupport;
@@ -4517,15 +4518,14 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
final
$abstractvectortype$ fromByteBuffer0Template(ByteBuffer bb, int offset) {
$Type$Species vsp = vspecies();
- return VectorSupport.load(
- vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
- bufferBase(bb), bufferAddress(bb, offset),
- bb, offset, vsp,
- (buf, off, s) -> {
- ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
- return s.ldOp(wb, off,
- (wb_, o, i) -> wb_.get{#if[byte]?(:$Type$(}o + i * $sizeInBytes$));
- });
+ return ScopedMemoryAccess.loadFromByteBuffer(
+ vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
+ bb, offset, vsp,
+ (buf, off, s) -> {
+ ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
+ return s.ldOp(wb, off,
+ (wb_, o, i) -> wb_.get{#if[byte]?(:$Type$(}o + i * $sizeInBytes$));
+ });
}
// Unchecked storing operations in native byte order.
@@ -4568,15 +4568,14 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
final
void intoByteBuffer0(ByteBuffer bb, int offset) {
$Type$Species vsp = vspecies();
- VectorSupport.store(
- vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
- bufferBase(bb), bufferAddress(bb, offset),
- this, bb, offset,
- (buf, off, v) -> {
- ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
- v.stOp(wb, off,
- (wb_, o, i, e) -> wb_.put{#if[byte]?(:$Type$(}o + i * $sizeInBytes$, e));
- });
+ ScopedMemoryAccess.storeIntoByteBuffer(
+ vsp.vectorType(), vsp.elementType(), vsp.laneCount(),
+ this, bb, offset,
+ (buf, off, v) -> {
+ ByteBuffer wb = wrapper(buf, NATIVE_ENDIAN);
+ v.stOp(wb, off,
+ (wb_, o, i, e) -> wb_.put{#if[byte]?(:$Type$(}o + i * $sizeInBytes$, e));
+ });
}
// End of low-level memory operations.
diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/Reporter.java b/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/Reporter.java
index 2ac7741ce46..d4499c847c0 100644
--- a/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/Reporter.java
+++ b/src/jdk.javadoc/share/classes/jdk/javadoc/doclet/Reporter.java
@@ -94,6 +94,12 @@ public interface Reporter {
* The positions are all 0-based character offsets from the beginning of content of the file.
* The positions should satisfy the relation {@code start <= pos <= end}.
*
+ * @implSpec
+ * This implementation always throws {@code UnsupportedOperationException}.
+ * The implementation provided by the {@code javadoc} tool to
+ * {@link Doclet#init(Locale, Reporter) initialize} a doclet
+ * overrides this implementation.
+ *
* @param kind the kind of diagnostic
* @param file the file
* @param start the beginning of the enclosing range
@@ -103,7 +109,9 @@ public interface Reporter {
*
* @since 17
*/
- void print(Diagnostic.Kind kind, FileObject file, int start, int pos, int end, String message);
+ default void print(Diagnostic.Kind kind, FileObject file, int start, int pos, int end, String message) {
+ throw new UnsupportedOperationException();
+ }
/**
* Returns a writer that can be used to write non-diagnostic output,
diff --git a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacDmgBundler.java b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacDmgBundler.java
index 947b04797a0..709f1f96bf7 100644
--- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacDmgBundler.java
+++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacDmgBundler.java
@@ -346,7 +346,11 @@ public class MacDmgBundler extends MacBaseInstallerBundler {
"-volname", APP_NAME.fetchFrom(params),
"-ov", protoDMG.toAbsolutePath().toString(),
"-fs", "HFS+");
- IOUtils.exec(pb, false, null, true, Executor.INFINITE_TIMEOUT);
+ new RetryExecutor()
+ .setMaxAttemptsCount(10)
+ .setAttemptTimeoutMillis(3000)
+ .setWriteOutputToFile(true)
+ .execute(pb);
}
// mount temp image
diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/RetryExecutor.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/RetryExecutor.java
index 6043fc7b187..7ffbbfb8e31 100644
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/RetryExecutor.java
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/RetryExecutor.java
@@ -32,6 +32,7 @@ public final class RetryExecutor {
public RetryExecutor() {
setMaxAttemptsCount(5);
setAttemptTimeoutMillis(2 * 1000);
+ setWriteOutputToFile(false);
}
public RetryExecutor setMaxAttemptsCount(int v) {
@@ -44,6 +45,11 @@ public final class RetryExecutor {
return this;
}
+ RetryExecutor setWriteOutputToFile(boolean v) {
+ writeOutputToFile = v;
+ return this;
+ }
+
public RetryExecutor setExecutorInitializer(Consumer<Executor> v) {
executorInitializer = v;
return this;
@@ -69,11 +75,13 @@ public final class RetryExecutor {
}
public void execute(String cmdline[]) throws IOException {
- executeLoop(() -> Executor.of(cmdline));
+ executeLoop(() ->
+ Executor.of(cmdline).setWriteOutputToFile(writeOutputToFile));
}
public void execute(ProcessBuilder pb) throws IOException {
- executeLoop(() -> Executor.of(pb));
+ executeLoop(() ->
+ Executor.of(pb).setWriteOutputToFile(writeOutputToFile));
}
private void executeLoop(Supplier<Executor> execSupplier) throws IOException {
@@ -109,4 +117,5 @@ public final class RetryExecutor {
private boolean aborted;
private int attempts;
private int timeoutMillis;
+ private boolean writeOutputToFile;
}
diff --git a/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpChannelImpl.java b/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpChannelImpl.java
index 5a7ca3cc6c1..0b9a152d623 100644
--- a/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpChannelImpl.java
+++ b/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpChannelImpl.java
@@ -71,7 +71,6 @@ import static sun.nio.ch.sctp.ResultContainer.SHUTDOWN;
/**
* An implementation of an SctpChannel
*/
-@SuppressWarnings("removal")
public class SctpChannelImpl extends SctpChannel
implements SelChImpl
{
@@ -188,6 +187,7 @@ public class SctpChannelImpl extends SctpChannel
SctpNet.throwAlreadyBoundException();
InetSocketAddress isa = (local == null) ?
new InetSocketAddress(0) : Net.checkAddress(local);
+ @SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkListen(isa.getPort());
@@ -358,6 +358,7 @@ public class SctpChannelImpl extends SctpChannel
synchronized (sendLock) {
ensureOpenAndUnconnected();
InetSocketAddress isa = Net.checkAddress(endpoint);
+ @SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null)
sm.checkConnect(isa.getAddress().getHostAddress(),
@@ -1089,6 +1090,11 @@ public class SctpChannelImpl extends SctpChannel
boolean unordered, int ppid) throws IOException;
static {
+ loadSctpLibrary();
+ }
+
+ @SuppressWarnings("removal")
+ private static void loadSctpLibrary() {
IOUtil.load(); /* loads nio & net native libraries */
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
diff --git a/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpNet.java b/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpNet.java
index cfbf4d5968d..e3b5c1b60c1 100644
--- a/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpNet.java
+++ b/src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpNet.java
@@ -40,8 +40,8 @@ import sun.nio.ch.Net;
import com.sun.nio.sctp.SctpSocketOption;
import static com.sun.nio.sctp.SctpStandardSocketOptions.*;
-@SuppressWarnings("removal")
public class SctpNet {
+ @SuppressWarnings("removal")
private static final String osName = AccessController.doPrivileged(
(PrivilegedAction<String>) () -> System.getProperty("os.name"));
@@ -104,6 +104,7 @@ public class SctpNet {
private static Set<SocketAddress> getRevealedLocalAddressSet(
SocketAddress[] saa)
{
+ @SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
Set<SocketAddress> set = new HashSet<>(saa.length);
for (SocketAddress sa : saa) {
@@ -113,7 +114,7 @@ public class SctpNet {
}
private static SocketAddress getRevealedLocalAddress(SocketAddress sa,
- SecurityManager sm)
+ @SuppressWarnings("removal") SecurityManager sm)
{
if (sm == null || sa == null)
return sa;
@@ -336,6 +337,11 @@ public class SctpNet {
static native void init();
static {
+ loadSctpLibrary();
+ }
+
+ @SuppressWarnings("removal")
+ private static void loadSctpLibrary() {
IOUtil.load(); // loads nio & net native libraries
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
diff --git a/test/hotspot/jtreg/ProblemList-Xcomp.txt b/test/hotspot/jtreg/ProblemList-Xcomp.txt
index 89642be69a5..376d22908db 100644
--- a/test/hotspot/jtreg/ProblemList-Xcomp.txt
+++ b/test/hotspot/jtreg/ProblemList-Xcomp.txt
@@ -31,4 +31,4 @@ compiler/intrinsics/bmi/verifycode/BzhiTestI2L.java 8268033 generic-x64
vmTestbase/nsk/jvmti/SetFieldAccessWatch/setfldw001/TestDescription.java 8205957 generic-all
-vmTestbase/vm/mlvm/mixed/stress/regression/b6969574/INDIFY_Test.java 8265295 windows-x64
+vmTestbase/vm/mlvm/mixed/stress/regression/b6969574/INDIFY_Test.java 8265295 linux-x64,windows-x64
diff --git a/test/hotspot/jtreg/ProblemList-zgc.txt b/test/hotspot/jtreg/ProblemList-zgc.txt
index 7f5566a963d..b792278fe9d 100644
--- a/test/hotspot/jtreg/ProblemList-zgc.txt
+++ b/test/hotspot/jtreg/ProblemList-zgc.txt
@@ -39,4 +39,4 @@ serviceability/sa/ClhsdbFindPC.java#id3 8268722 macosx-x
serviceability/sa/ClhsdbPmap.java#id1 8268722 macosx-x64
serviceability/sa/ClhsdbPstack.java#id1 8268722 macosx-x64
serviceability/sa/TestJmapCore.java 8268722,8268283 macosx-x64,linux-aarch64
-serviceability/sa/TestJmapCoreMetaspace.java 8268722,8268636 macosx-x64,linux-x64
+serviceability/sa/TestJmapCoreMetaspace.java 8268722,8268636 generic-all
diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt
index f136d39fb15..0c54a198d91 100644
--- a/test/hotspot/jtreg/ProblemList.txt
+++ b/test/hotspot/jtreg/ProblemList.txt
@@ -70,7 +70,6 @@ compiler/whitebox/MakeMethodNotCompilableTest.java 8265360 macosx-aarch64
compiler/codecache/jmx/PoolsIndependenceTest.java 8264632 macosx-x64
-compiler/intrinsics/VectorizedMismatchTest.java 8268482 windows-x64
#############################################################################
@@ -111,7 +110,7 @@ resourcehogs/serviceability/sa/TestHeapDumpForLargeArray.java 8262386 generic-al
serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatIntervalTest.java 8214032 generic-all
serviceability/jvmti/HeapMonitor/MyPackage/HeapMonitorStatArrayCorrectnessTest.java 8224150 generic-all
serviceability/jvmti/ModuleAwareAgents/ThreadStart/MAAThreadStart.java 8225354 windows-all
-serviceability/dcmd/gc/RunFinalizationTest.java 8227120 linux-x64
+serviceability/dcmd/gc/RunFinalizationTest.java 8227120 linux-all,windows-x64
serviceability/jvmti/CompiledMethodLoad/Zombie.java 8245877 linux-aarch64
#############################################################################
diff --git a/test/hotspot/jtreg/TEST.groups b/test/hotspot/jtreg/TEST.groups
index a8d3511dbdf..89071c0fcba 100644
--- a/test/hotspot/jtreg/TEST.groups
+++ b/test/hotspot/jtreg/TEST.groups
@@ -71,6 +71,29 @@ hotspot_native_sanity = \
hotspot_containers = \
containers
+hotspot_vector_1 = \
+ compiler/c2/cr6340864 \
+ compiler/codegen \
+ compiler/loopopts/superword \
+ compiler/vectorapi \
+ compiler/vectorization \
+ -compiler/codegen/aes \
+ -compiler/codegen/Test6875866.java \
+ -compiler/codegen/Test6935535.java \
+ -compiler/codegen/TestGCMStorePlacement.java \
+ -compiler/codegen/TestTrichotomyExpressions.java \
+ -compiler/loopopts/superword/Vec_MulAddS2I.java \
+ -compiler/vectorapi/VectorRebracket128Test.java
+
+hotspot_vector_2 = \
+ compiler/intrinsics \
+ compiler/codegen/aes \
+ compiler/codegen/Test6875866.java \
+ compiler/codegen/Test6935535.java \
+ compiler/loopopts/superword/Vec_MulAddS2I.java \
+ compiler/vectorapi/VectorRebracket128Test.java \
+ -compiler/intrinsics/string/TestStringLatin1IndexOfChar.java
+
tier1_common = \
sanity/BasicVMTest.java \
gtest/GTestWrapper.java \
diff --git a/test/hotspot/jtreg/compiler/arraycopy/TestCloneAccess.java b/test/hotspot/jtreg/compiler/arraycopy/TestCloneAccess.java
index efe22f9228b..a0da0741cad 100644
--- a/test/hotspot/jtreg/compiler/arraycopy/TestCloneAccess.java
+++ b/test/hotspot/jtreg/compiler/arraycopy/TestCloneAccess.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -25,6 +25,8 @@
* @test
* @bug 8248791
* @summary Test cloning with more than 8 (=ArrayCopyLoadStoreMaxElem) where loads are wrongly replaced by zero.
+ * @requires vm.compiler2.enabled | vm.graal.enabled
+ *
* @run main/othervm -XX:-ReduceBulkZeroing
* -XX:CompileCommand=dontinline,compiler.arraycopy.TestCloneAccess::*
* compiler.arraycopy.TestCloneAccess
diff --git a/test/hotspot/jtreg/compiler/arraycopy/TestCloneAccessStressGCM.java b/test/hotspot/jtreg/compiler/arraycopy/TestCloneAccessStressGCM.java
index 0b259681ac4..5c910a4d293 100644
--- a/test/hotspot/jtreg/compiler/arraycopy/TestCloneAccessStressGCM.java
+++ b/test/hotspot/jtreg/compiler/arraycopy/TestCloneAccessStressGCM.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
* @bug 8235332 8248226
* @summary Test cloning with more than 8 (=ArrayCopyLoadStoreMaxElem) fields with StressGCM
* @library /
+ * @requires vm.compiler2.enabled | vm.graal.enabled
*
* @run main/othervm -Xbatch
* -XX:CompileCommand=dontinline,compiler.arraycopy.TestCloneAccessStressGCM::test
diff --git a/test/hotspot/jtreg/compiler/c2/TestJumpTable.java b/test/hotspot/jtreg/compiler/c2/TestJumpTable.java
index a7d1a803452..f624855eaa9 100644
--- a/test/hotspot/jtreg/compiler/c2/TestJumpTable.java
+++ b/test/hotspot/jtreg/compiler/c2/TestJumpTable.java
@@ -25,6 +25,8 @@
* @test
* @bug 8229855 8238812
* @summary Test jump table with key value that gets out of bounds after loop unrolling.
+ * @requires vm.compiler2.enabled
+ *
* @run main/othervm -XX:CompileCommand=dontinline,compiler.c2.TestJumpTable::test*
* -Xbatch -XX:+UnlockDiagnosticVMOptions -XX:-TieredCompilation -XX:-UseSwitchProfiling
* compiler.c2.TestJumpTable
diff --git a/test/hotspot/jtreg/compiler/c2/TestReplaceEquivPhis.java b/test/hotspot/jtreg/compiler/c2/TestReplaceEquivPhis.java
index 229df93e5c4..1fc767f8dfc 100644
--- a/test/hotspot/jtreg/compiler/c2/TestReplaceEquivPhis.java
+++ b/test/hotspot/jtreg/compiler/c2/TestReplaceEquivPhis.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020, Huawei Technologies Co., Ltd. All rights reserved.
+ * Copyright (c) 2020, 2021, Huawei Technologies Co., Ltd. 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,6 +25,7 @@
* @test
* @bug 8243670
* @summary Unexpected test result caused by C2 MergeMemNode::Ideal
+ * @requires vm.compiler2.enabled
*
* @run main/othervm -Xcomp -XX:-SplitIfBlocks
* -XX:CompileOnly=compiler.c2.TestReplaceEquivPhis::test
diff --git a/test/hotspot/jtreg/compiler/c2/TestShiftRightAndAccumulate.java b/test/hotspot/jtreg/compiler/c2/TestShiftRightAndAccumulate.java
index 517bed22b14..7b083cb79a8 100644
--- a/test/hotspot/jtreg/compiler/c2/TestShiftRightAndAccumulate.java
+++ b/test/hotspot/jtreg/compiler/c2/TestShiftRightAndAccumulate.java
@@ -25,8 +25,17 @@
* @test
* @bug 8260585
* @summary AArch64: Wrong code generated for shifting right and accumulating four unsigned short integers.
+ *
* @run main/othervm compiler.c2.TestShiftRightAndAccumulate
* @run main/othervm -Xcomp compiler.c2.TestShiftRightAndAccumulate
+ */
+
+/**
+ * @test
+ * @bug 8260585
+ * @summary AArch64: Wrong code generated for shifting right and accumulating four unsigned short integers.
+ * @requires vm.compiler2.enabled
+ *
* @run main/othervm -XX:-SuperWordLoopUnrollAnalysis compiler.c2.TestShiftRightAndAccumulate
*/
diff --git a/test/hotspot/jtreg/compiler/codegen/ClearArrayTest.java b/test/hotspot/jtreg/compiler/codegen/ClearArrayTest.java
index d1deb90e5bf..90f57ef3de6 100644
--- a/test/hotspot/jtreg/compiler/codegen/ClearArrayTest.java
+++ b/test/hotspot/jtreg/compiler/codegen/ClearArrayTest.java
@@ -25,7 +25,10 @@
* @test
* @bug 8260716
* @summary Test for correct code generation by the JIT
- * @run main/othervm -Xbatch -XX:CompileCommand=compileonly,*ClearArrayTest.test -XX:+UnlockDiagnosticVMOptions -XX:-IdealizeClearArrayNode compiler.codegen.ClearArrayTest
+ * @run main/othervm -Xbatch -XX:CompileCommand=compileonly,*ClearArrayTest.test
+ * -XX:+IgnoreUnrecognizedVMOptions
+ * -XX:+UnlockDiagnosticVMOptions -XX:-IdealizeClearArrayNode
+ * compiler.codegen.ClearArrayTest
*/
package compiler.codegen;
diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/aarch64/AArch64TestAssembler.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/aarch64/AArch64TestAssembler.java
index b71d2397f71..098095598ba 100644
--- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/aarch64/AArch64TestAssembler.java
+++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/aarch64/AArch64TestAssembler.java
@@ -263,8 +263,8 @@ public class AArch64TestAssembler extends TestAssembler {
@Override
public void emitEpilogue() {
recordMark(config.MARKID_DEOPT_HANDLER_ENTRY);
- recordCall(new HotSpotForeignCallTarget(config.handleDeoptStub), 5, true, null);
- code.emitInt(0x94000000); // bl <imm26>
+ recordCall(new HotSpotForeignCallTarget(config.handleDeoptStub), 4*4, true, null);
+ emitCall(0xdeaddeaddeadL);
}
@Override
@@ -285,7 +285,7 @@ public class AArch64TestAssembler extends TestAssembler {
@Override
public void emitCall(long addr) {
- emitLoadLong(scratchRegister, addr);
+ emitLoadPointer48(scratchRegister, addr);
emitBlr(scratchRegister);
}
@@ -320,20 +320,39 @@ public class AArch64TestAssembler extends TestAssembler {
}
}
+ private void emitLoadPointer32(Register ret, long addr) {
+ long a = addr;
+ long al = a;
+ a >>= 16;
+ long ah = a;
+ a >>= 16;
+ assert a == 0 : "invalid pointer" + Long.toHexString(addr);
+ // Set upper 16 bits first. See MacroAssembler::patch_oop().
+ emitMovz(ret, ((int)ah & 0xffff), 16);
+ emitMovk(ret, ((int)al & 0xffff), 0);
+ }
+
+ private void emitLoadPointer48(Register ret, long addr) {
+ // 48-bit VA
+ long a = addr;
+ emitMovz(ret, ((int)a & 0xffff), 0);
+ a >>= 16;
+ emitMovk(ret, ((int)a & 0xffff), 16);
+ a >>= 16;
+ emitMovk(ret, ((int)a & 0xffff), 32);
+ a >>= 16;
+ assert a == 0 : "invalid pointer" + Long.toHexString(addr);
+ }
+
@Override
public Register emitLoadPointer(HotSpotConstant c) {
recordDataPatchInCode(new ConstantReference((VMConstant) c));
Register ret = newRegister();
if (c.isCompressed()) {
- // Set upper 16 bits first. See MacroAssembler::patch_oop().
- emitMovz(ret, 0xdead, 16);
- emitMovk(ret, 0xdead, 0);
+ emitLoadPointer32(ret, 0xdeaddeadL);
} else {
- // 48-bit VA
- emitMovz(ret, 0xdead, 0);
- emitMovk(ret, 0xdead, 16);
- emitMovk(ret, 0xdead, 32);
+ emitLoadPointer48(ret, 0xdeaddeaddeadL);
}
return ret;
}
diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jpda/SocketIOPipe.java b/test/hotspot/jtreg/vmTestbase/nsk/share/jpda/SocketIOPipe.java
index 934f166a304..57fbb7a6915 100644
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/jpda/SocketIOPipe.java
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jpda/SocketIOPipe.java
@@ -234,7 +234,7 @@ public class SocketIOPipe extends Log.Logger implements Finalizable {
public SocketConnection getConnection() {
synchronized (this) {
- while (!connection.isConnected() && error != null) {
+ while (!connection.isConnected() && error == null) {
try {
wait();
} catch (InterruptedException e) {
diff --git a/test/jaxp/javax/xml/jaxp/unittest/bcel/UtilityTest.java b/test/jaxp/javax/xml/jaxp/unittest/bcel/UtilityTest.java
new file mode 100644
index 00000000000..56545698778
--- /dev/null
+++ b/test/jaxp/javax/xml/jaxp/unittest/bcel/UtilityTest.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 bcel;
+
+import com.sun.org.apache.bcel.internal.classfile.Utility;
+import java.util.Base64;
+import org.testng.annotations.Test;
+
+/*
+ * @test
+ * @bug 8256919
+ * @modules java.xml/com.sun.org.apache.bcel.internal.classfile
+ * @run testng bcel.UtilityTest
+ * @summary Tests the Utility.
+ */
+public class UtilityTest {
+
+ /*
+ * @bug 8256919
+ * Verifies the encode method.
+ */
+ @Test
+ public void test() throws Exception {
+ /**
+ * public class Hello {
+ * public void hello(){
+ * System.out.println("Hello,world");
+ * }
+ * public static void main(String[] args) {
+ * Hello hello = new Hello();
+ * hello.hello();
+ * }
+ * }
+ * javac Hello.java
+ * cat Hello.class |base64
+ */
+ String bytecodeBase64 = "cHVibGljIGNsYXNzIEhlbGxvIHsKICAgIHB1YmxpYyB2b2lkIGhlbGxvKCl7CiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJIZWxsbyx3b3JsZCIpOwogICAgfQogICAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nW10gYXJncykgewogICAgICAgIEhlbGxvIGhlbGxvID0gbmV3IEhlbGxvKCk7CiAgICAgICAgaGVsbG8uaGVsbG8oKTsKICAgIH0KfQo=";
+ byte[] bytecode = Base64.getDecoder().decode(bytecodeBase64);
+ // encode regression:
+ //(jdk1.8.0_171)$l$8b$I$A$A$A$A$A$A$AM$8e$c1$O$c2$m$QD$ef$7c$c5$a6$tH$M$3f$60$bc$7b$ef$d1x$c0$96$b4$q$5b$m$ec$d6$c6$Y$fe$dd$C$g$3b$c7$99$9d$b7$T$d7$H$ba$B$G4Dp$b5$88$B$de$Cv$c5$W$3c$83$ha$$$beT$z$u$ea_$c4v$d1ae$j$93$f3$8c$5ev$b5$7c$daB$c2$b1S$e7z$9a$8f$qb$c3$3f$e0b$9c$97$3d$ef$d5$e9v$H$93$sR$f0$a7$b7$Z$f5$v$5c$c0$db$ad9$f2K$z$aa$a1$9e$8fv$WY$7c$A$93C$7bZ$ce$A$A$A
+ //(jdk1.8.0_251)$l$8b$I$A$A$A$A$A$A$A
+ String classname = Utility.encode(bytecode,true);
+ /* attempting to decode would result in an exception:
+ * java.io.EOFException: Unexpected end of ZLIB input stream
+ *if encode is not done properly
+ */
+ Utility.decode(classname, true);
+ }
+
+}
diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt
index 64a656548ac..636233e5c97 100644
--- a/test/jdk/ProblemList.txt
+++ b/test/jdk/ProblemList.txt
@@ -526,6 +526,7 @@ java/awt/Robot/Delay/InterruptOfDelay.java 8265986 macosx-all
java/awt/MenuBar/TestNoScreenMenuBar.java 8265987 macosx-all
java/awt/Graphics2D/DrawString/DrawRotatedStringUsingRotatedFont.java 8266283 generic-all
+java/awt/KeyboardFocusmanager/TypeAhead/ButtonActionKeyTest/ButtonActionKeyTest.java 8257529 windows-x64
############################################################################
@@ -741,6 +742,7 @@ javax/swing/Popup/TaskbarPositionTest.java 8065097 macosx-all,linux-all
javax/swing/JEditorPane/6917744/bug6917744.java 8213124 macosx-all
javax/swing/JRootPane/4670486/bug4670486.java 8042381 macosx-all
javax/swing/JPopupMenu/4634626/bug4634626.java 8017175 macosx-all
+javax/swing/JFileChooser/FileSystemView/SystemIconTest.java 8268280 windows-x64
sanity/client/SwingSet/src/ToolTipDemoTest.java 8225012 windows-all,macosx-all
sanity/client/SwingSet/src/ScrollPaneDemoTest.java 8225013 linux-all
diff --git a/test/jdk/java/lang/invoke/MethodHandlesProxiesTest.java b/test/jdk/java/lang/invoke/MethodHandlesProxiesTest.java
index ff83a4ed935..48624b1c925 100644
--- a/test/jdk/java/lang/invoke/MethodHandlesProxiesTest.java
+++ b/test/jdk/java/lang/invoke/MethodHandlesProxiesTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -22,7 +22,7 @@
*/
/* @test
- * @bug 8206955
+ * @bug 8206955 8269351
* @run testng/othervm -ea -esa test.java.lang.invoke.MethodHandlesProxiesTest
*/
@@ -99,4 +99,24 @@ public class MethodHandlesProxiesTest {
assertEquals(proxy.b(), "OB");
assertEquals(proxy.c(), "OC");
}
+
+ public sealed interface Intf permits NonSealedInterface {
+ String m();
+ }
+
+ public non-sealed interface NonSealedInterface extends Intf {
+ }
+
+ @Test(expectedExceptions = { IllegalArgumentException.class })
+ public void testSealedInterface() {
+ MethodHandle target = MethodHandles.constant(String.class, "Sealed");
+ MethodHandleProxies.asInterfaceInstance(Intf.class, target);
+ }
+
+ @Test
+ public void testNonSealedInterface() {
+ MethodHandle target = MethodHandles.constant(String.class, "Non-Sealed");
+ NonSealedInterface proxy = MethodHandleProxies.asInterfaceInstance(NonSealedInterface.class, target);
+ assertEquals(proxy.m(), "Non-Sealed");
+ }
}
diff --git a/test/jdk/java/lang/invoke/t8150782/TestAccessClass.java b/test/jdk/java/lang/invoke/t8150782/TestAccessClass.java
index c3e01c922cb..08117e54b19 100644
--- a/test/jdk/java/lang/invoke/t8150782/TestAccessClass.java
+++ b/test/jdk/java/lang/invoke/t8150782/TestAccessClass.java
@@ -24,13 +24,17 @@
*/
/* @test
- * @bug 8150782 8207027
- * @compile TestAccessClass.java TestCls.java
+ * @bug 8150782 8207027 8266269
+ * @compile TestAccessClass.java TestCls.java p/Foo.java q/Bar.java
* @run testng/othervm -ea -esa test.java.lang.invoke.t8150782.TestAccessClass
*/
package test.java.lang.invoke.t8150782;
import java.lang.invoke.*;
+import java.lang.reflect.Modifier;
+
+import p.Foo;
+import q.Bar;
import static java.lang.invoke.MethodHandles.*;
@@ -55,13 +59,13 @@ public class TestAccessClass {
}
@Test
- public void returnsSameClassInSamePackage() throws IllegalAccessException, ClassNotFoundException {
+ public void returnsSameClassInSamePackage() throws IllegalAccessException {
Class<?> aClass = lookup().accessClass(Class1.class);
assertEquals(Class1.class, aClass);
}
@Test
- public void returnsSameArrayClassInSamePackage() throws IllegalAccessException, ClassNotFoundException {
+ public void returnsSameArrayClassInSamePackage() throws IllegalAccessException {
Class<?> aClass = lookup().accessClass(Class1[].class);
assertEquals(Class1[].class, aClass);
}
@@ -75,7 +79,7 @@ public class TestAccessClass {
}
@Test(dataProvider = "illegalAccessAccess", expectedExceptions = {IllegalAccessException.class})
- public void illegalAccessExceptionTest(Lookup lookup, Class<?> klass) throws IllegalAccessException, ClassNotFoundException {
+ public void illegalAccessExceptionTest(Lookup lookup, Class<?> klass) throws IllegalAccessException {
lookup.accessClass(klass);
}
@@ -84,4 +88,20 @@ public class TestAccessClass {
lookup().accessClass(TestCls.getPrivateSIC());
}
+ /**
+ * Verify that a protected Q is as accessible as a public Q during linkage
+ * (see JLS 15.12.4.3).
+ */
+ @Test
+ public void protectedInnerClass() throws Throwable {
+ lookup().accessClass(Bar.T_CLS);
+ lookup().accessClass(Bar.T_ARRAY_CLS);
+ MethodHandle mh = lookup().findStatic(Bar.class, "meth", MethodType.methodType(void.class, Bar.T_ARRAY_CLS));
+ mh.invoke(null);
+ }
+
+ @Test(expectedExceptions = {NullPointerException.class})
+ public void illegalArgument() throws IllegalAccessException {
+ lookup().accessClass(null);
+ }
}
diff --git a/test/jdk/java/lang/invoke/t8150782/TestFindClass.java b/test/jdk/java/lang/invoke/t8150782/TestFindClass.java
index afd16dfcd64..a023781cecb 100644
--- a/test/jdk/java/lang/invoke/t8150782/TestFindClass.java
+++ b/test/jdk/java/lang/invoke/t8150782/TestFindClass.java
@@ -24,13 +24,15 @@
*/
/* @test
- * @bug 8150782 8207027
- * @compile TestFindClass.java TestCls.java
+ * @bug 8150782 8207027 8266269
+ * @compile TestFindClass.java TestCls.java p/Foo.java q/Bar.java
* @run testng/othervm -ea -esa test.java.lang.invoke.t8150782.TestFindClass
*/
package test.java.lang.invoke.t8150782;
import java.lang.invoke.*;
+import p.Foo;
+import q.Bar;
import static java.lang.invoke.MethodHandles.*;
@@ -94,4 +96,18 @@ public class TestFindClass {
lookup().findClass(PACKAGE_PREFIX + "TestCls$PrivateSIC");
}
+ /**
+ * Verify that a protected Q is as accessible as a public Q during linkage
+ * (see JLS 15.12.4.3).
+ */
+ @Test
+ public void protectedInnerClass() throws IllegalAccessException, ClassNotFoundException {
+ lookup().findClass("p.Foo$T");
+ lookup().findClass("[Lp.Foo$T;");
+ }
+
+ @Test(expectedExceptions = {NullPointerException.class})
+ public void illegalArgument() throws IllegalAccessException, ClassNotFoundException {
+ lookup().findClass(null);
+ }
}
diff --git a/test/jdk/java/lang/invoke/t8150782/p/Foo.java b/test/jdk/java/lang/invoke/t8150782/p/Foo.java
new file mode 100644
index 00000000000..90640ed1f30
--- /dev/null
+++ b/test/jdk/java/lang/invoke/t8150782/p/Foo.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 p;
+
+public class Foo {
+ protected enum T { ONE }
+}
+
diff --git a/test/jdk/java/lang/invoke/t8150782/q/Bar.java b/test/jdk/java/lang/invoke/t8150782/q/Bar.java
new file mode 100644
index 00000000000..25bcd969ecf
--- /dev/null
+++ b/test/jdk/java/lang/invoke/t8150782/q/Bar.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 q;
+
+import p.Foo;
+
+// access protected inner class Foo.T
+public class Bar extends Foo {
+ public static final Class<?> T_CLS = T.class;
+ public static final Class<?> T_ARRAY_CLS = T[].class;
+
+ public static void meth(T[] arr) {
+ System.out.println("called method");
+ }
+}
diff --git a/test/jdk/java/lang/reflect/Proxy/SealedInterfaceTest.java b/test/jdk/java/lang/reflect/Proxy/SealedInterfaceTest.java
new file mode 100644
index 00000000000..1337248f817
--- /dev/null
+++ b/test/jdk/java/lang/reflect/Proxy/SealedInterfaceTest.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 8269351
+ * @run testng SealedInterfaceTest
+ */
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+import org.testng.annotations.Test;
+import static org.testng.Assert.*;
+
+public class SealedInterfaceTest {
+ sealed interface Intf permits NonSealedInterface {
+ void m1();
+ }
+
+ non-sealed interface NonSealedInterface extends Intf {
+ void m2();
+ }
+
+ @Test(expectedExceptions = { IllegalArgumentException.class })
+ public void testSealedInterface() {
+ Proxy.newProxyInstance(SealedInterfaceTest.class.getClassLoader(),
+ new Class<?>[]{ Intf.class },
+ new InvocationHandler() {
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ return null;
+ }
+ });
+ }
+
+ @Test
+ public void testNonSealedInterface() {
+ Proxy.newProxyInstance(SealedInterfaceTest.class.getClassLoader(),
+ new Class<?>[]{ NonSealedInterface.class },
+ new InvocationHandler() {
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ return null;
+ }
+ });
+ }
+}
diff --git a/test/jdk/jdk/incubator/vector/AbstractVectorLoadStoreTest.java b/test/jdk/jdk/incubator/vector/AbstractVectorLoadStoreTest.java
new file mode 100644
index 00000000000..1ec37d2f70e
--- /dev/null
+++ b/test/jdk/jdk/incubator/vector/AbstractVectorLoadStoreTest.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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.incubator.foreign.MemorySegment;
+import jdk.incubator.foreign.ResourceScope;
+
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+import java.util.function.IntFunction;
+
+public class AbstractVectorLoadStoreTest extends AbstractVectorTest {
+
+ static final Collection<ByteOrder> BYTE_ORDER_VALUES = Set.of(
+ ByteOrder.BIG_ENDIAN, ByteOrder.LITTLE_ENDIAN);
+
+ static final List<IntFunction<ByteBuffer>> BYTE_BUFFER_GENERATORS = List.of(
+ withToString("HB:RW:NE", (int s) -> {
+ return ByteBuffer.allocate(s)
+ .order(ByteOrder.nativeOrder());
+ }),
+ withToString("DB:RW:NE", (int s) -> {
+ return ByteBuffer.allocateDirect(s)
+ .order(ByteOrder.nativeOrder());
+ }),
+ withToString("MS:RW:NE", (int s) -> {
+ return MemorySegment.allocateNative(s, ResourceScope.newImplicitScope())
+ .asByteBuffer()
+ .order(ByteOrder.nativeOrder());
+ })
+ );
+}
diff --git a/test/jdk/jdk/incubator/vector/AbstractVectorTest.java b/test/jdk/jdk/incubator/vector/AbstractVectorTest.java
index 5e137d34ef4..e7d66881d72 100644
--- a/test/jdk/jdk/incubator/vector/AbstractVectorTest.java
+++ b/test/jdk/jdk/incubator/vector/AbstractVectorTest.java
@@ -84,20 +84,6 @@ public class AbstractVectorTest {
};
}
- static final Collection<ByteOrder> BYTE_ORDER_VALUES = Set.of(
- ByteOrder.BIG_ENDIAN, ByteOrder.LITTLE_ENDIAN);
-
- static final List<IntFunction<ByteBuffer>> BYTE_BUFFER_GENERATORS = List.of(
- withToString("HB:RW:NE", (int s) -> {
- return ByteBuffer.allocate(s)
- .order(ByteOrder.nativeOrder());
- }),
- withToString("DB:RW:NE", (int s) -> {
- return ByteBuffer.allocateDirect(s)
- .order(ByteOrder.nativeOrder());
- })
- );
-
static final List<IntFunction<boolean[]>> BOOL_ARRAY_GENERATORS = List.of(
withToString("boolean[i % 2]", (int s) -> {
return fill_boolean(s,
diff --git a/test/jdk/jdk/incubator/vector/Byte128VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Byte128VectorLoadStoreTests.java
index 11472254ec2..ff8f2c16f10 100644
--- a/test/jdk/jdk/incubator/vector/Byte128VectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/Byte128VectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm -XX:-TieredCompilation Byte128VectorLoadStoreTests
*
*/
@@ -42,12 +42,11 @@ import org.testng.annotations.Test;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class Byte128VectorLoadStoreTests extends AbstractVectorTest {
+public class Byte128VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Byte> SPECIES =
ByteVector.SPECIES_128;
diff --git a/test/jdk/jdk/incubator/vector/Byte256VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Byte256VectorLoadStoreTests.java
index a986dd80256..84375800f08 100644
--- a/test/jdk/jdk/incubator/vector/Byte256VectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/Byte256VectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm -XX:-TieredCompilation Byte256VectorLoadStoreTests
*
*/
@@ -42,12 +42,11 @@ import org.testng.annotations.Test;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class Byte256VectorLoadStoreTests extends AbstractVectorTest {
+public class Byte256VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Byte> SPECIES =
ByteVector.SPECIES_256;
diff --git a/test/jdk/jdk/incubator/vector/Byte512VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Byte512VectorLoadStoreTests.java
index b5a472d15e6..e87bcba3c65 100644
--- a/test/jdk/jdk/incubator/vector/Byte512VectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/Byte512VectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm -XX:-TieredCompilation Byte512VectorLoadStoreTests
*
*/
@@ -42,12 +42,11 @@ import org.testng.annotations.Test;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class Byte512VectorLoadStoreTests extends AbstractVectorTest {
+public class Byte512VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Byte> SPECIES =
ByteVector.SPECIES_512;
diff --git a/test/jdk/jdk/incubator/vector/Byte64VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Byte64VectorLoadStoreTests.java
index 384be4ab8fc..73f38468bae 100644
--- a/test/jdk/jdk/incubator/vector/Byte64VectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/Byte64VectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm -XX:-TieredCompilation Byte64VectorLoadStoreTests
*
*/
@@ -42,12 +42,11 @@ import org.testng.annotations.Test;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class Byte64VectorLoadStoreTests extends AbstractVectorTest {
+public class Byte64VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Byte> SPECIES =
ByteVector.SPECIES_64;
diff --git a/test/jdk/jdk/incubator/vector/ByteMaxVectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/ByteMaxVectorLoadStoreTests.java
index 203fe85cbe4..f8c4d2ae417 100644
--- a/test/jdk/jdk/incubator/vector/ByteMaxVectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/ByteMaxVectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED
* -XX:-TieredCompilation ByteMaxVectorLoadStoreTests
*
@@ -46,12 +46,11 @@ import java.lang.invoke.VarHandle;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class ByteMaxVectorLoadStoreTests extends AbstractVectorTest {
+public class ByteMaxVectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Byte> SPECIES =
ByteVector.SPECIES_MAX;
diff --git a/test/jdk/jdk/incubator/vector/Double128VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Double128VectorLoadStoreTests.java
index 28ac74b331f..b361734c8fa 100644
--- a/test/jdk/jdk/incubator/vector/Double128VectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/Double128VectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm -XX:-TieredCompilation Double128VectorLoadStoreTests
*
*/
@@ -43,12 +43,11 @@ import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class Double128VectorLoadStoreTests extends AbstractVectorTest {
+public class Double128VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Double> SPECIES =
DoubleVector.SPECIES_128;
diff --git a/test/jdk/jdk/incubator/vector/Double256VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Double256VectorLoadStoreTests.java
index 366b3d523f6..0bff64fe5f5 100644
--- a/test/jdk/jdk/incubator/vector/Double256VectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/Double256VectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm -XX:-TieredCompilation Double256VectorLoadStoreTests
*
*/
@@ -43,12 +43,11 @@ import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class Double256VectorLoadStoreTests extends AbstractVectorTest {
+public class Double256VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Double> SPECIES =
DoubleVector.SPECIES_256;
diff --git a/test/jdk/jdk/incubator/vector/Double512VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Double512VectorLoadStoreTests.java
index 8a100b947a7..f022a8f7418 100644
--- a/test/jdk/jdk/incubator/vector/Double512VectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/Double512VectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm -XX:-TieredCompilation Double512VectorLoadStoreTests
*
*/
@@ -43,12 +43,11 @@ import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class Double512VectorLoadStoreTests extends AbstractVectorTest {
+public class Double512VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Double> SPECIES =
DoubleVector.SPECIES_512;
diff --git a/test/jdk/jdk/incubator/vector/Double64VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Double64VectorLoadStoreTests.java
index 7e0883933a7..a18318c5e2e 100644
--- a/test/jdk/jdk/incubator/vector/Double64VectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/Double64VectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm -XX:-TieredCompilation Double64VectorLoadStoreTests
*
*/
@@ -43,12 +43,11 @@ import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class Double64VectorLoadStoreTests extends AbstractVectorTest {
+public class Double64VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Double> SPECIES =
DoubleVector.SPECIES_64;
diff --git a/test/jdk/jdk/incubator/vector/DoubleMaxVectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/DoubleMaxVectorLoadStoreTests.java
index 71d8b20eff8..0a3b1391aa2 100644
--- a/test/jdk/jdk/incubator/vector/DoubleMaxVectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/DoubleMaxVectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED
* -XX:-TieredCompilation DoubleMaxVectorLoadStoreTests
*
@@ -47,12 +47,11 @@ import java.nio.ByteBuffer;
import java.nio.DoubleBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class DoubleMaxVectorLoadStoreTests extends AbstractVectorTest {
+public class DoubleMaxVectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Double> SPECIES =
DoubleVector.SPECIES_MAX;
diff --git a/test/jdk/jdk/incubator/vector/Float128VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Float128VectorLoadStoreTests.java
index 7be10f051f6..eb604c93545 100644
--- a/test/jdk/jdk/incubator/vector/Float128VectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/Float128VectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm -XX:-TieredCompilation Float128VectorLoadStoreTests
*
*/
@@ -43,12 +43,11 @@ import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class Float128VectorLoadStoreTests extends AbstractVectorTest {
+public class Float128VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Float> SPECIES =
FloatVector.SPECIES_128;
diff --git a/test/jdk/jdk/incubator/vector/Float256VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Float256VectorLoadStoreTests.java
index a7b53dd1ac7..b76b499604d 100644
--- a/test/jdk/jdk/incubator/vector/Float256VectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/Float256VectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm -XX:-TieredCompilation Float256VectorLoadStoreTests
*
*/
@@ -43,12 +43,11 @@ import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class Float256VectorLoadStoreTests extends AbstractVectorTest {
+public class Float256VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Float> SPECIES =
FloatVector.SPECIES_256;
diff --git a/test/jdk/jdk/incubator/vector/Float512VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Float512VectorLoadStoreTests.java
index 67d12a11c3d..c264e497331 100644
--- a/test/jdk/jdk/incubator/vector/Float512VectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/Float512VectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm -XX:-TieredCompilation Float512VectorLoadStoreTests
*
*/
@@ -43,12 +43,11 @@ import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class Float512VectorLoadStoreTests extends AbstractVectorTest {
+public class Float512VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Float> SPECIES =
FloatVector.SPECIES_512;
diff --git a/test/jdk/jdk/incubator/vector/Float64VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Float64VectorLoadStoreTests.java
index 2993195195f..b6d39590b7c 100644
--- a/test/jdk/jdk/incubator/vector/Float64VectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/Float64VectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm -XX:-TieredCompilation Float64VectorLoadStoreTests
*
*/
@@ -43,12 +43,11 @@ import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class Float64VectorLoadStoreTests extends AbstractVectorTest {
+public class Float64VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Float> SPECIES =
FloatVector.SPECIES_64;
diff --git a/test/jdk/jdk/incubator/vector/FloatMaxVectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/FloatMaxVectorLoadStoreTests.java
index 2bd9b13ea5f..0f60e9424e8 100644
--- a/test/jdk/jdk/incubator/vector/FloatMaxVectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/FloatMaxVectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED
* -XX:-TieredCompilation FloatMaxVectorLoadStoreTests
*
@@ -47,12 +47,11 @@ import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class FloatMaxVectorLoadStoreTests extends AbstractVectorTest {
+public class FloatMaxVectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Float> SPECIES =
FloatVector.SPECIES_MAX;
diff --git a/test/jdk/jdk/incubator/vector/Int128VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Int128VectorLoadStoreTests.java
index afebe565a65..3cb331816fe 100644
--- a/test/jdk/jdk/incubator/vector/Int128VectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/Int128VectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm -XX:-TieredCompilation Int128VectorLoadStoreTests
*
*/
@@ -43,12 +43,11 @@ import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class Int128VectorLoadStoreTests extends AbstractVectorTest {
+public class Int128VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Integer> SPECIES =
IntVector.SPECIES_128;
diff --git a/test/jdk/jdk/incubator/vector/Int256VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Int256VectorLoadStoreTests.java
index 1bb1e992aea..eb3f2f8c67d 100644
--- a/test/jdk/jdk/incubator/vector/Int256VectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/Int256VectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm -XX:-TieredCompilation Int256VectorLoadStoreTests
*
*/
@@ -43,12 +43,11 @@ import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class Int256VectorLoadStoreTests extends AbstractVectorTest {
+public class Int256VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Integer> SPECIES =
IntVector.SPECIES_256;
diff --git a/test/jdk/jdk/incubator/vector/Int512VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Int512VectorLoadStoreTests.java
index 4ecce9322a4..bf63016a445 100644
--- a/test/jdk/jdk/incubator/vector/Int512VectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/Int512VectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm -XX:-TieredCompilation Int512VectorLoadStoreTests
*
*/
@@ -43,12 +43,11 @@ import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class Int512VectorLoadStoreTests extends AbstractVectorTest {
+public class Int512VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Integer> SPECIES =
IntVector.SPECIES_512;
diff --git a/test/jdk/jdk/incubator/vector/Int64VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Int64VectorLoadStoreTests.java
index 6122a398519..8dd1d48fab4 100644
--- a/test/jdk/jdk/incubator/vector/Int64VectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/Int64VectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm -XX:-TieredCompilation Int64VectorLoadStoreTests
*
*/
@@ -43,12 +43,11 @@ import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class Int64VectorLoadStoreTests extends AbstractVectorTest {
+public class Int64VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Integer> SPECIES =
IntVector.SPECIES_64;
diff --git a/test/jdk/jdk/incubator/vector/IntMaxVectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/IntMaxVectorLoadStoreTests.java
index db2840a947a..0c16d119eb4 100644
--- a/test/jdk/jdk/incubator/vector/IntMaxVectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/IntMaxVectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED
* -XX:-TieredCompilation IntMaxVectorLoadStoreTests
*
@@ -47,12 +47,11 @@ import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class IntMaxVectorLoadStoreTests extends AbstractVectorTest {
+public class IntMaxVectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Integer> SPECIES =
IntVector.SPECIES_MAX;
diff --git a/test/jdk/jdk/incubator/vector/LoadSvmlTest.java b/test/jdk/jdk/incubator/vector/LoadSvmlTest.java
new file mode 100644
index 00000000000..a3cbd3a3c52
--- /dev/null
+++ b/test/jdk/jdk/incubator/vector/LoadSvmlTest.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 8269335
+ * @summary Tests SVML shared library is loaded successfully.
+ * @modules jdk.incubator.vector
+ * @requires vm.compiler2.enabled
+ * @requires os.arch == "x86_64" | os.arch == "amd64"
+ * @requires os.family == "linux" | os.family == "windows"
+ * @library /test/lib
+ * @run main LoadSvmlTest
+ */
+
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
+import jdk.incubator.vector.FloatVector;
+import jdk.incubator.vector.VectorOperators;
+import jdk.incubator.vector.Vector;
+import jdk.incubator.vector.VectorSpecies;
+
+
+public class LoadSvmlTest {
+
+ private static class VectorTest {
+
+ static final VectorSpecies<Float> SPECIES = FloatVector.SPECIES_PREFERRED;
+
+ public static void main(String[] args) throws Exception {
+ float a[] = new float [1024];
+ float r[] = new float [1024];
+
+ for (int i = 0; i < a.length; i += SPECIES.length()) {
+ FloatVector av = FloatVector.fromArray(SPECIES, a, i);
+ av.lanewise(VectorOperators.SINH).intoArray(r, i);
+ }
+ }
+ }
+
+ public static void main(String... args) throws Exception {
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+ "-Xmn8m", "-Xlog:library=info",
+ "--add-modules=jdk.incubator.vector",
+ VectorTest.class.getName());
+
+ OutputAnalyzer output = new OutputAnalyzer(pb.start());
+ output.shouldHaveExitValue(0);
+ output.shouldMatch("Loaded library .*svml");
+ }
+}
diff --git a/test/jdk/jdk/incubator/vector/Long128VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Long128VectorLoadStoreTests.java
index 4d3775530c8..232ff397a11 100644
--- a/test/jdk/jdk/incubator/vector/Long128VectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/Long128VectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm -XX:-TieredCompilation Long128VectorLoadStoreTests
*
*/
@@ -43,12 +43,11 @@ import java.nio.ByteBuffer;
import java.nio.LongBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class Long128VectorLoadStoreTests extends AbstractVectorTest {
+public class Long128VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Long> SPECIES =
LongVector.SPECIES_128;
diff --git a/test/jdk/jdk/incubator/vector/Long256VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Long256VectorLoadStoreTests.java
index 107c5826e69..cbb01fc336d 100644
--- a/test/jdk/jdk/incubator/vector/Long256VectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/Long256VectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm -XX:-TieredCompilation Long256VectorLoadStoreTests
*
*/
@@ -43,12 +43,11 @@ import java.nio.ByteBuffer;
import java.nio.LongBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class Long256VectorLoadStoreTests extends AbstractVectorTest {
+public class Long256VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Long> SPECIES =
LongVector.SPECIES_256;
diff --git a/test/jdk/jdk/incubator/vector/Long512VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Long512VectorLoadStoreTests.java
index 77a692f8d09..695067a31c4 100644
--- a/test/jdk/jdk/incubator/vector/Long512VectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/Long512VectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm -XX:-TieredCompilation Long512VectorLoadStoreTests
*
*/
@@ -43,12 +43,11 @@ import java.nio.ByteBuffer;
import java.nio.LongBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class Long512VectorLoadStoreTests extends AbstractVectorTest {
+public class Long512VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Long> SPECIES =
LongVector.SPECIES_512;
diff --git a/test/jdk/jdk/incubator/vector/Long64VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Long64VectorLoadStoreTests.java
index f1735b3e87d..c574a76019f 100644
--- a/test/jdk/jdk/incubator/vector/Long64VectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/Long64VectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm -XX:-TieredCompilation Long64VectorLoadStoreTests
*
*/
@@ -43,12 +43,11 @@ import java.nio.ByteBuffer;
import java.nio.LongBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class Long64VectorLoadStoreTests extends AbstractVectorTest {
+public class Long64VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Long> SPECIES =
LongVector.SPECIES_64;
diff --git a/test/jdk/jdk/incubator/vector/LongMaxVectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/LongMaxVectorLoadStoreTests.java
index 4e7bfb3dcc4..27712230bad 100644
--- a/test/jdk/jdk/incubator/vector/LongMaxVectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/LongMaxVectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED
* -XX:-TieredCompilation LongMaxVectorLoadStoreTests
*
@@ -47,12 +47,11 @@ import java.nio.ByteBuffer;
import java.nio.LongBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class LongMaxVectorLoadStoreTests extends AbstractVectorTest {
+public class LongMaxVectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Long> SPECIES =
LongVector.SPECIES_MAX;
diff --git a/test/jdk/jdk/incubator/vector/Short128VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Short128VectorLoadStoreTests.java
index c1cc783242e..f9ca627a6f6 100644
--- a/test/jdk/jdk/incubator/vector/Short128VectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/Short128VectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm -XX:-TieredCompilation Short128VectorLoadStoreTests
*
*/
@@ -43,12 +43,11 @@ import java.nio.ByteBuffer;
import java.nio.ShortBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class Short128VectorLoadStoreTests extends AbstractVectorTest {
+public class Short128VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Short> SPECIES =
ShortVector.SPECIES_128;
diff --git a/test/jdk/jdk/incubator/vector/Short256VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Short256VectorLoadStoreTests.java
index 164156bd94b..056bad79c20 100644
--- a/test/jdk/jdk/incubator/vector/Short256VectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/Short256VectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm -XX:-TieredCompilation Short256VectorLoadStoreTests
*
*/
@@ -43,12 +43,11 @@ import java.nio.ByteBuffer;
import java.nio.ShortBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class Short256VectorLoadStoreTests extends AbstractVectorTest {
+public class Short256VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Short> SPECIES =
ShortVector.SPECIES_256;
diff --git a/test/jdk/jdk/incubator/vector/Short512VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Short512VectorLoadStoreTests.java
index 5fb455e5881..a1fe2e48749 100644
--- a/test/jdk/jdk/incubator/vector/Short512VectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/Short512VectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm -XX:-TieredCompilation Short512VectorLoadStoreTests
*
*/
@@ -43,12 +43,11 @@ import java.nio.ByteBuffer;
import java.nio.ShortBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class Short512VectorLoadStoreTests extends AbstractVectorTest {
+public class Short512VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Short> SPECIES =
ShortVector.SPECIES_512;
diff --git a/test/jdk/jdk/incubator/vector/Short64VectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/Short64VectorLoadStoreTests.java
index 9df0a192a29..142fce0b536 100644
--- a/test/jdk/jdk/incubator/vector/Short64VectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/Short64VectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm -XX:-TieredCompilation Short64VectorLoadStoreTests
*
*/
@@ -43,12 +43,11 @@ import java.nio.ByteBuffer;
import java.nio.ShortBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class Short64VectorLoadStoreTests extends AbstractVectorTest {
+public class Short64VectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Short> SPECIES =
ShortVector.SPECIES_64;
diff --git a/test/jdk/jdk/incubator/vector/ShortMaxVectorLoadStoreTests.java b/test/jdk/jdk/incubator/vector/ShortMaxVectorLoadStoreTests.java
index 0fc39b17f72..85c2a64b975 100644
--- a/test/jdk/jdk/incubator/vector/ShortMaxVectorLoadStoreTests.java
+++ b/test/jdk/jdk/incubator/vector/ShortMaxVectorLoadStoreTests.java
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
* @run testng/othervm --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED
* -XX:-TieredCompilation ShortMaxVectorLoadStoreTests
*
@@ -47,12 +47,11 @@ import java.nio.ByteBuffer;
import java.nio.ShortBuffer;
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class ShortMaxVectorLoadStoreTests extends AbstractVectorTest {
+public class ShortMaxVectorLoadStoreTests extends AbstractVectorLoadStoreTest {
static final VectorSpecies<Short> SPECIES =
ShortVector.SPECIES_MAX;
diff --git a/test/jdk/jdk/incubator/vector/templates/X-LoadStoreTest.java.template b/test/jdk/jdk/incubator/vector/templates/X-LoadStoreTest.java.template
index c64f87c5370..d88fd6fb284 100644
--- a/test/jdk/jdk/incubator/vector/templates/X-LoadStoreTest.java.template
+++ b/test/jdk/jdk/incubator/vector/templates/X-LoadStoreTest.java.template
@@ -23,7 +23,7 @@
/*
* @test
- * @modules jdk.incubator.vector java.base/jdk.internal.vm.annotation
+ * @modules jdk.incubator.foreign jdk.incubator.vector java.base/jdk.internal.vm.annotation
#if[MaxBit]
* @run testng/othervm --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED
* -XX:-TieredCompilation $vectorteststype$
@@ -57,12 +57,11 @@ import java.nio.$Type$Buffer;
#end[!byte]
import java.nio.ByteOrder;
import java.nio.ReadOnlyBufferException;
-import java.util.Arrays;
import java.util.List;
import java.util.function.*;
@Test
-public class $vectorteststype$ extends AbstractVectorTest {
+public class $vectorteststype$ extends AbstractVectorLoadStoreTest {
#if[MaxBit]
static final VectorSpecies<$Wideboxtype$> SPECIES =
$Type$Vector.SPECIES_MAX;
diff --git a/test/langtools/tools/javac/lambda/considerExceptionTVarInStuckExprs/ConsiderExceptionTVarsInStuckExprs.java b/test/langtools/tools/javac/lambda/considerExceptionTVarInStuckExprs/ConsiderExceptionTVarsInStuckExprs.java
new file mode 100644
index 00000000000..db4a802ea7c
--- /dev/null
+++ b/test/langtools/tools/javac/lambda/considerExceptionTVarInStuckExprs/ConsiderExceptionTVarsInStuckExprs.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 8254571
+ * @summary Erroneous generic type inference in a lambda expression with a checked exception
+ * @compile ConsiderExceptionTVarsInStuckExprs.java
+ */
+
+class ConsiderExceptionTVarsInStuckExprs {
+
+ public static void test() {
+ outer(nested(x -> mightThrow()));
+ outer(nested(ConsiderExceptionTVarsInStuckExprs::mightThrow2));
+ }
+
+ static <A> void outer(Object o) {}
+
+ static <B, C, E extends Throwable> B nested(Fun<C,E> fun) {
+ return null;
+ }
+
+ interface Fun<X, Y extends Throwable> {
+ void m(X t) throws Y;
+ }
+
+ static void mightThrow() throws Exception {}
+ static <C> void mightThrow2(C c) throws Exception {}
+}
diff --git a/test/langtools/tools/javac/patterns/DisambiguateParenthesizedPattern.java b/test/langtools/tools/javac/patterns/DisambiguateParenthesizedPattern.java
index a71a2b5a39b..7e6789315a4 100644
--- a/test/langtools/tools/javac/patterns/DisambiguateParenthesizedPattern.java
+++ b/test/langtools/tools/javac/patterns/DisambiguateParenthesizedPattern.java
@@ -42,6 +42,20 @@ public class DisambiguateParenthesizedPattern {
ExpressionType.EXPRESSION);
test.disambiguationTest("((0x1))",
ExpressionType.EXPRESSION);
+ test.disambiguationTest("(a > b)",
+ ExpressionType.EXPRESSION);
+ test.disambiguationTest("(a >> b)",
+ ExpressionType.EXPRESSION);
+ test.disambiguationTest("(a >>> b)",
+ ExpressionType.EXPRESSION);
+ test.disambiguationTest("(a < b | a > b)",
+ ExpressionType.EXPRESSION);
+ test.disambiguationTest("(a << b | a >> b)",
+ ExpressionType.EXPRESSION);
+ test.disambiguationTest("(a << b || a < b | a >>> b)",
+ ExpressionType.EXPRESSION);
+ test.disambiguationTest("(a < c.d > b)",
+ ExpressionType.PATTERN);
}
private final ParserFactory factory;
diff --git a/test/langtools/tools/javac/patterns/Exhaustiveness.java b/test/langtools/tools/javac/patterns/Exhaustiveness.java
index fc3e217b55f..444b63c2647 100644
--- a/test/langtools/tools/javac/patterns/Exhaustiveness.java
+++ b/test/langtools/tools/javac/patterns/Exhaustiveness.java
@@ -23,7 +23,7 @@
/**
* @test
- * @bug 8262891
+ * @bug 8262891 8268871
* @summary Check exhaustiveness of switches over sealed types.
* @library /tools/lib
* @modules jdk.compiler/com.sun.tools.javac.api
@@ -369,49 +369,6 @@ public class Exhaustiveness extends TestRunner {
""");
}
- private void doTest(Path base, String[] libraryCode, String testCode, String... expectedErrors) throws IOException {
- Path current = base.resolve(".");
- Path libSrc = current.resolve("lib-src");
- for (String code : libraryCode) {
- tb.writeJavaFiles(libSrc, code);
- }
-
- Path libClasses = current.resolve("libClasses");
-
- Files.createDirectories(libClasses);
-
- new JavacTask(tb)
- .options("--enable-preview",
- "-source", JAVA_VERSION)
- .outdir(libClasses)
- .files(tb.findJavaFiles(libSrc))
- .run();
-
- Path src = current.resolve("src");
- tb.writeJavaFiles(src, testCode);
-
- Path classes = current.resolve("libClasses");
-
- Files.createDirectories(libClasses);
-
- var log =
- new JavacTask(tb)
- .options("--enable-preview",
- "-source", JAVA_VERSION,
- "-XDrawDiagnostics",
- "-Xlint:-preview",
- "--class-path", libClasses.toString())
- .outdir(classes)
- .files(tb.findJavaFiles(src))
- .run(expectedErrors.length > 0 ? Task.Expect.FAIL : Task.Expect.SUCCESS)
- .writeAll()
- .getOutputLines(Task.OutputKind.DIRECT);
- if (expectedErrors.length > 0 && !List.of(expectedErrors).equals(log)) {
- throw new AssertionError("Incorrect errors, expected: " + List.of(expectedErrors) +
- ", actual: " + log);
- }
- }
-
@Test
public void testInaccessiblePermitted(Path base) throws IOException {
Path current = base.resolve(".");
@@ -640,4 +597,225 @@ public class Exhaustiveness extends TestRunner {
""");
}
+ @Test
+ public void testExhaustiveTransitive(Path base) throws Exception {
+ doTest(base,
+ new String[]{"""
+ package lib;
+ public sealed interface S permits A, B {}
+ """,
+ """
+ package lib;
+ public final class A implements S {}
+ """,
+ """
+ package lib;
+ public abstract sealed class B implements S permits C, D {}
+ """,
+ """
+ package lib;
+ public final class C extends B {}
+ """,
+ """
+ package lib;
+ public final class D extends B {}
+ """},
+ """
+ package test;
+ import lib.*;
+ public class Test {
+ private int test(S obj, boolean b) {
+ return switch (obj) {
+ case A a -> 0;
+ case C c && b -> 0;
+ case C c -> 0;
+ case D d -> 0;
+ };
+ }
+ }
+ """);
+ }
+
+ @Test
+ public void testNotExhaustiveTransitive(Path base) throws Exception {
+ doTest(base,
+ new String[]{"""
+ package lib;
+ public sealed interface S permits A, B {}
+ """,
+ """
+ package lib;
+ public final class A implements S {}
+ """,
+ """
+ package lib;
+ public abstract sealed class B implements S permits C, D {}
+ """,
+ """
+ package lib;
+ public final class C extends B {}
+ """,
+ """
+ package lib;
+ public final class D extends B {}
+ """},
+ """
+ package test;
+ import lib.*;
+ public class Test {
+ private int test(S obj, boolean b) {
+ return switch (obj) {
+ case A a -> 0;
+ case C c -> 0;
+ case D d && b -> 0;
+ };
+ }
+ }
+ """,
+ "Test.java:5:16: compiler.err.not.exhaustive",
+ "- compiler.note.preview.filename: Test.java, DEFAULT",
+ "- compiler.note.preview.recompile",
+ "1 error");
+ }
+
+ @Test
+ public void testExhaustiveIntersection(Path base) throws Exception {
+ doTest(base,
+ new String[]{"""
+ package lib;
+ public sealed interface S permits A, B {}
+ """,
+ """
+ package lib;
+ public abstract class Base {}
+ """,
+ """
+ package lib;
+ public interface Marker {}
+ """,
+ """
+ package lib;
+ public final class A extends Base implements S, Marker {}
+ """,
+ """
+ package lib;
+ public abstract sealed class B extends Base implements S permits C, D {}
+ """,
+ """
+ package lib;
+ public final class C extends B implements Marker {}
+ """,
+ """
+ package lib;
+ public final class D extends B implements Marker {}
+ """},
+ """
+ package test;
+ import lib.*;
+ public class Test {
+ private <T extends Base & S & Marker> int test(T obj, boolean b) {
+ return switch (obj) {
+ case A a -> 0;
+ case C c && b -> 0;
+ case C c -> 0;
+ case D d -> 0;
+ };
+ }
+ }
+ """);
+ }
+
+ @Test
+ public void testNotExhaustiveIntersection(Path base) throws Exception {
+ doTest(base,
+ new String[]{"""
+ package lib;
+ public sealed interface S permits A, B {}
+ """,
+ """
+ package lib;
+ public abstract class Base {}
+ """,
+ """
+ package lib;
+ public interface Marker {}
+ """,
+ """
+ package lib;
+ public final class A extends Base implements S, Marker {}
+ """,
+ """
+ package lib;
+ public abstract sealed class B extends Base implements S permits C, D {}
+ """,
+ """
+ package lib;
+ public final class C extends B implements Marker {}
+ """,
+ """
+ package lib;
+ public final class D extends B implements Marker {}
+ """},
+ """
+ package test;
+ import lib.*;
+ public class Test {
+ private <T extends Base & S & Marker> int test(T obj, boolean b) {
+ return switch (obj) {
+ case A a -> 0;
+ case C c -> 0;
+ case D d && b -> 0;
+ };
+ }
+ }
+ """,
+ "Test.java:5:16: compiler.err.not.exhaustive",
+ "- compiler.note.preview.filename: Test.java, DEFAULT",
+ "- compiler.note.preview.recompile",
+ "1 error");
+ }
+
+ private void doTest(Path base, String[] libraryCode, String testCode, String... expectedErrors) throws IOException {
+ Path current = base.resolve(".");
+ Path libSrc = current.resolve("lib-src");
+ for (String code : libraryCode) {
+ tb.writeJavaFiles(libSrc, code);
+ }
+
+ Path libClasses = current.resolve("libClasses");
+
+ Files.createDirectories(libClasses);
+
+ new JavacTask(tb)
+ .options("--enable-preview",
+ "-source", JAVA_VERSION)
+ .outdir(libClasses)
+ .files(tb.findJavaFiles(libSrc))
+ .run();
+
+ Path src = current.resolve("src");
+ tb.writeJavaFiles(src, testCode);
+
+ Path classes = current.resolve("libClasses");
+
+ Files.createDirectories(libClasses);
+
+ var log =
+ new JavacTask(tb)
+ .options("--enable-preview",
+ "-source", JAVA_VERSION,
+ "-XDrawDiagnostics",
+ "-Xlint:-preview",
+ "--class-path", libClasses.toString())
+ .outdir(classes)
+ .files(tb.findJavaFiles(src))
+ .run(expectedErrors.length > 0 ? Task.Expect.FAIL : Task.Expect.SUCCESS)
+ .writeAll()
+ .getOutputLines(Task.OutputKind.DIRECT);
+ if (expectedErrors.length > 0 && !List.of(expectedErrors).equals(log)) {
+ throw new AssertionError("Incorrect errors, expected: " + List.of(expectedErrors) +
+ ", actual: " + log);
+ }
+ }
+
}
diff --git a/test/langtools/tools/javac/patterns/Guards.java b/test/langtools/tools/javac/patterns/Guards.java
index b68510571f1..bd289aded0b 100644
--- a/test/langtools/tools/javac/patterns/Guards.java
+++ b/test/langtools/tools/javac/patterns/Guards.java
@@ -46,6 +46,9 @@ public class Guards {
runIfTrue(this::typeGuardIfTrueIfStatement);
runIfTrue(this::typeGuardIfTrueSwitchExpression);
runIfTrue(this::typeGuardIfTrueSwitchStatement);
+ runIfTrue(this::typeGuardAfterParenthesizedTrueSwitchStatement);
+ runIfTrue(this::typeGuardAfterParenthesizedTrueSwitchExpression);
+ runIfTrue(this::typeGuardAfterParenthesizedTrueIfStatement);
}
void run(Function<Object, String> convert) {
@@ -122,6 +125,32 @@ public class Guards {
}
}
+ String typeGuardAfterParenthesizedTrueSwitchStatement(Object o) {
+ switch (o) {
+ case (Integer i) && i == 0: o = String.valueOf(i); return "true";
+ case ((Integer i) && i == 2): o = String.valueOf(i); return "second";
+ case Object x: return "any";
+ }
+ }
+
+ String typeGuardAfterParenthesizedTrueSwitchExpression(Object o) {
+ return switch (o) {
+ case (Integer i) && i == 0: o = String.valueOf(i); yield "true";
+ case ((Integer i) && i == 2): o = String.valueOf(i); yield "second";
+ case Object x: yield "any";
+ };
+ }
+
+ String typeGuardAfterParenthesizedTrueIfStatement(Object o) {
+ if (o != null && o instanceof ((Integer i) && i == 0)) {
+ return "true";
+ } else if (o != null && o instanceof (((Integer i) && i == 2)) && (o = i) != null) {
+ return "second";
+ } else {
+ return "any";
+ }
+ }
+
String testPatternInGuard(Object o) {
if (o instanceof (CharSequence cs && cs instanceof String s)) {
return s;
diff --git a/test/langtools/tools/javac/patterns/LambdaCannotCapturePatternVariables.java b/test/langtools/tools/javac/patterns/LambdaCannotCapturePatternVariables.java
new file mode 100644
index 00000000000..a8dadc59942
--- /dev/null
+++ b/test/langtools/tools/javac/patterns/LambdaCannotCapturePatternVariables.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 8267610
+ * @summary LambdaToMethod cannot capture pattern variables. So the TransPatterns should
+ * transform the pattern variables and symbols to normal variables and symbols.
+ * @compile --enable-preview -source ${jdk.version} LambdaCannotCapturePatternVariables.java
+ * @run main/othervm --enable-preview LambdaCannotCapturePatternVariables
+ */
+
+import java.util.function.Supplier;
+
+public class LambdaCannotCapturePatternVariables {
+
+ public static void main(String[] args) {
+ var testVar = new LambdaCannotCapturePatternVariables();
+ testVar.testInstanceOfPatternVariable(Integer.valueOf(1));
+ testVar.testSwitchPatternVariable(Integer.valueOf(1));
+ testVar.test(Integer.valueOf(1));
+ }
+
+ public Integer testInstanceOfPatternVariable(Object x) {
+ if(x instanceof Number y) {
+ return ((Supplier<Integer>) (() -> {
+ return ((y instanceof Integer z) ? z : 1);
+ })).get();
+ }
+ return null;
+ }
+
+ public Integer testSwitchPatternVariable(Object x) {
+ switch (x) {
+ case Number n: {
+ return ((Supplier<Integer>) (() -> {
+ return ((n instanceof Integer i) ? i : 1);
+ })).get();
+ }
+ default: return null;
+ }
+ }
+
+ // Provided by the user
+ public Integer test(Object x) {
+ Integer bar = 1;
+ return ((x instanceof Number y) ?
+ ((Supplier<Integer>) (() -> {
+ return ((y instanceof Integer z) ? z : bar);
+ })).get() : bar);
+ }
+}
diff --git a/test/langtools/tools/javac/patterns/NestedPatternVariablesBytecode.java b/test/langtools/tools/javac/patterns/NestedPatternVariablesBytecode.java
new file mode 100644
index 00000000000..dbaa158ce69
--- /dev/null
+++ b/test/langtools/tools/javac/patterns/NestedPatternVariablesBytecode.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 8268748
+ * @summary Javac generates error opcodes when using nest pattern variables
+ * @library /tools/lib
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ * jdk.compiler/com.sun.tools.javac.main
+ * jdk.jdeps/com.sun.tools.classfile
+ * @build toolbox.ToolBox toolbox.JavacTask
+ * @run main NestedPatternVariablesBytecode
+ */
+
+import java.nio.file.Path;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.StreamSupport;
+
+import com.sun.tools.classfile.ClassFile;
+import com.sun.tools.classfile.ConstantPoolException;
+import com.sun.tools.classfile.Method;
+import com.sun.tools.classfile.Attribute;
+import com.sun.tools.classfile.Code_attribute;
+import com.sun.tools.classfile.Instruction;
+
+import toolbox.JavacTask;
+import toolbox.TestRunner;
+import toolbox.ToolBox;
+
+public class NestedPatternVariablesBytecode extends TestRunner {
+ private static final String JAVA_VERSION = System.getProperty("java.specification.version");
+ private static final String TEST_METHOD = "test";
+
+ ToolBox tb;
+ ClassFile cf;
+
+ public NestedPatternVariablesBytecode() {
+ super(System.err);
+ tb = new ToolBox();
+ }
+
+ public static void main(String[] args) throws Exception {
+ NestedPatternVariablesBytecode t = new NestedPatternVariablesBytecode();
+ t.runTests();
+ }
+
+ @Test
+ public void testNestedPatternVariablesBytecode() throws Exception {
+ String code = """
+ class NestedPatterVariablesTest {
+ String test(Object o) {
+ if (o instanceof (CharSequence cs && cs instanceof String s)) {
+ return s;
+ }
+ return null;
+ }
+ }""";
+ Path curPath = Path.of(".");
+ new JavacTask(tb)
+ .options("--enable-preview", "-source", JAVA_VERSION)
+ .sources(code)
+ .outdir(curPath)
+ .run();
+
+ cf = ClassFile.read(curPath.resolve("NestedPatterVariablesTest.class"));
+ Method testMethod = Arrays.stream(cf.methods)
+ .filter(m -> isTestMethod(m))
+ .findAny()
+ .get();
+ Code_attribute code_attribute = (Code_attribute) testMethod.attributes.get(Attribute.Code);
+
+ List<String> actualCode = getCodeInstructions(code_attribute);
+ List<String> expectedCode = Arrays.asList(
+ "aload_1", "instanceof", "ifeq", "aload_1", "checkcast", "astore_2", "aload_2", "instanceof",
+ "ifeq", "aload_2", "checkcast", "astore_3", "aload_3", "areturn", "aconst_null", "areturn");
+ tb.checkEqual(expectedCode, actualCode);
+ }
+
+ boolean isTestMethod(Method m) {
+ try {
+ return TEST_METHOD.equals(m.getName(cf.constant_pool));
+ } catch (ConstantPoolException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ List<String> getCodeInstructions(Code_attribute code) {
+ return StreamSupport.stream(code.getInstructions().spliterator(), false)
+ .map(Instruction::getMnemonic)
+ .toList();
+ }
+}
diff --git a/test/langtools/tools/javac/patterns/RawTypeBindingWarning.java b/test/langtools/tools/javac/patterns/RawTypeBindingWarning.java
index 5b87b328c04..bca8e7bdd0f 100644
--- a/test/langtools/tools/javac/patterns/RawTypeBindingWarning.java
+++ b/test/langtools/tools/javac/patterns/RawTypeBindingWarning.java
@@ -2,10 +2,24 @@
* @test /nodynamiccopyright/
* @bug 8263590
* @summary Verify correct warnings are produced for raw types in bindings
- * @compile/ref=RawTypeBindingWarning.out -Xlint:rawtypes -XDrawDiagnostics RawTypeBindingWarning.java
+ * @compile/ref=RawTypeBindingWarning.out -Xlint:rawtypes -XDrawDiagnostics --enable-preview -source ${jdk.version} RawTypeBindingWarning.java
*/
public class RawTypeBindingWarning<T> {
public static boolean t(Object o) {
return o instanceof RawTypeBindingWarning w;
}
+ public static void t2(Object o) {
+ switch (o) {
+ case RawTypeBindingWarning w -> {}
+ default -> {}
+ }
+ switch (o) {
+ case (RawTypeBindingWarning w) -> {}
+ default -> {}
+ }
+ switch (o) {
+ case (RawTypeBindingWarning w && false) -> {}
+ default -> {}
+ }
+ }
}
diff --git a/test/langtools/tools/javac/patterns/RawTypeBindingWarning.out b/test/langtools/tools/javac/patterns/RawTypeBindingWarning.out
index bc04d941777..4c4e36acbe3 100644
--- a/test/langtools/tools/javac/patterns/RawTypeBindingWarning.out
+++ b/test/langtools/tools/javac/patterns/RawTypeBindingWarning.out
@@ -1,2 +1,7 @@
RawTypeBindingWarning.java:9:29: compiler.warn.raw.class.use: RawTypeBindingWarning, RawTypeBindingWarning<T>
-1 warning
+RawTypeBindingWarning.java:13:18: compiler.warn.raw.class.use: RawTypeBindingWarning, RawTypeBindingWarning<T>
+RawTypeBindingWarning.java:17:19: compiler.warn.raw.class.use: RawTypeBindingWarning, RawTypeBindingWarning<T>
+RawTypeBindingWarning.java:21:19: compiler.warn.raw.class.use: RawTypeBindingWarning, RawTypeBindingWarning<T>
+- compiler.note.preview.filename: RawTypeBindingWarning.java, DEFAULT
+- compiler.note.preview.recompile
+4 warnings
diff --git a/test/langtools/tools/javac/patterns/SourceLevelChecks.java b/test/langtools/tools/javac/patterns/SourceLevelChecks.java
new file mode 100644
index 00000000000..c246cd635d2
--- /dev/null
+++ b/test/langtools/tools/javac/patterns/SourceLevelChecks.java
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 8268896
+ * @summary Verify source level checks are performed properly
+ * @library /tools/lib
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ * jdk.compiler/com.sun.tools.javac.main
+ * jdk.compiler/com.sun.tools.javac.util
+ * @build toolbox.ToolBox toolbox.JavacTask
+ * @run main SourceLevelChecks
+*/
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+
+import toolbox.TestRunner;
+import toolbox.JavacTask;
+import toolbox.Task;
+import toolbox.ToolBox;
+
+public class SourceLevelChecks extends TestRunner {
+
+ private static final String JAVA_VERSION = System.getProperty("java.specification.version");
+
+ ToolBox tb;
+
+ public static void main(String... args) throws Exception {
+ new SourceLevelChecks().runTests();
+ }
+
+ SourceLevelChecks() {
+ super(System.err);
+ tb = new ToolBox();
+ }
+
+ public void runTests() throws Exception {
+ runTests(m -> new Object[] { Paths.get(m.getName()) });
+ }
+
+ @Test
+ public void testPattern(Path base) throws Exception {
+ doTest(base,
+ """
+ package test;
+ public class Test {
+ private void test(Integer i) {
+ switch (i) {
+ case Integer d:
+ }
+ }
+ }
+ """,
+ "Test.java:5:26: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.pattern.switch)",
+ "1 error");
+ }
+
+ @Test
+ public void testParenthesizedPatternIf(Path base) throws Exception {
+ doTest(base,
+ """
+ package test;
+ public class Test {
+ private void test(Object o) {
+ if (o instanceof (Integer d)) {
+ }
+ }
+ }
+ """,
+ "Test.java:4:26: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.pattern.switch)",
+ "1 error");
+ }
+
+ @Test
+ public void testParenthesizedPatternSwitch(Path base) throws Exception {
+ doTest(base,
+ """
+ package test;
+ public class Test {
+ private void test(Integer i) {
+ switch (i) {
+ case (Integer d):
+ }
+ }
+ }
+ """,
+ "Test.java:5:18: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.pattern.switch)",
+ "1 error");
+ }
+
+ @Test
+ public void testCaseDefault(Path base) throws Exception {
+ doTest(base,
+ """
+ package test;
+ public class Test {
+ private void test(Integer i) {
+ switch (i) {
+ case default:
+ }
+ }
+ }
+ """,
+ "Test.java:5:18: compiler.err.preview.feature.disabled.plural: (compiler.misc.feature.pattern.switch)",
+ "1 error");
+ }
+
+ private void doTest(Path base, String testCode, String... expectedErrors) throws IOException {
+ Path current = base.resolve(".");
+ Path src = current.resolve("src");
+ Path classes = current.resolve("classes");
+ tb.writeJavaFiles(src, testCode);
+
+ Files.createDirectories(classes);
+
+ var log =
+ new JavacTask(tb)
+ .options("-source", "11",
+ "-Xlint:-options",
+ "-XDrawDiagnostics")
+ .outdir(classes)
+ .files(tb.findJavaFiles(src))
+ .run(Task.Expect.FAIL)
+ .writeAll()
+ .getOutputLines(Task.OutputKind.DIRECT);
+ if (!List.of(expectedErrors).equals(log)) {
+ throw new AssertionError("Incorrect errors, expected: " + List.of(expectedErrors) +
+ ", actual: " + log);
+ }
+ }
+
+}
diff --git a/test/micro/org/openjdk/bench/java/security/AlgorithmConstraintsPermits.java b/test/micro/org/openjdk/bench/java/security/AlgorithmConstraintsPermits.java
new file mode 100644
index 00000000000..3cb9567b92b
--- /dev/null
+++ b/test/micro/org/openjdk/bench/java/security/AlgorithmConstraintsPermits.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2021, Huawei Technologies Co., Ltd. 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.security;
+
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Param;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.State;
+import sun.security.util.DisabledAlgorithmConstraints;
+
+import java.security.AlgorithmConstraints;
+import java.security.CryptoPrimitive;
+import java.util.concurrent.TimeUnit;
+import java.util.EnumSet;
+import java.util.Set;
+
+import static sun.security.util.DisabledAlgorithmConstraints.PROPERTY_TLS_DISABLED_ALGS;
+
+@BenchmarkMode(Mode.AverageTime)
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+@Fork(jvmArgsAppend = {"--add-exports", "java.base/sun.security.util=ALL-UNNAMED"})
+@State(Scope.Thread)
+public class AlgorithmConstraintsPermits {
+
+ AlgorithmConstraints tlsDisabledAlgConstraints;
+ Set<CryptoPrimitive> primitives = EnumSet.of(CryptoPrimitive.KEY_AGREEMENT);
+
+ @Param({"SSLv3", "DES", "NULL", "TLS1.3"})
+ String algorithm;
+
+ @Setup
+ public void setup() {
+ tlsDisabledAlgConstraints = new DisabledAlgorithmConstraints(PROPERTY_TLS_DISABLED_ALGS);
+ }
+
+ @Benchmark
+ public boolean permits() {
+ return tlsDisabledAlgConstraints.permits(primitives, algorithm, null);
+ }
+}
+