From 41f312eb647470353f3cf1640ef0fbd32b07f283 Mon Sep 17 00:00:00 2001 From: Guoxiong Li Date: Thu, 17 Dec 2020 08:06:35 +0000 Subject: [PATCH 1/9] 8254023: A module declaration is not allowed to be a target of an annotation that lacks an @Target meta-annotation Reviewed-by: jfranck, vromero --- .../com/sun/tools/javac/comp/Check.java | 2 +- .../javac/annotations/8254023/T8254023.java | 29 +++++++++ .../annotations/8254023/module-info.java | 25 ++++++++ .../javac/annotations/8254023/test/A.java | 26 ++++++++ .../javac/modules/AnnotationProcessing.java | 62 ++++++++++++++++++- .../javac/modules/AnnotationsOnModules.java | 39 +++++++++++- 6 files changed, 180 insertions(+), 3 deletions(-) create mode 100644 test/langtools/tools/javac/annotations/8254023/T8254023.java create mode 100644 test/langtools/tools/javac/annotations/8254023/module-info.java create mode 100644 test/langtools/tools/javac/annotations/8254023/test/A.java diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java index 1ca0645ad65..801ea604a05 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java @@ -119,7 +119,7 @@ public class Check { names = Names.instance(context); dfltTargetMeta = new Name[] { names.PACKAGE, names.TYPE, names.FIELD, names.RECORD_COMPONENT, names.METHOD, names.CONSTRUCTOR, - names.ANNOTATION_TYPE, names.LOCAL_VARIABLE, names.PARAMETER}; + names.ANNOTATION_TYPE, names.LOCAL_VARIABLE, names.PARAMETER, names.MODULE }; log = Log.instance(context); rs = Resolve.instance(context); syms = Symtab.instance(context); diff --git a/test/langtools/tools/javac/annotations/8254023/T8254023.java b/test/langtools/tools/javac/annotations/8254023/T8254023.java new file mode 100644 index 00000000000..f9c59716bf3 --- /dev/null +++ b/test/langtools/tools/javac/annotations/8254023/T8254023.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2020, 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 8254023 + * @summary A module declaration is not allowed to be a target of an annotation that lacks an (at)Target meta-annotation + * @compile module-info.java test/A.java + */ diff --git a/test/langtools/tools/javac/annotations/8254023/module-info.java b/test/langtools/tools/javac/annotations/8254023/module-info.java new file mode 100644 index 00000000000..bc8011775df --- /dev/null +++ b/test/langtools/tools/javac/annotations/8254023/module-info.java @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2020, 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.A +module test { } diff --git a/test/langtools/tools/javac/annotations/8254023/test/A.java b/test/langtools/tools/javac/annotations/8254023/test/A.java new file mode 100644 index 00000000000..fbd0dfb32fa --- /dev/null +++ b/test/langtools/tools/javac/annotations/8254023/test/A.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2020, 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 test; + +public @interface A { } diff --git a/test/langtools/tools/javac/modules/AnnotationProcessing.java b/test/langtools/tools/javac/modules/AnnotationProcessing.java index 68e0794e8eb..1bf870bc54e 100644 --- a/test/langtools/tools/javac/modules/AnnotationProcessing.java +++ b/test/langtools/tools/javac/modules/AnnotationProcessing.java @@ -23,7 +23,7 @@ /** * @test - * @bug 8133884 8162711 8133896 8172158 8172262 8173636 8175119 8189747 8236842 + * @bug 8133884 8162711 8133896 8172158 8172262 8173636 8175119 8189747 8236842 8254023 * @summary Verify that annotation processing works. * @library /tools/lib * @modules @@ -517,6 +517,66 @@ public class AnnotationProcessing extends ModuleTestBase { } + @Test + public void testAnnotationsWithoutTargetInModuleInfo(Path base) throws Exception { + Path moduleSrc = base.resolve("module-src"); + Path m1 = moduleSrc.resolve("m1"); + + tb.writeJavaFiles(m1, + "@test.A module m1x { exports test; }", + "package test; public @interface A { }", + "package test; public @interface B { }"); + + Path classes = base.resolve("classes"); + Files.createDirectories(classes); + + List expectedLog = List.of("Note: m1x/test.A AP Invoked", + "Note: m1x/test.A AP Invoked"); + + List actualLog = new JavacTask(tb) + .options("-processor", AnnotationsWithoutTargetInModuleInfo.class.getName() + + "," + AnnotationsWithoutTargetNotInModuleInfo.class.getName()) + .outdir(classes) + .files(findJavaFiles(m1)) + .run() + .writeAll() + .getOutputLines(Task.OutputKind.DIRECT); + + tb.checkEqual(expectedLog, actualLog); + } + + @SupportedAnnotationTypes("m1x/test.A") + public static final class AnnotationsWithoutTargetInModuleInfo extends AbstractProcessor { + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + processingEnv.getMessager().printMessage(Kind.NOTE, "m1x/test.A AP Invoked"); + return false; + } + + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } + + } + + @SupportedAnnotationTypes("m1x/test.B") + public static final class AnnotationsWithoutTargetNotInModuleInfo extends AbstractProcessor { + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + processingEnv.getMessager().printMessage(Kind.NOTE, "m1x/test.B AP Invoked"); + return false; + } + + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } + + } + @Test public void testGenerateInMultiModeAPI(Path base) throws Exception { Path moduleSrc = base.resolve("module-src"); diff --git a/test/langtools/tools/javac/modules/AnnotationsOnModules.java b/test/langtools/tools/javac/modules/AnnotationsOnModules.java index 5d03bdef5a3..001a07b48aa 100644 --- a/test/langtools/tools/javac/modules/AnnotationsOnModules.java +++ b/test/langtools/tools/javac/modules/AnnotationsOnModules.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8159602 8170549 8171255 8171322 + * @bug 8159602 8170549 8171255 8171322 8254023 * @summary Test annotations on module declaration. * @library /tools/lib * @modules jdk.compiler/com.sun.tools.javac.api @@ -51,6 +51,7 @@ import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.ModuleElement; import javax.lang.model.element.TypeElement; +import com.sun.tools.classfile.Annotation; import com.sun.tools.classfile.Attribute; import com.sun.tools.classfile.ClassFile; import com.sun.tools.classfile.RuntimeInvisibleAnnotations_attribute; @@ -410,6 +411,42 @@ public class AnnotationsOnModules extends ModuleTestBase { } + @Test + public void testAnnotationWithoutTarget(Path base) throws Exception { + Path moduleSrc = base.resolve("module-src"); + Path m1 = moduleSrc.resolve("m1x"); + + tb.writeJavaFiles(m1, + "@test.A module m1x { exports test; }", + "package test; public @interface A { }"); + + Path classes = base.resolve("classes"); + Files.createDirectories(classes); + + new JavacTask(tb) + .options("--module-source-path", moduleSrc.toString()) + .outdir(classes) + .files(findJavaFiles(m1)) + .run() + .writeAll(); + + ClassFile cf = ClassFile.read(classes.resolve("m1x").resolve("module-info.class")); + var invisibleAnnotations = (RuntimeInvisibleAnnotations_attribute) cf.attributes.map.get(Attribute.RuntimeInvisibleAnnotations); + + if (invisibleAnnotations == null) { + throw new AssertionError("Annotations not found!"); + } + int length = invisibleAnnotations.annotations.length; + if (length != 1) { + throw new AssertionError("Incorrect number of annotations: " + length); + } + Annotation annotation = invisibleAnnotations.annotations[0]; + String annotationName = cf.constant_pool.getUTF8Value(annotation.type_index).toString(); + if (!"Ltest/A;".equals(annotationName)) { + throw new AssertionError("Incorrect annotation name: " + annotationName); + } + } + @Test public void testModuleInfoAnnotationsInAPI(Path base) throws Exception { Path moduleSrc = base.resolve("module-src"); From 04a1e5b75b2c3c1d5a923fe79b7fa76dd2961956 Mon Sep 17 00:00:00 2001 From: Christian Hagedorn Date: Thu, 17 Dec 2020 08:09:19 +0000 Subject: [PATCH 2/9] 8258505: [TESTBUG] TestDivZeroWithSplitIf.java fails due to missing UnlockDiagnosticVMOptions Reviewed-by: thartmann, kvn, dcubed --- .../hotspot/jtreg/compiler/loopopts/TestDivZeroWithSplitIf.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/compiler/loopopts/TestDivZeroWithSplitIf.java b/test/hotspot/jtreg/compiler/loopopts/TestDivZeroWithSplitIf.java index 2d43ebc53d4..eff1f1ca1d8 100644 --- a/test/hotspot/jtreg/compiler/loopopts/TestDivZeroWithSplitIf.java +++ b/test/hotspot/jtreg/compiler/loopopts/TestDivZeroWithSplitIf.java @@ -28,7 +28,7 @@ * @summary Verify that zero check is executed before division/modulo operation. * @requires vm.compiler2.enabled * @run main/othervm -Xcomp -XX:-TieredCompilation -XX:CompileOnly=compiler/loopopts/TestDivZeroWithSplitIf::test - * -XX:+StressGCM -XX:StressSeed=873732072 compiler.loopopts.TestDivZeroWithSplitIf + * -XX:+UnlockDiagnosticVMOptions -XX:+StressGCM -XX:StressSeed=873732072 compiler.loopopts.TestDivZeroWithSplitIf */ package compiler.loopopts; From 952dc704024d44c8f37449382fe769320f9dad1c Mon Sep 17 00:00:00 2001 From: Julia Boes Date: Thu, 17 Dec 2020 11:32:58 +0000 Subject: [PATCH 3/9] 8257636: Update usage of "type" terminology in java.lang.Class and java.lang.reflect Reviewed-by: darcy --- .../share/classes/java/lang/Class.java | 74 +++++++++---------- .../java/lang/reflect/AnnotatedArrayType.java | 4 +- .../java/lang/reflect/AnnotatedElement.java | 2 +- .../reflect/AnnotatedParameterizedType.java | 6 +- .../java/lang/reflect/AnnotatedType.java | 6 +- .../java/lang/reflect/Constructor.java | 2 +- .../classes/java/lang/reflect/Field.java | 6 +- .../java/lang/reflect/GenericArrayType.java | 4 +- .../reflect/GenericSignatureFormatError.java | 6 +- .../classes/java/lang/reflect/Method.java | 7 +- .../java/lang/reflect/ParameterizedType.java | 12 +-- .../classes/java/lang/reflect/Proxy.java | 9 ++- .../java/lang/reflect/ProxyGenerator.java | 5 +- .../java/lang/reflect/RecordComponent.java | 4 +- 14 files changed, 74 insertions(+), 73 deletions(-) diff --git a/src/java.base/share/classes/java/lang/Class.java b/src/java.base/share/classes/java/lang/Class.java index 16d5dc6e5dc..cf8c8733577 100644 --- a/src/java.base/share/classes/java/lang/Class.java +++ b/src/java.base/share/classes/java/lang/Class.java @@ -91,8 +91,8 @@ import sun.reflect.misc.ReflectUtil; /** * Instances of the class {@code Class} represent classes and - * interfaces in a running Java application. An enum type and a record - * type are kinds of class; an annotation type is a kind of + * interfaces in a running Java application. An enum class and a record + * class are kinds of class; an annotation interface is a kind of * interface. Every array also belongs to a class that is reflected as * a {@code Class} object that is shared by all arrays with the same * element type and number of dimensions. The primitive Java types @@ -131,7 +131,7 @@ import sun.reflect.misc.ReflectUtil; * * * It is also possible to get the {@code Class} object for a named - * type (or for {@code void}) using a class literal. + * class or interface (or for {@code void}) using a class literal. * For example: * *
@@ -159,8 +159,8 @@ import sun.reflect.misc.ReflectUtil; * {@link java.lang.invoke.MethodHandles.Lookup#defineHiddenClass(byte[], boolean, MethodHandles.Lookup.ClassOption...) * Lookup::defineHiddenClass} is a {@linkplain Class#isHidden() hidden} * class or interface. - * All kinds of class, including enum types and record types, may be - * hidden classes; all kinds of interface, including annotation types, + * All kinds of class, including enum classes and record classes, may be + * hidden classes; all kinds of interface, including annotation interfaces, * may be hidden interfaces. * * The {@linkplain #getName() name of a hidden class or interface} is @@ -294,7 +294,7 @@ public final class Class implements java.io.Serializable, if (isAnnotation()) { sb.append('@'); } - if (isInterface()) { // Note: all annotation types are interfaces + if (isInterface()) { // Note: all annotation interfaces are interfaces sb.append("interface"); } else { if (isEnum()) @@ -767,11 +767,11 @@ public final class Class implements java.io.Serializable, /** * Returns true if this {@code Class} object represents an annotation - * type. Note that if this method returns true, {@link #isInterface()} - * would also return true, as all annotation types are also interfaces. + * interface. Note that if this method returns true, {@link #isInterface()} + * would also return true, as all annotation interfaces are also interfaces. * * @return {@code true} if this {@code Class} object represents an annotation - * type; {@code false} otherwise + * interface; {@code false} otherwise * @since 1.5 */ public boolean isAnnotation() { @@ -1298,8 +1298,8 @@ public final class Class implements java.io.Serializable, * {@code null} otherwise. * * In particular, this method returns {@code null} if the underlying - * class is a local or anonymous class immediately enclosed by a type - * declaration, instance initializer or static initializer. + * class is a local or anonymous class immediately enclosed by a class or + * interface declaration, instance initializer or static initializer. * * @return the immediately enclosing method of the underlying class, if * that class is a local or anonymous class; otherwise {@code null}. @@ -1456,8 +1456,8 @@ public final class Class implements java.io.Serializable, * the immediately enclosing constructor of the underlying * class. Returns {@code null} otherwise. In particular, this * method returns {@code null} if the underlying class is a local - * or anonymous class immediately enclosed by a type declaration, - * instance initializer or static initializer. + * or anonymous class immediately enclosed by a class or + * interface declaration, instance initializer or static initializer. * * @return the immediately enclosing constructor of the underlying class, if * that class is a local or anonymous class; otherwise {@code null}. @@ -1650,9 +1650,9 @@ public final class Class implements java.io.Serializable, } /** - * Return an informative string for the name of this type. + * Return an informative string for the name of this class or interface. * - * @return an informative string for the name of this type + * @return an informative string for the name of this class or interface * @since 1.8 */ public String getTypeName() { @@ -2371,7 +2371,7 @@ public final class Class implements java.io.Serializable, * * * - * @jls 8.10 Record Types + * @jls 8.10 Record Classes * @since 16 */ @CallerSensitive @@ -2392,14 +2392,14 @@ public final class Class implements java.io.Serializable, * Class} object, including public, protected, default (package) * access, and private methods, but excluding inherited methods. * - *

