From fe396d8bf4514d147b79eb1116129ab846451101 Mon Sep 17 00:00:00 2001 From: Jaroslav Bachorik Date: Wed, 23 Sep 2015 14:25:02 +0200 Subject: [PATCH 1/9] 7199353: Define ConstructorProperties annotation type for MXBeans Reviewed-by: duke --- .../DefaultMXBeanMappingFactory.java | 20 +++- .../management/ConstructorProperties.java | 75 +++++++++++++ .../classes/javax/management/MXBean.java | 23 ++-- .../Introspector/AnnotationSecurityTest.java | 8 +- .../management/Introspector/Described.java | 2 +- .../management/Introspector/DescribedMX.java | 2 +- .../LegacyConstructorPropertiesTest.java | 105 ++++++++++++++++++ .../mxbean/AmbiguousConstructorTest.java | 6 +- .../mxbean/ExceptionDiagnosisTest.java | 5 +- .../javax/management/mxbean/LeakTest.java | 3 +- .../javax/management/mxbean/MXBeanTest.java | 3 +- .../management/mxbean/PropertyNamesTest.java | 5 +- .../javax/management/mxbean/TigerMXBean.java | 4 +- 13 files changed, 223 insertions(+), 38 deletions(-) create mode 100644 jdk/src/java.management/share/classes/javax/management/ConstructorProperties.java create mode 100644 jdk/test/javax/management/Introspector/LegacyConstructorPropertiesTest.java diff --git a/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/DefaultMXBeanMappingFactory.java b/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/DefaultMXBeanMappingFactory.java index 0b2835f9ee0..0cf1be360f7 100644 --- a/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/DefaultMXBeanMappingFactory.java +++ b/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/DefaultMXBeanMappingFactory.java @@ -60,6 +60,7 @@ import java.util.WeakHashMap; import javax.management.JMX; import javax.management.ObjectName; +import javax.management.ConstructorProperties; import javax.management.openmbean.ArrayType; import javax.management.openmbean.CompositeData; import javax.management.openmbean.CompositeDataInvocationHandler; @@ -1141,10 +1142,19 @@ public class DefaultMXBeanMappingFactory extends MXBeanMappingFactory { super(targetClass, itemNames); } - String applicable(Method[] getters) throws InvalidObjectException { - if (!JavaBeansAccessor.isAvailable()) - return "@ConstructorProperties annotation not available"; + private String[] getConstPropValues(Constructor ctr) { + // is constructor annotated by javax.management.ConstructorProperties ? + ConstructorProperties ctrProps = ctr.getAnnotation(ConstructorProperties.class); + if (ctrProps != null) { + return ctrProps.value(); + } else { + // try the legacy java.beans.ConstructorProperties annotation + String[] vals = JavaBeansAccessor.getConstructorPropertiesValue(ctr); + return vals; + } + } + String applicable(Method[] getters) throws InvalidObjectException { Class targetClass = getTargetClass(); Constructor[] constrs = targetClass.getConstructors(); @@ -1152,7 +1162,7 @@ public class DefaultMXBeanMappingFactory extends MXBeanMappingFactory { List> annotatedConstrList = newList(); for (Constructor constr : constrs) { if (Modifier.isPublic(constr.getModifiers()) - && JavaBeansAccessor.getConstructorPropertiesValue(constr) != null) + && getConstPropValues(constr) != null) annotatedConstrList.add(constr); } @@ -1181,7 +1191,7 @@ public class DefaultMXBeanMappingFactory extends MXBeanMappingFactory { // so we can test unambiguity. Set getterIndexSets = newSet(); for (Constructor constr : annotatedConstrList) { - String[] propertyNames = JavaBeansAccessor.getConstructorPropertiesValue(constr); + String[] propertyNames = getConstPropValues(constr); Type[] paramTypes = constr.getGenericParameterTypes(); if (paramTypes.length != propertyNames.length) { diff --git a/jdk/src/java.management/share/classes/javax/management/ConstructorProperties.java b/jdk/src/java.management/share/classes/javax/management/ConstructorProperties.java new file mode 100644 index 00000000000..7050208dfd1 --- /dev/null +++ b/jdk/src/java.management/share/classes/javax/management/ConstructorProperties.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2006, 2015 Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package javax.management; + +import java.lang.annotation.*; +import static java.lang.annotation.ElementType.*; +import static java.lang.annotation.RetentionPolicy.*; + +/** + *

+ * An annotation on a constructor that shows how the parameters of + * that constructor correspond to the constructed object's getter + * methods. For example: +*

+ *
+ *
+ *         public class MemoryUsage {
+ *             // standard JavaBean conventions with getters
+ *             @ConstructorProperties({"init", "used", "committed", "max"})
+ *             public MemoryUsage(long init, long used,
+ *                                long committed, long max) {...}
+ *             long getInit() {...}
+ *             long getUsed() {...}
+ *             long getCommitted() {...}
+ *             long getMax() {...}
+ *         }
+ *     
+ *
+ *

+ * The annotation shows that the first parameter of the constructor + * can be retrieved with the {@code getInit()} method, the second one with + * the {@code getUsed()} method, and so on. Since parameter names are not in + * general available at runtime, without the annotation there would be + * no way of knowing which parameter corresponds to which property. + *

+ *

+ * If a constructor is annotated by the both {@code @java.beans.ConstructorProperties} + * and {@code @javax.management.annotation.ConstructorProperties} annotations + * the JMX introspection will give an absolute precedence to the later one. + *

+ * + * @since 1.9 + */ +@Documented @Target(CONSTRUCTOR) @Retention(RUNTIME) +public @interface ConstructorProperties { + /** +

The getter names.

+ @return the getter names corresponding to the parameters in the + annotated constructor. + */ + String[] value(); +} diff --git a/jdk/src/java.management/share/classes/javax/management/MXBean.java b/jdk/src/java.management/share/classes/javax/management/MXBean.java index 766e36feda6..ed429cab8bf 100644 --- a/jdk/src/java.management/share/classes/javax/management/MXBean.java +++ b/jdk/src/java.management/share/classes/javax/management/MXBean.java @@ -168,8 +168,8 @@ public class MemoryUsage {

The definitions are the same in the two cases, except that with the MXBean, MemoryUsage no longer needs to be marked Serializable (though it can be). On - the other hand, we have added a {@code @ConstructorProperties} annotation - to link the constructor parameters to the corresponding getters. + the other hand, we have added a {@link ConstructorProperties @ConstructorProperties} + annotation to link the constructor parameters to the corresponding getters. We will see more about this below.

MemoryUsage is a model-specific class. @@ -850,10 +850,16 @@ public interface ModuleMXBean { J.

  • Otherwise, if J has at least one public - constructor with a {@link java.beans.ConstructorProperties - ConstructorProperties} annotation, then one - of those constructors (not necessarily always the same one) - will be called to reconstruct an instance of J. + constructor with either {@link javax.management.ConstructorProperties + @javax.management.ConstructorProperties} or + {@code @java.beans.ConstructoProperties} annotation, then one of those + constructors (not necessarily always the same one) will be called to + reconstruct an instance of J. + If a constructor is annotated with both + {@code @javax.management.ConstructorProperties} and + {@code @java.beans.ConstructorProperties}, + {@code @javax.management.ConstructorProperties} will be used and + {@code @java.beans.ConstructorProperties} will be ignored. Every such annotation must list as many strings as the constructor has parameters; each string must name a property corresponding to a getter of J; and the type of this @@ -909,8 +915,9 @@ public interface ModuleMXBean {

  • Otherwise, J is not reconstructible.

  • -

    Rule 2 is not applicable to subset Profiles of Java SE that do not - include the {@code java.beans} package. When targeting a runtime that does +

    When {@code @java.beans.ConstructorProperties} is used then rule 2 is not + applicable to subset Profiles of Java SE that do not include the + {@code java.beans} package. When targeting a runtime that does not include the {@code java.beans} package, and where there is a mismatch between the compile-time and runtime environment whereby J is compiled with a public constructor and the {@code ConstructorProperties} diff --git a/jdk/test/javax/management/Introspector/AnnotationSecurityTest.java b/jdk/test/javax/management/Introspector/AnnotationSecurityTest.java index 2d07a0a61bd..0afb509272c 100644 --- a/jdk/test/javax/management/Introspector/AnnotationSecurityTest.java +++ b/jdk/test/javax/management/Introspector/AnnotationSecurityTest.java @@ -27,8 +27,7 @@ * @summary Test that having a security manager doesn't trigger a * NotCompliantMBeanException * @author Daniel Fuchs, Yves Joan - * @modules java.desktop - * java.management + * @modules java.management * @run clean AnnotationSecurityTest Described UnDescribed DescribedMBean * UnDescribedMBean SqeDescriptorKey DescribedMX DescribedMXBean * @run build AnnotationSecurityTest Described UnDescribed DescribedMBean @@ -40,13 +39,8 @@ import java.io.File; import java.io.IOException; -import java.lang.annotation.Annotation; import java.lang.management.ManagementFactory; -import java.lang.reflect.AnnotatedElement; import java.lang.reflect.Method; -import java.lang.reflect.UndeclaredThrowableException; - -import javax.management.JMException; import javax.management.MBeanServer; import javax.management.ObjectName; /** diff --git a/jdk/test/javax/management/Introspector/Described.java b/jdk/test/javax/management/Introspector/Described.java index 1ef62efb54c..b29d61fa1a5 100644 --- a/jdk/test/javax/management/Introspector/Described.java +++ b/jdk/test/javax/management/Introspector/Described.java @@ -25,7 +25,7 @@ * * Used by AnnotationSecurityTest.java **/ -import java.beans.ConstructorProperties; +import javax.management.ConstructorProperties; /** * An MBean used by AnnotationSecurityTest.java diff --git a/jdk/test/javax/management/Introspector/DescribedMX.java b/jdk/test/javax/management/Introspector/DescribedMX.java index 625cc65f8af..0685452cd96 100644 --- a/jdk/test/javax/management/Introspector/DescribedMX.java +++ b/jdk/test/javax/management/Introspector/DescribedMX.java @@ -25,7 +25,7 @@ * * Used by AnnotationSecurityTest.java **/ -import java.beans.ConstructorProperties; +import javax.management.ConstructorProperties; /** * An MXBean used by AnnotationSecurityTest.java diff --git a/jdk/test/javax/management/Introspector/LegacyConstructorPropertiesTest.java b/jdk/test/javax/management/Introspector/LegacyConstructorPropertiesTest.java new file mode 100644 index 00000000000..1750e90fab5 --- /dev/null +++ b/jdk/test/javax/management/Introspector/LegacyConstructorPropertiesTest.java @@ -0,0 +1,105 @@ + +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.beans.ConstructorProperties; +import javax.management.MBeanServer; +import javax.management.MBeanServerFactory; +import javax.management.ObjectName; + +/* + * @test + * @bug 7199353 + * @summary Asserts that 'java.beans.ConstructorProperties' annotation is still + * recognized and properly handled for custom types mapped to open types. + * Also, makes sure that if the same constructor is annotated by both + * j.b.ConstructorProperties and j.m.ConstructorProperties annotations + * only j.m.ConstructorProperties annotation is considered. + * @author Jaroslav Bachorik + * @modules java.management + * java.desktop + * @run main LegacyConstructorPropertiesTest + */ + +public class LegacyConstructorPropertiesTest { + public static class CustomType { + private String name; + private int value; + @ConstructorProperties({"name", "value"}) + public CustomType(String name, int value) { + this.name = name; + this.value = value; + } + + // if @java.beans.ConstructorProperties would be used + // the introspector would choke on this + @ConstructorProperties("noname") + @javax.management.ConstructorProperties("name") + public CustomType(String name) { + this.name = name; + this.value = -1; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + } + + public static interface CustomMXBean { + public CustomType getProp(); + public void setProp(CustomType prop); + } + + public static final class Custom implements CustomMXBean { + private CustomType prop; + + @Override + public CustomType getProp() { + return prop; + } + + @Override + public void setProp(CustomType prop) { + this.prop = prop; + } + } + + public static void main(String[] args) throws Exception { + MBeanServer mbs = MBeanServerFactory.createMBeanServer(); + CustomMXBean mbean = new Custom(); + + mbs.registerMBean(mbean, ObjectName.getInstance("test:type=Custom")); + } +} diff --git a/jdk/test/javax/management/mxbean/AmbiguousConstructorTest.java b/jdk/test/javax/management/mxbean/AmbiguousConstructorTest.java index 2b251f66d26..6efdac8915d 100644 --- a/jdk/test/javax/management/mxbean/AmbiguousConstructorTest.java +++ b/jdk/test/javax/management/mxbean/AmbiguousConstructorTest.java @@ -26,15 +26,13 @@ * @bug 6175517 6278707 * @summary Test that ambiguous ConstructorProperties annotations are detected. * @author Eamonn McManus - * @modules java.desktop - * java.management + * @modules java.management * @run clean AmbiguousConstructorTest * @run build AmbiguousConstructorTest * @run main AmbiguousConstructorTest */ -import java.beans.ConstructorProperties; -import java.io.InvalidObjectException; +import javax.management.ConstructorProperties; import javax.management.*; public class AmbiguousConstructorTest { diff --git a/jdk/test/javax/management/mxbean/ExceptionDiagnosisTest.java b/jdk/test/javax/management/mxbean/ExceptionDiagnosisTest.java index 89ca763cfea..52f6c0d9d37 100644 --- a/jdk/test/javax/management/mxbean/ExceptionDiagnosisTest.java +++ b/jdk/test/javax/management/mxbean/ExceptionDiagnosisTest.java @@ -26,11 +26,10 @@ * @bug 6713777 * @summary Test that exception messages include all relevant information * @author Eamonn McManus - * @modules java.desktop - * java.management + * @modules java.management */ -import java.beans.ConstructorProperties; +import javax.management.ConstructorProperties; import java.io.File; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; diff --git a/jdk/test/javax/management/mxbean/LeakTest.java b/jdk/test/javax/management/mxbean/LeakTest.java index 982ec225d4b..43ac996ab5e 100644 --- a/jdk/test/javax/management/mxbean/LeakTest.java +++ b/jdk/test/javax/management/mxbean/LeakTest.java @@ -25,8 +25,7 @@ * @bug 6482247 * @summary Test that creating MXBeans does not introduce memory leaks. * @author Eamonn McManus - * @modules java.desktop - * java.management + * @modules java.management * @run build LeakTest RandomMXBeanTest MerlinMXBean TigerMXBean * @run main LeakTest */ diff --git a/jdk/test/javax/management/mxbean/MXBeanTest.java b/jdk/test/javax/management/mxbean/MXBeanTest.java index 9017d497a0d..6123be2365e 100644 --- a/jdk/test/javax/management/mxbean/MXBeanTest.java +++ b/jdk/test/javax/management/mxbean/MXBeanTest.java @@ -27,8 +27,7 @@ * @summary General MXBean test. * @author Eamonn McManus * @author Jaroslav Bachorik - * @modules java.desktop - * java.management + * @modules java.management * @run clean MXBeanTest MerlinMXBean TigerMXBean * @run build MXBeanTest MerlinMXBean TigerMXBean * @run main MXBeanTest diff --git a/jdk/test/javax/management/mxbean/PropertyNamesTest.java b/jdk/test/javax/management/mxbean/PropertyNamesTest.java index d8f6845ffd2..40e0c35fad2 100644 --- a/jdk/test/javax/management/mxbean/PropertyNamesTest.java +++ b/jdk/test/javax/management/mxbean/PropertyNamesTest.java @@ -26,14 +26,13 @@ * @bug 6175517 * @summary Test the PropertyNames annotation with MXBeans * @author Eamonn McManus - * @modules java.desktop - * java.management + * @modules java.management * @run clean PropertyNamesTest * @run build PropertyNamesTest * @run main PropertyNamesTest */ -import java.beans.ConstructorProperties; +import javax.management.ConstructorProperties; import java.util.Collections; import java.util.List; import javax.management.JMX; diff --git a/jdk/test/javax/management/mxbean/TigerMXBean.java b/jdk/test/javax/management/mxbean/TigerMXBean.java index cfc47a90b2c..a5e84834ec3 100644 --- a/jdk/test/javax/management/mxbean/TigerMXBean.java +++ b/jdk/test/javax/management/mxbean/TigerMXBean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,7 +21,7 @@ * questions. */ -import java.beans.ConstructorProperties; +import javax.management.ConstructorProperties; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; From 37668179b5b6adc2de82ceb2803ead7581172118 Mon Sep 17 00:00:00 2001 From: Dmitry Samersoff Date: Thu, 24 Sep 2015 20:40:12 +0300 Subject: [PATCH 2/9] 8086134: Deadlock detection fails to attach to core file Test reimplemented for jtreg Reviewed-by: jbachorik --- .../tools/jstack/DeadlockDetectionTest.java | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 jdk/test/sun/tools/jstack/DeadlockDetectionTest.java diff --git a/jdk/test/sun/tools/jstack/DeadlockDetectionTest.java b/jdk/test/sun/tools/jstack/DeadlockDetectionTest.java new file mode 100644 index 00000000000..31cdf311830 --- /dev/null +++ b/jdk/test/sun/tools/jstack/DeadlockDetectionTest.java @@ -0,0 +1,107 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import jdk.test.lib.apps.LingeredApp; +import jdk.test.lib.apps.LingeredAppWithDeadlock; + +import jdk.testlibrary.Utils; +import jdk.testlibrary.Platform; +import jdk.testlibrary.JDKToolLauncher; +import jdk.testlibrary.OutputAnalyzer; +import jdk.testlibrary.ProcessTools; + +/* + * @test + * @summary Test deadlock detection + * @library /../../test/lib/share/classes + * @library /lib/testlibrary + * @modules java.management + * @build jdk.testlibrary.* + * @build jdk.test.lib.apps.* + * @build DeadlockDetectionTest + * @run main DeadlockDetectionTest + */ +public class DeadlockDetectionTest { + + private static LingeredAppWithDeadlock theApp = null; + private static ProcessBuilder processBuilder = new ProcessBuilder(); + + private static OutputAnalyzer jstack(String... toolArgs) throws Exception { + JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jstack"); + launcher.addVMArg("-XX:+UsePerfData"); + if (toolArgs != null) { + for (String toolArg : toolArgs) { + launcher.addToolArg(toolArg); + } + } + + processBuilder.command(launcher.getCommand()); + System.out.println(processBuilder.command().stream().collect(Collectors.joining(" "))); + OutputAnalyzer output = ProcessTools.executeProcess(processBuilder); + System.out.println(output.getOutput()); + + return output; + } + + public static void main(String[] args) throws Exception { + System.out.println("Starting DeadlockDetectionTest"); + + if (!Platform.shouldSAAttach()) { + // Silently skip the test if we don't have enough permissions to attach + System.err.println("Error! Insufficient permissions to attach."); + return; + } + + if (!LingeredApp.isLastModifiedWorking()) { + // Exact behaviour of the test depends on operating system and the test nature, + // so just print the warning and continue + System.err.println("Warning! Last modified time doesn't work."); + } + + try { + List vmArgs = new ArrayList(); + vmArgs.add("-XX:+UsePerfData"); + vmArgs.addAll(Utils.getVmOptions()); + + theApp = new LingeredAppWithDeadlock(); + LingeredApp.startApp(vmArgs, theApp); + OutputAnalyzer output = jstack(Long.toString(theApp.getPid())); + System.out.println(output.getOutput()); + + if (output.getExitValue() == 3) { + System.out.println("Test can't run for some reason. Skipping"); + } + else { + output.shouldHaveExitValue(0); + output.shouldContain("Found 1 deadlock."); + } + + } finally { + LingeredApp.stopApp(theApp); + } + } +} From 768d7cfe712ef92c62efdc7c7961e9ef26477c03 Mon Sep 17 00:00:00 2001 From: Dmitry Samersoff Date: Thu, 1 Oct 2015 10:33:29 +0300 Subject: [PATCH 3/9] 8133063: Remove BasicLauncherTest from the problem list Remove BasicLauncherTest from the problem list Reviewed-by: jbachorik --- jdk/test/ProblemList.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 19e469d8942..58cec83e990 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -386,7 +386,4 @@ sun/tools/jinfo/JInfoRunningProcessFlagTest.java generic-all # 8057732 sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java generic-all -# 8132648 -sun/tools/jhsdb/BasicLauncherTest.java generic-all - ############################################################################ From 7d1251ff1224840c9245b0561349b158ea76260a Mon Sep 17 00:00:00 2001 From: Jaroslav Bachorik Date: Fri, 2 Oct 2015 18:49:54 +0200 Subject: [PATCH 4/9] 8138748: ManagementAgent.status DCMD fails with NPE for JMX configured on command line Reviewed-by: sspitsyn, dsamersoff, olagneau --- .../share/classes/sun/management/Agent.java | 5 +- .../jmxremote/startstop/JMXStatus1Test.java | 41 ++++++++++++ .../jmxremote/startstop/JMXStatus2Test.java | 44 +++++++++++++ .../jmxremote/startstop/JMXStatusTest.java | 65 ++++++++++--------- 4 files changed, 125 insertions(+), 30 deletions(-) create mode 100644 jdk/test/sun/management/jmxremote/startstop/JMXStatus1Test.java create mode 100644 jdk/test/sun/management/jmxremote/startstop/JMXStatus2Test.java diff --git a/jdk/src/java.management/share/classes/sun/management/Agent.java b/jdk/src/java.management/share/classes/sun/management/Agent.java index e0b781dc71c..6a236fd8f3a 100644 --- a/jdk/src/java.management/share/classes/sun/management/Agent.java +++ b/jdk/src/java.management/share/classes/sun/management/Agent.java @@ -102,7 +102,10 @@ public class Agent { private void addConfigProperties() { appendConfigPropsHeader(); boolean[] first = new boolean[] {true}; - configProps.entrySet().stream().forEach((e) -> { + Properties props = configProps != null ? + configProps : getManagementProperties(); + + props.entrySet().stream().forEach((e) -> { String key = (String)e.getKey(); if (key.startsWith("com.sun.management.")) { addConfigProp(key, e.getValue(), first[0]); diff --git a/jdk/test/sun/management/jmxremote/startstop/JMXStatus1Test.java b/jdk/test/sun/management/jmxremote/startstop/JMXStatus1Test.java new file mode 100644 index 00000000000..059c9b45e30 --- /dev/null +++ b/jdk/test/sun/management/jmxremote/startstop/JMXStatus1Test.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +import java.util.Collections; +import java.util.List; +import java.util.regex.Pattern; + +/** + * A flavor of {@linkplain JMXStatusTest} test where the test application + * is started without the management agent initialized. + */ +public class JMXStatus1Test extends JMXStatusTest { + @Override + protected List getCustomVmArgs() { + return Collections.emptyList(); + } + + @Override + protected Pattern getDefaultPattern() { + return JMXStatusTest.DISABLED_AGENT_STATUS; + } +} \ No newline at end of file diff --git a/jdk/test/sun/management/jmxremote/startstop/JMXStatus2Test.java b/jdk/test/sun/management/jmxremote/startstop/JMXStatus2Test.java new file mode 100644 index 00000000000..d4ce0085457 --- /dev/null +++ b/jdk/test/sun/management/jmxremote/startstop/JMXStatus2Test.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +import java.util.Arrays; +import java.util.List; +import java.util.regex.Pattern; + +/** + * A flavor of {@linkplain JMXStatusTest} test where the test application + * is started with the management agent initialized. + */ +public class JMXStatus2Test extends JMXStatusTest { + @Override + protected List getCustomVmArgs() { + // not specifying the jmxremote.port > only local agent started + return Arrays.asList( + "-Dcom.sun.management.jmxremote" + ); + } + + @Override + protected Pattern getDefaultPattern() { + return JMXStatusTest.LOCAL_AGENT_STATUS; + } +} \ No newline at end of file diff --git a/jdk/test/sun/management/jmxremote/startstop/JMXStatusTest.java b/jdk/test/sun/management/jmxremote/startstop/JMXStatusTest.java index 0f516b6b504..84943bd69d9 100644 --- a/jdk/test/sun/management/jmxremote/startstop/JMXStatusTest.java +++ b/jdk/test/sun/management/jmxremote/startstop/JMXStatusTest.java @@ -22,6 +22,8 @@ */ import java.net.BindException; +import java.util.ArrayList; +import java.util.List; import java.util.function.Predicate; import java.util.regex.Pattern; import org.testng.annotations.*; @@ -31,23 +33,25 @@ import jdk.testlibrary.ProcessTools; /** * @test - * @bug 8023093 + * @bug 8023093 8138748 * @summary Performs a sanity test for the ManagementAgent.status diagnostic command. - * Management agent may be disable, started (only local connections) and started. + * Management agent may be disabled, started (only local connections) and started. * The test asserts that the expected text is being printed. * @library /lib/testlibrary * @modules java.management/sun.management * @build jdk.testlibrary.* PortAllocator TestApp ManagementAgentJcmd - * @run testng/othervm -XX:+UsePerfData JMXStatusTest + * JMXStatusTest JMXStatus1Test JMXStatus2Test + * @run testng/othervm -XX:+UsePerfData JMXStatus1Test + * @run testng/othervm -XX:+UsePerfData JMXStatus2Test */ -public class JMXStatusTest { +abstract public class JMXStatusTest { private final static String TEST_APP_NAME = "TestApp"; - private final static Pattern DISABLE_AGENT_STATUS = Pattern.compile( + protected final static Pattern DISABLED_AGENT_STATUS = Pattern.compile( "Agent\\s*\\: disabled$" ); - private final static Pattern LOCAL_AGENT_STATUS = Pattern.compile( + protected final static Pattern LOCAL_AGENT_STATUS = Pattern.compile( "Agent\\s*\\:\\s*enabled\\n+" + "Connection Type\\s*\\:\\s*local\\n+" + "Protocol\\s*\\:\\s*[a-z]+\\n+" + @@ -56,14 +60,15 @@ public class JMXStatusTest { Pattern.MULTILINE ); - private final static Pattern REMOTE_AGENT_STATUS = Pattern.compile( + protected final static Pattern REMOTE_AGENT_STATUS = Pattern.compile( "Agent\\s*\\: enabled\\n+" + + ".*" + "Connection Type\\s*\\: remote\\n+" + "Protocol\\s*\\: [a-z]+\\n+" + "Host\\s*\\: .+\\n+" + "URL\\s*\\: service\\:jmx\\:.+\\n+" + "Properties\\s*\\:\\n+(\\s*\\S+\\s*=\\s*\\S+\\n*)+", - Pattern.MULTILINE + Pattern.MULTILINE | Pattern.DOTALL ); private static ProcessBuilder testAppPb; @@ -71,22 +76,24 @@ public class JMXStatusTest { private ManagementAgentJcmd jcmd; - @BeforeClass - public static void setupClass() throws Exception { - testAppPb = ProcessTools.createJavaProcessBuilder( - "-cp", System.getProperty("test.class.path"), - "-XX:+UsePerfData", - TEST_APP_NAME - ); - } + abstract protected List getCustomVmArgs(); + abstract protected Pattern getDefaultPattern(); @BeforeTest - public void setup() { + public final void setup() throws Exception { + List args = new ArrayList<>(); + args.add("-cp"); + args.add(System.getProperty("test.class.path")); + args.add("-XX:+UsePerfData"); + args.addAll(getCustomVmArgs()); + args.add(TEST_APP_NAME); + testAppPb = ProcessTools.createJavaProcessBuilder(args.toArray(new String[args.size()])); + jcmd = new ManagementAgentJcmd(TEST_APP_NAME, false); } @BeforeMethod - public void startTestApp() throws Exception { + public final void startTestApp() throws Exception { testApp = ProcessTools.startProcess( TEST_APP_NAME, testAppPb, (Predicate)l->l.trim().equals("main enter") @@ -94,7 +101,7 @@ public class JMXStatusTest { } @AfterMethod - public void stopTestApp() throws Exception { + public final void stopTestApp() throws Exception { testApp.getOutputStream().write(1); testApp.getOutputStream().flush(); testApp.waitFor(); @@ -102,13 +109,7 @@ public class JMXStatusTest { } @Test - public void testAgentDisabled() throws Exception { - String status = jcmd.status(); - assertStatusMatches(DISABLE_AGENT_STATUS, status); - } - - @Test - public void testAgentLocal() throws Exception { + public final void testAgentLocal() throws Exception { jcmd.startLocal(); String status = jcmd.status(); @@ -116,7 +117,7 @@ public class JMXStatusTest { } @Test - public void testAgentRemote() throws Exception { + public final void testAgentRemote() throws Exception { while (true) { try { int[] ports = PortAllocator.allocatePorts(1); @@ -135,11 +136,17 @@ public class JMXStatusTest { } } - private void assertStatusMatches(Pattern expected, String value) { + @Test + public final void testAgentDefault() throws Exception { + String status = jcmd.status(); + assertStatusMatches(getDefaultPattern(), status); + } + + protected void assertStatusMatches(Pattern expected, String value) { assertStatusMatches(expected, value, ""); } - private void assertStatusMatches(Pattern expected, String value, String msg) { + protected void assertStatusMatches(Pattern expected, String value, String msg) { int idx = value.indexOf('\n'); if (idx > -1) { value = value.substring(idx + 1).trim(); From efc0baaf9729daca9045df7e790c03d3b0f8ca41 Mon Sep 17 00:00:00 2001 From: Zoltan Majo Date: Mon, 5 Oct 2015 10:30:20 +0200 Subject: [PATCH 5/9] 8137173: @HotSpotIntrinsicCandidate is not Oracle-specific Change the description of the @HotSpotIntrinsicCandidate annotation. Reviewed-by: mr, alanb --- .../share/classes/jdk/internal/HotSpotIntrinsicCandidate.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/src/java.base/share/classes/jdk/internal/HotSpotIntrinsicCandidate.java b/jdk/src/java.base/share/classes/jdk/internal/HotSpotIntrinsicCandidate.java index e3efada1a7c..95ea0b44b87 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/HotSpotIntrinsicCandidate.java +++ b/jdk/src/java.base/share/classes/jdk/internal/HotSpotIntrinsicCandidate.java @@ -28,8 +28,8 @@ package jdk.internal; import java.lang.annotation.*; /** - * The {@code @HotSpotIntrinsicCandidate} annotation is specific to the Oracle Java - * HotSpot Virtual Machine implementation and indicates that an annotated method + * The {@code @HotSpotIntrinsicCandidate} annotation is specific to the + * HotSpot Virtual Machine. It indicates that an annotated method * may be (but is not guaranteed to be) intrinsified by the HotSpot VM. A method * is intrinsified if the HotSpot VM replaces the annotated method with hand-written * assembly and/or hand-written compiler IR -- a compiler intrinsic -- to improve From 64e85130bb2169d651a842b8f003e3b96135a1b2 Mon Sep 17 00:00:00 2001 From: Jaroslav Bachorik Date: Thu, 8 Oct 2015 09:40:31 +0200 Subject: [PATCH 6/9] 8138579: Custom launcher fails to start because of permission problem Reviewed-by: sspitsyn, dsamersoff --- .../sun/management/jmxremote/bootstrap/CustomLauncherTest.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java b/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java index 8542c98515f..5e61420ddeb 100644 --- a/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java +++ b/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java @@ -255,8 +255,7 @@ public class CustomLauncherTest { // and set the executable flag Path localLauncherPath = FS.getPath(WORK_DIR, "launcher"); Files.copy(launcherPath, localLauncherPath, - StandardCopyOption.REPLACE_EXISTING, - StandardCopyOption.COPY_ATTRIBUTES); + StandardCopyOption.REPLACE_EXISTING); if (!Files.isExecutable(localLauncherPath)) { Set perms = new HashSet<>( Files.getPosixFilePermissions( From e83a2f1ef420ee1c5d31067767e252fc1d348799 Mon Sep 17 00:00:00 2001 From: Christian Thalinger Date: Thu, 8 Oct 2015 13:32:45 -1000 Subject: [PATCH 7/9] 8136421: JEP 243: Java-Level JVM Compiler Interface Reviewed-by: ihse, alanb, roland, coleenp, iveresov, kvn, kbarrett --- jdk/make/src/classes/build/tools/module/boot.modules | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/make/src/classes/build/tools/module/boot.modules b/jdk/make/src/classes/build/tools/module/boot.modules index 6830c6c8335..02de8910651 100644 --- a/jdk/make/src/classes/build/tools/module/boot.modules +++ b/jdk/make/src/classes/build/tools/module/boot.modules @@ -29,3 +29,4 @@ jdk.sctp jdk.security.auth jdk.security.jgss jdk.snmp +jdk.vm.ci From 8a269a674bb7714f75cc95da4245f0af6540cba1 Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Mon, 12 Oct 2015 15:41:50 +0200 Subject: [PATCH 8/9] 8134607: Remove per-compiler performance counters Reviewed-by: twisti, neliasso --- .../share/classes/sun/management/CompilerThreadStat.java | 1 + .../share/classes/sun/management/HotspotCompilation.java | 2 ++ .../share/classes/sun/management/HotspotCompilationMBean.java | 1 + 3 files changed, 4 insertions(+) diff --git a/jdk/src/java.management/share/classes/sun/management/CompilerThreadStat.java b/jdk/src/java.management/share/classes/sun/management/CompilerThreadStat.java index 3317cf0c76f..9ebffa3dc06 100644 --- a/jdk/src/java.management/share/classes/sun/management/CompilerThreadStat.java +++ b/jdk/src/java.management/share/classes/sun/management/CompilerThreadStat.java @@ -27,6 +27,7 @@ package sun.management; /** */ +@Deprecated public class CompilerThreadStat implements java.io.Serializable { private String name; private long taskCount; diff --git a/jdk/src/java.management/share/classes/sun/management/HotspotCompilation.java b/jdk/src/java.management/share/classes/sun/management/HotspotCompilation.java index 920d972664e..e7e29b3e20b 100644 --- a/jdk/src/java.management/share/classes/sun/management/HotspotCompilation.java +++ b/jdk/src/java.management/share/classes/sun/management/HotspotCompilation.java @@ -90,6 +90,7 @@ class HotspotCompilation this.time = (LongCounter) lookup(basename + "time"); } + @SuppressWarnings("deprecation") CompilerThreadStat getCompilerThreadStat() { MethodInfo minfo = new MethodInfo(method.stringValue(), (int) type.longValue(), @@ -182,6 +183,7 @@ class HotspotCompilation return nmethodSize.longValue(); } + @Deprecated public List getCompilerThreadStats() { List list = new ArrayList<>(threads.size()); for (CompilerThreadInfo info : threads) { diff --git a/jdk/src/java.management/share/classes/sun/management/HotspotCompilationMBean.java b/jdk/src/java.management/share/classes/sun/management/HotspotCompilationMBean.java index 8085a0e6666..2a9849f0abb 100644 --- a/jdk/src/java.management/share/classes/sun/management/HotspotCompilationMBean.java +++ b/jdk/src/java.management/share/classes/sun/management/HotspotCompilationMBean.java @@ -46,6 +46,7 @@ public interface HotspotCompilationMBean { * the statistic of a compiler thread. * */ + @Deprecated public java.util.List getCompilerThreadStats(); /** From 4f7119fdef9c5b1e9b777d093ef97ebdd141e5f1 Mon Sep 17 00:00:00 2001 From: Jaroslav Bachorik Date: Fri, 16 Oct 2015 06:29:36 +0200 Subject: [PATCH 9/9] 8139725: Backout escaped partial fix for JDK-7199353 Reviewed-by: alanb --- .../DefaultMXBeanMappingFactory.java | 20 +--- .../management/ConstructorProperties.java | 75 ------------- .../classes/javax/management/MXBean.java | 23 ++-- .../Introspector/AnnotationSecurityTest.java | 8 +- .../management/Introspector/Described.java | 2 +- .../management/Introspector/DescribedMX.java | 2 +- .../LegacyConstructorPropertiesTest.java | 105 ------------------ .../mxbean/AmbiguousConstructorTest.java | 6 +- .../mxbean/ExceptionDiagnosisTest.java | 5 +- .../javax/management/mxbean/LeakTest.java | 3 +- .../javax/management/mxbean/MXBeanTest.java | 3 +- .../management/mxbean/PropertyNamesTest.java | 5 +- .../javax/management/mxbean/TigerMXBean.java | 4 +- 13 files changed, 38 insertions(+), 223 deletions(-) delete mode 100644 jdk/src/java.management/share/classes/javax/management/ConstructorProperties.java delete mode 100644 jdk/test/javax/management/Introspector/LegacyConstructorPropertiesTest.java diff --git a/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/DefaultMXBeanMappingFactory.java b/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/DefaultMXBeanMappingFactory.java index 0cf1be360f7..0b2835f9ee0 100644 --- a/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/DefaultMXBeanMappingFactory.java +++ b/jdk/src/java.management/share/classes/com/sun/jmx/mbeanserver/DefaultMXBeanMappingFactory.java @@ -60,7 +60,6 @@ import java.util.WeakHashMap; import javax.management.JMX; import javax.management.ObjectName; -import javax.management.ConstructorProperties; import javax.management.openmbean.ArrayType; import javax.management.openmbean.CompositeData; import javax.management.openmbean.CompositeDataInvocationHandler; @@ -1142,19 +1141,10 @@ public class DefaultMXBeanMappingFactory extends MXBeanMappingFactory { super(targetClass, itemNames); } - private String[] getConstPropValues(Constructor ctr) { - // is constructor annotated by javax.management.ConstructorProperties ? - ConstructorProperties ctrProps = ctr.getAnnotation(ConstructorProperties.class); - if (ctrProps != null) { - return ctrProps.value(); - } else { - // try the legacy java.beans.ConstructorProperties annotation - String[] vals = JavaBeansAccessor.getConstructorPropertiesValue(ctr); - return vals; - } - } - String applicable(Method[] getters) throws InvalidObjectException { + if (!JavaBeansAccessor.isAvailable()) + return "@ConstructorProperties annotation not available"; + Class targetClass = getTargetClass(); Constructor[] constrs = targetClass.getConstructors(); @@ -1162,7 +1152,7 @@ public class DefaultMXBeanMappingFactory extends MXBeanMappingFactory { List> annotatedConstrList = newList(); for (Constructor constr : constrs) { if (Modifier.isPublic(constr.getModifiers()) - && getConstPropValues(constr) != null) + && JavaBeansAccessor.getConstructorPropertiesValue(constr) != null) annotatedConstrList.add(constr); } @@ -1191,7 +1181,7 @@ public class DefaultMXBeanMappingFactory extends MXBeanMappingFactory { // so we can test unambiguity. Set getterIndexSets = newSet(); for (Constructor constr : annotatedConstrList) { - String[] propertyNames = getConstPropValues(constr); + String[] propertyNames = JavaBeansAccessor.getConstructorPropertiesValue(constr); Type[] paramTypes = constr.getGenericParameterTypes(); if (paramTypes.length != propertyNames.length) { diff --git a/jdk/src/java.management/share/classes/javax/management/ConstructorProperties.java b/jdk/src/java.management/share/classes/javax/management/ConstructorProperties.java deleted file mode 100644 index 7050208dfd1..00000000000 --- a/jdk/src/java.management/share/classes/javax/management/ConstructorProperties.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2006, 2015 Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package javax.management; - -import java.lang.annotation.*; -import static java.lang.annotation.ElementType.*; -import static java.lang.annotation.RetentionPolicy.*; - -/** - *

    - * An annotation on a constructor that shows how the parameters of - * that constructor correspond to the constructed object's getter - * methods. For example: -*

    - *
    - *
    - *         public class MemoryUsage {
    - *             // standard JavaBean conventions with getters
    - *             @ConstructorProperties({"init", "used", "committed", "max"})
    - *             public MemoryUsage(long init, long used,
    - *                                long committed, long max) {...}
    - *             long getInit() {...}
    - *             long getUsed() {...}
    - *             long getCommitted() {...}
    - *             long getMax() {...}
    - *         }
    - *     
    - *
    - *

    - * The annotation shows that the first parameter of the constructor - * can be retrieved with the {@code getInit()} method, the second one with - * the {@code getUsed()} method, and so on. Since parameter names are not in - * general available at runtime, without the annotation there would be - * no way of knowing which parameter corresponds to which property. - *

    - *

    - * If a constructor is annotated by the both {@code @java.beans.ConstructorProperties} - * and {@code @javax.management.annotation.ConstructorProperties} annotations - * the JMX introspection will give an absolute precedence to the later one. - *

    - * - * @since 1.9 - */ -@Documented @Target(CONSTRUCTOR) @Retention(RUNTIME) -public @interface ConstructorProperties { - /** -

    The getter names.

    - @return the getter names corresponding to the parameters in the - annotated constructor. - */ - String[] value(); -} diff --git a/jdk/src/java.management/share/classes/javax/management/MXBean.java b/jdk/src/java.management/share/classes/javax/management/MXBean.java index ed429cab8bf..766e36feda6 100644 --- a/jdk/src/java.management/share/classes/javax/management/MXBean.java +++ b/jdk/src/java.management/share/classes/javax/management/MXBean.java @@ -168,8 +168,8 @@ public class MemoryUsage {

    The definitions are the same in the two cases, except that with the MXBean, MemoryUsage no longer needs to be marked Serializable (though it can be). On - the other hand, we have added a {@link ConstructorProperties @ConstructorProperties} - annotation to link the constructor parameters to the corresponding getters. + the other hand, we have added a {@code @ConstructorProperties} annotation + to link the constructor parameters to the corresponding getters. We will see more about this below.

    MemoryUsage is a model-specific class. @@ -850,16 +850,10 @@ public interface ModuleMXBean { J.

  • Otherwise, if J has at least one public - constructor with either {@link javax.management.ConstructorProperties - @javax.management.ConstructorProperties} or - {@code @java.beans.ConstructoProperties} annotation, then one of those - constructors (not necessarily always the same one) will be called to - reconstruct an instance of J. - If a constructor is annotated with both - {@code @javax.management.ConstructorProperties} and - {@code @java.beans.ConstructorProperties}, - {@code @javax.management.ConstructorProperties} will be used and - {@code @java.beans.ConstructorProperties} will be ignored. + constructor with a {@link java.beans.ConstructorProperties + ConstructorProperties} annotation, then one + of those constructors (not necessarily always the same one) + will be called to reconstruct an instance of J. Every such annotation must list as many strings as the constructor has parameters; each string must name a property corresponding to a getter of J; and the type of this @@ -915,9 +909,8 @@ public interface ModuleMXBean {

  • Otherwise, J is not reconstructible.

  • -

    When {@code @java.beans.ConstructorProperties} is used then rule 2 is not - applicable to subset Profiles of Java SE that do not include the - {@code java.beans} package. When targeting a runtime that does +

    Rule 2 is not applicable to subset Profiles of Java SE that do not + include the {@code java.beans} package. When targeting a runtime that does not include the {@code java.beans} package, and where there is a mismatch between the compile-time and runtime environment whereby J is compiled with a public constructor and the {@code ConstructorProperties} diff --git a/jdk/test/javax/management/Introspector/AnnotationSecurityTest.java b/jdk/test/javax/management/Introspector/AnnotationSecurityTest.java index 0afb509272c..2d07a0a61bd 100644 --- a/jdk/test/javax/management/Introspector/AnnotationSecurityTest.java +++ b/jdk/test/javax/management/Introspector/AnnotationSecurityTest.java @@ -27,7 +27,8 @@ * @summary Test that having a security manager doesn't trigger a * NotCompliantMBeanException * @author Daniel Fuchs, Yves Joan - * @modules java.management + * @modules java.desktop + * java.management * @run clean AnnotationSecurityTest Described UnDescribed DescribedMBean * UnDescribedMBean SqeDescriptorKey DescribedMX DescribedMXBean * @run build AnnotationSecurityTest Described UnDescribed DescribedMBean @@ -39,8 +40,13 @@ import java.io.File; import java.io.IOException; +import java.lang.annotation.Annotation; import java.lang.management.ManagementFactory; +import java.lang.reflect.AnnotatedElement; import java.lang.reflect.Method; +import java.lang.reflect.UndeclaredThrowableException; + +import javax.management.JMException; import javax.management.MBeanServer; import javax.management.ObjectName; /** diff --git a/jdk/test/javax/management/Introspector/Described.java b/jdk/test/javax/management/Introspector/Described.java index b29d61fa1a5..1ef62efb54c 100644 --- a/jdk/test/javax/management/Introspector/Described.java +++ b/jdk/test/javax/management/Introspector/Described.java @@ -25,7 +25,7 @@ * * Used by AnnotationSecurityTest.java **/ -import javax.management.ConstructorProperties; +import java.beans.ConstructorProperties; /** * An MBean used by AnnotationSecurityTest.java diff --git a/jdk/test/javax/management/Introspector/DescribedMX.java b/jdk/test/javax/management/Introspector/DescribedMX.java index 0685452cd96..625cc65f8af 100644 --- a/jdk/test/javax/management/Introspector/DescribedMX.java +++ b/jdk/test/javax/management/Introspector/DescribedMX.java @@ -25,7 +25,7 @@ * * Used by AnnotationSecurityTest.java **/ -import javax.management.ConstructorProperties; +import java.beans.ConstructorProperties; /** * An MXBean used by AnnotationSecurityTest.java diff --git a/jdk/test/javax/management/Introspector/LegacyConstructorPropertiesTest.java b/jdk/test/javax/management/Introspector/LegacyConstructorPropertiesTest.java deleted file mode 100644 index 1750e90fab5..00000000000 --- a/jdk/test/javax/management/Introspector/LegacyConstructorPropertiesTest.java +++ /dev/null @@ -1,105 +0,0 @@ - -/* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -import java.beans.ConstructorProperties; -import javax.management.MBeanServer; -import javax.management.MBeanServerFactory; -import javax.management.ObjectName; - -/* - * @test - * @bug 7199353 - * @summary Asserts that 'java.beans.ConstructorProperties' annotation is still - * recognized and properly handled for custom types mapped to open types. - * Also, makes sure that if the same constructor is annotated by both - * j.b.ConstructorProperties and j.m.ConstructorProperties annotations - * only j.m.ConstructorProperties annotation is considered. - * @author Jaroslav Bachorik - * @modules java.management - * java.desktop - * @run main LegacyConstructorPropertiesTest - */ - -public class LegacyConstructorPropertiesTest { - public static class CustomType { - private String name; - private int value; - @ConstructorProperties({"name", "value"}) - public CustomType(String name, int value) { - this.name = name; - this.value = value; - } - - // if @java.beans.ConstructorProperties would be used - // the introspector would choke on this - @ConstructorProperties("noname") - @javax.management.ConstructorProperties("name") - public CustomType(String name) { - this.name = name; - this.value = -1; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getValue() { - return value; - } - - public void setValue(int value) { - this.value = value; - } - } - - public static interface CustomMXBean { - public CustomType getProp(); - public void setProp(CustomType prop); - } - - public static final class Custom implements CustomMXBean { - private CustomType prop; - - @Override - public CustomType getProp() { - return prop; - } - - @Override - public void setProp(CustomType prop) { - this.prop = prop; - } - } - - public static void main(String[] args) throws Exception { - MBeanServer mbs = MBeanServerFactory.createMBeanServer(); - CustomMXBean mbean = new Custom(); - - mbs.registerMBean(mbean, ObjectName.getInstance("test:type=Custom")); - } -} diff --git a/jdk/test/javax/management/mxbean/AmbiguousConstructorTest.java b/jdk/test/javax/management/mxbean/AmbiguousConstructorTest.java index 6efdac8915d..2b251f66d26 100644 --- a/jdk/test/javax/management/mxbean/AmbiguousConstructorTest.java +++ b/jdk/test/javax/management/mxbean/AmbiguousConstructorTest.java @@ -26,13 +26,15 @@ * @bug 6175517 6278707 * @summary Test that ambiguous ConstructorProperties annotations are detected. * @author Eamonn McManus - * @modules java.management + * @modules java.desktop + * java.management * @run clean AmbiguousConstructorTest * @run build AmbiguousConstructorTest * @run main AmbiguousConstructorTest */ -import javax.management.ConstructorProperties; +import java.beans.ConstructorProperties; +import java.io.InvalidObjectException; import javax.management.*; public class AmbiguousConstructorTest { diff --git a/jdk/test/javax/management/mxbean/ExceptionDiagnosisTest.java b/jdk/test/javax/management/mxbean/ExceptionDiagnosisTest.java index 52f6c0d9d37..89ca763cfea 100644 --- a/jdk/test/javax/management/mxbean/ExceptionDiagnosisTest.java +++ b/jdk/test/javax/management/mxbean/ExceptionDiagnosisTest.java @@ -26,10 +26,11 @@ * @bug 6713777 * @summary Test that exception messages include all relevant information * @author Eamonn McManus - * @modules java.management + * @modules java.desktop + * java.management */ -import javax.management.ConstructorProperties; +import java.beans.ConstructorProperties; import java.io.File; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; diff --git a/jdk/test/javax/management/mxbean/LeakTest.java b/jdk/test/javax/management/mxbean/LeakTest.java index 43ac996ab5e..982ec225d4b 100644 --- a/jdk/test/javax/management/mxbean/LeakTest.java +++ b/jdk/test/javax/management/mxbean/LeakTest.java @@ -25,7 +25,8 @@ * @bug 6482247 * @summary Test that creating MXBeans does not introduce memory leaks. * @author Eamonn McManus - * @modules java.management + * @modules java.desktop + * java.management * @run build LeakTest RandomMXBeanTest MerlinMXBean TigerMXBean * @run main LeakTest */ diff --git a/jdk/test/javax/management/mxbean/MXBeanTest.java b/jdk/test/javax/management/mxbean/MXBeanTest.java index 6123be2365e..9017d497a0d 100644 --- a/jdk/test/javax/management/mxbean/MXBeanTest.java +++ b/jdk/test/javax/management/mxbean/MXBeanTest.java @@ -27,7 +27,8 @@ * @summary General MXBean test. * @author Eamonn McManus * @author Jaroslav Bachorik - * @modules java.management + * @modules java.desktop + * java.management * @run clean MXBeanTest MerlinMXBean TigerMXBean * @run build MXBeanTest MerlinMXBean TigerMXBean * @run main MXBeanTest diff --git a/jdk/test/javax/management/mxbean/PropertyNamesTest.java b/jdk/test/javax/management/mxbean/PropertyNamesTest.java index 40e0c35fad2..d8f6845ffd2 100644 --- a/jdk/test/javax/management/mxbean/PropertyNamesTest.java +++ b/jdk/test/javax/management/mxbean/PropertyNamesTest.java @@ -26,13 +26,14 @@ * @bug 6175517 * @summary Test the PropertyNames annotation with MXBeans * @author Eamonn McManus - * @modules java.management + * @modules java.desktop + * java.management * @run clean PropertyNamesTest * @run build PropertyNamesTest * @run main PropertyNamesTest */ -import javax.management.ConstructorProperties; +import java.beans.ConstructorProperties; import java.util.Collections; import java.util.List; import javax.management.JMX; diff --git a/jdk/test/javax/management/mxbean/TigerMXBean.java b/jdk/test/javax/management/mxbean/TigerMXBean.java index a5e84834ec3..cfc47a90b2c 100644 --- a/jdk/test/javax/management/mxbean/TigerMXBean.java +++ b/jdk/test/javax/management/mxbean/TigerMXBean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,7 +21,7 @@ * questions. */ -import javax.management.ConstructorProperties; +import java.beans.ConstructorProperties; import java.util.Arrays; import java.util.Collections; import java.util.HashSet;