diff --git a/src/java.base/share/classes/java/lang/classfile/AttributeMapper.java b/src/java.base/share/classes/java/lang/classfile/AttributeMapper.java index 0e7d625290e..0b46055423a 100644 --- a/src/java.base/share/classes/java/lang/classfile/AttributeMapper.java +++ b/src/java.base/share/classes/java/lang/classfile/AttributeMapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ * @since 22 */ @PreviewFeature(feature = PreviewFeature.Feature.CLASSFILE_API) -public interface AttributeMapper { +public interface AttributeMapper> { /** * Attribute stability indicator diff --git a/src/java.base/share/classes/java/lang/classfile/package-info.java b/src/java.base/share/classes/java/lang/classfile/package-info.java index 921cf9e1a34..6e9ecfe4819 100644 --- a/src/java.base/share/classes/java/lang/classfile/package-info.java +++ b/src/java.base/share/classes/java/lang/classfile/package-info.java @@ -147,7 +147,7 @@ * ClassReader, int)} method for mapping from the classfile format * to an attribute instance, and the * {@link java.lang.classfile.AttributeMapper#writeAttribute(java.lang.classfile.BufWriter, - * java.lang.Object)} method for mapping back to the classfile format. It also + * java.lang.classfile.Attribute)} method for mapping back to the classfile format. It also * contains metadata including the attribute name, the set of classfile entities * where the attribute is applicable, and whether multiple attributes of the * same kind are allowed on a single entity. diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/AttributeHolder.java b/src/java.base/share/classes/jdk/internal/classfile/impl/AttributeHolder.java index 31e1a7f2533..fb9ecc98902 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/AttributeHolder.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/AttributeHolder.java @@ -54,7 +54,7 @@ public void writeTo(BufWriterImpl buf) { } @SuppressWarnings("unchecked") - A get(AttributeMapper am) { + > A get(AttributeMapper am) { for (Attribute a : attributes) if (a.attributeMapper() == am) return (A)a; diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/BoundAttribute.java b/src/java.base/share/classes/jdk/internal/classfile/impl/BoundAttribute.java index d5ed0c14bce..36ef2fa55eb 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/BoundAttribute.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/BoundAttribute.java @@ -148,7 +148,7 @@ public static List> readAttributes(AttributedElement enclosing, Cla mapper = customAttributes.apply(name); } if (mapper != null) { - filled.add((Attribute) Objects.requireNonNull(mapper.readAttribute(enclosing, reader, p))); + filled.add(Objects.requireNonNull(mapper.readAttribute(enclosing, reader, p))); } else { AttributeMapper fakeMapper = new AttributeMapper<>() { @Override diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/Util.java b/src/java.base/share/classes/jdk/internal/classfile/impl/Util.java index 1ff80d76676..a064c40be30 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/Util.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/Util.java @@ -224,7 +224,7 @@ public static MethodTypeDesc methodTypeSymbol(NameAndTypeEntry nat) { } @SuppressWarnings("unchecked") - private static void writeAttribute(BufWriterImpl writer, Attribute attr) { + private static > void writeAttribute(BufWriterImpl writer, Attribute attr) { if (attr instanceof CustomAttribute ca) { var mapper = (AttributeMapper) ca.attributeMapper(); mapper.writeAttribute(writer, (T) ca); diff --git a/src/java.base/share/classes/jdk/internal/vm/Continuation.java b/src/java.base/share/classes/jdk/internal/vm/Continuation.java index 5c1d41c36d9..99d0c62aaec 100644 --- a/src/java.base/share/classes/jdk/internal/vm/Continuation.java +++ b/src/java.base/share/classes/jdk/internal/vm/Continuation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -427,6 +427,7 @@ public boolean isPreempted() { * Pins the current continuation (enters a critical section). * This increments an internal semaphore that, when greater than 0, pins the continuation. */ + @IntrinsicCandidate public static native void pin(); /** @@ -434,6 +435,7 @@ public boolean isPreempted() { * This decrements an internal semaphore that, when equal 0, unpins the current continuation * if pinned with {@link #pin()}. */ + @IntrinsicCandidate public static native void unpin(); /** diff --git a/src/java.base/share/classes/module-info.java b/src/java.base/share/classes/module-info.java index 8c012e30c0a..a11013dc615 100644 --- a/src/java.base/share/classes/module-info.java +++ b/src/java.base/share/classes/module-info.java @@ -270,7 +270,8 @@ jdk.internal.jvmstat, jdk.management, jdk.management.agent, - jdk.internal.vm.ci; + jdk.internal.vm.ci, + jdk.jfr; exports jdk.internal.vm.annotation to java.instrument, jdk.internal.vm.ci, diff --git a/src/java.base/unix/classes/sun/nio/ch/FileKey.java b/src/java.base/unix/classes/sun/nio/ch/FileKey.java index e60e63f073d..119abe4a3b5 100644 --- a/src/java.base/unix/classes/sun/nio/ch/FileKey.java +++ b/src/java.base/unix/classes/sun/nio/ch/FileKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,15 +33,18 @@ */ public class FileKey { - private long st_dev; // ID of device - private long st_ino; // Inode number + private final long st_dev; // ID of device + private final long st_ino; // Inode number - private FileKey() { } + private FileKey(long st_dev, long st_ino) { + this.st_dev = st_dev; + this.st_ino = st_ino; + } public static FileKey create(FileDescriptor fd) throws IOException { - FileKey fk = new FileKey(); - fk.init(fd); - return fk; + long finfo[] = new long[2]; + init(fd, finfo); + return new FileKey(finfo[0], finfo[1]); } @Override @@ -59,10 +62,10 @@ public boolean equals(Object obj) { && (this.st_ino == other.st_ino); } - private native void init(FileDescriptor fd) throws IOException; - private static native void initIDs(); + private static native void init(FileDescriptor fd, long[] finfo) + throws IOException; static { - initIDs(); + IOUtil.load(); } } diff --git a/src/java.base/unix/native/libnio/ch/FileKey.c b/src/java.base/unix/native/libnio/ch/FileKey.c index c3817003b5b..59a866bcaff 100644 --- a/src/java.base/unix/native/libnio/ch/FileKey.c +++ b/src/java.base/unix/native/libnio/ch/FileKey.c @@ -30,29 +30,21 @@ #include "nio_util.h" #include "sun_nio_ch_FileKey.h" -static jfieldID key_st_dev; /* id for FileKey.st_dev */ -static jfieldID key_st_ino; /* id for FileKey.st_ino */ - - -JNIEXPORT void JNICALL -Java_sun_nio_ch_FileKey_initIDs(JNIEnv *env, jclass clazz) -{ - CHECK_NULL(key_st_dev = (*env)->GetFieldID(env, clazz, "st_dev", "J")); - CHECK_NULL(key_st_ino = (*env)->GetFieldID(env, clazz, "st_ino", "J")); -} - - JNIEXPORT void JNICALL -Java_sun_nio_ch_FileKey_init(JNIEnv *env, jobject this, jobject fdo) +Java_sun_nio_ch_FileKey_init(JNIEnv* env, jclass clazz, jobject fdo, + jlongArray finfo) { struct stat fbuf; int res; + jlong deviceAndInode[2]; - RESTARTABLE(fstat(fdval(env, fdo), &fbuf), res); + int fd = fdval(env, fdo); + RESTARTABLE(fstat(fd, &fbuf), res); if (res < 0) { JNU_ThrowIOExceptionWithLastError(env, "fstat failed"); } else { - (*env)->SetLongField(env, this, key_st_dev, (jlong)fbuf.st_dev); - (*env)->SetLongField(env, this, key_st_ino, (jlong)fbuf.st_ino); + deviceAndInode[0] = (jlong)fbuf.st_dev; + deviceAndInode[1] = (jlong)fbuf.st_ino; + (*env)->SetLongArrayRegion(env, finfo, 0, 2, deviceAndInode); } } diff --git a/src/java.base/windows/classes/sun/nio/ch/FileKey.java b/src/java.base/windows/classes/sun/nio/ch/FileKey.java index 8669517f0c5..a900c382e68 100644 --- a/src/java.base/windows/classes/sun/nio/ch/FileKey.java +++ b/src/java.base/windows/classes/sun/nio/ch/FileKey.java @@ -33,16 +33,21 @@ */ public class FileKey { - private int dwVolumeSerialNumber; - private int nFileIndexHigh; - private int nFileIndexLow; + private final int dwVolumeSerialNumber; + private final int nFileIndexHigh; + private final int nFileIndexLow; - private FileKey() { } + private FileKey(int dwVolumeSerialNumber, int nFileIndexHigh, + int nFileIndexLow) { + this.dwVolumeSerialNumber = dwVolumeSerialNumber; + this.nFileIndexHigh = nFileIndexHigh; + this.nFileIndexLow = nFileIndexLow; + } public static FileKey create(FileDescriptor fd) throws IOException { - FileKey fk = new FileKey(); - fk.init(fd); - return fk; + int finfo[] = new int[3]; + init(fd, finfo); + return new FileKey(finfo[0], finfo[1], finfo[2]); } @Override @@ -60,11 +65,10 @@ public boolean equals(Object obj) { && this.nFileIndexLow == other.nFileIndexLow; } - private native void init(FileDescriptor fd) throws IOException; - private static native void initIDs(); + private static native void init(FileDescriptor fd, int[] finfo) + throws IOException; static { IOUtil.load(); - initIDs(); } } diff --git a/src/java.base/windows/native/libnio/ch/FileKey.c b/src/java.base/windows/native/libnio/ch/FileKey.c index 9cd3459aef8..e552ed6b7ae 100644 --- a/src/java.base/windows/native/libnio/ch/FileKey.c +++ b/src/java.base/windows/native/libnio/ch/FileKey.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,32 +30,20 @@ #include "nio_util.h" #include "sun_nio_ch_FileKey.h" -static jfieldID key_volumeSN; /* id for FileKey.dwVolumeSerialNumber */ -static jfieldID key_indexHigh; /* id for FileKey.nFileIndexHigh */ -static jfieldID key_indexLow; /* id for FileKey.nFileIndexLow */ - - -JNIEXPORT void JNICALL -Java_sun_nio_ch_FileKey_initIDs(JNIEnv *env, jclass clazz) -{ - CHECK_NULL(key_volumeSN = (*env)->GetFieldID(env, clazz, "dwVolumeSerialNumber", "I")); - CHECK_NULL(key_indexHigh = (*env)->GetFieldID(env, clazz, "nFileIndexHigh", "I")); - CHECK_NULL(key_indexLow = (*env)->GetFieldID(env, clazz, "nFileIndexLow", "I")); -} - - JNIEXPORT void JNICALL -Java_sun_nio_ch_FileKey_init(JNIEnv *env, jobject this, jobject fdo) +Java_sun_nio_ch_FileKey_init(JNIEnv *env, jclass clazz, jobject fdo, jintArray finfo) { - HANDLE fileHandle = (HANDLE)(handleval(env, fdo)); + HANDLE fileHandle = (HANDLE)handleval(env, fdo); BOOL result; BY_HANDLE_FILE_INFORMATION fileInfo; + jint info[3]; result = GetFileInformationByHandle(fileHandle, &fileInfo); if (result) { - (*env)->SetIntField(env, this, key_volumeSN, fileInfo.dwVolumeSerialNumber); - (*env)->SetIntField(env, this, key_indexHigh, fileInfo.nFileIndexHigh); - (*env)->SetIntField(env, this, key_indexLow, fileInfo.nFileIndexLow); + info[0] = (jint)fileInfo.dwVolumeSerialNumber; + info[1] = (jint)fileInfo.nFileIndexHigh; + info[2] = (jint)fileInfo.nFileIndexLow; + (*env)->SetIntArrayRegion(env, finfo, 0, 3, info); } else { JNU_ThrowIOExceptionWithLastError(env, "GetFileInformationByHandle failed"); } diff --git a/src/java.compiler/share/classes/javax/annotation/processing/Filer.java b/src/java.compiler/share/classes/javax/annotation/processing/Filer.java index 61af2aae0c7..ba9b7ed60ec 100644 --- a/src/java.compiler/share/classes/javax/annotation/processing/Filer.java +++ b/src/java.compiler/share/classes/javax/annotation/processing/Filer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,10 +25,8 @@ package javax.annotation.processing; -import javax.tools.JavaFileManager; import javax.tools.*; import javax.lang.model.element.Element; -import javax.lang.model.element.TypeElement; import javax.lang.model.util.Elements; import java.io.IOException; diff --git a/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java b/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java index fd3cb1cb0f8..4e32f0cdcd8 100644 --- a/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java +++ b/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java @@ -25,10 +25,6 @@ package javax.lang.model; -import java.util.Collections; -import java.util.Set; -import java.util.HashSet; - /** * Source versions of the Java programming language. * diff --git a/src/java.compiler/share/classes/javax/lang/model/element/Element.java b/src/java.compiler/share/classes/javax/lang/model/element/Element.java index 59866114325..129dad29020 100644 --- a/src/java.compiler/share/classes/javax/lang/model/element/Element.java +++ b/src/java.compiler/share/classes/javax/lang/model/element/Element.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,8 +27,6 @@ import java.lang.annotation.Annotation; -import java.lang.annotation.AnnotationTypeMismatchException; -import java.lang.annotation.IncompleteAnnotationException; import java.util.List; import java.util.Set; diff --git a/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java b/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java index a8c3b91f8b5..3f34b179992 100644 --- a/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java +++ b/src/java.compiler/share/classes/javax/lang/model/element/TypeElement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,8 +25,6 @@ package javax.lang.model.element; -import jdk.internal.javac.PreviewFeature; - import java.util.List; import javax.lang.model.type.*; import javax.lang.model.util.*; diff --git a/src/java.compiler/share/classes/javax/lang/model/element/VariableElement.java b/src/java.compiler/share/classes/javax/lang/model/element/VariableElement.java index 07e8c25b8f7..4d2b2582901 100644 --- a/src/java.compiler/share/classes/javax/lang/model/element/VariableElement.java +++ b/src/java.compiler/share/classes/javax/lang/model/element/VariableElement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,8 +25,6 @@ package javax.lang.model.element; -import jdk.internal.javac.PreviewFeature; - import javax.lang.model.util.Elements; import javax.lang.model.type.TypeMirror; import javax.lang.model.type.TypeKind; diff --git a/src/java.compiler/share/classes/javax/lang/model/type/TypeVariable.java b/src/java.compiler/share/classes/javax/lang/model/type/TypeVariable.java index e5ab0458f69..abea88fb6f2 100644 --- a/src/java.compiler/share/classes/javax/lang/model/type/TypeVariable.java +++ b/src/java.compiler/share/classes/javax/lang/model/type/TypeVariable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,8 +28,6 @@ import javax.lang.model.element.Element; import javax.lang.model.element.TypeParameterElement; -import javax.lang.model.util.Types; - /** * Represents a type variable. diff --git a/src/java.compiler/share/classes/javax/lang/model/type/TypeVisitor.java b/src/java.compiler/share/classes/javax/lang/model/type/TypeVisitor.java index 31d75fe7929..f3f76803e8f 100644 --- a/src/java.compiler/share/classes/javax/lang/model/type/TypeVisitor.java +++ b/src/java.compiler/share/classes/javax/lang/model/type/TypeVisitor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,6 @@ package javax.lang.model.type; -import javax.lang.model.element.*; import javax.lang.model.util.*; /** diff --git a/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitorPreview.java b/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitorPreview.java index fed666eb32f..724ebe59379 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitorPreview.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractAnnotationValueVisitorPreview.java @@ -28,7 +28,6 @@ import jdk.internal.javac.PreviewFeature; import static javax.lang.model.SourceVersion.*; -import javax.lang.model.SourceVersion; import javax.annotation.processing.SupportedSourceVersion; import javax.annotation.processing.ProcessingEnvironment; diff --git a/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitorPreview.java b/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitorPreview.java index 66a62b7fcb6..7297e7c0c7b 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitorPreview.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractElementVisitorPreview.java @@ -29,9 +29,6 @@ import javax.annotation.processing.SupportedSourceVersion; import javax.annotation.processing.ProcessingEnvironment; -import javax.lang.model.SourceVersion; -import javax.lang.model.element.ElementVisitor; -import javax.lang.model.element.RecordComponentElement; import static javax.lang.model.SourceVersion.*; /** diff --git a/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor9.java b/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor9.java index b5b9cfb23b0..f802c3bf1b9 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor9.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitor9.java @@ -26,7 +26,6 @@ package javax.lang.model.util; import javax.annotation.processing.SupportedSourceVersion; -import javax.lang.model.type.*; import javax.lang.model.SourceVersion; import static javax.lang.model.SourceVersion.*; diff --git a/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitorPreview.java b/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitorPreview.java index c066f1c2f6f..823bad0748a 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitorPreview.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/AbstractTypeVisitorPreview.java @@ -29,7 +29,6 @@ import javax.annotation.processing.SupportedSourceVersion; import javax.annotation.processing.ProcessingEnvironment; -import javax.lang.model.SourceVersion; import static javax.lang.model.SourceVersion.*; /** diff --git a/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor6.java b/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor6.java index 41ad8ffe218..764f4e32737 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor6.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,6 @@ import javax.lang.model.element.*; import javax.annotation.processing.SupportedSourceVersion; import javax.lang.model.SourceVersion; -import javax.lang.model.element.ElementVisitor; import static javax.lang.model.element.ElementKind.*; import static javax.lang.model.SourceVersion.*; diff --git a/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor9.java b/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor9.java index 4197f539408..89dcb1f51f3 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor9.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitor9.java @@ -28,7 +28,6 @@ import javax.lang.model.element.*; import javax.annotation.processing.SupportedSourceVersion; import javax.lang.model.SourceVersion; -import javax.lang.model.element.ElementVisitor; import static javax.lang.model.SourceVersion.*; /** diff --git a/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitorPreview.java b/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitorPreview.java index 7c3a1166e31..71d5f15fc85 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitorPreview.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/ElementKindVisitorPreview.java @@ -30,7 +30,6 @@ import javax.annotation.processing.SupportedSourceVersion; import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.*; -import javax.lang.model.SourceVersion; import static javax.lang.model.SourceVersion.*; /** diff --git a/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner14.java b/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner14.java index 03a69516b51..2f6fb0e03a0 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner14.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner14.java @@ -30,7 +30,6 @@ import javax.lang.model.element.*; import javax.annotation.processing.SupportedSourceVersion; import javax.lang.model.SourceVersion; -import javax.lang.model.element.ElementVisitor; import static javax.lang.model.SourceVersion.*; /** diff --git a/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner6.java b/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner6.java index c5bde23b47e..bff95313508 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner6.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,7 +27,6 @@ import javax.lang.model.element.*; import javax.annotation.processing.SupportedSourceVersion; -import javax.lang.model.element.ElementVisitor; import javax.lang.model.SourceVersion; import static javax.lang.model.SourceVersion.*; diff --git a/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner7.java b/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner7.java index 51c78c60067..be7fa9908b6 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner7.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner7.java @@ -28,7 +28,6 @@ import javax.lang.model.element.*; import javax.annotation.processing.SupportedSourceVersion; import javax.lang.model.SourceVersion; -import javax.lang.model.element.ElementVisitor; import static javax.lang.model.SourceVersion.*; diff --git a/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner9.java b/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner9.java index a9a66d6c185..d572181b32c 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner9.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/ElementScanner9.java @@ -28,7 +28,6 @@ import javax.lang.model.element.*; import javax.annotation.processing.SupportedSourceVersion; import javax.lang.model.SourceVersion; -import javax.lang.model.element.ElementVisitor; import static javax.lang.model.SourceVersion.*; diff --git a/src/java.compiler/share/classes/javax/lang/model/util/ElementScannerPreview.java b/src/java.compiler/share/classes/javax/lang/model/util/ElementScannerPreview.java index 6e21554132a..85c30afcf2b 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/ElementScannerPreview.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/ElementScannerPreview.java @@ -27,13 +27,9 @@ import jdk.internal.javac.PreviewFeature; -import java.util.List; -import java.util.ArrayList; import javax.annotation.processing.SupportedSourceVersion; import javax.annotation.processing.ProcessingEnvironment; import javax.lang.model.element.*; -import javax.lang.model.SourceVersion; -import javax.lang.model.element.ElementVisitor; import static javax.lang.model.SourceVersion.*; /** diff --git a/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitorPreview.java b/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitorPreview.java index 48182072416..c0444c91060 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitorPreview.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleAnnotationValueVisitorPreview.java @@ -29,7 +29,6 @@ import javax.annotation.processing.SupportedSourceVersion; import javax.annotation.processing.ProcessingEnvironment; -import javax.lang.model.SourceVersion; import static javax.lang.model.SourceVersion.*; /** diff --git a/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor6.java b/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor6.java index 2e8e27eeff0..c28b13d4992 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor6.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,6 @@ import javax.lang.model.element.*; import javax.annotation.processing.SupportedSourceVersion; import javax.lang.model.SourceVersion; -import javax.lang.model.element.ElementVisitor; import static javax.lang.model.SourceVersion.*; diff --git a/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor7.java b/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor7.java index fcd26dda60d..3c71f97b675 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor7.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitor7.java @@ -28,7 +28,6 @@ import javax.lang.model.element.*; import javax.annotation.processing.SupportedSourceVersion; import javax.lang.model.SourceVersion; -import javax.lang.model.element.ElementVisitor; import static javax.lang.model.SourceVersion.*; /** diff --git a/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitorPreview.java b/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitorPreview.java index 6acc8f2da48..79da686ee08 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitorPreview.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleElementVisitorPreview.java @@ -29,9 +29,6 @@ import javax.annotation.processing.SupportedSourceVersion; import javax.annotation.processing.ProcessingEnvironment; -import javax.lang.model.SourceVersion; -import javax.lang.model.element.ElementVisitor; -import javax.lang.model.element.RecordComponentElement; import static javax.lang.model.SourceVersion.*; /** diff --git a/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java b/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java index ce6321d9fd3..9386c027316 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor6.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,6 @@ import javax.annotation.processing.SupportedSourceVersion; import javax.lang.model.SourceVersion; import static javax.lang.model.SourceVersion.*; -import javax.lang.model.type.TypeVisitor; /** diff --git a/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java b/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java index f47314aeeb2..c550a76e4b6 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor7.java @@ -29,7 +29,6 @@ import javax.annotation.processing.SupportedSourceVersion; import javax.lang.model.SourceVersion; import static javax.lang.model.SourceVersion.*; -import javax.lang.model.type.TypeVisitor; /** * A simple visitor of types with default behavior appropriate for the diff --git a/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor9.java b/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor9.java index 8f97b34d547..32174be9949 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor9.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitor9.java @@ -27,7 +27,6 @@ import javax.annotation.processing.SupportedSourceVersion; import javax.lang.model.SourceVersion; -import javax.lang.model.type.IntersectionType; import static javax.lang.model.SourceVersion.*; /** diff --git a/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitorPreview.java b/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitorPreview.java index a058f42937a..1efbe710837 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitorPreview.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/SimpleTypeVisitorPreview.java @@ -29,7 +29,6 @@ import javax.annotation.processing.SupportedSourceVersion; import javax.annotation.processing.ProcessingEnvironment; -import javax.lang.model.SourceVersion; import static javax.lang.model.SourceVersion.*; /** diff --git a/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitorPreview.java b/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitorPreview.java index 703ef744edc..70e0498f565 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitorPreview.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/TypeKindVisitorPreview.java @@ -29,7 +29,6 @@ import javax.annotation.processing.SupportedSourceVersion; import javax.annotation.processing.ProcessingEnvironment; -import javax.lang.model.SourceVersion; import javax.lang.model.type.*; import static javax.lang.model.SourceVersion.*; diff --git a/src/java.compiler/share/classes/javax/lang/model/util/Types.java b/src/java.compiler/share/classes/javax/lang/model/util/Types.java index f6296050ca9..0cea2734e21 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/Types.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/Types.java @@ -25,9 +25,6 @@ package javax.lang.model.util; -import java.lang.annotation.Annotation; -import java.lang.annotation.AnnotationTypeMismatchException; -import java.lang.annotation.IncompleteAnnotationException; import java.util.List; import javax.lang.model.element.*; import javax.lang.model.type.*; diff --git a/src/java.datatransfer/share/classes/java/awt/datatransfer/SystemFlavorMap.java b/src/java.datatransfer/share/classes/java/awt/datatransfer/SystemFlavorMap.java index d481465138b..6b2dc14c05f 100644 --- a/src/java.datatransfer/share/classes/java/awt/datatransfer/SystemFlavorMap.java +++ b/src/java.datatransfer/share/classes/java/awt/datatransfer/SystemFlavorMap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,8 +61,6 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable { */ private static String JavaMIME = "JAVA_DATAFLAVOR:"; - private static final Object FLAVOR_MAP_KEY = new Object(); - /** * The list of valid, decoded text flavor representation classes, in order * from best to worst. diff --git a/src/java.desktop/macosx/classes/com/apple/laf/AquaKeyBindings.java b/src/java.desktop/macosx/classes/com/apple/laf/AquaKeyBindings.java index d64ac90e9ac..60bb3da9f87 100644 --- a/src/java.desktop/macosx/classes/com/apple/laf/AquaKeyBindings.java +++ b/src/java.desktop/macosx/classes/com/apple/laf/AquaKeyBindings.java @@ -388,7 +388,9 @@ LateBoundInputMap getTableInputMap() { "alt shift TAB", "focusHeader", "F8", "focusHeader", "ctrl shift UP", "selectFirstRowExtendSelection", - "ctrl shift DOWN", "selectLastRowExtendSelection" + "ctrl shift DOWN", "selectLastRowExtendSelection", + "ctrl shift RIGHT", "selectLastColumnExtendSelection", + "ctrl shift LEFT", "selectFirstColumnExtendSelection" })); } diff --git a/src/jdk.compiler/share/data/symbols/java.base-N.sym.txt b/src/jdk.compiler/share/data/symbols/java.base-N.sym.txt index fd1bd11f6b9..f14c1fb1a4c 100644 --- a/src/jdk.compiler/share/data/symbols/java.base-N.sym.txt +++ b/src/jdk.compiler/share/data/symbols/java.base-N.sym.txt @@ -462,18 +462,6 @@ class name java/net/Socket method name descriptor (Ljava/lang/String;IZ)V thrownTypes java/io/IOException flags 1 deprecated true runtimeAnnotations @Ljava/lang/Deprecated;(forRemoval=Ztrue,since="1.1") method name descriptor (Ljava/net/InetAddress;IZ)V thrownTypes java/io/IOException flags 1 deprecated true runtimeAnnotations @Ljava/lang/Deprecated;(forRemoval=Ztrue,since="1.1") -class name java/nio/HeapByteBuffer -method name hashCode descriptor ()I flags 1 - -class name java/nio/HeapByteBufferR -method name hashCode descriptor ()I flags 1 - -class name java/nio/HeapCharBuffer -method name hashCode descriptor ()I flags 1 - -class name java/nio/HeapCharBufferR -method name hashCode descriptor ()I flags 1 - class name java/security/Provider header extends java/util/Properties nestMembers java/security/Provider$Service flags 421 innerclass innerClass java/util/Map$Entry outerClass java/util/Map innerClassName Entry flags 609 diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/StringPool.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/StringPool.java index 6513895069e..d16bd9ab2a9 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/StringPool.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/StringPool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicLong; +import jdk.internal.vm.Continuation; public final class StringPool { public static final int MIN_LIMIT = 16; @@ -71,33 +72,49 @@ private static long externalSid(long internalSid) { return internalSid >> 16; } - /* synchronized because of writing the string to the JVM. */ - private static synchronized long storeString(String s) { - Long lsid = cache.get(s); - long internalSid; - if (lsid != null) { - internalSid = lsid.longValue(); - if (isCurrentGeneration(internalSid)) { - // Someone already updated the cache. - return externalSid(internalSid); + /* Explicitly pin a virtual thread before acquiring the string pool monitor + * because migrating the EventWriter onto another carrier thread is impossible. + */ + private static long storeString(String s, boolean pinVirtualThread) { + if (pinVirtualThread) { + assert(Thread.currentThread().isVirtual()); + Continuation.pin(); + } + try { + /* synchronized because of writing the string to the JVM. */ + synchronized (StringPool.class) { + Long lsid = cache.get(s); + long internalSid; + if (lsid != null) { + internalSid = lsid.longValue(); + if (isCurrentGeneration(internalSid)) { + // Someone already updated the cache. + return externalSid(internalSid); + } + internalSid = updateInternalSid(internalSid); + } else { + // Not yet added or the cache was cleared. + internalSid = nextInternalSid(); + currentSizeUTF16 += s.length(); + } + long extSid = externalSid(internalSid); + // Write the string to the JVM before publishing to the cache. + JVM.addStringConstant(extSid, s); + cache.put(s, internalSid); + return extSid; + } + } finally { + if (pinVirtualThread) { + assert(Thread.currentThread().isVirtual()); + Continuation.unpin(); } - internalSid = updateInternalSid(internalSid); - } else { - // Not yet added or the cache was cleared. - internalSid = nextInternalSid(); - currentSizeUTF16 += s.length(); } - long extSid = externalSid(internalSid); - // Write the string to the JVM before publishing to the cache. - JVM.addStringConstant(extSid, s); - cache.put(s, internalSid); - return extSid; } /* a string fetched from the string pool must be of the current generation */ - private static long ensureCurrentGeneration(String s, Long lsid) { + private static long ensureCurrentGeneration(String s, Long lsid, boolean pinVirtualThread) { long internalSid = lsid.longValue(); - return isCurrentGeneration(internalSid) ? externalSid(internalSid) : storeString(s); + return isCurrentGeneration(internalSid) ? externalSid(internalSid) : storeString(s, pinVirtualThread); } /* @@ -109,10 +126,10 @@ private static long ensureCurrentGeneration(String s, Long lsid) { * effectively invalidating the fetched string id. The event restart mechanism * of the EventWriter ensures that committed strings are in the correct generation. */ - public static long addString(String s) { + public static long addString(String s, boolean pinVirtualThread) { Long lsid = cache.get(s); if (lsid != null) { - return ensureCurrentGeneration(s, lsid); + return ensureCurrentGeneration(s, lsid, pinVirtualThread); } if (!preCache(s)) { /* we should not pool this string */ @@ -120,9 +137,9 @@ public static long addString(String s) { } if (cache.size() > MAX_SIZE || currentSizeUTF16 > MAX_SIZE_UTF16) { /* pool was full */ - reset(); + reset(pinVirtualThread); } - return storeString(s); + return storeString(s, pinVirtualThread); } private static boolean preCache(String s) { @@ -143,8 +160,21 @@ private static boolean preCache(String s) { return false; } - private static synchronized void reset() { - cache.clear(); - currentSizeUTF16 = 0; + private static void reset(boolean pinVirtualThread) { + if (pinVirtualThread) { + assert(Thread.currentThread().isVirtual()); + Continuation.pin(); + } + try { + synchronized (StringPool.class) { + cache.clear(); + currentSizeUTF16 = 0; + } + } finally { + if (pinVirtualThread) { + assert(Thread.currentThread().isVirtual()); + Continuation.unpin(); + } + } } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/event/EventWriter.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/event/EventWriter.java index 833fb087e24..970365ef73d 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/event/EventWriter.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/event/EventWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -65,6 +65,7 @@ public final class EventWriter { private long currentPosition; private long maxPosition; private boolean valid; + private boolean pinVirtualThread; boolean excluded; private PlatformEventType eventType; @@ -144,7 +145,7 @@ public void putString(String s) { return; } if (length > StringPool.MIN_LIMIT && length < StringPool.MAX_LIMIT) { - long l = StringPool.addString(s); + long l = StringPool.addString(s, pinVirtualThread); if (l > 0) { putByte(StringParser.Encoding.CONSTANT_POOL.byteValue()); putLong(l); @@ -296,11 +297,12 @@ public boolean endEvent() { return false; } - private EventWriter(long startPos, long maxPos, long threadID, boolean valid, boolean excluded) { + private EventWriter(long startPos, long maxPos, long threadID, boolean valid, boolean pinVirtualThread, boolean excluded) { startPosition = currentPosition = startPos; maxPosition = maxPos; this.threadID = threadID; this.valid = valid; + this.pinVirtualThread = pinVirtualThread; this.excluded = excluded; } diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index 2414f3d090a..a991817f951 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -119,6 +119,7 @@ runtime/ErrorHandling/TestDwarf.java#checkDecoder 8305489 linux-all runtime/ErrorHandling/MachCodeFramesInErrorFile.java 8313315 linux-ppc64le runtime/Thread/TestAlwaysPreTouchStacks.java 8335167 macosx-aarch64 runtime/cds/appcds/customLoader/HelloCustom_JFR.java 8241075 linux-all,windows-x64 +runtime/interpreter/LastJsrTest.java 8338924 linux-all applications/jcstress/copy.java 8229852 linux-all diff --git a/test/hotspot/jtreg/compiler/c2/irTests/scalarReplacement/ScalarReplacementWithGCBarrierTests.java b/test/hotspot/jtreg/compiler/c2/irTests/scalarReplacement/ScalarReplacementWithGCBarrierTests.java new file mode 100644 index 00000000000..fbf5cdd61cc --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/irTests/scalarReplacement/ScalarReplacementWithGCBarrierTests.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2024 Alibaba Group Holding Limited. 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 compiler.c2.irTests.scalarReplacement; + +import compiler.lib.ir_framework.*; + +/* + * @test + * @bug 8333334 + * @summary Tests that dead barrier control flows do not affect the scalar replacement. + * @library /test/lib / + * @requires vm.compiler2.enabled + * @requires vm.gc.G1 + * @run driver compiler.c2.irTests.scalarReplacement.ScalarReplacementWithGCBarrierTests + */ +public class ScalarReplacementWithGCBarrierTests { + static class List { + public Node head; + + public void push(int value) { + Node n = new Node(); + n.value = value; + n.next = head; + head = n; + } + + @ForceInline + public Iter iter() { + Iter iter = new Iter(); + iter.list = this; + iter.n = head; + iter.sum = 0; + return iter; + } + } + + static class Node { + public int value; + public Node next; + } + + static class Iter { + public List list; + public Node n; + public Integer sum; + + @ForceInline + public boolean next() { + int lastSum = sum; + while (sum - lastSum < 1000) { + while (n != null && n.value < 30) n = n.next; + if (n == null) return false; + sum += n.value; + n = n.next; + } + return true; + } + } + + private static final int SIZE = 1000; + + public static void main(String[] args) { + // Must use G1 GC to ensure there is a pre-barrier + // before the first field write. + TestFramework.runWithFlags("-XX:+UseG1GC"); + } + + @Run(test = "testScalarReplacementWithGCBarrier") + private void runner() { + List list = new List(); + for (int i = 0; i < SIZE; i++) { + list.push(i); + } + testScalarReplacementWithGCBarrier(list); + } + + // Allocation of `Iter iter` should be eliminated by scalar replacement, and + // the allocation of `Integer sum` can not be eliminated, so there should be + // 1 allocation after allocations and locks elimination. + // + // Before the patch of JDK-8333334, both allocations of `Iter` and `Integer` + // could not be eliminated. + @Test + @IR(phase = { CompilePhase.AFTER_PARSING }, counts = { IRNode.ALLOC, "1" }) + @IR(phase = { CompilePhase.INCREMENTAL_BOXING_INLINE }, counts = { IRNode.ALLOC, "2" }) + @IR(phase = { CompilePhase.ITER_GVN_AFTER_ELIMINATION }, counts = { IRNode.ALLOC, "1" }) + private int testScalarReplacementWithGCBarrier(List list) { + Iter iter = list.iter(); + while (true) { + while (iter.next()) {} + if (list.head == null) break; + list.head = list.head.next; + iter.n = list.head; + } + return iter.sum; + } +} diff --git a/test/jdk/javax/swing/JTable/KeyBoardNavigation.java b/test/jdk/javax/swing/JTable/KeyBoardNavigation.java index 595547421ad..728361a3e90 100644 --- a/test/jdk/javax/swing/JTable/KeyBoardNavigation.java +++ b/test/jdk/javax/swing/JTable/KeyBoardNavigation.java @@ -39,7 +39,7 @@ /* * @test * @key headful - * @bug 4112270 8264102 + * @bug 4112270 8264102 8329756 * @library /java/awt/regtesthelpers * @build PassFailJFrame * @summary Test Keyboard Navigation in JTable. @@ -178,7 +178,7 @@ public static void main(String[] args) throws Exception { 1. Refer the below keyboard navigation specs (referenced from bug report 4112270). 2. Check all combinations of navigational keys mentioned below - and verifying each key combinations against the spec defined. + and verify each key combination against the spec defined. If it does, press "pass", otherwise press "fail". """; @@ -270,24 +270,19 @@ public static String getOSSpecificInstructions() { up/down Left/Right Arrow - Deselect current selection; move focus one cell left/right - FN+Up Arrow/FN+Down Arrow - Deselect current selection; + fn+Up/Down Arrow - Deselect current selection; scroll up/down one JViewport view; first visible cell in current column gets focus - Control-FN+Up Arrow/FN+Down Arrow - Deselect current selection; - move focus and view to - first/last cell in current row - F2 - Allows editing in a cell containing information without + fn - Allows editing in a cell containing information without overwriting the information Esc - Resets the cell content back to the state it was in before editing started - Ctrl+A, Ctrl+/ - Select All - Ctrl+\\ - Deselect all + Cmd+A - Select All Shift-Up/Down Arrow - Extend selection up/down one row Shift-Left/Right Arrow - Extend selection left/right one column - FN-Shift Up/Down Arrow - Extend selection to top/bottom of column - Shift-PageUp/PageDown - Extend selection up/down one view and scroll - table - """; + Ctrl-Shift Up/Down Arrow - Extend selection to top/bottom of row + Ctrl-Shift Left/Right Arrow - Extend selection to first/last of column + """; String osName = System.getProperty("os.name").toLowerCase(); if (osName.startsWith("mac")) { return MAC_SPECIFIC; diff --git a/test/jdk/jdk/jfr/threading/TestStringPoolVirtualThreadPinning.java b/test/jdk/jdk/jfr/threading/TestStringPoolVirtualThreadPinning.java new file mode 100644 index 00000000000..0dc1ef85661 --- /dev/null +++ b/test/jdk/jdk/jfr/threading/TestStringPoolVirtualThreadPinning.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.jfr.threading; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ThreadFactory; + +import jdk.jfr.Event; +import jdk.jfr.Name; +import jdk.jfr.Recording; +import jdk.jfr.consumer.RecordedEvent; +import jdk.jfr.consumer.RecordedThread; +import jdk.jfr.consumer.RecordingFile; +import jdk.test.lib.Asserts; +import jdk.test.lib.Utils; + +/** + * @test + * @bug 8338417 + * @summary Tests pinning of virtual threads when the JFR string pool monitor is contended. + * @key jfr + * @requires vm.hasJFR & vm.continuations + * @library /test/lib /test/jdk + * @run main/othervm jdk.jfr.threading.TestStringPoolVirtualThreadPinning + */ +public class TestStringPoolVirtualThreadPinning { + + private static final int VIRTUAL_THREAD_COUNT = 100_000; + private static final int STARTER_THREADS = 10; + + @Name("test.Tester") + private static class TestEvent extends Event { + private String eventString = Thread.currentThread().getName(); + } + + /* + * During event commit, the thread is in a critical section because it has loaded a carrier thread local event writer object. + * For virtual threads, a contended monitor, such as a synchronized block, is a point where a thread could become unmounted. + * A monitor guards the JFR string pool, but because of the event writer, remounting a virtual thread onto another carrier is impossible. + * + * The test provokes JFR string pool monitor contention to exercise explicit pin constructs to ensure the pinning of virtual threads. + */ + public static void main(String... args) throws Exception { + try (Recording r = new Recording()) { + r.start(); + + ThreadFactory factory = Thread.ofVirtual().factory(); + CompletableFuture[] c = new CompletableFuture[STARTER_THREADS]; + for (int j = 0; j < STARTER_THREADS; j++) { + c[j] = CompletableFuture.runAsync(() -> { + for (int i = 0; i < VIRTUAL_THREAD_COUNT / STARTER_THREADS; i++) { + try { + Thread vt = factory.newThread(TestStringPoolVirtualThreadPinning::emitEvent); + // For an event field string to be placed in the JFR string pool, it must exceed 16 characters. + // We use the virtual thread name as the event field string so we can verify the result as a 1-1 mapping. + vt.setName("VirtualTestThread-" + i); + vt.start(); + vt.join(); + } catch (InterruptedException ie) { + ie.printStackTrace(); + } + } + }); + } + for (int j = 0; j < STARTER_THREADS; j++) { + c[j].get(); + } + + r.stop(); + Path p = Utils.createTempFile("test", ".jfr"); + r.dump(p); + List events = RecordingFile.readAllEvents(p); + Asserts.assertEquals(events.size(), VIRTUAL_THREAD_COUNT, "Expected " + VIRTUAL_THREAD_COUNT + " events"); + for (RecordedEvent e : events) { + RecordedThread t = e.getThread(); + Asserts.assertNotNull(t); + Asserts.assertTrue(t.isVirtual()); + Asserts.assertEquals(e.getString("eventString"), t.getJavaName()); + } + } + } + + private static void emitEvent() { + TestEvent t = new TestEvent(); + t.commit(); + } +} diff --git a/test/lib/jdk/test/lib/NetworkConfiguration.java b/test/lib/jdk/test/lib/NetworkConfiguration.java index 8ea10ede6a4..3532bb1a3ee 100644 --- a/test/lib/jdk/test/lib/NetworkConfiguration.java +++ b/test/lib/jdk/test/lib/NetworkConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -127,8 +127,8 @@ public static boolean isSameInterface(NetworkInterface ni1, NetworkInterface ni2 public static boolean isTestable(NetworkInterface nif) { if (Platform.isOSX()) { - if (nif.getName().contains("awdl")) { - return false; // exclude awdl + if (nif.getName().contains("awdl") || nif.getName().contains("docker")) { + return false; // exclude awdl or docker } // filter out interfaces that only have link-local IPv6 addresses // on macOS interfaces like 'en6' fall in this category and @@ -145,6 +145,13 @@ public static boolean isTestable(NetworkInterface nif) { return false; } } + + if (Platform.isLinux()) { + String dName = nif.getDisplayName(); + if (dName != null && dName.contains("docker")) { + return false; + } + } return true; } diff --git a/test/micro/org/openjdk/bench/java/util/concurrent/Maps.java b/test/micro/org/openjdk/bench/java/util/concurrent/Maps.java index bd68e582e6a..62883efb8bb 100644 --- a/test/micro/org/openjdk/bench/java/util/concurrent/Maps.java +++ b/test/micro/org/openjdk/bench/java/util/concurrent/Maps.java @@ -1,5 +1,6 @@ /* * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, Alibaba Group Holding Limited. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +36,7 @@ import org.openjdk.jmh.annotations.Threads; import org.openjdk.jmh.annotations.Warmup; +import java.util.Enumeration; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; @@ -127,6 +129,21 @@ public ConcurrentHashMap testConcurrentHashMapPutAll() { return map; } + @Benchmark + public int testConcurrentHashMapIterators() { + ConcurrentHashMap map = (ConcurrentHashMap) staticMap; + int sum = 0; + Enumeration it = map.elements(); + while (it.hasMoreElements()) { + sum += (int) it.nextElement(); + } + it = map.keys(); + while (it.hasMoreElements()) { + sum += (int) it.nextElement(); + } + return sum; + } + private static class SimpleRandom { private final static long multiplier = 0x5DEECE66DL; private final static long addend = 0xBL;