If this {@code Class} object represents a type that has multiple - * declared methods with the same name and parameter types, but different - * return types, then the returned array has a {@code Method} object for - * each such method. + *

If this {@code Class} object represents a class or interface that + * has multiple declared methods with the same name and parameter types, + * but different return types, then the returned array has a {@code Method} + * object for each such method. * - *

If this {@code Class} object represents a type that has a class - * initialization method {@code }, then the returned array does - * not have a corresponding {@code Method} object. + *

If this {@code Class} object represents a class or interface that + * has a class initialization method {@code }, then the returned + * array does not have a corresponding {@code Method} object. * *

If this {@code Class} object represents a class or interface with no * declared methods, then the returned array has length 0. @@ -3671,13 +3671,13 @@ public final class Class implements java.io.Serializable, * Returns true if and only if this class was declared as an enum in the * source code. * - * Note that {@link java.lang.Enum} is not itself an enum type. + * Note that {@link java.lang.Enum} is not itself an enum class. * * Also note that if an enum constant is declared with a class body, * the class of that enum constant object is an anonymous class - * and not the class of the declaring enum type. The + * and not the class of the declaring enum class. The * {@link Enum#getDeclaringClass} method of an enum constant can - * be used to get the class of the enum type declaring the + * be used to get the class of the enum class declaring the * constant. * * @return true if and only if this class was declared as an enum in the @@ -3702,11 +3702,11 @@ public final class Class implements java.io.Serializable, * components; {@link #getRecordComponents()} returns a non-null but * possibly empty value for a record. * - *

Note that class {@link Record} is not a record type and thus invoking - * this method on class {@code Record} returns {@code false}. + *

Note that class {@link Record} is not a record class and thus + * invoking this method on class {@code Record} returns {@code false}. * * @return true if and only if this class is a record class, otherwise false - * @jls 8.10 Record Types + * @jls 8.10 Record Classes * @since 16 */ public boolean isRecord() { @@ -3730,12 +3730,12 @@ public final class Class implements java.io.Serializable, /** * Returns the elements of this enum class or null if this - * Class object does not represent an enum type. + * Class object does not represent an enum class. * * @return an array containing the values comprising the enum class * represented by this {@code Class} object in the order they're * declared, or null if this {@code Class} object does not - * represent an enum type + * represent an enum class * @since 1.5 */ public T[] getEnumConstants() { @@ -3745,7 +3745,7 @@ public final class Class implements java.io.Serializable, /** * Returns the elements of this enum class or null if this - * Class object does not represent an enum type; + * Class object does not represent an enum class; * identical to getEnumConstants except that the result is * uncloned, cached, and shared by all callers. */ @@ -3788,7 +3788,7 @@ public final class Class implements java.io.Serializable, T[] universe = getEnumConstantsShared(); if (universe == null) throw new IllegalArgumentException( - getName() + " is not an enum type"); + getName() + " is not an enum class"); directory = new HashMap<>((int)(universe.length / 0.75f) + 1); for (T constant : universe) { directory.put(((Enum)constant).name(), constant); @@ -4024,7 +4024,7 @@ public final class Class implements java.io.Serializable, return new AnnotationData(annotations, declaredAnnotations, classRedefinedCount); } - // Annotation types cache their internal (AnnotationType) form + // Annotation interfaces cache their internal (AnnotationType) form @SuppressWarnings("UnusedDeclaration") private transient volatile AnnotationType annotationType; @@ -4050,10 +4050,10 @@ public final class Class implements java.io.Serializable, * Returns an {@code AnnotatedType} object that represents the use of a * type to specify the superclass of the entity represented by this {@code * Class} object. (The use of type Foo to specify the superclass - * in '... extends Foo' is distinct from the declaration of type + * in '... extends Foo' is distinct from the declaration of class * Foo.) * - *

If this {@code Class} object represents a type whose declaration + *

If this {@code Class} object represents a class whose declaration * does not explicitly indicate an annotated superclass, then the return * value is an {@code AnnotatedType} object representing an element with no * annotations. @@ -4082,7 +4082,7 @@ public final class Class implements java.io.Serializable, * of types to specify superinterfaces of the entity represented by this * {@code Class} object. (The use of type Foo to specify a * superinterface in '... implements Foo' is distinct from the - * declaration of type Foo.) + * declaration of interface Foo.) * *

If this {@code Class} object represents a class, the return value is * an array containing objects representing the uses of interface types to diff --git a/src/java.base/share/classes/java/lang/reflect/AnnotatedArrayType.java b/src/java.base/share/classes/java/lang/reflect/AnnotatedArrayType.java index fa9ccc03686..3d99eefa5af 100644 --- a/src/java.base/share/classes/java/lang/reflect/AnnotatedArrayType.java +++ b/src/java.base/share/classes/java/lang/reflect/AnnotatedArrayType.java @@ -46,8 +46,8 @@ public interface AnnotatedArrayType extends AnnotatedType { /** * Returns the potentially annotated type that this type is a member of, if - * this type represents a nested type. For example, if this type is - * {@code @TA O.I}, return a representation of {@code @TA O}. + * this type represents a nested class or interface. For example, if this + * type is {@code @TA O.I}, return a representation of {@code @TA O}. * *

Returns {@code null} for an {@code AnnotatedType} that is an instance * of {@code AnnotatedArrayType}. diff --git a/src/java.base/share/classes/java/lang/reflect/AnnotatedElement.java b/src/java.base/share/classes/java/lang/reflect/AnnotatedElement.java index 933ffab3e73..ef5b962be93 100644 --- a/src/java.base/share/classes/java/lang/reflect/AnnotatedElement.java +++ b/src/java.base/share/classes/java/lang/reflect/AnnotatedElement.java @@ -248,7 +248,7 @@ import sun.reflect.annotation.AnnotationType; * *

Similarly, attempting to read an enum-valued member will result in * a {@link EnumConstantNotPresentException} if the enum constant in the - * annotation is no longer present in the enum type. + * annotation is no longer present in the enum class. * *

If an annotation type T is (meta-)annotated with an * {@code @Repeatable} annotation whose value element indicates a type diff --git a/src/java.base/share/classes/java/lang/reflect/AnnotatedParameterizedType.java b/src/java.base/share/classes/java/lang/reflect/AnnotatedParameterizedType.java index fc32e910116..9ecf35f828f 100644 --- a/src/java.base/share/classes/java/lang/reflect/AnnotatedParameterizedType.java +++ b/src/java.base/share/classes/java/lang/reflect/AnnotatedParameterizedType.java @@ -49,13 +49,13 @@ public interface AnnotatedParameterizedType extends AnnotatedType { * {@code @TA O.I}, return a representation of {@code @TA O}. * *

Returns {@code null} if this {@code AnnotatedType} represents a - * top-level type, or a local or anonymous class, or a primitive type, or - * void. + * top-level class or interface, or a local or anonymous class, or + * a primitive type, or void. * * @return an {@code AnnotatedType} object representing the potentially * annotated type that this type is a member of, or {@code null} * @throws TypeNotPresentException if the owner type - * refers to a non-existent type declaration + * refers to a non-existent class or interface declaration * @throws MalformedParameterizedTypeException if the owner type * refers to a parameterized type that cannot be instantiated * for any reason diff --git a/src/java.base/share/classes/java/lang/reflect/AnnotatedType.java b/src/java.base/share/classes/java/lang/reflect/AnnotatedType.java index 662cdd42e36..9525d3638fd 100644 --- a/src/java.base/share/classes/java/lang/reflect/AnnotatedType.java +++ b/src/java.base/share/classes/java/lang/reflect/AnnotatedType.java @@ -55,8 +55,8 @@ public interface AnnotatedType extends AnnotatedElement { * {@code @TA O.I}, return a representation of {@code @TA O}. * *

Returns {@code null} if this {@code AnnotatedType} represents a - * top-level type, or a local or anonymous class, or a primitive type, or - * void. + * top-level class or interface, or a local or anonymous class, or + * a primitive type, or void. * *

Returns {@code null} if this {@code AnnotatedType} is an instance of * {@code AnnotatedArrayType}, {@code AnnotatedTypeVariable}, or @@ -69,7 +69,7 @@ public interface AnnotatedType extends AnnotatedElement { * @return an {@code AnnotatedType} object representing the potentially * annotated type that this type is a member of, or {@code null} * @throws TypeNotPresentException if the owner type - * refers to a non-existent type declaration + * refers to a non-existent class or interface declaration * @throws MalformedParameterizedTypeException if the owner type * refers to a parameterized type that cannot be instantiated * for any reason diff --git a/src/java.base/share/classes/java/lang/reflect/Constructor.java b/src/java.base/share/classes/java/lang/reflect/Constructor.java index ed8c9c59f4e..7a2309c25f1 100644 --- a/src/java.base/share/classes/java/lang/reflect/Constructor.java +++ b/src/java.base/share/classes/java/lang/reflect/Constructor.java @@ -462,7 +462,7 @@ public final class Constructor extends Executable { * after possible unwrapping, a parameter value * cannot be converted to the corresponding formal * parameter type by a method invocation conversion; if - * this constructor pertains to an enum type. + * this constructor pertains to an enum class. * @throws InstantiationException if the class that declares the * underlying constructor represents an abstract class. * @throws InvocationTargetException if the underlying constructor diff --git a/src/java.base/share/classes/java/lang/reflect/Field.java b/src/java.base/share/classes/java/lang/reflect/Field.java index 4c1e394f78c..28fa076816b 100644 --- a/src/java.base/share/classes/java/lang/reflect/Field.java +++ b/src/java.base/share/classes/java/lang/reflect/Field.java @@ -206,10 +206,10 @@ class Field extends AccessibleObject implements Member { /** * Returns {@code true} if this field represents an element of - * an enumerated type; returns {@code false} otherwise. + * an enumerated class; returns {@code false} otherwise. * * @return {@code true} if and only if this field represents an element of - * an enumerated type. + * an enumerated class. * @since 1.5 */ public boolean isEnumConstant() { @@ -258,7 +258,7 @@ class Field extends AccessibleObject implements Member { * The Java Virtual Machine Specification * @throws TypeNotPresentException if the generic type * signature of the underlying field refers to a non-existent - * type declaration + * class or interface declaration * @throws MalformedParameterizedTypeException if the generic * signature of the underlying field refers to a parameterized type * that cannot be instantiated for any reason diff --git a/src/java.base/share/classes/java/lang/reflect/GenericArrayType.java b/src/java.base/share/classes/java/lang/reflect/GenericArrayType.java index ad4e047f748..80a280ef33f 100644 --- a/src/java.base/share/classes/java/lang/reflect/GenericArrayType.java +++ b/src/java.base/share/classes/java/lang/reflect/GenericArrayType.java @@ -44,8 +44,8 @@ public interface GenericArrayType extends Type { * * @return a {@code Type} object representing the component type * of this array - * @throws TypeNotPresentException if the underlying array type's - * component type refers to a non-existent type declaration + * @throws TypeNotPresentException if the underlying array type's component + * type refers to a non-existent class or interface declaration * @throws MalformedParameterizedTypeException if the * underlying array type's component type refers to a * parameterized type that cannot be instantiated for any reason diff --git a/src/java.base/share/classes/java/lang/reflect/GenericSignatureFormatError.java b/src/java.base/share/classes/java/lang/reflect/GenericSignatureFormatError.java index 7200e49f7c3..0d2b6c67200 100644 --- a/src/java.base/share/classes/java/lang/reflect/GenericSignatureFormatError.java +++ b/src/java.base/share/classes/java/lang/reflect/GenericSignatureFormatError.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, 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,8 @@ package java.lang.reflect; /** * Thrown when a syntactically malformed signature attribute is - * encountered by a reflective method that needs to interpret the - * generic signature information for a type, method or constructor. + * encountered by a reflective method that needs to interpret the generic + * signature information for a class or interface, method or constructor. * * @since 1.5 */ diff --git a/src/java.base/share/classes/java/lang/reflect/Method.java b/src/java.base/share/classes/java/lang/reflect/Method.java index 567ae8be660..080851cc9ee 100644 --- a/src/java.base/share/classes/java/lang/reflect/Method.java +++ b/src/java.base/share/classes/java/lang/reflect/Method.java @@ -282,9 +282,9 @@ public final class Method extends Executable { * specified in * The Java Virtual Machine Specification * @throws TypeNotPresentException if the underlying method's - * return type refers to a non-existent type declaration + * return type refers to a non-existent class or interface declaration * @throws MalformedParameterizedTypeException if the - * underlying method's return typed refers to a parameterized + * underlying method's return type refers to a parameterized * type that cannot be instantiated for any reason * @since 1.5 */ @@ -603,8 +603,7 @@ public final class Method extends Executable { * method; returns {@code false} otherwise. * * A default method is a public non-abstract instance method, that - * is, a non-static method with a body, declared in an interface - * type. + * is, a non-static method with a body, declared in an interface. * * @return true if and only if this method is a default * method as defined by the Java Language Specification. diff --git a/src/java.base/share/classes/java/lang/reflect/ParameterizedType.java b/src/java.base/share/classes/java/lang/reflect/ParameterizedType.java index 62d6b7bf9e5..99016623a3e 100644 --- a/src/java.base/share/classes/java/lang/reflect/ParameterizedType.java +++ b/src/java.base/share/classes/java/lang/reflect/ParameterizedType.java @@ -32,15 +32,15 @@ package java.lang.reflect; * *

A parameterized type is created the first time it is needed by a * reflective method, as specified in this package. When a - * parameterized type p is created, the generic type declaration that - * p instantiates is resolved, and all type arguments of p are created + * parameterized type p is created, the generic class or interface declaration + * that p instantiates is resolved, and all type arguments of p are created * recursively. See {@link java.lang.reflect.TypeVariable * TypeVariable} for details on the creation process for type * variables. Repeated creation of a parameterized type has no effect. * *

Instances of classes that implement this interface must implement * an equals() method that equates any two instances that share the - * same generic type declaration and have equal type parameters. + * same generic class or interface declaration and have equal type parameters. * * @jls 4.5 Parameterized Types * @since 1.5 @@ -56,8 +56,8 @@ public interface ParameterizedType extends Type { * * @return an array of {@code Type} objects representing the actual type * arguments to this type - * @throws TypeNotPresentException if any of the - * actual type arguments refers to a non-existent type declaration + * @throws TypeNotPresentException if any of the actual type arguments + * refers to a non-existent class or interface declaration * @throws MalformedParameterizedTypeException if any of the * actual type parameters refer to a parameterized type that cannot * be instantiated for any reason @@ -86,7 +86,7 @@ public interface ParameterizedType extends Type { * this type is a member of. If this type is a top-level type, * {@code null} is returned * @throws TypeNotPresentException if the owner type - * refers to a non-existent type declaration + * refers to a non-existent class or interface declaration * @throws MalformedParameterizedTypeException if the owner type * refers to a parameterized type that cannot be instantiated * for any reason 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 ad123b55118..1d03c37aae7 100644 --- a/src/java.base/share/classes/java/lang/reflect/Proxy.java +++ b/src/java.base/share/classes/java/lang/reflect/Proxy.java @@ -240,10 +240,11 @@ import static java.lang.module.ModuleDescriptor.Modifier.SYNTHETIC; * *

* A dynamic module can read the modules of all of the superinterfaces of a proxy - * class and the modules of the types referenced by all public method signatures - * of a proxy class. If a superinterface or a referenced type, say {@code T}, - * is in a non-exported package, the {@linkplain Module module} of {@code T} is - * updated to export the package of {@code T} to the dynamic module. + * class and the modules of the classes and interfaces referenced by + * all public method signatures of a proxy class. If a superinterface or + * a referenced class or interface, say {@code T}, is in a non-exported package, + * the {@linkplain Module module} of {@code T} is updated to export the + * package of {@code T} to the dynamic module. * *

Methods Duplicated in Multiple Proxy Interfaces

* diff --git a/src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java b/src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java index 5932113bd78..ba595d473ef 100644 --- a/src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java +++ b/src/java.base/share/classes/java/lang/reflect/ProxyGenerator.java @@ -203,10 +203,11 @@ final class ProxyGenerator extends ClassWriter { } /** - * Return an array of the type names from an array of Classes. + * Return an array of the class and interface names from an array of Classes. * * @param classes an array of classes or interfaces - * @return the array of class names; or null if there are no classes + * @return the array of class and interface names; or null if classes is + * null or empty */ private static String[] typeNames(List> classes) { if (classes == null || classes.size() == 0) diff --git a/src/java.base/share/classes/java/lang/reflect/RecordComponent.java b/src/java.base/share/classes/java/lang/reflect/RecordComponent.java index 50d36418631..bca4705ca87 100644 --- a/src/java.base/share/classes/java/lang/reflect/RecordComponent.java +++ b/src/java.base/share/classes/java/lang/reflect/RecordComponent.java @@ -43,7 +43,7 @@ import java.util.Objects; * * @see Class#getRecordComponents() * @see java.lang.Record - * @jls 8.10 Record Types + * @jls 8.10 Record Classes * @since 16 */ public final class RecordComponent implements AnnotatedElement { @@ -83,7 +83,7 @@ public final class RecordComponent implements AnnotatedElement { } /** - * Returns a {@code String} that describes the generic type signature for + * Returns a {@code String} that describes the generic type signature for * this record component. * * @return a {@code String} that describes the generic type signature for From 61390d8e452058efe00ca8ce833baa879fbb9c9e Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Thu, 17 Dec 2020 14:18:00 +0000 Subject: [PATCH 4/9] 8257999: Parallel GC crash in gc/parallel/TestDynShrinkHeap.java: new region is not in covered_region Reviewed-by: sjohanss, tschatzl --- src/hotspot/share/gc/parallel/psOldGen.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/gc/parallel/psOldGen.cpp b/src/hotspot/share/gc/parallel/psOldGen.cpp index 51500f8c307..5d23956d466 100644 --- a/src/hotspot/share/gc/parallel/psOldGen.cpp +++ b/src/hotspot/share/gc/parallel/psOldGen.cpp @@ -35,6 +35,7 @@ #include "logging/log.hpp" #include "oops/oop.inline.hpp" #include "runtime/java.hpp" +#include "runtime/orderAccess.hpp" #include "utilities/align.hpp" PSOldGen::PSOldGen(ReservedSpace rs, size_t initial_size, size_t min_size, @@ -380,7 +381,9 @@ void PSOldGen::post_resize() { WorkGang* workers = Thread::current()->is_VM_thread() ? &ParallelScavengeHeap::heap()->workers() : NULL; - // ALWAYS do this last!! + // Ensure the space bounds are updated and made visible to other + // threads after the other data structures have been resized. + OrderAccess::storestore(); object_space()->initialize(new_memregion, SpaceDecorator::DontClear, SpaceDecorator::DontMangle, From 7aac4dc17573b7df2af8aa3d1f01add56b30ad02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Gr=C3=B6nlund?= Date: Thu, 17 Dec 2020 14:34:44 +0000 Subject: [PATCH 5/9] 8257621: JFR StringPool misses cached items across consecutive recordings Reviewed-by: egahlin --- src/hotspot/share/jfr/jni/jfrJniMethod.cpp | 8 +-- src/hotspot/share/jfr/jni/jfrJniMethod.hpp | 4 +- .../jfr/jni/jfrJniMethodRegistration.cpp | 3 +- .../checkpoint/jfrCheckpointManager.cpp | 22 ++----- .../types/traceid/jfrTraceIdEpoch.cpp | 3 +- .../types/traceid/jfrTraceIdEpoch.hpp | 21 ++----- .../recorder/service/jfrRecorderService.cpp | 10 +-- .../jfr/recorder/stringpool/jfrStringPool.cpp | 50 +++------------ .../jfr/recorder/stringpool/jfrStringPool.hpp | 4 +- src/hotspot/share/jfr/utilities/jfrSignal.hpp | 51 +++++++++++++++ .../classes/jdk/jfr/internal/EventWriter.java | 5 ++ .../share/classes/jdk/jfr/internal/JVM.java | 13 +--- .../classes/jdk/jfr/internal/StringPool.java | 63 +++++++------------ test/jdk/ProblemList.txt | 1 - 14 files changed, 106 insertions(+), 152 deletions(-) create mode 100644 src/hotspot/share/jfr/utilities/jfrSignal.hpp diff --git a/src/hotspot/share/jfr/jni/jfrJniMethod.cpp b/src/hotspot/share/jfr/jni/jfrJniMethod.cpp index 3e8404e145c..306691746b3 100644 --- a/src/hotspot/share/jfr/jni/jfrJniMethod.cpp +++ b/src/hotspot/share/jfr/jni/jfrJniMethod.cpp @@ -160,10 +160,6 @@ NO_TRANSITION(jboolean, jfr_is_available(JNIEnv* env, jclass jvm)) return !Jfr::is_disabled() ? JNI_TRUE : JNI_FALSE; NO_TRANSITION_END -NO_TRANSITION(jlong, jfr_get_epoch_address(JNIEnv* env, jobject jvm)) - return JfrTraceIdEpoch::epoch_address(); -NO_TRANSITION_END - NO_TRANSITION(jlong, jfr_get_unloaded_event_classes_count(JNIEnv* env, jobject jvm)) return JfrKlassUnloading::event_class_count(); NO_TRANSITION_END @@ -327,8 +323,8 @@ JVM_ENTRY_NO_ENV(jlong, jfr_type_id(JNIEnv* env, jobject jvm, jclass jc)) return JfrTraceId::load_raw(jc); JVM_END -JVM_ENTRY_NO_ENV(jboolean, jfr_add_string_constant(JNIEnv* env, jclass jvm, jboolean epoch, jlong id, jstring string)) - return JfrStringPool::add(epoch == JNI_TRUE, id, string, thread) ? JNI_TRUE : JNI_FALSE; +JVM_ENTRY_NO_ENV(jboolean, jfr_add_string_constant(JNIEnv* env, jclass jvm, jlong id, jstring string)) + return JfrStringPool::add(id, string, thread); JVM_END JVM_ENTRY_NO_ENV(void, jfr_set_force_instrumentation(JNIEnv* env, jobject jvm, jboolean force_instrumentation)) diff --git a/src/hotspot/share/jfr/jni/jfrJniMethod.hpp b/src/hotspot/share/jfr/jni/jfrJniMethod.hpp index a193df55f9f..aedfa03c0e5 100644 --- a/src/hotspot/share/jfr/jni/jfrJniMethod.hpp +++ b/src/hotspot/share/jfr/jni/jfrJniMethod.hpp @@ -120,9 +120,7 @@ jboolean JNICALL jfr_event_writer_flush(JNIEnv* env, jclass cls, jobject writer, void JNICALL jfr_flush(JNIEnv* env, jobject jvm); void JNICALL jfr_abort(JNIEnv* env, jobject jvm, jstring errorMsg); -jlong JNICALL jfr_get_epoch_address(JNIEnv* env, jobject jvm); - -jboolean JNICALL jfr_add_string_constant(JNIEnv* env, jclass jvm, jboolean epoch, jlong id, jstring string); +jboolean JNICALL jfr_add_string_constant(JNIEnv* env, jclass jvm, jlong id, jstring string); void JNICALL jfr_uncaught_exception(JNIEnv* env, jobject jvm, jobject thread, jthrowable throwable); diff --git a/src/hotspot/share/jfr/jni/jfrJniMethodRegistration.cpp b/src/hotspot/share/jfr/jni/jfrJniMethodRegistration.cpp index 2d11467dc19..db7dd149a39 100644 --- a/src/hotspot/share/jfr/jni/jfrJniMethodRegistration.cpp +++ b/src/hotspot/share/jfr/jni/jfrJniMethodRegistration.cpp @@ -75,8 +75,7 @@ JfrJniMethodRegistration::JfrJniMethodRegistration(JNIEnv* env) { (char*)"flush", (char*)"()V", (void*)jfr_flush, (char*)"setRepositoryLocation", (char*)"(Ljava/lang/String;)V", (void*)jfr_set_repository_location, (char*)"abort", (char*)"(Ljava/lang/String;)V", (void*)jfr_abort, - (char*)"getEpochAddress", (char*)"()J",(void*)jfr_get_epoch_address, - (char*)"addStringConstant", (char*)"(ZJLjava/lang/String;)Z", (void*)jfr_add_string_constant, + (char*)"addStringConstant", (char*)"(JLjava/lang/String;)Z", (void*)jfr_add_string_constant, (char*)"uncaughtException", (char*)"(Ljava/lang/Thread;Ljava/lang/Throwable;)V", (void*)jfr_uncaught_exception, (char*)"setForceInstrumentation", (char*)"(Z)V", (void*)jfr_set_force_instrumentation, (char*)"getUnloadedEventClassCount", (char*)"()J", (void*)jfr_get_unloaded_event_classes_count, diff --git a/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp b/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp index a66241b1fcf..e5cd7a9fa47 100644 --- a/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp +++ b/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp @@ -42,6 +42,7 @@ #include "jfr/utilities/jfrBigEndian.hpp" #include "jfr/utilities/jfrIterator.hpp" #include "jfr/utilities/jfrLinkedList.inline.hpp" +#include "jfr/utilities/jfrSignal.hpp" #include "jfr/utilities/jfrThreadIterator.hpp" #include "jfr/utilities/jfrTypes.hpp" #include "jfr/writers/jfrJavaEventWriter.hpp" @@ -57,22 +58,7 @@ typedef JfrCheckpointManager::BufferPtr BufferPtr; -static volatile bool constant_pending = false; - -static bool is_constant_pending() { - if (Atomic::load_acquire(&constant_pending)) { - Atomic::release_store(&constant_pending, false); // reset - return true; - } - return false; -} - -static void set_constant_pending() { - if (!Atomic::load_acquire(&constant_pending)) { - Atomic::release_store(&constant_pending, true); - } -} - +static JfrSignal _new_checkpoint; static JfrCheckpointManager* _instance = NULL; JfrCheckpointManager& JfrCheckpointManager::instance() { @@ -231,7 +217,7 @@ BufferPtr JfrCheckpointManager::flush(BufferPtr old, size_t used, size_t request // indicates a lease is being returned release(old); // signal completion of a new checkpoint - set_constant_pending(); + _new_checkpoint.signal(); return NULL; } BufferPtr new_buffer = lease(old, thread, used + requested); @@ -474,7 +460,7 @@ size_t JfrCheckpointManager::flush_type_set() { elements = ::flush_type_set(thread); } } - if (is_constant_pending()) { + if (_new_checkpoint.is_signaled()) { WriteOperation wo(_chunkwriter); MutexedWriteOperation mwo(wo); _thread_local_mspace->iterate(mwo); // current epoch list diff --git a/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.cpp b/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.cpp index 66f05828d6c..03c3ad48ea2 100644 --- a/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.cpp +++ b/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.cpp @@ -26,9 +26,9 @@ #include "jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.hpp" #include "runtime/safepoint.hpp" +JfrSignal JfrTraceIdEpoch::_tag_state; bool JfrTraceIdEpoch::_epoch_state = false; bool JfrTraceIdEpoch::_synchronizing = false; -volatile bool JfrTraceIdEpoch::_changed_tag_state = false; void JfrTraceIdEpoch::begin_epoch_shift() { assert(SafepointSynchronize::is_at_safepoint(), "invariant"); @@ -43,3 +43,4 @@ void JfrTraceIdEpoch::end_epoch_shift() { OrderAccess::storestore(); _synchronizing = false; } + diff --git a/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.hpp b/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.hpp index 33044922e93..6cc32a1f388 100644 --- a/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.hpp +++ b/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceIdEpoch.hpp @@ -25,6 +25,7 @@ #ifndef SHARE_JFR_RECORDER_CHECKPOINT_TYPES_TRACEID_JFRTRACEIDEPOCH_HPP #define SHARE_JFR_RECORDER_CHECKPOINT_TYPES_TRACEID_JFRTRACEIDEPOCH_HPP +#include "jfr/utilities/jfrSignal.hpp" #include "jfr/utilities/jfrTypes.hpp" #include "memory/allocation.hpp" #include "runtime/atomic.hpp" @@ -54,21 +55,13 @@ class JfrTraceIdEpoch : AllStatic { friend class JfrCheckpointManager; private: + static JfrSignal _tag_state; static bool _epoch_state; static bool _synchronizing; - static volatile bool _changed_tag_state; static void begin_epoch_shift(); static void end_epoch_shift(); - static bool changed_tag_state() { - return Atomic::load_acquire(&_changed_tag_state); - } - - static void set_tag_state(bool value) { - Atomic::release_store(&_changed_tag_state, value); - } - public: static bool epoch() { return _epoch_state; @@ -115,17 +108,11 @@ class JfrTraceIdEpoch : AllStatic { } static bool has_changed_tag_state() { - if (changed_tag_state()) { - set_tag_state(false); - return true; - } - return false; + return _tag_state.is_signaled(); } static void set_changed_tag_state() { - if (!changed_tag_state()) { - set_tag_state(true); - } + _tag_state.signal(); } }; diff --git a/src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp b/src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp index dc6c812e3ae..243fd5d4ce9 100644 --- a/src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp +++ b/src/hotspot/share/jfr/recorder/service/jfrRecorderService.cpp @@ -314,9 +314,7 @@ static size_t write_storage(JfrStorage& storage, JfrChunkWriter& chunkwriter) { } typedef Content StringPool; -typedef Content StringPoolSafepoint; typedef WriteCheckpointEvent WriteStringPool; -typedef WriteCheckpointEvent WriteStringPoolSafepoint; static u4 flush_stringpool(JfrStringPool& string_pool, JfrChunkWriter& chunkwriter) { StringPool sp(string_pool); @@ -330,12 +328,6 @@ static u4 write_stringpool(JfrStringPool& string_pool, JfrChunkWriter& chunkwrit return invoke(wsp); } -static u4 write_stringpool_safepoint(JfrStringPool& string_pool, JfrChunkWriter& chunkwriter) { - StringPoolSafepoint sps(string_pool); - WriteStringPoolSafepoint wsps(chunkwriter, sps, TYPE_STRING); - return invoke(wsps); -} - typedef Content FlushTypeSetFunctor; typedef WriteContent FlushTypeSet; @@ -569,7 +561,7 @@ void JfrRecorderService::safepoint_write() { assert(SafepointSynchronize::is_at_safepoint(), "invariant"); _checkpoint_manager.begin_epoch_shift(); if (_string_pool.is_modified()) { - write_stringpool_safepoint(_string_pool, _chunkwriter); + write_stringpool(_string_pool, _chunkwriter); } _checkpoint_manager.on_rotation(); _storage.write_at_safepoint(); diff --git a/src/hotspot/share/jfr/recorder/stringpool/jfrStringPool.cpp b/src/hotspot/share/jfr/recorder/stringpool/jfrStringPool.cpp index de836b00064..f9d84d3dd26 100644 --- a/src/hotspot/share/jfr/recorder/stringpool/jfrStringPool.cpp +++ b/src/hotspot/share/jfr/recorder/stringpool/jfrStringPool.cpp @@ -32,6 +32,7 @@ #include "jfr/recorder/stringpool/jfrStringPool.hpp" #include "jfr/recorder/stringpool/jfrStringPoolWriter.hpp" #include "jfr/utilities/jfrLinkedList.inline.hpp" +#include "jfr/utilities/jfrSignal.hpp" #include "jfr/utilities/jfrTypes.hpp" #include "logging/log.hpp" #include "runtime/atomic.hpp" @@ -40,44 +41,19 @@ typedef JfrStringPool::BufferPtr BufferPtr; -static JfrStringPool* _instance = NULL; -static uint64_t store_generation = 0; -static uint64_t serialized_generation = 0; - -inline void set_generation(uint64_t value, uint64_t* const dest) { - assert(dest != NULL, "invariant"); - Atomic::release_store(dest, value); -} - -static void increment_store_generation() { - const uint64_t current_serialized = Atomic::load_acquire(&serialized_generation); - const uint64_t current_stored = Atomic::load_acquire(&store_generation); - if (current_serialized == current_stored) { - set_generation(current_serialized + 1, &store_generation); - } -} - -static bool increment_serialized_generation() { - const uint64_t current_stored = Atomic::load_acquire(&store_generation); - const uint64_t current_serialized = Atomic::load_acquire(&serialized_generation); - if (current_stored != current_serialized) { - set_generation(current_stored, &serialized_generation); - return true; - } - return false; -} +static JfrSignal _new_string; bool JfrStringPool::is_modified() { - return increment_serialized_generation(); + return _new_string.is_signaled(); } +static JfrStringPool* _instance = NULL; + JfrStringPool& JfrStringPool::instance() { return *_instance; } JfrStringPool* JfrStringPool::create(JfrChunkWriter& cw) { - store_generation = 0; - serialized_generation = 0; assert(_instance == NULL, "invariant"); _instance = new JfrStringPool(cw); return _instance; @@ -155,20 +131,16 @@ BufferPtr JfrStringPool::lease(Thread* thread, size_t size /* 0 */) { return buffer; } -bool JfrStringPool::add(bool epoch, jlong id, jstring string, JavaThread* jt) { +jboolean JfrStringPool::add(jlong id, jstring string, JavaThread* jt) { assert(jt != NULL, "invariant"); - const bool current_epoch = JfrTraceIdEpoch::epoch(); - if (current_epoch != epoch) { - return current_epoch; - } { JfrStringPoolWriter writer(jt); writer.write(id); writer.write(string); writer.inc_nof_strings(); } - increment_store_generation(); - return current_epoch; + _new_string.signal(); + return JNI_TRUE; } template