From 47c30dbc166e2d5e4331e4bff53ae9ebfb51d03f Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Sat, 2 May 2020 07:17:20 -0700 Subject: [PATCH 01/88] 8244141: use @requires and SkippedException in some hotspot/runtime tests Reviewed-by: minqi, gziemski --- .../CDSCompressedKPtrs.java | 36 +++++++++---------- .../SafeFetchInErrorHandlingTest.java | 9 ++--- .../ErrorHandling/SecondaryErrorTest.java | 13 ++----- .../runtime/LocalLong/LocalLongTest.java | 22 ++++++------ .../jtreg/runtime/logging/VtablesTest.java | 33 +++++++++-------- 5 files changed, 48 insertions(+), 65 deletions(-) diff --git a/test/hotspot/jtreg/runtime/CDSCompressedKPtrs/CDSCompressedKPtrs.java b/test/hotspot/jtreg/runtime/CDSCompressedKPtrs/CDSCompressedKPtrs.java index c95d508d6f3..3daf28d5c30 100644 --- a/test/hotspot/jtreg/runtime/CDSCompressedKPtrs/CDSCompressedKPtrs.java +++ b/test/hotspot/jtreg/runtime/CDSCompressedKPtrs/CDSCompressedKPtrs.java @@ -24,6 +24,7 @@ /** * @test * @requires vm.cds + * @requires vm.bits == 64 * @bug 8003424 * @summary Testing UseCompressedClassPointers with CDS * @library /test/lib @@ -35,31 +36,30 @@ import jdk.test.lib.Platform; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; +import jtreg.SkippedException; public class CDSCompressedKPtrs { public static void main(String[] args) throws Exception { ProcessBuilder pb; - if (Platform.is64bit()) { + pb = ProcessTools.createJavaProcessBuilder( + "-XX:+UseCompressedClassPointers", "-XX:+UseCompressedOops", + "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./CDSCompressedKPtrs.jsa", "-Xshare:dump", "-Xlog:cds"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + try { + output.shouldContain("Loading classes to share"); + output.shouldHaveExitValue(0); + pb = ProcessTools.createJavaProcessBuilder( "-XX:+UseCompressedClassPointers", "-XX:+UseCompressedOops", - "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./CDSCompressedKPtrs.jsa", "-Xshare:dump", "-Xlog:cds"); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - try { - output.shouldContain("Loading classes to share"); - output.shouldHaveExitValue(0); + "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./CDSCompressedKPtrs.jsa", "-Xshare:on", "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("sharing"); + output.shouldHaveExitValue(0); - pb = ProcessTools.createJavaProcessBuilder( - "-XX:+UseCompressedClassPointers", "-XX:+UseCompressedOops", - "-XX:+UnlockDiagnosticVMOptions", "-XX:SharedArchiveFile=./CDSCompressedKPtrs.jsa", "-Xshare:on", "-version"); - output = new OutputAnalyzer(pb.start()); - output.shouldContain("sharing"); - output.shouldHaveExitValue(0); - - } catch (RuntimeException e) { - // Report 'passed' if CDS was turned off. - output.shouldContain("Unable to use shared archive"); - output.shouldHaveExitValue(1); - } + } catch (RuntimeException e) { + output.shouldContain("Unable to use shared archive"); + output.shouldHaveExitValue(1); + throw new SkippedException("CDS was turned off"); } } } diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java index 28aa95dec84..8f3419d88e8 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java @@ -28,7 +28,6 @@ import java.io.InputStreamReader; import java.util.regex.Pattern; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.Platform; import jdk.test.lib.process.ProcessTools; /* @@ -37,19 +36,15 @@ import jdk.test.lib.process.ProcessTools; * @summary SafeFetch32 and SafeFetchN do not work in error handling * @modules java.base/jdk.internal.misc * @library /test/lib + * @requires vm.debug + * @requires vm.flavor != "zero" * @author Thomas Stuefe (SAP) * @run driver SafeFetchInErrorHandlingTest */ public class SafeFetchInErrorHandlingTest { - public static void main(String[] args) throws Exception { - - if (!Platform.isDebugBuild() || Platform.isZero()) { - return; - } - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-Xmx100M", diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/SecondaryErrorTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/SecondaryErrorTest.java index 57d1baae9be..494158b5d91 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/SecondaryErrorTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/SecondaryErrorTest.java @@ -27,6 +27,8 @@ * @bug 8065896 * @summary Synchronous signals during error reporting may terminate or hang VM process * @library /test/lib + * @requires vm.debug + * @requires os.family != "windows" * @author Thomas Stuefe (SAP) * @modules java.base/jdk.internal.misc * java.management @@ -40,23 +42,12 @@ import java.io.InputStreamReader; import java.util.regex.Pattern; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.Platform; import jdk.test.lib.process.ProcessTools; public class SecondaryErrorTest { public static void main(String[] args) throws Exception { - - // Do not execute for windows, nor for non-debug builds - if (Platform.isWindows()) { - return; - } - - if (!Platform.isDebugBuild()) { - return; - } - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-Xmx100M", diff --git a/test/hotspot/jtreg/runtime/LocalLong/LocalLongTest.java b/test/hotspot/jtreg/runtime/LocalLong/LocalLongTest.java index 718f0c42942..2c1a0709b2a 100644 --- a/test/hotspot/jtreg/runtime/LocalLong/LocalLongTest.java +++ b/test/hotspot/jtreg/runtime/LocalLong/LocalLongTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -27,25 +27,23 @@ * @bug 8163014 * @modules java.base/jdk.internal.misc * @library /test/lib + * @requires vm.bits == 64 * @compile LocalLongHelper.java * @run driver LocalLongTest */ -import jdk.test.lib.Platform; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; public class LocalLongTest { public static void main(String... args) throws Exception { - if (Platform.is64bit()) { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xint", - "--add-opens", - "java.base/java.lang=ALL-UNNAMED", - "--add-opens", - "java.base/java.lang.invoke=ALL-UNNAMED", - "LocalLongHelper"); - OutputAnalyzer o = new OutputAnalyzer(pb.start()); - o.shouldHaveExitValue(0); - } + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xint", + "--add-opens", + "java.base/java.lang=ALL-UNNAMED", + "--add-opens", + "java.base/java.lang.invoke=ALL-UNNAMED", + "LocalLongHelper"); + OutputAnalyzer o = new OutputAnalyzer(pb.start()); + o.shouldHaveExitValue(0); }; } diff --git a/test/hotspot/jtreg/runtime/logging/VtablesTest.java b/test/hotspot/jtreg/runtime/logging/VtablesTest.java index 2941416e26e..083a46dcebb 100644 --- a/test/hotspot/jtreg/runtime/logging/VtablesTest.java +++ b/test/hotspot/jtreg/runtime/logging/VtablesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -26,6 +26,7 @@ * @bug 8141564 * @summary vtables=trace should have logging from each of the statements in the code * @library /test/lib + * @requires vm.debug * @compile ClassB.java * p1/A.java * p2/B.jcod @@ -42,23 +43,21 @@ import jdk.test.lib.process.OutputAnalyzer; public class VtablesTest { public static void main(String[] args) throws Exception { - if (Platform.isDebugBuild()) { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:vtables=trace", "ClassB"); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("copy vtable from ClassA to ClassB"); - output.shouldContain("Initializing: ClassB"); - output.shouldContain("adding ClassB.Method1()V"); - output.shouldContain("] overriding with ClassB.Method2()V"); - output.shouldContain("invokevirtual resolved method: caller-class:ClassB"); - output.shouldContain("invokevirtual selected method: receiver-class:ClassB"); - output.shouldContain("NOT overriding with p2.D.nooverride()V"); - output.shouldHaveExitValue(0); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:vtables=trace", "ClassB"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain("copy vtable from ClassA to ClassB"); + output.shouldContain("Initializing: ClassB"); + output.shouldContain("adding ClassB.Method1()V"); + output.shouldContain("] overriding with ClassB.Method2()V"); + output.shouldContain("invokevirtual resolved method: caller-class:ClassB"); + output.shouldContain("invokevirtual selected method: receiver-class:ClassB"); + output.shouldContain("NOT overriding with p2.D.nooverride()V"); + output.shouldHaveExitValue(0); - pb = ProcessTools.createJavaProcessBuilder("-Xlog:vtables=trace", "p1/C"); - output = new OutputAnalyzer(pb.start()); - output.shouldContain("transitive overriding superclass "); - output.shouldHaveExitValue(0); - } + pb = ProcessTools.createJavaProcessBuilder("-Xlog:vtables=trace", "p1/C"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("transitive overriding superclass "); + output.shouldHaveExitValue(0); } } From bcf3ae8245d8f07dafe0681a985a29126c32b593 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Wed, 29 Apr 2020 19:55:52 -0700 Subject: [PATCH 02/88] 8244142: some hotspot/runtime tests don't check exit code of forked JVM Reviewed-by: gziemski, minqi --- test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeTest.java | 1 + .../jtreg/runtime/getSysPackage/GetPackageXbootclasspath.java | 3 ++- test/hotspot/jtreg/runtime/records/RedefineRecord.java | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeTest.java b/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeTest.java index ff6e42c2382..a0d9f60fae0 100644 --- a/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeTest.java +++ b/test/hotspot/jtreg/runtime/Metaspace/MaxMetaspaceSizeTest.java @@ -43,5 +43,6 @@ public class MaxMetaspaceSizeTest { "--version"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("MaxMetaspaceSize is too small."); + output.shouldNotHaveExitValue(0); } } diff --git a/test/hotspot/jtreg/runtime/getSysPackage/GetPackageXbootclasspath.java b/test/hotspot/jtreg/runtime/getSysPackage/GetPackageXbootclasspath.java index 455a2340abe..e00b7a7e42f 100644 --- a/test/hotspot/jtreg/runtime/getSysPackage/GetPackageXbootclasspath.java +++ b/test/hotspot/jtreg/runtime/getSysPackage/GetPackageXbootclasspath.java @@ -54,6 +54,7 @@ public class GetPackageXbootclasspath { new OutputAnalyzer(ProcessTools.createJavaProcessBuilder( "-Xbootclasspath/a:" + test_classes, "P.Test") - .start()).shouldContain("Test Passed"); + .start()).shouldContain("Test Passed") + .shouldHaveExitValue(0); } } diff --git a/test/hotspot/jtreg/runtime/records/RedefineRecord.java b/test/hotspot/jtreg/runtime/records/RedefineRecord.java index d59d7740465..65d678cef4b 100644 --- a/test/hotspot/jtreg/runtime/records/RedefineRecord.java +++ b/test/hotspot/jtreg/runtime/records/RedefineRecord.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 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 @@ -103,6 +103,7 @@ public class RedefineRecord { "RedefineRecord"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotContain("processing of -javaagent failed"); + output.shouldHaveExitValue(0); } } } From f0f7070cb55f4f32aa75a49178eda31c555d0524 Mon Sep 17 00:00:00 2001 From: Jatin Bhateja Date: Sat, 2 May 2020 20:37:56 +0530 Subject: [PATCH 03/88] 8244186: assertion failure test/jdk/javax/net/ssl/DTLS/RespondToRetransmit.java Removing an assertion which prevents logic folding over cones already having a MacroLogic node. Reviewed-by: kvn --- src/hotspot/share/opto/compile.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/opto/compile.cpp b/src/hotspot/share/opto/compile.cpp index d14add2c838..01aaef49138 100644 --- a/src/hotspot/share/opto/compile.cpp +++ b/src/hotspot/share/opto/compile.cpp @@ -2478,7 +2478,9 @@ uint Compile::compute_truth_table(Unique_Node_List& partition, Unique_Node_List& bool Compile::compute_logic_cone(Node* n, Unique_Node_List& partition, Unique_Node_List& inputs) { assert(partition.size() == 0, "not empty"); assert(inputs.size() == 0, "not empty"); - assert(!is_vector_ternary_bitwise_op(n), "not supported"); + if (is_vector_ternary_bitwise_op(n)) { + return false; + } bool is_unary_op = is_vector_unary_bitwise_op(n); if (is_unary_op) { @@ -2520,6 +2522,7 @@ bool Compile::compute_logic_cone(Node* n, Unique_Node_List& partition, Unique_No (inputs.size() == 2 || inputs.size() == 3); } + void Compile::process_logic_cone_root(PhaseIterGVN &igvn, Node *n, VectorSet &visited) { assert(is_vector_bitwise_op(n), "not a root"); From eee32495a1ab3dc9c365b0183d9291e23c97c05b Mon Sep 17 00:00:00 2001 From: Alexey Semenyuk Date: Sat, 2 May 2020 11:02:48 -0400 Subject: [PATCH 04/88] 8244220: Compiler error in jpackage with VS2019 Reviewed-by: herrick, almatvee, prr --- .../windows/native/libjpackage/JniUtils.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/jdk.incubator.jpackage/windows/native/libjpackage/JniUtils.h b/src/jdk.incubator.jpackage/windows/native/libjpackage/JniUtils.h index 8f5f38293da..c1ad0b07f10 100644 --- a/src/jdk.incubator.jpackage/windows/native/libjpackage/JniUtils.h +++ b/src/jdk.incubator.jpackage/windows/native/libjpackage/JniUtils.h @@ -48,6 +48,10 @@ struct JniObjWithEnv { return ! operator == (other); } + explicit operator bool() const { + return env && obj; + } + JNIEnv *env; jobject obj; From 765a5b858b1252cdc86643fc7cac3b607aa07405 Mon Sep 17 00:00:00 2001 From: Jie Fu Date: Sun, 3 May 2020 20:11:14 +0800 Subject: [PATCH 05/88] 8244276: Zero and minimal VM build failure after JDK-8178349 (use of undeclared identifier 'SystemDictionaryShared') Reviewed-by: minqi, dholmes --- src/hotspot/share/classfile/systemDictionary.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hotspot/share/classfile/systemDictionary.cpp b/src/hotspot/share/classfile/systemDictionary.cpp index bff53b20657..b7fb8bc2d86 100644 --- a/src/hotspot/share/classfile/systemDictionary.cpp +++ b/src/hotspot/share/classfile/systemDictionary.cpp @@ -2336,12 +2336,14 @@ bool SystemDictionary::add_loader_constraint(Symbol* class_name, InstanceKlass* klass2 = find_class(d_hash2, constraint_name, dictionary2); bool result = constraints()->add_entry(constraint_name, klass1, class_loader1, klass2, class_loader2); +#if INCLUDE_CDS if (Arguments::is_dumping_archive() && klass_being_linked != NULL && !klass_being_linked->is_shared()) { SystemDictionaryShared::record_linking_constraint(constraint_name, InstanceKlass::cast(klass_being_linked), class_loader1, class_loader2, THREAD); } +#endif // INCLUDE_CDS if (Signature::is_array(class_name)) { constraint_name->decrement_refcount(); } From 57fbf93ef90e01a057b7d58c9c660c64829a384f Mon Sep 17 00:00:00 2001 From: "Daniel D. Daugherty" Date: Sun, 3 May 2020 10:00:36 -0400 Subject: [PATCH 06/88] 8230940: Obsolete MonitorBound Obsolete MonitorBound option and delete associated code. Reviewed-by: kbarrett, dholmes, redestad --- src/hotspot/share/runtime/arguments.cpp | 2 +- src/hotspot/share/runtime/flags/jvmFlag.cpp | 2 +- src/hotspot/share/runtime/globals.hpp | 3 - src/hotspot/share/runtime/safepoint.cpp | 4 -- src/hotspot/share/runtime/safepoint.hpp | 1 - src/hotspot/share/runtime/synchronizer.cpp | 68 +-------------------- src/hotspot/share/runtime/synchronizer.hpp | 1 - src/hotspot/share/runtime/vmThread.cpp | 8 +-- src/hotspot/share/runtime/vmThread.hpp | 3 +- 9 files changed, 5 insertions(+), 87 deletions(-) diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index 828c87bc5c5..d70ebeffc30 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -522,7 +522,6 @@ static SpecialFlag const special_jvm_flags[] = { { "UseMembar", JDK_Version::jdk(10), JDK_Version::jdk(12), JDK_Version::undefined() }, { "AllowRedefinitionToAddDeleteMethods", JDK_Version::jdk(13), JDK_Version::undefined(), JDK_Version::undefined() }, { "FlightRecorder", JDK_Version::jdk(13), JDK_Version::undefined(), JDK_Version::undefined() }, - { "MonitorBound", JDK_Version::jdk(14), JDK_Version::jdk(15), JDK_Version::jdk(16) }, { "PrintVMQWaitTime", JDK_Version::jdk(15), JDK_Version::jdk(16), JDK_Version::jdk(17) }, { "UseNewFieldLayout", JDK_Version::jdk(15), JDK_Version::jdk(16), JDK_Version::jdk(17) }, { "ForceNUMA", JDK_Version::jdk(15), JDK_Version::jdk(16), JDK_Version::jdk(17) }, @@ -550,6 +549,7 @@ static SpecialFlag const special_jvm_flags[] = { { "UseSSE", JDK_Version::undefined(), JDK_Version::jdk(15), JDK_Version::jdk(16) }, #endif // !X86 { "UseAdaptiveGCBoundary", JDK_Version::undefined(), JDK_Version::jdk(15), JDK_Version::jdk(16) }, + { "MonitorBound", JDK_Version::jdk(14), JDK_Version::jdk(15), JDK_Version::jdk(16) }, #ifdef TEST_VERIFY_SPECIAL_JVM_FLAGS // These entries will generate build errors. Their purpose is to test the macros. diff --git a/src/hotspot/share/runtime/flags/jvmFlag.cpp b/src/hotspot/share/runtime/flags/jvmFlag.cpp index 81210d3d7d1..4611155d7ee 100644 --- a/src/hotspot/share/runtime/flags/jvmFlag.cpp +++ b/src/hotspot/share/runtime/flags/jvmFlag.cpp @@ -426,7 +426,7 @@ void JVMFlag::print_on(outputStream* st, bool withComments, bool printRanges) { // double MinRAMPercentage [ 0.000 ... 100.000 ] {product} {default} // uintx MinSurvivorRatio [ 3 ... 18446744073709551615 ] {product} {default} // size_t MinTLABSize [ 1 ... 9223372036854775807 ] {product} {default} - // intx MonitorBound [ 0 ... 2147483647 ] {product} {default} + // intx MaxInlineSize [ 0 ... 2147483647 ] {product} {default} // | | | | | | // | | | | | +-- col7 // | | | | +-- col6 diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp index 3da38e060aa..aa9b2dc830c 100644 --- a/src/hotspot/share/runtime/globals.hpp +++ b/src/hotspot/share/runtime/globals.hpp @@ -691,9 +691,6 @@ const size_t minimumSymbolTableSize = 1024; "Use LWP-based instead of libthread-based synchronization " \ "(SPARC only)") \ \ - product(intx, MonitorBound, 0, "(Deprecated) Bound Monitor population") \ - range(0, max_jint) \ - \ experimental(intx, MonitorUsedDeflationThreshold, 90, \ "Percentage of used monitors before triggering cleanup " \ "safepoint which deflates monitors (0 is off). " \ diff --git a/src/hotspot/share/runtime/safepoint.cpp b/src/hotspot/share/runtime/safepoint.cpp index 30516068b78..c37e8219f31 100644 --- a/src/hotspot/share/runtime/safepoint.cpp +++ b/src/hotspot/share/runtime/safepoint.cpp @@ -499,10 +499,6 @@ bool SafepointSynchronize::is_cleanup_needed() { return false; } -bool SafepointSynchronize::is_forced_cleanup_needed() { - return ObjectSynchronizer::needs_monitor_scavenge(); -} - class ParallelSPCleanupThreadClosure : public ThreadClosure { private: CodeBlobClosure* _nmethod_cl; diff --git a/src/hotspot/share/runtime/safepoint.hpp b/src/hotspot/share/runtime/safepoint.hpp index 9a5d299aaba..dda0594f938 100644 --- a/src/hotspot/share/runtime/safepoint.hpp +++ b/src/hotspot/share/runtime/safepoint.hpp @@ -162,7 +162,6 @@ public: static void handle_polling_page_exception(JavaThread *thread); static bool is_cleanup_needed(); - static bool is_forced_cleanup_needed(); static void do_cleanup_tasks(); static void set_is_at_safepoint() { _state = _synchronized; } diff --git a/src/hotspot/share/runtime/synchronizer.cpp b/src/hotspot/share/runtime/synchronizer.cpp index ff36b773d99..84b6a8a09a5 100644 --- a/src/hotspot/share/runtime/synchronizer.cpp +++ b/src/hotspot/share/runtime/synchronizer.cpp @@ -781,7 +781,6 @@ struct SharedGlobals { }; static SharedGlobals GVars; -static int _forceMonitorScavenge = 0; // Scavenge required and pending static markWord read_stable_mark(oop obj) { markWord mark = obj->mark(); @@ -1170,27 +1169,8 @@ static bool monitors_used_above_threshold() { return false; } -// Returns true if MonitorBound is set (> 0) and if the specified -// cnt is > MonitorBound. Otherwise returns false. -static bool is_MonitorBound_exceeded(const int cnt) { - const int mx = MonitorBound; - return mx > 0 && cnt > mx; -} - bool ObjectSynchronizer::is_cleanup_needed() { - if (monitors_used_above_threshold()) { - // Too many monitors in use. - return true; - } - return needs_monitor_scavenge(); -} - -bool ObjectSynchronizer::needs_monitor_scavenge() { - if (Atomic::load(&_forceMonitorScavenge) == 1) { - log_info(monitorinflation)("Monitor scavenge needed, triggering safepoint cleanup."); - return true; - } - return false; + return monitors_used_above_threshold(); } void ObjectSynchronizer::oops_do(OopClosure* f) { @@ -1237,41 +1217,6 @@ void ObjectSynchronizer::list_oops_do(ObjectMonitor* list, OopClosure* f) { // -- assigned to an object. The object is inflated and the mark refers // to the ObjectMonitor. - -// Constraining monitor pool growth via MonitorBound ... -// -// If MonitorBound is not set (<= 0), MonitorBound checks are disabled. -// -// The monitor pool is grow-only. We scavenge at STW safepoint-time, but the -// the rate of scavenging is driven primarily by GC. As such, we can find -// an inordinate number of monitors in circulation. -// To avoid that scenario we can artificially induce a STW safepoint -// if the pool appears to be growing past some reasonable bound. -// Generally we favor time in space-time tradeoffs, but as there's no -// natural back-pressure on the # of extant monitors we need to impose some -// type of limit. Beware that if MonitorBound is set to too low a value -// we could just loop. In addition, if MonitorBound is set to a low value -// we'll incur more safepoints, which are harmful to performance. -// See also: GuaranteedSafepointInterval -// -// If MonitorBound is set, the boundry applies to -// (om_list_globals._population - om_list_globals._free_count) -// i.e., if there are not enough ObjectMonitors on the global free list, -// then a safepoint deflation is induced. Picking a good MonitorBound value -// is non-trivial. - -static void InduceScavenge(Thread* self, const char * Whence) { - // Induce STW safepoint to trim monitors - // Ultimately, this results in a call to deflate_idle_monitors() in the near future. - // More precisely, trigger a cleanup safepoint as the number - // of active monitors passes the specified threshold. - // TODO: assert thread state is reasonable - - if (Atomic::xchg(&_forceMonitorScavenge, 1) == 0) { - VMThread::check_for_forced_cleanup(); - } -} - ObjectMonitor* ObjectSynchronizer::om_alloc(Thread* self) { // A large MAXPRIVATE value reduces both list lock contention // and list coherency traffic, but also tends to increase the @@ -1315,15 +1260,6 @@ ObjectMonitor* ObjectSynchronizer::om_alloc(Thread* self) { } self->om_free_provision += 1 + (self->om_free_provision / 2); if (self->om_free_provision > MAXPRIVATE) self->om_free_provision = MAXPRIVATE; - - if (is_MonitorBound_exceeded(Atomic::load(&om_list_globals._population) - - Atomic::load(&om_list_globals._free_count))) { - // Not enough ObjectMonitors on the global free list. - // We can't safely induce a STW safepoint from om_alloc() as our thread - // state may not be appropriate for such activities and callers may hold - // naked oops, so instead we defer the action. - InduceScavenge(self, "om_alloc"); - } continue; } @@ -2025,8 +1961,6 @@ void ObjectSynchronizer::finish_deflate_idle_monitors(DeflateMonitorCounters* co Atomic::load(&om_list_globals._free_count)); } - Atomic::store(&_forceMonitorScavenge, 0); // Reset - OM_PERFDATA_OP(Deflations, inc(counters->n_scavenged)); OM_PERFDATA_OP(MonExtant, set_value(counters->n_in_circulation)); diff --git a/src/hotspot/share/runtime/synchronizer.hpp b/src/hotspot/share/runtime/synchronizer.hpp index 0227a6eb705..4128313540f 100644 --- a/src/hotspot/share/runtime/synchronizer.hpp +++ b/src/hotspot/share/runtime/synchronizer.hpp @@ -145,7 +145,6 @@ class ObjectSynchronizer : AllStatic { ObjectMonitor** free_head_p, ObjectMonitor** free_tail_p); static bool is_cleanup_needed(); - static bool needs_monitor_scavenge(); static void oops_do(OopClosure* f); // Process oops in thread local used monitors static void thread_local_used_oops_do(Thread* thread, OopClosure* f); diff --git a/src/hotspot/share/runtime/vmThread.cpp b/src/hotspot/share/runtime/vmThread.cpp index bb41a3c1fc5..71c41fdbb7a 100644 --- a/src/hotspot/share/runtime/vmThread.cpp +++ b/src/hotspot/share/runtime/vmThread.cpp @@ -400,11 +400,6 @@ class HandshakeALotClosure : public HandshakeClosure { } }; -void VMThread::check_for_forced_cleanup() { - MonitorLocker mq(VMOperationQueue_lock, Mutex::_no_safepoint_check_flag); - mq.notify(); -} - VM_Operation* VMThread::no_op_safepoint() { // Check for handshakes first since we may need to return a VMop. if (HandshakeALot) { @@ -415,8 +410,7 @@ VM_Operation* VMThread::no_op_safepoint() { long interval_ms = SafepointTracing::time_since_last_safepoint_ms(); bool max_time_exceeded = GuaranteedSafepointInterval != 0 && (interval_ms >= GuaranteedSafepointInterval); - if ((max_time_exceeded && SafepointSynchronize::is_cleanup_needed()) || - SafepointSynchronize::is_forced_cleanup_needed()) { + if (max_time_exceeded && SafepointSynchronize::is_cleanup_needed()) { return &cleanup_op; } if (SafepointALot) { diff --git a/src/hotspot/share/runtime/vmThread.hpp b/src/hotspot/share/runtime/vmThread.hpp index 38bcbcc76b5..eb5e95eb1f2 100644 --- a/src/hotspot/share/runtime/vmThread.hpp +++ b/src/hotspot/share/runtime/vmThread.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -136,7 +136,6 @@ class VMThread: public NamedThread { // The ever running loop for the VMThread void loop(); - static void check_for_forced_cleanup(); // Called to stop the VM thread static void wait_for_vm_thread_exit(); From bbcb3b638b0488d4705cae73add15455ca3de977 Mon Sep 17 00:00:00 2001 From: Christian Hagedorn Date: Mon, 4 May 2020 10:23:23 +0200 Subject: [PATCH 07/88] 8230402: Allocation of compile task fails with assert: "Leaking compilation tasks?" Remove assert that is only hit with hand written edge case tests. Reviewed-by: kvn, thartmann --- src/hotspot/share/compiler/compileTask.cpp | 5 -- src/hotspot/share/compiler/compileTask.hpp | 4 - .../TestOverloadCompileQueues.java | 87 ++++++++++++++++++- 3 files changed, 84 insertions(+), 12 deletions(-) diff --git a/src/hotspot/share/compiler/compileTask.cpp b/src/hotspot/share/compiler/compileTask.cpp index 312d9ccf182..26155b19f13 100644 --- a/src/hotspot/share/compiler/compileTask.cpp +++ b/src/hotspot/share/compiler/compileTask.cpp @@ -33,9 +33,6 @@ #include "runtime/handles.inline.hpp" CompileTask* CompileTask::_task_free_list = NULL; -#ifdef ASSERT -int CompileTask::_num_allocated_tasks = 0; -#endif /** * Allocate a CompileTask, from the free list if possible. @@ -50,8 +47,6 @@ CompileTask* CompileTask::allocate() { task->set_next(NULL); } else { task = new CompileTask(); - DEBUG_ONLY(_num_allocated_tasks++;) - assert (WhiteBoxAPI || JVMCI_ONLY(UseJVMCICompiler ||) _num_allocated_tasks < 10000, "Leaking compilation tasks?"); task->set_next(NULL); task->set_is_free(true); } diff --git a/src/hotspot/share/compiler/compileTask.hpp b/src/hotspot/share/compiler/compileTask.hpp index ebe86174349..2b76ddbac65 100644 --- a/src/hotspot/share/compiler/compileTask.hpp +++ b/src/hotspot/share/compiler/compileTask.hpp @@ -75,10 +75,6 @@ class CompileTask : public CHeapObj { private: static CompileTask* _task_free_list; -#ifdef ASSERT - static int _num_allocated_tasks; -#endif - Monitor* _lock; uint _compile_id; Method* _method; diff --git a/test/hotspot/jtreg/compiler/classUnloading/methodUnloading/TestOverloadCompileQueues.java b/test/hotspot/jtreg/compiler/classUnloading/methodUnloading/TestOverloadCompileQueues.java index 32933fdb94b..04906954090 100644 --- a/test/hotspot/jtreg/compiler/classUnloading/methodUnloading/TestOverloadCompileQueues.java +++ b/test/hotspot/jtreg/compiler/classUnloading/methodUnloading/TestOverloadCompileQueues.java @@ -23,12 +23,12 @@ /* * @test TestOverloadCompileQueues - * @bug 8163511 + * @bug 8163511 8230402 * @summary Test overloading the C1 and C2 compile queues with tasks. * @requires !vm.graal.enabled - * @run main/othervm -XX:-TieredCompilation -XX:CompileThreshold=2 -XX:CICompilerCount=1 + * @run main/othervm/timeout=300 -XX:-TieredCompilation -XX:CompileThreshold=2 -XX:CICompilerCount=1 * compiler.classUnloading.methodUnloading.TestOverloadCompileQueues - * @run main/othervm -XX:TieredCompileTaskTimeout=1000 -XX:CompileThresholdScaling=0.001 -XX:CICompilerCount=2 + * @run main/othervm/timeout=300 -XX:TieredCompileTaskTimeout=1000 -XX:CompileThresholdScaling=0.001 -XX:CICompilerCount=2 * compiler.classUnloading.methodUnloading.TestOverloadCompileQueues */ @@ -37,9 +37,13 @@ package compiler.classUnloading.methodUnloading; import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; +import java.util.Arrays; public class TestOverloadCompileQueues { public static final int ITERS = 500; // Increase for longer stress testing + public static final int ITERS_A = 1000; // Increase for longer stress testing + + public static int iArr[] = new int[100]; // Some methods to fill up the compile queue public static void test0() { } @@ -63,7 +67,65 @@ public class TestOverloadCompileQueues { public static void test18() { } public static void test19() { } + // More methods that do some more complex things. Therefore, the compiler needs to spend some more time compiling them. + // With 50 methods, a queue size of 10000 is also reached in the second run with TieredCompilation enabled. + public static void testA0() { Arrays.sort(iArr); } + public static void testA1() { Arrays.sort(iArr); } + public static void testA2() { Arrays.sort(iArr); } + public static void testA3() { Arrays.sort(iArr); } + public static void testA4() { Arrays.sort(iArr); } + public static void testA5() { Arrays.sort(iArr); } + public static void testA6() { Arrays.sort(iArr); } + public static void testA7() { Arrays.sort(iArr); } + public static void testA8() { Arrays.sort(iArr); } + public static void testA9() { Arrays.sort(iArr); } + public static void testA10() { Arrays.sort(iArr); } + public static void testA11() { Arrays.sort(iArr); } + public static void testA12() { Arrays.sort(iArr); } + public static void testA13() { Arrays.sort(iArr); } + public static void testA14() { Arrays.sort(iArr); } + public static void testA15() { Arrays.sort(iArr); } + public static void testA16() { Arrays.sort(iArr); } + public static void testA17() { Arrays.sort(iArr); } + public static void testA18() { Arrays.sort(iArr); } + public static void testA19() { Arrays.sort(iArr); } + public static void testA20() { Arrays.sort(iArr); } + public static void testA21() { Arrays.sort(iArr); } + public static void testA22() { Arrays.sort(iArr); } + public static void testA23() { Arrays.sort(iArr); } + public static void testA24() { Arrays.sort(iArr); } + public static void testA25() { Arrays.sort(iArr); } + public static void testA26() { Arrays.sort(iArr); } + public static void testA27() { Arrays.sort(iArr); } + public static void testA28() { Arrays.sort(iArr); } + public static void testA29() { Arrays.sort(iArr); } + public static void testA30() { Arrays.sort(iArr); } + public static void testA31() { Arrays.sort(iArr); } + public static void testA32() { Arrays.sort(iArr); } + public static void testA33() { Arrays.sort(iArr); } + public static void testA34() { Arrays.sort(iArr); } + public static void testA35() { Arrays.sort(iArr); } + public static void testA36() { Arrays.sort(iArr); } + public static void testA37() { Arrays.sort(iArr); } + public static void testA38() { Arrays.sort(iArr); } + public static void testA39() { Arrays.sort(iArr); } + public static void testA40() { Arrays.sort(iArr); } + public static void testA41() { Arrays.sort(iArr); } + public static void testA42() { Arrays.sort(iArr); } + public static void testA43() { Arrays.sort(iArr); } + public static void testA44() { Arrays.sort(iArr); } + public static void testA45() { Arrays.sort(iArr); } + public static void testA46() { Arrays.sort(iArr); } + public static void testA47() { Arrays.sort(iArr); } + public static void testA48() { Arrays.sort(iArr); } + public static void testA49() { Arrays.sort(iArr); } + public static void main(String[] args) throws Throwable { + run(); + runA(); + } + + public static void run() throws Throwable { Class thisClass = TestOverloadCompileQueues.class; ClassLoader defaultLoader = thisClass.getClassLoader(); URL classesDir = thisClass.getProtectionDomain().getCodeSource().getLocation(); @@ -84,4 +146,23 @@ public class TestOverloadCompileQueues { System.gc(); } } + + public static void runA() throws Throwable { + Class thisClass = TestOverloadCompileQueues.class; + ClassLoader defaultLoader = thisClass.getClassLoader(); + URL classesDir = thisClass.getProtectionDomain().getCodeSource().getLocation(); + + for (int i = 0; i < ITERS_A; ++i) { + // Load test class with own class loader + URLClassLoader myLoader = URLClassLoader.newInstance(new URL[] {classesDir}, defaultLoader.getParent()); + Class testClass = Class.forName(thisClass.getCanonicalName(), true, myLoader); + + // Execute all test methods to trigger compilation and fill up compile queue + for (int j = 0; j < 50; ++j) { + Method method = testClass.getDeclaredMethod("testA" + j); + method.invoke(null); + method.invoke(null); + } + } + } } From 09912cc50918a10b66b0195dccef50485c7ef17f Mon Sep 17 00:00:00 2001 From: Christian Hagedorn Date: Mon, 4 May 2020 10:27:46 +0200 Subject: [PATCH 08/88] 8244182: Use root node as default for find_node when called from debugger Improve find_node for simpler debugging. Reviewed-by: roland, thartmann --- src/hotspot/share/opto/node.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/hotspot/share/opto/node.cpp b/src/hotspot/share/opto/node.cpp index d7433260f21..d467fdb2d7c 100644 --- a/src/hotspot/share/opto/node.cpp +++ b/src/hotspot/share/opto/node.cpp @@ -1594,6 +1594,11 @@ Node* find_node(Node* n, int idx) { return n->find(idx); } +// call this from debugger with root node as default: +Node* find_node(int idx) { + return Compile::current()->root()->find(idx); +} + //------------------------------find------------------------------------------- Node* Node::find(int idx) const { ResourceArea *area = Thread::current()->resource_area(); From 1a35219f017dc578da344c1d8c5909dc770fc5d1 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Mon, 4 May 2020 12:28:35 +0200 Subject: [PATCH 09/88] 8243557: Inconvenient span for multi-catch error diagnostics Reviewed-by: vromero --- .../com/sun/tools/javac/comp/Flow.java | 3 +- .../jdk/jshell/ErrorTranslationTest.java | 8 +- test/langtools/tools/javac/api/DiagSpans.java | 262 ++++++++++++++++++ 3 files changed, 271 insertions(+), 2 deletions(-) create mode 100644 test/langtools/tools/javac/api/DiagSpans.java diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java index 02d03542297..0d06ed464e7 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java @@ -1266,7 +1266,8 @@ public class Flow { ctypes = ctypes.append(exc); if (types.isSameType(exc, syms.objectType)) continue; - checkCaughtType(l.head.pos(), exc, thrownInTry, caughtInTry); + var pos = subClauses.size() > 1 ? ct.pos() : l.head.pos(); + checkCaughtType(pos, exc, thrownInTry, caughtInTry); caughtInTry = chk.incl(exc, caughtInTry); } } diff --git a/test/langtools/jdk/jshell/ErrorTranslationTest.java b/test/langtools/jdk/jshell/ErrorTranslationTest.java index d0cdc3ff522..fe6f6e6b333 100644 --- a/test/langtools/jdk/jshell/ErrorTranslationTest.java +++ b/test/langtools/jdk/jshell/ErrorTranslationTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8188225 + * @bug 8188225 8243557 * @summary Tests for shell error translation * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main @@ -67,6 +67,12 @@ public class ErrorTranslationTest extends ReplToolTesting { ); } + public void testExceptionErrors() { + test( + a -> assertDiagnostic(a, "try { } catch (IllegalStateException | java.io.IOException ex) { }", newExpectedDiagnostic(39, 58, -1, -1, -1, Diagnostic.Kind.ERROR)) + ); + } + public void testWarnings() { List list = new ArrayList<>(); ExpectedDiagnostic[] diagnostics = new ExpectedDiagnostic[]{ diff --git a/test/langtools/tools/javac/api/DiagSpans.java b/test/langtools/tools/javac/api/DiagSpans.java new file mode 100644 index 00000000000..e4cdc6a5f07 --- /dev/null +++ b/test/langtools/tools/javac/api/DiagSpans.java @@ -0,0 +1,262 @@ +/* + * 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 8243557 + * @summary Verify spans of diagnostics + * @library /tools/lib + * @modules jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.main + * @build toolbox.JavacTask toolbox.TestRunner toolbox.ToolBox + * @run main DiagSpans + */ + +import java.io.IOException; +import java.util.List; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Objects; +import javax.tools.DiagnosticListener; +import javax.tools.JavaFileObject; +import javax.tools.SimpleJavaFileObject; +import javax.tools.ToolProvider; + +import toolbox.TestRunner; +import toolbox.ToolBox; + +public class DiagSpans extends TestRunner { + + public static void main(String... args) throws Exception { + DiagSpans t = new DiagSpans(); + t.runTests(); + } + + private final ToolBox tb = new ToolBox(); + + DiagSpans() throws IOException { + super(System.err); + } + + @Test + public void testCannotBeThrownMultiple() throws Exception { + runDiagSpanTest(""" + class Test { + public void exception() { + try { + } catch (RuntimeException | /^ReflectiveOperationException/ ex) { + } + } + } + """, + '/', + '^'); + } + + @Test + public void testCannotBeThrownMultiplePrefered() throws Exception { + runDiagSpanTest(""" + class Test { + public void exception() { + try { + } catch (RuntimeException | /java.lang^.ReflectiveOperationException/ ex) { + } + } + } + """, + '/', + '^'); + } + + @Test + public void testCannotBeThrownSingle() throws Exception { + runDiagSpanTest(""" + class Test { + public void exception() { + try { + } /^catch (ReflectiveOperationException ex) { + }/ + } + } + """, + '/', + '^'); + } + + @Test + public void testAlreadyCaughtMultiple() throws Exception { + runDiagSpanTest(""" + class Test { + public void exception() { + try { + } catch (IllegalStateException ex) { + } catch (IllegalArgumentException | /^IllegalStateException/ ex) { + } + } + } + """, + '/', + '^'); + } + + @Test + public void testAlreadyCaughtSimple() throws Exception { + runDiagSpanTest(""" + class Test { + public void exception() { + try { + } catch (IllegalStateException ex) { + } /^catch (IllegalStateException ex) { + }/ + } + } + """, + '/', + '^'); + } + + @Test + public void testUnreachableCatchMulti() throws Exception { + runDiagSpanTest(""" + class Test { + public void exception(boolean b) { + try { + if (b) + throw new Sub1(); + else + throw new Sub2(); + } catch(Sub1 exc) { + } catch(Sub2 exc) { + } catch(IllegalStateException | /^Base1/ | /^Base2/ exc) { } + } + } + class Base1 extends Exception {} + class Sub1 extends Base1 {} + class Base2 extends Exception {} + class Sub2 extends Base2 {} + """, + '/', + '^'); + } + + @Test + public void testSubtypeMulti1() throws Exception { + runDiagSpanTest(""" + class Test { + public void exception(boolean b) { + try { + throw new Sub1(); + } catch(Base1 | /^Sub1/ exc) { } + } + } + class Base1 extends Exception {} + class Sub1 extends Base1 {} + """, + '/', + '^'); + } + + @Test + public void testSubtypeMulti2() throws Exception { + runDiagSpanTest(""" + class Test { + public void exception(boolean b) { + try { + throw new Sub1(); + } catch(Sub1 | /^Base1/ exc) { } + } + } + class Base1 extends Exception {} + class Sub1 extends Base1 {} + """, + '/', + '^'); + } + + private void runDiagSpanTest(String code, char spanMarker, char prefMarker) throws Exception { + var realCode = new StringBuilder(); + var expectedError = new ArrayList(); + int startPos = -1; + int preferedPos = -1; + int pos = 0; + + for (int i = 0; i < code.length(); i++) { + char c = code.charAt(i); + if (c == spanMarker) { + if (startPos == (-1)) { + startPos = pos; + } else { + expectedError.add("" + startPos + ":" + pos + ":" + preferedPos); + startPos = (-1); + preferedPos = (-1); + } + } else if (c == prefMarker) { + if (preferedPos == (-1)) { + preferedPos = pos; + } else { + throw new AssertionError("Too many markers!"); + } + } else { + realCode.append(c); + pos++; + } + } + + if (startPos != (-1) || preferedPos != (-1)) { + throw new AssertionError("Incorrect number of markers!"); + } + + var compiler = ToolProvider.getSystemJavaCompiler(); + var actualErrors = new ArrayList(); + DiagnosticListener dl = d -> { + System.err.println("d=" + d); + actualErrors.add("" + d.getStartPosition() + + ":" + d.getEndPosition() + + ":" + d.getPosition()); + }; + var sourceFiles = List.of(new JFOImpl(realCode.toString())); + var task = compiler.getTask(null, null, dl, null, null, sourceFiles); + task.call(); + if (!Objects.equals(expectedError, actualErrors)) { + throw new AssertionError("Expected error spans not found, expected: " + + expectedError + ", actual: " + actualErrors); + } + } + + class JFOImpl extends SimpleJavaFileObject { + + private final String code; + + public JFOImpl(String code) throws URISyntaxException { + super(new URI("mem://Test.java"), Kind.SOURCE); + this.code = code; + } + + @Override + public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { + return code; + } + } +} From 4e5542117162a029d3cf0890437f07cbe4bf5c26 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Mon, 4 May 2020 12:28:36 +0200 Subject: [PATCH 10/88] 8243548: Javac incorrectly collects enum fields when verifying switch expression exhaustivness When gathering enum constants for exhaustivness analysis, make sure nested enum classes are not included Reviewed-by: vromero --- .../share/classes/com/sun/tools/javac/comp/Flow.java | 9 ++++++--- .../tools/javac/switchexpr/ExhaustiveEnumSwitch.java | 10 +++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java index 0d06ed464e7..bb217c4e50d 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Flow.java @@ -30,7 +30,6 @@ package com.sun.tools.javac.comp; import java.util.HashMap; import java.util.HashSet; import java.util.Set; -import java.util.stream.Collectors; import com.sun.source.tree.LambdaExpressionTree.BodyKind; import com.sun.tools.javac.code.*; @@ -44,6 +43,7 @@ import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; import com.sun.tools.javac.util.JCDiagnostic.Error; import com.sun.tools.javac.util.JCDiagnostic.Warning; +import com.sun.tools.javac.code.Kinds.Kind; import com.sun.tools.javac.code.Symbol.*; import com.sun.tools.javac.tree.JCTree.*; @@ -697,9 +697,12 @@ public class Flow { pendingExits = new ListBuffer<>(); scan(tree.selector); Set constants = null; - if ((tree.selector.type.tsym.flags() & ENUM) != 0) { + TypeSymbol selectorSym = tree.selector.type.tsym; + if ((selectorSym.flags() & ENUM) != 0) { constants = new HashSet<>(); - for (Symbol s : tree.selector.type.tsym.members().getSymbols(s -> (s.flags() & ENUM) != 0)) { + Filter enumConstantFilter = + s -> (s.flags() & ENUM) != 0 && s.kind == Kind.VAR; + for (Symbol s : selectorSym.members().getSymbols(enumConstantFilter)) { constants.add(s.name); } } diff --git a/test/langtools/tools/javac/switchexpr/ExhaustiveEnumSwitch.java b/test/langtools/tools/javac/switchexpr/ExhaustiveEnumSwitch.java index e01aedfea18..c45dfda4928 100644 --- a/test/langtools/tools/javac/switchexpr/ExhaustiveEnumSwitch.java +++ b/test/langtools/tools/javac/switchexpr/ExhaustiveEnumSwitch.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8206986 + * @bug 8206986 8243548 * @summary Verify that an switch expression over enum can be exhaustive without default. * @compile ExhaustiveEnumSwitch.java * @compile ExhaustiveEnumSwitchExtra.java @@ -56,4 +56,12 @@ public class ExhaustiveEnumSwitch { } enum ExhaustiveEnumSwitchEnum { A, B; + class NestedClass {} + enum NestedEnum {} + interface NestedInterface {} + @interface NestedAnnotation {} + void nestedMethod() {} + static void nestedStaticMethod() {} + int nestedField; + static int nestedStaticField; } From 352e460529330cb7b786b789a982fd02d4ce0ac0 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Mon, 4 May 2020 12:37:58 +0100 Subject: [PATCH 11/88] 8244281: test/jdk/com/sun/crypto/provider/KeyProtector/IterationCount.java fails with --illegal-access=deny Reviewed-by: weijun, xuelei --- .../jdk/com/sun/crypto/provider/KeyProtector/IterationCount.java | 1 + 1 file changed, 1 insertion(+) diff --git a/test/jdk/com/sun/crypto/provider/KeyProtector/IterationCount.java b/test/jdk/com/sun/crypto/provider/KeyProtector/IterationCount.java index 6e8ac975b59..e61f8b45f77 100644 --- a/test/jdk/com/sun/crypto/provider/KeyProtector/IterationCount.java +++ b/test/jdk/com/sun/crypto/provider/KeyProtector/IterationCount.java @@ -88,6 +88,7 @@ public class IterationCount { private static void executeCommand(List cmd, String expectedCount) throws Throwable { + cmd.add("--add-opens=java.base/com.sun.crypto.provider=ALL-UNNAMED"); cmd.add(IterationCount.class.getName()); cmd.add(clientStr); cmd.add(expectedCount); From e5099daae260524893840f53093367bfbfe6d880 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Mon, 4 May 2020 12:40:17 +0100 Subject: [PATCH 12/88] 8244283: test/jdk/sun/net/idn/TestStringPrep.java fails with --illegal-access=deny Reviewed-by: chegar --- test/jdk/sun/net/idn/TestStringPrep.java | 1 + 1 file changed, 1 insertion(+) diff --git a/test/jdk/sun/net/idn/TestStringPrep.java b/test/jdk/sun/net/idn/TestStringPrep.java index 6ee0db7fc28..3ccb5adac20 100644 --- a/test/jdk/sun/net/idn/TestStringPrep.java +++ b/test/jdk/sun/net/idn/TestStringPrep.java @@ -26,6 +26,7 @@ * @summary Unit test for jdk.internal.icu.text.StringPrep * @bug 4737170 8060097 8174270 * @modules java.base/jdk.internal.icu.text + * java.base/sun.net.idn:open * @library . * @compile -XDignore.symbol.file TestStringPrep.java NFS4StringPrep.java * TestData.java From c7b1b1bb743cb6ed78d49121d66b5651ebf8a8b1 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Mon, 4 May 2020 12:45:12 +0100 Subject: [PATCH 13/88] 8244284: Two tests in test/hotspot/jtreg/vmTestbase fail with --illegal-access=deny Reviewed-by: iignatyev --- .../invokeMethod/invokemethod009/TestDescription.java | 3 ++- .../invokeMethod/invokemethod006/TestDescription.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod009/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod009/TestDescription.java index 0c9e4f3a174..d253d25892d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod009/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassType/invokeMethod/invokemethod009/TestDescription.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -42,6 +42,7 @@ * should return list of loaded classes only. * COMMENTS * + * @modules jdk.jdi/com.sun.tools.jdi:open * @library /vmTestbase * /test/lib * @run driver jdk.test.lib.FileInstaller . . diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod006/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod006/TestDescription.java index 8f822bd3262..3fa2a5519eb 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod006/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/invokeMethod/invokemethod006/TestDescription.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -38,6 +38,7 @@ * class loader. * COMMENTS * + * @modules jdk.jdi/com.sun.tools.jdi:open * @library /vmTestbase * /test/lib * @run driver jdk.test.lib.FileInstaller . . From cbfcae7746398fad9a71a4a8efef6f0034320f88 Mon Sep 17 00:00:00 2001 From: Stefan Johansson Date: Mon, 4 May 2020 15:05:38 +0200 Subject: [PATCH 14/88] 8233439: G1 zero_filled optimization when committing CardCountsTable does not work Reviewed-by: tschatzl, kbarrett --- .../share/gc/g1/g1RegionToSpaceMapper.cpp | 113 +++++++++++------- .../share/gc/g1/g1RegionToSpaceMapper.hpp | 6 +- 2 files changed, 68 insertions(+), 51 deletions(-) diff --git a/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.cpp b/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.cpp index cef4c9b1ab3..725bf93b030 100644 --- a/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.cpp +++ b/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.cpp @@ -46,7 +46,7 @@ G1RegionToSpaceMapper::G1RegionToSpaceMapper(ReservedSpace rs, _listener(NULL), _storage(rs, used_size, page_size), _region_granularity(region_granularity), - _commit_map(rs.size() * commit_factor / region_granularity, mtGC), + _region_commit_map(rs.size() * commit_factor / region_granularity, mtGC), _memory_type(type) { guarantee(is_power_of_2(page_size), "must be"); guarantee(is_power_of_2(region_granularity), "must be"); @@ -88,13 +88,13 @@ class G1RegionsLargerThanCommitSizeMapper : public G1RegionToSpaceMapper { if (AlwaysPreTouch) { _storage.pretouch(start_page, size_in_pages, pretouch_gang); } - _commit_map.set_range(start_idx, start_idx + num_regions); + _region_commit_map.set_range(start_idx, start_idx + num_regions); fire_on_commit(start_idx, num_regions, zero_filled); } virtual void uncommit_regions(uint start_idx, size_t num_regions) { _storage.uncommit((size_t)start_idx * _pages_per_region, num_regions * _pages_per_region); - _commit_map.clear_range(start_idx, start_idx + num_regions); + _region_commit_map.clear_range(start_idx, start_idx + num_regions); } }; @@ -102,18 +102,26 @@ class G1RegionsLargerThanCommitSizeMapper : public G1RegionToSpaceMapper { // than the commit granularity. // Basically, the contents of one OS page span several regions. class G1RegionsSmallerThanCommitSizeMapper : public G1RegionToSpaceMapper { - private: - class CommitRefcountArray : public G1BiasedMappedArray { - protected: - virtual uint default_value() const { return 0; } - }; - size_t _regions_per_page; - CommitRefcountArray _refcounts; + size_t region_idx_to_page_idx(uint region_idx) const { + return region_idx / _regions_per_page; + } - uintptr_t region_idx_to_page_idx(uint region) const { - return region / _regions_per_page; + bool is_page_committed(size_t page_idx) { + size_t region = page_idx * _regions_per_page; + size_t region_limit = region + _regions_per_page; + // Committed if there is a bit set in the range. + return _region_commit_map.get_next_one_offset(region, region_limit) != region_limit; + } + + void numa_request_on_node(size_t page_idx) { + if (_memory_type == mtJavaHeap) { + uint region = (uint)(page_idx * _regions_per_page); + void* address = _storage.page_start(page_idx); + size_t size_in_bytes = _storage.page_size(); + G1NUMA::numa()->request_memory_on_node(address, size_in_bytes, region); + } } public: @@ -124,63 +132,76 @@ class G1RegionsSmallerThanCommitSizeMapper : public G1RegionToSpaceMapper { size_t commit_factor, MemoryType type) : G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, commit_factor, type), - _regions_per_page((page_size * commit_factor) / alloc_granularity), _refcounts() { + _regions_per_page((page_size * commit_factor) / alloc_granularity) { guarantee((page_size * commit_factor) >= alloc_granularity, "allocation granularity smaller than commit granularity"); - _refcounts.initialize((HeapWord*)rs.base(), (HeapWord*)(rs.base() + align_up(rs.size(), page_size)), page_size); } virtual void commit_regions(uint start_idx, size_t num_regions, WorkGang* pretouch_gang) { + uint region_limit = (uint)(start_idx + num_regions); + assert(num_regions > 0, "Must commit at least one region"); + assert(_region_commit_map.get_next_one_offset(start_idx, region_limit) == region_limit, + "Should be no committed regions in the range [%u, %u)", start_idx, region_limit); + size_t const NoPage = ~(size_t)0; size_t first_committed = NoPage; size_t num_committed = 0; + size_t start_page = region_idx_to_page_idx(start_idx); + size_t end_page = region_idx_to_page_idx(region_limit - 1); + bool all_zero_filled = true; - G1NUMA* numa = G1NUMA::numa(); - - for (uint region_idx = start_idx; region_idx < start_idx + num_regions; region_idx++) { - assert(!_commit_map.at(region_idx), "Trying to commit storage at region %u that is already committed", region_idx); - size_t page_idx = region_idx_to_page_idx(region_idx); - uint old_refcount = _refcounts.get_by_index(page_idx); - - bool zero_filled = false; - if (old_refcount == 0) { - if (first_committed == NoPage) { - first_committed = page_idx; - num_committed = 1; - } else { - num_committed++; + for (size_t page = start_page; page <= end_page; page++) { + if (!is_page_committed(page)) { + // Page not committed. + if (num_committed == 0) { + first_committed = page; } - zero_filled = _storage.commit(page_idx, 1); - if (_memory_type == mtJavaHeap) { - void* address = _storage.page_start(page_idx); - size_t size_in_bytes = _storage.page_size(); - numa->request_memory_on_node(address, size_in_bytes, region_idx); + num_committed++; + + if (!_storage.commit(page, 1)) { + // Found dirty region during commit. + all_zero_filled = false; } + + // Move memory to correct NUMA node for the heap. + numa_request_on_node(page); + } else { + // Page already committed. + all_zero_filled = false; } - all_zero_filled &= zero_filled; - - _refcounts.set_by_index(page_idx, old_refcount + 1); - _commit_map.set_bit(region_idx); } + + // Update the commit map for the given range. + _region_commit_map.set_range(start_idx, region_limit); + if (AlwaysPreTouch && num_committed > 0) { _storage.pretouch(first_committed, num_committed, pretouch_gang); } + fire_on_commit(start_idx, num_regions, all_zero_filled); } virtual void uncommit_regions(uint start_idx, size_t num_regions) { - for (uint i = start_idx; i < start_idx + num_regions; i++) { - assert(_commit_map.at(i), "Trying to uncommit storage at region %u that is not committed", i); - size_t idx = region_idx_to_page_idx(i); - uint old_refcount = _refcounts.get_by_index(idx); - assert(old_refcount > 0, "must be"); - if (old_refcount == 1) { - _storage.uncommit(idx, 1); + uint region_limit = (uint)(start_idx + num_regions); + assert(num_regions > 0, "Must uncommit at least one region"); + assert(_region_commit_map.get_next_zero_offset(start_idx, region_limit) == region_limit, + "Should only be committed regions in the range [%u, %u)", start_idx, region_limit); + + size_t start_page = region_idx_to_page_idx(start_idx); + size_t end_page = region_idx_to_page_idx(region_limit - 1); + + // Clear commit map for the given range. + _region_commit_map.clear_range(start_idx, region_limit); + + for (size_t page = start_page; page <= end_page; page++) { + // We know all pages were committed before clearing the map. If the + // the page is still marked as committed after the clear we should + // not uncommit it. + if (!is_page_committed(page)) { + _storage.uncommit(page, 1); } - _refcounts.set_by_index(idx, old_refcount - 1); - _commit_map.clear_bit(i); } } }; diff --git a/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.hpp b/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.hpp index 7ac80020e93..87ffae6172b 100644 --- a/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.hpp +++ b/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.hpp @@ -51,7 +51,7 @@ class G1RegionToSpaceMapper : public CHeapObj { size_t _region_granularity; // Mapping management - CHeapBitMap _commit_map; + CHeapBitMap _region_commit_map; MemoryType _memory_type; @@ -68,10 +68,6 @@ class G1RegionToSpaceMapper : public CHeapObj { virtual ~G1RegionToSpaceMapper() {} - bool is_committed(uintptr_t idx) const { - return _commit_map.at(idx); - } - void commit_and_set_special(); virtual void commit_regions(uint start_idx, size_t num_regions = 1, WorkGang* pretouch_workers = NULL) = 0; virtual void uncommit_regions(uint start_idx, size_t num_regions = 1) = 0; From 2d8bea8c1d08e1ae5234c8e0af214e32757e2021 Mon Sep 17 00:00:00 2001 From: Zhengyu Gu Date: Mon, 4 May 2020 10:01:25 -0400 Subject: [PATCH 15/88] 8244328: Shenandoah: move ShenandoahThreadLocalData::_disarmed_value initialization Reviewed-by: shade --- src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp b/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp index de7db42afca..133876de9cd 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp @@ -54,7 +54,8 @@ private: _gclab(NULL), _gclab_size(0), _worker_id(INVALID_WORKER_ID), - _force_satb_flush(false) { + _force_satb_flush(false), + _disarmed_value(ShenandoahCodeRoots::disarmed_value()) { } ~ShenandoahThreadLocalData() { @@ -128,7 +129,6 @@ public: assert(data(thread)->_gclab == NULL, "Only initialize once"); data(thread)->_gclab = new PLAB(PLAB::min_size()); data(thread)->_gclab_size = 0; - data(thread)->_disarmed_value = ShenandoahCodeRoots::disarmed_value(); } static PLAB* gclab(Thread* thread) { From 31041d406a1527eebf7e3d3a384e568dc66fe9fb Mon Sep 17 00:00:00 2001 From: Jorn Vernee Date: Mon, 4 May 2020 09:41:01 -0700 Subject: [PATCH 16/88] 8241100: Make Boolean, Character, Byte, and Short implement Constable Reviewed-by: jrose, briangoetz, psandoz --- .../share/classes/java/lang/Boolean.java | 23 +++++- .../share/classes/java/lang/Byte.java | 25 +++++- .../share/classes/java/lang/Character.java | 31 ++++++-- .../share/classes/java/lang/Short.java | 25 +++++- .../java/lang/constant/ConstantDescs.java | 36 ++++++++- .../java/lang/invoke/ConstantBootstraps.java | 67 +++++++++++++++- test/jdk/java/lang/constant/ConvertTest.java | 79 +++++++++++++++++++ .../lang/constant/DescribeResolveTest.java | 58 ++++++++++++++ 8 files changed, 330 insertions(+), 14 deletions(-) create mode 100644 test/jdk/java/lang/constant/ConvertTest.java create mode 100644 test/jdk/java/lang/constant/DescribeResolveTest.java diff --git a/src/java.base/share/classes/java/lang/Boolean.java b/src/java.base/share/classes/java/lang/Boolean.java index 932bb397747..29516752c97 100644 --- a/src/java.base/share/classes/java/lang/Boolean.java +++ b/src/java.base/share/classes/java/lang/Boolean.java @@ -27,6 +27,15 @@ package java.lang; import jdk.internal.HotSpotIntrinsicCandidate; +import java.lang.constant.Constable; +import java.lang.constant.ConstantDesc; +import java.lang.constant.ConstantDescs; +import java.lang.constant.DynamicConstantDesc; +import java.util.Optional; + +import static java.lang.constant.ConstantDescs.BSM_GET_STATIC_FINAL; +import static java.lang.constant.ConstantDescs.CD_Boolean; + /** * The Boolean class wraps a value of the primitive type * {@code boolean} in an object. An object of type @@ -43,7 +52,7 @@ import jdk.internal.HotSpotIntrinsicCandidate; * @since 1.0 */ public final class Boolean implements java.io.Serializable, - Comparable + Comparable, Constable { /** * The {@code Boolean} object corresponding to the primitive @@ -344,4 +353,16 @@ public final class Boolean implements java.io.Serializable, public static boolean logicalXor(boolean a, boolean b) { return a ^ b; } + + /** + * Returns an {@link Optional} containing the nominal descriptor for this + * instance. + * + * @return an {@link Optional} describing the {@linkplain Boolean} instance + * @since 15 + */ + @Override + public Optional> describeConstable() { + return Optional.of(value ? ConstantDescs.TRUE : ConstantDescs.FALSE); + } } diff --git a/src/java.base/share/classes/java/lang/Byte.java b/src/java.base/share/classes/java/lang/Byte.java index 78168f35432..c43b319c9e7 100644 --- a/src/java.base/share/classes/java/lang/Byte.java +++ b/src/java.base/share/classes/java/lang/Byte.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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,6 +28,15 @@ package java.lang; import jdk.internal.HotSpotIntrinsicCandidate; import jdk.internal.misc.VM; +import java.lang.constant.Constable; +import java.lang.constant.DynamicConstantDesc; +import java.util.Optional; + +import static java.lang.constant.ConstantDescs.BSM_EXPLICIT_CAST; +import static java.lang.constant.ConstantDescs.CD_byte; +import static java.lang.constant.ConstantDescs.CD_int; +import static java.lang.constant.ConstantDescs.DEFAULT_NAME; + /** * * The {@code Byte} class wraps a value of primitive type {@code byte} @@ -44,7 +53,7 @@ import jdk.internal.misc.VM; * @see java.lang.Number * @since 1.1 */ -public final class Byte extends Number implements Comparable { +public final class Byte extends Number implements Comparable, Constable { /** * A constant holding the minimum value a {@code byte} can @@ -77,6 +86,18 @@ public final class Byte extends Number implements Comparable { return Integer.toString((int)b, 10); } + /** + * Returns an {@link Optional} containing the nominal descriptor for this + * instance. + * + * @return an {@link Optional} describing the {@linkplain Byte} instance + * @since 15 + */ + @Override + public Optional> describeConstable() { + return Optional.of(DynamicConstantDesc.ofNamed(BSM_EXPLICIT_CAST, DEFAULT_NAME, CD_byte, intValue())); + } + private static class ByteCache { private ByteCache() {} diff --git a/src/java.base/share/classes/java/lang/Character.java b/src/java.base/share/classes/java/lang/Character.java index 3e4048c118b..5c9da38de21 100644 --- a/src/java.base/share/classes/java/lang/Character.java +++ b/src/java.base/share/classes/java/lang/Character.java @@ -25,14 +25,22 @@ package java.lang; -import java.util.Arrays; -import java.util.Map; -import java.util.HashMap; -import java.util.Locale; - import jdk.internal.HotSpotIntrinsicCandidate; import jdk.internal.misc.VM; +import java.lang.constant.Constable; +import java.lang.constant.DynamicConstantDesc; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.Optional; + +import static java.lang.constant.ConstantDescs.BSM_EXPLICIT_CAST; +import static java.lang.constant.ConstantDescs.CD_char; +import static java.lang.constant.ConstantDescs.CD_int; +import static java.lang.constant.ConstantDescs.DEFAULT_NAME; + /** * The {@code Character} class wraps a value of the primitive * type {@code char} in an object. An object of class @@ -122,7 +130,7 @@ import jdk.internal.misc.VM; * @since 1.0 */ public final -class Character implements java.io.Serializable, Comparable { +class Character implements java.io.Serializable, Comparable, Constable { /** * The minimum radix available for conversion to and from strings. * The constant value of this field is the smallest value permitted @@ -602,6 +610,17 @@ class Character implements java.io.Serializable, Comparable { */ public static final int MAX_CODE_POINT = 0X10FFFF; + /** + * Returns an {@link Optional} containing the nominal descriptor for this + * instance. + * + * @return an {@link Optional} describing the {@linkplain Character} instance + * @since 15 + */ + @Override + public Optional> describeConstable() { + return Optional.of(DynamicConstantDesc.ofNamed(BSM_EXPLICIT_CAST, DEFAULT_NAME, CD_char, (int) value)); + } /** * Instances of this class represent particular subsets of the Unicode diff --git a/src/java.base/share/classes/java/lang/Short.java b/src/java.base/share/classes/java/lang/Short.java index c5a686c1a71..de3e738bd8d 100644 --- a/src/java.base/share/classes/java/lang/Short.java +++ b/src/java.base/share/classes/java/lang/Short.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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,6 +28,15 @@ package java.lang; import jdk.internal.HotSpotIntrinsicCandidate; import jdk.internal.misc.VM; +import java.lang.constant.Constable; +import java.lang.constant.DynamicConstantDesc; +import java.util.Optional; + +import static java.lang.constant.ConstantDescs.BSM_EXPLICIT_CAST; +import static java.lang.constant.ConstantDescs.CD_int; +import static java.lang.constant.ConstantDescs.CD_short; +import static java.lang.constant.ConstantDescs.DEFAULT_NAME; + /** * The {@code Short} class wraps a value of primitive type {@code * short} in an object. An object of type {@code Short} contains a @@ -43,7 +52,7 @@ import jdk.internal.misc.VM; * @see java.lang.Number * @since 1.1 */ -public final class Short extends Number implements Comparable { +public final class Short extends Number implements Comparable, Constable { /** * A constant holding the minimum value a {@code short} can @@ -203,6 +212,18 @@ public final class Short extends Number implements Comparable { return valueOf(s, 10); } + /** + * Returns an {@link Optional} containing the nominal descriptor for this + * instance. + * + * @return an {@link Optional} describing the {@linkplain Short} instance + * @since 15 + */ + @Override + public Optional> describeConstable() { + return Optional.of(DynamicConstantDesc.ofNamed(BSM_EXPLICIT_CAST, DEFAULT_NAME, CD_short, intValue())); + } + private static class ShortCache { private ShortCache() {} diff --git a/src/java.base/share/classes/java/lang/constant/ConstantDescs.java b/src/java.base/share/classes/java/lang/constant/ConstantDescs.java index 0dd8531d315..4dbdc193f7c 100644 --- a/src/java.base/share/classes/java/lang/constant/ConstantDescs.java +++ b/src/java.base/share/classes/java/lang/constant/ConstantDescs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -194,10 +194,18 @@ public final class ConstantDescs { = ofConstantBootstrap(CD_ConstantBootstraps, "enumConstant", CD_Enum); + /** + * {@link MethodHandleDesc} representing {@link ConstantBootstraps#getStaticFinal(Lookup, String, Class, Class) ConstantBootstraps.getStaticFinal} + * @since 15 + */ + public static final DirectMethodHandleDesc BSM_GET_STATIC_FINAL + = ofConstantBootstrap(CD_ConstantBootstraps, "getStaticFinal", + CD_Object, CD_Class); + /** {@link MethodHandleDesc} representing {@link ConstantBootstraps#nullConstant(Lookup, String, Class) ConstantBootstraps.nullConstant} */ public static final DirectMethodHandleDesc BSM_NULL_CONSTANT = ofConstantBootstrap(CD_ConstantBootstraps, "nullConstant", - ConstantDescs.CD_Object); + CD_Object); /** {@link MethodHandleDesc} representing {@link ConstantBootstraps#fieldVarHandle(Lookup, String, Class, Class, Class) ConstantBootstraps.fieldVarHandle} */ public static final DirectMethodHandleDesc BSM_VARHANDLE_FIELD @@ -219,6 +227,14 @@ public final class ConstantDescs { = ofConstantBootstrap(CD_ConstantBootstraps, "invoke", CD_Object, CD_MethodHandle, CD_Object.arrayType()); + /** + * {@link MethodHandleDesc} representing {@link ConstantBootstraps#explicitCast(Lookup, String, Class, Object)} ConstantBootstraps.explicitCast} + * @since 15 + */ + public static final DirectMethodHandleDesc BSM_EXPLICIT_CAST + = ofConstantBootstrap(CD_ConstantBootstraps, "explicitCast", + CD_Object, CD_Object); + /** {@link ClassDesc} representing the primitive type {@code int} */ public static final ClassDesc CD_int = ClassDesc.ofDescriptor("I"); @@ -251,6 +267,22 @@ public final class ConstantDescs { = DynamicConstantDesc.ofNamed(ConstantDescs.BSM_NULL_CONSTANT, DEFAULT_NAME, ConstantDescs.CD_Object); + /** + * Nominal descriptor representing the constant {@linkplain Boolean#TRUE} + * @since 15 + */ + public static final DynamicConstantDesc TRUE + = DynamicConstantDesc.ofNamed(BSM_GET_STATIC_FINAL, + "TRUE", CD_Boolean, CD_Boolean); + + /** + * Nominal descriptor representing the constant {@linkplain Boolean#TRUE} + * @since 15 + */ + public static final DynamicConstantDesc FALSE + = DynamicConstantDesc.ofNamed(BSM_GET_STATIC_FINAL, + "FALSE", CD_Boolean, CD_Boolean); + static final DirectMethodHandleDesc MHD_METHODHANDLE_ASTYPE = MethodHandleDesc.ofMethod(Kind.VIRTUAL, CD_MethodHandle, "asType", MethodTypeDesc.of(CD_MethodHandle, CD_MethodType)); diff --git a/src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java b/src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java index 5cc230c63d5..71cae83e160 100644 --- a/src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java +++ b/src/java.base/share/classes/java/lang/invoke/ConstantBootstraps.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -355,6 +355,71 @@ public final class ConstantBootstraps { return MethodHandles.arrayElementVarHandle(validateClassAccess(lookup, arrayClass)); } + /** + * Applies a conversion from a source type to a destination type. + *

+ * Given a destination type {@code dstType} and an input + * value {@code value}, one of the following will happen: + *

    + *
  • If {@code dstType} is {@code void.class}, + * a {@link ClassCastException} is thrown. + *
  • If {@code dstType} is {@code Object.class}, {@code value} is returned as is. + *
+ *

+ * Otherwise one of the following conversions is applied to {@code value}: + *

    + *
  1. If {@code dstType} is a reference type, a reference cast + * is applied to {@code value} as if by calling {@code dstType.cast(value)}. + *
  2. If {@code dstType} is a primitive type, then, if the runtime type + * of {@code value} is a primitive wrapper type (such as {@link Integer}), + * a Java unboxing conversion is applied {@jls 5.1.8} followed by a + * Java casting conversion {@jls 5.5} converting either directly to + * {@code dstType}, or, if {@code dstType} is {@code boolean}, + * to {@code int}, which is then converted to either {@code true} + * or {@code false} depending on whether the least-significant-bit + * is 1 or 0 respectively. If the runtime type of {@code value} is + * not a primitive wrapper type a {@link ClassCastException} is thrown. + *
+ *

+ * The result is the same as when using the following code: + *

{@code
+     * MethodHandle id = MethodHandles.identity(dstType);
+     * MethodType mt = MethodType.methodType(dstType, Object.class);
+     * MethodHandle conv = MethodHandles.explicitCastArguments(id, mt);
+     * return conv.invoke(value);
+     * }
+ * + * @param lookup unused + * @param name unused + * @param dstType the destination type of the conversion + * @param value the value to be converted + * @return the converted value + * @throws ClassCastException when {@code dstType} is {@code void}, + * when a cast per (1) fails, or when {@code dstType} is a primitive type + * and the runtime type of {@code value} is not a primitive wrapper type + * (such as {@link Integer}) + * + * @since 15 + */ + public static Object explicitCast(MethodHandles.Lookup lookup, String name, Class dstType, Object value) + throws ClassCastException { + if (dstType == void.class) + throw new ClassCastException("Can not convert to void"); + if (dstType == Object.class) + return value; + + MethodHandle id = MethodHandles.identity(dstType); + MethodType mt = MethodType.methodType(dstType, Object.class); + MethodHandle conv = MethodHandles.explicitCastArguments(id, mt); + try { + return conv.invoke(value); + } catch (ClassCastException e) { + throw e; // specified, let CCE through + } catch (Throwable throwable) { + throw new InternalError(throwable); // Not specified, throw InternalError + } + } + private static Class validateClassAccess(MethodHandles.Lookup lookup, Class type) { try { lookup.accessClass(type); diff --git a/test/jdk/java/lang/constant/ConvertTest.java b/test/jdk/java/lang/constant/ConvertTest.java new file mode 100644 index 00000000000..d7018df6352 --- /dev/null +++ b/test/jdk/java/lang/constant/ConvertTest.java @@ -0,0 +1,79 @@ +/* + * 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 + * @run testng ConvertTest + */ + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.lang.invoke.ConstantBootstraps; +import java.math.BigInteger; + +import static org.testng.Assert.assertEquals; + +public class ConvertTest { + + @DataProvider + public static Object[][] cceInputs() { + return new Object[][]{ + { void.class, null }, + { Integer.class, "a" }, + { int.class, BigInteger.ZERO }, + }; + } + + @Test(dataProvider = "cceInputs", expectedExceptions = ClassCastException.class) + public void testBadConversion(Class dstType, Object value) { + ConstantBootstraps.explicitCast(null, null, dstType, value); + } + + @DataProvider + public static Object[][] goodInputs() { + Object o = new Object(); + return new Object[][]{ + { Object.class, null, null }, + { Object.class, o, o }, + { String.class, "abc", "abc" }, + { short.class, 10, (short) 10 }, + { int.class, (short) 10, 10 }, + { boolean.class, 1, true }, + { boolean.class, 2, false }, + { int.class, true, 1 }, + { int.class, false, 0 }, + { int.class, 10, 10 }, + { Integer.class, 10, 10 }, + { Object.class, 10, 10 }, + { Number.class, 10, 10 }, + }; + } + + @Test(dataProvider = "goodInputs") + public void testSuccess(Class dstType, Object value, Object expected) { + Object actual = ConstantBootstraps.explicitCast(null, null, dstType, value); + assertEquals(actual, expected); + } + +} diff --git a/test/jdk/java/lang/constant/DescribeResolveTest.java b/test/jdk/java/lang/constant/DescribeResolveTest.java new file mode 100644 index 00000000000..cc2a36dd3e2 --- /dev/null +++ b/test/jdk/java/lang/constant/DescribeResolveTest.java @@ -0,0 +1,58 @@ +/* + * 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 + * @run testng DescribeResolveTest + */ + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.lang.constant.Constable; +import java.lang.constant.ConstantDesc; +import java.lang.invoke.MethodHandles; + +import static org.testng.Assert.assertEquals; + +public class DescribeResolveTest { + + @DataProvider + public static Object[][] constables() { + return new Object[][]{ + { true }, + { false }, + { (short) 10 }, + { (byte) 10 }, + { (char) 10 }, + }; + } + + @Test(dataProvider = "constables") + public void testDescribeResolve(Constable constable) throws ReflectiveOperationException { + ConstantDesc desc = constable.describeConstable().orElseThrow(); + Object resolved = desc.resolveConstantDesc(MethodHandles.lookup()); + assertEquals(constable, resolved); + } + +} From e70d76d741a243c319d8586ab85c8b39412a408c Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Mon, 4 May 2020 19:09:07 +0200 Subject: [PATCH 17/88] 8244200: Shenandoah: build breakages after JDK-8241743 Reviewed-by: rkennke --- .../gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp | 1 + .../gc/shenandoah/heuristics/shenandoahCompactHeuristics.cpp | 1 + .../gc/shenandoah/heuristics/shenandoahPassiveHeuristics.cpp | 1 + .../gc/shenandoah/heuristics/shenandoahStaticHeuristics.cpp | 1 + .../share/gc/shenandoah/shenandoahConcurrentMark.inline.hpp | 1 + src/hotspot/share/gc/shenandoah/shenandoahEvacOOMHandler.cpp | 2 +- src/hotspot/share/gc/shenandoah/shenandoahJfrSupport.cpp | 2 +- src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.cpp | 2 +- src/hotspot/share/gc/shenandoah/shenandoahOopClosures.hpp | 2 +- src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.cpp | 2 +- src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp | 2 +- .../share/gc/shenandoah/shenandoahRootProcessor.inline.hpp | 1 + src/hotspot/share/gc/shenandoah/shenandoahUnload.cpp | 1 + src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp | 2 +- 14 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp index e7153510d29..59531b23e9b 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp @@ -27,6 +27,7 @@ #include "gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.hpp" #include "gc/shenandoah/shenandoahCollectionSet.hpp" #include "gc/shenandoah/shenandoahFreeSet.hpp" +#include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp" #include "logging/log.hpp" #include "logging/logTag.hpp" diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahCompactHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahCompactHeuristics.cpp index 74d3107a6aa..a2292cf78df 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahCompactHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahCompactHeuristics.cpp @@ -27,6 +27,7 @@ #include "gc/shenandoah/shenandoahCollectionSet.hpp" #include "gc/shenandoah/heuristics/shenandoahCompactHeuristics.hpp" #include "gc/shenandoah/shenandoahFreeSet.hpp" +#include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp" #include "logging/log.hpp" #include "logging/logTag.hpp" diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahPassiveHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahPassiveHeuristics.cpp index 152ed29f541..8cd21b08b3e 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahPassiveHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahPassiveHeuristics.cpp @@ -26,6 +26,7 @@ #include "gc/shenandoah/heuristics/shenandoahPassiveHeuristics.hpp" #include "gc/shenandoah/shenandoahCollectionSet.hpp" +#include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp" #include "logging/log.hpp" #include "logging/logTag.hpp" diff --git a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahStaticHeuristics.cpp b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahStaticHeuristics.cpp index 003857c08d9..d35d7df8009 100644 --- a/src/hotspot/share/gc/shenandoah/heuristics/shenandoahStaticHeuristics.cpp +++ b/src/hotspot/share/gc/shenandoah/heuristics/shenandoahStaticHeuristics.cpp @@ -27,6 +27,7 @@ #include "gc/shenandoah/heuristics/shenandoahStaticHeuristics.hpp" #include "gc/shenandoah/shenandoahCollectionSet.hpp" #include "gc/shenandoah/shenandoahFreeSet.hpp" +#include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp" #include "logging/log.hpp" #include "logging/logTag.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.inline.hpp index b45feb9197c..681ed0b1e84 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.inline.hpp @@ -28,6 +28,7 @@ #include "gc/shenandoah/shenandoahAsserts.hpp" #include "gc/shenandoah/shenandoahBarrierSet.inline.hpp" #include "gc/shenandoah/shenandoahConcurrentMark.hpp" +#include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp" #include "gc/shenandoah/shenandoahStringDedup.inline.hpp" #include "gc/shenandoah/shenandoahTaskqueue.inline.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahEvacOOMHandler.cpp b/src/hotspot/share/gc/shenandoah/shenandoahEvacOOMHandler.cpp index 6e43dfbb542..8cd1a21e518 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahEvacOOMHandler.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahEvacOOMHandler.cpp @@ -24,7 +24,7 @@ #include "precompiled.hpp" -#include "gc/shenandoah/shenandoahHeap.hpp" +#include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" #include "gc/shenandoah/shenandoahEvacOOMHandler.hpp" #include "gc/shenandoah/shenandoahThreadLocalData.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahJfrSupport.cpp b/src/hotspot/share/gc/shenandoah/shenandoahJfrSupport.cpp index e953bc23845..cd555e12c6f 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahJfrSupport.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahJfrSupport.cpp @@ -23,7 +23,7 @@ */ #include "precompiled.hpp" -#include "gc/shenandoah/shenandoahHeap.hpp" +#include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahHeapRegion.hpp" #include "gc/shenandoah/shenandoahJfrSupport.hpp" #include "jfr/jfrEvents.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.cpp b/src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.cpp index 1b9645380aa..eea57c3dd5d 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.cpp @@ -24,7 +24,7 @@ #include "precompiled.hpp" #include "gc/shared/markBitMap.inline.hpp" -#include "gc/shenandoah/shenandoahHeap.hpp" +#include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp" #include "gc/shenandoah/shenandoahMarkingContext.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.hpp b/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.hpp index f1d6b7821bd..a175fc1743f 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.hpp @@ -26,7 +26,7 @@ #define SHARE_GC_SHENANDOAH_SHENANDOAHOOPCLOSURES_HPP #include "gc/shared/referenceProcessor.hpp" -#include "gc/shenandoah/shenandoahHeap.hpp" +#include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahStrDedupQueue.hpp" #include "gc/shenandoah/shenandoahTaskqueue.hpp" #include "memory/iterator.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.cpp b/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.cpp index 15d6acefcdc..853fcb82a8b 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.cpp @@ -27,7 +27,7 @@ #include "gc/shared/workerDataArray.inline.hpp" #include "gc/shenandoah/shenandoahCollectorPolicy.hpp" #include "gc/shenandoah/shenandoahPhaseTimings.hpp" -#include "gc/shenandoah/shenandoahHeap.hpp" +#include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahHeuristics.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" #include "runtime/orderAccess.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp index 70a8155cc1c..65071a2a7ad 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp @@ -31,7 +31,7 @@ #include "gc/shenandoah/shenandoahClosures.inline.hpp" #include "gc/shenandoah/shenandoahConcurrentRoots.hpp" #include "gc/shenandoah/shenandoahRootProcessor.inline.hpp" -#include "gc/shenandoah/shenandoahHeap.hpp" +#include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahPhaseTimings.hpp" #include "gc/shenandoah/shenandoahStringDedup.hpp" #include "gc/shenandoah/shenandoahVMOperations.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp index 2b9efc9a339..33da3b00ea8 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.inline.hpp @@ -32,6 +32,7 @@ #include "gc/shenandoah/shenandoahClosures.inline.hpp" #include "gc/shenandoah/shenandoahConcurrentRoots.hpp" #include "gc/shenandoah/shenandoahHeuristics.hpp" +#include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahPhaseTimings.hpp" #include "gc/shenandoah/shenandoahRootProcessor.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahUnload.cpp b/src/hotspot/share/gc/shenandoah/shenandoahUnload.cpp index 66b6244861a..35c64949044 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahUnload.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahUnload.cpp @@ -34,6 +34,7 @@ #include "gc/shenandoah/shenandoahClosures.inline.hpp" #include "gc/shenandoah/shenandoahCodeRoots.hpp" #include "gc/shenandoah/shenandoahConcurrentRoots.hpp" +#include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahNMethod.inline.hpp" #include "gc/shenandoah/shenandoahLock.hpp" #include "gc/shenandoah/shenandoahRootProcessor.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp b/src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp index db73279d3c7..4c6f16c19ce 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp @@ -30,7 +30,7 @@ #include "gc/shared/gcWhen.hpp" #include "gc/shenandoah/shenandoahCollectorPolicy.hpp" #include "gc/shenandoah/shenandoahMarkCompact.hpp" -#include "gc/shenandoah/shenandoahHeap.hpp" +#include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahHeuristics.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" #include "utilities/debug.hpp" From 90e8a0a3dbacba97ba5cb43648a5cb804cd6aed2 Mon Sep 17 00:00:00 2001 From: Toshio Nakamura Date: Mon, 4 May 2020 19:01:27 +0100 Subject: [PATCH 18/88] 8243453: java --describe-module failed with non-ASCII module name under non-UTF8 environment Reviewed-by: alanb --- src/java.base/share/native/libjli/java.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/java.base/share/native/libjli/java.c b/src/java.base/share/native/libjli/java.c index 38ddbc03248..637c2092ecd 100644 --- a/src/java.base/share/native/libjli/java.c +++ b/src/java.base/share/native/libjli/java.c @@ -1958,7 +1958,7 @@ DescribeModule(JNIEnv *env, char *optString) NULL_CHECK(cls); NULL_CHECK(describeModuleID = (*env)->GetStaticMethodID(env, cls, "describeModule", "(Ljava/lang/String;)V")); - NULL_CHECK(joptString = (*env)->NewStringUTF(env, optString)); + NULL_CHECK(joptString = NewPlatformString(env, optString)); (*env)->CallStaticVoidMethod(env, cls, describeModuleID, joptString); } From 0efacb3eedf79dceb6aa185057df2658ce899723 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Mon, 4 May 2020 19:07:41 +0100 Subject: [PATCH 19/88] 8244292: Headful clients failing with --illegal-access=deny Reviewed-by: prr --- .../java/swing/plaf/windows/RevalidateOnPropertyChange.java | 4 ++-- .../DisplayChangesException/DisplayChangesException.java | 3 ++- .../awt/event/SequencedEvent/MultipleContextsUnitTest.java | 4 ++-- test/jdk/javax/accessibility/6714324/TabbedPaneMemLeak.java | 3 ++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/test/jdk/com/sun/java/swing/plaf/windows/RevalidateOnPropertyChange.java b/test/jdk/com/sun/java/swing/plaf/windows/RevalidateOnPropertyChange.java index 5b47f8d6b21..2bc4a251cb9 100644 --- a/test/jdk/com/sun/java/swing/plaf/windows/RevalidateOnPropertyChange.java +++ b/test/jdk/com/sun/java/swing/plaf/windows/RevalidateOnPropertyChange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -41,7 +41,7 @@ import javax.swing.plaf.FontUIResource; * @summary tests if the desktop property changes this will force the UIs to * update all known Frames * @requires (os.family == "windows") - * @modules java.desktop/sun.awt + * @modules java.desktop/java.awt:open java.desktop/sun.awt */ public final class RevalidateOnPropertyChange { diff --git a/test/jdk/java/awt/Toolkit/DisplayChangesException/DisplayChangesException.java b/test/jdk/java/awt/Toolkit/DisplayChangesException/DisplayChangesException.java index 385b9d820b7..0f13265ac58 100644 --- a/test/jdk/java/awt/Toolkit/DisplayChangesException/DisplayChangesException.java +++ b/test/jdk/java/awt/Toolkit/DisplayChangesException/DisplayChangesException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -39,6 +39,7 @@ import sun.awt.SunToolkit; * @bug 8207070 * @modules java.desktop/sun.java2d * java.desktop/sun.awt + * java.desktop/sun.awt.windows:open */ public final class DisplayChangesException { diff --git a/test/jdk/java/awt/event/SequencedEvent/MultipleContextsUnitTest.java b/test/jdk/java/awt/event/SequencedEvent/MultipleContextsUnitTest.java index 6f89e1668fe..8c7062f4abf 100644 --- a/test/jdk/java/awt/event/SequencedEvent/MultipleContextsUnitTest.java +++ b/test/jdk/java/awt/event/SequencedEvent/MultipleContextsUnitTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -35,7 +35,7 @@ import sun.awt.SunToolkit; * @bug 8204142 * @author Sergey Bylokhov * @key headful - * @modules java.desktop/sun.awt + * @modules java.desktop/java.awt:open java.desktop/sun.awt * @run main/othervm/timeout=30 MultipleContextsUnitTest */ public final class MultipleContextsUnitTest { diff --git a/test/jdk/javax/accessibility/6714324/TabbedPaneMemLeak.java b/test/jdk/javax/accessibility/6714324/TabbedPaneMemLeak.java index f025a52927f..bbede7174a0 100644 --- a/test/jdk/javax/accessibility/6714324/TabbedPaneMemLeak.java +++ b/test/jdk/javax/accessibility/6714324/TabbedPaneMemLeak.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -26,6 +26,7 @@ * @bug 6714324 * @summary tests if removing a Tab from JTabbedComponent, clears the reference * to the Page (AccessibleContext) object. + * @modules java.desktop/java.awt:open * @run main TabbedPaneMemLeak */ import javax.accessibility.Accessible; From 14ae7cf7692de8c8d5978ffe7a3e0d6cfa13c99a Mon Sep 17 00:00:00 2001 From: Andy Herrick Date: Sun, 3 May 2020 13:50:30 -0400 Subject: [PATCH 20/88] 8242865: Usability problems using mac signing in jpackage Reviewed-by: asemenyuk, almatvee --- .../jpackage/internal/MacBaseInstallerBundler.java | 6 ++++-- .../internal/resources/MacResources.properties | 11 ++++++----- .../internal/resources/MacResources_ja.properties | 10 ++++++---- .../internal/resources/MacResources_zh_CN.properties | 10 ++++++---- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/MacBaseInstallerBundler.java b/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/MacBaseInstallerBundler.java index 049673e863b..6423ea12268 100644 --- a/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/MacBaseInstallerBundler.java +++ b/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/MacBaseInstallerBundler.java @@ -167,12 +167,14 @@ public abstract class MacBaseInstallerBundler extends AbstractBundler { Pattern p = Pattern.compile("\"alis\"=\"([^\"]+)\""); Matcher m = p.matcher(baos.toString()); if (!m.find()) { - Log.error("Did not find a key matching '" + key + "'"); + Log.error(MessageFormat.format(I18N.getString( + "error.cert.not.found"), key, keychainName)); return null; } String matchedKey = m.group(1); if (m.find()) { - Log.error("Found more than one key matching '" + key + "'"); + Log.error(MessageFormat.format(I18N.getString( + "error.multiple.certs.found"), key, keychainName)); return null; } Log.verbose("Using key '" + matchedKey + "'"); diff --git a/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/resources/MacResources.properties b/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/resources/MacResources.properties index e194fc36789..9072e7c9de3 100644 --- a/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/resources/MacResources.properties +++ b/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/resources/MacResources.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2017, 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 @@ -31,10 +31,10 @@ pkg.bundler.name=Mac PKG Package error.invalid-cfbundle-version=Invalid CFBundleVersion: [{0}] error.invalid-cfbundle-version.advice=Set a compatible 'appVersion' or set a 'mac.CFBundleVersion'. Valid versions are one to three integers separated by dots. -error.explicit-sign-no-cert=Signature explicitly requested but no signing certificate specified -error.explicit-sign-no-cert.advice=Either specify a valid cert in 'mac.signing-key-developer-id-app' or unset 'signBundle' or set 'signBundle' to false. +error.explicit-sign-no-cert=Signature explicitly requested but no signing certificate found +error.explicit-sign-no-cert.advice=Specify a valid mac-signing-key-user-name and mac-signing-keychain error.must-sign-app-store=Mac App Store apps must be signed, and signing has been disabled by bundler configuration -error.must-sign-app-store.advice=Either unset 'signBundle' or set 'signBundle' to true +error.must-sign-app-store.advice=Use --mac-sign option with appropriate user-name and keychain error.no-app-signing-key=No Mac App Store App Signing Key error.no-app-signing-key.advice=Install your app signing keys into your Mac Keychain using XCode. error.no-pkg-signing-key=No Mac App Store Installer Signing Key @@ -42,7 +42,8 @@ error.no-pkg-signing-key.advice=Install your app signing keys into your Mac Keyc error.certificate.expired=Error: Certificate expired {0} error.no.xcode.signing=Xcode with command line developer tools is required for signing error.no.xcode.signing.advice=Install Xcode with command line developer tools. - +error.cert.not.found=No certificate found matching [{0}] using keychain [{1}] +error.multiple.certs.found=Multiple certificates found matching [{0}] using keychain [{1}] resource.bundle-config-file=Bundle config file resource.app-info-plist=Application Info.plist resource.runtime-info-plist=Java Runtime Info.plist diff --git a/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/resources/MacResources_ja.properties b/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/resources/MacResources_ja.properties index a49705f079c..30b2b036f4b 100644 --- a/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/resources/MacResources_ja.properties +++ b/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/resources/MacResources_ja.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2017, 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 @@ -31,10 +31,10 @@ pkg.bundler.name=Mac PKG\u30D1\u30C3\u30B1\u30FC\u30B8 error.invalid-cfbundle-version=\u7121\u52B9\u306ACFBundleVersion: [{0}] error.invalid-cfbundle-version.advice=\u4E92\u63DB\u6027\u306E\u3042\u308B'appVersion'\u3092\u8A2D\u5B9A\u3059\u308B\u304B\u3001'mac.CFBundleVersion'\u3092\u8A2D\u5B9A\u3057\u307E\u3059\u3002\u6709\u52B9\u306A\u30D0\u30FC\u30B8\u30E7\u30F3\u306F\u3001\u30C9\u30C3\u30C8\u3067\u533A\u5207\u3089\u308C\u305F1\u304B\u30893\u3064\u306E\u6574\u6570\u3067\u3059\u3002 -error.explicit-sign-no-cert=\u7F72\u540D\u304C\u660E\u793A\u7684\u306B\u8981\u6C42\u3055\u308C\u307E\u3057\u305F\u304C\u3001\u7F72\u540D\u8A3C\u660E\u66F8\u304C\u6307\u5B9A\u3055\u308C\u3066\u3044\u307E\u305B\u3093 -error.explicit-sign-no-cert.advice=\u6709\u52B9\u306A\u8A3C\u660E\u66F8\u3092'mac.signing-key-developer-id-app'\u3067\u6307\u5B9A\u3059\u308B\u304B\u3001'signBundle'\u3092\u8A2D\u5B9A\u89E3\u9664\u3059\u308B\u304B\u3001\u307E\u305F\u306F'signBundle'\u3092false\u306B\u8A2D\u5B9A\u3057\u307E\u3059\u3002 +error.explicit-sign-no-cert=Signature explicitly requested but no signing certificate found +error.explicit-sign-no-cert.advice=Specify a valid mac-signing-key-user-name and mac-signing-keychain error.must-sign-app-store=Mac App Store\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u306F\u7F72\u540D\u3055\u308C\u3066\u3044\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059\u304C\u3001\u7F72\u540D\u306F\u30D0\u30F3\u30C9\u30E9\u69CB\u6210\u306B\u3088\u3063\u3066\u7121\u52B9\u5316\u3055\u308C\u3066\u3044\u307E\u3059 -error.must-sign-app-store.advice='signBundle'\u3092\u8A2D\u5B9A\u89E3\u9664\u3059\u308B\u304B\u3001'signBundle'\u3092true\u306B\u8A2D\u5B9A\u3057\u3066\u304F\u3060\u3055\u3044 +error.must-sign-app-store.advice=Use --mac-sign option with appropriate user-name and keychain error.no-app-signing-key=Mac App Store\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u306E\u7F72\u540D\u30AD\u30FC\u304C\u3042\u308A\u307E\u305B\u3093 error.no-app-signing-key.advice=XCode\u3092\u4F7F\u7528\u3057\u3066\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u306E\u7F72\u540D\u30AD\u30FC\u3092Mac\u30AD\u30FC\u30C1\u30A7\u30FC\u30F3\u306B\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u3057\u307E\u3059\u3002 error.no-pkg-signing-key=Mac App Store\u30A4\u30F3\u30B9\u30C8\u30FC\u30E9\u306E\u7F72\u540D\u30AD\u30FC\u304C\u3042\u308A\u307E\u305B\u3093 @@ -42,6 +42,8 @@ error.no-pkg-signing-key.advice=XCode\u3092\u4F7F\u7528\u3057\u3066\u30A2\u30D7\ error.certificate.expired=\u30A8\u30E9\u30FC: \u8A3C\u660E\u66F8\u306F{0}\u306B\u671F\u9650\u304C\u5207\u308C\u307E\u3057\u305F error.no.xcode.signing=\u7F72\u540D\u306B\u306F\u3001Xcode\u3068\u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u30FB\u30C7\u30D9\u30ED\u30C3\u30D1\u30FB\u30C4\u30FC\u30EB\u304C\u5FC5\u8981\u3067\u3059 error.no.xcode.signing.advice=Xcode\u3068\u30B3\u30DE\u30F3\u30C9\u30E9\u30A4\u30F3\u30FB\u30C7\u30D9\u30ED\u30C3\u30D1\u30FB\u30C4\u30FC\u30EB\u3092\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u3057\u3066\u304F\u3060\u3055\u3044\u3002 +error.cert.not.found=No certificate found matching [{0}] using keychain [{1}] +error.multiple.certs.found=Multiple certificates found matching [{0}] using keychain [{1}] resource.bundle-config-file=\u30D0\u30F3\u30C9\u30EB\u69CB\u6210\u30D5\u30A1\u30A4\u30EB resource.app-info-plist=\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u306EInfo.plist diff --git a/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/resources/MacResources_zh_CN.properties b/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/resources/MacResources_zh_CN.properties index 14432eb449c..e720904a6ab 100644 --- a/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/resources/MacResources_zh_CN.properties +++ b/src/jdk.incubator.jpackage/macosx/classes/jdk/incubator/jpackage/internal/resources/MacResources_zh_CN.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2017, 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 @@ -31,10 +31,10 @@ pkg.bundler.name=Mac PKG \u7A0B\u5E8F\u5305 error.invalid-cfbundle-version=\u65E0\u6548\u7684 CFBundleVersion\uFF1A[{0}] error.invalid-cfbundle-version.advice=\u8BBE\u7F6E\u517C\u5BB9\u7684 'appVersion' \u6216\u8005\u8BBE\u7F6E 'mac.CFBundleVersion'\u3002\u6709\u6548\u7248\u672C\u5305\u542B\u4E00\u5230\u4E09\u4E2A\u7528\u70B9\u5206\u9694\u7684\u6574\u6570\u3002 -error.explicit-sign-no-cert=\u5DF2\u660E\u786E\u8BF7\u6C42\u7B7E\u540D, \u4F46\u672A\u6307\u5B9A\u7B7E\u540D\u8BC1\u4E66 -error.explicit-sign-no-cert.advice=\u5728 'mac.signing-key-developer-id-app' \u4E2D\u6307\u5B9A\u6709\u6548\u7684\u8BC1\u4E66, \u6216\u8005\u53D6\u6D88\u8BBE\u7F6E 'signBundle', \u6216\u8005\u5C06 'signBundle' \u8BBE\u7F6E\u4E3A\u201C\u5047\u201D\u3002 +error.explicit-sign-no-cert=Signature explicitly requested but no signing certificate found +error.explicit-sign-no-cert.advice=Specify a valid mac-signing-key-user-name and mac-signing-keychain error.must-sign-app-store=Mac App Store \u5E94\u7528\u7A0B\u5E8F\u5FC5\u987B\u7B7E\u540D, \u800C\u6253\u5305\u7A0B\u5E8F\u914D\u7F6E\u5DF2\u7981\u7528\u7B7E\u540D -error.must-sign-app-store.advice=\u53D6\u6D88\u8BBE\u7F6E 'signBundle' \u6216\u8005\u5C06 'signBundle' \u8BBE\u7F6E\u4E3A true +error.must-sign-app-store.advice=Use --mac-sign option with appropriate user-name and keychain error.no-app-signing-key=\u65E0 Mac App Store \u5E94\u7528\u7A0B\u5E8F\u7B7E\u540D\u5BC6\u94A5 error.no-app-signing-key.advice=\u4F7F\u7528 XCode \u5C06\u5E94\u7528\u7A0B\u5E8F\u7B7E\u540D\u5BC6\u94A5\u5B89\u88C5\u5230 Mac \u5BC6\u94A5\u94FE\u4E2D\u3002 error.no-pkg-signing-key=\u65E0 Mac App Store \u5B89\u88C5\u7A0B\u5E8F\u7B7E\u540D\u5BC6\u94A5 @@ -42,6 +42,8 @@ error.no-pkg-signing-key.advice=\u4F7F\u7528 XCode \u5C06\u5E94\u7528\u7A0B\u5E8 error.certificate.expired=\u9519\u8BEF: \u8BC1\u4E66\u5DF2\u5931\u6548 {0} error.no.xcode.signing=\u9700\u8981\u4F7F\u7528\u5E26\u547D\u4EE4\u884C\u5F00\u53D1\u4EBA\u5458\u5DE5\u5177\u7684 Xcode \u8FDB\u884C\u7B7E\u540D error.no.xcode.signing.advice=\u5B89\u88C5\u5E26\u547D\u4EE4\u884C\u5F00\u53D1\u4EBA\u5458\u5DE5\u5177\u7684 Xcode\u3002 +error.cert.not.found=No certificate found matching [{0}] using keychain [{1}] +error.multiple.certs.found=Multiple certificates found matching [{0}] using keychain [{1}] resource.bundle-config-file=\u5305\u914D\u7F6E\u6587\u4EF6 resource.app-info-plist=\u5E94\u7528\u7A0B\u5E8F Info.plist From 342edb4c6df5ab2efa2ca859d57a3380e688b139 Mon Sep 17 00:00:00 2001 From: Andy Herrick Date: Mon, 4 May 2020 13:39:46 -0400 Subject: [PATCH 21/88] 8244018: No error message for non-existent icon path Reviewed-by: asemenyuk, almatvee --- .../jpackage/internal/DeployParams.java | 11 +++ .../resources/MainResources.properties | 1 + .../resources/MainResources_ja.properties | 1 + .../resources/MainResources_zh_CN.properties | 1 + .../jdk/jpackage/tests/NonExistentTest.java | 93 +++++++++++++++++++ 5 files changed, 107 insertions(+) create mode 100644 test/jdk/tools/jpackage/share/jdk/jpackage/tests/NonExistentTest.java diff --git a/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/DeployParams.java b/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/DeployParams.java index 9a77b103f81..695177ce4a3 100644 --- a/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/DeployParams.java +++ b/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/DeployParams.java @@ -295,6 +295,17 @@ public class DeployParams { throw new PackagerException("ERR_LicenseFileNotExit"); } } + + // Validate icon file if set + String icon = (String)bundlerArguments.get( + Arguments.CLIOptions.ICON.getId()); + if (icon != null) { + File iconFile = new File(icon); + if (!iconFile.exists()) { + throw new PackagerException("ERR_IconFileNotExit", + iconFile.getAbsolutePath()); + } + } } void setTargetFormat(String t) { diff --git a/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/resources/MainResources.properties b/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/resources/MainResources.properties index 9c24b568f3d..8408308cb50 100644 --- a/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/resources/MainResources.properties +++ b/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/resources/MainResources.properties @@ -90,6 +90,7 @@ ERR_NoUniqueName=Error: --add-launcher = requires a unique name ERR_NoJreInstallerName=Error: Jre Installers require a name parameter ERR_InvalidAppName=Error: Invalid Application name: {0} ERR_InvalidSLName=Error: Invalid Add Launcher name: {0} +ERR_IconFileNotExit=Error: Specified icon file [{0}] does not exist ERR_LicenseFileNotExit=Error: Specified license file does not exist ERR_BuildRootInvalid=Error: temp ({0}) must be non-existant or empty directory ERR_InvalidOption=Error: Invalid Option: [{0}] diff --git a/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/resources/MainResources_ja.properties b/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/resources/MainResources_ja.properties index e6220367e03..ebbca6c2df7 100644 --- a/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/resources/MainResources_ja.properties +++ b/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/resources/MainResources_ja.properties @@ -89,6 +89,7 @@ ERR_NoUniqueName=\u30A8\u30E9\u30FC: --add-launcher =\u306B\u30 ERR_NoJreInstallerName=\u30A8\u30E9\u30FC: Jre\u30A4\u30F3\u30B9\u30C8\u30FC\u30E9\u306B\u306F\u540D\u524D\u30D1\u30E9\u30E1\u30FC\u30BF\u304C\u5FC5\u8981\u3067\u3059 ERR_InvalidAppName=\u30A8\u30E9\u30FC: \u7121\u52B9\u306A\u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\u30F3\u540D: {0} ERR_InvalidSLName=\u30A8\u30E9\u30FC: \u7121\u52B9\u306A\u8FFD\u52A0\u30E9\u30F3\u30C1\u30E3\u540D: {0} +ERR_IconFileNotExit=Error: Specified icon file [{0}] does not exist ERR_LicenseFileNotExit=\u30A8\u30E9\u30FC: \u6307\u5B9A\u3055\u308C\u305F\u30E9\u30A4\u30BB\u30F3\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u306F\u5B58\u5728\u3057\u307E\u305B\u3093 ERR_BuildRootInvalid=\u30A8\u30E9\u30FC: \u4E00\u6642({0})\u306F\u5B58\u5728\u3057\u306A\u3044\u304B\u3001\u7A7A\u306E\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3067\u3042\u308B\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059 ERR_InvalidOption=\u30A8\u30E9\u30FC: \u7121\u52B9\u306A\u30AA\u30D7\u30B7\u30E7\u30F3: [{0}] diff --git a/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/resources/MainResources_zh_CN.properties b/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/resources/MainResources_zh_CN.properties index ee5640eee70..f9a1e44b1b8 100644 --- a/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/resources/MainResources_zh_CN.properties +++ b/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/resources/MainResources_zh_CN.properties @@ -89,6 +89,7 @@ ERR_NoUniqueName=\u9519\u8BEF\uFF1A--add-launcher = \u9700\u898 ERR_NoJreInstallerName=\u9519\u8BEF\uFF1AJre \u5B89\u88C5\u7A0B\u5E8F\u9700\u8981\u4E00\u4E2A\u540D\u79F0\u53C2\u6570 ERR_InvalidAppName=\u9519\u8BEF\uFF1A\u5E94\u7528\u7A0B\u5E8F\u540D\u79F0 {0} \u65E0\u6548 ERR_InvalidSLName=\u9519\u8BEF\uFF1A\u6DFB\u52A0\u542F\u52A8\u7A0B\u5E8F\u540D\u79F0 {0} \u65E0\u6548 +ERR_IconFileNotExit=Error: Specified icon file [{0}] does not exist ERR_LicenseFileNotExit=\u9519\u8BEF\uFF1A\u6307\u5B9A\u7684\u8BB8\u53EF\u8BC1\u6587\u4EF6\u4E0D\u5B58\u5728 ERR_BuildRootInvalid=\u9519\u8BEF\uFF1A\u4E34\u65F6\u76EE\u5F55 ({0}) \u5FC5\u987B\u662F\u4E0D\u5B58\u5728\u7684\u76EE\u5F55\u6216\u7A7A\u767D\u76EE\u5F55 ERR_InvalidOption=\u9519\u8BEF\uFF1A\u9009\u9879 [{0}] \u65E0\u6548 diff --git a/test/jdk/tools/jpackage/share/jdk/jpackage/tests/NonExistentTest.java b/test/jdk/tools/jpackage/share/jdk/jpackage/tests/NonExistentTest.java new file mode 100644 index 00000000000..34844fbf882 --- /dev/null +++ b/test/jdk/tools/jpackage/share/jdk/jpackage/tests/NonExistentTest.java @@ -0,0 +1,93 @@ +/* + * 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 jdk.jpackage.tests; + +import java.util.Collection; +import java.util.List; +import jdk.jpackage.test.Annotations.Parameters; +import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.TKit; + +/* + * @test + * @summary jpackage application version testing + * @library ../../../../helpers + * @build jdk.jpackage.test.* + * @modules jdk.incubator.jpackage/jdk.incubator.jpackage.internal + * @compile NonExistentTest.java + * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=jdk.jpackage.tests.NonExistentTest + */ + +public final class NonExistentTest { + + private final String expectedError; + private final JPackageCommand cmd; + + @Parameters + public static Collection input() { + return List.of(new Object[][]{ + // non-existent icon + {"Hello", + new String[]{"--icon", "non-existent"}, + "Error:"}, + {"com.other/com.other.Hello", + new String[]{"--icon", "non-existent"}, + "Error:"}, + // non-existent input + {"Hello", + new String[]{"--input", "non-existent"}, + "Exception:"}, + {"com.other/com.other.Hello", + new String[]{"--input", "non-existent"}, + "Exception:"}, + // non-existent resource-dir + {"Hello", + new String[]{"--resource-dir", "non-existent"}, + "Specified resource directory"}, + {"com.other/com.other.Hello", + new String[]{"--resource-dir", "non-existent"}, + "Specified resource directory"}, + }); + } + + public NonExistentTest(String javaAppDesc, String[] jpackageArgs, + String expectedError) { + this.expectedError = expectedError; + + cmd = JPackageCommand.helloAppImage(javaAppDesc) + .saveConsoleOutput(true).dumpOutput(true); + if (jpackageArgs != null) { + cmd.addArguments(jpackageArgs); + } + } + + @Test + public void test() { + List output = cmd.execute(1).getOutput(); + TKit.assertNotNull(output, "output is null"); + TKit.assertTextStream(expectedError).apply(output.stream()); + } +} From df182ea6e05619c9d33f3d1a4f9bd7c02041bafc Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Mon, 4 May 2020 11:40:09 -0700 Subject: [PATCH 22/88] 8244133: Refactor nsk/jdi tests to reduce code duplication in settingBreakpoint communication Reviewed-by: cjplummer, sspitsyn --- .../BooleanType/_itself_/booleantype001.java | 134 +----------- .../addInstanceFilter/instancefilter002.java | 141 +------------ .../addInstanceFilter/instancefilter003.java | 141 +------------ .../addThreadFilter/threadfilter002.java | 141 +------------ .../addThreadFilter/threadfilter003.java | 139 +----------- .../location/location001.java | 142 +------------ .../jdi/ByteType/_itself_/bytetype001.java | 142 +------------ .../jdi/CharType/_itself_/chartype001.java | 142 +------------ .../definedClasses/definedclasses001.java | 142 +------------ .../visibleClasses/visibleclasses001.java | 141 +------------ .../addClassExclusionFilter/filter003.java | 133 +----------- .../addClassFilter_rt/filter_rt002.java | 134 +----------- .../addClassFilter_s/filter_s002.java | 132 +----------- .../DoubleType/_itself_/doubletype001.java | 145 +------------ .../nsk/jdi/Event/request/request001.java | 138 +----------- .../EventIterator/nextEvent/nextevent001.java | 141 +------------ .../nsk/jdi/EventQueue/remove/remove004.java | 140 +----------- .../jdi/EventQueue/remove_l/remove_l004.java | 140 +----------- .../addCountFilter/addcountfilter001.java | 149 +------------ .../jdi/EventRequest/disable/disable002.java | 148 +------------ .../jdi/EventRequest/enable/enable001.java | 149 +------------ .../jdi/EventRequest/enable/enable002.java | 150 +------------ .../getProperty/getproperty001.java | 149 +------------ .../EventRequest/isEnabled/isenabled001.java | 150 +------------ .../putProperty/putproperty001.java | 149 +------------ .../setEnabled/setenabled001.java | 149 +------------ .../setEnabled/setenabled002.java | 149 +------------ .../setEnabled/setenabled003.java | 143 +------------ .../setSuspendPolicy/setsuspendpolicy001.java | 149 +------------ .../suspendPolicy/suspendpolicy001.java | 149 +------------ .../accwtchpreq002.java | 144 +------------ .../breakpointRequests/breakpreq002.java | 146 +------------ .../classPrepareRequests/clsprepreq002.java | 132 +----------- .../classUnloadRequests/clsunlreq002.java | 141 +------------ .../craccwtchpreq003.java | 141 +------------ .../crbreakpreq003.java | 145 +------------ .../createClassPrepareRequest/cpreg001.java | 142 +------------ .../createClassUnloadRequest/cureg001.java | 141 +------------ .../createExceptionRequest/crexreq009.java | 141 +------------ .../createExceptionRequest/crexreq010.java | 141 +------------ .../createMethodEntryRequest/menreg001.java | 141 +------------ .../createMethodExitRequest/mexreg001.java | 143 +------------ .../crmodwtchpreq003.java | 142 +------------ .../createStepRequest/crstepreq002.java | 141 +------------ .../createThreadDeathRequest/tdreg001.java | 141 +------------ .../createThreadStartRequest/tsreg001.java | 142 +------------ .../createVMDeathRequest/vmdreg001.java | 141 +------------ .../deleteAllBreakpoints/delallbreakp002.java | 145 +------------ .../deleteEventRequest/delevtreq002.java | 145 +------------ .../deleteEventRequests/delevtreqs002.java | 145 +------------ .../exceptionRequests/excreq002.java | 140 +----------- .../methodEntryRequests/methentreq002.java | 153 +------------- .../methodExitRequests/methexitreq002.java | 132 +----------- .../modwtchpreq002.java | 141 +------------ .../stepRequests/stepreq002.java | 141 +------------ .../threadDeathRequests/thrdeathreq002.java | 141 +------------ .../threadStartRequests/thrstartreq002.java | 141 +------------ .../vmDeathRequests/vmdeathreq001.java | 141 +------------ .../eventIterator/eventiterator001.java | 142 +------------ .../eventIterator/eventiterator002.java | 141 +------------ .../eventIterator/eventiterator003.java | 135 +----------- .../eventIterator/eventiterator004.java | 141 +------------ .../nsk/jdi/EventSet/resume/resume002.java | 141 +------------ .../nsk/jdi/EventSet/resume/resume003.java | 141 +------------ .../nsk/jdi/EventSet/resume/resume004.java | 141 +------------ .../nsk/jdi/EventSet/resume/resume005.java | 141 +------------ .../nsk/jdi/EventSet/resume/resume006.java | 141 +------------ .../nsk/jdi/EventSet/resume/resume007.java | 141 +------------ .../nsk/jdi/EventSet/resume/resume010.java | 141 +------------ .../nsk/jdi/EventSet/resume/resume011.java | 141 +------------ .../nsk/jdi/EventSet/resume/resume012.java | 140 +----------- .../nsk/jdi/EventSet/resume/resume013.java | 141 +------------ .../suspendPolicy/suspendpolicy001.java | 142 +------------ .../suspendPolicy/suspendpolicy002.java | 142 +------------ .../suspendPolicy/suspendpolicy003.java | 140 +----------- .../suspendPolicy/suspendpolicy004.java | 141 +------------ .../suspendPolicy/suspendpolicy005.java | 141 +------------ .../suspendPolicy/suspendpolicy006.java | 141 +------------ .../suspendPolicy/suspendpolicy007.java | 141 +------------ .../suspendPolicy/suspendpolicy008.java | 141 +------------ .../suspendPolicy/suspendpolicy009.java | 141 +------------ .../suspendPolicy/suspendpolicy010.java | 141 +------------ .../suspendPolicy/suspendpolicy011.java | 140 +----------- .../suspendPolicy/suspendpolicy012.java | 142 +------------ .../suspendPolicy/suspendpolicy013.java | 141 +------------ .../suspendPolicy/suspendpolicy014.java | 141 +------------ .../suspendPolicy/suspendpolicy015.java | 141 +------------ .../suspendPolicy/suspendpolicy016.java | 143 +------------ .../suspendPolicy/suspendpolicy017.java | 141 +------------ .../addClassExclusionFilter/filter002.java | 141 +------------ .../addClassFilter_rt/filter_rt002.java | 141 +------------ .../addClassFilter_s/filter_s002.java | 141 +------------ .../addInstanceFilter/instancefilter002.java | 141 +------------ .../addInstanceFilter/instancefilter003.java | 141 +------------ .../addThreadFilter/threadfilter002.java | 141 +------------ .../addThreadFilter/threadfilter003.java | 141 +------------ .../exception/exception001.java | 141 +------------ .../notifyCaught/notifycaught001.java | 141 +------------ .../notifyUncaught/notifyuncaught001.java | 141 +------------ .../jdi/FloatType/_itself_/floattype001.java | 141 +------------ .../IntegerType/_itself_/integertype001.java | 141 +------------ .../jdi/LocatableEvent/thread/thread001.java | 141 +------------ .../jdi/LongType/_itself_/longtype001.java | 141 +------------ .../jdi/Method/isObsolete/isobsolete001.java | 138 +----------- .../jdi/Method/isObsolete/isobsolete002.java | 139 +----------- .../addClassExclusionFilter/filter002.java | 133 +----------- .../addClassFilter_rt/filter_rt002.java | 141 +------------ .../addClassFilter_s/filter_s002.java | 141 +------------ .../addInstanceFilter/instancefilter002.java | 141 +------------ .../addInstanceFilter/instancefilter003.java | 139 +----------- .../addThreadFilter/threadfilter002.java | 141 +------------ .../addThreadFilter/threadfilter003.java | 141 +------------ .../addClassExclusionFilter/filter002.java | 133 +----------- .../addClassFilter_rt/filter_rt002.java | 142 +------------ .../addClassFilter_s/filter_s002.java | 141 +------------ .../addInstanceFilter/instancefilter002.java | 141 +------------ .../addInstanceFilter/instancefilter003.java | 141 +------------ .../addThreadFilter/threadfilter002.java | 141 +------------ .../addThreadFilter/threadfilter003.java | 141 +------------ .../_itself_/mwevent001.java | 140 +----------- .../disablecollection002.java | 142 +------------ .../classPath/classpath001.java | 141 +------------ .../_itself_/primitivetype001.java | 141 +------------ .../classLoader/classloader001.java | 140 +----------- .../ReferenceType/getValue/getvalue001.java | 140 +----------- .../ReferenceType/getValue/getvalue002.java | 139 +----------- .../ReferenceType/getValue/getvalue003.java | 139 +----------- .../ReferenceType/getValues/getvalues001.java | 140 +----------- .../jdi/ReferenceType/isFinal/isfinal001.java | 140 +----------- .../ReferenceType/isStatic/isstatic001.java | 141 +------------ .../ReferenceType/isStatic/isstatic002.java | 141 +------------ .../nestedTypes/nestedtypes001.java | 140 +----------- .../nestedTypes/nestedtypes002.java | 199 +++--------------- .../jdi/ShortType/_itself_/shorttype001.java | 141 +------------ .../addClassExclusionFilter/filter002.java | 151 +------------ .../addClassFilter_rt/filter_rt002.java | 141 +------------ .../addClassFilter_s/filter_s002.java | 141 +------------ .../addInstanceFilter/instancefilter002.java | 141 +------------ .../addInstanceFilter/instancefilter003.java | 141 +------------ .../nsk/jdi/StepRequest/depth/depth001.java | 141 +------------ .../nsk/jdi/StepRequest/depth/depth002.java | 141 +------------ .../nsk/jdi/StepRequest/depth/depth003.java | 141 +------------ .../nsk/jdi/StepRequest/size/size001.java | 141 +------------ .../nsk/jdi/StepRequest/size/size002.java | 141 +------------ .../nsk/jdi/StepRequest/thread/thread001.java | 140 +----------- .../addThreadFilter/addthreadfilter001.java | 141 +------------ .../addThreadFilter/addthreadfilter002.java | 141 +------------ .../addThreadFilter/addthreadfilter003.java | 141 +------------ .../addThreadFilter/addthreadfilter005.java | 141 +------------ .../popFrames/popframes001.java | 138 +----------- .../popFrames/popframes002.java | 139 +----------- .../popFrames/popframes003.java | 154 +------------- .../popFrames/popframes004.java | 139 +----------- .../popFrames/popframes005.java | 138 +----------- .../addThreadFilter/addthreadfilter001.java | 141 +------------ .../addThreadFilter/addthreadfilter003.java | 141 +------------ .../addThreadFilter/addthreadfilter005.java | 143 +------------ .../jdi/VMDeathEvent/_itself_/vmdeath002.java | 147 +------------ .../jdi/VMDeathEvent/_itself_/vmdeath003.java | 141 +------------ .../allClasses/allclasses001.java | 142 +------------ .../canAddMethod/canaddmethod001.java | 142 +------------ .../canPopFrames/canpopframes001.java | 141 +------------ .../canredefineclasses001.java | 140 +----------- .../canreqvmdev001.java | 141 +------------ .../curc001.java | 141 +------------ .../canusefilters001.java | 141 +------------ .../canwatchaccess001.java | 141 +------------ .../canwatchmod001.java | 141 +------------ .../redefineClasses/redefineclasses001.java | 139 +----------- .../jdi/VoidType/_itself_/voidtype001.java | 141 +------------ .../addClassExclusionFilter/filter003.java | 141 +------------ .../addClassExclusionFilter/filter004.java | 141 +------------ .../addClassFilter_rt/filter_rt003.java | 140 +----------- .../addClassFilter_rt/filter_rt004.java | 141 +------------ .../addClassFilter_s/filter_s003.java | 141 +------------ .../addClassFilter_s/filter_s004.java | 141 +------------ .../addInstanceFilter/instancefilter003.java | 141 +------------ .../addInstanceFilter/instancefilter004.java | 141 +------------ .../addInstanceFilter/instancefilter005.java | 141 +------------ .../addInstanceFilter/instancefilter006.java | 141 +------------ .../addThreadFilter/addthreadfilter003.java | 141 +------------ .../addThreadFilter/addthreadfilter004.java | 141 +------------ .../addThreadFilter/addthreadfilter005.java | 141 +------------ .../addThreadFilter/addthreadfilter006.java | 140 +----------- .../jdi/WatchpointRequest/field/field001.java | 141 +------------ .../jdi/WatchpointRequest/field/field002.java | 141 +------------ .../vmTestbase/nsk/share/jdi/JDIBase.java | 167 +++++++++++++++ 187 files changed, 593 insertions(+), 25924 deletions(-) create mode 100644 test/hotspot/jtreg/vmTestbase/nsk/share/jdi/JDIBase.java diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BooleanType/_itself_/booleantype001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BooleanType/_itself_/booleantype001.java index fc595162b34..a2fbc2b89bb 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BooleanType/_itself_/booleantype001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BooleanType/_itself_/booleantype001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -24,14 +24,12 @@ package nsk.jdi.BooleanType._itself_; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; import com.sun.jdi.*; import com.sun.jdi.event.*; import com.sun.jdi.request.*; -import java.util.*; import java.io.*; /** @@ -73,18 +71,7 @@ import java.io.*; *
*/ -public class booleantype001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/BooleanType/_itself_/booleantype001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; +public class booleantype001 extends JDIBase { //----------------------------------------------------- main method @@ -105,19 +92,6 @@ public class booleantype001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } // ************************************************ test parameters @@ -127,20 +101,7 @@ public class booleantype001 { //====================================================== test program //------------------------------------------------------ common section - static Debugee debuggee; - static ArgumentHandler argsHandler; - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; //------------------------------------------------------ methods @@ -340,95 +301,4 @@ public class booleantype001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter002.java index 95f2bd2b4b2..a4b54bd831a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -24,14 +24,12 @@ package nsk.jdi.BreakpointRequest.addInstanceFilter; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; import com.sun.jdi.*; import com.sun.jdi.event.*; import com.sun.jdi.request.*; -import java.util.*; import java.io.*; /** @@ -82,18 +80,7 @@ import java.io.*; *
*/ -public class instancefilter002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; +public class instancefilter002 extends JDIBase { //----------------------------------------------------- main method @@ -114,20 +101,6 @@ public class instancefilter002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -137,25 +110,6 @@ public class instancefilter002 { "nsk.jdi.BreakpointRequest.addInstanceFilter.instancefilter002aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -413,97 +367,6 @@ public class instancefilter002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private BreakpointRequest setting2BreakpointRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter003.java index 8dcabd16b16..0ca023a47b3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -24,14 +24,12 @@ package nsk.jdi.BreakpointRequest.addInstanceFilter; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; import com.sun.jdi.*; import com.sun.jdi.event.*; import com.sun.jdi.request.*; -import java.util.*; import java.io.*; /** @@ -77,18 +75,7 @@ import java.io.*; *
*/ -public class instancefilter003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/BreakpointRequest/addInstanceFilter/instancefilter003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; +public class instancefilter003 extends JDIBase { //----------------------------------------------------- main method @@ -109,20 +96,6 @@ public class instancefilter003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -132,25 +105,6 @@ public class instancefilter003 { "nsk.jdi.BreakpointRequest.addInstanceFilter.instancefilter003aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -380,97 +334,6 @@ public class instancefilter003 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private BreakpointRequest setting2BreakpointRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter002.java index a73e342938c..34de029d726 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -24,14 +24,12 @@ package nsk.jdi.BreakpointRequest.addThreadFilter; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; import com.sun.jdi.*; import com.sun.jdi.event.*; import com.sun.jdi.request.*; -import java.util.*; import java.io.*; /** @@ -83,18 +81,7 @@ import java.io.*; *
*/ -public class threadfilter002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; +public class threadfilter002 extends JDIBase { //----------------------------------------------------- main method @@ -115,20 +102,6 @@ public class threadfilter002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -137,24 +110,6 @@ public class threadfilter002 { private String testedClassName = "nsk.jdi.BreakpointRequest.addThreadFilter.threadfilter002aTestClass"; - //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - //------------------------------------------------------ methods @@ -399,98 +354,6 @@ public class threadfilter002 { return; } - - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private BreakpointRequest setting2BreakpointRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter003.java index 9e73e2e750b..9fabd5cf949 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -24,14 +24,12 @@ package nsk.jdi.BreakpointRequest.addThreadFilter; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; import com.sun.jdi.*; import com.sun.jdi.event.*; import com.sun.jdi.request.*; -import java.util.*; import java.io.*; /** @@ -83,18 +81,7 @@ import java.io.*; *
*/ -public class threadfilter003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/BreakpointRequest/addThreadFilter/threadfilter003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; +public class threadfilter003 extends JDIBase { //----------------------------------------------------- main method @@ -115,19 +102,6 @@ public class threadfilter003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } // ************************************************ test parameters @@ -138,25 +112,6 @@ public class threadfilter003 { "nsk.jdi.BreakpointRequest.addThreadFilter.threadfilter003aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -408,96 +363,6 @@ public class threadfilter003 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } // ============================== test's additional methods diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/location/location001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/location/location001.java index bafe4d58b0c..d3ac2eb9c6a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/location/location001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/BreakpointRequest/location/location001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -79,20 +79,7 @@ import java.io.*; *
*/ -public class location001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/BreakpointRequest/location/location001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class location001 extends JDIBase { public static void main (String argv[]) { @@ -111,20 +98,6 @@ public class location001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -137,25 +110,6 @@ public class location001 { Location location2 = null; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -300,6 +254,7 @@ public class location001 { ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); BreakpointRequest bpRequest = settingBreakpoint(mainThread, + debuggeeClass, bPointMethod, lineForComm, "zero"); bpRequest.enable(); @@ -371,97 +326,6 @@ public class location001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private BreakpointRequest setting2BreakpointRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ByteType/_itself_/bytetype001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ByteType/_itself_/bytetype001.java index 168b381cec8..8be846c734e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ByteType/_itself_/bytetype001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ByteType/_itself_/bytetype001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -24,14 +24,12 @@ package nsk.jdi.ByteType._itself_; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; import com.sun.jdi.*; import com.sun.jdi.event.*; import com.sun.jdi.request.*; -import java.util.*; import java.io.*; /** @@ -73,18 +71,7 @@ import java.io.*; *
*/ -public class bytetype001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ByteType/_itself_/bytetype001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; +public class bytetype001 extends JDIBase { //----------------------------------------------------- main method @@ -105,45 +92,12 @@ public class bytetype001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.ByteType._itself_.bytetype001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -342,96 +296,4 @@ public class bytetype001 { return; } - - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/CharType/_itself_/chartype001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/CharType/_itself_/chartype001.java index 67304d1cb84..ad07d11b5bb 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/CharType/_itself_/chartype001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/CharType/_itself_/chartype001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -24,14 +24,12 @@ package nsk.jdi.CharType._itself_; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; import com.sun.jdi.*; import com.sun.jdi.event.*; import com.sun.jdi.request.*; -import java.util.*; import java.io.*; /** @@ -73,18 +71,7 @@ import java.io.*; *
*/ -public class chartype001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/CharType/_itself_/chartype001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; +public class chartype001 extends JDIBase { //----------------------------------------------------- main method @@ -105,45 +92,12 @@ public class chartype001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.CharType._itself_.chartype001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -342,96 +296,4 @@ public class chartype001 { return; } - - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassLoaderReference/definedClasses/definedclasses001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassLoaderReference/definedClasses/definedclasses001.java index 522e623195d..ce0d4a10e29 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassLoaderReference/definedClasses/definedclasses001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassLoaderReference/definedClasses/definedclasses001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -24,7 +24,6 @@ package nsk.jdi.ClassLoaderReference.definedClasses; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; import com.sun.jdi.*; @@ -77,20 +76,7 @@ import java.io.*; *
*/ -public class definedclasses001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ClassLoaderReference/definedClasses/definedclasses001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class definedclasses001 extends JDIBase { public static void main (String argv[]) { @@ -109,45 +95,12 @@ public class definedclasses001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.ClassLoaderReference.definedClasses.definedclasses001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -338,95 +291,4 @@ public class definedclasses001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassLoaderReference/visibleClasses/visibleclasses001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassLoaderReference/visibleClasses/visibleclasses001.java index f26063aad46..bfcc7121611 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassLoaderReference/visibleClasses/visibleclasses001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassLoaderReference/visibleClasses/visibleclasses001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -24,7 +24,6 @@ package nsk.jdi.ClassLoaderReference.visibleClasses; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; import com.sun.jdi.*; @@ -87,20 +86,7 @@ import java.io.*; *
*/ -public class visibleclasses001 { - - //----------------------------------------------------- template section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- template parameters - static final String - sHeader1 = "\n==> nsk/jdi/ClassLoaderReference/visibleClasses/visibleclasses001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class visibleclasses001 extends JDIBase { public static void main (String argv[]) { @@ -119,49 +105,17 @@ public class visibleclasses001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.ClassLoaderReference.visibleClasses.visibleclasses001a"; //====================================================== test program - //------------------------------------------------------ common section - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; static List primitiveArraysNamesPatterns = Arrays.asList(new String[] { "^boolean(\\[\\])+", "^byte(\\[\\])+", "^char(\\[\\])+", "^int(\\[\\])+", "^short(\\[\\])+", "^long(\\[\\])+", "^float(\\[\\])+", "^double(\\[\\])+"}); - - //------------------------------------------------------ methods - private int runThis (String argv[], PrintStream out) { argsHandler = new ArgumentHandler(argv); @@ -384,95 +338,4 @@ public class visibleclasses001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter003.java index 7fee118f977..e747d251434 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -24,14 +24,12 @@ package nsk.jdi.ClassPrepareRequest.addClassExclusionFilter; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; import com.sun.jdi.*; import com.sun.jdi.event.*; import com.sun.jdi.request.*; -import java.util.*; import java.io.*; /** @@ -78,20 +76,7 @@ import java.io.*; *
*/ -public class filter003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ClassPrepareRequest/addClassExclusionFilter/filter003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class filter003 extends JDIBase { public static void main (String argv[]) { @@ -110,20 +95,6 @@ public class filter003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -133,25 +104,6 @@ public class filter003 { "nsk.jdi.ClassPrepareRequest.addClassExclusionFilter.TestClass10"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -382,87 +334,8 @@ public class filter003 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) + protected void breakpointForCommunication() throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { log2("breakpointForCommunication"); do { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt002.java index 26bd7702c59..0b8d0866e29 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -24,14 +24,12 @@ package nsk.jdi.ClassPrepareRequest.addClassFilter_rt; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; import com.sun.jdi.*; import com.sun.jdi.event.*; import com.sun.jdi.request.*; -import java.util.*; import java.io.*; /** @@ -82,20 +80,7 @@ import java.io.*; *
*/ -public class filter_rt002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ClassPrepareRequest/addClassFilter_rt/filter_rt002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class filter_rt002 extends JDIBase { public static void main (String argv[]) { @@ -114,20 +99,6 @@ public class filter_rt002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -137,25 +108,6 @@ public class filter_rt002 { "nsk.jdi.ClassPrepareRequest.addClassFilter_rt.filter_rt002aTestClass10"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -297,7 +249,6 @@ public class filter_rt002 { String bPointMethod = "methodForCommunication"; String lineForComm = "lineForComm"; - ThreadReference mainThread = debuggee.threadByNameOrThrow("main"); BreakpointRequest bpRequest = settingBreakpoint(mainThread, @@ -389,87 +340,8 @@ public class filter_rt002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) + protected void breakpointForCommunication() throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { log2("breakpointForCommunication"); do { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s002.java index 99ef62c4ebf..c0461a73e96 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -82,20 +82,7 @@ import java.io.*; *
*/ -public class filter_s002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ClassPrepareRequest/addClassFilter_s/filter_s002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class filter_s002 extends JDIBase { public static void main (String argv[]) { @@ -114,20 +101,6 @@ public class filter_s002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -137,25 +110,6 @@ public class filter_s002 { "nsk.jdi.ClassPrepareRequest.addClassFilter_s.TestClass10"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -385,88 +339,8 @@ public class filter_s002 { log1(" TESTING ENDS"); return; } - - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) + protected void breakpointForCommunication() throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { log2("breakpointForCommunication"); do { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/DoubleType/_itself_/doubletype001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/DoubleType/_itself_/doubletype001.java index 228dfc55253..328656766b5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/DoubleType/_itself_/doubletype001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/DoubleType/_itself_/doubletype001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -73,20 +73,7 @@ import java.io.*; *
*/ -public class doubletype001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/DoubleType/_itself_/doubletype001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class doubletype001 extends JDIBase { public static void main (String argv[]) { @@ -105,45 +92,12 @@ public class doubletype001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.DoubleType._itself_.doubletype001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -342,99 +296,4 @@ public class doubletype001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - - // ============================== test's additional methods - - - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/request/request001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/request/request001.java index e0fd2c82b7b..7138445da4b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/request/request001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/Event/request/request001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -95,20 +95,7 @@ import java.io.*; *
*/ -public class request001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/Event/request/request001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class request001 extends JDIBase { public static void main (String argv[]) { @@ -127,20 +114,6 @@ public class request001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -150,24 +123,6 @@ public class request001 { "nsk.jdi.Event.request.TestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - // Event #: // 0-6 : AccessWatchpoint, ModificationWatchpoint, Breakpoint, Exception, @@ -626,95 +581,6 @@ public class request001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private AccessWatchpointRequest settingAccessWatchpoint ( diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventIterator/nextEvent/nextevent001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventIterator/nextEvent/nextevent001.java index b5b11c1da34..64f98ba53bf 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventIterator/nextEvent/nextevent001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventIterator/nextEvent/nextevent001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -95,20 +95,7 @@ import java.io.*; *
*/ -public class nextevent001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventIterator/nextEvent/nextevent001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class nextevent001 extends JDIBase { public static void main (String argv[]) { @@ -127,20 +114,6 @@ public class nextevent001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -150,23 +123,6 @@ public class nextevent001 { "nsk.jdi.EventIterator.nextEvent.TestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - // Event #: // 0-6 : AccessWatchpoint, ModificationWatchpoint, Breakpoint, Exception, @@ -180,8 +136,6 @@ public class nextevent001 { int eventFlags[] = { 0,0,0,0, 0,0,0,0, 3,0,0,0, 1,1 }; - //------------------------------------------------------ methods - private int runThis (String argv[], PrintStream out) { argsHandler = new ArgumentHandler(argv); @@ -614,97 +568,6 @@ public class nextevent001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private AccessWatchpointRequest settingAccessWatchpoint ( diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove/remove004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove/remove004.java index 283268e7b19..fc32b09c7aa 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove/remove004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove/remove004.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -74,20 +74,7 @@ import java.io.*; * a breakpoint event after the debuggee finishes sleeping.
*/ -public class remove004 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventQueue/remove/remove004 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class remove004 extends JDIBase { public static void main (String argv[]) { @@ -106,47 +93,15 @@ public class remove004 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventQueue.remove.remove004a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static long waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; static Value trueValue; - static int testExitCode = PASSED; - - //------------------------------------------------------ methods - private int runThis (String argv[], PrintStream out) { argsHandler = new ArgumentHandler(argv); @@ -374,97 +329,6 @@ public class remove004 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l004.java index 187a22a5795..85b6259d9dd 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventQueue/remove_l/remove_l004.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -69,20 +69,7 @@ import java.io.*; * After WAITTIME, the debugger just expects to get normal breakpoint event.
*/ -public class remove_l004 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventQueue/remove_l/remove_l004 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class remove_l004 extends JDIBase { public static void main (String argv[]) { @@ -101,47 +88,15 @@ public class remove_l004 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventQueue.remove_l.remove_l004a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static long waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; static Value trueValue; - static int testExitCode = PASSED; - - //------------------------------------------------------ methods - private int runThis (String argv[], PrintStream out) { argsHandler = new ArgumentHandler(argv); @@ -348,95 +303,4 @@ public class remove_l004 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/addCountFilter/addcountfilter001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/addCountFilter/addcountfilter001.java index b328996820c..b7ca96dcaa9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/addCountFilter/addcountfilter001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/addCountFilter/addcountfilter001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -78,20 +78,7 @@ import java.io.*; *
*/ -public class addcountfilter001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequest/addCountFilter/addcountfilter001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class addcountfilter001 extends JDIBase { public static void main (String argv[]) { @@ -110,20 +97,6 @@ public class addcountfilter001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -132,28 +105,8 @@ public class addcountfilter001 { private String testedClassName = "nsk.jdi.EventRequest.addCountFilter.TestClass11"; - Location location = null; // !!!!!!!!!!!!! see settingBreakpoint - //====================================================== test program - //------------------------------------------------------ common section - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -163,6 +116,7 @@ public class addcountfilter001 { waitTime = argsHandler.getWaitTime() * 60000; + try { log2("launching a debuggee :"); log2(" " + debuggeeName); @@ -409,7 +363,7 @@ public class addcountfilter001 { case 11: log2(".....setting up BreakpointRequest"); - eventRequest1 = eventRManager.createBreakpointRequest(location); + eventRequest1 = eventRManager.createBreakpointRequest(breakpLocation); break; @@ -472,99 +426,4 @@ public class addcountfilter001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - -// this is only for this test to get Location object -location = lineLocation; - - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_ALL); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/disable/disable002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/disable/disable002.java index 5c2e62a328e..6de71120957 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/disable/disable002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/disable/disable002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -76,20 +76,7 @@ import java.io.*; *
*/ -public class disable002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequest/disable/disable002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class disable002 extends JDIBase { public static void main (String argv[]) { @@ -108,20 +95,6 @@ public class disable002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -130,28 +103,7 @@ public class disable002 { private String testedClassName = "nsk.jdi.EventRequest.disable.disable002aTestClass11"; - Location location = null; // !!!!!!!!!!!!! see settingBreakpoint - //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -403,7 +355,7 @@ public class disable002 { case 11: log2(".....setting up BreakpointRequest"); - eventRequest1 = eventRManager.createBreakpointRequest(location); + eventRequest1 = eventRManager.createBreakpointRequest(breakpLocation); break; @@ -428,99 +380,5 @@ public class disable002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - -// this is only for this test to get Location object -location = lineLocation; - - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_ALL); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable001.java index 737de0eed1a..c374cfd31dd 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -76,20 +76,7 @@ import java.io.*; *
*/ -public class enable001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequest/enable/enable001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class enable001 extends JDIBase { public static void main (String argv[]) { @@ -108,20 +95,6 @@ public class enable001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -130,28 +103,7 @@ public class enable001 { private String testedClassName = "nsk.jdi.EventRequest.enable.enable001aTestClass11"; - Location location = null; // !!!!!!!!!!!!! see settingBreakpoint - //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -403,7 +355,7 @@ public class enable001 { case 11: log2(".....setting up BreakpointRequest"); - eventRequest1 = eventRManager.createBreakpointRequest(location); + eventRequest1 = eventRManager.createBreakpointRequest(breakpLocation); break; @@ -426,99 +378,4 @@ public class enable001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - -// this is only for this test to get Location object -location = lineLocation; - - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_ALL); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable002.java index 9f71e51f117..5d216a654ef 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/enable/enable002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -24,14 +24,12 @@ package nsk.jdi.EventRequest.enable; import nsk.share.*; -import nsk.share.jpda.*; import nsk.share.jdi.*; import com.sun.jdi.*; import com.sun.jdi.event.*; import com.sun.jdi.request.*; -import java.util.*; import java.io.*; /** @@ -79,20 +77,7 @@ import java.io.*; *
*/ -public class enable002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequest/enable/enable002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class enable002 extends JDIBase { public static void main (String argv[]) { @@ -111,20 +96,6 @@ public class enable002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -133,28 +104,8 @@ public class enable002 { private String testedClassName = "nsk.jdi.EventRequest.enable.enable002aTestClass11"; - Location location = null; // !!!!!!!!!!!!! see settingBreakpoint //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -408,7 +359,7 @@ public class enable002 { case 11: log2(".....setting up BreakpointRequest"); - eventRequest1 = eventRManager.createBreakpointRequest(location); + eventRequest1 = eventRManager.createBreakpointRequest(breakpLocation); break; @@ -444,99 +395,4 @@ public class enable002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - -// this is only for this test to get Location object -location = lineLocation; - - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_ALL); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/getProperty/getproperty001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/getProperty/getproperty001.java index 175aecc7a1b..8c2467af249 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/getProperty/getproperty001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/getProperty/getproperty001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -78,20 +78,7 @@ import java.io.*; *
*/ -public class getproperty001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequest/getProperty/getproperty001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class getproperty001 extends JDIBase { public static void main (String argv[]) { @@ -110,20 +97,6 @@ public class getproperty001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -132,28 +105,7 @@ public class getproperty001 { private String testedClassName = "nsk.jdi.EventRequest.getProperty.TestClass11"; - Location location = null; // !!!!!!!!!!!!! see settingBreakpoint - //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -409,7 +361,7 @@ public class getproperty001 { case 11: log2(".....setting up BreakpointRequest"); - eventRequest1 = eventRManager.createBreakpointRequest(location); + eventRequest1 = eventRManager.createBreakpointRequest(breakpLocation); break; @@ -440,99 +392,4 @@ public class getproperty001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - -// this is only for this test to get Location object -location = lineLocation; - - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_ALL); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/isEnabled/isenabled001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/isEnabled/isenabled001.java index 9947e4e2f4b..17283512c9a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/isEnabled/isenabled001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/isEnabled/isenabled001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -76,20 +76,7 @@ import java.io.*; *
*/ -public class isenabled001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequest/isEnabled/isenabled001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class isenabled001 extends JDIBase { public static void main (String argv[]) { @@ -108,20 +95,6 @@ public class isenabled001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -130,28 +103,7 @@ public class isenabled001 { private String testedClassName = "nsk.jdi.EventRequest.isEnabled.TestClass11"; - Location location = null; // !!!!!!!!!!!!! see settingBreakpoint - //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -161,6 +113,7 @@ public class isenabled001 { waitTime = argsHandler.getWaitTime() * 60000; + try { log2("launching a debuggee :"); log2(" " + debuggeeName); @@ -403,7 +356,7 @@ public class isenabled001 { case 11: log2(".....setting up BreakpointRequest"); - eventRequest1 = eventRManager.createBreakpointRequest(location); + eventRequest1 = eventRManager.createBreakpointRequest(breakpLocation); break; @@ -434,99 +387,4 @@ public class isenabled001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - -// this is only for this test to get Location object -location = lineLocation; - - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_ALL); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/putProperty/putproperty001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/putProperty/putproperty001.java index 50b69647478..3c29d9216a8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/putProperty/putproperty001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/putProperty/putproperty001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -78,20 +78,7 @@ import java.io.*; *
*/ -public class putproperty001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequest/putProperty/putproperty001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class putproperty001 extends JDIBase { public static void main (String argv[]) { @@ -110,20 +97,6 @@ public class putproperty001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -132,28 +105,7 @@ public class putproperty001 { private String testedClassName = "nsk.jdi.EventRequest.putProperty.TestClass11"; - Location location = null; // !!!!!!!!!!!!! see settingBreakpoint - //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -409,7 +361,7 @@ public class putproperty001 { case 11: log2(".....setting up BreakpointRequest"); - eventRequest1 = eventRManager.createBreakpointRequest(location); + eventRequest1 = eventRManager.createBreakpointRequest(breakpLocation); break; @@ -445,99 +397,4 @@ public class putproperty001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - -// this is only for this test to get Location object -location = lineLocation; - - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_ALL); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled001.java index f98935aa1bd..ac1c2fc133b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -75,20 +75,7 @@ import java.io.*; *
*/ -public class setenabled001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequest/setEnabled/setenabled001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class setenabled001 extends JDIBase { public static void main (String argv[]) { @@ -107,20 +94,6 @@ public class setenabled001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -129,28 +102,7 @@ public class setenabled001 { private String testedClassName = "nsk.jdi.EventRequest.setEnabled.setenabled001aTestClass11"; - Location location = null; // !!!!!!!!!!!!! see settingBreakpoint - //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -402,7 +354,7 @@ public class setenabled001 { case 11: log2(".....setting up BreakpointRequest"); - eventRequest1 = eventRManager.createBreakpointRequest(location); + eventRequest1 = eventRManager.createBreakpointRequest(breakpLocation); break; @@ -433,99 +385,4 @@ public class setenabled001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - -// this is only for this test to get Location object -location = lineLocation; - - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_ALL); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled002.java index dd9e57d8838..b598b0d23c6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -79,20 +79,7 @@ import java.io.*; *
*/ -public class setenabled002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequest/setEnabled/setenabled002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class setenabled002 extends JDIBase { public static void main (String argv[]) { @@ -111,20 +98,6 @@ public class setenabled002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -133,28 +106,7 @@ public class setenabled002 { private String testedClassName = "nsk.jdi.EventRequest.setEnabled.setenabled002aTestClass11"; - Location location = null; // !!!!!!!!!!!!! see settingBreakpoint - //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -408,7 +360,7 @@ public class setenabled002 { case 11: log2(".....setting up BreakpointRequest"); - eventRequest1 = eventRManager.createBreakpointRequest(location); + eventRequest1 = eventRManager.createBreakpointRequest(breakpLocation); break; @@ -460,99 +412,4 @@ public class setenabled002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - -// this is only for this test to get Location object -location = lineLocation; - - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled003.java index 802f90a39ba..6817dad7ff4 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setEnabled/setenabled003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -78,20 +78,7 @@ import java.io.*; *
*/ -public class setenabled003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequest/setEnabled/setenabled003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class setenabled003 extends JDIBase { public static void main (String argv[]) { @@ -110,20 +97,6 @@ public class setenabled003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -133,25 +106,6 @@ public class setenabled003 { "nsk.jdi.EventRequest.setEnabled.Thread1setenabled003a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -412,97 +366,4 @@ public class setenabled003 { return; } - - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setSuspendPolicy/setsuspendpolicy001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setSuspendPolicy/setsuspendpolicy001.java index ef7c823339c..5da99f0ddcb 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setSuspendPolicy/setsuspendpolicy001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/setSuspendPolicy/setsuspendpolicy001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -80,20 +80,7 @@ import java.io.*; *
*/ -public class setsuspendpolicy001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequest/setSuspendPolicy/setsuspendpolicy001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class setsuspendpolicy001 extends JDIBase { public static void main (String argv[]) { @@ -112,20 +99,6 @@ public class setsuspendpolicy001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -134,28 +107,7 @@ public class setsuspendpolicy001 { private String testedClassName = "nsk.jdi.EventRequest.setSuspendPolicy.TestClass11"; - Location location = null; // !!!!!!!!!!!!! see settingBreakpoint - //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -411,7 +363,7 @@ public class setsuspendpolicy001 { case 11: log2(".....setting up BreakpointRequest"); - eventRequest1 = eventRManager.createBreakpointRequest(location); + eventRequest1 = eventRManager.createBreakpointRequest(breakpLocation); break; @@ -476,99 +428,4 @@ public class setsuspendpolicy001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - -// this is only for this test to get Location object -location = lineLocation; - - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_ALL); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/suspendPolicy/suspendpolicy001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/suspendPolicy/suspendpolicy001.java index 49d5e4a29c6..9c5cff3963c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/suspendPolicy/suspendpolicy001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequest/suspendPolicy/suspendpolicy001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -75,20 +75,7 @@ import java.io.*; *
*/ -public class suspendpolicy001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequest/suspendPolicy/suspendpolicy001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class suspendpolicy001 extends JDIBase { public static void main (String argv[]) { @@ -107,20 +94,6 @@ public class suspendpolicy001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -129,28 +102,8 @@ public class suspendpolicy001 { private String testedClassName = "nsk.jdi.EventRequest.suspendPolicy.TestClass11"; - Location location = null; // !!!!!!!!!!!!! see settingBreakpoint //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -406,7 +359,7 @@ public class suspendpolicy001 { case 11: log2(".....setting up BreakpointRequest"); - eventRequest1 = eventRManager.createBreakpointRequest(location); + eventRequest1 = eventRManager.createBreakpointRequest(breakpLocation); break; @@ -449,100 +402,4 @@ public class suspendpolicy001 { return; } - - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - -// this is only for this test to get Location object -location = lineLocation; - - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_ALL); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/accessWatchpointRequests/accwtchpreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/accessWatchpointRequests/accwtchpreq002.java index b47ba8671f2..63c671fe789 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/accessWatchpointRequests/accwtchpreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/accessWatchpointRequests/accwtchpreq002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -76,20 +76,7 @@ import java.io.*; *
*/ -public class accwtchpreq002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/accessWatchpointRequests/accwtchpreq002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class accwtchpreq002 extends JDIBase { public static void main (String argv[]) { @@ -108,45 +95,10 @@ public class accwtchpreq002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - - // ************************************************ test parameters - private String debuggeeName = "nsk.jdi.EventRequestManager.accessWatchpointRequests.accwtchpreq002a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -425,96 +377,4 @@ public class accwtchpreq002 { return; } - - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/breakpointRequests/breakpreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/breakpointRequests/breakpreq002.java index 03408b0b249..1e9660c8964 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/breakpointRequests/breakpreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/breakpointRequests/breakpreq002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -76,20 +76,7 @@ import java.io.*; *
*/ -public class breakpreq002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/breakpointRequests/breakpreq002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class breakpreq002 extends JDIBase { public static void main (String argv[]) { @@ -108,48 +95,12 @@ public class breakpreq002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.breakpointRequests.breakpreq002a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - Location breakpLocation = null; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -158,7 +109,6 @@ public class breakpreq002 { Binder binder = new Binder(argsHandler, logHandler); waitTime = argsHandler.getWaitTime() * 60000; - try { log2("launching a debuggee :"); log2(" " + debuggeeName); @@ -418,96 +368,4 @@ public class breakpreq002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); -breakpLocation = lineLocation; - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/classPrepareRequests/clsprepreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/classPrepareRequests/clsprepreq002.java index 489a4224563..df26bc95d2c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/classPrepareRequests/clsprepreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/classPrepareRequests/clsprepreq002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -76,20 +76,7 @@ import java.io.*; *
*/ -public class clsprepreq002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/classPrepareRequests/clsprepreq002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class clsprepreq002 extends JDIBase { public static void main (String argv[]) { @@ -108,45 +95,12 @@ public class clsprepreq002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.classPrepareRequests.clsprepreq002a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -418,87 +372,8 @@ public class clsprepreq002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) + protected void breakpointForCommunication() throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { log2("breakpointForCommunication"); do { @@ -520,4 +395,5 @@ public class clsprepreq002 { throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); } + } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/classUnloadRequests/clsunlreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/classUnloadRequests/clsunlreq002.java index 2ac173491fb..f2a5d602cef 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/classUnloadRequests/clsunlreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/classUnloadRequests/clsunlreq002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -76,20 +76,7 @@ import java.io.*; *
*/ -public class clsunlreq002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/classUnloadRequests/clsunlreq002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class clsunlreq002 extends JDIBase { public static void main (String argv[]) { @@ -108,45 +95,12 @@ public class clsunlreq002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.classUnloadRequests.clsunlreq002a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -413,95 +367,4 @@ public class clsunlreq002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createAccessWatchpointRequest/craccwtchpreq003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createAccessWatchpointRequest/craccwtchpreq003.java index cca726ae16a..17369a06471 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createAccessWatchpointRequest/craccwtchpreq003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createAccessWatchpointRequest/craccwtchpreq003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -79,20 +79,7 @@ import java.io.*; *
*/ -public class craccwtchpreq003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/createAccessWatchpointRequest/craccwtchpreq003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class craccwtchpreq003 extends JDIBase { public static void main (String argv[]) { @@ -111,45 +98,12 @@ public class craccwtchpreq003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.createAccessWatchpointRequest.craccwtchpreq003a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -375,95 +329,4 @@ public class craccwtchpreq003 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createBreakpointRequest/crbreakpreq003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createBreakpointRequest/crbreakpreq003.java index 89b741a8233..42ebb25299d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createBreakpointRequest/crbreakpreq003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createBreakpointRequest/crbreakpreq003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -76,20 +76,7 @@ import java.io.*; *
*/ -public class crbreakpreq003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/createBreakpointRequest/crbreakpreq003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class crbreakpreq003 extends JDIBase { public static void main (String argv[]) { @@ -108,48 +95,12 @@ public class crbreakpreq003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.createBreakpointRequest.crbreakpreq003a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - Location breakpLocation = null; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -356,96 +307,4 @@ public class crbreakpreq003 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); -breakpLocation = lineLocation; - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createClassPrepareRequest/cpreg001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createClassPrepareRequest/cpreg001.java index 36637f92ba2..07a88d62c03 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createClassPrepareRequest/cpreg001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createClassPrepareRequest/cpreg001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -74,20 +74,7 @@ import java.io.*; *
*/ -public class cpreg001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/createClassPrepareRequest/cpreg001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class cpreg001 extends JDIBase { public static void main (String argv[]) { @@ -106,45 +93,12 @@ public class cpreg001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.createClassPrepareRequest.cpreg001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -154,6 +108,7 @@ public class cpreg001 { waitTime = argsHandler.getWaitTime() * 60000; + try { log2("launching a debuggee :"); log2(" " + debuggeeName); @@ -331,95 +286,4 @@ public class cpreg001 { return; } - - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createClassUnloadRequest/cureg001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createClassUnloadRequest/cureg001.java index 4d2afde5363..d808931ce0e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createClassUnloadRequest/cureg001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createClassUnloadRequest/cureg001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -74,20 +74,7 @@ import java.io.*; *
*/ -public class cureg001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/createClassUnloadRequest/cureg001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class cureg001 extends JDIBase { public static void main (String argv[]) { @@ -106,45 +93,12 @@ public class cureg001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.createClassUnloadRequest.cureg001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -331,95 +285,4 @@ public class cureg001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createExceptionRequest/crexreq009.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createExceptionRequest/crexreq009.java index 86bf02f9e4f..f4c58210200 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createExceptionRequest/crexreq009.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createExceptionRequest/crexreq009.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -77,20 +77,7 @@ import java.io.*; *
*/ -public class crexreq009 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/createExceptionRequest/crexreq009 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class crexreq009 extends JDIBase { public static void main (String argv[]) { @@ -109,45 +96,12 @@ public class crexreq009 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.createExceptionRequest.crexreq009a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -355,95 +309,4 @@ public class crexreq009 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createExceptionRequest/crexreq010.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createExceptionRequest/crexreq010.java index 9499f1da59a..f6f9e0b710b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createExceptionRequest/crexreq010.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createExceptionRequest/crexreq010.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -78,20 +78,7 @@ import java.io.*; *
*/ -public class crexreq010 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/createExceptionRequest/crexreq010 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class crexreq010 extends JDIBase { public static void main (String argv[]) { @@ -110,45 +97,12 @@ public class crexreq010 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.createExceptionRequest.crexreq010a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -346,95 +300,4 @@ public class crexreq010 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createMethodEntryRequest/menreg001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createMethodEntryRequest/menreg001.java index b35521575dd..7a9ee65e6fe 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createMethodEntryRequest/menreg001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createMethodEntryRequest/menreg001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -74,20 +74,7 @@ import java.io.*; *
*/ -public class menreg001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/createMethodEntryRequest/menreg001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class menreg001 extends JDIBase { public static void main (String argv[]) { @@ -106,45 +93,12 @@ public class menreg001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.createMethodEntryRequest.menreg001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -331,95 +285,4 @@ public class menreg001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createMethodExitRequest/mexreg001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createMethodExitRequest/mexreg001.java index 6888a5a83be..3035fc9aadd 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createMethodExitRequest/mexreg001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createMethodExitRequest/mexreg001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -74,20 +74,7 @@ import java.io.*; *
*/ -public class mexreg001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/createMethodExitRequest/mexreg001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class mexreg001 extends JDIBase { public static void main (String argv[]) { @@ -106,45 +93,12 @@ public class mexreg001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.createMethodExitRequest.mexreg001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -153,7 +107,6 @@ public class mexreg001 { Binder binder = new Binder(argsHandler, logHandler); waitTime = argsHandler.getWaitTime() * 60000; - try { log2("launching a debuggee :"); log2(" " + debuggeeName); @@ -331,96 +284,4 @@ public class mexreg001 { return; } - - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createModificationWatchpointRequest/crmodwtchpreq003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createModificationWatchpointRequest/crmodwtchpreq003.java index 96c7cd6df9e..3e2f9a479bf 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createModificationWatchpointRequest/crmodwtchpreq003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createModificationWatchpointRequest/crmodwtchpreq003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -78,20 +78,7 @@ import java.io.*; *
*/ -public class crmodwtchpreq003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/createModificationWatchpointRequest/crmodwtchpreq003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class crmodwtchpreq003 extends JDIBase { public static void main (String argv[]) { @@ -110,45 +97,12 @@ public class crmodwtchpreq003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.createModificationWatchpointRequest.crmodwtchpreq003a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -374,96 +328,4 @@ public class crmodwtchpreq003 { return; } - - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq002.java index e3a25488fd2..dfa75241c92 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createStepRequest/crstepreq002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -78,20 +78,7 @@ import java.io.*; *
*/ -public class crstepreq002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/createStepRequest/crstepreq002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class crstepreq002 extends JDIBase { public static void main (String argv[]) { @@ -110,45 +97,12 @@ public class crstepreq002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.createStepRequest.crstepreq002a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -442,95 +396,4 @@ public class crstepreq002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createThreadDeathRequest/tdreg001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createThreadDeathRequest/tdreg001.java index 2acb1847858..6b14e960242 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createThreadDeathRequest/tdreg001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createThreadDeathRequest/tdreg001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -74,20 +74,7 @@ import java.io.*; *
*/ -public class tdreg001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/createThreadDeathRequest/tdreg001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class tdreg001 extends JDIBase { public static void main (String argv[]) { @@ -106,45 +93,12 @@ public class tdreg001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.createThreadDeathRequest.tdreg001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -331,95 +285,4 @@ public class tdreg001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createThreadStartRequest/tsreg001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createThreadStartRequest/tsreg001.java index 4da1bd4e926..3bb3b75b595 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createThreadStartRequest/tsreg001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createThreadStartRequest/tsreg001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -74,20 +74,7 @@ import java.io.*; *
*/ -public class tsreg001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/createThreadStartRequest/tsreg001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class tsreg001 extends JDIBase { public static void main (String argv[]) { @@ -106,45 +93,12 @@ public class tsreg001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.createThreadStartRequest.tsreg001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -153,7 +107,6 @@ public class tsreg001 { Binder binder = new Binder(argsHandler, logHandler); waitTime = argsHandler.getWaitTime() * 60000; - try { log2("launching a debuggee :"); log2(" " + debuggeeName); @@ -331,95 +284,4 @@ public class tsreg001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createVMDeathRequest/vmdreg001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createVMDeathRequest/vmdreg001.java index cf0b159dfcd..5c1b71388ea 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createVMDeathRequest/vmdreg001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/createVMDeathRequest/vmdreg001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -76,20 +76,7 @@ import java.io.*; *
*/ -public class vmdreg001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/createVMDeathRequest/vmdreg001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class vmdreg001 extends JDIBase { public static void main (String argv[]) { @@ -108,45 +95,12 @@ public class vmdreg001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.createVMDeathRequest.vmdreg001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -343,95 +297,4 @@ public class vmdreg001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteAllBreakpoints/delallbreakp002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteAllBreakpoints/delallbreakp002.java index b381b0079c3..968e88adbd6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteAllBreakpoints/delallbreakp002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteAllBreakpoints/delallbreakp002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -75,20 +75,7 @@ import java.io.*; *
*/ -public class delallbreakp002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/deleteAllBreakpoints/delallbreakp002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class delallbreakp002 extends JDIBase { public static void main (String argv[]) { @@ -107,48 +94,12 @@ public class delallbreakp002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.deleteAllBreakpoints.delallbreakp002a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - Location breakpLocation = null; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -342,96 +293,4 @@ public class delallbreakp002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); -breakpLocation = lineLocation; - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteEventRequest/delevtreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteEventRequest/delevtreq002.java index 1ed1c56a2e0..30aae28e622 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteEventRequest/delevtreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteEventRequest/delevtreq002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -81,20 +81,7 @@ import java.io.*; *
*/ -public class delevtreq002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/deleteEventRequest/delevtreq002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class delevtreq002 extends JDIBase { public static void main (String argv[]) { @@ -113,48 +100,12 @@ public class delevtreq002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.deleteEventRequest.delevtreq002a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - Location breakpLocation = null; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -427,96 +378,4 @@ public class delevtreq002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); -breakpLocation = lineLocation; - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteEventRequests/delevtreqs002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteEventRequests/delevtreqs002.java index 746e80c7710..bc63f49ce8e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteEventRequests/delevtreqs002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/deleteEventRequests/delevtreqs002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -79,20 +79,7 @@ import java.io.*; *
*/ -public class delevtreqs002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/deleteEventRequests/delevtreqs002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class delevtreqs002 extends JDIBase { public static void main (String argv[]) { @@ -111,48 +98,12 @@ public class delevtreqs002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.deleteEventRequests.delevtreqs002a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - Location breakpLocation = null; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -496,96 +447,4 @@ public class delevtreqs002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); -breakpLocation = lineLocation; - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/exceptionRequests/excreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/exceptionRequests/excreq002.java index 7c999c53ef0..9b4172106b9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/exceptionRequests/excreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/exceptionRequests/excreq002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -76,20 +76,7 @@ import java.io.*; *
*/ -public class excreq002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/exceptionRequests/excreq002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class excreq002 extends JDIBase { public static void main (String argv[]) { @@ -108,45 +95,13 @@ public class excreq002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.exceptionRequests.excreq002a"; //====================================================== test program - //------------------------------------------------------ common section - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -418,95 +373,4 @@ public class excreq002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/methodEntryRequests/methentreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/methodEntryRequests/methentreq002.java index 1ba95aceb8f..691ce87e0d3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/methodEntryRequests/methentreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/methodEntryRequests/methentreq002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -76,20 +76,7 @@ import java.io.*; *
*/ -public class methentreq002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/methodEntryRequests/methentreq002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class methentreq002 extends JDIBase { public static void main (String argv[]) { @@ -108,45 +95,12 @@ public class methentreq002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.methodEntryRequests.methentreq002a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -413,107 +367,4 @@ public class methentreq002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - log2("breakpointForCommunication"); - - do { - getEventSet(); - - Event event = eventIterator.nextEvent(); - if (event instanceof BreakpointEvent) - return; - - log2(" received: " + event); - - if (EventFilters.filtered(event, debuggeeName)) { - eventSet.resume(); - } - else { - break; - } - } while (true); - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/methodExitRequests/methexitreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/methodExitRequests/methexitreq002.java index 62d7e8a97e7..616b058b7d5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/methodExitRequests/methexitreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/methodExitRequests/methexitreq002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -76,20 +76,7 @@ import java.io.*; *
*/ -public class methexitreq002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/methodExitRequests/methexitreq002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class methexitreq002 extends JDIBase { public static void main (String argv[]) { @@ -107,46 +94,12 @@ public class methexitreq002 { } return testExitCode; } - - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.methodExitRequests.methexitreq002a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -413,86 +366,7 @@ public class methexitreq002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() + protected void breakpointForCommunication() throws JDITestRuntimeException { log2("breakpointForCommunication"); diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/modificationWatchpointRequests/modwtchpreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/modificationWatchpointRequests/modwtchpreq002.java index 952288b029b..a88563a92b5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/modificationWatchpointRequests/modwtchpreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/modificationWatchpointRequests/modwtchpreq002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -76,20 +76,7 @@ import java.io.*; *
*/ -public class modwtchpreq002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/modificationWatchpointRequests/modwtchpreq002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class modwtchpreq002 extends JDIBase { public static void main (String argv[]) { @@ -108,45 +95,12 @@ public class modwtchpreq002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.modificationWatchpointRequests.modwtchpreq002a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -425,95 +379,4 @@ public class modwtchpreq002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/stepRequests/stepreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/stepRequests/stepreq002.java index 2b57e4ab49e..2905cb0236f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/stepRequests/stepreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/stepRequests/stepreq002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -76,20 +76,7 @@ import java.io.*; *
*/ -public class stepreq002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/stepRequests/stepreq002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class stepreq002 extends JDIBase { public static void main (String argv[]) { @@ -108,45 +95,12 @@ public class stepreq002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.stepRequests.stepreq002a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -420,95 +374,4 @@ public class stepreq002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/threadDeathRequests/thrdeathreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/threadDeathRequests/thrdeathreq002.java index 6f577993329..ac3ab653fa9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/threadDeathRequests/thrdeathreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/threadDeathRequests/thrdeathreq002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -76,20 +76,7 @@ import java.io.*; *
*/ -public class thrdeathreq002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/threadDeathRequests/thrdeathreq002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class thrdeathreq002 extends JDIBase { public static void main (String argv[]) { @@ -108,45 +95,12 @@ public class thrdeathreq002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.threadDeathRequests.thrdeathreq002a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -413,95 +367,4 @@ public class thrdeathreq002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/threadStartRequests/thrstartreq002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/threadStartRequests/thrstartreq002.java index 017c18292d4..c830df6a369 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/threadStartRequests/thrstartreq002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/threadStartRequests/thrstartreq002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -76,20 +76,7 @@ import java.io.*; *
*/ -public class thrstartreq002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/threadStartRequests/thrstartreq002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class thrstartreq002 extends JDIBase { public static void main (String argv[]) { @@ -108,45 +95,12 @@ public class thrstartreq002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.threadStartRequests.thrstartreq002a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -413,95 +367,4 @@ public class thrstartreq002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/vmDeathRequests/vmdeathreq001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/vmDeathRequests/vmdeathreq001.java index b5be0dd7236..af502883a9d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/vmDeathRequests/vmdeathreq001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventRequestManager/vmDeathRequests/vmdeathreq001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -76,20 +76,7 @@ import java.io.*; *
*/ -public class vmdeathreq001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventRequestManager/vmDeathRequests/vmdeathreq001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class vmdeathreq001 extends JDIBase { public static void main (String argv[]) { @@ -108,45 +95,12 @@ public class vmdeathreq001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventRequestManager.vmDeathRequests.vmdeathreq001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -413,95 +367,4 @@ public class vmdeathreq001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator001.java index 089f2212e94..d1f715df880 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -71,20 +71,7 @@ import java.io.*; *
*/ -public class eventiterator001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/eventIterator/eventiterator001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class eventiterator001 extends JDIBase { public static void main (String argv[]) { @@ -103,20 +90,6 @@ public class eventiterator001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -126,26 +99,6 @@ public class eventiterator001 { "nsk.jdi.EventSet.eventIterator.eventiterator001aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -361,97 +314,6 @@ public class eventiterator001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ClassPrepareRequest settingClassPrepareRequest ( String testedClass, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator002.java index ca5dd54ba15..a4be961309b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -77,20 +77,7 @@ import java.io.*; *
*/ -public class eventiterator002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/eventIterator/eventiterator002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class eventiterator002 extends JDIBase { public static void main (String argv[]) { @@ -109,20 +96,6 @@ public class eventiterator002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -132,25 +105,6 @@ public class eventiterator002 { "nsk.jdi.EventSet.eventIterator.eventiterator002aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -425,97 +379,6 @@ public class eventiterator002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private AccessWatchpointRequest settingAccessWatchpointRequest ( diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator003.java index 862b631773b..3dc70e632f9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -74,20 +74,7 @@ import java.io.*; *
*/ -public class eventiterator003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - - static final int FAILED = 2; - - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String sHeader1 = "\n==> nsk/jdi/EventSet/eventIterator/eventiterator003 ", - sHeader2 = "--> debugger: ", sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class eventiterator003 extends JDIBase { public static void main(String argv[]) { @@ -106,22 +93,6 @@ public class eventiterator003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventSet.eventIterator.eventiterator003a"; @@ -129,29 +100,6 @@ public class eventiterator003 { private String testedClassName = "nsk.jdi.EventSet.eventIterator.TestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - - static EventRequestManager eventRManager = null; - - static EventQueue eventQueue = null; - - static EventSet eventSet = null; - - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - //------------------------------------------------------ methods private int runThis(String argv[], PrintStream out) { @@ -386,85 +334,6 @@ public class eventiterator003 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint(ThreadReference thread, ReferenceType testedClass, String methodName, - String bpLine, String property) throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = ((IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine))).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD); - } catch (Exception e1) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch (Exception e2) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - private void getEventSet() throws JDITestRuntimeException { - try { - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } - eventIterator = eventSet.eventIterator(); - } catch (Exception e) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - private void breakpointForCommunication() throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ThreadStartRequest settingThreadStartRequest(ThreadReference thread, int suspendPolicy, String property) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator004.java index b9119773aa1..5e060095cce 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/eventIterator/eventiterator004.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -65,20 +65,7 @@ import java.io.*; *
*/ -public class eventiterator004 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/eventIterator/eventiterator004 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class eventiterator004 extends JDIBase { public static void main (String argv[]) { @@ -97,20 +84,6 @@ public class eventiterator004 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -120,23 +93,6 @@ public class eventiterator004 { "nsk.jdi.EventSet.eventIterator.TestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - // Event #: // 0-6 : AccessWatchpoint, ModificationWatchpoint, Breakpoint, Exception, @@ -150,8 +106,6 @@ public class eventiterator004 { int eventFlags[] = { 0,0,0,0, 0,0,0,0, 3,0,0,0, 1,1 }; - //------------------------------------------------------ methods - private int runThis (String argv[], PrintStream out) { argsHandler = new ArgumentHandler(argv); @@ -357,97 +311,6 @@ public class eventiterator004 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private void check() { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002.java index dea420743c4..e3417621fd8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -85,20 +85,7 @@ import java.io.*; *
*/ -public class resume002 { - - //----------------------------------------------------- template section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- template parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class resume002 extends JDIBase { public static void main (String argv[]) { @@ -117,20 +104,6 @@ public class resume002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -140,25 +113,6 @@ public class resume002 { "nsk.jdi.EventSet.resume.resume002aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -504,97 +458,6 @@ public class resume002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private AccessWatchpointRequest settingAccessWatchpointRequest ( diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume003.java index 422e2465f05..176a87b490b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -85,20 +85,7 @@ import java.io.*; *
*/ -public class resume003 { - - //----------------------------------------------------- template section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- template parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class resume003 extends JDIBase { public static void main (String argv[]) { @@ -117,20 +104,6 @@ public class resume003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -140,25 +113,6 @@ public class resume003 { "nsk.jdi.EventSet.resume.resume003aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -505,97 +459,6 @@ public class resume003 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ModificationWatchpointRequest settingModificationWatchpointRequest ( diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004.java index 394573d207e..a37a4b222cf 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume004.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -85,20 +85,7 @@ import java.io.*; *
*/ -public class resume004 { - - //----------------------------------------------------- template section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- template parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume004 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class resume004 extends JDIBase { public static void main (String argv[]) { @@ -117,20 +104,6 @@ public class resume004 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -140,25 +113,6 @@ public class resume004 { "nsk.jdi.EventSet.resume.resume004aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -498,97 +452,6 @@ public class resume004 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private BreakpointRequest settingBreakpointRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005.java index b57abbf7d2c..84f96cf3345 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume005.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -85,20 +85,7 @@ import java.io.*; *
*/ -public class resume005 { - - //----------------------------------------------------- template section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- template parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume005 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class resume005 extends JDIBase { public static void main (String argv[]) { @@ -117,20 +104,6 @@ public class resume005 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -140,25 +113,6 @@ public class resume005 { "nsk.jdi.EventSet.resume.resume005aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -498,97 +452,6 @@ public class resume005 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ExceptionRequest settingExceptionRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006.java index 6e7f282453c..53e35df25eb 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume006.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -85,20 +85,7 @@ import java.io.*; *
*/ -public class resume006 { - - //----------------------------------------------------- template section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- template parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume006 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class resume006 extends JDIBase { public static void main (String argv[]) { @@ -117,20 +104,6 @@ public class resume006 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -140,25 +113,6 @@ public class resume006 { "nsk.jdi.EventSet.resume.resume006aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -496,97 +450,6 @@ public class resume006 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private MethodEntryRequest settingMethodEntryRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume007.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume007.java index ce4ebbcb7fa..05d07e7933a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume007.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume007.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -85,20 +85,7 @@ import java.io.*; *
*/ -public class resume007 { - - //----------------------------------------------------- template section - static final int PASSED = Consts.TEST_PASSED; - static final int FAILED = Consts.TEST_FAILED; - static final int PASS_BASE = Consts.JCK_STATUS_BASE; - - //----------------------------------------------------- template parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume007 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class resume007 extends JDIBase { public static void main (String argv[]) { @@ -117,20 +104,6 @@ public class resume007 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -140,25 +113,6 @@ public class resume007 { "nsk.jdi.EventSet.resume.resume007aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -495,97 +449,6 @@ public class resume007 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private MethodExitRequest settingMethodExitRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010.java index 973bc52ac61..707704f21d2 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume010.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -85,20 +85,7 @@ import java.io.*; *
*/ -public class resume010 { - - //----------------------------------------------------- template section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- template parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume010 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class resume010 extends JDIBase { public static void main (String argv[]) { @@ -117,20 +104,6 @@ public class resume010 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -140,25 +113,6 @@ public class resume010 { "nsk.jdi.EventSet.resume.resume010aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -493,97 +447,6 @@ public class resume010 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private StepRequest settingStepRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume011.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume011.java index 12bf8340405..0aa593f038e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume011.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume011.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -69,20 +69,7 @@ import java.io.*; *
*/ -public class resume011 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume011 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class resume011 extends JDIBase { public static void main (String argv[]) { @@ -101,20 +88,6 @@ public class resume011 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -124,25 +97,6 @@ public class resume011 { "nsk.jdi.EventSet.resume.TestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -338,97 +292,6 @@ public class resume011 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private VMDeathRequest settingVMDeathRequest( int suspendPolicy, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume012.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume012.java index fcb52349bc2..2f84e7fe6bc 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume012.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume012.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -70,20 +70,7 @@ import java.io.*; *
*/ -public class resume012 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume012 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class resume012 extends JDIBase { public static void main (String argv[]) { @@ -102,20 +89,6 @@ public class resume012 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -125,25 +98,6 @@ public class resume012 { "nsk.jdi.EventSet.resume.TestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -339,96 +293,6 @@ public class resume012 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } // ============================== test's additional methods diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume013.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume013.java index c1a9f385004..0cd4f25e919 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume013.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/resume/resume013.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -70,20 +70,7 @@ import java.io.*; *
*/ -public class resume013 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/resume/resume013 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class resume013 extends JDIBase { public static void main (String argv[]) { @@ -102,20 +89,6 @@ public class resume013 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -125,25 +98,6 @@ public class resume013 { "nsk.jdi.EventSet.resume.TestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -338,97 +292,6 @@ public class resume013 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private VMDeathRequest settingVMDeathRequest( int suspendPolicy, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy001.java index fe02854a102..9de1fcfecf4 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -83,20 +83,7 @@ import java.io.*; *
*/ -public class suspendpolicy001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/suspendPolicy/suspendpolicy001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class suspendpolicy001 extends JDIBase { public static void main (String argv[]) { @@ -115,46 +102,12 @@ public class suspendpolicy001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.EventSet.suspendPolicy.suspendpolicy001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods - private int runThis (String argv[], PrintStream out) { argsHandler = new ArgumentHandler(argv); @@ -486,97 +439,6 @@ public class suspendpolicy001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ClassPrepareRequest settingClassPrepareRequest ( String testedClass, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy002.java index 2f3f9df0a5a..fa550ccbf96 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -81,20 +81,7 @@ import java.io.*; *
*/ -public class suspendpolicy002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/suspendPolicy/suspendpolicy002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class suspendpolicy002 extends JDIBase { public static void main (String argv[]) { @@ -112,21 +99,6 @@ public class suspendpolicy002 { } return testExitCode; } - - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -136,25 +108,6 @@ public class suspendpolicy002 { "nsk.jdi.EventSet.suspendPolicy.suspendpolicy002aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -481,97 +434,6 @@ public class suspendpolicy002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private AccessWatchpointRequest settingAccessWatchpointRequest ( diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy003.java index a75cf23b44a..c990fce716f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -81,20 +81,7 @@ import java.io.*; *
*/ -public class suspendpolicy003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/suspendPolicy/suspendpolicy003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class suspendpolicy003 extends JDIBase { public static void main (String argv[]) { @@ -113,20 +100,6 @@ public class suspendpolicy003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -136,25 +109,6 @@ public class suspendpolicy003 { "nsk.jdi.EventSet.suspendPolicy.suspendpolicy003aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -488,96 +442,6 @@ public class suspendpolicy003 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } // ============================== test's additional methods diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy004.java index e91c8551ea3..763befc2b29 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy004.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -81,20 +81,7 @@ import java.io.*; *
*/ -public class suspendpolicy004 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/suspendPolicy/suspendpolicy004 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class suspendpolicy004 extends JDIBase { public static void main (String argv[]) { @@ -113,20 +100,6 @@ public class suspendpolicy004 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -136,25 +109,6 @@ public class suspendpolicy004 { "nsk.jdi.EventSet.suspendPolicy.suspendpolicy004aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -483,97 +437,6 @@ public class suspendpolicy004 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private BreakpointRequest settingBreakpointRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy005.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy005.java index 8331bb93bf6..896e48ad488 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy005.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy005.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -81,20 +81,7 @@ import java.io.*; *
*/ -public class suspendpolicy005 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/suspendPolicy/suspendpolicy005 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class suspendpolicy005 extends JDIBase { public static void main (String argv[]) { @@ -113,20 +100,6 @@ public class suspendpolicy005 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -136,25 +109,6 @@ public class suspendpolicy005 { "nsk.jdi.EventSet.suspendPolicy.suspendpolicy005aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -483,97 +437,6 @@ public class suspendpolicy005 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ExceptionRequest settingExceptionRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy006.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy006.java index d4d483de7c1..e1006ed04a5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy006.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy006.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -80,20 +80,7 @@ import java.io.*; *
*/ -public class suspendpolicy006 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/suspendPolicy/suspendpolicy006 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class suspendpolicy006 extends JDIBase { public static void main (String argv[]) { @@ -112,20 +99,6 @@ public class suspendpolicy006 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -135,25 +108,6 @@ public class suspendpolicy006 { "nsk.jdi.EventSet.suspendPolicy.suspendpolicy006aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -481,97 +435,6 @@ public class suspendpolicy006 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private MethodEntryRequest settingMethodEntryRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy007.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy007.java index 66b345dec97..12c3a10e208 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy007.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy007.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -80,20 +80,7 @@ import java.io.*; *
*/ -public class suspendpolicy007 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/suspendPolicy/suspendpolicy007 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class suspendpolicy007 extends JDIBase { public static void main (String argv[]) { @@ -112,20 +99,6 @@ public class suspendpolicy007 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -135,25 +108,6 @@ public class suspendpolicy007 { "nsk.jdi.EventSet.suspendPolicy.suspendpolicy007aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -480,97 +434,6 @@ public class suspendpolicy007 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private MethodExitRequest settingMethodExitRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy008.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy008.java index 8fa8e8b6985..7690717a2ca 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy008.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy008.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -80,20 +80,7 @@ import java.io.*; *
*/ -public class suspendpolicy008 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/suspendPolicy/suspendpolicy008 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class suspendpolicy008 extends JDIBase { public static void main (String argv[]) { @@ -112,20 +99,6 @@ public class suspendpolicy008 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -135,25 +108,6 @@ public class suspendpolicy008 { "nsk.jdi.EventSet.suspendPolicy.TestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -457,97 +411,6 @@ public class suspendpolicy008 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ThreadStartRequest settingThreadStartRequest(int suspendPolicy, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy009.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy009.java index 1b2c058213b..86a8e1faa5e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy009.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy009.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -80,20 +80,7 @@ import java.io.*; *
*/ -public class suspendpolicy009 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/suspendPolicy/suspendpolicy009 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class suspendpolicy009 extends JDIBase { public static void main (String argv[]) { @@ -112,20 +99,6 @@ public class suspendpolicy009 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -135,25 +108,6 @@ public class suspendpolicy009 { "nsk.jdi.EventSet.suspendPolicy.TestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -457,97 +411,6 @@ public class suspendpolicy009 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ThreadDeathRequest settingThreadDeathRequest(int suspendPolicy, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy010.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy010.java index 321653ff4e5..682c5062492 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy010.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy010.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -79,20 +79,7 @@ import java.io.*; *
*/ -public class suspendpolicy010 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/suspendPolicy/suspendpolicy010 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class suspendpolicy010 extends JDIBase { public static void main (String argv[]) { @@ -111,20 +98,6 @@ public class suspendpolicy010 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -134,25 +107,6 @@ public class suspendpolicy010 { "nsk.jdi.EventSet.suspendPolicy.suspendpolicy010aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -412,97 +366,6 @@ public class suspendpolicy010 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private StepRequest settingStepRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy011.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy011.java index 34d59838441..772169efb21 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy011.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy011.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -78,20 +78,7 @@ import java.io.*; *
*/ -public class suspendpolicy011 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/suspendPolicy/suspendpolicy011 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class suspendpolicy011 extends JDIBase { public static void main (String argv[]) { @@ -110,20 +97,6 @@ public class suspendpolicy011 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -133,28 +106,9 @@ public class suspendpolicy011 { "nsk.jdi.EventSet.suspendPolicy.TestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - int policyToCheck = 0; - //------------------------------------------------------ methods - private int runThis (String argv[], PrintStream out) { argsHandler = new ArgumentHandler(argv); @@ -359,96 +313,6 @@ public class suspendpolicy011 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } // ============================== test's additional methods diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy012.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy012.java index f79f84a0dcb..554faa833a9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy012.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy012.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -78,20 +78,7 @@ import java.io.*; *
*/ -public class suspendpolicy012 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/suspendPolicy/suspendpolicy012 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class suspendpolicy012 extends JDIBase { public static void main (String argv[]) { @@ -110,20 +97,6 @@ public class suspendpolicy012 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -133,28 +106,9 @@ public class suspendpolicy012 { "nsk.jdi.EventSet.suspendPolicy.TestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - int policyToCheck = 0; - //------------------------------------------------------ methods - private int runThis (String argv[], PrintStream out) { argsHandler = new ArgumentHandler(argv); @@ -162,7 +116,6 @@ public class suspendpolicy012 { Binder binder = new Binder(argsHandler, logHandler); waitTime = argsHandler.getWaitTime() * 60000; - try { log2("launching a debuggee :"); log2(" " + debuggeeName); @@ -359,97 +312,6 @@ public class suspendpolicy012 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private VMDeathRequest settingVMDeathRequest( int suspendPolicy, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy013.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy013.java index cf13951176c..147cc80db82 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy013.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy013.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -78,20 +78,7 @@ import java.io.*; *
*/ -public class suspendpolicy013 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/suspendPolicy/suspendpolicy013 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class suspendpolicy013 extends JDIBase { public static void main (String argv[]) { @@ -110,20 +97,6 @@ public class suspendpolicy013 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -133,28 +106,9 @@ public class suspendpolicy013 { "nsk.jdi.EventSet.suspendPolicy.TestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - int policyToCheck = 0; - //------------------------------------------------------ methods - private int runThis (String argv[], PrintStream out) { argsHandler = new ArgumentHandler(argv); @@ -359,97 +313,6 @@ public class suspendpolicy013 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private VMDeathRequest settingVMDeathRequest( int suspendPolicy, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy014.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy014.java index e36917567fe..e2b94fb620e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy014.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy014.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -79,20 +79,7 @@ import java.io.*; *
*/ -public class suspendpolicy014 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/suspendPolicy/suspendpolicy014 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class suspendpolicy014 extends JDIBase { public static void main (String argv[]) { @@ -111,20 +98,6 @@ public class suspendpolicy014 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -134,28 +107,9 @@ public class suspendpolicy014 { "nsk.jdi.EventSet.suspendPolicy.TestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - int policyToCheck = 0; - //------------------------------------------------------ methods - private int runThis (String argv[], PrintStream out) { argsHandler = new ArgumentHandler(argv); @@ -362,97 +316,6 @@ public class suspendpolicy014 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private VMDeathRequest settingVMDeathRequest( int suspendPolicy, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy015.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy015.java index 778c01aa644..071e339d7f9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy015.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy015.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -79,20 +79,7 @@ import java.io.*; *
*/ -public class suspendpolicy015 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/suspendPolicy/suspendpolicy015 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class suspendpolicy015 extends JDIBase { public static void main (String argv[]) { @@ -111,20 +98,6 @@ public class suspendpolicy015 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -134,28 +107,9 @@ public class suspendpolicy015 { "nsk.jdi.EventSet.suspendPolicy.TestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - int policyToCheck = 0; - //------------------------------------------------------ methods - private int runThis (String argv[], PrintStream out) { argsHandler = new ArgumentHandler(argv); @@ -362,97 +316,6 @@ public class suspendpolicy015 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private VMDeathRequest settingVMDeathRequest( int suspendPolicy, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy016.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy016.java index 6de316fc1e5..9fc708b9c53 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy016.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy016.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -79,20 +79,7 @@ import java.io.*; *
*/ -public class suspendpolicy016 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/suspendPolicy/suspendpolicy016 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class suspendpolicy016 extends JDIBase { public static void main (String argv[]) { @@ -111,22 +98,6 @@ public class suspendpolicy016 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - - // ************************************************ test parameters - private String debuggeeName = "nsk.jdi.EventSet.suspendPolicy.suspendpolicy016a"; @@ -134,28 +105,9 @@ public class suspendpolicy016 { "nsk.jdi.EventSet.suspendPolicy.TestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - int policyToCheck = 0; - //------------------------------------------------------ methods - private int runThis (String argv[], PrintStream out) { argsHandler = new ArgumentHandler(argv); @@ -363,97 +315,6 @@ public class suspendpolicy016 { } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private VMDeathRequest settingVMDeathRequest( int suspendPolicy, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy017.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy017.java index 211527fea66..94ba9b6e5a4 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy017.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/EventSet/suspendPolicy/suspendpolicy017.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -79,20 +79,7 @@ import java.io.*; *
*/ -public class suspendpolicy017 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/EventSet/suspendPolicy/suspendpolicy017 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class suspendpolicy017 extends JDIBase { public static void main (String argv[]) { @@ -111,20 +98,6 @@ public class suspendpolicy017 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -134,28 +107,9 @@ public class suspendpolicy017 { "nsk.jdi.EventSet.suspendPolicy.TestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - int policyToCheck = 0; - //------------------------------------------------------ methods - private int runThis (String argv[], PrintStream out) { argsHandler = new ArgumentHandler(argv); @@ -364,97 +318,6 @@ public class suspendpolicy017 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private VMDeathRequest settingVMDeathRequest( int suspendPolicy, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addClassExclusionFilter/filter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addClassExclusionFilter/filter002.java index 73671ae9afa..dbb738b9066 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addClassExclusionFilter/filter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addClassExclusionFilter/filter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -81,20 +81,7 @@ import java.io.*; *
*/ -public class filter002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ExceptionRequest/addClassExclusionFilter/filter002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class filter002 extends JDIBase { public static void main (String argv[]) { @@ -113,20 +100,6 @@ public class filter002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -136,25 +109,6 @@ public class filter002 { "nsk.jdi.ExceptionRequest.addClassExclusionFilter.TestClass10"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -386,97 +340,6 @@ public class filter002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ExceptionRequest setting23ExceptionRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addClassFilter_rt/filter_rt002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addClassFilter_rt/filter_rt002.java index 9c8b6742293..981d57ca002 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addClassFilter_rt/filter_rt002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addClassFilter_rt/filter_rt002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -82,20 +82,7 @@ import java.io.*; *
*/ -public class filter_rt002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ExceptionRequest/addClassFilter_rt/filter_rt002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class filter_rt002 extends JDIBase { public static void main (String argv[]) { @@ -114,20 +101,6 @@ public class filter_rt002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -137,25 +110,6 @@ public class filter_rt002 { "nsk.jdi.ExceptionRequest.addClassFilter_rt.filter_rt002aTestClass10"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -388,97 +342,6 @@ public class filter_rt002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ExceptionRequest setting21ExceptionRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addClassFilter_s/filter_s002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addClassFilter_s/filter_s002.java index 1e0fd47ed46..e4c53f8014d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addClassFilter_s/filter_s002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addClassFilter_s/filter_s002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -82,20 +82,7 @@ import java.io.*; *
*/ -public class filter_s002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ExceptionRequest/addClassFilter_s/filter_s002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class filter_s002 extends JDIBase { public static void main (String argv[]) { @@ -114,20 +101,6 @@ public class filter_s002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -137,25 +110,6 @@ public class filter_s002 { "nsk.jdi.ExceptionRequest.addClassFilter_s.filter_s002aTestClass10"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -387,97 +341,6 @@ public class filter_s002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ExceptionRequest setting22ExceptionRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addInstanceFilter/instancefilter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addInstanceFilter/instancefilter002.java index d9f5f86c1a8..5ae15dad45b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addInstanceFilter/instancefilter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addInstanceFilter/instancefilter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -82,20 +82,7 @@ import java.io.*; *
*/ -public class instancefilter002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ExceptionRequest/addInstanceFilter/instancefilter002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class instancefilter002 extends JDIBase { public static void main (String argv[]) { @@ -114,20 +101,6 @@ public class instancefilter002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -137,25 +110,6 @@ public class instancefilter002 { "nsk.jdi.ExceptionRequest.addInstanceFilter.instancefilter002aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -409,97 +363,6 @@ public class instancefilter002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ExceptionRequest setting2ExceptionRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addInstanceFilter/instancefilter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addInstanceFilter/instancefilter003.java index 15b80dea916..a7d7bbe29f7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addInstanceFilter/instancefilter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addInstanceFilter/instancefilter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -77,20 +77,7 @@ import java.io.*; *
*/ -public class instancefilter003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ExceptionRequest/addInstanceFilter/instancefilter003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class instancefilter003 extends JDIBase { public static void main (String argv[]) { @@ -109,20 +96,6 @@ public class instancefilter003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -132,25 +105,6 @@ public class instancefilter003 { "nsk.jdi.ExceptionRequest.addInstanceFilter.instancefilter003aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -376,97 +330,6 @@ public class instancefilter003 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ExceptionRequest setting2ExceptionRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addThreadFilter/threadfilter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addThreadFilter/threadfilter002.java index 383cb2a9a67..ece923ee2ad 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addThreadFilter/threadfilter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addThreadFilter/threadfilter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -84,20 +84,7 @@ import java.io.*; *
*/ -public class threadfilter002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ExceptionRequest/addThreadFilter/threadfilter002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class threadfilter002 extends JDIBase { public static void main (String argv[]) { @@ -116,20 +103,6 @@ public class threadfilter002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -139,25 +112,6 @@ public class threadfilter002 { "nsk.jdi.ExceptionRequest.addThreadFilter.threadfilter002aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -396,97 +350,6 @@ public class threadfilter002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ExceptionRequest setting2ExceptionRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addThreadFilter/threadfilter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addThreadFilter/threadfilter003.java index e661f7b292b..80d8ecd457e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addThreadFilter/threadfilter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/addThreadFilter/threadfilter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -84,20 +84,7 @@ import java.io.*; *
*/ -public class threadfilter003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ExceptionRequest/addThreadFilter/threadfilter003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class threadfilter003 extends JDIBase { public static void main (String argv[]) { @@ -116,20 +103,6 @@ public class threadfilter003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -139,25 +112,6 @@ public class threadfilter003 { "nsk.jdi.ExceptionRequest.addThreadFilter.threadfilter003aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -401,97 +355,6 @@ public class threadfilter003 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ExceptionRequest setting2ExceptionRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/exception/exception001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/exception/exception001.java index bed4712c333..c9091734db5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/exception/exception001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/exception/exception001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -79,20 +79,7 @@ import java.io.*; *
*/ -public class exception001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ExceptionRequest/exception/exception001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class exception001 extends JDIBase { public static void main (String argv[]) { @@ -111,45 +98,12 @@ public class exception001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.ExceptionRequest.exception.exception001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -376,97 +330,6 @@ public class exception001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ExceptionRequest setting25ExceptionRequest ( ReferenceType refType ) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/notifyCaught/notifycaught001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/notifyCaught/notifycaught001.java index c8d5b0b7e2c..ea2615dfc06 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/notifyCaught/notifycaught001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/notifyCaught/notifycaught001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -77,20 +77,7 @@ import java.io.*; *
*/ -public class notifycaught001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ExceptionRequest/notifyCaught/notifycaught001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class notifycaught001 extends JDIBase { public static void main (String argv[]) { @@ -109,45 +96,12 @@ public class notifycaught001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.ExceptionRequest.notifyCaught.notifycaught001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -365,97 +319,6 @@ public class notifycaught001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ExceptionRequest setting24ExceptionRequest ( boolean notifyCaught, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/notifyUncaught/notifyuncaught001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/notifyUncaught/notifyuncaught001.java index 3e6cf1a1feb..d4aacc05bc5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/notifyUncaught/notifyuncaught001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ExceptionRequest/notifyUncaught/notifyuncaught001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -77,20 +77,7 @@ import java.io.*; *
*/ -public class notifyuncaught001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ExceptionRequest/notifyUncaught/notifyuncaught001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class notifyuncaught001 extends JDIBase { public static void main (String argv[]) { @@ -109,45 +96,12 @@ public class notifyuncaught001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.ExceptionRequest.notifyUncaught.notifyuncaught001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -365,97 +319,6 @@ public class notifyuncaught001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ExceptionRequest setting24ExceptionRequest ( boolean notifyCaught, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/FloatType/_itself_/floattype001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/FloatType/_itself_/floattype001.java index ca1cfbbe939..8e0bb5716ac 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/FloatType/_itself_/floattype001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/FloatType/_itself_/floattype001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -73,20 +73,7 @@ import java.io.*; *
*/ -public class floattype001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/FloatType/_itself_/floattype001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class floattype001 extends JDIBase { public static void main (String argv[]) { @@ -105,45 +92,12 @@ public class floattype001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.FloatType._itself_.floattype001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -342,95 +296,4 @@ public class floattype001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/IntegerType/_itself_/integertype001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/IntegerType/_itself_/integertype001.java index c2ab6e0fd91..f49e1da055a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/IntegerType/_itself_/integertype001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/IntegerType/_itself_/integertype001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -73,20 +73,7 @@ import java.io.*; *
*/ -public class integertype001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/IntegerType/_itself_/integertype001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class integertype001 extends JDIBase { public static void main (String argv[]) { @@ -105,45 +92,12 @@ public class integertype001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.IntegerType._itself_.integertype001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -342,95 +296,4 @@ public class integertype001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/LocatableEvent/thread/thread001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/LocatableEvent/thread/thread001.java index b3b3cd0cc61..20af06ee462 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/LocatableEvent/thread/thread001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/LocatableEvent/thread/thread001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -85,20 +85,7 @@ import java.io.*; *
*/ -public class thread001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/LocatableEvent/thread/thread001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class thread001 extends JDIBase { public static void main (String argv[]) { @@ -117,20 +104,6 @@ public class thread001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -140,25 +113,6 @@ public class thread001 { "nsk.jdi.LocatableEvent.thread.TestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -536,97 +490,6 @@ public class thread001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private AccessWatchpointRequest settingAccessWatchpoint ( diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/LongType/_itself_/longtype001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/LongType/_itself_/longtype001.java index d45dc04c964..9854f1eedbd 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/LongType/_itself_/longtype001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/LongType/_itself_/longtype001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -73,20 +73,7 @@ import java.io.*; *
*/ -public class longtype001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/LongType/_itself_/longtype001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class longtype001 extends JDIBase { public static void main (String argv[]) { @@ -105,45 +92,12 @@ public class longtype001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.LongType._itself_.longtype001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -342,95 +296,4 @@ public class longtype001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/Method/isObsolete/isobsolete001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/Method/isObsolete/isobsolete001.java index 70135c18a4f..2869667740d 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/Method/isObsolete/isobsolete001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/Method/isObsolete/isobsolete001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -81,20 +81,7 @@ import java.io.*; *
*/ -public class isobsolete001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/Method/isObsolete/isobsolete001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class isobsolete001 extends JDIBase { public static void main (String argv[]) { @@ -113,20 +100,6 @@ public class isobsolete001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -135,23 +108,6 @@ public class isobsolete001 { private static final int brkpLineNumber = 49; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - class JDITestRuntimeException extends RuntimeException { JDITestRuntimeException(String str) { @@ -417,96 +373,6 @@ public class isobsolete001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/Method/isObsolete/isobsolete002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/Method/isObsolete/isobsolete002.java index 9ccedf98133..098065a1d9e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/Method/isObsolete/isobsolete002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/Method/isObsolete/isobsolete002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -79,20 +79,7 @@ import java.io.*; *
*/ -public class isobsolete002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/Method/isObsolete/isobsolete002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class isobsolete002 extends JDIBase { public static void main (String argv[]) { @@ -111,20 +98,6 @@ public class isobsolete002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -133,23 +106,6 @@ public class isobsolete002 { private static final int brkpLineNumber = 49; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - class JDITestRuntimeException extends RuntimeException { JDITestRuntimeException(String str) { @@ -417,97 +373,6 @@ public class isobsolete002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addClassExclusionFilter/filter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addClassExclusionFilter/filter002.java index 171e075047a..0806e7f21e5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addClassExclusionFilter/filter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addClassExclusionFilter/filter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -81,20 +81,7 @@ import java.io.*; *
*/ -public class filter002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/MethodEntryRequest/addClassExclusionFilter/filter002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class filter002 extends JDIBase { public static void main (String argv[]) { @@ -113,20 +100,6 @@ public class filter002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -136,25 +109,7 @@ public class filter002 { "nsk.jdi.MethodEntryRequest.addClassExclusionFilter.TestClass10"; //====================================================== test program - //------------------------------------------------------ common section - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -163,7 +118,6 @@ public class filter002 { Binder binder = new Binder(argsHandler, logHandler); waitTime = argsHandler.getWaitTime() * 60000; - try { log2("launching a debuggee :"); log2(" " + debuggeeName); @@ -383,86 +337,7 @@ public class filter002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() + protected void breakpointForCommunication() throws JDITestRuntimeException { log2("breakpointForCommunication"); @@ -486,6 +361,8 @@ public class filter002 { throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); } + + // ============================== test's additional methods private MethodEntryRequest setting23MethodEntryRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addClassFilter_rt/filter_rt002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addClassFilter_rt/filter_rt002.java index 6297fc7b8bf..81f651e5853 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addClassFilter_rt/filter_rt002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addClassFilter_rt/filter_rt002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -82,20 +82,7 @@ import java.io.*; *
*/ -public class filter_rt002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/MethodEntryRequest/addClassFilter_rt/filter_rt002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class filter_rt002 extends JDIBase { public static void main (String argv[]) { @@ -114,20 +101,6 @@ public class filter_rt002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -137,25 +110,6 @@ public class filter_rt002 { "nsk.jdi.MethodEntryRequest.addClassFilter_rt.filter_rt002aTestClass10"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -388,97 +342,6 @@ public class filter_rt002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private MethodEntryRequest setting21MethodEntryRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addClassFilter_s/filter_s002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addClassFilter_s/filter_s002.java index 4173f206010..a02d4d1f83b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addClassFilter_s/filter_s002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addClassFilter_s/filter_s002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -81,20 +81,7 @@ import java.io.*; *
*/ -public class filter_s002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/MethodEntryRequest/addClassFilter_s/filter_s002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class filter_s002 extends JDIBase { public static void main (String argv[]) { @@ -113,20 +100,6 @@ public class filter_s002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -136,25 +109,6 @@ public class filter_s002 { "nsk.jdi.MethodEntryRequest.addClassFilter_s.TestClass10"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -383,97 +337,6 @@ public class filter_s002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private MethodEntryRequest setting22MethodEntryRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addInstanceFilter/instancefilter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addInstanceFilter/instancefilter002.java index 75e8c58f1a0..904db070d35 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addInstanceFilter/instancefilter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addInstanceFilter/instancefilter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -82,20 +82,7 @@ import java.io.*; *
*/ -public class instancefilter002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/MethodEntryRequest/addInstanceFilter/instancefilter002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class instancefilter002 extends JDIBase { public static void main (String argv[]) { @@ -114,20 +101,6 @@ public class instancefilter002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -137,25 +110,6 @@ public class instancefilter002 { "nsk.jdi.MethodEntryRequest.addInstanceFilter.instancefilter002aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -414,97 +368,6 @@ public class instancefilter002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private MethodEntryRequest setting2MethodEntryRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addInstanceFilter/instancefilter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addInstanceFilter/instancefilter003.java index ec40131c95e..c2ba325aeff 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addInstanceFilter/instancefilter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addInstanceFilter/instancefilter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -78,20 +78,7 @@ import java.io.*; *
*/ -public class instancefilter003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/MethodEntryRequest/addInstanceFilter/instancefilter003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class instancefilter003 extends JDIBase { public static void main (String argv[]) { @@ -112,18 +99,6 @@ public class instancefilter003 { //-------------------------------------------------- log procedures - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -133,25 +108,6 @@ public class instancefilter003 { "nsk.jdi.MethodEntryRequest.addInstanceFilter.instancefilter003aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -381,97 +337,6 @@ public class instancefilter003 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private MethodEntryRequest setting2MethodEntryRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addThreadFilter/threadfilter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addThreadFilter/threadfilter002.java index c4b7efab8fa..9f55fe518d0 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addThreadFilter/threadfilter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addThreadFilter/threadfilter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -84,20 +84,7 @@ import java.io.*; *
*/ -public class threadfilter002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/MethodEntryRequest/addThreadFilter/threadfilter002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class threadfilter002 extends JDIBase { public static void main (String argv[]) { @@ -116,20 +103,6 @@ public class threadfilter002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -139,25 +112,6 @@ public class threadfilter002 { "nsk.jdi.MethodEntryRequest.addThreadFilter.threadfilter002aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -396,97 +350,6 @@ public class threadfilter002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private MethodEntryRequest setting2MethodEntryRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addThreadFilter/threadfilter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addThreadFilter/threadfilter003.java index 2915c989a7d..eb150be88ff 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addThreadFilter/threadfilter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodEntryRequest/addThreadFilter/threadfilter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -84,20 +84,7 @@ import java.io.*; *
*/ -public class threadfilter003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/MethodEntryRequest/addThreadFilter/threadfilter003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class threadfilter003 extends JDIBase { public static void main (String argv[]) { @@ -116,20 +103,6 @@ public class threadfilter003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -139,25 +112,6 @@ public class threadfilter003 { "nsk.jdi.MethodEntryRequest.addThreadFilter.threadfilter003aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -399,97 +353,6 @@ public class threadfilter003 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private MethodEntryRequest setting2MethodEntryRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addClassExclusionFilter/filter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addClassExclusionFilter/filter002.java index 405bb9a7dd9..4a4e5dfcfcd 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addClassExclusionFilter/filter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addClassExclusionFilter/filter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -81,20 +81,7 @@ import java.io.*; *
*/ -public class filter002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/MethodExitRequest/addClassExclusionFilter/filter002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class filter002 extends JDIBase { public static void main (String argv[]) { @@ -113,20 +100,6 @@ public class filter002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -136,25 +109,6 @@ public class filter002 { "nsk.jdi.MethodExitRequest.addClassExclusionFilter.TestClass10"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -383,87 +337,8 @@ public class filter002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { + protected void breakpointForCommunication() + throws JDITestRuntimeException { log2("breakpointForCommunication"); do { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addClassFilter_rt/filter_rt002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addClassFilter_rt/filter_rt002.java index 4d860872554..367f7aa7bf3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addClassFilter_rt/filter_rt002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addClassFilter_rt/filter_rt002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -82,20 +82,7 @@ import java.io.*; *
*/ -public class filter_rt002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/MethodExitRequest/addClassFilter_rt/filter_rt002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class filter_rt002 extends JDIBase { public static void main (String argv[]) { @@ -114,20 +101,6 @@ public class filter_rt002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -137,25 +110,6 @@ public class filter_rt002 { "nsk.jdi.MethodExitRequest.addClassFilter_rt.filter_rt002aTestClass10"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -164,7 +118,6 @@ public class filter_rt002 { Binder binder = new Binder(argsHandler, logHandler); waitTime = argsHandler.getWaitTime() * 60000; - try { log2("launching a debuggee :"); log2(" " + debuggeeName); @@ -388,97 +341,6 @@ public class filter_rt002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private MethodExitRequest setting21MethodExitRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addClassFilter_s/filter_s002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addClassFilter_s/filter_s002.java index 7b5e471a8f4..d34d006f532 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addClassFilter_s/filter_s002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addClassFilter_s/filter_s002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -81,20 +81,7 @@ import java.io.*; *
*/ -public class filter_s002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/MethodExitRequest/addClassFilter_s/filter_s002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class filter_s002 extends JDIBase { public static void main (String argv[]) { @@ -113,20 +100,6 @@ public class filter_s002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -136,25 +109,6 @@ public class filter_s002 { "nsk.jdi.MethodExitRequest.addClassFilter_s.TestClass10"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -383,97 +337,6 @@ public class filter_s002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private MethodExitRequest setting22MethodExitRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addInstanceFilter/instancefilter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addInstanceFilter/instancefilter002.java index a2b87ad3f9e..b20a88171ca 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addInstanceFilter/instancefilter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addInstanceFilter/instancefilter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -82,20 +82,7 @@ import java.io.*; *
*/ -public class instancefilter002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/MethodExitRequest/addInstanceFilter/instancefilter002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class instancefilter002 extends JDIBase { public static void main (String argv[]) { @@ -114,20 +101,6 @@ public class instancefilter002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -137,25 +110,6 @@ public class instancefilter002 { "nsk.jdi.MethodExitRequest.addInstanceFilter.instancefilter002aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -414,97 +368,6 @@ public class instancefilter002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private MethodExitRequest setting2MethodExitRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addInstanceFilter/instancefilter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addInstanceFilter/instancefilter003.java index 2c00a9e0ff7..2e1fcb3f8ca 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addInstanceFilter/instancefilter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addInstanceFilter/instancefilter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -78,20 +78,7 @@ import java.io.*; *
*/ -public class instancefilter003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/MethodExitRequest/addInstanceFilter/instancefilter003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class instancefilter003 extends JDIBase { public static void main (String argv[]) { @@ -110,20 +97,6 @@ public class instancefilter003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -133,25 +106,6 @@ public class instancefilter003 { "nsk.jdi.MethodExitRequest.addInstanceFilter.instancefilter003aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -381,97 +335,6 @@ public class instancefilter003 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private MethodExitRequest setting2MethodExitRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addThreadFilter/threadfilter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addThreadFilter/threadfilter002.java index c911fb0eb56..173e621e50a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addThreadFilter/threadfilter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addThreadFilter/threadfilter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -83,20 +83,7 @@ import java.io.*; *
*/ -public class threadfilter002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/MethodExitRequest/addThreadFilter/threadfilter002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class threadfilter002 extends JDIBase { public static void main (String argv[]) { @@ -115,20 +102,6 @@ public class threadfilter002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -138,25 +111,6 @@ public class threadfilter002 { "nsk.jdi.MethodExitRequest.addThreadFilter.threadfilter002aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -396,97 +350,6 @@ public class threadfilter002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private MethodExitRequest setting2MethodExitRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addThreadFilter/threadfilter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addThreadFilter/threadfilter003.java index ebcb3c4a784..aeea727ca17 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addThreadFilter/threadfilter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/MethodExitRequest/addThreadFilter/threadfilter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -83,20 +83,7 @@ import java.io.*; *
*/ -public class threadfilter003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/MethodExitRequest/addThreadFilter/threadfilter003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class threadfilter003 extends JDIBase { public static void main (String argv[]) { @@ -115,20 +102,6 @@ public class threadfilter003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -138,25 +111,6 @@ public class threadfilter003 { "nsk.jdi.MethodExitRequest.addThreadFilter.threadfilter003aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -402,97 +356,6 @@ public class threadfilter003 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private MethodExitRequest setting2MethodExitRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ModificationWatchpointEvent/_itself_/mwevent001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ModificationWatchpointEvent/_itself_/mwevent001.java index b3e0181047e..c208bb22b24 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ModificationWatchpointEvent/_itself_/mwevent001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ModificationWatchpointEvent/_itself_/mwevent001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -78,20 +78,7 @@ import java.io.*; *
*/ -public class mwevent001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ModificationWatchpointEvent/_itself_/mwevent001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class mwevent001 extends JDIBase { public static void main (String argv[]) { @@ -110,20 +97,6 @@ public class mwevent001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -133,24 +106,6 @@ public class mwevent001 { "nsk.jdi.ModificationWatchpointEvent._itself_.CheckedClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -373,95 +328,4 @@ public class mwevent001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/disableCollection/disablecollection002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/disableCollection/disablecollection002.java index 56f2999c70f..9f8bb31a612 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/disableCollection/disablecollection002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ObjectReference/disableCollection/disablecollection002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -97,20 +97,7 @@ import java.io.*; *
*/ -public class disablecollection002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ObjectReference/disableCollection/disablecollection002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class disablecollection002 extends JDIBase { public static void main (String argv[]) { @@ -129,45 +116,12 @@ public class disablecollection002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.ObjectReference.disableCollection.disablecollection002a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -176,7 +130,6 @@ public class disablecollection002 { Binder binder = new Binder(argsHandler, logHandler); waitTime = argsHandler.getWaitTime() * 60000; - try { log2("launching a debuggee :"); log2(" " + debuggeeName); @@ -377,95 +330,4 @@ public class disablecollection002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/PathSearchingVirtualMachine/classPath/classpath001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/PathSearchingVirtualMachine/classPath/classpath001.java index 325a67397bf..c78762a6e2f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/PathSearchingVirtualMachine/classPath/classpath001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/PathSearchingVirtualMachine/classPath/classpath001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -79,20 +79,7 @@ import java.io.*; *
*/ -public class classpath001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/PathSearchingVirtualMachine/classPath/classpath001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class classpath001 extends JDIBase { public static void main (String argv[]) { @@ -111,45 +98,12 @@ public class classpath001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.PathSearchingVirtualMachine.classPath.classpath001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -370,95 +324,4 @@ public class classpath001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/PrimitiveType/_itself_/primitivetype001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/PrimitiveType/_itself_/primitivetype001.java index 89959a84fa5..70e37948055 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/PrimitiveType/_itself_/primitivetype001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/PrimitiveType/_itself_/primitivetype001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -72,20 +72,7 @@ import java.io.*; *
*/ -public class primitivetype001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/PrimitiveType/_itself_/primitivetype001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class primitivetype001 extends JDIBase { public static void main (String argv[]) { @@ -104,45 +91,12 @@ public class primitivetype001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.PrimitiveType._itself_.primitivetype001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -338,95 +292,4 @@ public class primitivetype001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/classLoader/classloader001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/classLoader/classloader001.java index 5aab6d1e139..b74b73bfb04 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/classLoader/classloader001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/classLoader/classloader001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -63,20 +63,7 @@ import java.io.*; * to inform the debugger of checks finished, and both end.
*/ -public class classloader001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ReferenceType/classLoader/classloader001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class classloader001 extends JDIBase { public static void main (String argv[]) { @@ -95,20 +82,6 @@ public class classloader001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private final static String packagePrefix = "nsk.jdi.ReferenceType.classLoader."; @@ -117,24 +90,6 @@ public class classloader001 { private final static String testedClassName1 = packagePrefix + "classloader001c"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -353,95 +308,4 @@ public class classloader001 { } } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValue/getvalue001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValue/getvalue001.java index 70b3e9d0ddb..fdbe0a5b5f3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValue/getvalue001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValue/getvalue001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -63,20 +63,7 @@ import java.io.*; * to inform the debugger of checks finished, and both end.
*/ -public class getvalue001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ReferenceType/getValue/getvalue001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class getvalue001 extends JDIBase { public static void main (String argv[]) { @@ -95,20 +82,6 @@ public class getvalue001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -118,24 +91,6 @@ public class getvalue001 { "nsk.jdi.ReferenceType.getValue.getvalue001aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -362,95 +317,4 @@ public class getvalue001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValue/getvalue002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValue/getvalue002.java index c0ac6f588b2..b7a54199497 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValue/getvalue002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValue/getvalue002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -62,20 +62,7 @@ import java.io.*; * to inform the debugger of checks finished, and both end.
*/ -public class getvalue002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ReferenceType/getValue/getvalue002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class getvalue002 extends JDIBase { public static void main (String argv[]) { @@ -94,20 +81,6 @@ public class getvalue002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -117,24 +90,6 @@ public class getvalue002 { "nsk.jdi.ReferenceType.getValue.getvalue002aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -363,94 +318,4 @@ public class getvalue002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValue/getvalue003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValue/getvalue003.java index e05eea7a94d..cb01b136bee 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValue/getvalue003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValue/getvalue003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -62,20 +62,7 @@ import java.io.*; * to inform the debugger of checks finished, and both end.
*/ -public class getvalue003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ReferenceType/getValue/getvalue003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class getvalue003 extends JDIBase { public static void main (String argv[]) { @@ -94,20 +81,6 @@ public class getvalue003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -117,24 +90,6 @@ public class getvalue003 { "nsk.jdi.ReferenceType.getValue.getvalue003aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -363,94 +318,4 @@ public class getvalue003 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValues/getvalues001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValues/getvalues001.java index 16e57b679db..a538815e6a1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValues/getvalues001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/getValues/getvalues001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -66,20 +66,7 @@ import java.io.*; * to inform the debugger of checks finished, and both end.
*/ -public class getvalues001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ReferenceType/getValues/getvalues001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class getvalues001 extends JDIBase { public static void main (String argv[]) { @@ -98,20 +85,6 @@ public class getvalues001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -121,24 +94,6 @@ public class getvalues001 { "nsk.jdi.ReferenceType.getValues.TestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -390,95 +345,4 @@ public class getvalues001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/isFinal/isfinal001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/isFinal/isfinal001.java index cf7cfcc8270..34fac9f878e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/isFinal/isfinal001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/isFinal/isfinal001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -48,20 +48,7 @@ import java.io.*; * - primitive classes.
*/ -public class isfinal001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ReferenceType/isFinal/isfinal001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class isfinal001 extends JDIBase { public static void main (String argv[]) { @@ -80,20 +67,6 @@ public class isfinal001 { return exitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -105,24 +78,6 @@ public class isfinal001 { String mName = "nsk.jdi.ReferenceType.isFinal"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -439,95 +394,4 @@ public class isfinal001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/isStatic/isstatic001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/isStatic/isstatic001.java index ac64893f8bb..370e99fef7e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/isStatic/isstatic001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/isStatic/isstatic001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -79,20 +79,7 @@ import java.io.*; *
*/ -public class isstatic001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ReferenceType/isStatic/isstatic001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class isstatic001 extends JDIBase { public static void main (String argv[]) { @@ -111,20 +98,6 @@ public class isstatic001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -133,25 +106,6 @@ public class isstatic001 { String mName = "nsk.jdi.ReferenceType.isStatic"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -457,95 +411,4 @@ public class isstatic001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/isStatic/isstatic002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/isStatic/isstatic002.java index a2a0acb9191..8eba67bae64 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/isStatic/isstatic002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/isStatic/isstatic002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -79,20 +79,7 @@ import java.io.*; *
*/ -public class isstatic002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ReferenceType/isStatic/isstatic002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class isstatic002 extends JDIBase { public static void main (String argv[]) { @@ -111,20 +98,6 @@ public class isstatic002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -133,25 +106,6 @@ public class isstatic002 { String mName = "nsk.jdi.ReferenceType.isStatic"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -368,95 +322,4 @@ public class isstatic002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/nestedTypes/nestedtypes001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/nestedTypes/nestedtypes001.java index 831d3d982d5..3a5b90df78e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/nestedTypes/nestedtypes001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/nestedTypes/nestedtypes001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -62,20 +62,7 @@ import java.io.*; * to inform the debugger of checks finished, and both end.
*/ -public class nestedtypes001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ReferenceType/nestedTypes/nestedtypes001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class nestedtypes001 extends JDIBase { public static void main (String argv[]) { @@ -89,20 +76,6 @@ public class nestedtypes001 { return new nestedtypes001().runThis(argv, out); } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -111,24 +84,6 @@ public class nestedtypes001 { String mName = "nsk.jdi.ReferenceType.nestedTypes"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -378,95 +333,4 @@ public class nestedtypes001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/nestedTypes/nestedtypes002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/nestedTypes/nestedtypes002.java index 12db4ab322b..5a64f4cf03e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/nestedTypes/nestedtypes002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ReferenceType/nestedTypes/nestedtypes002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -62,20 +62,7 @@ import java.io.*; * to inform the debugger of checks finished, and both end.
*/ -public class nestedtypes002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ReferenceType/nestedTypes/nestedtypes002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class nestedtypes002 extends JDIBase { public static void main (String argv[]) { @@ -89,20 +76,6 @@ public class nestedtypes002 { return new nestedtypes002().runThis(argv, out); } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -111,24 +84,6 @@ public class nestedtypes002 { String mName = "nsk.jdi.ReferenceType.nestedTypes"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -245,7 +200,6 @@ public class nestedtypes002 { } - private static BreakpointEvent bpEvent; private void testRun() throws JDITestRuntimeException, Exception { @@ -253,7 +207,7 @@ public class nestedtypes002 { eventRManager = vm.eventRequestManager(); ClassPrepareRequest cpRequest = eventRManager.createClassPrepareRequest(); - cpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); + cpRequest.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD); cpRequest.addClassFilter(debuggeeName); cpRequest.enable(); @@ -265,24 +219,24 @@ public class nestedtypes002 { debuggeeClass = event.referenceType(); if (!debuggeeClass.name().equals(debuggeeName)) - throw new JDITestRuntimeException("** Unexpected ClassName for ClassPrepareEvent **"); + throw new JDITestRuntimeException("** Unexpected ClassName for ClassPrepareEvent **"); log2(" received: ClassPrepareEvent for debuggeeClass"); String bPointMethod = "methodForCommunication"; - String lineForComm = "lineForComm"; + String lineForComm = "lineForComm"; BreakpointRequest bpRequest; try { bpRequest = settingBreakpoint(debuggee.threadByNameOrThrow("main"), - debuggeeClass, - bPointMethod, lineForComm, "zero"); - } catch ( Exception e ) { + debuggeeClass, + bPointMethod, lineForComm, "zero"); + } catch (Exception e) { throw e; } bpRequest.enable(); - //------------------------------------------------------ testing section + //------------------------------------------------------ testing section log1(" TESTING BEGINS"); @@ -292,7 +246,7 @@ public class nestedtypes002 { breakpointForCommunication(); int instruction = ((IntegerValue) - (debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value(); + (debuggeeClass.getValue(debuggeeClass.fieldByName("instruction")))).value(); if (instruction == 0) { vm.resume(); @@ -303,9 +257,9 @@ public class nestedtypes002 { //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ variable part - ReferenceType testedType = null; - List nestedTypes = null; - String typeForCheck; + ReferenceType testedType = null; + List nestedTypes = null; + String typeForCheck; log2("----- Case for testing: ArrayType"); @@ -322,7 +276,7 @@ public class nestedtypes002 { } log2(" getting: ReferenceType testedType = (ReferenceType) classList.get(0);"); - testedType = (ReferenceType) classes.get(0); + testedType = (ReferenceType) classes.get(0); log2(" getting: List nestedTypes = testedType.nestedTypes();"); nestedTypes = testedType.nestedTypes(); @@ -335,17 +289,17 @@ public class nestedtypes002 { log2("----- Cases for testing: primitive classes"); String names[] = { - "bl", - "bt", - "ch", - "db", - "fl", - "in", - "ln", - "sh" - }; + "bl", + "bt", + "ch", + "db", + "fl", + "in", + "ln", + "sh" + }; - Method testMethod = (Method)debuggeeClass.methodsByName("main").get(0); + Method testMethod = (Method) debuggeeClass.methodsByName("main").get(0); // bpEvent should be assigned while getting of BreakpointEvent if (bpEvent == null) { throw new JDITestRuntimeException("bpEvent is null"); @@ -356,7 +310,7 @@ public class nestedtypes002 { try { frame = bpEvent.thread().frame(1); } catch (Exception e) { - throw new JDITestRuntimeException("Unexpected exception while getting stack frame: " + e ); + throw new JDITestRuntimeException("Unexpected exception while getting stack frame: " + e); } if (frame.location().method() != testMethod) { throw new JDITestRuntimeException("Cannot take frame of main method"); @@ -368,17 +322,17 @@ public class nestedtypes002 { LocalVariable lVar = null; try { lVar = frame.visibleVariableByName(names[i1]); - } catch (Exception e ) { - throw new JDITestRuntimeException("Unexpected exception while searching for field " + names[i1] + " : " + e ); + } catch (Exception e) { + throw new JDITestRuntimeException("Unexpected exception while searching for field " + names[i1] + " : " + e); } Value val = null; try { val = frame.getValue(lVar); - } catch (Exception e ) { - throw new JDITestRuntimeException("Unexpected exception while getting value of field " + names[i1] + " : " + e ); + } catch (Exception e) { + throw new JDITestRuntimeException("Unexpected exception while getting value of field " + names[i1] + " : " + e); } - testedType = ((ClassObjectReference)val).reflectedType(); + testedType = ((ClassObjectReference) val).reflectedType(); log2(" checking nestedTypes() for ClassObjectReference of : " + testedType.name()); nestedTypes = testedType.nestedTypes(); @@ -395,97 +349,4 @@ public class nestedtypes002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - Event event = eventIterator.nextEvent(); - if ( event instanceof BreakpointEvent) { - bpEvent = (BreakpointEvent)event; - return; - } - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ShortType/_itself_/shorttype001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ShortType/_itself_/shorttype001.java index 47830a1b7ac..7c800a58ffe 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ShortType/_itself_/shorttype001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ShortType/_itself_/shorttype001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -73,20 +73,7 @@ import java.io.*; *
*/ -public class shorttype001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ShortType/_itself_/shorttype001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class shorttype001 extends JDIBase { public static void main (String argv[]) { @@ -105,45 +92,12 @@ public class shorttype001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.ShortType._itself_.shorttype001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -342,95 +296,4 @@ public class shorttype001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassExclusionFilter/filter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassExclusionFilter/filter002.java index 231e44f7a3c..0f1666fe29b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassExclusionFilter/filter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassExclusionFilter/filter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -80,20 +80,7 @@ import java.io.*; *
*/ -public class filter002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/StepRequest/addClassExclusionFilter/filter002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class filter002 extends JDIBase { public static void main (String argv[]) { @@ -112,20 +99,6 @@ public class filter002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -135,25 +108,6 @@ public class filter002 { "nsk.jdi.StepRequest.addClassExclusionFilter.TestClass10"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -382,107 +336,6 @@ public class filter002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - Event evt = eventIterator.nextEvent(); - - if (evt instanceof BreakpointEvent) - return; - - log3("Didn't get expected BreakpointEvent, events are:"); - while(true) { - log3(" event = " + evt); - if (!eventIterator.hasNext()) { - break; - } - evt = eventIterator.nextEvent(); - } - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private StepRequest setting23StepRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassFilter_rt/filter_rt002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassFilter_rt/filter_rt002.java index a2f35183295..ff014d43141 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassFilter_rt/filter_rt002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassFilter_rt/filter_rt002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -82,20 +82,7 @@ import java.io.*; *
*/ -public class filter_rt002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/StepRequest/addClassFilter_rt/filter_rt002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class filter_rt002 extends JDIBase { public static void main (String argv[]) { @@ -114,20 +101,6 @@ public class filter_rt002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -137,25 +110,6 @@ public class filter_rt002 { "nsk.jdi.StepRequest.addClassFilter_rt.filter_rt002aTestClass10"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -393,97 +347,6 @@ public class filter_rt002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private StepRequest setting21StepRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassFilter_s/filter_s002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassFilter_s/filter_s002.java index 2eeb2852b4e..4a49575e987 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassFilter_s/filter_s002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addClassFilter_s/filter_s002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -82,20 +82,7 @@ import java.io.*; *
*/ -public class filter_s002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/StepRequest/addClassFilter_s/filter_s002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class filter_s002 extends JDIBase { public static void main (String argv[]) { @@ -114,20 +101,6 @@ public class filter_s002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -137,25 +110,6 @@ public class filter_s002 { "nsk.jdi.StepRequest.addClassFilter_s.TestClass10"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -385,97 +339,6 @@ public class filter_s002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private StepRequest setting23StepRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addInstanceFilter/instancefilter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addInstanceFilter/instancefilter002.java index c48d2c700b4..066206c5214 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addInstanceFilter/instancefilter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addInstanceFilter/instancefilter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -82,20 +82,7 @@ import java.io.*; *
*/ -public class instancefilter002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/StepRequest/addInstanceFilter/instancefilter002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class instancefilter002 extends JDIBase { public static void main (String argv[]) { @@ -114,20 +101,6 @@ public class instancefilter002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -137,25 +110,6 @@ public class instancefilter002 { "nsk.jdi.StepRequest.addInstanceFilter.instancefilter002aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -413,97 +367,6 @@ public class instancefilter002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private StepRequest setting2StepRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addInstanceFilter/instancefilter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addInstanceFilter/instancefilter003.java index f12c5ae7ff3..b764fa9fee6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addInstanceFilter/instancefilter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/addInstanceFilter/instancefilter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -78,20 +78,7 @@ import java.io.*; *
*/ -public class instancefilter003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/StepRequest/addInstanceFilter/instancefilter003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class instancefilter003 extends JDIBase { public static void main (String argv[]) { @@ -110,20 +97,6 @@ public class instancefilter003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -133,25 +106,6 @@ public class instancefilter003 { "nsk.jdi.StepRequest.addInstanceFilter.instancefilter003aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -380,97 +334,6 @@ public class instancefilter003 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private StepRequest setting2StepRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth001.java index fbeb350ef96..12004bad5df 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -78,20 +78,7 @@ import java.io.*; *
*/ -public class depth001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/StepRequest/depth/depth001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class depth001 extends JDIBase { public static void main (String argv[]) { @@ -110,20 +97,6 @@ public class depth001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -133,25 +106,6 @@ public class depth001 { "nsk.jdi.StepRequest.depth.TestClass10"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -360,97 +314,6 @@ public class depth001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private StepRequest setting24StepRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth002.java index adc2bd80c42..dffd96e0199 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -78,20 +78,7 @@ import java.io.*; *
*/ -public class depth002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/StepRequest/depth/depth002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class depth002 extends JDIBase { public static void main (String argv[]) { @@ -110,20 +97,6 @@ public class depth002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -133,25 +106,6 @@ public class depth002 { "nsk.jdi.StepRequest.depth.depth002aTestClass10"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -360,97 +314,6 @@ public class depth002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private StepRequest setting24StepRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth003.java index 8d848790707..6e050f7a0d8 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/depth/depth003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -78,20 +78,7 @@ import java.io.*; *
*/ -public class depth003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/StepRequest/depth/depth003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class depth003 extends JDIBase { public static void main (String argv[]) { @@ -110,20 +97,6 @@ public class depth003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -133,25 +106,6 @@ public class depth003 { "nsk.jdi.StepRequest.depth.depth003aTestClass10"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -360,97 +314,6 @@ public class depth003 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private StepRequest setting24StepRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/size/size001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/size/size001.java index fc7e105367d..5585a491328 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/size/size001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/size/size001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -78,20 +78,7 @@ import java.io.*; *
*/ -public class size001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/StepRequest/size/size001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class size001 extends JDIBase { public static void main (String argv[]) { @@ -110,20 +97,6 @@ public class size001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -133,25 +106,6 @@ public class size001 { "nsk.jdi.StepRequest.size.TestClass10"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -360,97 +314,6 @@ public class size001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private StepRequest setting24StepRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/size/size002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/size/size002.java index a8ed1a0ccd1..9bb533b8724 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/size/size002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/size/size002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -78,20 +78,7 @@ import java.io.*; *
*/ -public class size002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/StepRequest/size/size002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class size002 extends JDIBase { public static void main (String argv[]) { @@ -110,20 +97,6 @@ public class size002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -133,25 +106,6 @@ public class size002 { "nsk.jdi.StepRequest.size.size002aTestClass10"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -360,97 +314,6 @@ public class size002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private StepRequest setting24StepRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/thread/thread001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/thread/thread001.java index f99cd7db856..aaa8737d70c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/thread/thread001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/StepRequest/thread/thread001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -79,20 +79,7 @@ import java.io.*; *
*/ -public class thread001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/StepRequest/thread/thread001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class thread001 extends JDIBase { public static void main (String argv[]) { @@ -111,19 +98,6 @@ public class thread001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } // ************************************************ test parameters @@ -134,25 +108,6 @@ public class thread001 { "nsk.jdi.StepRequest.thread.TestClass10"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -361,97 +316,6 @@ public class thread001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private StepRequest setting24StepRequest ( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter001.java index 72acf1999fc..a62fb913812 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -78,20 +78,7 @@ import java.io.*; *
*/ -public class addthreadfilter001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class addthreadfilter001 extends JDIBase { public static void main (String argv[]) { @@ -110,45 +97,12 @@ public class addthreadfilter001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.ThreadDeathRequest.addThreadFilter.addthreadfilter001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -378,95 +332,4 @@ public class addthreadfilter001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter002.java index 4e54e439d82..56617b9f300 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -75,20 +75,7 @@ import java.io.*; *
*/ -public class addthreadfilter002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class addthreadfilter002 extends JDIBase { public static void main (String argv[]) { @@ -107,45 +94,12 @@ public class addthreadfilter002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.ThreadDeathRequest.addThreadFilter.addthreadfilter002a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -374,95 +328,4 @@ public class addthreadfilter002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter003.java index 811486a427e..268726deeb6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -86,20 +86,7 @@ import java.io.*; */ -public class addthreadfilter003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class addthreadfilter003 extends JDIBase { public static void main (String argv[]) { @@ -118,20 +105,6 @@ public class addthreadfilter003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -141,25 +114,6 @@ public class addthreadfilter003 { "nsk.jdi.ThreadDeathRequest.addThreadFilter.TestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -393,97 +347,6 @@ public class addthreadfilter003 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ThreadDeathRequest setting2ThreadDeathRequest( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter005.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter005.java index 67a47387eb2..aad3c9cc4e3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter005.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter005.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -86,20 +86,7 @@ import java.io.*; */ -public class addthreadfilter005 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ThreadDeathRequest/addThreadFilter/addthreadfilter005 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class addthreadfilter005 extends JDIBase { public static void main (String argv[]) { @@ -118,20 +105,6 @@ public class addthreadfilter005 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -141,25 +114,6 @@ public class addthreadfilter005 { "nsk.jdi.ThreadDeathRequest.addThreadFilter.addthreadfilter005aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -405,97 +359,6 @@ public class addthreadfilter005 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ThreadDeathRequest setting2ThreadDeathRequest( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes001.java index db5ef413aba..7e5b21d5d36 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -91,20 +91,7 @@ import java.io.*; * has to be incremented one more time.
*/ -public class popframes001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ThreadReference/popFrames/popframes001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class popframes001 extends JDIBase { public static void main (String argv[]) { @@ -123,42 +110,12 @@ public class popframes001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.ThreadReference.popFrames.popframes001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; BreakpointRequest breakpointRequest; @@ -422,97 +379,6 @@ public class popframes001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private void breakpointInMethod() diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes002.java index 7272e11631c..b37bf4c6b18 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -83,20 +83,7 @@ import java.io.*; * If no the event, the test FAILED.
*/ -public class popframes002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ThreadReference/popFrames/popframes002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class popframes002 extends JDIBase { public static void main (String argv[]) { @@ -115,50 +102,18 @@ public class popframes002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.ThreadReference.popFrames.popframes002a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; BreakpointRequest bpRequest; BreakpointRequest breakpointRequest2; BreakpointRequest breakpointRequest3; - //------------------------------------------------------ methods - private int runThis (String argv[], PrintStream out) { argsHandler = new ArgumentHandler(argv); @@ -401,96 +356,6 @@ public class popframes002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } // ============================== test's additional methods diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes003.java index eca4f172956..455030b9a00 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -82,20 +82,7 @@ import java.io.*; * If no the event, the test FAILED.
*/ -public class popframes003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ThreadReference/popFrames/popframes003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class popframes003 extends JDIBase { public static void main (String argv[]) { @@ -114,42 +101,12 @@ public class popframes003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.ThreadReference.popFrames.popframes003a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; BreakpointRequest bpRequest; MethodEntryRequest meRequest; @@ -157,9 +114,6 @@ public class popframes003 { BreakpointRequest bpRequest2; MethodEntryRequest meRequest3; - - //------------------------------------------------------ methods - private int runThis (String argv[], PrintStream out) { argsHandler = new ArgumentHandler(argv); @@ -472,69 +426,6 @@ public class popframes003 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - /* * private MethodEntryRequest settingMethodEntryRequest(ThreadReference, ReferenceType, * String) @@ -576,45 +467,4 @@ public class popframes003 { } - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void eventForCommunication() - throws JDITestRuntimeException { - - log2("eventForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof MethodEntryEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a MethodEntryEvent **"); - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes004.java index 184c89b027e..a372af1b8d5 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes004.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -81,20 +81,7 @@ import java.io.*; *
*/ -public class popframes004 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ThreadReference/popFrames/popframes004 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class popframes004 extends JDIBase { public static void main (String argv[]) { @@ -113,42 +100,12 @@ public class popframes004 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.ThreadReference.popFrames.popframes004a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; BreakpointRequest bpRequest; BreakpointRequest breakpointRequest2; @@ -412,98 +369,6 @@ public class popframes004 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private void breakpointInMethod(String number) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes005.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes005.java index d8f5f71271b..09abeb54d5e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes005.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadReference/popFrames/popframes005.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -85,20 +85,7 @@ import java.io.*; *
*/ -public class popframes005 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ThreadReference/popFrames/popframes005 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class popframes005 extends JDIBase { public static void main (String argv[]) { @@ -117,42 +104,12 @@ public class popframes005 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.ThreadReference.popFrames.popframes005a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; BreakpointRequest bpRequest; BreakpointRequest breakpointRequest2; @@ -394,97 +351,6 @@ public class popframes005 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } // ============================== test's additional methods diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter001.java index f0d9002a9ec..da06b4fbb81 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -78,20 +78,7 @@ import java.io.*; *
*/ -public class addthreadfilter001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class addthreadfilter001 extends JDIBase { public static void main (String argv[]) { @@ -110,45 +97,12 @@ public class addthreadfilter001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.ThreadStartRequest.addThreadFilter.addthreadfilter001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -377,95 +331,4 @@ public class addthreadfilter001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter003.java index 8796a1b3ddb..2ecb416a506 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -86,20 +86,7 @@ import java.io.*; */ -public class addthreadfilter003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class addthreadfilter003 extends JDIBase { public static void main (String argv[]) { @@ -118,20 +105,6 @@ public class addthreadfilter003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -141,25 +114,6 @@ public class addthreadfilter003 { "nsk.jdi.ThreadStartRequest.addThreadFilter.TestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -393,97 +347,6 @@ public class addthreadfilter003 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ThreadStartRequest setting2ThreadStartRequest( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter005.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter005.java index 1b1d849c98d..36adefde262 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter005.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter005.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -82,20 +82,7 @@ import java.io.*; */ -public class addthreadfilter005 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/ThreadStartRequest/addThreadFilter/addthreadfilter005 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class addthreadfilter005 extends JDIBase { public static void main (String argv[]) { @@ -114,20 +101,6 @@ public class addthreadfilter005 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -136,27 +109,6 @@ public class addthreadfilter005 { private String testedClassName = "nsk.jdi.ThreadStartRequest.addThreadFilter.addthreadfilter005aTestClass"; - //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods - private int runThis (String argv[], PrintStream out) { argsHandler = new ArgumentHandler(argv); @@ -400,97 +352,6 @@ public class addthreadfilter005 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ThreadStartRequest setting2ThreadStartRequest( ThreadReference thread, diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VMDeathEvent/_itself_/vmdeath002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VMDeathEvent/_itself_/vmdeath002.java index a12d345f92a..00ed1e16a8e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VMDeathEvent/_itself_/vmdeath002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VMDeathEvent/_itself_/vmdeath002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -64,20 +64,7 @@ import java.io.*; *
*/ -public class vmdeath002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/VMDeathEvent/_itself_/vmdeath002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class vmdeath002 extends JDIBase { public static void main (String argv[]) { @@ -96,45 +83,12 @@ public class vmdeath002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.VMDeathEvent._itself_.vmdeath002a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -324,101 +278,4 @@ public class vmdeath002 { return; } - - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } - - //System.out.println("================getEventSet()"); - //for (Event e : eventSet) - //System.out.println("Event in queue: " + e.toString()); - -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VMDeathEvent/_itself_/vmdeath003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VMDeathEvent/_itself_/vmdeath003.java index 690b9c93ae3..03a82a5a4a9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VMDeathEvent/_itself_/vmdeath003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VMDeathEvent/_itself_/vmdeath003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -70,20 +70,7 @@ import java.io.*; *
*/ -public class vmdeath003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/VMDeathEvent/_itself_/vmdeath003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class vmdeath003 extends JDIBase { public static void main (String argv[]) { @@ -102,45 +89,12 @@ public class vmdeath003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.VMDeathEvent._itself_.vmdeath003a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -327,95 +281,4 @@ public class vmdeath003 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/allClasses/allclasses001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/allClasses/allclasses001.java index e65ee66bd2b..0d7e734c7cc 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/allClasses/allclasses001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/allClasses/allclasses001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -67,20 +67,7 @@ import java.io.*; *
*/ -public class allclasses001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/VirtualMachine/allClasses/allclasses001", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class allclasses001 extends JDIBase { public static void main (String argv[]) { int result = run(argv, System.out); @@ -97,20 +84,6 @@ public class allclasses001 { return exitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -120,28 +93,10 @@ public class allclasses001 { "nsk.jdi.VirtualMachine.allClasses."; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; static final int returnCode0 = 0; static final int returnCode1 = 1; - //------------------------------------------------------ methods - private int runThis (String argv[], PrintStream out) { argsHandler = new ArgumentHandler(argv); @@ -442,99 +397,6 @@ public class allclasses001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException, Exception { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); -// breakpRequest = null; - throw e1; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); -// breakpRequest = null; - throw e2; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private int refTypeYes ( String name ) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canAddMethod/canaddmethod001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canAddMethod/canaddmethod001.java index 2e3ae8008a1..715d9183505 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canAddMethod/canaddmethod001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canAddMethod/canaddmethod001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -60,20 +60,7 @@ import java.io.*; * to inform the debugger of checks finished, and both end.
*/ -public class canaddmethod001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/VirtualMachine/canAddMethod/canaddmethod001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class canaddmethod001 extends JDIBase { public static void main (String argv[]) { @@ -92,45 +79,12 @@ public class canaddmethod001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.VirtualMachine.canAddMethod.canaddmethod001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -314,96 +268,4 @@ public class canaddmethod001 { log1(" TESTING ENDS"); return; } - - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canPopFrames/canpopframes001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canPopFrames/canpopframes001.java index da18818db07..8d5a131b6ba 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canPopFrames/canpopframes001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canPopFrames/canpopframes001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -60,20 +60,7 @@ import java.io.*; * to inform the debugger of checks finished, and both end.
*/ -public class canpopframes001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/VirtualMachine/canPopFrames/canpopframes001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class canpopframes001 extends JDIBase { public static void main (String argv[]) { @@ -92,45 +79,12 @@ public class canpopframes001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.VirtualMachine.canPopFrames.canpopframes001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -315,95 +269,4 @@ public class canpopframes001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canRedefineClasses/canredefineclasses001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canRedefineClasses/canredefineclasses001.java index d12656c923d..d0d66e9554f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canRedefineClasses/canredefineclasses001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canRedefineClasses/canredefineclasses001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -60,20 +60,7 @@ import java.io.*; * to inform the debugger of checks finished, and both end.
*/ -public class canredefineclasses001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/VirtualMachine/canRedefineClasses/canredefineclasses001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class canredefineclasses001 extends JDIBase { public static void main (String argv[]) { @@ -92,45 +79,12 @@ public class canredefineclasses001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.VirtualMachine.canRedefineClasses.canredefineclasses001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -315,95 +269,5 @@ public class canredefineclasses001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canRequestVMDeathEvent/canreqvmdev001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canRequestVMDeathEvent/canreqvmdev001.java index 29369343c06..0fca1d97396 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canRequestVMDeathEvent/canreqvmdev001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canRequestVMDeathEvent/canreqvmdev001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -60,20 +60,7 @@ import java.io.*; * to inform the debugger of checks finished, and both end.
*/ -public class canreqvmdev001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/VirtualMachine/canRequestVMDeathEvent/canreqvmdev001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class canreqvmdev001 extends JDIBase { public static void main (String argv[]) { @@ -92,45 +79,12 @@ public class canreqvmdev001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.VirtualMachine.canRequestVMDeathEvent.canreqvmdev001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -315,95 +269,4 @@ public class canreqvmdev001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canUnrestrictedlyRedefineClasses/curc001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canUnrestrictedlyRedefineClasses/curc001.java index 0775dd1f2d7..2fe87528dfc 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canUnrestrictedlyRedefineClasses/curc001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canUnrestrictedlyRedefineClasses/curc001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -60,20 +60,7 @@ import java.io.*; * to inform the debugger of checks finished, and both end.
*/ -public class curc001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/VirtualMachine/canUnrestrictedlyRedefineClasses/curc001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class curc001 extends JDIBase { public static void main (String argv[]) { @@ -92,45 +79,12 @@ public class curc001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.VirtualMachine.canUnrestrictedlyRedefineClasses.curc001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -315,95 +269,4 @@ public class curc001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canUseInstanceFilters/canusefilters001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canUseInstanceFilters/canusefilters001.java index e2bc38ee317..7ee8bc91ad9 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canUseInstanceFilters/canusefilters001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canUseInstanceFilters/canusefilters001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -60,20 +60,7 @@ import java.io.*; * to inform the debugger of checks finished, and both end.
*/ -public class canusefilters001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/VirtualMachine/canUseInstanceFilters/canusefilters001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class canusefilters001 extends JDIBase { public static void main (String argv[]) { @@ -92,45 +79,12 @@ public class canusefilters001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.VirtualMachine.canUseInstanceFilters.canusefilters001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -315,95 +269,4 @@ public class canusefilters001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canWatchFieldAccess/canwatchaccess001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canWatchFieldAccess/canwatchaccess001.java index 4c7cce74ba2..22ecbe109f6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canWatchFieldAccess/canwatchaccess001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canWatchFieldAccess/canwatchaccess001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -71,20 +71,7 @@ import java.io.*; * to inform the debugger of checks finished, and both end.
*/ -public class canwatchaccess001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/VirtualMachine/canWatchFieldAccess/canwatchaccess001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class canwatchaccess001 extends JDIBase { public static void main (String argv[]) { @@ -103,45 +90,12 @@ public class canwatchaccess001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.VirtualMachine.canWatchFieldAccess.canwatchaccess001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -326,95 +280,4 @@ public class canwatchaccess001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canWatchFieldModification/canwatchmod001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canWatchFieldModification/canwatchmod001.java index 6f8b41710dd..2b622584b60 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canWatchFieldModification/canwatchmod001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/canWatchFieldModification/canwatchmod001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -72,20 +72,7 @@ import java.io.*; *
*/ -public class canwatchmod001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/VirtualMachine/canWatchFieldModification/canwatchmod001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class canwatchmod001 extends JDIBase { public static void main (String argv[]) { @@ -104,45 +91,12 @@ public class canwatchmod001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.VirtualMachine.canWatchFieldModification.canwatchmod001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -327,95 +281,4 @@ public class canwatchmod001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses001.java index 70094bb5954..c8339ae4df1 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VirtualMachine/redefineClasses/redefineclasses001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -94,20 +94,7 @@ import java.io.*; *
*/ -public class redefineclasses001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/VirtualMachine/redefineClasses/redefineclasses001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class redefineclasses001 extends JDIBase { public static void main (String argv[]) { @@ -126,44 +113,12 @@ public class redefineclasses001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.VirtualMachine.redefineClasses.redefineclasses001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - private int runThis (String argv[], PrintStream out) { @@ -410,96 +365,6 @@ public class redefineclasses001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - alllineLocations = method.allLineLocations(); - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private void breakpointInMethod(String number) diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VoidType/_itself_/voidtype001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VoidType/_itself_/voidtype001.java index 0e4f073f438..505d6bd0f96 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/VoidType/_itself_/voidtype001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/VoidType/_itself_/voidtype001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -72,20 +72,7 @@ import java.io.*; *
*/ -public class voidtype001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/VoidType/_itself_/voidtype001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class voidtype001 extends JDIBase { public static void main (String argv[]) { @@ -104,45 +91,12 @@ public class voidtype001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = "nsk.jdi.VoidType._itself_.voidtype001a"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -344,95 +298,4 @@ public class voidtype001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - } diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassExclusionFilter/filter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassExclusionFilter/filter003.java index 2237832dff9..ffd2e949858 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassExclusionFilter/filter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassExclusionFilter/filter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -82,20 +82,7 @@ import java.io.*; *
*/ -public class filter003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/WatchpointRequest/addClassExclusionFilter/filter003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class filter003 extends JDIBase { public static void main (String argv[]) { @@ -114,20 +101,6 @@ public class filter003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -137,25 +110,6 @@ public class filter003 { "nsk.jdi.WatchpointRequest.addClassExclusionFilter.filter003aTestClass10"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -391,97 +345,6 @@ public class filter003 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private AccessWatchpointRequest setting23AccessWatchpointRequest ( diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassExclusionFilter/filter004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassExclusionFilter/filter004.java index 2fb77ace017..8922042f1dd 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassExclusionFilter/filter004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassExclusionFilter/filter004.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -82,20 +82,7 @@ import java.io.*; *
*/ -public class filter004 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/WatchpointRequest/addClassExclusionFilter/filter004 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class filter004 extends JDIBase { public static void main (String argv[]) { @@ -114,20 +101,6 @@ public class filter004 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -137,25 +110,6 @@ public class filter004 { "nsk.jdi.WatchpointRequest.addClassExclusionFilter.filter004aTestClass10"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -391,97 +345,6 @@ public class filter004 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ModificationWatchpointRequest setting23ModificationWatchpointRequest ( diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_rt/filter_rt003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_rt/filter_rt003.java index 3b898363894..fab20a4862b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_rt/filter_rt003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_rt/filter_rt003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -82,20 +82,7 @@ import java.io.*; *
*/ -public class filter_rt003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/WatchpointRequest/addClassFilter_rt/filter_rt003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class filter_rt003 extends JDIBase { public static void main (String argv[]) { @@ -114,20 +101,6 @@ public class filter_rt003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -137,25 +110,6 @@ public class filter_rt003 { "nsk.jdi.WatchpointRequest.addClassFilter_rt.filter_rt003aTestClass10"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -390,96 +344,6 @@ public class filter_rt003 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } // ============================== test's additional methods diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_rt/filter_rt004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_rt/filter_rt004.java index e69348f86dc..b00a463fcc7 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_rt/filter_rt004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_rt/filter_rt004.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -82,20 +82,7 @@ import java.io.*; *
*/ -public class filter_rt004 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/WatchpointRequest/addClassFilter_rt/filter_rt004 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class filter_rt004 extends JDIBase { public static void main (String argv[]) { @@ -114,20 +101,6 @@ public class filter_rt004 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -137,25 +110,6 @@ public class filter_rt004 { "nsk.jdi.WatchpointRequest.addClassFilter_rt.filter_rt004aTestClass10"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -390,97 +344,6 @@ public class filter_rt004 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ModificationWatchpointRequest setting21ModificationWatchpointRequest ( diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_s/filter_s003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_s/filter_s003.java index 52bf38e1650..48e82775a7a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_s/filter_s003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_s/filter_s003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -82,20 +82,7 @@ import java.io.*; *
*/ -public class filter_s003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/WatchpointRequest/addClassFilter_s/filter_s003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class filter_s003 extends JDIBase { public static void main (String argv[]) { @@ -114,20 +101,6 @@ public class filter_s003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -137,25 +110,6 @@ public class filter_s003 { "nsk.jdi.WatchpointRequest.addClassFilter_s.filter_s003aTestClass10"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -390,97 +344,6 @@ public class filter_s003 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private AccessWatchpointRequest setting21AccessWatchpointRequest ( diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_s/filter_s004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_s/filter_s004.java index 30bae5092ae..e4d4a3cb77e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_s/filter_s004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addClassFilter_s/filter_s004.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -82,20 +82,7 @@ import java.io.*; *
*/ -public class filter_s004 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/WatchpointRequest/addClassFilter_s/filter_s004 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class filter_s004 extends JDIBase { public static void main (String argv[]) { @@ -114,20 +101,6 @@ public class filter_s004 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -137,25 +110,6 @@ public class filter_s004 { "nsk.jdi.WatchpointRequest.addClassFilter_s.filter_s004aTestClass10"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -390,97 +344,6 @@ public class filter_s004 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ModificationWatchpointRequest setting21ModificationWatchpointRequest ( diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter003.java index 94d2149344b..278b468ead3 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -83,20 +83,7 @@ import java.io.*; *
*/ -public class instancefilter003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class instancefilter003 extends JDIBase { public static void main (String argv[]) { @@ -115,20 +102,6 @@ public class instancefilter003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -138,25 +111,6 @@ public class instancefilter003 { "nsk.jdi.WatchpointRequest.addInstanceFilter.instancefilter003aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -417,97 +371,6 @@ public class instancefilter003 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private AccessWatchpointRequest setting2AccessWatchpointRequest ( diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter004.java index f10273db3dc..c64d02f1999 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter004.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -83,20 +83,7 @@ import java.io.*; *
*/ -public class instancefilter004 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter004 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class instancefilter004 extends JDIBase { public static void main (String argv[]) { @@ -115,20 +102,6 @@ public class instancefilter004 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -138,25 +111,6 @@ public class instancefilter004 { "nsk.jdi.WatchpointRequest.addInstanceFilter.instancefilter004aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -417,97 +371,6 @@ public class instancefilter004 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ModificationWatchpointRequest setting2ModificationWatchpointRequest ( diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter005.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter005.java index 0fb515b01d3..025f39cb34f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter005.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter005.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -79,20 +79,7 @@ import java.io.*; *
*/ -public class instancefilter005 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter005 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class instancefilter005 extends JDIBase { public static void main (String argv[]) { @@ -111,20 +98,6 @@ public class instancefilter005 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -134,25 +107,6 @@ public class instancefilter005 { "nsk.jdi.WatchpointRequest.addInstanceFilter.instancefilter005aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -384,97 +338,6 @@ public class instancefilter005 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private AccessWatchpointRequest setting2AccessWatchpointRequest ( diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter006.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter006.java index 83fa96600d7..d8f7a272d76 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter006.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter006.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -79,20 +79,7 @@ import java.io.*; *
*/ -public class instancefilter006 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/WatchpointRequest/addInstanceFilter/instancefilter006 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class instancefilter006 extends JDIBase { public static void main (String argv[]) { @@ -111,20 +98,6 @@ public class instancefilter006 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -134,25 +107,6 @@ public class instancefilter006 { "nsk.jdi.WatchpointRequest.addInstanceFilter.instancefilter006aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -384,97 +338,6 @@ public class instancefilter006 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ModificationWatchpointRequest setting2ModificationWatchpointRequest ( diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter003.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter003.java index 237d52da575..7b9cf915e06 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter003.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter003.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -86,20 +86,7 @@ import java.io.*; *
*/ -public class addthreadfilter003 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter003 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class addthreadfilter003 extends JDIBase { public static void main (String argv[]) { @@ -118,20 +105,6 @@ public class addthreadfilter003 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -141,25 +114,6 @@ public class addthreadfilter003 { "nsk.jdi.WatchpointRequest.addThreadFilter.addthreadfilter003aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -407,97 +361,6 @@ public class addthreadfilter003 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private AccessWatchpointRequest setting2AccessWatchpointRequest ( diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter004.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter004.java index 1a8c570f759..8b6ac6bdda6 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter004.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter004.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -86,20 +86,7 @@ import java.io.*; *
*/ -public class addthreadfilter004 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter004 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class addthreadfilter004 extends JDIBase { public static void main (String argv[]) { @@ -118,20 +105,6 @@ public class addthreadfilter004 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -141,25 +114,6 @@ public class addthreadfilter004 { "nsk.jdi.WatchpointRequest.addThreadFilter.addthreadfilter004aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -407,97 +361,6 @@ public class addthreadfilter004 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ModificationWatchpointRequest setting2ModificationWatchpointRequest ( diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter005.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter005.java index ae80e88d5d5..3c9b5eae570 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter005.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter005.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -86,20 +86,7 @@ import java.io.*; *
*/ -public class addthreadfilter005 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter005 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class addthreadfilter005 extends JDIBase { public static void main (String argv[]) { @@ -118,20 +105,6 @@ public class addthreadfilter005 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -141,25 +114,6 @@ public class addthreadfilter005 { "nsk.jdi.WatchpointRequest.addThreadFilter.addthreadfilter005aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -410,97 +364,6 @@ public class addthreadfilter005 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private AccessWatchpointRequest setting2AccessWatchpointRequest ( diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter006.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter006.java index 7a8d8f62db0..a939d2f100f 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter006.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter006.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -86,20 +86,7 @@ import java.io.*; *
*/ -public class addthreadfilter006 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/WatchpointRequest/addThreadFilter/addthreadfilter006 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class addthreadfilter006 extends JDIBase { public static void main (String argv[]) { @@ -118,19 +105,6 @@ public class addthreadfilter006 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } // ************************************************ test parameters @@ -141,25 +115,6 @@ public class addthreadfilter006 { "nsk.jdi.WatchpointRequest.addThreadFilter.addthreadfilter006aTestClass"; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -410,97 +365,6 @@ public class addthreadfilter006 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ModificationWatchpointRequest setting2ModificationWatchpointRequest ( diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/field/field001.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/field/field001.java index c3c3a61a8f0..8c0bd684827 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/field/field001.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/field/field001.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -77,20 +77,7 @@ import java.io.*; *
*/ -public class field001 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/WatchpointRequest/field/field001 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class field001 extends JDIBase { public static void main (String argv[]) { @@ -109,20 +96,6 @@ public class field001 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -135,25 +108,6 @@ public class field001 { Field field2 = null; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -363,97 +317,6 @@ public class field001 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private AccessWatchpointRequest setting21AccessWatchpointRequest ( diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/field/field002.java b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/field/field002.java index 66a61dfe847..b795cb9495a 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/field/field002.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/WatchpointRequest/field/field002.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -78,20 +78,7 @@ import java.io.*; *
*/ -public class field002 { - - //----------------------------------------------------- templete section - static final int PASSED = 0; - static final int FAILED = 2; - static final int PASS_BASE = 95; - - //----------------------------------------------------- templete parameters - static final String - sHeader1 = "\n==> nsk/jdi/WatchpointRequest/field/field002 ", - sHeader2 = "--> debugger: ", - sHeader3 = "##> debugger: "; - - //----------------------------------------------------- main method +public class field002 extends JDIBase { public static void main (String argv[]) { @@ -110,20 +97,6 @@ public class field002 { return testExitCode; } - //-------------------------------------------------- log procedures - - private static Log logHandler; - - private static void log1(String message) { - logHandler.display(sHeader1 + message); - } - private static void log2(String message) { - logHandler.display(sHeader2 + message); - } - private static void log3(String message) { - logHandler.complain(sHeader3 + message); - } - // ************************************************ test parameters private String debuggeeName = @@ -136,25 +109,6 @@ public class field002 { Field field2 = null; //====================================================== test program - //------------------------------------------------------ common section - - static Debugee debuggee; - static ArgumentHandler argsHandler; - - static int waitTime; - - static VirtualMachine vm = null; - static EventRequestManager eventRManager = null; - static EventQueue eventQueue = null; - static EventSet eventSet = null; - static EventIterator eventIterator = null; - - static ReferenceType debuggeeClass = null; - - static int testExitCode = PASSED; - - - //------------------------------------------------------ methods private int runThis (String argv[], PrintStream out) { @@ -364,97 +318,6 @@ public class field002 { return; } - /* - * private BreakpointRequest settingBreakpoint(ThreadReference, ReferenceType, - * String, String, String) - * - * It sets up a breakpoint at given line number within a given method in a given class - * for a given thread. - * - * Return value: BreakpointRequest object in case of success - * - * JDITestRuntimeException in case of an Exception thrown within the method - */ - - private BreakpointRequest settingBreakpoint ( ThreadReference thread, - ReferenceType testedClass, - String methodName, - String bpLine, - String property) - throws JDITestRuntimeException { - - log2("......setting up a breakpoint:"); - log2(" thread: " + thread + "; class: " + testedClass + - "; method: " + methodName + "; line: " + bpLine); - - List alllineLocations = null; - Location lineLocation = null; - BreakpointRequest breakpRequest = null; - - try { - Method method = (Method) testedClass.methodsByName(methodName).get(0); - - alllineLocations = method.allLineLocations(); - - int n = - ( (IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine) ) ).value(); - if (n > alllineLocations.size()) { - log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); - } else { - lineLocation = (Location) alllineLocations.get(n); - try { - breakpRequest = eventRManager.createBreakpointRequest(lineLocation); - breakpRequest.putProperty("number", property); - breakpRequest.addThreadFilter(thread); - breakpRequest.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD); - } catch ( Exception e1 ) { - log3("ERROR: inner Exception within settingBreakpoint() : " + e1); - breakpRequest = null; - } - } - } catch ( Exception e2 ) { - log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); - breakpRequest = null; - } - - if (breakpRequest == null) { - log2(" A BREAKPOINT HAS NOT BEEN SET UP"); - throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); - } - - log2(" a breakpoint has been set up"); - return breakpRequest; - } - - - private void getEventSet() - throws JDITestRuntimeException { - try { -// log2(" eventSet = eventQueue.remove(waitTime);"); - eventSet = eventQueue.remove(waitTime); - if (eventSet == null) { - throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); - } -// log2(" eventIterator = eventSet.eventIterator;"); - eventIterator = eventSet.eventIterator(); - } catch ( Exception e ) { - throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); - } - } - - - private void breakpointForCommunication() - throws JDITestRuntimeException { - - log2("breakpointForCommunication"); - getEventSet(); - - if (eventIterator.nextEvent() instanceof BreakpointEvent) - return; - - throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); - } - // ============================== test's additional methods private ModificationWatchpointRequest setting21ModificationWatchpointRequest ( diff --git a/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/JDIBase.java b/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/JDIBase.java new file mode 100644 index 00000000000..9d0950e260c --- /dev/null +++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jdi/JDIBase.java @@ -0,0 +1,167 @@ +/* + * 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 nsk.share.jdi; + +import com.sun.jdi.IntegerValue; +import com.sun.jdi.Location; +import com.sun.jdi.Method; +import com.sun.jdi.ReferenceType; +import com.sun.jdi.ThreadReference; +import com.sun.jdi.VirtualMachine; +import com.sun.jdi.event.BreakpointEvent; +import com.sun.jdi.event.Event; +import com.sun.jdi.event.EventIterator; +import com.sun.jdi.event.EventQueue; +import com.sun.jdi.event.EventSet; +import com.sun.jdi.request.BreakpointRequest; +import com.sun.jdi.request.EventRequest; +import com.sun.jdi.request.EventRequestManager; +import java.util.List; +import nsk.share.Log; + +public class JDIBase { + + // Exit code constants + public static final int PASSED = 0; + public static final int FAILED = 2; + public static final int PASS_BASE = 95; + + + // Log helpers + private final String sHeader1 = "\n=> " + this.getClass().getName().replace(".", "/") + " "; + + private static final String + sHeader2 = "--> debugger: ", + sHeader3 = "##> debugger: "; + + public final void log1(String message) { + logHandler.display(sHeader1 + message); + } + + public final void log2(String message) { + logHandler.display(sHeader2 + message); + } + + public final void log3(String message) { + logHandler.complain(sHeader3 + message); + } + + protected Log logHandler; + + // common variables used by tests + protected Debugee debuggee; + protected ArgumentHandler argsHandler; + protected VirtualMachine vm; + protected ReferenceType debuggeeClass; + protected static int testExitCode = PASSED; + protected long waitTime; + + // used by tests with breakpoint communication + protected EventRequestManager eventRManager; + protected EventQueue eventQueue; + protected EventSet eventSet; + protected EventIterator eventIterator; + + // additional fields initialized during breakpoint communication + protected Location breakpLocation = null; + protected BreakpointEvent bpEvent; + + protected final BreakpointRequest settingBreakpoint(ThreadReference thread, + ReferenceType testedClass, + String methodName, + String bpLine, + String property) + throws JDITestRuntimeException { + + log2("......setting up a breakpoint:"); + log2(" thread: " + thread + "; class: " + testedClass + + "; method: " + methodName + "; line: " + bpLine); + + List alllineLocations = null; + Location lineLocation = null; + BreakpointRequest breakpRequest = null; + + try { + Method method = (Method) testedClass.methodsByName(methodName).get(0); + + alllineLocations = method.allLineLocations(); + + int n = + ((IntegerValue) testedClass.getValue(testedClass.fieldByName(bpLine))).value(); + if (n > alllineLocations.size()) { + log3("ERROR: TEST_ERROR_IN_settingBreakpoint(): number is out of bound of method's lines"); + } else { + lineLocation = (Location) alllineLocations.get(n); + breakpLocation = lineLocation; + try { + breakpRequest = eventRManager.createBreakpointRequest(lineLocation); + breakpRequest.putProperty("number", property); + breakpRequest.addThreadFilter(thread); + breakpRequest.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD); + } catch (Exception e1) { + log3("ERROR: inner Exception within settingBreakpoint() : " + e1); + breakpRequest = null; + } + } + } catch (Exception e2) { + log3("ERROR: ATTENTION: outer Exception within settingBreakpoint() : " + e2); + breakpRequest = null; + } + + if (breakpRequest == null) { + log2(" A BREAKPOINT HAS NOT BEEN SET UP"); + throw new JDITestRuntimeException("**FAILURE to set up a breakpoint**"); + } + + log2(" a breakpoint has been set up"); + return breakpRequest; + } + + protected final void getEventSet() throws JDITestRuntimeException { + try { + eventSet = eventQueue.remove(waitTime); + if (eventSet == null) { + throw new JDITestRuntimeException("** TIMEOUT while waiting for event **"); + } + eventIterator = eventSet.eventIterator(); + } catch (Exception e) { + throw new JDITestRuntimeException("** EXCEPTION while waiting for event ** : " + e); + } + } + + protected void breakpointForCommunication() throws JDITestRuntimeException { + + log2("breakpointForCommunication"); + getEventSet(); + + Event event = eventIterator.nextEvent(); + if (event instanceof BreakpointEvent) { + bpEvent = (BreakpointEvent) event; + return; + } + + throw new JDITestRuntimeException("** event IS NOT a breakpoint **"); + } + +} From 600319b68a62083e3377224ce27e1e2b00ebfd99 Mon Sep 17 00:00:00 2001 From: Erik Gahlin Date: Mon, 4 May 2020 23:16:44 +0200 Subject: [PATCH 23/88] 8244149: jdk/jfr/api/consumer/recordingstream/TestOnEvent.java times out Reviewed-by: mgronlun --- .../consumer/recordingstream/TestOnEvent.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnEvent.java b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnEvent.java index 85b7d2e593a..806908d324a 100644 --- a/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnEvent.java +++ b/test/jdk/jdk/jfr/api/consumer/recordingstream/TestOnEvent.java @@ -26,6 +26,7 @@ package jdk.jfr.api.consumer.recordingstream; import java.util.concurrent.CountDownLatch; +import java.util.concurrent.atomic.AtomicBoolean; import jdk.jfr.Event; import jdk.jfr.Name; @@ -96,7 +97,7 @@ public class TestOnEvent { System.out.println("testTwoEventWithSameName" + e); eventA.countDown(); }); - r.startAsync(); + start(r); EventA a1 = new EventA(); a1.commit(); EventAlsoA a2 = new EventAlsoA(); @@ -124,7 +125,7 @@ public class TestOnEvent { } }); - r.startAsync(); + start(r); EventA a = new EventA(); a.commit(); EventC c = new EventC(); @@ -142,7 +143,7 @@ public class TestOnEvent { r.onEvent(e -> { event.countDown(); }); - r.startAsync(); + start(r); EventA a = new EventA(); a.commit(); event.await(); @@ -172,6 +173,18 @@ public class TestOnEvent { } } + // Starts recording stream and ensures stream + // is receiving events before method returns. + private static void start(RecordingStream rs) throws InterruptedException { + CountDownLatch started = new CountDownLatch(1); + rs.onFlush(() -> { + if (started.getCount() > 0) { + started.countDown(); + } + }); + rs.startAsync(); + started.await(); + } private static void log(String msg) { System.out.println(msg); From a8edd11d7a792e4c73d6fa5b1d6385c8bbe529c8 Mon Sep 17 00:00:00 2001 From: Sibabrata Sahoo Date: Mon, 4 May 2020 23:07:04 -0700 Subject: [PATCH 24/88] 8242335: Additional Tests for RSASSA-PSS New Tests for RSASSA-PSS Reviewed-by: valeriep --- .../security/rsa/pss/PSSKeyCompatibility.java | 279 ++++++++++++++++++ .../security/rsa/pss/SerializedPSSKey.java | 260 ++++++++++++++++ 2 files changed, 539 insertions(+) create mode 100644 test/jdk/sun/security/rsa/pss/PSSKeyCompatibility.java create mode 100644 test/jdk/sun/security/rsa/pss/SerializedPSSKey.java diff --git a/test/jdk/sun/security/rsa/pss/PSSKeyCompatibility.java b/test/jdk/sun/security/rsa/pss/PSSKeyCompatibility.java new file mode 100644 index 00000000000..4961a2a2ad8 --- /dev/null +++ b/test/jdk/sun/security/rsa/pss/PSSKeyCompatibility.java @@ -0,0 +1,279 @@ +/* + * 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. + */ + +import java.io.ByteArrayInputStream; +import java.security.Key; +import java.security.KeyFactory; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.interfaces.RSAPrivateCrtKey; +import java.security.interfaces.RSAPublicKey; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.PKCS8EncodedKeySpec; +import java.security.spec.RSAPrivateCrtKeySpec; +import java.security.spec.RSAPublicKeySpec; +import java.security.spec.X509EncodedKeySpec; +import java.util.Arrays; +import java.util.Base64; + +/** + * @test + * @bug 8242335 + * @summary OpenSSL generated compatibility test with RSASSA-PSS Java. + * @run main PSSKeyCompatibility + */ +public class PSSKeyCompatibility { + + private static final String ALGO = "RSASSA-PSS"; + private static final String OID = "1.2.840.113549.1.1.10"; + private static final String PROVIDER = "SunRsaSign"; + + public static void main(String[] args) { + + boolean result = true; + for (String algo : new String[]{ALGO, OID}) { + System.out.println("With : " + algo); + result &= validateCert(algo, PROVIDER, PUBLIC_256); + result &= validateCert(algo, PROVIDER, PUBLIC_384); + result &= validateCert(algo, PROVIDER, PUBLIC_512); + + result &= validatePrivate(algo, PROVIDER, PRIVATE); + } + if (!result) { + throw new RuntimeException("Some test cases failed"); + } + } + + private static boolean validatePrivate(String algorithm, String provider, + String type) { + + try { + KeyFactory kf = KeyFactory.getInstance(algorithm, provider); + PKCS8EncodedKeySpec privSpec = new PKCS8EncodedKeySpec( + Base64.getMimeDecoder().decode(type)); + PrivateKey priv = kf.generatePrivate(privSpec); + + RSAPrivateCrtKey crtKey = (RSAPrivateCrtKey) priv; + PrivateKey priv1 = kf.generatePrivate(new RSAPrivateCrtKeySpec( + crtKey.getModulus(), + crtKey.getPublicExponent(), + crtKey.getPrivateExponent(), + crtKey.getPrimeP(), + crtKey.getPrimeQ(), + crtKey.getPrimeExponentP(), + crtKey.getPrimeExponentQ(), + crtKey.getCrtCoefficient(), + crtKey.getParams() + )); + equals(priv, priv1); + } catch (NoSuchAlgorithmException | InvalidKeySpecException + | NoSuchProviderException e) { + e.printStackTrace(System.out); + return false; + } + System.out.println("PASSED - validatePrivate"); + return true; + } + + private static boolean validateCert(String algorithm, String provider, + String type) { + + try { + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + Certificate cert = cf.generateCertificate( + new ByteArrayInputStream(type.getBytes())); + System.out.println(cert); + KeyFactory kf = KeyFactory.getInstance(algorithm, provider); + X509EncodedKeySpec pubSpec = kf.getKeySpec( + cert.getPublicKey(), X509EncodedKeySpec.class); + PublicKey pub = kf.generatePublic(pubSpec); + PublicKey pub1 = kf.generatePublic(new RSAPublicKeySpec( + ((RSAPublicKey) pub).getModulus(), + ((RSAPublicKey) pub).getPublicExponent(), + ((RSAPublicKey) pub).getParams())); + equals(cert.getPublicKey(), pub); + equals(pub, pub1); + } catch (CertificateException | NoSuchAlgorithmException + | InvalidKeySpecException | NoSuchProviderException e) { + e.printStackTrace(System.out); + return false; + } + System.out.println("PASSED - validateCert"); + return true; + } + + private static void equals(Key orig, Key gen) { + if (!orig.equals(gen) && orig.hashCode() != gen.hashCode() + && !Arrays.equals(orig.getEncoded(), gen.getEncoded())) { + throw new RuntimeException("Key mismatch found"); + } + } + + //rsa_pss_pss_sha256 + private static final String PRIVATE + = "MIIEvAIBADALBgkqhkiG9w0BAQoEggSoMIIEpAIBAAKCAQEAu1qb8PZ8vMrX08Gf\n" + + "y9mx7c5NHymdPIpdDvaiYkpRfYGXp3Jpx7A0Hq01QY0OUu+0sCd5IbiVoVGqM4cq\n" + + "r2e4eyYnbgJEF7Tg8Ipu70cOUCZLj/fYNAjvFjv4+lxQYRCZHUH+lWPDPtJWKELx\n" + + "iIsAL5tglfyrQrdWLaOiZKlJ49DrYKU6PYqELxdQ1lw3r8iBbgGJP2podGD0rMWw\n" + + "nGX4pl9C7dYA+FV2yDirpH+OMNGOqB5QCe2WcsMLMzLPxJxOpqU8lCuscXR0VZuV\n" + + "krgztGJcq4J0eqp05jvMWii4vW/KSIh9bndVmS2QIU7YArI8RMXtbSHdE0hXAkh+\n" + + "Phb6/QIDAQABAoIBAQC4gbJDKquLTYQhYXTaT4h/toSS5OuZfHXKz675d1ErdZ2B\n" + + "ZRaxdmDNuSxSYvSxTqm2NRmA0QRiu0cPudSaq12twdRg7VBbvGEt4lb/xA1fd2dA\n" + + "4AcGr6mtTuCSxqjN/oebnat3OalFS+VXfx3Yp3NGbxE+hHewm1b+WUELOwCunhYw\n" + + "WJxs5dR0APiqzknveFgkOSDRbMYhwN6ZIrAmZH0wkGI7ufssnp9LEVDkoQCaFHlW\n" + + "bUpBHV1YxMCgAD/Azoo7MtedoO/+qnu1h26VhMVMCQL1DymZAnWd5kXumP9PG9j9\n" + + "z2JwIdYc7wkLVoSHJmjuXn/Sa/X7YCTGNk5Qwp/tAoGBAPJIWN3b6FPasnAevD2O\n" + + "04l1nnNrjNmu7aMGTTH5CrDseI7y/nqbSC18pOivRLmvhkON26I/Gu8GPKBteZAV\n" + + "OHKPc4RM11nvv9CyN4yDp0g76pPXLPXRRN/HV0RfBkmaiE6rpS07ue8FDUZmqb9+\n" + + "T8LV2eCYL7gYnIxsctzEQ8tXAoGBAMX2H7wpZVqHlGW94FF2pLp82q2cP80PBD+Z\n" + + "TglUVHy957EGPqEzxAWf3saORMDXyme7o0eSHJ1tikNTqAb+//zg5JexNEZSv6cR\n" + + "trAxuUT7kgjdJaD2i2BjlJyGG6fiXHcxC8lBvnFiWrC+qihTKDPdwWXdEOwzqCdL\n" + + "0eBbKAvLAoGAKDjah/p6F3G3LeXsWkvb0nY0V/UC7SCdUvM43ZL6s2SOnyy4EqK0\n" + + "2NhYiEiQoEMDhzOFwum3Dvd6GSgThlf/hwVJqC0Zk1S6A2uSzUEOBG/uAZ03WZfk\n" + + "V0JAupkL8iw1dNoKEfhYZdXw3j8s7x2JIE9gXGjngyiS1L0sVHpAxwECgYB78csS\n" + + "23RLB0JhpU2yk6812ABu3LqRoEpPq6PRcYxogdpz2u4RrkCYKO2psd/YQgPHiRMF\n" + + "N7VU2AXOe61jm/sZEJHvbBLHyP2YFB4nGSrfxwc7J4Ns0ZCYbCDbE5hzN+Ye9oVj\n" + + "oBcmFKelq+sLzm0IdFqndY8n5HvvBqjEaS6cmwKBgQDM5VsMKnGuqy5pozamgABu\n" + + "/z3f8ATzPVr85LiEWP7qB9Y1JIFuTma3IVlULtab2S4rhrHqQNy6qA6Be9fKKPwE\n" + + "TCmM/SDdolcz2d0rC2VDO+pc1RPluDpB/Ag8aHkV58azQASHHvAKBckIe7fay2t2\n" + + "j4FaKzM/ieY3WSapIbjf3w=="; + + /* + * Certificate: Data: Version: 3 (0x2) + * Serial Number: 11:4c:35:8c:63:47:91:1d:c1:c8:0f:c2:6f:d0:bd:8b:8f:89:e3:6c + * Signature Algorithm: rsassaPss + * Hash Algorithm: sha256 + * Mask Algorithm: mgf1 with sha256 + * Salt Length: 0xDE + * Trailer Field: 0xBC (default) + * Issuer: CN = localhost + * Validity Not Before: Apr 8 06:01:37 2020 GMT + * Not After : Apr 3 06:01:37 2040 GMT + * Subject: CN = localhost + * Subject Public Key Info: Public + * Key Algorithm: rsassaPss + * RSA-PSS Public-Key: (2048 bit) + */ + private static final String PUBLIC_256 = "-----BEGIN CERTIFICATE-----\n" + + "MIIDaTCCAiCgAwIBAgIUe9ijWtZJGfoH6whOTEIc+J/T1vswPgYJKoZIhvcNAQEK\n" + + "MDGgDTALBglghkgBZQMEAgGhGjAYBgkqhkiG9w0BAQgwCwYJYIZIAWUDBAIBogQC\n" + + "AgDeMBQxEjAQBgNVBAMMCWxvY2FsaG9zdDAeFw0yMDAzMTcwNjM4MDdaFw00MDAz\n" + + "MTIwNjM4MDdaMBQxEjAQBgNVBAMMCWxvY2FsaG9zdDCCASAwCwYJKoZIhvcNAQEK\n" + + "A4IBDwAwggEKAoIBAQC7Wpvw9ny8ytfTwZ/L2bHtzk0fKZ08il0O9qJiSlF9gZen\n" + + "cmnHsDQerTVBjQ5S77SwJ3khuJWhUaozhyqvZ7h7JiduAkQXtODwim7vRw5QJkuP\n" + + "99g0CO8WO/j6XFBhEJkdQf6VY8M+0lYoQvGIiwAvm2CV/KtCt1Yto6JkqUnj0Otg\n" + + "pTo9ioQvF1DWXDevyIFuAYk/amh0YPSsxbCcZfimX0Lt1gD4VXbIOKukf44w0Y6o\n" + + "HlAJ7ZZywwszMs/EnE6mpTyUK6xxdHRVm5WSuDO0YlyrgnR6qnTmO8xaKLi9b8pI\n" + + "iH1ud1WZLZAhTtgCsjxExe1tId0TSFcCSH4+Fvr9AgMBAAGjUzBRMB0GA1UdDgQW\n" + + "BBSDV090I9jEWvpjZ7fgO+GGocVgaDAfBgNVHSMEGDAWgBSDV090I9jEWvpjZ7fg\n" + + "O+GGocVgaDAPBgNVHRMBAf8EBTADAQH/MD4GCSqGSIb3DQEBCjAxoA0wCwYJYIZI\n" + + "AWUDBAIBoRowGAYJKoZIhvcNAQEIMAsGCWCGSAFlAwQCAaIEAgIA3gOCAQEAVl99\n" + + "g2F0H9YzEtvG5NjSGq8uCW5dLQd5DcXNfyfSLlUBwCTaZXncrc5/3DLYN1mWRQm2\n" + + "pCwmoGVzslwcLNENldTYogCc0Pc3YeG81wTBq0Tt6zS8RsDR3jhCFSDTVOjOoe0R\n" + + "kdYRd9d2pLg2ZOzAJXa6GLrFA+3Vv3dFFh8FhGB9CcVsyPQDzWhXQ0IwukHK+AMY\n" + + "6x1h12/CGQfrzBhrUtwbV+9iZN3lVsBYEFNKVz8Ca7H80YC4bsEHAHeR5nIUFk82\n" + + "kYuOBhcfC10oz+NdM1KbyAX8/4Uf7S3aBca27GTr1vP6tkmybonRHnZRoELNo1RQ\n" + + "wM0XPciACllEAJCVrQ==\n" + + "-----END CERTIFICATE-----"; + + /* + * Certificate: Data: Version: 3 (0x2) + * Serial Number: 32:f5:cf:23:71:d3:7f:16:10:5d:6e:c7:25:82:ee:7f:a8:ec:27:80 + * Signature Algorithm: rsassaPss + * Hash Algorithm: sha384 + * Mask Algorithm: mgf1 with sha384 + * Salt Length: 0xCE + * Trailer Field: 0xBC (default) + * Issuer: CN = localhost + * Validity Not Before: Apr 8 06:01:37 2020 GMT + * Not After : Apr 3 06:01:37 2040 GMT + * Subject: CN = localhost + * Subject Public Key Info: Public + * Key Algorithm: rsassaPss + * RSA-PSS Public-Key: (2048 bit) + */ + private static final String PUBLIC_384 = "-----BEGIN CERTIFICATE-----\n" + + "MIIDaTCCAiCgAwIBAgIUAeOnPMUidJHBqZbvhJWcH/05h0MwPgYJKoZIhvcNAQEK\n" + + "MDGgDTALBglghkgBZQMEAgKhGjAYBgkqhkiG9w0BAQgwCwYJYIZIAWUDBAICogQC\n" + + "AgDOMBQxEjAQBgNVBAMMCWxvY2FsaG9zdDAeFw0yMDAzMTcwNzI2MzFaFw00MDAz\n" + + "MTIwNzI2MzFaMBQxEjAQBgNVBAMMCWxvY2FsaG9zdDCCASAwCwYJKoZIhvcNAQEK\n" + + "A4IBDwAwggEKAoIBAQDPgUMdvdYOeVahvAp92RNG55plAlUyEdowNmIpEbyZOlEM\n" + + "Jc+7VqMt1K/+ZX1MkAGrFjV635p3c0NqI6qyv57cXA7VT92aYp9S0l4t7Cb2DQ6Y\n" + + "D+1jPNYTpYoMoI8ZPA486RGpnBtmRp9KRSkAoLS6AngCABE7OxuE0MrYKhbJ/8Lq\n" + + "Ss627FDXK+7aLCbEdLbr5G9BAIMEQDJAomHcqBMz5+EnEXWHc8drHFVIniHByFv3\n" + + "HmzDhFEMKCV9PbBXjgKdpMIAJsRXG3t1CBE/pEzILomgg3i4OHSUvEIzTApwTJvg\n" + + "UqtXi0UJqPohPViCQFeWLMa2N0pOAx1FMfdJIutLAgMBAAGjUzBRMB0GA1UdDgQW\n" + + "BBQBEi9rWGXrZObncP4StBKXB3baODAfBgNVHSMEGDAWgBQBEi9rWGXrZObncP4S\n" + + "tBKXB3baODAPBgNVHRMBAf8EBTADAQH/MD4GCSqGSIb3DQEBCjAxoA0wCwYJYIZI\n" + + "AWUDBAICoRowGAYJKoZIhvcNAQEIMAsGCWCGSAFlAwQCAqIEAgIAzgOCAQEADIQ6\n" + + "2ktTyS9+POWWe8yGEqW/q9DxL0NAqc0n4rYm5hs/8MKk1NMaqIku2xjE3T/16iFj\n" + + "3WEtj51yoSIUN0VxXPUoj3Yv5xR03huBk8gAwTpQc9psRQuGpLt9BBq0dyErQ8XR\n" + + "88SshQRpDEZ2yR4Tb+U5XfbWe70uCGfeG3iDMtZPAx2GnYBD+u3JaN/m7sr0cB8V\n" + + "Y8GuxWNh40aaIR0iaWbIC4b9N3wYDOa1yd8PqAKnLIs1F5CinJM6i5LmbkQpd+cK\n" + + "t13iaFYN26HuD3AywDQDvyYTwV7q5jcoEGAd35+pmKCdatEHlo0uLzbTGZw31Gfo\n" + + "BeSEh3vmXa1Q7SOpTQ==\n" + + "-----END CERTIFICATE-----"; + /* + * Certificate: Data: Version: 3 (0x2) + * Serial Number: 32:f5:cf:23:71:d3:7f:16:10:5d:6e:c7:25:82:ee:7f:a8:ec:27:80 + * Signature Algorithm: rsassaPss + * Hash Algorithm: sha512 + * Mask Algorithm: mgf1 with sha512 + * Salt Length: 0xBE + * Trailer Field: 0xBC (default) + * Issuer: CN = localhost + * Validity Not Before: Apr 8 06:01:37 2020 GMT + * Not After : Apr 3 06:01:37 2040 GMT + * Subject: CN = localhost + * Subject Public Key Info: Public + * Key Algorithm: rsassaPss + * RSA-PSS Public-Key: (2048 bit) + */ + private static final String PUBLIC_512 = "-----BEGIN CERTIFICATE-----\n" + + "MIIDaTCCAiCgAwIBAgIUMvXPI3HTfxYQXW7HJYLuf6jsJ4AwPgYJKoZIhvcNAQEK\n" + + "MDGgDTALBglghkgBZQMEAgOhGjAYBgkqhkiG9w0BAQgwCwYJYIZIAWUDBAIDogQC\n" + + "AgC+MBQxEjAQBgNVBAMMCWxvY2FsaG9zdDAeFw0yMDAzMTcwNzI4MjZaFw00MDAz\n" + + "MTIwNzI4MjZaMBQxEjAQBgNVBAMMCWxvY2FsaG9zdDCCASAwCwYJKoZIhvcNAQEK\n" + + "A4IBDwAwggEKAoIBAQCzuWpxs8c0JPgSykN9LM+2k0RlexrxCAlkgHRpfLI8XpV4\n" + + "Ak3hx9a045Ym1yyskNw7FjZVfWNgmx5Z8qQZvBykCL2iwDoMLEfoJTcE3cZEppaz\n" + + "3PqRoOVhuUGqA4jOW8WGbMi7aq/9UfTQGikxMBD7aS/ExILtAcd0N173ZARWcP0s\n" + + "68bRDLmTYAclZTWDZee0gAl8MHMnXSFFPotSbZOEWz4RqhpCa49tcx1BHgto3lyc\n" + + "ofzOerHpilZ/zAqOVRF2qHoZKlYTsTcSK0mE2MAfV7fk40qHYkyKbKLJVj8L8Lmc\n" + + "AFUNTx07bLYymgtqa07ei+kaVTJdlzDWiREgN8MNAgMBAAGjUzBRMB0GA1UdDgQW\n" + + "BBRlbX8E0L89iIOjkgLpbL/WSbuxmTAfBgNVHSMEGDAWgBRlbX8E0L89iIOjkgLp\n" + + "bL/WSbuxmTAPBgNVHRMBAf8EBTADAQH/MD4GCSqGSIb3DQEBCjAxoA0wCwYJYIZI\n" + + "AWUDBAIDoRowGAYJKoZIhvcNAQEIMAsGCWCGSAFlAwQCA6IEAgIAvgOCAQEAaRTy\n" + + "CmQxYkS5qCGQeJun/lFVLVE83Sl2kCBaJCMJdBYw38H+6DknJx/sjZwD1vO+OGj6\n" + + "1yyzQF1dv2Y5qOUrJIgw1ODkxTLMCrdotVqClazX02VGvyRe7efbjii96/9hqtxt\n" + + "TZwN7+8wUX6sP91z1vXVYD5sfl/qum/cWAVJEyw32h7RpUeB0rCJcIUrNqnbBziw\n" + + "SRkZof1Q2b02JRO0Pb3jV3H1MV5Agt3cFCCdsmvVq595rmYRwVMtyzCxXHb8jm+N\n" + + "8Fzhl9pxCCd4KIOGDAvngFZAloVsCHt+BG8jPhSxOldnFM7xGrGss2lLJnmf3YSe\n" + + "EPDF7NvA9wKPz4oyRg==\n" + + "-----END CERTIFICATE-----"; + +} diff --git a/test/jdk/sun/security/rsa/pss/SerializedPSSKey.java b/test/jdk/sun/security/rsa/pss/SerializedPSSKey.java new file mode 100644 index 00000000000..eb0bd1dde7a --- /dev/null +++ b/test/jdk/sun/security/rsa/pss/SerializedPSSKey.java @@ -0,0 +1,260 @@ +/* + * 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. + */ + +import static javax.crypto.Cipher.PRIVATE_KEY; +import static javax.crypto.Cipher.PUBLIC_KEY; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.security.InvalidKeyException; +import java.security.Key; +import java.security.KeyFactory; +import java.security.KeyPair; +import java.security.KeyPairGenerator; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.security.NoSuchProviderException; +import java.security.PrivateKey; +import java.security.PublicKey; +import java.security.Signature; +import java.security.interfaces.RSAPrivateCrtKey; +import java.security.interfaces.RSAPublicKey; +import java.security.spec.InvalidKeySpecException; +import java.security.spec.MGF1ParameterSpec; +import java.security.spec.PKCS8EncodedKeySpec; +import java.security.spec.PSSParameterSpec; +import java.security.spec.RSAKeyGenParameterSpec; +import java.security.spec.RSAPrivateCrtKeySpec; +import java.security.spec.RSAPublicKeySpec; +import java.security.spec.X509EncodedKeySpec; +import java.util.Arrays; + +/** + * @test @bug 8242335 + * @summary Test RSASSA-PSS serialized keys + * @run main SerializedPSSKey + */ +public class SerializedPSSKey { + + private static final String ALGO = "RSASSA-PSS"; + private static final String OID = "1.2.840.113549.1.1.10"; + private static final String PROVIDER = "SunRsaSign"; + private static final int KEY_SIZE = 2048; + private static final byte[] DATA = "Test".getBytes(); + /** + * Digest algorithms to test w/ RSASSA-PSS signature algorithms + */ + private static final String[] DIGEST_ALG = { + "SHA-1", "SHA-224", "SHA-256", "SHA-384", + "SHA-512", "SHA-512/224", "SHA-512/256" + }; + + public static void main(String[] args) throws Exception { + + for (String algo : new String[]{ALGO, OID}) { + KeyPairGenerator kpg = KeyPairGenerator.getInstance(algo, PROVIDER); + + // Algorithm-Independent Initialization + kpg.initialize(KEY_SIZE); + KeyPair kp = kpg.generateKeyPair(); + test(algo, kp, null); + for (String digest : DIGEST_ALG) { + PSSParameterSpec params = genPSSParameter(digest, KEY_SIZE); + // RSAKeyGenParameterSpec#1 Initialization + kpg.initialize(new RSAKeyGenParameterSpec(KEY_SIZE, + RSAKeyGenParameterSpec.F4, params)); + KeyPair kp2 = kpg.generateKeyPair(); + test(algo, kp2, params); + } + System.out.println("Successful with : " + algo); + } + } + + private static void test(String algo, KeyPair orig, PSSParameterSpec params) + throws Exception { + + Key[] privs = manipulateKey(algo, PRIVATE_KEY, orig.getPrivate()); + Key[] pubs = manipulateKey(algo, PUBLIC_KEY, orig.getPublic()); + for (Key pri : privs) { + for (Key pub : pubs) { + testSerialize(orig, new KeyPair( + (PublicKey) pub, (PrivateKey) pri)); + if (params != null) { + testSignature(algo, (PublicKey) pub, + (PrivateKey) pri, params); + } + } + } + } + + private static void testSignature(String algo, PublicKey pub, + PrivateKey priv, PSSParameterSpec params) throws Exception { + + Signature sig = Signature.getInstance(algo, PROVIDER); + sig.setParameter(params); + sig.initSign(priv); + sig.update(DATA); + byte[] signature = sig.sign(); + + sig.initVerify(pub); + sig.update(DATA); + if (!sig.verify(signature)) { + throw new RuntimeException("Signature verification failed"); + } + // Re-verify the signature with another Signature instance + Signature sig1 = Signature.getInstance(algo, PROVIDER); + sig1.setParameter(params); + sig1.initVerify(pub); + sig1.update(DATA); + if (!sig1.verify(signature)) { + throw new RuntimeException("Signature verification failed"); + } + } + + private static Key[] manipulateKey(String algo, int type, Key key) + throws NoSuchAlgorithmException, InvalidKeySpecException, + NoSuchProviderException, InvalidKeyException { + + KeyFactory kf = KeyFactory.getInstance(algo, PROVIDER); + switch (type) { + case PUBLIC_KEY: + return new Key[]{ + kf.generatePublic(kf.getKeySpec(key, RSAPublicKeySpec.class)), + kf.generatePublic(new X509EncodedKeySpec(key.getEncoded())), + kf.generatePublic(new RSAPublicKeySpec( + ((RSAPublicKey) key).getModulus(), + ((RSAPublicKey) key).getPublicExponent(), + ((RSAPublicKey) key).getParams())), + kf.translateKey(key) + }; + case PRIVATE_KEY: + RSAPrivateCrtKey crtKey = (RSAPrivateCrtKey) key; + return new Key[]{ + kf.generatePrivate( + kf.getKeySpec(key, RSAPrivateCrtKeySpec.class)), + kf.generatePrivate(new PKCS8EncodedKeySpec(key.getEncoded())), + kf.generatePrivate(new RSAPrivateCrtKeySpec( + crtKey.getModulus(), + crtKey.getPublicExponent(), + crtKey.getPrivateExponent(), + crtKey.getPrimeP(), + crtKey.getPrimeQ(), + crtKey.getPrimeExponentP(), + crtKey.getPrimeExponentQ(), + crtKey.getCrtCoefficient(), + crtKey.getParams() + )), + kf.translateKey(key) + }; + } + throw new RuntimeException("We shouldn't reach here"); + } + + private static PSSParameterSpec genPSSParameter(String digest, int keySize) + throws NoSuchAlgorithmException { + + int dgLen = MessageDigest.getInstance(digest).getDigestLength(); + // pick a salt length based on the key length and digestAlgo + int saltLength = keySize / 8 - dgLen - 2; + if (saltLength < 0) { + System.out.printf("keysize: %s, digestLen: %s%n", keySize / 8, dgLen); + return null; + } + return new PSSParameterSpec(digest, "MGF1", new MGF1ParameterSpec(digest), + saltLength, PSSParameterSpec.TRAILER_FIELD_BC); + } + + /** + * Compare original KeyPair with transformed ones. + */ + private static void testKeyEquals(KeyPair orig, PublicKey pubKey, + PrivateKey priKey) { + + if (!orig.getPrivate().equals(priKey) + && orig.getPrivate().hashCode() != priKey.hashCode() + && !Arrays.equals(orig.getPrivate().getEncoded(), + priKey.getEncoded())) { + throw new RuntimeException( + "PrivateKey is not equal with transformed one"); + } + if (!orig.getPublic().equals(pubKey) + && orig.getPublic().hashCode() != pubKey.hashCode() + && !Arrays.equals(orig.getPublic().getEncoded(), + pubKey.getEncoded())) { + throw new RuntimeException( + "PublicKey is not equal with transformed one"); + } + } + + /** + * Test serialization of KeyPair and Keys it holds. + */ + private static void testSerialize(KeyPair orig, KeyPair transformed) + throws Exception { + + testKeyEquals(orig, transformed.getPublic(), transformed.getPrivate()); + PrivateKey serializedPrivate = deserializedCopy(transformed.getPrivate(), + PrivateKey.class); + PublicKey serializedPublic = deserializedCopy(transformed.getPublic(), + PublicKey.class); + testKeyEquals(orig, serializedPublic, serializedPrivate); + // Verify Serialized KeyPair instance. + KeyPair copy = deserializedCopy(transformed, KeyPair.class); + testKeyEquals(orig, copy.getPublic(), copy.getPrivate()); + } + + private static T deserializedCopy(T orig, Class type) + throws IOException, ClassNotFoundException { + return deserialize(serialize(orig), type); + } + + /** + * Deserialize the Key object. + */ + private static T deserialize(byte[] serialized, + Class type) throws IOException, ClassNotFoundException { + + T key = null; + try (ByteArrayInputStream bis = new ByteArrayInputStream(serialized); + ObjectInputStream ois = new ObjectInputStream(bis)) { + key = (T) ois.readObject(); + } + return key; + } + + /** + * Serialize the given Key object. + */ + private static byte[] serialize(T key) + throws IOException { + + try (ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(bos)) { + oos.writeObject(key); + return bos.toByteArray(); + } + } + +} From 81597d9f8fbc40bb1a26ca9fe66ece3caf1c9dda Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Mon, 4 May 2020 21:20:39 +0200 Subject: [PATCH 25/88] 8244078: ProcessTools executeTestJvm and createJavaProcessBuilder have inconsistent handling of test.*.opts Reviewed-by: dholmes, cjplummer --- .../ClassAndLibraryNotMatchTest.java | 2 +- .../vmflags/BasicFlagsChange.java | 2 +- .../jtreg/compiler/ciReplay/CiReplayBase.java | 11 ++-- .../jtreg/compiler/ciReplay/SABase.java | 2 +- .../common/GraalUnitTestLauncher.java | 5 +- .../runtime/cr8015436/Driver8015436.java | 4 +- .../compiler/types/correctness/OffTest.java | 2 +- test/hotspot/jtreg/gc/TestAllocateHeapAt.java | 3 +- .../jtreg/gc/TestAllocateHeapAtError.java | 3 +- .../jtreg/gc/TestAllocateHeapAtMultiple.java | 2 +- .../jtreg/gc/TestVerifyDuringStartup.java | 3 +- .../jtreg/gc/arguments/GCArguments.java | 20 +++--- .../gc/arguments/TestUseNUMAInterleaving.java | 3 +- .../jtreg/gc/g1/TestShrinkAuxiliaryData.java | 2 +- .../jtreg/gc/g1/mixedgc/TestLogging.java | 3 +- .../jtreg/gc/logging/TestMetaSpaceLog.java | 3 +- .../jtreg/gc/nvdimm/TestAllocateOldGenAt.java | 2 +- .../gc/nvdimm/TestAllocateOldGenAtError.java | 2 +- .../nvdimm/TestAllocateOldGenAtMultiple.java | 2 +- .../nvdimm/TestHumongousObjectsOnNvdimm.java | 2 +- .../gc/nvdimm/TestOldObjectsOnNvdimm.java | 2 +- .../gc/nvdimm/TestYoungObjectsOnDram.java | 2 +- test/hotspot/jtreg/gc/whitebox/TestWBGC.java | 3 +- .../7162488/TestUnrecognizedVmOption.java | 2 +- .../BootstrapMethod/BSMCalledTwice.java | 2 +- .../UnsupportedClassFileVersion.java | 2 +- .../InvocationTests/invocationC1Tests.java | 2 +- .../InvocationTests/invocationGraalTests.java | 2 +- .../InvocationTests/invokeinterfaceTests.java | 2 +- .../InvocationTests/invokespecialTests.java | 2 +- .../InvocationTests/invokevirtualTests.java | 2 +- .../runtime/StackTrace/LargeClassTest.java | 2 +- .../jtreg/runtime/Unsafe/RangeCheck.java | 3 +- .../jtreg/runtime/cds/SharedArchiveFile.java | 6 +- .../runtime/cds/appcds/DumpClassList.java | 3 +- .../cds/appcds/GraalWithLimitedMetaspace.java | 4 +- .../jtreg/runtime/cds/appcds/TestCommon.java | 4 +- .../DynamicArchiveTestBase.java | 2 +- .../dynamicArchive/NoClassToArchive.java | 3 +- .../sharedStrings/SharedStringsBasic.java | 4 +- .../appcds/sharedStrings/SysDictCrash.java | 4 +- .../handshake/HandshakeTransitionTest.java | 3 +- .../PatchModule/PatchModuleClassList.java | 9 +-- .../jtreg/runtime/os/AvailableProcessors.java | 3 +- .../jtreg/runtime/os/TestUseCpuAllocPath.java | 3 +- .../jtreg/runtime/verifier/OverriderMsg.java | 2 +- .../jtreg/runtime/verifier/TestANewArray.java | 6 +- .../runtime/verifier/TestMultiANewArray.java | 2 +- .../jvmti/GetObjectSizeClass.java | 2 +- .../jvmti/GetObjectSizeOverflow.java | 2 +- .../logging/TestLogRotation.java | 3 +- .../serviceability/sa/ClhsdbCDSCore.java | 6 +- .../jtreg/serviceability/sa/TestJmapCore.java | 2 +- .../src/sun/hotspot/tools/ctw/CtwRunner.java | 4 +- .../lib/jittester/jtreg/JitTesterDriver.java | 2 +- .../jtreg/testlibrary_tests/ctw/CtwTest.java | 2 +- .../largeheap/MemOptions/MemOptionsTest.java | 4 +- .../jtreg/vmTestbase/jit/tiered/Test.java | 4 +- .../TestMaxMetaspaceSize.java | 4 +- .../retransform003/TestDriver.java | 3 +- .../SetNativeMethodPrefix002/TestDriver.java | 3 +- .../vm/compiler/CodeCacheInfo/Test.java | 4 +- .../CodeCacheInfoOnCompilation/Test.java | 2 +- test/jdk/com/sun/jdi/JITDebug.java | 2 +- .../jdk/com/sun/jdi/PrivateTransportTest.java | 2 +- test/jdk/com/sun/jdi/cds/CDSJDITest.java | 2 +- test/jdk/com/sun/jdi/lib/jdb/Debuggee.java | 9 +-- test/jdk/java/io/File/MacPath.java | 2 +- .../RenamePackage/RenamePackageTest.java | 4 +- .../shutdown/ShutdownInterruptedMain.java | 4 +- .../java/lang/StackWalker/CallerFromMain.java | 2 +- .../System/MacEncoding/MacJNUEncoding.java | 2 +- .../TestDaemonThreadLauncher.java | 2 +- .../charset/Charset/DefaultCharsetTest.java | 2 +- test/jdk/java/nio/file/Path/MacPathTest.java | 2 +- .../streaming/TestCrossProcessStreaming.java | 2 +- .../api/consumer/streaming/TestProcess.java | 2 +- .../jdk/jfr/event/runtime/TestDumpReason.java | 3 +- .../jfr/event/runtime/TestShutdownEvent.java | 2 +- test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java | 2 +- test/jdk/jdk/jfr/jvm/TestJfrJavaBase.java | 2 +- .../jdk/jfr/startupargs/TestDumpOnExit.java | 2 +- .../jfr/startupargs/TestMemoryOptions.java | 24 ++++--- .../TestMultipleStartupRecordings.java | 8 +-- .../startupargs/TestRetransformUsingLog.java | 2 +- .../jfr/startupargs/TestStartDuration.java | 4 +- .../jdk/jfr/startupargs/TestStartName.java | 2 +- .../ssl/SSLEngineImpl/SSLEngineKeyLimit.java | 2 +- .../ResumptionUpdateBoundValues.java | 2 +- .../ssl/SSLSocketImpl/SSLSocketKeyLimit.java | 2 +- test/lib/jdk/test/lib/cds/CDSTestUtils.java | 4 +- .../jdk/test/lib/jfr/AppExecutorHelper.java | 2 +- .../jdk/test/lib/process/ProcessTools.java | 62 ++++++++++--------- 93 files changed, 170 insertions(+), 205 deletions(-) diff --git a/test/hotspot/jtreg/compiler/aot/verification/ClassAndLibraryNotMatchTest.java b/test/hotspot/jtreg/compiler/aot/verification/ClassAndLibraryNotMatchTest.java index 23acef2236c..e1640841cd1 100644 --- a/test/hotspot/jtreg/compiler/aot/verification/ClassAndLibraryNotMatchTest.java +++ b/test/hotspot/jtreg/compiler/aot/verification/ClassAndLibraryNotMatchTest.java @@ -92,7 +92,7 @@ public class ClassAndLibraryNotMatchTest { private void runAndCheckHelloWorld(String checkString) { ProcessBuilder pb; try { - pb = ProcessTools.createJavaProcessBuilder(true, "-cp", ".", + pb = ProcessTools.createTestJvm("-cp", ".", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseAOT", "-XX:AOTLibrary=./" + LIB_NAME, HELLO_WORLD_CLASS_NAME); } catch (Exception e) { diff --git a/test/hotspot/jtreg/compiler/aot/verification/vmflags/BasicFlagsChange.java b/test/hotspot/jtreg/compiler/aot/verification/vmflags/BasicFlagsChange.java index c52a6f5f7f9..e2ca3784913 100644 --- a/test/hotspot/jtreg/compiler/aot/verification/vmflags/BasicFlagsChange.java +++ b/test/hotspot/jtreg/compiler/aot/verification/vmflags/BasicFlagsChange.java @@ -87,7 +87,7 @@ public class BasicFlagsChange { so, a message like "skipped $pathTolibrary aot library" or "loaded $pathToLibrary aot library" is present for cases of incompatible or compatible flags respectively */ - pb = ProcessTools.createJavaProcessBuilder(true, "-XX:+UnlockExperimentalVMOptions", + pb = ProcessTools.createTestJvm("-XX:+UnlockExperimentalVMOptions", "-XX:+UseAOT", "-XX:+PrintAOT", "-XX:AOTLibrary=./" + libName, option, HelloWorldPrinter.class.getName()); } catch (Exception ex) { diff --git a/test/hotspot/jtreg/compiler/ciReplay/CiReplayBase.java b/test/hotspot/jtreg/compiler/ciReplay/CiReplayBase.java index 0bbdc58b181..818ab4ee5d3 100644 --- a/test/hotspot/jtreg/compiler/ciReplay/CiReplayBase.java +++ b/test/hotspot/jtreg/compiler/ciReplay/CiReplayBase.java @@ -142,11 +142,10 @@ public abstract class CiReplayBase { options.add(needCoreDump ? ENABLE_COREDUMP_ON_CRASH : DISABLE_COREDUMP_ON_CRASH); options.add(EmptyMain.class.getName()); if (needCoreDump) { - crashOut = ProcessTools.executeProcess(getTestJavaCommandlineWithPrefix( + crashOut = ProcessTools.executeProcess(getTestJvmCommandlineWithPrefix( RUN_SHELL_NO_LIMIT, options.toArray(new String[0]))); } else { - crashOut = ProcessTools.executeProcess(ProcessTools.createJavaProcessBuilder(true, - options)); + crashOut = ProcessTools.executeProcess(ProcessTools.createTestJvm(options)); } crashOutputString = crashOut.getOutput(); Asserts.assertNotEquals(crashOut.getExitValue(), 0, "Crash JVM exits gracefully"); @@ -190,7 +189,7 @@ public abstract class CiReplayBase { List allAdditionalOpts = new ArrayList<>(); allAdditionalOpts.addAll(Arrays.asList(REPLAY_OPTIONS)); allAdditionalOpts.addAll(Arrays.asList(additionalVmOpts)); - OutputAnalyzer oa = ProcessTools.executeProcess(getTestJavaCommandlineWithPrefix( + OutputAnalyzer oa = ProcessTools.executeProcess(getTestJvmCommandlineWithPrefix( RUN_SHELL_ZERO_LIMIT, allAdditionalOpts.toArray(new String[0]))); return oa.getExitValue(); } catch (Throwable t) { @@ -290,9 +289,9 @@ public abstract class CiReplayBase { return null; } - private String[] getTestJavaCommandlineWithPrefix(String prefix, String... args) { + private String[] getTestJvmCommandlineWithPrefix(String prefix, String... args) { try { - String cmd = ProcessTools.getCommandLine(ProcessTools.createJavaProcessBuilder(true, args)); + String cmd = ProcessTools.getCommandLine(ProcessTools.createTestJvm(args)); return new String[]{"sh", "-c", prefix + (Platform.isWindows() ? cmd.replace('\\', '/').replace(";", "\\;").replace("|", "\\|") : cmd)}; } catch(Throwable t) { diff --git a/test/hotspot/jtreg/compiler/ciReplay/SABase.java b/test/hotspot/jtreg/compiler/ciReplay/SABase.java index bf0340d731e..017226185dd 100644 --- a/test/hotspot/jtreg/compiler/ciReplay/SABase.java +++ b/test/hotspot/jtreg/compiler/ciReplay/SABase.java @@ -57,7 +57,7 @@ public class SABase extends CiReplayBase { } ProcessBuilder pb; try { - pb = ProcessTools.createJavaProcessBuilder(true, "--add-modules", "jdk.hotspot.agent", + pb = ProcessTools.createTestJvm("--add-modules", "jdk.hotspot.agent", "--add-exports=jdk.hotspot.agent/sun.jvm.hotspot=ALL-UNNAMED", "sun.jvm.hotspot.CLHSDB", JDKToolFinder.getTestJDKTool("java"), TEST_CORE_FILE_NAME); diff --git a/test/hotspot/jtreg/compiler/graalunit/common/GraalUnitTestLauncher.java b/test/hotspot/jtreg/compiler/graalunit/common/GraalUnitTestLauncher.java index 89f50ab3f1f..e84529d8a9f 100644 --- a/test/hotspot/jtreg/compiler/graalunit/common/GraalUnitTestLauncher.java +++ b/test/hotspot/jtreg/compiler/graalunit/common/GraalUnitTestLauncher.java @@ -113,7 +113,7 @@ public class GraalUnitTestLauncher { String classPath = String.join(File.pathSeparator, System.getProperty("java.class.path"), String.join(File.separator, libsDir, MXTOOL_JARFILE)); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false, + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-cp", classPath, "com.oracle.mxtool.junit.FindClassesByAnnotatedMethods", graalUnitTestFilePath, testAnnotationName); @@ -277,8 +277,7 @@ public class GraalUnitTestLauncher { javaFlags.add("@"+GENERATED_TESTCLASSES_FILENAME); - ProcessBuilder javaPB = ProcessTools.createJavaProcessBuilder(true, - javaFlags); + ProcessBuilder javaPB = ProcessTools.createTestJvm(javaFlags); // Some tests rely on MX_SUBPROCESS_COMMAND_FILE env variable which contains // name of the file with java executable and java args used to launch the current process. diff --git a/test/hotspot/jtreg/compiler/runtime/cr8015436/Driver8015436.java b/test/hotspot/jtreg/compiler/runtime/cr8015436/Driver8015436.java index 79c4eb8971a..36f4266c7d5 100644 --- a/test/hotspot/jtreg/compiler/runtime/cr8015436/Driver8015436.java +++ b/test/hotspot/jtreg/compiler/runtime/cr8015436/Driver8015436.java @@ -30,8 +30,8 @@ public class Driver8015436 { public static void main(String args[]) { OutputAnalyzer oa; try { - oa = ProcessTools.executeProcess(ProcessTools.createJavaProcessBuilder( - /* add test vm options */ true, Test8015436.class.getName())); + oa = ProcessTools.executeProcess(ProcessTools.createTestJvm( + Test8015436.class.getName())); } catch (Exception ex) { throw new Error("TESTBUG: exception while running child process: " + ex, ex); } diff --git a/test/hotspot/jtreg/compiler/types/correctness/OffTest.java b/test/hotspot/jtreg/compiler/types/correctness/OffTest.java index d84e55f5dfd..c1cc848249d 100644 --- a/test/hotspot/jtreg/compiler/types/correctness/OffTest.java +++ b/test/hotspot/jtreg/compiler/types/correctness/OffTest.java @@ -86,7 +86,7 @@ public class OffTest { OPTIONS[TYPE_PROFILE_INDEX] = typeProfileLevel; OPTIONS[USE_TYPE_SPECULATION_INDEX] = useTypeSpeculation; OPTIONS[PROFILING_TYPE_INDEX] = type.name(); - ProcessBuilder processBuilder = ProcessTools.createJavaProcessBuilder(/* addTestVmOptions= */ true, OPTIONS); + ProcessBuilder processBuilder = ProcessTools.createTestJvm(OPTIONS); OutputAnalyzer outputAnalyzer = new OutputAnalyzer(processBuilder.start()); outputAnalyzer.shouldHaveExitValue(0); } diff --git a/test/hotspot/jtreg/gc/TestAllocateHeapAt.java b/test/hotspot/jtreg/gc/TestAllocateHeapAt.java index e83401f89d4..cda602948c5 100644 --- a/test/hotspot/jtreg/gc/TestAllocateHeapAt.java +++ b/test/hotspot/jtreg/gc/TestAllocateHeapAt.java @@ -40,8 +40,7 @@ import java.util.Collections; public class TestAllocateHeapAt { public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - true, + ProcessBuilder pb = ProcessTools.createTestJvm( "-XX:AllocateHeapAt=" + System.getProperty("test.dir", "."), "-Xlog:gc+heap=info", "-Xmx32m", diff --git a/test/hotspot/jtreg/gc/TestAllocateHeapAtError.java b/test/hotspot/jtreg/gc/TestAllocateHeapAtError.java index 4304044bd5d..8dd48deda39 100644 --- a/test/hotspot/jtreg/gc/TestAllocateHeapAtError.java +++ b/test/hotspot/jtreg/gc/TestAllocateHeapAtError.java @@ -46,8 +46,7 @@ public class TestAllocateHeapAtError { f = new File(test_dir, UUID.randomUUID().toString()); } while(f.exists()); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - true, + ProcessBuilder pb = ProcessTools.createTestJvm( "-XX:AllocateHeapAt=" + f.getName(), "-Xlog:gc+heap=info", "-Xmx32m", diff --git a/test/hotspot/jtreg/gc/TestAllocateHeapAtMultiple.java b/test/hotspot/jtreg/gc/TestAllocateHeapAtMultiple.java index 6d2f914a355..438b92f8a80 100644 --- a/test/hotspot/jtreg/gc/TestAllocateHeapAtMultiple.java +++ b/test/hotspot/jtreg/gc/TestAllocateHeapAtMultiple.java @@ -62,7 +62,7 @@ public class TestAllocateHeapAtMultiple { "-Xlog:gc+heap=info", "-version"}); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, flags); + ProcessBuilder pb = ProcessTools.createTestJvm(flags); OutputAnalyzer output = new OutputAnalyzer(pb.start()); System.out.println("Output:\n" + output.getOutput()); diff --git a/test/hotspot/jtreg/gc/TestVerifyDuringStartup.java b/test/hotspot/jtreg/gc/TestVerifyDuringStartup.java index 0893754a2b0..78d9085de8e 100644 --- a/test/hotspot/jtreg/gc/TestVerifyDuringStartup.java +++ b/test/hotspot/jtreg/gc/TestVerifyDuringStartup.java @@ -38,8 +38,7 @@ import jdk.test.lib.process.OutputAnalyzer; public class TestVerifyDuringStartup { public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - true, + ProcessBuilder pb = ProcessTools.createTestJvm( "-XX:-UseTLAB", "-XX:+UnlockDiagnosticVMOptions", "-XX:+VerifyDuringStartup", diff --git a/test/hotspot/jtreg/gc/arguments/GCArguments.java b/test/hotspot/jtreg/gc/arguments/GCArguments.java index 2c9dcdf11b7..b2610da0c4e 100644 --- a/test/hotspot/jtreg/gc/arguments/GCArguments.java +++ b/test/hotspot/jtreg/gc/arguments/GCArguments.java @@ -67,22 +67,18 @@ public final class GCArguments { } static public ProcessBuilder createJavaProcessBuilder(List arguments) { - return createJavaProcessBuilder(false, arguments); - } - - static public ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions, - List arguments) { - return createJavaProcessBuilder(addTestVmAndJavaOptions, - arguments.toArray(String[]::new)); + return createJavaProcessBuilder(arguments.toArray(String[]::new)); } static public ProcessBuilder createJavaProcessBuilder(String... arguments) { - return createJavaProcessBuilder(false, arguments); + return ProcessTools.createJavaProcessBuilder(withDefaults(arguments)); } - static public ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions, - String... arguments) { - return ProcessTools.createJavaProcessBuilder(addTestVmAndJavaOptions, - withDefaults(arguments)); + static public ProcessBuilder createTestJvm(List arguments) { + return createTestJvm(arguments.toArray(String[]::new)); + } + + static public ProcessBuilder createTestJvm(String... arguments) { + return ProcessTools.createTestJvm(withDefaults(arguments)); } } diff --git a/test/hotspot/jtreg/gc/arguments/TestUseNUMAInterleaving.java b/test/hotspot/jtreg/gc/arguments/TestUseNUMAInterleaving.java index 9ca7049e1b0..cd632d6ea3a 100644 --- a/test/hotspot/jtreg/gc/arguments/TestUseNUMAInterleaving.java +++ b/test/hotspot/jtreg/gc/arguments/TestUseNUMAInterleaving.java @@ -41,8 +41,7 @@ import jdk.test.lib.process.ProcessTools; public class TestUseNUMAInterleaving { public static void main(String[] args) throws Exception { - ProcessBuilder pb = GCArguments.createJavaProcessBuilder( - true, + ProcessBuilder pb = GCArguments.createTestJvm( "-XX:+UseNUMA", "-XX:+PrintFlagsFinal", "-version"); diff --git a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java b/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java index 250aeb8e84c..ac9db0afaa2 100644 --- a/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java +++ b/test/hotspot/jtreg/gc/g1/TestShrinkAuxiliaryData.java @@ -102,7 +102,7 @@ public class TestShrinkAuxiliaryData { } private void performTest(List opts) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, opts); + ProcessBuilder pb = ProcessTools.createTestJvm(opts); OutputAnalyzer output = new OutputAnalyzer(pb.start()); System.out.println(output.getStdout()); diff --git a/test/hotspot/jtreg/gc/g1/mixedgc/TestLogging.java b/test/hotspot/jtreg/gc/g1/mixedgc/TestLogging.java index 2fd6f0f6488..a7cab355e61 100644 --- a/test/hotspot/jtreg/gc/g1/mixedgc/TestLogging.java +++ b/test/hotspot/jtreg/gc/g1/mixedgc/TestLogging.java @@ -90,8 +90,7 @@ public class TestLogging { Collections.addAll(testOpts, extraFlags); testOpts.add(RunMixedGC.class.getName()); System.out.println(testOpts); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false, - testOpts); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(testOpts); return new OutputAnalyzer(pb.start()); } } diff --git a/test/hotspot/jtreg/gc/logging/TestMetaSpaceLog.java b/test/hotspot/jtreg/gc/logging/TestMetaSpaceLog.java index 169f668695f..617ca9f8d06 100644 --- a/test/hotspot/jtreg/gc/logging/TestMetaSpaceLog.java +++ b/test/hotspot/jtreg/gc/logging/TestMetaSpaceLog.java @@ -84,8 +84,7 @@ public class TestMetaSpaceLog { String testSrc= "-Dtest.src=" + System.getProperty("test.src", "."); ProcessBuilder pb = - ProcessTools.createJavaProcessBuilder( - true, + ProcessTools.createTestJvm( "-Xlog:gc*", "-Xbootclasspath/a:.", "-XX:+UnlockDiagnosticVMOptions", diff --git a/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAt.java b/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAt.java index 5cd0378a33a..e668e05ece6 100644 --- a/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAt.java +++ b/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAt.java @@ -59,7 +59,7 @@ public class TestAllocateOldGenAt { ArrayList flags = new ArrayList<>(); Collections.addAll(flags, commonFlags); Collections.addAll(flags, extraFlags); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, flags); + ProcessBuilder pb = ProcessTools.createTestJvm(flags); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtError.java b/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtError.java index 54219fb6a89..6b8a9c91540 100644 --- a/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtError.java +++ b/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtError.java @@ -89,7 +89,7 @@ public class TestAllocateOldGenAtError { Collections.addAll(flags, commonFlags); Collections.addAll(flags, extraFlags); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, flags); + ProcessBuilder pb = ProcessTools.createTestJvm(flags); OutputAnalyzer output = new OutputAnalyzer(pb.start()); return output; } diff --git a/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtMultiple.java b/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtMultiple.java index c56e3824b7c..67d408881fa 100644 --- a/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtMultiple.java +++ b/test/hotspot/jtreg/gc/nvdimm/TestAllocateOldGenAtMultiple.java @@ -63,7 +63,7 @@ public class TestAllocateOldGenAtMultiple { Collections.addAll(flags, new String[] {"-XX:+UnlockExperimentalVMOptions", "-XX:AllocateOldGenAt=" + test_dir, "-version"}); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, flags); + ProcessBuilder pb = ProcessTools.createTestJvm(flags); OutputAnalyzer output = new OutputAnalyzer(pb.start()); System.out.println("Output:\n" + output.getOutput()); diff --git a/test/hotspot/jtreg/gc/nvdimm/TestHumongousObjectsOnNvdimm.java b/test/hotspot/jtreg/gc/nvdimm/TestHumongousObjectsOnNvdimm.java index 18cdc1f3b50..39a997fb9dc 100644 --- a/test/hotspot/jtreg/gc/nvdimm/TestHumongousObjectsOnNvdimm.java +++ b/test/hotspot/jtreg/gc/nvdimm/TestHumongousObjectsOnNvdimm.java @@ -72,7 +72,7 @@ public class TestHumongousObjectsOnNvdimm { Collections.addAll(flags, extraFlags); flags.add(HumongousObjectTest.class.getName()); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, flags); + ProcessBuilder pb = ProcessTools.createTestJvm(flags); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/gc/nvdimm/TestOldObjectsOnNvdimm.java b/test/hotspot/jtreg/gc/nvdimm/TestOldObjectsOnNvdimm.java index 20ec5e58c7c..c4193331537 100644 --- a/test/hotspot/jtreg/gc/nvdimm/TestOldObjectsOnNvdimm.java +++ b/test/hotspot/jtreg/gc/nvdimm/TestOldObjectsOnNvdimm.java @@ -71,7 +71,7 @@ public class TestOldObjectsOnNvdimm { Collections.addAll(flags, extraFlags); flags.add(OldObjectTest.class.getName()); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, flags); + ProcessBuilder pb = ProcessTools.createTestJvm(flags); OutputAnalyzer output = new OutputAnalyzer(pb.start()); System.out.println(output.getStdout()); diff --git a/test/hotspot/jtreg/gc/nvdimm/TestYoungObjectsOnDram.java b/test/hotspot/jtreg/gc/nvdimm/TestYoungObjectsOnDram.java index 35938f86b2c..6a1d9e6526b 100644 --- a/test/hotspot/jtreg/gc/nvdimm/TestYoungObjectsOnDram.java +++ b/test/hotspot/jtreg/gc/nvdimm/TestYoungObjectsOnDram.java @@ -72,7 +72,7 @@ public class TestYoungObjectsOnDram { Collections.addAll(flags, extraFlags); flags.add(YoungObjectTest.class.getName()); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, flags); + ProcessBuilder pb = ProcessTools.createTestJvm(flags); OutputAnalyzer output = new OutputAnalyzer(pb.start()); System.out.println(output.getStdout()); diff --git a/test/hotspot/jtreg/gc/whitebox/TestWBGC.java b/test/hotspot/jtreg/gc/whitebox/TestWBGC.java index 2667896208f..2d1cdbf26c4 100644 --- a/test/hotspot/jtreg/gc/whitebox/TestWBGC.java +++ b/test/hotspot/jtreg/gc/whitebox/TestWBGC.java @@ -43,8 +43,7 @@ import sun.hotspot.WhiteBox; public class TestWBGC { public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - true, + ProcessBuilder pb = ProcessTools.createTestJvm( "-Xbootclasspath/a:.", "-XX:+UnlockDiagnosticVMOptions", "-XX:+WhiteBoxAPI", diff --git a/test/hotspot/jtreg/runtime/7162488/TestUnrecognizedVmOption.java b/test/hotspot/jtreg/runtime/7162488/TestUnrecognizedVmOption.java index 68d40e24a92..c8526d6cbcb 100644 --- a/test/hotspot/jtreg/runtime/7162488/TestUnrecognizedVmOption.java +++ b/test/hotspot/jtreg/runtime/7162488/TestUnrecognizedVmOption.java @@ -36,7 +36,7 @@ public class TestUnrecognizedVmOption { public static void main(String[] args) throws Exception { ProcessBuilder pb = - ProcessTools.createJavaProcessBuilder(true, "-showversion", "-XX:" + OPTION); + ProcessTools.createTestJvm("-showversion", "-XX:" + OPTION); new OutputAnalyzer(pb.start()) .shouldNotHaveExitValue(0) .shouldContain("Unrecognized VM option") diff --git a/test/hotspot/jtreg/runtime/BootstrapMethod/BSMCalledTwice.java b/test/hotspot/jtreg/runtime/BootstrapMethod/BSMCalledTwice.java index ba9bb957b34..bad675a40ff 100644 --- a/test/hotspot/jtreg/runtime/BootstrapMethod/BSMCalledTwice.java +++ b/test/hotspot/jtreg/runtime/BootstrapMethod/BSMCalledTwice.java @@ -97,7 +97,7 @@ public class BSMCalledTwice implements Opcodes { }; cl.loadClass(classTestCName); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-cp", ".", classTestCName); + ProcessBuilder pb = ProcessTools.createTestJvm("-cp", ".", classTestCName); OutputAnalyzer output = new OutputAnalyzer(pb.start()); String test_output = output.getOutput(); if (test_output == null) { diff --git a/test/hotspot/jtreg/runtime/ClassFile/UnsupportedClassFileVersion.java b/test/hotspot/jtreg/runtime/ClassFile/UnsupportedClassFileVersion.java index 486bba9717c..255e5e402cc 100644 --- a/test/hotspot/jtreg/runtime/ClassFile/UnsupportedClassFileVersion.java +++ b/test/hotspot/jtreg/runtime/ClassFile/UnsupportedClassFileVersion.java @@ -42,7 +42,7 @@ import jdk.test.lib.process.OutputAnalyzer; public class UnsupportedClassFileVersion implements Opcodes { public static void main(String... args) throws Exception { writeClassFile(); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-cp", ".", "ClassFile"); + ProcessBuilder pb = ProcessTools.createTestJvm("-cp", ".", "ClassFile"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("ClassFile has been compiled by a more recent version of the " + "Java Runtime (class file version 99.0), this version of " + diff --git a/test/hotspot/jtreg/runtime/InvocationTests/invocationC1Tests.java b/test/hotspot/jtreg/runtime/InvocationTests/invocationC1Tests.java index 33f5a16849a..759f7440840 100644 --- a/test/hotspot/jtreg/runtime/InvocationTests/invocationC1Tests.java +++ b/test/hotspot/jtreg/runtime/InvocationTests/invocationC1Tests.java @@ -48,7 +48,7 @@ public class invocationC1Tests { public static void runTest(String whichTests, String classFileVersion) throws Throwable { System.out.println("\nC1 invocation tests, Tests: " + whichTests + ", class file version: " + classFileVersion); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false, "-Xmx128M", + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xmx128M", "-Xcomp", "-XX:TieredStopAtLevel=1", "--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED", whichTests, "--classfile_version=" + classFileVersion); diff --git a/test/hotspot/jtreg/runtime/InvocationTests/invocationGraalTests.java b/test/hotspot/jtreg/runtime/InvocationTests/invocationGraalTests.java index 2a9c5acb9fc..9c60973c67a 100644 --- a/test/hotspot/jtreg/runtime/InvocationTests/invocationGraalTests.java +++ b/test/hotspot/jtreg/runtime/InvocationTests/invocationGraalTests.java @@ -49,7 +49,7 @@ public class invocationGraalTests { public static void runTest(String whichTests, String classFileVersion) throws Throwable { System.out.println("\nGraal invocation tests, Tests: " + whichTests + ", class file version: " + classFileVersion); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false, "-Xmx128M", + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xmx128M", "-XX:+UnlockExperimentalVMOptions", "-XX:+EnableJVMCI", "-XX:+UseJVMCICompiler", "--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED", whichTests, "--classfile_version=" + classFileVersion); diff --git a/test/hotspot/jtreg/runtime/InvocationTests/invokeinterfaceTests.java b/test/hotspot/jtreg/runtime/InvocationTests/invokeinterfaceTests.java index 7260df737aa..5efccfeaa19 100644 --- a/test/hotspot/jtreg/runtime/InvocationTests/invokeinterfaceTests.java +++ b/test/hotspot/jtreg/runtime/InvocationTests/invokeinterfaceTests.java @@ -47,7 +47,7 @@ public class invokeinterfaceTests { public static void runTest(String classFileVersion, String option) throws Throwable { System.out.println("\ninvokeinterface invocation tests, option: " + option + ", class file version: " + classFileVersion); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false, "-Xmx128M", option, + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xmx128M", option, "--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED", "invokeinterface.Generator", "--classfile_version=" + classFileVersion); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/InvocationTests/invokespecialTests.java b/test/hotspot/jtreg/runtime/InvocationTests/invokespecialTests.java index 6563b10bd18..a37cca5681c 100644 --- a/test/hotspot/jtreg/runtime/InvocationTests/invokespecialTests.java +++ b/test/hotspot/jtreg/runtime/InvocationTests/invokespecialTests.java @@ -46,7 +46,7 @@ public class invokespecialTests { public static void runTest(String classFileVersion, String option) throws Throwable { System.out.println("\ninvokespecial invocation tests, option: " + option + ", class file version: " + classFileVersion); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false, "-Xmx128M", option, + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xmx128M", option, "--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED", "invokespecial.Generator", "--classfile_version=" + classFileVersion); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/InvocationTests/invokevirtualTests.java b/test/hotspot/jtreg/runtime/InvocationTests/invokevirtualTests.java index e9ee8e3a1eb..a8892ad42d7 100644 --- a/test/hotspot/jtreg/runtime/InvocationTests/invokevirtualTests.java +++ b/test/hotspot/jtreg/runtime/InvocationTests/invokevirtualTests.java @@ -46,7 +46,7 @@ public class invokevirtualTests { public static void runTest(String classFileVersion, String option) throws Throwable { System.out.println("\ninvokevirtual invocation tests, option: " + option + ", class file version: " + classFileVersion); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false, "-Xmx128M", option, + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xmx128M", option, "--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED", "invokevirtual.Generator", "--classfile_version=" + classFileVersion); OutputAnalyzer output = new OutputAnalyzer(pb.start()); diff --git a/test/hotspot/jtreg/runtime/StackTrace/LargeClassTest.java b/test/hotspot/jtreg/runtime/StackTrace/LargeClassTest.java index 79bb139a680..3909c159a41 100644 --- a/test/hotspot/jtreg/runtime/StackTrace/LargeClassTest.java +++ b/test/hotspot/jtreg/runtime/StackTrace/LargeClassTest.java @@ -46,7 +46,7 @@ import jdk.test.lib.process.OutputAnalyzer; public class LargeClassTest implements Opcodes { public static void main(String... args) throws Exception { writeClassFile(); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-cp", ".", "Large"); + ProcessBuilder pb = ProcessTools.createTestJvm("-cp", ".", "Large"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldHaveExitValue(0); } diff --git a/test/hotspot/jtreg/runtime/Unsafe/RangeCheck.java b/test/hotspot/jtreg/runtime/Unsafe/RangeCheck.java index 4b64ad388cb..31b6279b1b8 100644 --- a/test/hotspot/jtreg/runtime/Unsafe/RangeCheck.java +++ b/test/hotspot/jtreg/runtime/Unsafe/RangeCheck.java @@ -44,8 +44,7 @@ public class RangeCheck { return; } - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - true, + ProcessBuilder pb = ProcessTools.createTestJvm( "-Xmx128m", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", "-XX:-CreateCoredumpOnCrash", diff --git a/test/hotspot/jtreg/runtime/cds/SharedArchiveFile.java b/test/hotspot/jtreg/runtime/cds/SharedArchiveFile.java index 94a02f9c034..afee4a4d361 100644 --- a/test/hotspot/jtreg/runtime/cds/SharedArchiveFile.java +++ b/test/hotspot/jtreg/runtime/cds/SharedArchiveFile.java @@ -41,20 +41,20 @@ import jdk.test.lib.process.OutputAnalyzer; // methods to form command line to create/use shared archive. public class SharedArchiveFile { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, + ProcessBuilder pb = ProcessTools.createTestJvm( "-XX:SharedArchiveFile=./SharedArchiveFile.jsa", "-Xshare:dump", "-Xlog:cds"); OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, "SharedArchiveFile"); CDSTestUtils.checkDump(out); // -XX:+DumpSharedSpaces should behave the same as -Xshare:dump - pb = ProcessTools.createJavaProcessBuilder(true, + pb = ProcessTools.createTestJvm( "-XX:SharedArchiveFile=./SharedArchiveFile.jsa", "-XX:+DumpSharedSpaces", "-Xlog:cds"); out = CDSTestUtils.executeAndLog(pb, "SharedArchiveFile"); CDSTestUtils.checkDump(out); - pb = ProcessTools.createJavaProcessBuilder(true, + pb = ProcessTools.createTestJvm( "-XX:SharedArchiveFile=./SharedArchiveFile.jsa", "-Xshare:on", "-version"); out = CDSTestUtils.executeAndLog(pb, "SharedArchiveFile"); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/DumpClassList.java b/test/hotspot/jtreg/runtime/cds/appcds/DumpClassList.java index 6f5ded64d90..07101416f38 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/DumpClassList.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/DumpClassList.java @@ -74,8 +74,7 @@ public class DumpClassList { String appendJar = JarBuilder.build("bootappend", "boot/append/Foo"); // dump class list - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - true, + ProcessBuilder pb = ProcessTools.createTestJvm( "-XX:DumpLoadedClassList=" + classList, "--patch-module=java.base=" + patchJar, "-Xbootclasspath/a:" + appendJar, diff --git a/test/hotspot/jtreg/runtime/cds/appcds/GraalWithLimitedMetaspace.java b/test/hotspot/jtreg/runtime/cds/appcds/GraalWithLimitedMetaspace.java index bf72084e476..2abe40054b3 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/GraalWithLimitedMetaspace.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/GraalWithLimitedMetaspace.java @@ -83,7 +83,7 @@ public class GraalWithLimitedMetaspace { } static void dumpLoadedClasses(String[] expectedClasses) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, + ProcessBuilder pb = ProcessTools.createTestJvm( "-XX:DumpLoadedClassList=" + CLASSLIST_FILE, // trigger JVMCI runtime init so that JVMCI classes will be // included in the classlist @@ -110,7 +110,7 @@ public class GraalWithLimitedMetaspace { } static void dumpArchive() throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, + ProcessBuilder pb = ProcessTools.createTestJvm( "-cp", TESTJAR, "-XX:SharedClassListFile=" + CLASSLIST_FILE, diff --git a/test/hotspot/jtreg/runtime/cds/appcds/TestCommon.java b/test/hotspot/jtreg/runtime/cds/appcds/TestCommon.java index e2d2b5d60bc..6d79382720d 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/TestCommon.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/TestCommon.java @@ -238,7 +238,7 @@ public class TestCommon extends CDSTestUtils { } } - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmd); + ProcessBuilder pb = ProcessTools.createTestJvm(cmd); if (opts.appJarDir != null) { pb.directory(new File(opts.appJarDir)); } @@ -384,7 +384,7 @@ public class TestCommon extends CDSTestUtils { } } - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmd); + ProcessBuilder pb = ProcessTools.createTestJvm(cmd); if (opts.appJarDir != null) { pb.directory(new File(opts.appJarDir)); } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DynamicArchiveTestBase.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DynamicArchiveTestBase.java index 57056130e9a..d3208f7a058 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DynamicArchiveTestBase.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DynamicArchiveTestBase.java @@ -242,7 +242,7 @@ class DynamicArchiveTestBase { if (!executedIn_run) { throw new Exception("Test error: dynamic archive tests must be executed via DynamicArchiveTestBase.run()"); } - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmdLine); + ProcessBuilder pb = ProcessTools.createTestJvm(cmdLine); if (jarDir != null) { pb.directory(new File(jarDir)); } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/NoClassToArchive.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/NoClassToArchive.java index 0bfc9ba2feb..a8fe1c1f07b 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/NoClassToArchive.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/NoClassToArchive.java @@ -105,8 +105,7 @@ public class NoClassToArchive extends DynamicArchiveTestBase { private static void doTestCustomBase(String baseArchiveName, String topArchiveName) throws Exception { String appJar = ClassFileInstaller.getJarPath("strConcatApp.jar"); // dump class list by running the StrConcatApp - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - true, + ProcessBuilder pb = ProcessTools.createTestJvm( "-XX:DumpLoadedClassList=" + classList, "-cp", appJar, diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsBasic.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsBasic.java index 1fbb8767d68..d18ed40dfef 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsBasic.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsBasic.java @@ -50,7 +50,7 @@ public class SharedStringsBasic { String sharedArchiveConfigFile = TestCommon.getSourceFile("SharedStringsBasic.txt").toString(); - ProcessBuilder dumpPb = ProcessTools.createJavaProcessBuilder(true, + ProcessBuilder dumpPb = ProcessTools.createTestJvm( TestCommon.concat(vmOptionsPrefix, "-cp", appJar, "-XX:SharedArchiveConfigFile=" + sharedArchiveConfigFile, @@ -62,7 +62,7 @@ public class SharedStringsBasic { .shouldContain("Shared string table stats") .shouldHaveExitValue(0); - ProcessBuilder runPb = ProcessTools.createJavaProcessBuilder(true, + ProcessBuilder runPb = ProcessTools.createTestJvm( TestCommon.concat(vmOptionsPrefix, "-cp", appJar, "-XX:SharedArchiveFile=./SharedStringsBasic.jsa", diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SysDictCrash.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SysDictCrash.java index 7cdab2535cf..70d5fa6110f 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SysDictCrash.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SysDictCrash.java @@ -44,7 +44,7 @@ public class SysDictCrash { // SharedBaseAddress=0 puts the archive at a very high address on solaris, // which provokes the crash. - ProcessBuilder dumpPb = ProcessTools.createJavaProcessBuilder(true, + ProcessBuilder dumpPb = ProcessTools.createTestJvm( TestCommon.concat(vmOptionsPrefix, "-XX:+UseG1GC", "-XX:MaxRAMPercentage=12.5", "-cp", ".", @@ -69,7 +69,7 @@ public class SysDictCrash { return; } - ProcessBuilder runPb = ProcessTools.createJavaProcessBuilder(true, + ProcessBuilder runPb = ProcessTools.createTestJvm( TestCommon.concat(vmOptionsPrefix, "-XX:+UseG1GC", "-XX:MaxRAMPercentage=12.5", "-XX:SharedArchiveFile=./SysDictCrash.jsa", diff --git a/test/hotspot/jtreg/runtime/handshake/HandshakeTransitionTest.java b/test/hotspot/jtreg/runtime/handshake/HandshakeTransitionTest.java index 93891f58357..8c6112d5ab6 100644 --- a/test/hotspot/jtreg/runtime/handshake/HandshakeTransitionTest.java +++ b/test/hotspot/jtreg/runtime/handshake/HandshakeTransitionTest.java @@ -57,8 +57,7 @@ public class HandshakeTransitionTest { useJVMCICompilerStr = "-XX:+UnlockExperimentalVMOptions"; } ProcessBuilder pb = - ProcessTools.createJavaProcessBuilder( - true, + ProcessTools.createTestJvm( "-Djava.library.path=" + lib, "-XX:+SafepointALot", "-XX:+HandshakeALot", diff --git a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleClassList.java b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleClassList.java index 2c4442c7c91..85bb2f8b7c8 100644 --- a/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleClassList.java +++ b/test/hotspot/jtreg/runtime/modules/PatchModule/PatchModuleClassList.java @@ -63,8 +63,7 @@ public class PatchModuleClassList { String moduleJar = BasicJarBuilder.getTestJar("javanaming.jar"); String classList = "javanaming.list"; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - true, + ProcessBuilder pb = ProcessTools.createTestJvm( "-XX:DumpLoadedClassList=" + classList, "--patch-module=java.naming=" + moduleJar, "PatchModuleMain", BOOT_CLASS.replace('/', '.')); @@ -98,8 +97,7 @@ public class PatchModuleClassList { moduleJar = BasicJarBuilder.getTestJar("javasql.jar"); classList = "javasql.list"; - pb = ProcessTools.createJavaProcessBuilder( - true, + pb = ProcessTools.createTestJvm( "-XX:DumpLoadedClassList=" + classList, "--patch-module=java.sql=" + moduleJar, "PatchModuleMain", PLATFORM_CLASS.replace('/', '.')); @@ -131,8 +129,7 @@ public class PatchModuleClassList { moduleJar = BasicJarBuilder.getTestJar("hello.jar"); classList = "hello.list"; - pb = ProcessTools.createJavaProcessBuilder( - true, + pb = ProcessTools.createTestJvm( "-XX:DumpLoadedClassList=" + classList, "-Xbootclasspath/a:" + moduleJar, "Hello"); diff --git a/test/hotspot/jtreg/runtime/os/AvailableProcessors.java b/test/hotspot/jtreg/runtime/os/AvailableProcessors.java index 8d88e0e6292..ef258f4c87d 100644 --- a/test/hotspot/jtreg/runtime/os/AvailableProcessors.java +++ b/test/hotspot/jtreg/runtime/os/AvailableProcessors.java @@ -68,8 +68,7 @@ public class AvailableProcessors { // Get the java command we want to execute // Enable logging for easier failure diagnosis ProcessBuilder master = - ProcessTools.createJavaProcessBuilder(false, - "-Xlog:os=trace", + ProcessTools.createJavaProcessBuilder("-Xlog:os=trace", "AvailableProcessors"); int[] expected = new int[] { 1, available/2, available-1, available }; diff --git a/test/hotspot/jtreg/runtime/os/TestUseCpuAllocPath.java b/test/hotspot/jtreg/runtime/os/TestUseCpuAllocPath.java index 76eb73d8085..546203ad913 100644 --- a/test/hotspot/jtreg/runtime/os/TestUseCpuAllocPath.java +++ b/test/hotspot/jtreg/runtime/os/TestUseCpuAllocPath.java @@ -41,8 +41,7 @@ public class TestUseCpuAllocPath { public static void main(String[] args) throws Exception { ProcessBuilder pb = - ProcessTools.createJavaProcessBuilder(false, - "-Xlog:os=trace", + ProcessTools.createJavaProcessBuilder("-Xlog:os=trace", "-XX:+UnlockDiagnosticVMOptions", "-XX:+UseCpuAllocPath", "-version"); diff --git a/test/hotspot/jtreg/runtime/verifier/OverriderMsg.java b/test/hotspot/jtreg/runtime/verifier/OverriderMsg.java index 8e484da4b39..d90012d0fba 100644 --- a/test/hotspot/jtreg/runtime/verifier/OverriderMsg.java +++ b/test/hotspot/jtreg/runtime/verifier/OverriderMsg.java @@ -125,7 +125,7 @@ public class OverriderMsg { public static void main(String... args) throws Exception { dump_HasFinal(); dump_Overrider(); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-cp", ".", "Overrider"); + ProcessBuilder pb = ProcessTools.createTestJvm("-cp", ".", "Overrider"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain( "java.lang.VerifyError: class Overrider overrides final method HasFinal.m(Ljava/lang/String;)V"); diff --git a/test/hotspot/jtreg/runtime/verifier/TestANewArray.java b/test/hotspot/jtreg/runtime/verifier/TestANewArray.java index a5f9b5a1008..880d945dffa 100644 --- a/test/hotspot/jtreg/runtime/verifier/TestANewArray.java +++ b/test/hotspot/jtreg/runtime/verifier/TestANewArray.java @@ -69,7 +69,7 @@ public class TestANewArray { byte[] classFile_254 = dumpClassFile(cfv, test_Dimension_254, array_Dimension_254); writeClassFileFromByteArray(classFile_254); System.err.println("Running with cfv: " + cfv + ", test_Dimension_254"); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-verify", "-cp", ".", classCName); + ProcessBuilder pb = ProcessTools.createTestJvm("-verify", "-cp", ".", classCName); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldNotContain("java.lang.VerifyError"); output.shouldHaveExitValue(0); @@ -78,7 +78,7 @@ public class TestANewArray { byte[] classFile_255 = dumpClassFile(cfv, test_Dimension_255, array_Dimension_255); writeClassFileFromByteArray(classFile_255); System.err.println("Running with cfv: " + cfv + ", test_Dimension_255"); - pb = ProcessTools.createJavaProcessBuilder(true, "-verify", "-cp", ".", classCName); + pb = ProcessTools.createTestJvm("-verify", "-cp", ".", classCName); output = new OutputAnalyzer(pb.start()); // If anewarray has an operand with 255 array dimensions then VerifyError should // be thrown because the resulting array would have 256 dimensions. @@ -95,7 +95,7 @@ public class TestANewArray { byte[] classFile_264 = dumpClassFile(cfv, test_Dimension_264, array_Dimension_264); writeClassFileFromByteArray(classFile_264); System.err.println("Running with cfv: " + cfv + ", test_Dimension_264"); - pb = ProcessTools.createJavaProcessBuilder(true, "-verify", "-cp", ".", classCName); + pb = ProcessTools.createTestJvm("-verify", "-cp", ".", classCName); output = new OutputAnalyzer(pb.start()); output.shouldContain("java.lang.ClassFormatError"); output.shouldHaveExitValue(1); diff --git a/test/hotspot/jtreg/runtime/verifier/TestMultiANewArray.java b/test/hotspot/jtreg/runtime/verifier/TestMultiANewArray.java index 7e53ce27734..ba3734d889a 100644 --- a/test/hotspot/jtreg/runtime/verifier/TestMultiANewArray.java +++ b/test/hotspot/jtreg/runtime/verifier/TestMultiANewArray.java @@ -48,7 +48,7 @@ public class TestMultiANewArray { int cfv = Integer.parseInt(args[0]); writeClassFile(cfv); System.err.println("Running with cfv: " + cfv); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-cp", ".", "ClassFile"); + ProcessBuilder pb = ProcessTools.createTestJvm("-cp", ".", "ClassFile"); OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldContain("VerifyError"); output.shouldHaveExitValue(1); diff --git a/test/hotspot/jtreg/serviceability/jvmti/GetObjectSizeClass.java b/test/hotspot/jtreg/serviceability/jvmti/GetObjectSizeClass.java index e54fee726bc..c0a5041fdf2 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/GetObjectSizeClass.java +++ b/test/hotspot/jtreg/serviceability/jvmti/GetObjectSizeClass.java @@ -50,7 +50,7 @@ public class GetObjectSizeClass { pb.command(new String[] { JDKToolFinder.getJDKTool("jar"), "cmf", "MANIFEST.MF", "agent.jar", "GetObjectSizeClassAgent.class"}); pb.start().waitFor(); - ProcessBuilder pt = ProcessTools.createJavaProcessBuilder(true, "-javaagent:agent.jar", "GetObjectSizeClassAgent"); + ProcessBuilder pt = ProcessTools.createTestJvm("-javaagent:agent.jar", "GetObjectSizeClassAgent"); OutputAnalyzer output = new OutputAnalyzer(pt.start()); output.stdoutShouldContain("GetObjectSizeClass passed"); diff --git a/test/hotspot/jtreg/serviceability/jvmti/GetObjectSizeOverflow.java b/test/hotspot/jtreg/serviceability/jvmti/GetObjectSizeOverflow.java index 1f3cf82b296..5395e7c7790 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/GetObjectSizeOverflow.java +++ b/test/hotspot/jtreg/serviceability/jvmti/GetObjectSizeOverflow.java @@ -57,7 +57,7 @@ public class GetObjectSizeOverflow { pb.command(new String[] { JDKToolFinder.getJDKTool("jar"), "cmf", "MANIFEST.MF", "agent.jar", "GetObjectSizeOverflowAgent.class"}); pb.start().waitFor(); - ProcessBuilder pt = ProcessTools.createJavaProcessBuilder(true, "-Xmx4000m", "-javaagent:agent.jar", "GetObjectSizeOverflowAgent"); + ProcessBuilder pt = ProcessTools.createTestJvm("-Xmx4000m", "-javaagent:agent.jar", "GetObjectSizeOverflowAgent"); OutputAnalyzer output = new OutputAnalyzer(pt.start()); if (output.getStdout().contains("Could not reserve enough space") || output.getStderr().contains("java.lang.OutOfMemoryError")) { diff --git a/test/hotspot/jtreg/serviceability/logging/TestLogRotation.java b/test/hotspot/jtreg/serviceability/logging/TestLogRotation.java index 1ed3c144067..608c656c580 100644 --- a/test/hotspot/jtreg/serviceability/logging/TestLogRotation.java +++ b/test/hotspot/jtreg/serviceability/logging/TestLogRotation.java @@ -71,8 +71,7 @@ public class TestLogRotation { } public static void runTest(int numberOfFiles) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - true, + ProcessBuilder pb = ProcessTools.createTestJvm( "-cp", System.getProperty("java.class.path"), "-Xlog:gc=debug:" + logFileName + "::filesize=" + logFileSizeK + "k" diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java index fe9b8f77c65..cd4514b2e5c 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSCore.java @@ -98,7 +98,7 @@ public class ClhsdbCDSCore { List options = new ArrayList<>(); options.addAll(Arrays.asList(jArgs)); crashOut = - ProcessTools.executeProcess(getTestJavaCommandlineWithPrefix( + ProcessTools.executeProcess(getTestJvmCommandlineWithPrefix( RUN_SHELL_NO_LIMIT, options.toArray(new String[0]))); } catch (Throwable t) { throw new Error("Can't execute the java cds process.", t); @@ -253,9 +253,9 @@ public class ClhsdbCDSCore { return null; } - private static String[] getTestJavaCommandlineWithPrefix(String prefix, String... args) { + private static String[] getTestJvmCommandlineWithPrefix(String prefix, String... args) { try { - String cmd = ProcessTools.getCommandLine(ProcessTools.createJavaProcessBuilder(true, args)); + String cmd = ProcessTools.getCommandLine(ProcessTools.createTestJvm(args)); return new String[]{"sh", "-c", prefix + cmd}; } catch (Throwable t) { throw new Error("Can't create process builder: " + t, t); diff --git a/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java b/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java index 70c43b50027..e236db618d7 100644 --- a/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java +++ b/test/hotspot/jtreg/serviceability/sa/TestJmapCore.java @@ -88,7 +88,7 @@ public class TestJmapCore { } static void test(String type) throws Throwable { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-XX:+CreateCoredumpOnCrash", + ProcessBuilder pb = ProcessTools.createTestJvm("-XX:+CreateCoredumpOnCrash", "-Xmx512m", "-XX:MaxMetaspaceSize=64m", "-XX:+CrashOnOutOfMemoryError", TestJmapCore.class.getName(), type); diff --git a/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java b/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java index 1965511aebc..da9d623f6d8 100644 --- a/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java +++ b/test/hotspot/jtreg/testlibrary/ctw/src/sun/hotspot/tools/ctw/CtwRunner.java @@ -174,9 +174,7 @@ public class CtwRunner { while (!done) { String[] cmd = cmd(classStart, classStop); try { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - /* addTestVmAndJavaOptions = */ true, - cmd); + ProcessBuilder pb = ProcessTools.createTestJvm(cmd); String commandLine = pb.command() .stream() .collect(Collectors.joining(" ")); diff --git a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/jtreg/JitTesterDriver.java b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/jtreg/JitTesterDriver.java index b0177849bd2..e350d5cf121 100644 --- a/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/jtreg/JitTesterDriver.java +++ b/test/hotspot/jtreg/testlibrary/jittester/src/jdk/test/lib/jittester/jtreg/JitTesterDriver.java @@ -47,7 +47,7 @@ public class JitTesterDriver { } OutputAnalyzer oa; try { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, args); + ProcessBuilder pb = ProcessTools.createTestJvm(args); oa = new OutputAnalyzer(pb.start()); } catch (Exception e) { throw new Error("Unexpected exception on test jvm start :" + e, e); diff --git a/test/hotspot/jtreg/testlibrary_tests/ctw/CtwTest.java b/test/hotspot/jtreg/testlibrary_tests/ctw/CtwTest.java index 88e34933de3..ca0577ff8e8 100644 --- a/test/hotspot/jtreg/testlibrary_tests/ctw/CtwTest.java +++ b/test/hotspot/jtreg/testlibrary_tests/ctw/CtwTest.java @@ -101,7 +101,7 @@ public abstract class CtwTest { cmd[i] = cmd[i].replace("*", "\"*\""); } } - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmd); + ProcessBuilder pb = ProcessTools.createTestJvm(cmd); OutputAnalyzer output = new OutputAnalyzer(pb.start()); dump(output, "compile"); output.shouldHaveExitValue(0); diff --git a/test/hotspot/jtreg/vmTestbase/gc/huge/quicklook/largeheap/MemOptions/MemOptionsTest.java b/test/hotspot/jtreg/vmTestbase/gc/huge/quicklook/largeheap/MemOptions/MemOptionsTest.java index 1a0814e1dac..f8f213d733e 100644 --- a/test/hotspot/jtreg/vmTestbase/gc/huge/quicklook/largeheap/MemOptions/MemOptionsTest.java +++ b/test/hotspot/jtreg/vmTestbase/gc/huge/quicklook/largeheap/MemOptions/MemOptionsTest.java @@ -94,7 +94,7 @@ public class MemOptionsTest { var cmd = new ArrayList(); Collections.addAll(cmd, opts); cmd.add(MemStat.class.getName()); - var pb = ProcessTools.createJavaProcessBuilder(true, cmd); + var pb = ProcessTools.createTestJvm(cmd); var output = new OutputAnalyzer(pb.start()); if (output.getExitValue() != 0) { output.reportDiagnosticSummary(); @@ -107,7 +107,7 @@ public class MemOptionsTest { var cmd = new ArrayList(); Collections.addAll(cmd, opts); cmd.add(MemStat.class.getName()); - var pb = ProcessTools.createJavaProcessBuilder(true, cmd); + var pb = ProcessTools.createTestJvm(cmd); var output = new OutputAnalyzer(pb.start()); if (output.getExitValue() == 0) { output.reportDiagnosticSummary(); diff --git a/test/hotspot/jtreg/vmTestbase/jit/tiered/Test.java b/test/hotspot/jtreg/vmTestbase/jit/tiered/Test.java index a82ae0a3e7c..20661e306a8 100644 --- a/test/hotspot/jtreg/vmTestbase/jit/tiered/Test.java +++ b/test/hotspot/jtreg/vmTestbase/jit/tiered/Test.java @@ -54,7 +54,7 @@ public class Test { public static void main(String[] args) throws Exception { { System.out.println("TieredCompilation is enabled"); - var pb = ProcessTools.createJavaProcessBuilder(true, + var pb = ProcessTools.createTestJvm( "-XX:+TieredCompilation", "-XX:+PrintTieredEvents", "-version"); @@ -67,7 +67,7 @@ public class Test { } { System.out.println("TieredCompilation is disabled"); - var pb = ProcessTools.createJavaProcessBuilder(true, + var pb = ProcessTools.createTestJvm( "-XX:-TieredCompilation", "-XX:+PrintTieredEvents", "-version"); diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/flags/maxMetaspaceSize/TestMaxMetaspaceSize.java b/test/hotspot/jtreg/vmTestbase/metaspace/flags/maxMetaspaceSize/TestMaxMetaspaceSize.java index d67d77e5b08..1cdfbd4e361 100644 --- a/test/hotspot/jtreg/vmTestbase/metaspace/flags/maxMetaspaceSize/TestMaxMetaspaceSize.java +++ b/test/hotspot/jtreg/vmTestbase/metaspace/flags/maxMetaspaceSize/TestMaxMetaspaceSize.java @@ -39,8 +39,8 @@ import jdk.test.lib.process.ProcessTools; public class TestMaxMetaspaceSize { public static void main(String[] args) throws Exception { ProcessBuilder pb = - ProcessTools.createJavaProcessBuilder(true, "-XX:MaxMetaspaceSize=100m", - maxMetaspaceSize.class.getName()); + ProcessTools.createTestJvm("-XX:MaxMetaspaceSize=100m", + maxMetaspaceSize.class.getName()); OutputAnalyzer out = new OutputAnalyzer(pb.start()); if (out.getExitValue() == 0) { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RetransformClasses/retransform003/TestDriver.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RetransformClasses/retransform003/TestDriver.java index 1fcaeffc33e..739659b019c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RetransformClasses/retransform003/TestDriver.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RetransformClasses/retransform003/TestDriver.java @@ -69,8 +69,7 @@ import java.util.Arrays; public class TestDriver { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - true, + ProcessBuilder pb = ProcessTools.createTestJvm( "-agentlib:retransform003-01=id=1 can_retransform_classes=1", "-agentlib:retransform003-02=id=2 can_retransform_classes=0", "-agentlib:retransform003-03=id=3 can_retransform_classes=1", diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix002/TestDriver.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix002/TestDriver.java index c8218922815..5e74b95db8c 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix002/TestDriver.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/SetNativeMethodPrefix/SetNativeMethodPrefix002/TestDriver.java @@ -58,8 +58,7 @@ import java.util.Arrays; public class TestDriver { public static void main(String[] args) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - true, + ProcessBuilder pb = ProcessTools.createTestJvm( "-agentlib:SetNativeMethodPrefix001=trace=all", "-agentlib:SetNativeMethodPrefix002-01=trace=all prefix=wa_", "-agentlib:SetNativeMethodPrefix002-02=trace=all prefix=wb_", diff --git a/test/hotspot/jtreg/vmTestbase/vm/compiler/CodeCacheInfo/Test.java b/test/hotspot/jtreg/vmTestbase/vm/compiler/CodeCacheInfo/Test.java index a8e9df7f186..60744d68898 100644 --- a/test/hotspot/jtreg/vmTestbase/vm/compiler/CodeCacheInfo/Test.java +++ b/test/hotspot/jtreg/vmTestbase/vm/compiler/CodeCacheInfo/Test.java @@ -78,7 +78,7 @@ public class Test { public static void main(String[] args) throws Exception { { System.out.println("SegmentedCodeCache is enabled"); - var pb = ProcessTools.createJavaProcessBuilder(true, + var pb = ProcessTools.createTestJvm( "-XX:+SegmentedCodeCache", "-XX:+PrintCodeCache", "-version"); @@ -88,7 +88,7 @@ public class Test { } { System.out.println("SegmentedCodeCache is disabled"); - var pb = ProcessTools.createJavaProcessBuilder(true, + var pb = ProcessTools.createTestJvm( "-XX:-SegmentedCodeCache", "-XX:+PrintCodeCache", "-version"); diff --git a/test/hotspot/jtreg/vmTestbase/vm/compiler/CodeCacheInfoOnCompilation/Test.java b/test/hotspot/jtreg/vmTestbase/vm/compiler/CodeCacheInfoOnCompilation/Test.java index 852032c2aea..4580e7f0ec8 100644 --- a/test/hotspot/jtreg/vmTestbase/vm/compiler/CodeCacheInfoOnCompilation/Test.java +++ b/test/hotspot/jtreg/vmTestbase/vm/compiler/CodeCacheInfoOnCompilation/Test.java @@ -46,7 +46,7 @@ public class Test { private static String REGEXP = "^(CodeCache|(CodeHeap.*)): size=\\d+Kb used=\\d+Kb max_used=\\d+Kb free=\\d+Kb"; public static void main(String[] args) throws Exception { - var pb = ProcessTools.createJavaProcessBuilder(true, + var pb = ProcessTools.createTestJvm( "-XX:-PrintCodeCache", "-XX:+PrintCodeCacheOnCompilation", "-XX:-Inline", diff --git a/test/jdk/com/sun/jdi/JITDebug.java b/test/jdk/com/sun/jdi/JITDebug.java index 7356a54b886..e7a5647fdd4 100644 --- a/test/jdk/com/sun/jdi/JITDebug.java +++ b/test/jdk/com/sun/jdi/JITDebug.java @@ -104,7 +104,7 @@ public class JITDebug { } void testLaunch() { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true); + ProcessBuilder pb = ProcessTools.createTestJvm(); List largs = pb.command(); largs.add("-classpath"); largs.add(Utils.TEST_CLASSES); diff --git a/test/jdk/com/sun/jdi/PrivateTransportTest.java b/test/jdk/com/sun/jdi/PrivateTransportTest.java index 24d71cbbc3c..c12db8b90be 100644 --- a/test/jdk/com/sun/jdi/PrivateTransportTest.java +++ b/test/jdk/com/sun/jdi/PrivateTransportTest.java @@ -82,7 +82,7 @@ public class PrivateTransportTest { String libName = transportLib.getFileName().toString().replace("dt_socket", "private_dt_socket"); Files.copy(transportLib, Paths.get(Utils.TEST_CLASSES).resolve(libName)); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, + ProcessBuilder pb = ProcessTools.createTestJvm( "-agentlib:jdwp=transport=private_dt_socket,server=y,suspend=n", "-classpath", Utils.TEST_CLASSES, "HelloWorld"); diff --git a/test/jdk/com/sun/jdi/cds/CDSJDITest.java b/test/jdk/com/sun/jdi/cds/CDSJDITest.java index 6e42b73dc35..f55c55373d0 100644 --- a/test/jdk/com/sun/jdi/cds/CDSJDITest.java +++ b/test/jdk/com/sun/jdi/cds/CDSJDITest.java @@ -81,7 +81,7 @@ public class CDSJDITest { outputDump.shouldHaveExitValue(0); // Run the test specified JDI test - pb = ProcessTools.createJavaProcessBuilder(true, testArgs); + pb = ProcessTools.createTestJvm(testArgs); OutputAnalyzer outputRun = executeAndLog(pb, "exec"); try { outputRun.shouldContain("sharing"); diff --git a/test/jdk/com/sun/jdi/lib/jdb/Debuggee.java b/test/jdk/com/sun/jdi/lib/jdb/Debuggee.java index 876d1fcf0a8..71b3eb28d6d 100644 --- a/test/jdk/com/sun/jdi/lib/jdb/Debuggee.java +++ b/test/jdk/com/sun/jdi/lib/jdb/Debuggee.java @@ -69,7 +69,6 @@ public class Debuggee implements Closeable { private String transport = "dt_socket"; private String address = null; private boolean suspended = true; - private boolean addTestVmAndJavaOptions = true; private Launcher(String mainClass) { this.mainClass = mainClass; @@ -101,11 +100,6 @@ public class Debuggee implements Closeable { suspended = value; return this; } - // default is "true" - public Launcher addTestVmAndJavaOptions(boolean value) { - addTestVmAndJavaOptions = value; - return this; - } public ProcessBuilder prepare() { List debuggeeArgs = new LinkedList<>(); @@ -117,8 +111,7 @@ public class Debuggee implements Closeable { + ",server=y,suspend=" + (suspended ? "y" : "n")); debuggeeArgs.addAll(options); debuggeeArgs.add(mainClass); - return ProcessTools.createJavaProcessBuilder(addTestVmAndJavaOptions, - debuggeeArgs.toArray(new String[0])); + return ProcessTools.createTestJvm(debuggeeArgs); } public Debuggee launch(String name) { diff --git a/test/jdk/java/io/File/MacPath.java b/test/jdk/java/io/File/MacPath.java index 08ffc83534b..a9d91018783 100644 --- a/test/jdk/java/io/File/MacPath.java +++ b/test/jdk/java/io/File/MacPath.java @@ -38,7 +38,7 @@ import jdk.test.lib.process.ProcessTools; public class MacPath { public static void main(String args[]) throws Exception { final ProcessBuilder pb = - ProcessTools.createJavaProcessBuilder(true, MacPathTest.class.getName()); + ProcessTools.createTestJvm(MacPathTest.class.getName()); final Map env = pb.environment(); env.put("LC_ALL", "en_US.UTF-8"); Process p = ProcessTools.startProcess("Mac Path Test", pb); diff --git a/test/jdk/java/io/Serializable/evolution/RenamePackage/RenamePackageTest.java b/test/jdk/java/io/Serializable/evolution/RenamePackage/RenamePackageTest.java index 7a3da8e04d5..faccc09bb4b 100644 --- a/test/jdk/java/io/Serializable/evolution/RenamePackage/RenamePackageTest.java +++ b/test/jdk/java/io/Serializable/evolution/RenamePackage/RenamePackageTest.java @@ -81,7 +81,7 @@ public class RenamePackageTest { } private static void runTestSerialDriver() throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, + ProcessBuilder pb = ProcessTools.createTestJvm( "-classpath", SHARE.toString() + File.pathSeparator @@ -93,7 +93,7 @@ public class RenamePackageTest { } private static void runInstallSerialDriver() throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, + ProcessBuilder pb = ProcessTools.createTestJvm( "-classpath", SHARE.toString() + File.pathSeparator diff --git a/test/jdk/java/lang/RuntimeTests/shutdown/ShutdownInterruptedMain.java b/test/jdk/java/lang/RuntimeTests/shutdown/ShutdownInterruptedMain.java index d4f508bdb47..e141fc35212 100644 --- a/test/jdk/java/lang/RuntimeTests/shutdown/ShutdownInterruptedMain.java +++ b/test/jdk/java/lang/RuntimeTests/shutdown/ShutdownInterruptedMain.java @@ -31,14 +31,14 @@ */ import jdk.test.lib.process.OutputAnalyzer; -import static jdk.test.lib.process.ProcessTools.createJavaProcessBuilder; +import static jdk.test.lib.process.ProcessTools.createTestJvm; import static jdk.test.lib.process.ProcessTools.executeProcess; public class ShutdownInterruptedMain { public static void main(String[] args) throws Exception { if (args.length > 0) { - ProcessBuilder pb = createJavaProcessBuilder(true, "ShutdownInterruptedMain"); + ProcessBuilder pb = createTestJvm("ShutdownInterruptedMain"); OutputAnalyzer output = executeProcess(pb); output.shouldContain("Shutdown Hook"); output.shouldHaveExitValue(0); diff --git a/test/jdk/java/lang/StackWalker/CallerFromMain.java b/test/jdk/java/lang/StackWalker/CallerFromMain.java index f1b352f7cb1..3cb599c6859 100644 --- a/test/jdk/java/lang/StackWalker/CallerFromMain.java +++ b/test/jdk/java/lang/StackWalker/CallerFromMain.java @@ -37,7 +37,7 @@ public class CallerFromMain { private static final StackWalker sw = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE); public static void main(String[] args) throws Exception { if (args.length > 0) { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "CallerFromMain"); + ProcessBuilder pb = ProcessTools.createTestJvm("CallerFromMain"); OutputAnalyzer output = ProcessTools.executeProcess(pb); System.out.println(output.getOutput()); output.shouldHaveExitValue(0); diff --git a/test/jdk/java/lang/System/MacEncoding/MacJNUEncoding.java b/test/jdk/java/lang/System/MacEncoding/MacJNUEncoding.java index d1464ba4fd0..24cc9adab16 100644 --- a/test/jdk/java/lang/System/MacEncoding/MacJNUEncoding.java +++ b/test/jdk/java/lang/System/MacEncoding/MacJNUEncoding.java @@ -49,7 +49,7 @@ public class MacJNUEncoding { final String locale = args[2]; System.out.println("Running test for locale: " + locale); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, + ProcessBuilder pb = ProcessTools.createTestJvm( ExpectedEncoding.class.getName(), args[0], args[1]); Map env = pb.environment(); env.put("LANG", locale); diff --git a/test/jdk/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java b/test/jdk/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java index 7dca12ebe45..728fc5d17ab 100644 --- a/test/jdk/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java +++ b/test/jdk/java/lang/instrument/DaemonThread/TestDaemonThreadLauncher.java @@ -29,7 +29,7 @@ import jdk.test.lib.process.ProcessTools; public class TestDaemonThreadLauncher { public static void main(String args[]) throws Exception { for(int i=0; i<50; i++) { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, "-javaagent:DummyAgent.jar", "TestDaemonThread", "."); + ProcessBuilder pb = ProcessTools.createTestJvm("-javaagent:DummyAgent.jar", "TestDaemonThread", "."); OutputAnalyzer analyzer = ProcessTools.executeProcess(pb); analyzer.shouldNotContain("ASSERTION FAILED"); analyzer.shouldHaveExitValue(0); diff --git a/test/jdk/java/nio/charset/Charset/DefaultCharsetTest.java b/test/jdk/java/nio/charset/Charset/DefaultCharsetTest.java index e7a6197888e..b8eef9ca56b 100644 --- a/test/jdk/java/nio/charset/Charset/DefaultCharsetTest.java +++ b/test/jdk/java/nio/charset/Charset/DefaultCharsetTest.java @@ -54,7 +54,7 @@ import static org.testng.Assert.assertTrue; public class DefaultCharsetTest { private static final ProcessBuilder pb - = ProcessTools.createJavaProcessBuilder(true, Default.class.getName()); + = ProcessTools.createTestJvm(Default.class.getName()); private static final Map env = pb.environment(); private static String UNSUPPORTED = null; diff --git a/test/jdk/java/nio/file/Path/MacPathTest.java b/test/jdk/java/nio/file/Path/MacPathTest.java index 00d5eddc045..a65e310ff7f 100644 --- a/test/jdk/java/nio/file/Path/MacPathTest.java +++ b/test/jdk/java/nio/file/Path/MacPathTest.java @@ -41,7 +41,7 @@ import jdk.test.lib.process.ProcessTools; public class MacPathTest { public static void main(String args[]) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, MacPath.class.getName()); + ProcessBuilder pb = ProcessTools.createTestJvm(MacPath.class.getName()); pb.environment().put("LC_ALL", "en_US.UTF-8"); ProcessTools.executeProcess(pb) .outputTo(System.out) diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestCrossProcessStreaming.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestCrossProcessStreaming.java index e5ddc392f73..d38187bf33a 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestCrossProcessStreaming.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestCrossProcessStreaming.java @@ -131,7 +131,7 @@ public class TestCrossProcessStreaming { static Process start() throws Exception { String[] args = {"-XX:StartFlightRecording", EventProducer.class.getName()}; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false, args); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args); return ProcessTools.startProcess("Event-Producer", pb, line -> line.contains(MAIN_STARTED), 0, TimeUnit.SECONDS); diff --git a/test/jdk/jdk/jfr/api/consumer/streaming/TestProcess.java b/test/jdk/jdk/jfr/api/consumer/streaming/TestProcess.java index 329343f948c..1345dc80d38 100644 --- a/test/jdk/jdk/jfr/api/consumer/streaming/TestProcess.java +++ b/test/jdk/jdk/jfr/api/consumer/streaming/TestProcess.java @@ -63,7 +63,7 @@ public final class TestProcess implements AutoCloseable { "-XX:StartFlightRecording:settings=none", TestProcess.class.getName(), path.toString() }; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(false, args); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args); process = ProcessTools.startProcess(name, pb); } diff --git a/test/jdk/jdk/jfr/event/runtime/TestDumpReason.java b/test/jdk/jdk/jfr/event/runtime/TestDumpReason.java index 1141314ed06..c080443eda3 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestDumpReason.java +++ b/test/jdk/jdk/jfr/event/runtime/TestDumpReason.java @@ -91,8 +91,7 @@ public class TestDumpReason { private static long runProcess(Class crasher) throws Exception { System.out.println("Test case for " + crasher.getName()); - Process p = ProcessTools.createJavaProcessBuilder( - true, + Process p = ProcessTools.createTestJvm( "-Xmx64m", "-XX:-CreateCoredumpOnCrash", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", diff --git a/test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java b/test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java index 12f2b1428d1..37ad0ba9ead 100644 --- a/test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java +++ b/test/jdk/jdk/jfr/event/runtime/TestShutdownEvent.java @@ -91,7 +91,7 @@ public class TestShutdownEvent { } private static void runSubtest(int subTestIndex) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, + ProcessBuilder pb = ProcessTools.createTestJvm( "-Xlog:jfr=debug", "-XX:-CreateCoredumpOnCrash", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", diff --git a/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java b/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java index 4ce929ad6cb..8cffebd2a89 100644 --- a/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java +++ b/test/jdk/jdk/jfr/jvm/TestDumpOnCrash.java @@ -110,7 +110,7 @@ public class TestDumpOnCrash { private static long runProcess(Class crasher, String signal, boolean disk) throws Exception { System.out.println("Test case for crasher " + crasher.getName()); final String flightRecordingOptions = "dumponexit=true,disk=" + Boolean.toString(disk); - Process p = ProcessTools.createJavaProcessBuilder(true, + Process p = ProcessTools.createTestJvm( "-Xmx64m", "-XX:-CreateCoredumpOnCrash", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", diff --git a/test/jdk/jdk/jfr/jvm/TestJfrJavaBase.java b/test/jdk/jdk/jfr/jvm/TestJfrJavaBase.java index e2351fdf8a5..4aae0b3a4c4 100644 --- a/test/jdk/jdk/jfr/jvm/TestJfrJavaBase.java +++ b/test/jdk/jdk/jfr/jvm/TestJfrJavaBase.java @@ -51,7 +51,7 @@ public class TestJfrJavaBase { public static void main(String[] args) throws Exception { OutputAnalyzer output; if (args.length == 0) { - output = ProcessTools.executeProcess(ProcessTools.createJavaProcessBuilder(false, + output = ProcessTools.executeProcess(ProcessTools.createJavaProcessBuilder( "-Dtest.jdk=" + System.getProperty("test.jdk"), "--limit-modules", "java.base", "-cp", System.getProperty("java.class.path"), TestJfrJavaBase.class.getName(), "runtest")); diff --git a/test/jdk/jdk/jfr/startupargs/TestDumpOnExit.java b/test/jdk/jdk/jfr/startupargs/TestDumpOnExit.java index ee404d9d9dc..b4b9a03826d 100644 --- a/test/jdk/jdk/jfr/startupargs/TestDumpOnExit.java +++ b/test/jdk/jdk/jfr/startupargs/TestDumpOnExit.java @@ -94,7 +94,7 @@ public class TestDumpOnExit { } private static void testDumponExit(Supplier p,String... args) throws Exception, IOException { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, args); + ProcessBuilder pb = ProcessTools.createTestJvm(args); OutputAnalyzer output = ProcessTools.executeProcess(pb); System.out.println(output.getOutput()); output.shouldHaveExitValue(0); diff --git a/test/jdk/jdk/jfr/startupargs/TestMemoryOptions.java b/test/jdk/jdk/jfr/startupargs/TestMemoryOptions.java index a8dcc08dd5e..64a731d8dfa 100644 --- a/test/jdk/jdk/jfr/startupargs/TestMemoryOptions.java +++ b/test/jdk/jdk/jfr/startupargs/TestMemoryOptions.java @@ -485,21 +485,19 @@ public class TestMemoryOptions { final String flightRecorderOptions = tc.getTestString(); ProcessBuilder pb; if (flightRecorderOptions != null) { - pb = ProcessTools.createJavaProcessBuilder(true, - "--add-exports=jdk.jfr/jdk.jfr.internal=ALL-UNNAMED", - "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", - flightRecorderOptions, - "-XX:StartFlightRecording", - SUT.class.getName(), - tc.getTestName()); + pb = ProcessTools.createTestJvm("--add-exports=jdk.jfr/jdk.jfr.internal=ALL-UNNAMED", + "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", + flightRecorderOptions, + "-XX:StartFlightRecording", + SUT.class.getName(), + tc.getTestName()); } else { // default, no FlightRecorderOptions passed - pb = ProcessTools.createJavaProcessBuilder(true, - "--add-exports=jdk.jfr/jdk.jfr.internal=ALL-UNNAMED", - "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", - "-XX:StartFlightRecording", - SUT.class.getName(), - tc.getTestName()); + pb = ProcessTools.createTestJvm("--add-exports=jdk.jfr/jdk.jfr.internal=ALL-UNNAMED", + "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", + "-XX:StartFlightRecording", + SUT.class.getName(), + tc.getTestName()); } System.out.println("Driver launching SUT with string: " + flightRecorderOptions != null ? flightRecorderOptions : "default"); diff --git a/test/jdk/jdk/jfr/startupargs/TestMultipleStartupRecordings.java b/test/jdk/jdk/jfr/startupargs/TestMultipleStartupRecordings.java index de3589f9aac..19b8734f55f 100644 --- a/test/jdk/jdk/jfr/startupargs/TestMultipleStartupRecordings.java +++ b/test/jdk/jdk/jfr/startupargs/TestMultipleStartupRecordings.java @@ -57,14 +57,14 @@ public class TestMultipleStartupRecordings { private static void launchUnary(String options) throws Exception { String recording1 = START_FLIGHT_RECORDING + (options != null ? options : ""); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, recording1, MainClass.class.getName()); + ProcessBuilder pb = ProcessTools.createTestJvm(recording1, MainClass.class.getName()); test(pb, "Started recording 1"); } private static void launchBinary(String options1, String options2) throws Exception { String recording1 = START_FLIGHT_RECORDING + (options1 != null ? options1 : ""); String recording2 = START_FLIGHT_RECORDING + (options2 != null ? options2 : ""); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, recording1, recording2, MainClass.class.getName()); + ProcessBuilder pb = ProcessTools.createTestJvm(recording1, recording2, MainClass.class.getName()); test(pb, "Started recording 1", "Started recording 2"); } @@ -72,7 +72,7 @@ public class TestMultipleStartupRecordings { String recording1 = START_FLIGHT_RECORDING + (options1 != null ? options1 : ""); String recording2 = START_FLIGHT_RECORDING + (options2 != null ? options2 : ""); String recording3 = START_FLIGHT_RECORDING + (options3 != null ? options3 : ""); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, recording1, recording2, recording3, MainClass.class.getName()); + ProcessBuilder pb = ProcessTools.createTestJvm(recording1, recording2, recording3, MainClass.class.getName()); test(pb, "Started recording 1", "Started recording 2", "Started recording 3"); } @@ -96,7 +96,7 @@ public class TestMultipleStartupRecordings { String flightRecorderOptions = FLIGHT_RECORDER_OPTIONS + "=maxchunksize=8m"; String recording1 = START_FLIGHT_RECORDING + "=filename=recording1.jfr"; String recording2 = START_FLIGHT_RECORDING + "=name=myrecording,filename=recording2.jfr"; - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, flightRecorderOptions, recording1, recording2, MainClass.class.getName()); + ProcessBuilder pb = ProcessTools.createTestJvm(flightRecorderOptions, recording1, recording2, MainClass.class.getName()); test(pb, "Started recording 1", "Started recording 2"); } diff --git a/test/jdk/jdk/jfr/startupargs/TestRetransformUsingLog.java b/test/jdk/jdk/jfr/startupargs/TestRetransformUsingLog.java index 902be7d5277..9c76bc2e92d 100644 --- a/test/jdk/jdk/jfr/startupargs/TestRetransformUsingLog.java +++ b/test/jdk/jdk/jfr/startupargs/TestRetransformUsingLog.java @@ -106,7 +106,7 @@ public class TestRetransformUsingLog { } System.out.println(); System.out.println(); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, args.toArray(new String[0])); + ProcessBuilder pb = ProcessTools.createTestJvm(args); OutputAnalyzer out = ProcessTools.executeProcess(pb); System.out.println(out.getOutput()); verifier.accept(out); diff --git a/test/jdk/jdk/jfr/startupargs/TestStartDuration.java b/test/jdk/jdk/jfr/startupargs/TestStartDuration.java index 2c1340682f1..d84f337fb7d 100644 --- a/test/jdk/jdk/jfr/startupargs/TestStartDuration.java +++ b/test/jdk/jdk/jfr/startupargs/TestStartDuration.java @@ -55,7 +55,7 @@ public class TestStartDuration { } private static void testDurationInRange(String duration, Duration durationString, boolean wait) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, + ProcessBuilder pb = ProcessTools.createTestJvm( "-XX:StartFlightRecording=name=TestStartDuration,duration=" + duration, TestValues.class.getName(), durationString.toString(), wait ? "wait" : ""); OutputAnalyzer out = ProcessTools.executeProcess(pb); @@ -65,7 +65,7 @@ public class TestStartDuration { private static void testDurationJavaVersion(String duration, boolean inRange) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, + ProcessBuilder pb = ProcessTools.createTestJvm( "-XX:StartFlightRecording=name=TestStartDuration,duration=" + duration, "-version"); OutputAnalyzer out = ProcessTools.executeProcess(pb); diff --git a/test/jdk/jdk/jfr/startupargs/TestStartName.java b/test/jdk/jdk/jfr/startupargs/TestStartName.java index cb5d17509c3..80c7c9bd686 100644 --- a/test/jdk/jdk/jfr/startupargs/TestStartName.java +++ b/test/jdk/jdk/jfr/startupargs/TestStartName.java @@ -47,7 +47,7 @@ public class TestStartName { } private static void testName(String recordingName, boolean validName) throws Exception { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, + ProcessBuilder pb = ProcessTools.createTestJvm( "-XX:StartFlightRecording=name=" + recordingName, TestName.class.getName(), recordingName); OutputAnalyzer out = ProcessTools.executeProcess(pb); diff --git a/test/jdk/sun/security/ssl/SSLEngineImpl/SSLEngineKeyLimit.java b/test/jdk/sun/security/ssl/SSLEngineImpl/SSLEngineKeyLimit.java index 0552a752019..fa6f12bc2b7 100644 --- a/test/jdk/sun/security/ssl/SSLEngineImpl/SSLEngineKeyLimit.java +++ b/test/jdk/sun/security/ssl/SSLEngineImpl/SSLEngineKeyLimit.java @@ -119,7 +119,7 @@ public class SSLEngineKeyLimit { System.out.println("test.java.opts: " + System.getProperty("test.java.opts")); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, + ProcessBuilder pb = ProcessTools.createTestJvm( Utils.addTestJavaOpts("SSLEngineKeyLimit", "p", args[1])); OutputAnalyzer output = ProcessTools.executeProcess(pb); diff --git a/test/jdk/sun/security/ssl/SSLSessionImpl/ResumptionUpdateBoundValues.java b/test/jdk/sun/security/ssl/SSLSessionImpl/ResumptionUpdateBoundValues.java index 8c25cfc17e7..d537db8ae20 100644 --- a/test/jdk/sun/security/ssl/SSLSessionImpl/ResumptionUpdateBoundValues.java +++ b/test/jdk/sun/security/ssl/SSLSessionImpl/ResumptionUpdateBoundValues.java @@ -189,7 +189,7 @@ public class ResumptionUpdateBoundValues { System.out.println("test.java.opts: " + System.getProperty("test.java.opts")); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, + ProcessBuilder pb = ProcessTools.createTestJvm( Utils.addTestJavaOpts("ResumptionUpdateBoundValues", "p")); OutputAnalyzer output = ProcessTools.executeProcess(pb); diff --git a/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketKeyLimit.java b/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketKeyLimit.java index 8d2912cefaa..198e0bdd6f0 100644 --- a/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketKeyLimit.java +++ b/test/jdk/sun/security/ssl/SSLSocketImpl/SSLSocketKeyLimit.java @@ -124,7 +124,7 @@ public class SSLSocketKeyLimit { System.out.println("test.java.opts: " + System.getProperty("test.java.opts")); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, + ProcessBuilder pb = ProcessTools.createTestJvm( Utils.addTestJavaOpts("SSLSocketKeyLimit", "p", args[1])); OutputAnalyzer output = ProcessTools.executeProcess(pb); diff --git a/test/lib/jdk/test/lib/cds/CDSTestUtils.java b/test/lib/jdk/test/lib/cds/CDSTestUtils.java index 7968071ec53..b8f743d9119 100644 --- a/test/lib/jdk/test/lib/cds/CDSTestUtils.java +++ b/test/lib/jdk/test/lib/cds/CDSTestUtils.java @@ -256,7 +256,7 @@ public class CDSTestUtils { for (String s : opts.suffix) cmd.add(s); String[] cmdLine = cmd.toArray(new String[cmd.size()]); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmdLine); + ProcessBuilder pb = ProcessTools.createTestJvm(cmdLine); return executeAndLog(pb, "dump"); } @@ -414,7 +414,7 @@ public class CDSTestUtils { for (String s : opts.suffix) cmd.add(s); String[] cmdLine = cmd.toArray(new String[cmd.size()]); - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmdLine); + ProcessBuilder pb = ProcessTools.createTestJvm(cmdLine); return executeAndLog(pb, "exec"); } diff --git a/test/lib/jdk/test/lib/jfr/AppExecutorHelper.java b/test/lib/jdk/test/lib/jfr/AppExecutorHelper.java index 239a0f7f9e3..6768f4ed8f9 100644 --- a/test/lib/jdk/test/lib/jfr/AppExecutorHelper.java +++ b/test/lib/jdk/test/lib/jfr/AppExecutorHelper.java @@ -74,7 +74,7 @@ public class AppExecutorHelper { Collections.addAll(arguments, classArguments); } - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, arguments.toArray(new String[0])); + ProcessBuilder pb = ProcessTools.createTestJvm(arguments); return ProcessTools.executeProcess(pb); } } diff --git a/test/lib/jdk/test/lib/process/ProcessTools.java b/test/lib/jdk/test/lib/process/ProcessTools.java index 1157733ffe7..da79c703b93 100644 --- a/test/lib/jdk/test/lib/process/ProcessTools.java +++ b/test/lib/jdk/test/lib/process/ProcessTools.java @@ -273,19 +273,7 @@ public final class ProcessTools { * @return The ProcessBuilder instance representing the java command. */ public static ProcessBuilder createJavaProcessBuilder(List command) { - return createJavaProcessBuilder(false, command); - } - - /** - * Create ProcessBuilder using the java launcher from the jdk to be tested. - * - * @param addTestVmAndJavaOptions If true, adds test.vm.opts and test.java.opts - * to the java arguments. - * @param command Arguments to pass to the java command. - * @return The ProcessBuilder instance representing the java command. - */ - public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions, List command) { - return createJavaProcessBuilder(addTestVmAndJavaOptions, command.toArray(String[]::new)); + return createJavaProcessBuilder(command.toArray(String[]::new)); } /** @@ -295,18 +283,6 @@ public final class ProcessTools { * @return The ProcessBuilder instance representing the java command. */ public static ProcessBuilder createJavaProcessBuilder(String... command) { - return createJavaProcessBuilder(false, command); - } - - /** - * Create ProcessBuilder using the java launcher from the jdk to be tested. - * - * @param addTestVmAndJavaOptions If true, adds test.vm.opts and test.java.opts - * to the java arguments. - * @param command Arguments to pass to the java command. - * @return The ProcessBuilder instance representing the java command. - */ - public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions, String... command) { String javapath = JDKToolFinder.getJDKTool("java"); ArrayList args = new ArrayList<>(); @@ -315,10 +291,6 @@ public final class ProcessTools { args.add("-cp"); args.add(System.getProperty("java.class.path")); - if (addTestVmAndJavaOptions) { - Collections.addAll(args, Utils.getTestJavaOpts()); - } - Collections.addAll(args, command); // Reporting @@ -341,6 +313,36 @@ public final class ProcessTools { } } + /** + * Create ProcessBuilder using the java launcher from the jdk to be tested. + * The default jvm options from jtreg, test.vm.opts and test.java.opts, are added. + * + * The command line will be like: + * {test.jdk}/bin/java {test.vm.opts} {test.java.opts} cmds + * Create ProcessBuilder using the java launcher from the jdk to be tested. + * + * @param command Arguments to pass to the java command. + * @return The ProcessBuilder instance representing the java command. + */ + public static ProcessBuilder createTestJvm(List command) { + return createTestJvm(command.toArray(String[]::new)); + } + + /** + * Create ProcessBuilder using the java launcher from the jdk to be tested. + * The default jvm options from jtreg, test.vm.opts and test.java.opts, are added. + * + * The command line will be like: + * {test.jdk}/bin/java {test.vm.opts} {test.java.opts} cmds + * Create ProcessBuilder using the java launcher from the jdk to be tested. + * + * @param command Arguments to pass to the java command. + * @return The ProcessBuilder instance representing the java command. + */ + public static ProcessBuilder createTestJvm(String... command) { + return createJavaProcessBuilder(Utils.prependTestJavaOpts(command)); + } + /** * Executes a test jvm process, waits for it to finish and returns the process output. * The default jvm options from jtreg, test.vm.opts and test.java.opts, are added. @@ -372,7 +374,7 @@ public final class ProcessTools { * @return The output from the process. */ public static OutputAnalyzer executeTestJvm(String... cmds) throws Exception { - ProcessBuilder pb = createJavaProcessBuilder(true, cmds); + ProcessBuilder pb = createTestJvm(cmds); return executeProcess(pb); } From 00e15ff4e685ca011da33df7a9bc961ce3a8bb29 Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Tue, 5 May 2020 11:44:09 +0200 Subject: [PATCH 26/88] 8244326: Shenandoah: global statistics should not accept bogus samples Reviewed-by: rkennke --- .../gc/shenandoah/shenandoahPhaseTimings.cpp | 43 ++++++++++++++----- .../gc/shenandoah/shenandoahPhaseTimings.hpp | 1 + 2 files changed, 33 insertions(+), 11 deletions(-) diff --git a/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.cpp b/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.cpp index 853fcb82a8b..af6ed59b95d 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.cpp @@ -57,7 +57,7 @@ ShenandoahPhaseTimings::ShenandoahPhaseTimings(uint max_workers) : _worker_data[i] = NULL; SHENANDOAH_PAR_PHASE_DO(,, SHENANDOAH_WORKER_DATA_NULL) #undef SHENANDOAH_WORKER_DATA_NULL - _cycle_data[i] = 0; + _cycle_data[i] = uninitialized(); } // Then punch in the worker-related data. @@ -134,7 +134,7 @@ bool ShenandoahPhaseTimings::is_root_work_phase(Phase phase) { void ShenandoahPhaseTimings::set_cycle_data(Phase phase, double time) { #ifdef ASSERT double d = _cycle_data[phase]; - assert(d == 0, "Should not be set yet: %s, current value: %lf", phase_name(phase), d); + assert(d == uninitialized(), "Should not be set yet: %s, current value: %lf", phase_name(phase), d); #endif _cycle_data[phase] = time; } @@ -175,23 +175,44 @@ void ShenandoahPhaseTimings::flush_par_workers_to_cycle() { for (uint pi = 0; pi < _num_phases; pi++) { Phase phase = Phase(pi); if (is_worker_phase(phase)) { - double s = 0; + double s = uninitialized(); for (uint i = 1; i < _num_par_phases; i++) { - double t = worker_data(phase, ParPhase(i))->sum(); - // add to each line in phase - set_cycle_data(Phase(phase + i + 1), t); - s += t; + ShenandoahWorkerData* wd = worker_data(phase, ParPhase(i)); + double ws = uninitialized(); + for (uint c = 0; c < _max_workers; c++) { + double v = wd->get(c); + if (v != ShenandoahWorkerData::uninitialized()) { + if (ws == uninitialized()) { + ws = v; + } else { + ws += v; + } + } + } + if (ws != uninitialized()) { + // add to each line in phase + set_cycle_data(Phase(phase + i + 1), ws); + if (s == uninitialized()) { + s = ws; + } else { + s += ws; + } + } + } + if (s != uninitialized()) { + // add to total for phase + set_cycle_data(Phase(phase + 1), s); } - // add to total for phase - set_cycle_data(Phase(phase + 1), s); } } } void ShenandoahPhaseTimings::flush_cycle_to_global() { for (uint i = 0; i < _num_phases; i++) { - _global_data[i].add(_cycle_data[i]); - _cycle_data[i] = 0; + if (_cycle_data[i] != uninitialized()) { + _global_data[i].add(_cycle_data[i]); + _cycle_data[i] = uninitialized(); + } if (_worker_data[i] != NULL) { _worker_data[i]->reset(); } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp b/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp index 4381fca439d..5716b2ca6a9 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp @@ -195,6 +195,7 @@ private: Phase worker_par_phase(Phase phase, ParPhase par_phase); void set_cycle_data(Phase phase, double time); + static double uninitialized() { return -1; } public: ShenandoahPhaseTimings(uint _max_workers); From 1a0755008d0c7c400a2a11676981c98a12ebd16e Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Tue, 5 May 2020 08:11:44 -0700 Subject: [PATCH 27/88] 8244214: Change to VS2019 for building on Windows at Oracle Reviewed-by: mikael --- doc/building.html | 2 +- doc/building.md | 2 +- make/conf/jib-profiles.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/building.html b/doc/building.html index d715086f69b..0fd6c117fee 100644 --- a/doc/building.html +++ b/doc/building.html @@ -295,7 +295,7 @@ Windows -Microsoft Visual Studio 2017 update 15.9.16 +Microsoft Visual Studio 2019 update 16.5.3 diff --git a/doc/building.md b/doc/building.md index 32069933ec5..4eb8abee2f6 100644 --- a/doc/building.md +++ b/doc/building.md @@ -330,7 +330,7 @@ issues. Linux gcc 9.2.0 macOS Apple Xcode 10.1 (using clang 10.0.0) Solaris Oracle Solaris Studio 12.6 (with compiler version 5.15) - Windows Microsoft Visual Studio 2017 update 15.9.16 + Windows Microsoft Visual Studio 2019 update 16.5.3 All compilers are expected to be able to compile to the C99 language standard, as some C99 features are used in the source code. Microsoft Visual Studio diff --git a/make/conf/jib-profiles.js b/make/conf/jib-profiles.js index 01b874434eb..37042740286 100644 --- a/make/conf/jib-profiles.js +++ b/make/conf/jib-profiles.js @@ -986,7 +986,7 @@ var getJibProfilesDependencies = function (input, common) { macosx_x64: "Xcode10.1-MacOSX10.14+1.0", solaris_x64: "SS12u4-Solaris11u1+1.0", solaris_sparcv9: "SS12u6-Solaris11u3+1.0", - windows_x64: "VS2017-15.9.16+1.0", + windows_x64: "VS2019-16.5.3+1.0", linux_aarch64: "gcc9.2.0-OL7.6+1.0", linux_arm: "gcc8.2.0-Fedora27+1.0", linux_ppc64le: "gcc8.2.0-Fedora27+1.0", From 704749a094030470dcad61c0c207893dfb4265f4 Mon Sep 17 00:00:00 2001 From: Anirvan Sarkar Date: Tue, 5 May 2020 09:12:40 -0700 Subject: [PATCH 28/88] 8244293: Remove outdated @apiNote in java.util.Objects Reviewed-by: psandoz --- .../share/classes/java/util/Objects.java | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/src/java.base/share/classes/java/util/Objects.java b/src/java.base/share/classes/java/util/Objects.java index 8f4e72195ca..8cd0dddf18c 100644 --- a/src/java.base/share/classes/java/util/Objects.java +++ b/src/java.base/share/classes/java/util/Objects.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -37,20 +37,6 @@ import java.util.function.Supplier; * hash code of an object, returning a string for an object, comparing two * objects, and checking if indexes or sub-range values are out of bounds. * - * @apiNote - * Static methods such as {@link Objects#checkIndex}, - * {@link Objects#checkFromToIndex}, and {@link Objects#checkFromIndexSize} are - * provided for the convenience of checking if values corresponding to indexes - * and sub-ranges are out of bounds. - * Variations of these static methods support customization of the runtime - * exception, and corresponding exception detail message, that is thrown when - * values are out of bounds. Such methods accept a functional interface - * argument, instances of {@code BiFunction}, that maps out-of-bound values to a - * runtime exception. Care should be taken when using such methods in - * combination with an argument that is a lambda expression, method reference or - * class that capture values. In such cases the cost of capture, related to - * functional interface allocation, may exceed the cost of checking bounds. - * * @since 1.7 */ public final class Objects { From 5ac755681fa182c804d243e13a3d8905f6e6584f Mon Sep 17 00:00:00 2001 From: Zhengyu Gu Date: Tue, 5 May 2020 12:32:40 -0400 Subject: [PATCH 29/88] 8244420: Shenandoah: Ensure _disarmed_value offset < 128 Reviewed-by: rkennke --- .../share/gc/shenandoah/shenandoahThreadLocalData.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp b/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp index 133876de9cd..5ff5590c1b5 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahThreadLocalData.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved. + * Copyright (c) 2018, 2020, Red Hat, Inc. 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 @@ -56,6 +56,10 @@ private: _worker_id(INVALID_WORKER_ID), _force_satb_flush(false), _disarmed_value(ShenandoahCodeRoots::disarmed_value()) { + + // At least on x86_64, nmethod entry barrier encodes _disarmed_value offset + // in instruction as disp8 immed + assert(in_bytes(disarmed_value_offset()) < 128, "Offset range check"); } ~ShenandoahThreadLocalData() { From c976be69c3b39de6e3a58c2a7f5771c73e40bc51 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Tue, 5 May 2020 09:27:22 -0700 Subject: [PATCH 30/88] 8244385: various clean-ups in runtime tests Reviewed-by: minqi --- .../jtreg/runtime/8176717/TestInheritFD.java | 8 +- .../runtime/ClassFile/PreviewVersion.java | 4 +- .../CompressedClassSpaceSize.java | 107 ++++++++---------- .../BadNativeStackInErrorHandlingTest.java | 10 +- .../ErrorHandling/CreateCoredumpOnCrash.java | 11 +- .../jtreg/runtime/LoadClass/TestResize.java | 26 ++--- .../AssertSafepointCheckConsistency1.java | 29 ++--- .../AssertSafepointCheckConsistency2.java | 29 ++--- .../AssertSafepointCheckConsistency3.java | 32 +++--- .../AssertSafepointCheckConsistency4.java | 32 +++--- .../Safepoint/NoSafepointVerifier.java | 25 ++-- .../jtreg/runtime/Unsafe/RangeCheck.java | 11 +- .../appcds/TestCombinedCompressedFlags.java | 11 +- .../runtime/cds/appcds/TestZGCWithCDS.java | 48 ++++---- .../jtreg/runtime/logging/ItablesTest.java | 36 +++--- .../logging/RemovedDevelopFlagsTest.java | 26 ++--- .../LargePages/TestLargePageSizeInBytes.java | 9 +- .../memory/RunUnitTestsConcurrently.java | 8 +- .../symboltable/ShortLivedSymbolCleanup.java | 27 ++--- 19 files changed, 233 insertions(+), 256 deletions(-) diff --git a/test/hotspot/jtreg/runtime/8176717/TestInheritFD.java b/test/hotspot/jtreg/runtime/8176717/TestInheritFD.java index 7d540dfbe1f..dbc1e5bb124 100644 --- a/test/hotspot/jtreg/runtime/8176717/TestInheritFD.java +++ b/test/hotspot/jtreg/runtime/8176717/TestInheritFD.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -30,6 +30,7 @@ import static java.util.stream.Collectors.toList; import static jdk.test.lib.process.ProcessTools.createJavaProcessBuilder; import static jdk.test.lib.Platform.isWindows; import jdk.test.lib.Utils; +import jtreg.SkippedException; import java.io.BufferedReader; import java.io.File; @@ -50,6 +51,7 @@ import java.util.stream.Stream; * @library /test/lib * @modules java.base/jdk.internal.misc * java.management + * @run driver TestInheritFD */ /** @@ -83,9 +85,7 @@ public class TestInheritFD { File commFile = Utils.createTempFile("communication", ".txt").toFile(); if (!isWindows() && !lsofCommand().isPresent()) { - System.out.println("Could not find lsof like command"); - System.out.println("Exit test case as successful though it could not verify anything"); - return; + throw new SkippedException("Could not find lsof like command"); } ProcessBuilder pb = createJavaProcessBuilder( diff --git a/test/hotspot/jtreg/runtime/ClassFile/PreviewVersion.java b/test/hotspot/jtreg/runtime/ClassFile/PreviewVersion.java index 8bd2294fa60..6a0486c4c3e 100644 --- a/test/hotspot/jtreg/runtime/ClassFile/PreviewVersion.java +++ b/test/hotspot/jtreg/runtime/ClassFile/PreviewVersion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -64,12 +64,14 @@ public class PreviewVersion { "-cp", "." + File.pathSeparator + System.getProperty("test.classes"), "PVTest"); oa = new OutputAnalyzer(pb.start()); oa.shouldContain("Hi!"); + oa.shouldHaveExitValue(0); // Test -Xlog:class+preview pb = ProcessTools.createJavaProcessBuilder("--enable-preview", "-Xlog:class+preview", "-cp", "." + File.pathSeparator + System.getProperty("test.classes"), "PVTest"); oa = new OutputAnalyzer(pb.start()); oa.shouldContain("[info][class,preview] Loading class PVTest that depends on preview features"); + oa.shouldHaveExitValue(0); // Subtract 1 from class's major version. The class should fail to load // because its major_version does not match the JVM current version. diff --git a/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassSpaceSize.java b/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassSpaceSize.java index a2476e4bfba..0e12a067f15 100644 --- a/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassSpaceSize.java +++ b/test/hotspot/jtreg/runtime/CompressedOops/CompressedClassSpaceSize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -29,9 +29,9 @@ * @library /test/lib * @modules java.base/jdk.internal.misc * java.management - * @run main CompressedClassSpaceSize + * @run driver CompressedClassSpaceSize */ -import jdk.test.lib.Platform; + import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; @@ -40,71 +40,62 @@ public class CompressedClassSpaceSize { public static void main(String[] args) throws Exception { ProcessBuilder pb; OutputAnalyzer output; - if (Platform.is64bit()) { - // Minimum size is 1MB - pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=0", - "-version"); - output = new OutputAnalyzer(pb.start()); - output.shouldContain("outside the allowed range") - .shouldHaveExitValue(1); + // Minimum size is 1MB + pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=0", + "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("outside the allowed range") + .shouldHaveExitValue(1); - // Invalid size of -1 should be handled correctly - pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=-1", - "-version"); - output = new OutputAnalyzer(pb.start()); - output.shouldContain("Improperly specified VM option 'CompressedClassSpaceSize=-1'") - .shouldHaveExitValue(1); + // Invalid size of -1 should be handled correctly + pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=-1", + "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("Improperly specified VM option 'CompressedClassSpaceSize=-1'") + .shouldHaveExitValue(1); - // Maximum size is 3GB - pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=4g", - "-version"); - output = new OutputAnalyzer(pb.start()); - output.shouldContain("outside the allowed range") - .shouldHaveExitValue(1); + // Maximum size is 3GB + pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=4g", + "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("outside the allowed range") + .shouldHaveExitValue(1); - // Make sure the minimum size is set correctly and printed - pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", - "-XX:CompressedClassSpaceSize=1m", - "-Xlog:gc+metaspace=trace", - "-version"); - output = new OutputAnalyzer(pb.start()); - output.shouldContain("Compressed class space size: 1048576") - .shouldHaveExitValue(0); + // Make sure the minimum size is set correctly and printed + pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", + "-XX:CompressedClassSpaceSize=1m", + "-Xlog:gc+metaspace=trace", + "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("Compressed class space size: 1048576") + .shouldHaveExitValue(0); - // Make sure the maximum size is set correctly and printed - pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", - "-XX:CompressedClassSpaceSize=3g", - "-Xlog:gc+metaspace=trace", - "-version"); - output = new OutputAnalyzer(pb.start()); - output.shouldContain("Compressed class space size: 3221225472") - .shouldHaveExitValue(0); + // Make sure the maximum size is set correctly and printed + pb = ProcessTools.createJavaProcessBuilder("-XX:+UnlockDiagnosticVMOptions", + "-XX:CompressedClassSpaceSize=3g", + "-Xlog:gc+metaspace=trace", + "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("Compressed class space size: 3221225472") + .shouldHaveExitValue(0); - pb = ProcessTools.createJavaProcessBuilder("-XX:-UseCompressedOops", - "-XX:CompressedClassSpaceSize=1m", - "-version"); - output = new OutputAnalyzer(pb.start()); - output.shouldContain("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used") - .shouldHaveExitValue(0); + pb = ProcessTools.createJavaProcessBuilder("-XX:-UseCompressedOops", + "-XX:CompressedClassSpaceSize=1m", + "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used") + .shouldHaveExitValue(0); - pb = ProcessTools.createJavaProcessBuilder("-XX:-UseCompressedClassPointers", - "-XX:CompressedClassSpaceSize=1m", - "-version"); - output = new OutputAnalyzer(pb.start()); - output.shouldContain("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used") - .shouldHaveExitValue(0); - } else { - // 32bit platforms doesn't have compressed oops - pb = ProcessTools.createJavaProcessBuilder("-XX:CompressedClassSpaceSize=1m", - "-version"); - output = new OutputAnalyzer(pb.start()); - output.shouldContain("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used") - .shouldHaveExitValue(0); - } + pb = ProcessTools.createJavaProcessBuilder("-XX:-UseCompressedClassPointers", + "-XX:CompressedClassSpaceSize=1m", + "-version"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("Setting CompressedClassSpaceSize has no effect when compressed class pointers are not used") + .shouldHaveExitValue(0); } } diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/BadNativeStackInErrorHandlingTest.java b/test/hotspot/jtreg/runtime/ErrorHandling/BadNativeStackInErrorHandlingTest.java index fd036a4a71a..64faeada1eb 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/BadNativeStackInErrorHandlingTest.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/BadNativeStackInErrorHandlingTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -27,7 +27,6 @@ import java.io.FileInputStream; import java.io.InputStreamReader; import java.util.regex.Pattern; -import jdk.test.lib.Platform; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; @@ -36,16 +35,15 @@ import jdk.test.lib.process.ProcessTools; * @bug 8194652 * @summary Printing native stack shows an "error occurred during error reporting". * @modules java.base/jdk.internal.misc + * @requires vm.debug + * @requires vm.flavor != "zero" * @library /test/lib + * @run driver BadNativeStackInErrorHandlingTest */ // This test was adapted from SafeFetchInErrorHandlingTest.java. public class BadNativeStackInErrorHandlingTest { public static void main(String[] args) throws Exception { - if (!Platform.isDebugBuild() || Platform.isZero()) { - return; - } - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( "-XX:+UnlockDiagnosticVMOptions", "-Xmx100M", diff --git a/test/hotspot/jtreg/runtime/ErrorHandling/CreateCoredumpOnCrash.java b/test/hotspot/jtreg/runtime/ErrorHandling/CreateCoredumpOnCrash.java index 6946866abb6..36502046570 100644 --- a/test/hotspot/jtreg/runtime/ErrorHandling/CreateCoredumpOnCrash.java +++ b/test/hotspot/jtreg/runtime/ErrorHandling/CreateCoredumpOnCrash.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -44,13 +44,16 @@ public class CreateCoredumpOnCrash { } public static void main(String[] args) throws Exception { - runTest("-XX:-CreateCoredumpOnCrash").shouldContain("CreateCoredumpOnCrash turned off, no core file dumped"); + runTest("-XX:-CreateCoredumpOnCrash").shouldContain("CreateCoredumpOnCrash turned off, no core file dumped") + .shouldNotHaveExitValue(0); if (Platform.isWindows()) { // The old CreateMinidumpOnCrash option should still work - runTest("-XX:-CreateMinidumpOnCrash").shouldContain("CreateCoredumpOnCrash turned off, no core file dumped"); + runTest("-XX:-CreateMinidumpOnCrash").shouldContain("CreateCoredumpOnCrash turned off, no core file dumped") + .shouldNotHaveExitValue(0); } else { - runTest("-XX:+CreateCoredumpOnCrash").shouldNotContain("CreateCoredumpOnCrash turned off, no core file dumped"); + runTest("-XX:+CreateCoredumpOnCrash").shouldNotContain("CreateCoredumpOnCrash turned off, no core file dumped") + .shouldNotHaveExitValue(0); } } diff --git a/test/hotspot/jtreg/runtime/LoadClass/TestResize.java b/test/hotspot/jtreg/runtime/LoadClass/TestResize.java index ecc6a07da37..609f3ab890d 100644 --- a/test/hotspot/jtreg/runtime/LoadClass/TestResize.java +++ b/test/hotspot/jtreg/runtime/LoadClass/TestResize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -25,11 +25,11 @@ * @test * @bug 8184765 * @summary make sure the SystemDictionary gets resized when load factor is too high + * @requires vm.debug * @library /test/lib * @modules java.base/jdk.internal.misc * java.management * @compile TriggerResize.java - * @requires (vm.debug == true) * @run driver TestResize */ @@ -112,16 +112,14 @@ public class TestResize { } public static void main(String[] args) throws Exception { - if (Platform.isDebugBuild()) { - // -XX:+PrintSystemDictionaryAtExit will print the details of system dictionary, - // that will allow us to calculate the table's load factor. - // -Xlog:safepoint+cleanup will print out cleanup details at safepoint - // that will allow us to detect if the system dictionary resized. - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintSystemDictionaryAtExit", - "-Xlog:safepoint+cleanup", - "TriggerResize", - "50000"); - analyzeOutputOn(pb); - } + // -XX:+PrintSystemDictionaryAtExit will print the details of system dictionary, + // that will allow us to calculate the table's load factor. + // -Xlog:safepoint+cleanup will print out cleanup details at safepoint + // that will allow us to detect if the system dictionary resized. + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintSystemDictionaryAtExit", + "-Xlog:safepoint+cleanup", + "TriggerResize", + "50000"); + analyzeOutputOn(pb); } -} \ No newline at end of file +} diff --git a/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency1.java b/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency1.java index 9ae6cc2f506..e2315f8d0df 100644 --- a/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency1.java +++ b/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency1.java @@ -25,17 +25,17 @@ * @test * @bug 8047290 * @summary Ensure that a Monitor::lock_without_safepoint_check fires an assert when it incorrectly acquires a lock which must always have safepoint checks. + * @requires vm.debug * @library /test/lib * @modules java.base/jdk.internal.misc * java.management * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller sun.hotspot.WhiteBox - * @run main AssertSafepointCheckConsistency1 + * @run driver AssertSafepointCheckConsistency1 */ import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.Platform; import sun.hotspot.WhiteBox; @@ -43,18 +43,19 @@ public class AssertSafepointCheckConsistency1 { public static void main(String args[]) throws Exception { if (args.length > 0) { WhiteBox.getWhiteBox().assertMatchingSafepointCalls(true, true); + return; } - if (Platform.isDebugBuild()){ - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-Xbootclasspath/a:.", - "-XX:+UnlockDiagnosticVMOptions", - "-XX:+WhiteBoxAPI", - "-XX:-CreateCoredumpOnCrash", - "-Xmx128m", - "AssertSafepointCheckConsistency1", - "test"); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("assert").shouldContain("always"); - } + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-Xbootclasspath/a:.", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI", + "-XX:-CreateCoredumpOnCrash", + "-Xmx128m", + "AssertSafepointCheckConsistency1", + "test"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain("assert") + .shouldContain("always") + .shouldNotHaveExitValue(0); } } diff --git a/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency2.java b/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency2.java index f676ff831db..d677ce94c17 100644 --- a/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency2.java +++ b/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency2.java @@ -25,17 +25,17 @@ * @test * @bug 8047290 * @summary Ensure that a Monitor::lock fires an assert when it incorrectly acquires a lock which must never have safepoint checks. + * @requires vm.debug * @library /test/lib * @modules java.base/jdk.internal.misc * java.management * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller sun.hotspot.WhiteBox - * @run main AssertSafepointCheckConsistency2 + * @run driver AssertSafepointCheckConsistency2 */ import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.Platform; import sun.hotspot.WhiteBox; @@ -43,19 +43,20 @@ public class AssertSafepointCheckConsistency2 { public static void main(String args[]) throws Exception { if (args.length > 0) { WhiteBox.getWhiteBox().assertMatchingSafepointCalls(false, false); + return; } - if (Platform.isDebugBuild()){ - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-Xbootclasspath/a:.", - "-XX:+UnlockDiagnosticVMOptions", - "-XX:+WhiteBoxAPI", - "-XX:-CreateCoredumpOnCrash", - "-Xmx128m", - "AssertSafepointCheckConsistency2", - "test"); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-Xbootclasspath/a:.", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI", + "-XX:-CreateCoredumpOnCrash", + "-Xmx128m", + "AssertSafepointCheckConsistency2", + "test"); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain("assert").shouldContain("never"); - } + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain("assert") + .shouldContain("never") + .shouldNotHaveExitValue(0); } } diff --git a/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency3.java b/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency3.java index 92c19ce66db..bd6d5cba638 100644 --- a/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency3.java +++ b/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency3.java @@ -25,17 +25,17 @@ * @test * @bug 8047290 * @summary Ensure that Monitor::lock_without_safepoint_check does not assert when it correctly acquires a lock which must never have safepoint checks. + * @requires vm.debug * @library /test/lib * @modules java.base/jdk.internal.misc * java.management * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller sun.hotspot.WhiteBox - * @run main AssertSafepointCheckConsistency3 + * @run driver AssertSafepointCheckConsistency3 */ import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.Platform; import sun.hotspot.WhiteBox; @@ -43,21 +43,21 @@ public class AssertSafepointCheckConsistency3 { public static void main(String args[]) throws Exception { if (args.length > 0) { WhiteBox.getWhiteBox().assertMatchingSafepointCalls(false, true); + return; } - if (Platform.isDebugBuild()){ - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-Xbootclasspath/a:.", - "-XX:+UnlockDiagnosticVMOptions", - "-XX:+WhiteBoxAPI", - "-XX:-CreateCoredumpOnCrash", - "-Xmx32m", - "AssertSafepointCheckConsistency3", - "test"); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-Xbootclasspath/a:.", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI", + "-XX:-CreateCoredumpOnCrash", + "-Xmx32m", + "AssertSafepointCheckConsistency3", + "test"); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldNotContain("assert"); - output.shouldNotContain("never"); - output.shouldNotContain("always"); - } + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldNotContain("assert") + .shouldNotContain("never") + .shouldNotContain("always") + .shouldHaveExitValue(0); } } diff --git a/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency4.java b/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency4.java index b7eed265e76..6397b0a11f8 100644 --- a/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency4.java +++ b/test/hotspot/jtreg/runtime/Safepoint/AssertSafepointCheckConsistency4.java @@ -25,17 +25,17 @@ * @test * @bug 8047290 * @summary Ensure that Monitor::lock does not assert when it correctly acquires a lock which must always have safepoint checks. + * @requires vm.debug * @library /test/lib * @modules java.base/jdk.internal.misc * java.management * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller sun.hotspot.WhiteBox - * @run main AssertSafepointCheckConsistency4 + * @run driver AssertSafepointCheckConsistency4 */ import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.Platform; import sun.hotspot.WhiteBox; @@ -43,22 +43,22 @@ public class AssertSafepointCheckConsistency4 { public static void main(String args[]) throws Exception { if (args.length > 0) { WhiteBox.getWhiteBox().assertMatchingSafepointCalls(true, false); + return; } - if (Platform.isDebugBuild()){ - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-Xbootclasspath/a:.", - "-XX:+UnlockDiagnosticVMOptions", - "-XX:+WhiteBoxAPI", - "-XX:-CreateCoredumpOnCrash", - "-Xmx32m", - "AssertSafepointCheckConsistency4", - "test"); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-Xbootclasspath/a:.", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI", + "-XX:-CreateCoredumpOnCrash", + "-Xmx32m", + "AssertSafepointCheckConsistency4", + "test"); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldNotContain("assert"); - output.shouldNotContain("never"); - output.shouldNotContain("always"); - } + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldNotContain("assert") + .shouldNotContain("never") + .shouldNotContain("always") + .shouldHaveExitValue(0); } } diff --git a/test/hotspot/jtreg/runtime/Safepoint/NoSafepointVerifier.java b/test/hotspot/jtreg/runtime/Safepoint/NoSafepointVerifier.java index a0a4c052455..0c004b43d83 100644 --- a/test/hotspot/jtreg/runtime/Safepoint/NoSafepointVerifier.java +++ b/test/hotspot/jtreg/runtime/Safepoint/NoSafepointVerifier.java @@ -25,34 +25,33 @@ * @test * @bug 8184732 * @summary Ensure that special locks never safepoint check. + * @requires vm.debug * @library /test/lib * @modules java.base/jdk.internal.misc * java.management * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller sun.hotspot.WhiteBox - * @run main NoSafepointVerifier + * @run driver NoSafepointVerifier */ import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.Platform; import sun.hotspot.WhiteBox; public class NoSafepointVerifier { static void runTest(String test) throws Exception { - if (Platform.isDebugBuild()){ - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( - "-Xbootclasspath/a:.", - "-XX:+UnlockDiagnosticVMOptions", - "-XX:+WhiteBoxAPI", - "-XX:-CreateCoredumpOnCrash", - "NoSafepointVerifier", - test); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain(test); - } + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + "-Xbootclasspath/a:.", + "-XX:+UnlockDiagnosticVMOptions", + "-XX:+WhiteBoxAPI", + "-XX:-CreateCoredumpOnCrash", + "NoSafepointVerifier", + test); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain(test) + .shouldNotHaveExitValue(0); } static String test1 = "Special locks or below should never safepoint"; diff --git a/test/hotspot/jtreg/runtime/Unsafe/RangeCheck.java b/test/hotspot/jtreg/runtime/Unsafe/RangeCheck.java index 31b6279b1b8..2f9ae3fddff 100644 --- a/test/hotspot/jtreg/runtime/Unsafe/RangeCheck.java +++ b/test/hotspot/jtreg/runtime/Unsafe/RangeCheck.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -25,25 +25,21 @@ * @test * @bug 8001071 * @summary Add simple range check into VM implemenation of Unsafe access methods + * @requires vm.debug * @library /test/lib * @modules java.base/jdk.internal.misc * java.management + * @run driver RangeCheck */ import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.Platform; import jdk.internal.misc.Unsafe; public class RangeCheck { public static void main(String args[]) throws Exception { - if (!Platform.isDebugBuild()) { - System.out.println("Testing assert which requires a debug build. Passing silently."); - return; - } - ProcessBuilder pb = ProcessTools.createTestJvm( "-Xmx128m", "--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED", @@ -53,6 +49,7 @@ public class RangeCheck { OutputAnalyzer output = new OutputAnalyzer(pb.start()); output.shouldMatch("assert\\(byte_offset < p_size\\) failed: Unsafe access: offset \\d+ > object's size \\d+"); + output.shouldNotHaveExitValue(0); } public static class DummyClassWithMainRangeCheck { diff --git a/test/hotspot/jtreg/runtime/cds/appcds/TestCombinedCompressedFlags.java b/test/hotspot/jtreg/runtime/cds/appcds/TestCombinedCompressedFlags.java index 6ca6b147d98..244a5b738df 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/TestCombinedCompressedFlags.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/TestCombinedCompressedFlags.java @@ -26,18 +26,17 @@ * @bug 8232069 * @summary Testing different combination of CompressedOops and CompressedClassPointers * @requires vm.cds - * @requires (vm.gc=="null") + * @requires vm.gc == "null" + * @requires vm.bits == 64 * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @compile test-classes/Hello.java * @modules java.base/jdk.internal.misc - * @run main/othervm TestCombinedCompressedFlags + * @run driver TestCombinedCompressedFlags */ -import jdk.test.lib.Platform; import jdk.test.lib.process.OutputAnalyzer; import java.util.List; import java.util.ArrayList; -import jtreg.SkippedException; public class TestCombinedCompressedFlags { public static String HELLO_STRING = "Hello World"; @@ -161,10 +160,6 @@ public class TestCombinedCompressedFlags { } public static void main(String[] args) throws Exception { - if (!Platform.is64bit()) { - throw new SkippedException("Platform is not 64 bit, skipped"); - } - String helloJar = JarBuilder.build("hello", "Hello"); configureRunArgs(); OutputAnalyzer out; diff --git a/test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithCDS.java b/test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithCDS.java index cf79a9bdb44..3c078619b5d 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithCDS.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithCDS.java @@ -1,38 +1,46 @@ +/* + * 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 8232069 for ZGC * @requires vm.cds - * @requires (vm.gc=="null") + * @requires vm.bits == 64 + * @requires vm.gc.Z + * @comment Graal does not support ZGC + * @requires !vm.graal.enabled * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @compile test-classes/Hello.java - * @build sun.hotspot.WhiteBox - * @run driver ClassFileInstaller sun.hotspot.WhiteBox - * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. TestZGCWithCDS + * @run driver TestZGCWithCDS */ import jdk.test.lib.Platform; import jdk.test.lib.process.OutputAnalyzer; -import jtreg.SkippedException; - -import sun.hotspot.gc.GC; -import sun.hotspot.code.Compiler; public class TestZGCWithCDS { public final static String HELLO = "Hello World"; public final static String UNABLE_TO_USE_ARCHIVE = "Unable to use shared archive."; public final static String ERR_MSG = "The saved state of UseCompressedOops and UseCompressedClassPointers is different from runtime, CDS will be disabled."; public static void main(String... args) throws Exception { - // The test is only for 64-bit - if (!Platform.is64bit()) { - throw new SkippedException("Platform is not 64 bit, skipped"); - } - - // Platform must support ZGC - if (!GC.Z.isSupported()) { - throw new SkippedException("Platform does not support ZGC, skipped"); - } else if (Compiler.isGraalEnabled()) { - throw new SkippedException("Graal does not support ZGC, skipped"); - } - String helloJar = JarBuilder.build("hello", "Hello"); // 0. dump with ZGC System.out.println("0. Dump with ZGC"); diff --git a/test/hotspot/jtreg/runtime/logging/ItablesTest.java b/test/hotspot/jtreg/runtime/logging/ItablesTest.java index 2209fb0e53d..fb94256bf94 100644 --- a/test/hotspot/jtreg/runtime/logging/ItablesTest.java +++ b/test/hotspot/jtreg/runtime/logging/ItablesTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -26,6 +26,7 @@ * @bug 8141564 * @summary itables=trace should have logging from each of the statements * in the code + * @requires vm.debug * @library /test/lib * @compile ClassB.java * ItablesVtableTest.java @@ -36,27 +37,24 @@ import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.Platform; public class ItablesTest { public static void main(String[] args) throws Exception { - if (Platform.isDebugBuild()) { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:itables=trace", "ClassB"); - OutputAnalyzer output = new OutputAnalyzer(pb.start()); - output.shouldContain(": Initializing itables for ClassB"); - output.shouldContain(": Initializing itable indices for interface "); - output.shouldContain("itable index "); - output.shouldContain("target: ClassB.Method1()V, method_holder: ClassB target_method flags: public"); - output.shouldContain("invokeinterface resolved interface method: caller-class"); - output.shouldContain("invokespecial resolved method: caller-class:ClassB"); - output.shouldContain("invokespecial selected method: resolved-class:ClassB"); - output.shouldContain("invokeinterface selected method: receiver-class"); - output.shouldHaveExitValue(0); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:itables=trace", "ClassB"); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + output.shouldContain(": Initializing itables for ClassB"); + output.shouldContain(": Initializing itable indices for interface "); + output.shouldContain("itable index "); + output.shouldContain("target: ClassB.Method1()V, method_holder: ClassB target_method flags: public"); + output.shouldContain("invokeinterface resolved interface method: caller-class"); + output.shouldContain("invokespecial resolved method: caller-class:ClassB"); + output.shouldContain("invokespecial selected method: resolved-class:ClassB"); + output.shouldContain("invokeinterface selected method: receiver-class"); + output.shouldHaveExitValue(0); - pb = ProcessTools.createJavaProcessBuilder("-Xlog:itables=trace", "ItablesVtableTest"); - output = new OutputAnalyzer(pb.start()); - output.shouldContain("vtable index "); - output.shouldHaveExitValue(0); - } + pb = ProcessTools.createJavaProcessBuilder("-Xlog:itables=trace", "ItablesVtableTest"); + output = new OutputAnalyzer(pb.start()); + output.shouldContain("vtable index "); + output.shouldHaveExitValue(0); } } diff --git a/test/hotspot/jtreg/runtime/logging/RemovedDevelopFlagsTest.java b/test/hotspot/jtreg/runtime/logging/RemovedDevelopFlagsTest.java index a53749812a0..9c9ce86b7cd 100644 --- a/test/hotspot/jtreg/runtime/logging/RemovedDevelopFlagsTest.java +++ b/test/hotspot/jtreg/runtime/logging/RemovedDevelopFlagsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 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 @@ -26,10 +26,10 @@ * @test RemovedDevelopFlagsTest * @bug 8146632 * @modules java.base/jdk.internal.misc + * @requires vm.debug * @library /test/lib * @run driver RemovedDevelopFlagsTest */ -import jdk.test.lib.Platform; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; @@ -50,16 +50,14 @@ public class RemovedDevelopFlagsTest { } public static void main(String... args) throws Exception { - if (Platform.isDebugBuild()){ - exec("TraceClassInitialization", "-Xlog:class+init"); - exec("TraceClassLoaderData", "-Xlog:class+loader+data"); - exec("TraceDefaultMethods", "-Xlog:defaultmethods=debug"); - exec("TraceItables", "-Xlog:itables=debug"); - exec("TraceSafepoint", "-Xlog:safepoint=debug"); - exec("TraceStartupTime", "-Xlog:startuptime"); - exec("TraceVMOperation", "-Xlog:vmoperation=debug"); - exec("PrintVtables", "-Xlog:vtables=debug"); - exec("VerboseVerification", "-Xlog:verification"); - } - }; + exec("TraceClassInitialization", "-Xlog:class+init"); + exec("TraceClassLoaderData", "-Xlog:class+loader+data"); + exec("TraceDefaultMethods", "-Xlog:defaultmethods=debug"); + exec("TraceItables", "-Xlog:itables=debug"); + exec("TraceSafepoint", "-Xlog:safepoint=debug"); + exec("TraceStartupTime", "-Xlog:startuptime"); + exec("TraceVMOperation", "-Xlog:vmoperation=debug"); + exec("PrintVtables", "-Xlog:vtables=debug"); + exec("VerboseVerification", "-Xlog:verification"); + } } diff --git a/test/hotspot/jtreg/runtime/memory/LargePages/TestLargePageSizeInBytes.java b/test/hotspot/jtreg/runtime/memory/LargePages/TestLargePageSizeInBytes.java index 37b06f71936..0957a92a6ca 100644 --- a/test/hotspot/jtreg/runtime/memory/LargePages/TestLargePageSizeInBytes.java +++ b/test/hotspot/jtreg/runtime/memory/LargePages/TestLargePageSizeInBytes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -24,6 +24,7 @@ /* @test TestLargePageSizeInBytes * @summary Tests that the flag -XX:LargePageSizeInBytes does not cause warnings on Solaris * @bug 8049536 + * @requires os.family == "solaris" * @library /test/lib * @modules java.base/jdk.internal.misc * java.management @@ -31,7 +32,6 @@ */ import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.Platform; import jdk.test.lib.process.ProcessTools; public class TestLargePageSizeInBytes { @@ -39,11 +39,6 @@ public class TestLargePageSizeInBytes { private static long G = 1024L * M; public static void main(String[] args) throws Exception { - if (!Platform.isSolaris()) { - // We only use the syscall mencntl on Solaris - return; - } - testLargePageSizeInBytes(4 * M); testLargePageSizeInBytes(256 * M); testLargePageSizeInBytes(512 * M); diff --git a/test/hotspot/jtreg/runtime/memory/RunUnitTestsConcurrently.java b/test/hotspot/jtreg/runtime/memory/RunUnitTestsConcurrently.java index a94f58168cd..4c8b17da750 100644 --- a/test/hotspot/jtreg/runtime/memory/RunUnitTestsConcurrently.java +++ b/test/hotspot/jtreg/runtime/memory/RunUnitTestsConcurrently.java @@ -24,6 +24,8 @@ /* * @test * @summary Test launches unit tests inside vm concurrently + * @requires vm.debug + * @requires vm.bits == 64 * @library /test/lib * @modules java.base/jdk.internal.misc * java.management @@ -32,7 +34,6 @@ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI RunUnitTestsConcurrently 30 15000 */ -import jdk.test.lib.Platform; import sun.hotspot.WhiteBox; public class RunUnitTestsConcurrently { @@ -45,15 +46,12 @@ public class RunUnitTestsConcurrently { @Override public void run() { while (System.currentTimeMillis() - timeStamp < timeout) { - WhiteBox.getWhiteBox().runMemoryUnitTests(); + wb.runMemoryUnitTests(); } } } public static void main(String[] args) throws InterruptedException { - if (!Platform.isDebugBuild() || !Platform.is64bit()) { - return; - } wb = WhiteBox.getWhiteBox(); System.out.println("Starting threads"); diff --git a/test/hotspot/jtreg/runtime/symboltable/ShortLivedSymbolCleanup.java b/test/hotspot/jtreg/runtime/symboltable/ShortLivedSymbolCleanup.java index a664aaf9e20..b14542862d1 100644 --- a/test/hotspot/jtreg/runtime/symboltable/ShortLivedSymbolCleanup.java +++ b/test/hotspot/jtreg/runtime/symboltable/ShortLivedSymbolCleanup.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -25,13 +25,13 @@ * @test * @bug 8195100 * @summary a short lived Symbol should be cleaned up + * @requires vm.debug * @library /test/lib * @modules java.base/jdk.internal.misc * java.management - * @requires (vm.debug == true) + * @run driver ShortLivedSymbolCleanup */ -import jdk.test.lib.Platform; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; import java.util.Scanner; @@ -88,19 +88,14 @@ public class ShortLivedSymbolCleanup { } public static void main(String[] args) throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:symboltable=trace", + "-version"); + int size = getSymbolTableSize(pb); - if (Platform.isDebugBuild()) { - { - ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:symboltable=trace", - "-version"); - int size = getSymbolTableSize(pb); - - pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintSymbolTableSizeHistogram", - LotsOfTempSymbols.class.getName(), - Integer.toString(size)); - analyzeOutputOn(size, pb); - } - } + pb = ProcessTools.createJavaProcessBuilder("-XX:+PrintSymbolTableSizeHistogram", + LotsOfTempSymbols.class.getName(), + Integer.toString(size)); + analyzeOutputOn(size, pb); } static class LotsOfTempSymbols { @@ -116,4 +111,4 @@ public class ShortLivedSymbolCleanup { } } } -} \ No newline at end of file +} From a899004d4eb5e7700b36c0ef0414905eecc373c7 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Tue, 5 May 2020 09:27:24 -0700 Subject: [PATCH 31/88] 8244384: @requires-related clean up in gc/metaspace/ tests Reviewed-by: kbarrett, stefank --- .../CompressedClassSpaceSizeInJmapHeap.java | 6 ------ .../TestCapacityUntilGCWrapAround.java | 20 +++++++++---------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/test/hotspot/jtreg/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java b/test/hotspot/jtreg/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java index b9e808601d6..92c4bb93806 100644 --- a/test/hotspot/jtreg/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java +++ b/test/hotspot/jtreg/gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java @@ -36,7 +36,6 @@ package gc.metaspace; */ import jdk.test.lib.JDKToolLauncher; -import jdk.test.lib.Platform; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.SA.SATestUtils; @@ -50,11 +49,6 @@ public class CompressedClassSpaceSizeInJmapHeap { public static void main(String[] args) throws Exception { SATestUtils.skipIfCannotAttach(); // throws SkippedException if attach not expected to work. - if (!Platform.is64bit()) { - // Compressed Class Space is only available on 64-bit JVMs - return; - } - String pid = Long.toString(ProcessTools.getProcessId()); JDKToolLauncher jmap = JDKToolLauncher.create("jhsdb") diff --git a/test/hotspot/jtreg/gc/metaspace/TestCapacityUntilGCWrapAround.java b/test/hotspot/jtreg/gc/metaspace/TestCapacityUntilGCWrapAround.java index 6438503e62a..737b11c5d9d 100644 --- a/test/hotspot/jtreg/gc/metaspace/TestCapacityUntilGCWrapAround.java +++ b/test/hotspot/jtreg/gc/metaspace/TestCapacityUntilGCWrapAround.java @@ -30,6 +30,7 @@ package gc.metaspace; * @library /test/lib * @modules java.base/jdk.internal.misc * java.management + * @requires vm.bits == 32 * @build sun.hotspot.WhiteBox * @run driver ClassFileInstaller sun.hotspot.WhiteBox * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI gc.metaspace.TestCapacityUntilGCWrapAround @@ -38,7 +39,6 @@ package gc.metaspace; import sun.hotspot.WhiteBox; import jdk.test.lib.Asserts; -import jdk.test.lib.Platform; public class TestCapacityUntilGCWrapAround { private static long MB = 1024 * 1024; @@ -46,17 +46,15 @@ public class TestCapacityUntilGCWrapAround { private static long MAX_UINT = 4 * GB - 1; // On 32-bit platforms public static void main(String[] args) { - if (Platform.is32bit()) { - WhiteBox wb = WhiteBox.getWhiteBox(); + WhiteBox wb = WhiteBox.getWhiteBox(); - long before = wb.metaspaceCapacityUntilGC(); - // Now force possible overflow of capacity_until_GC. - long after = wb.incMetaspaceCapacityUntilGC(MAX_UINT); + long before = wb.metaspaceCapacityUntilGC(); + // Now force possible overflow of capacity_until_GC. + long after = wb.incMetaspaceCapacityUntilGC(MAX_UINT); - Asserts.assertGTE(after, before, - "Increasing with MAX_UINT should not cause wrap around: " + after + " < " + before); - Asserts.assertLTE(after, MAX_UINT, - "Increasing with MAX_UINT should not cause value larger than MAX_UINT:" + after); - } + Asserts.assertGTE(after, before, + "Increasing with MAX_UINT should not cause wrap around: " + after + " < " + before); + Asserts.assertLTE(after, MAX_UINT, + "Increasing with MAX_UINT should not cause value larger than MAX_UINT:" + after); } } From 80d280263a4afe9130029c8032ce6cbe2c69e81e Mon Sep 17 00:00:00 2001 From: Fernando Guallini Date: Tue, 5 May 2020 16:35:48 +0000 Subject: [PATCH 32/88] 8183266: [TESTBUG]Add test to cover XPathEvaluationResult.XPathResultType.getQNameType method Reviewed-by: joehw --- .../xml/xpath/XPathEvaluationResult.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/java.xml/share/classes/javax/xml/xpath/XPathEvaluationResult.java b/src/java.xml/share/classes/javax/xml/xpath/XPathEvaluationResult.java index 8ac93b878c6..b6f78fc832e 100644 --- a/src/java.xml/share/classes/javax/xml/xpath/XPathEvaluationResult.java +++ b/src/java.xml/share/classes/javax/xml/xpath/XPathEvaluationResult.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -85,17 +85,30 @@ public interface XPathEvaluationResult { /** * Compares this type to the specified class type. * @param clsType class type - * @return true if the argument is not null and is a class type that + * @return true if the argument is not null and is a class type or accepted subtype that * matches that this type represents, false otherwise. */ private boolean equalsClassType(Class clsType) { - Objects.nonNull(clsType); - if (clsType.isAssignableFrom(this.clsType)) { + if (Objects.nonNull(clsType) && this.clsType.isAssignableFrom(clsType)) { + if (this.clsType == Number.class) { + return isAcceptedNumberSubType(clsType); + } return true; } return false; } + /** + * Compares the specified class type to accepted subtypes of number. + * @param clsType class type + * @return true if class type is an accepted subtype of Number, false otherwise + */ + private boolean isAcceptedNumberSubType(Class clsType) { + return clsType.isAssignableFrom(Double.class) || + clsType.isAssignableFrom(Integer.class) || + clsType.isAssignableFrom(Long.class); + } + /** * Returns the QName type as specified in {@link XPathConstants} that * corresponds to the specified class type. @@ -103,7 +116,7 @@ public interface XPathEvaluationResult { * @return the QName type that matches with the specified class type, * null if there is no match */ - static public QName getQNameType(Class clsType) { + static public QName getQNameType(Class clsType) { for (XPathResultType type : XPathResultType.values()) { if (type.equalsClassType(clsType)) { return type.qnameType; From 0b7a47665f9b78ccf35275b678502c8aa3d55957 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Tue, 5 May 2020 09:54:51 -0700 Subject: [PATCH 33/88] 8243431: use reproducible random in :vmTestbase_vm_metaspace Reviewed-by: dholmes --- .../flags/maxMetaspaceSize/TestMaxMetaspaceSize.java | 1 + .../metaspace/staticReferences/StaticReferences.java | 1 + .../metaspace/stressDictionary/StressDictionary.java | 9 +++++++-- .../generateHierarchy/GenerateHierarchyHelper.java | 5 +++-- .../stressHierarchy001/TestDescription.java | 1 + .../stressHierarchy002/TestDescription.java | 1 + .../stressHierarchy003/TestDescription.java | 1 + .../stressHierarchy004/TestDescription.java | 1 + .../stressHierarchy005/TestDescription.java | 1 + .../stressHierarchy006/TestDescription.java | 1 + .../stressHierarchy007/TestDescription.java | 1 + .../stressHierarchy008/TestDescription.java | 1 + .../stressHierarchy009/TestDescription.java | 1 + .../stressHierarchy010/TestDescription.java | 1 + .../stressHierarchy011/TestDescription.java | 1 + .../stressHierarchy012/TestDescription.java | 1 + .../stressHierarchy013/TestDescription.java | 1 + .../stressHierarchy014/TestDescription.java | 1 + .../stressHierarchy015/TestDescription.java | 1 + 19 files changed, 27 insertions(+), 4 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/flags/maxMetaspaceSize/TestMaxMetaspaceSize.java b/test/hotspot/jtreg/vmTestbase/metaspace/flags/maxMetaspaceSize/TestMaxMetaspaceSize.java index 1cdfbd4e361..5df4b8aea8f 100644 --- a/test/hotspot/jtreg/vmTestbase/metaspace/flags/maxMetaspaceSize/TestMaxMetaspaceSize.java +++ b/test/hotspot/jtreg/vmTestbase/metaspace/flags/maxMetaspaceSize/TestMaxMetaspaceSize.java @@ -24,6 +24,7 @@ /* * @test + * @key randomness * * @summary converted from VM Testbase metaspace/flags/maxMetaspaceSize. * diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/staticReferences/StaticReferences.java b/test/hotspot/jtreg/vmTestbase/metaspace/staticReferences/StaticReferences.java index f4d2515ad22..be5009dc006 100644 --- a/test/hotspot/jtreg/vmTestbase/metaspace/staticReferences/StaticReferences.java +++ b/test/hotspot/jtreg/vmTestbase/metaspace/staticReferences/StaticReferences.java @@ -23,6 +23,7 @@ /* * @test + * @key randomness * @modules java.base/jdk.internal.misc:+open * * @summary converted from VM Testbase metaspace/staticReferences. diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/stressDictionary/StressDictionary.java b/test/hotspot/jtreg/vmTestbase/metaspace/stressDictionary/StressDictionary.java index fd2e7a4687e..e1402ed4b50 100644 --- a/test/hotspot/jtreg/vmTestbase/metaspace/stressDictionary/StressDictionary.java +++ b/test/hotspot/jtreg/vmTestbase/metaspace/stressDictionary/StressDictionary.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -23,6 +23,7 @@ /* * @test + * @key randomness * * @summary converted from VM Testbase metaspace/stressDictionary. * VM Testbase keywords: [nonconcurrent, javac] @@ -60,6 +61,10 @@ public class StressDictionary extends GCTestBase { private static byte[] bytecode; private class FillingDictionaryWorker implements Callable { + private final Random random; + public FillingDictionaryWorker(long seed) { + this.random = new Random(seed); + } @Override public Object call() throws Exception { while (stresser.continueExecution()) { @@ -117,7 +122,7 @@ public class StressDictionary extends GCTestBase { bytecode = generateAndCompile(); List> tasks = new LinkedList>(); for (int i = 0; i < NUMBER_OF_CORRUPTING_THREADS; i++) { - tasks.add(this.new FillingDictionaryWorker()); + tasks.add(this.new FillingDictionaryWorker(random.nextLong())); } for (int i = 0; i < NUMBER_OF_NOT_CORRUPTING_THREADS; i++) { tasks.add(this.new RegularWorker()); diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/common/generateHierarchy/GenerateHierarchyHelper.java b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/common/generateHierarchy/GenerateHierarchyHelper.java index 7815ca6dd9f..daccf644393 100644 --- a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/common/generateHierarchy/GenerateHierarchyHelper.java +++ b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/common/generateHierarchy/GenerateHierarchyHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -25,6 +25,7 @@ package metaspace.stressHierarchy.common.generateHierarchy; import java.util.*; import vm.share.InMemoryJavaCompiler; +import jdk.test.lib.Utils; public class GenerateHierarchyHelper { @@ -41,7 +42,7 @@ public class GenerateHierarchyHelper { private static final int EDGE_IN_MIXED_CASE = 30; - private static Random random = new Random(); + private static Random random = Utils.getRandomInstance(); public static TreeDescriptor generateHierarchy(int depth, int minLevelSize, int maxLevelSize, Type type) { TreeDescriptor tree = new TreeDescriptor(); diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy001/TestDescription.java b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy001/TestDescription.java index fda116b1547..16e144e5f39 100644 --- a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy001/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy001/TestDescription.java @@ -24,6 +24,7 @@ /* * @test + * @key randomness * * @summary converted from VM Testbase metaspace/stressHierarchy/stressHierarchy001. * VM Testbase keywords: [nonconcurrent, javac, no_cds] diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy002/TestDescription.java b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy002/TestDescription.java index 80869a337a5..bec94254f6f 100644 --- a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy002/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy002/TestDescription.java @@ -24,6 +24,7 @@ /* * @test + * @key randomness * * @summary converted from VM Testbase metaspace/stressHierarchy/stressHierarchy002. * VM Testbase keywords: [nonconcurrent, javac, no_cds] diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy003/TestDescription.java b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy003/TestDescription.java index 8f7224b342b..d240be1bf3a 100644 --- a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy003/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy003/TestDescription.java @@ -24,6 +24,7 @@ /* * @test + * @key randomness * * @summary converted from VM Testbase metaspace/stressHierarchy/stressHierarchy003. * VM Testbase keywords: [nonconcurrent, javac, no_cds] diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy004/TestDescription.java b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy004/TestDescription.java index 1f1872a729c..decad347f1c 100644 --- a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy004/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy004/TestDescription.java @@ -24,6 +24,7 @@ /* * @test + * @key randomness * * @summary converted from VM Testbase metaspace/stressHierarchy/stressHierarchy004. * VM Testbase keywords: [nonconcurrent, javac, no_cds] diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy005/TestDescription.java b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy005/TestDescription.java index c47b29af04d..98b0d55e4a0 100644 --- a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy005/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy005/TestDescription.java @@ -24,6 +24,7 @@ /* * @test + * @key randomness * * @summary converted from VM Testbase metaspace/stressHierarchy/stressHierarchy005. * VM Testbase keywords: [nonconcurrent, javac, no_cds] diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy006/TestDescription.java b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy006/TestDescription.java index 74b48988d14..4dcc9962dc8 100644 --- a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy006/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy006/TestDescription.java @@ -24,6 +24,7 @@ /* * @test + * @key randomness * * @summary converted from VM Testbase metaspace/stressHierarchy/stressHierarchy006. * VM Testbase keywords: [nonconcurrent, javac, no_cds] diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy007/TestDescription.java b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy007/TestDescription.java index f6c0e25c496..9cf1ac5de69 100644 --- a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy007/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy007/TestDescription.java @@ -24,6 +24,7 @@ /* * @test + * @key randomness * * @summary converted from VM Testbase metaspace/stressHierarchy/stressHierarchy007. * VM Testbase keywords: [nonconcurrent, javac, no_cds] diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy008/TestDescription.java b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy008/TestDescription.java index 3321d357444..d17b5825936 100644 --- a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy008/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy008/TestDescription.java @@ -24,6 +24,7 @@ /* * @test + * @key randomness * * @summary converted from VM Testbase metaspace/stressHierarchy/stressHierarchy008. * VM Testbase keywords: [nonconcurrent, javac, no_cds] diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy009/TestDescription.java b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy009/TestDescription.java index be5107fa208..cbdda0343ff 100644 --- a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy009/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy009/TestDescription.java @@ -24,6 +24,7 @@ /* * @test + * @key randomness * * @summary converted from VM Testbase metaspace/stressHierarchy/stressHierarchy009. * VM Testbase keywords: [nonconcurrent, javac, no_cds] diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy010/TestDescription.java b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy010/TestDescription.java index 89fb06c219e..fda197a62b7 100644 --- a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy010/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy010/TestDescription.java @@ -24,6 +24,7 @@ /* * @test + * @key randomness * * @summary converted from VM Testbase metaspace/stressHierarchy/stressHierarchy010. * VM Testbase keywords: [nonconcurrent, javac, no_cds] diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy011/TestDescription.java b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy011/TestDescription.java index dc0bb9df7c0..09dfaaf4732 100644 --- a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy011/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy011/TestDescription.java @@ -24,6 +24,7 @@ /* * @test + * @key randomness * * @summary converted from VM Testbase metaspace/stressHierarchy/stressHierarchy011. * VM Testbase keywords: [nonconcurrent, javac, no_cds] diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy012/TestDescription.java b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy012/TestDescription.java index 20588430cc4..ec58a160c59 100644 --- a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy012/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy012/TestDescription.java @@ -24,6 +24,7 @@ /* * @test + * @key randomness * * @summary converted from VM Testbase metaspace/stressHierarchy/stressHierarchy012. * VM Testbase keywords: [nonconcurrent, javac, no_cds] diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy013/TestDescription.java b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy013/TestDescription.java index eabf6f6839c..c85a6c8ba1b 100644 --- a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy013/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy013/TestDescription.java @@ -24,6 +24,7 @@ /* * @test + * @key randomness * * @summary converted from VM Testbase metaspace/stressHierarchy/stressHierarchy013. * VM Testbase keywords: [nonconcurrent, javac, no_cds] diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy014/TestDescription.java b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy014/TestDescription.java index ababfac7b44..6b28c61e4c3 100644 --- a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy014/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy014/TestDescription.java @@ -24,6 +24,7 @@ /* * @test + * @key randomness * * @summary converted from VM Testbase metaspace/stressHierarchy/stressHierarchy014. * VM Testbase keywords: [nonconcurrent, javac, no_cds] diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy015/TestDescription.java b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy015/TestDescription.java index 11b102a37a3..068f2c6a436 100644 --- a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy015/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/stressHierarchy015/TestDescription.java @@ -24,6 +24,7 @@ /* * @test + * @key randomness * * @summary converted from VM Testbase metaspace/stressHierarchy/stressHierarchy015. * VM Testbase keywords: [nonconcurrent, javac, no_cds] From 2163dec6c423616663d40812657ce9b72fa8eff5 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Tue, 5 May 2020 09:54:51 -0700 Subject: [PATCH 34/88] 8243432: use reproducible random in :vmTestbase_vm_defmeth Reviewed-by: dholmes --- .../jtreg/vmTestbase/vm/runtime/defmeth/StressTest.java | 9 +++++---- .../scenarios/Stress_noredefine/TestDescription.java | 3 ++- .../scenarios/Stress_redefine/TestDescription.java | 3 ++- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/StressTest.java b/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/StressTest.java index 273423a00b2..a12dcba649d 100644 --- a/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/StressTest.java +++ b/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/StressTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 @@ -37,6 +37,7 @@ import vm.runtime.defmeth.shared.builder.TestBuilder; import vm.share.options.Option; import vm.share.options.OptionSupport; import vm.share.options.Options; +import jdk.test.lib.Utils; import static jdk.internal.org.objectweb.asm.Opcodes.*; /* @@ -72,7 +73,7 @@ public class StressTest implements Runnable { private Throwable reason; private volatile long executedTests = 0; - public Worker(String id, int seed) { + public Worker(String id, long seed) { setName(id); this.rand = new Random(seed); } @@ -215,7 +216,7 @@ public class StressTest implements Runnable { private void startWorkers() { Random rand; if (seed == 0) { - seed = (new Random()).nextInt(); + seed = Utils.SEED; } System.out.printf("Seed: %d\n", seed); @@ -247,7 +248,7 @@ public class StressTest implements Runnable { for (int i = 0; i < workers.length; i++) { workers[i] = new Worker( String.format("Worker #%d/%d", i+1, workers.length), - rand.nextInt()); + rand.nextLong()); } for (Worker worker : workers) { diff --git a/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/scenarios/Stress_noredefine/TestDescription.java b/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/scenarios/Stress_noredefine/TestDescription.java index 6c6a571dee6..6c3af6f022b 100644 --- a/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/scenarios/Stress_noredefine/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/scenarios/Stress_noredefine/TestDescription.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -24,6 +24,7 @@ /* * @test + * @key randomness * @modules java.base/jdk.internal.org.objectweb.asm:+open java.base/jdk.internal.org.objectweb.asm.util:+open * * @summary converted from VM Testbase vm/runtime/defmeth/scenarios/Stress_noredefine. diff --git a/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/scenarios/Stress_redefine/TestDescription.java b/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/scenarios/Stress_redefine/TestDescription.java index 7e4ae7cceea..ea2ffc897fe 100644 --- a/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/scenarios/Stress_redefine/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/scenarios/Stress_redefine/TestDescription.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -24,6 +24,7 @@ /* * @test + * @key randomness * @modules java.base/jdk.internal.org.objectweb.asm:+open java.base/jdk.internal.org.objectweb.asm.util:+open * * @summary converted from VM Testbase vm/runtime/defmeth/scenarios/Stress_redefine. From cd9b2bb97f07a8f677257e3475f15697bc91d03e Mon Sep 17 00:00:00 2001 From: Fernando Guallini Date: Tue, 5 May 2020 16:59:41 +0000 Subject: [PATCH 35/88] 8244444: [TESTBUG] Test for XPathEvaluationResult.XPathResultType Reviewed-by: joehw --- .../ptests/XPathEvaluationResultTest.java | 115 ++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 test/jaxp/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathEvaluationResultTest.java diff --git a/test/jaxp/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathEvaluationResultTest.java b/test/jaxp/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathEvaluationResultTest.java new file mode 100644 index 00000000000..aaedc697b46 --- /dev/null +++ b/test/jaxp/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathEvaluationResultTest.java @@ -0,0 +1,115 @@ +/* + * 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 javax.xml.xpath.ptests; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Listeners; +import org.testng.annotations.Test; +import org.w3c.dom.Node; + +import javax.xml.namespace.QName; +import javax.xml.xpath.XPathConstants; +import javax.xml.xpath.XPathEvaluationResult; +import javax.xml.xpath.XPathNodes; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; + +import static org.testng.Assert.*; + +/* + * @test + * @bug 8183266 + * @summary verifies the specification of the XPathEvaluationResult API + * @library /javax/xml/jaxp/libs + * @run testng/othervm -DrunSecMngr=true javax.xml.xpath.ptests.XPathEvaluationResultTest + * @run testng/othervm javax.xml.xpath.ptests.XPathEvaluationResultTest + */ +@Listeners({jaxp.library.BasePolicy.class}) +public class XPathEvaluationResultTest { + + /* + * Test getQNameType returns QName type for supported types and Number subtypes + */ + @Test(dataProvider = "supportedTypes") + public void testQNameTypeSupportedTypes(QName expectedQName, Class type) { + QName qName = XPathEvaluationResult.XPathResultType.getQNameType(type); + assertNotNull(qName); + assertEquals(expectedQName, qName); + } + + /* + * Test getQNameType returns null when type is not supported + */ + @Test(dataProvider = "unsupportedTypes") + public void testQNameTypeUnsupportedTypes(Class type) { + QName qName = XPathEvaluationResult.XPathResultType.getQNameType(type); + assertNull(qName); + } + + /* + * Test getQNameType is null safe + */ + @Test + public void testQNameTypeNullType() { + QName qName = XPathEvaluationResult.XPathResultType.getQNameType(null); + assertNull(qName); + } + + /* + * DataProvider: Class types supported + */ + @DataProvider(name = "supportedTypes") + public Object[][] getSupportedTypes() { + return new Object[][]{ + {XPathConstants.STRING, String.class}, + {XPathConstants.BOOLEAN, Boolean.class}, + {XPathConstants.NODESET, XPathNodes.class}, + {XPathConstants.NODE, Node.class}, + {XPathConstants.NUMBER, Long.class}, + {XPathConstants.NUMBER, Integer.class}, + {XPathConstants.NUMBER, Double.class}, + {XPathConstants.NUMBER, Number.class} + }; + } + + /* + * DataProvider: Class types not supported + */ + @DataProvider(name = "unsupportedTypes") + public Object[][] getUnsupportedTypes() { + return new Object[][]{ + new Object[]{AtomicInteger.class}, + new Object[]{AtomicLong.class}, + new Object[]{BigDecimal.class}, + new Object[]{BigInteger.class}, + new Object[]{Byte.class}, + new Object[]{Float.class}, + new Object[]{Short.class}, + new Object[]{Character.class}, + new Object[]{StringBuilder.class}, + }; + } +} From 469c13a86d08b506b5081108297a82493bc4b548 Mon Sep 17 00:00:00 2001 From: Patrick Concannon Date: Tue, 5 May 2020 18:34:39 +0100 Subject: [PATCH 36/88] 8243488: Add tests for set/get SendBufferSize and getReceiveBufferSize in DatagramSocket Tests added for methods: setSendBufferSize(int), getSendBufferSize(), and getReceieveBufferSize() to increase test coverage in the DatagramSocket class Reviewed-by: alanb, chegar, dfuchs --- .../SetGetReceiveBufferSize.java | 98 ++++++++++++++++ .../DatagramSocket/SetGetSendBufferSize.java | 111 ++++++++++++++++++ .../DatagramSocket/SetReceiveBufferSize.java | 46 -------- 3 files changed, 209 insertions(+), 46 deletions(-) create mode 100644 test/jdk/java/net/DatagramSocket/SetGetReceiveBufferSize.java create mode 100644 test/jdk/java/net/DatagramSocket/SetGetSendBufferSize.java delete mode 100644 test/jdk/java/net/DatagramSocket/SetReceiveBufferSize.java diff --git a/test/jdk/java/net/DatagramSocket/SetGetReceiveBufferSize.java b/test/jdk/java/net/DatagramSocket/SetGetReceiveBufferSize.java new file mode 100644 index 00000000000..7c7c9a07227 --- /dev/null +++ b/test/jdk/java/net/DatagramSocket/SetGetReceiveBufferSize.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 1999, 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 4173717 8243488 + * @summary Check that setReceiveBufferSize and getReceiveBufferSize work as expected + * @run testng SetGetReceiveBufferSize + * @run testng/othervm -Djava.net.preferIPv4Stack=true SetGetReceiveBufferSize + */ + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.io.IOException; +import java.net.DatagramSocket; +import java.net.MulticastSocket; +import java.net.SocketException; +import java.nio.channels.DatagramChannel; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.expectThrows; + +public class SetGetReceiveBufferSize { + static final Class SE = SocketException.class; + static final Class IAE = IllegalArgumentException.class; + + @FunctionalInterface + public interface DatagramSocketSupplier { + DatagramSocket open() throws IOException; + } + static DatagramSocketSupplier supplier(DatagramSocketSupplier supplier) { return supplier; } + + @DataProvider + public Object[][] invariants() { + return new Object[][]{ + {"DatagramSocket", supplier(() -> new DatagramSocket())}, + {"MulticastSocket", supplier(() -> new MulticastSocket())}, + {"DatagramSocketAdaptor", supplier(() -> DatagramChannel.open().socket())}, + }; + } + + @Test(dataProvider = "invariants") + public void testSetInvalidBufferSize(String name, DatagramSocketSupplier supplier) throws IOException { + var invalidArgs = new int[]{ -1, 0 }; + + try (var socket = supplier.open()) { + for (int i : invalidArgs) { + Exception ex = expectThrows(IAE, () -> socket.setReceiveBufferSize(i)); + System.out.println(name + " got expected exception: " + ex); + } + } + } + + @Test(dataProvider = "invariants") + public void testSetAndGetBufferSize(String name, DatagramSocketSupplier supplier) throws IOException { + var validArgs = new int[]{ 1234, 2345, 3456 }; + + try (var socket = supplier.open()) { + for (int i : validArgs) { + socket.setReceiveBufferSize(i); + assertEquals(socket.getReceiveBufferSize(), i, name); + } + } + } + + @Test(dataProvider = "invariants") + public void testSetGetAfterClose(String name, DatagramSocketSupplier supplier) throws IOException { + var socket = supplier.open(); + socket.close(); + + Exception setException = expectThrows(SE, () -> socket.setReceiveBufferSize(2345)); + System.out.println(name + " got expected exception: " + setException); + + Exception getException = expectThrows(SE, () -> socket.getReceiveBufferSize()); + System.out.println(name + " got expected exception: " + getException); + } +} diff --git a/test/jdk/java/net/DatagramSocket/SetGetSendBufferSize.java b/test/jdk/java/net/DatagramSocket/SetGetSendBufferSize.java new file mode 100644 index 00000000000..70ed4eef750 --- /dev/null +++ b/test/jdk/java/net/DatagramSocket/SetGetSendBufferSize.java @@ -0,0 +1,111 @@ +/* + * 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 8243488 + * @library /test/lib + * @build jdk.test.lib.Platform + * @summary Check that setSendBufferSize and getSendBufferSize work as expected + * @run testng SetGetSendBufferSize + * @run testng/othervm -Djava.net.preferIPv4Stack=true SetGetSendBufferSize + */ + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.io.IOException; +import java.net.DatagramSocket; +import java.net.MulticastSocket; +import java.net.SocketException; +import java.nio.channels.DatagramChannel; + +import jdk.test.lib.Platform; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.expectThrows; + +public class SetGetSendBufferSize { + static final Class SE = SocketException.class; + static final Class IAE = IllegalArgumentException.class; + + public interface DatagramSocketSupplier { + DatagramSocket open() throws IOException; + } + static DatagramSocketSupplier supplier(DatagramSocketSupplier supplier) { return supplier; } + + @DataProvider + public Object[][] invariants() { + return new Object[][]{ + {"DatagramSocket", supplier(() -> new DatagramSocket())}, + {"MulticastSocket", supplier(() -> new MulticastSocket())}, + {"DatagramSocketAdaptor", supplier(() -> DatagramChannel.open().socket())}, + }; + } + + @Test(dataProvider = "invariants") + public void testSetInvalidBufferSize(String name, DatagramSocketSupplier supplier) throws IOException { + var invalidArgs = new int[]{ -1, 0 }; + + try (var socket = supplier.open()) { + for (int i : invalidArgs) { + Exception ex = expectThrows(IAE, () -> socket.setSendBufferSize(i)); + System.out.println(name + " got expected exception: " + ex); + } + } + } + + @Test(dataProvider = "invariants") + public void testSetAndGetBufferSize(String name, DatagramSocketSupplier supplier) throws IOException { + var validArgs = new int[]{ 2345, 3456 }; + + try (var socket = supplier.open()) { + for (int i : validArgs) { + socket.setSendBufferSize(i); + assertEquals(socket.getSendBufferSize(), i, name); + } + } + } + + @Test(dataProvider = "invariants") + public void testInitialSendBufferSize(String name, DatagramSocketSupplier supplier) throws IOException { + if(Platform.isOSX()) { + try (var socket = supplier.open()){ + assertTrue(socket.getSendBufferSize() >= 65507, name); + } + } + } + + @Test(dataProvider = "invariants") + public void testSetGetAfterClose(String name, DatagramSocketSupplier supplier) throws IOException { + var socket = supplier.open(); + socket.close(); + + Exception setException = expectThrows(SE, () -> socket.setSendBufferSize(2345)); + System.out.println(name + " got expected exception: " + setException); + + Exception getException = expectThrows(SE, () -> socket.getSendBufferSize()); + System.out.println(name + " got expected exception: " + getException); + } +} diff --git a/test/jdk/java/net/DatagramSocket/SetReceiveBufferSize.java b/test/jdk/java/net/DatagramSocket/SetReceiveBufferSize.java deleted file mode 100644 index 58e7e268154..00000000000 --- a/test/jdk/java/net/DatagramSocket/SetReceiveBufferSize.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 1999, 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 4173717 - @summary Make sure that passing 0 in setReceiveBufferSize will throw - IllegalArgumentException - */ -import java.net.*; - -public class SetReceiveBufferSize { - - public static void main(String args[]) throws Exception { - boolean error = true; - - try (DatagramSocket soc = new DatagramSocket()) { - soc.setReceiveBufferSize(0); - } catch (IllegalArgumentException e) { - error = false; - } - - if (error) { - throw new RuntimeException("Test with 0 buffer size failed!"); - } - } -} From 2883bccf48f7a63c3635a0792138c5481050966f Mon Sep 17 00:00:00 2001 From: Martin Balao Date: Sat, 28 Mar 2020 19:41:10 -0300 Subject: [PATCH 37/88] 8239385: KerberosTicket client name refers wrongly to sAMAccountName in AD Reviewed-by: weijun --- .../classes/sun/security/krb5/Config.java | 3 +- .../sun/security/krb5/KrbAsReqBuilder.java | 93 ++++++++++++++----- .../classes/sun/security/krb5/KrbKdcRep.java | 18 ++-- .../sun/security/krb5/auto/ReferralsTest.java | 40 +++++++- 4 files changed, 120 insertions(+), 34 deletions(-) diff --git a/src/java.security.jgss/share/classes/sun/security/krb5/Config.java b/src/java.security.jgss/share/classes/sun/security/krb5/Config.java index 8c34be94db7..62abc719ad3 100644 --- a/src/java.security.jgss/share/classes/sun/security/krb5/Config.java +++ b/src/java.security.jgss/share/classes/sun/security/krb5/Config.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -154,6 +154,7 @@ public class Config { KdcComm.initStatic(); EType.initStatic(); Checksum.initStatic(); + KrbAsReqBuilder.ReferralsState.initStatic(); } diff --git a/src/java.security.jgss/share/classes/sun/security/krb5/KrbAsReqBuilder.java b/src/java.security.jgss/share/classes/sun/security/krb5/KrbAsReqBuilder.java index c626cfda8e2..bdd70d64911 100644 --- a/src/java.security.jgss/share/classes/sun/security/krb5/KrbAsReqBuilder.java +++ b/src/java.security.jgss/share/classes/sun/security/krb5/KrbAsReqBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -278,7 +278,9 @@ public final class KrbAsReqBuilder { } options = (options == null) ? new KDCOptions() : options; if (referralsState.isEnabled()) { - options.set(KDCOptions.CANONICALIZE, true); + if (referralsState.sendCanonicalize()) { + options.set(KDCOptions.CANONICALIZE, true); + } extraPAs = new PAData[]{ new PAData(Krb5.PA_REQ_ENC_PA_REP, new byte[]{}) }; } else { @@ -333,7 +335,7 @@ public final class KrbAsReqBuilder { boolean preAuthFailedOnce = false; KdcComm comm = null; EncryptionKey pakey = null; - ReferralsState referralsState = new ReferralsState(); + ReferralsState referralsState = new ReferralsState(this); while (true) { if (referralsState.refreshComm()) { comm = new KdcComm(refCname.getRealmAsString()); @@ -379,43 +381,88 @@ public final class KrbAsReqBuilder { } } - private final class ReferralsState { + static final class ReferralsState { + private static boolean canonicalizeConfig; private boolean enabled; + private boolean sendCanonicalize; + private boolean isEnterpriseCname; private int count; private boolean refreshComm; + private KrbAsReqBuilder reqBuilder; - ReferralsState() throws KrbException { - if (Config.DISABLE_REFERRALS) { - if (refCname.getNameType() == PrincipalName.KRB_NT_ENTERPRISE) { - throw new KrbException("NT-ENTERPRISE principals only allowed" + - " when referrals are enabled."); + static { + initStatic(); + } + + // Config may be refreshed while running so the setting + // value may need to be updated. See Config::refresh. + static void initStatic() { + canonicalizeConfig = false; + try { + canonicalizeConfig = Config.getInstance() + .getBooleanObject("libdefaults", "canonicalize") == + Boolean.TRUE; + } catch (KrbException e) { + if (Krb5.DEBUG) { + System.out.println("Exception in getting canonicalize," + + " using default value " + + Boolean.valueOf(canonicalizeConfig) + ": " + + e.getMessage()); } - enabled = false; - } else { - enabled = true; + } + } + + ReferralsState(KrbAsReqBuilder reqBuilder) throws KrbException { + this.reqBuilder = reqBuilder; + sendCanonicalize = canonicalizeConfig; + isEnterpriseCname = reqBuilder.refCname.getNameType() == + PrincipalName.KRB_NT_ENTERPRISE; + updateStatus(); + if (!enabled && isEnterpriseCname) { + throw new KrbException("NT-ENTERPRISE principals only" + + " allowed when referrals are enabled."); } refreshComm = true; } + private void updateStatus() { + enabled = !Config.DISABLE_REFERRALS && + (isEnterpriseCname || sendCanonicalize); + } + boolean handleError(KrbException ke) throws RealmException { if (enabled) { if (ke.returnCode() == Krb5.KRB_ERR_WRONG_REALM) { Realm referredRealm = ke.getError().getClientRealm(); - if (req.getMessage().reqBody.kdcOptions.get(KDCOptions.CANONICALIZE) && - referredRealm != null && referredRealm.toString().length() > 0 && + if (referredRealm != null && + !referredRealm.toString().isEmpty() && count < Config.MAX_REFERRALS) { - refCname = new PrincipalName(refCname.getNameType(), - refCname.getNameStrings(), referredRealm); + // A valid referral was received while referrals + // were enabled. Change the cname realm to the referred + // realm and set refreshComm to send a new request. + reqBuilder.refCname = new PrincipalName( + reqBuilder.refCname.getNameType(), + reqBuilder.refCname.getNameStrings(), + referredRealm); refreshComm = true; count++; return true; } } - if (count < Config.MAX_REFERRALS && - refCname.getNameType() != PrincipalName.KRB_NT_ENTERPRISE) { - // Server may raise an error if CANONICALIZE is true. - // Try CANONICALIZE false. - enabled = false; + if (count < Config.MAX_REFERRALS && sendCanonicalize) { + if (Krb5.DEBUG) { + System.out.println("KrbAsReqBuilder: AS-REQ failed." + + " Retrying with CANONICALIZE false."); + } + + // Server returned an unexpected error with + // CANONICALIZE true. Retry with false. + sendCanonicalize = false; + + // Setting CANONICALIZE to false may imply that referrals + // are now disabled (if cname is not of NT-ENTERPRISE type). + updateStatus(); + return true; } } @@ -431,6 +478,10 @@ public final class KrbAsReqBuilder { boolean isEnabled() { return enabled; } + + boolean sendCanonicalize() { + return sendCanonicalize; + } } /** diff --git a/src/java.security.jgss/share/classes/sun/security/krb5/KrbKdcRep.java b/src/java.security.jgss/share/classes/sun/security/krb5/KrbKdcRep.java index 79ee135b55d..762d9d3ba51 100644 --- a/src/java.security.jgss/share/classes/sun/security/krb5/KrbKdcRep.java +++ b/src/java.security.jgss/share/classes/sun/security/krb5/KrbKdcRep.java @@ -44,11 +44,13 @@ abstract class KrbKdcRep { ) throws KrbApErrException { // cname change in AS-REP is allowed only if the client - // sent CANONICALIZE and the server supports RFC 6806 - Section 11 - // FAST scheme (ENC-PA-REP flag). + // sent CANONICALIZE or an NT-ENTERPRISE cname in the request, and the + // server supports RFC 6806 - Section 11 FAST scheme (ENC-PA-REP flag). if (isAsReq && !req.reqBody.cname.equals(rep.cname) && - (!req.reqBody.kdcOptions.get(KDCOptions.CANONICALIZE) || - !rep.encKDCRepPart.flags.get(Krb5.TKT_OPTS_ENC_PA_REP))) { + ((!req.reqBody.kdcOptions.get(KDCOptions.CANONICALIZE) && + req.reqBody.cname.getNameType() != + PrincipalName.KRB_NT_ENTERPRISE) || + !rep.encKDCRepPart.flags.get(Krb5.TKT_OPTS_ENC_PA_REP))) { rep.encKDCRepPart.key.destroy(); throw new KrbApErrException(Krb5.KRB_AP_ERR_MODIFIED); } @@ -138,14 +140,16 @@ abstract class KrbKdcRep { } // RFC 6806 - Section 11 mechanism check - if (rep.encKDCRepPart.flags.get(Krb5.TKT_OPTS_ENC_PA_REP) && - req.reqBody.kdcOptions.get(KDCOptions.CANONICALIZE)) { + // The availability of the ENC-PA-REP flag in the KDC response is + // mandatory on some cases (see Krb5.TKT_OPTS_ENC_PA_REP check above). + if (rep.encKDCRepPart.flags.get(Krb5.TKT_OPTS_ENC_PA_REP)) { boolean reqPaReqEncPaRep = false; boolean repPaReqEncPaRepValid = false; - // PA_REQ_ENC_PA_REP only required for AS requests for (PAData pa : req.pAData) { if (pa.getType() == Krb5.PA_REQ_ENC_PA_REP) { + // The KDC supports RFC 6806 and ENC-PA-REP was sent in + // the request (AS-REQ). A valid checksum is now required. reqPaReqEncPaRep = true; break; } diff --git a/test/jdk/sun/security/krb5/auto/ReferralsTest.java b/test/jdk/sun/security/krb5/auto/ReferralsTest.java index a6e81268f05..eb29f8eb80a 100644 --- a/test/jdk/sun/security/krb5/auto/ReferralsTest.java +++ b/test/jdk/sun/security/krb5/auto/ReferralsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Red Hat, Inc. + * Copyright (c) 2019, 2020, Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,15 +38,19 @@ import java.util.Map; import java.util.Set; import javax.security.auth.kerberos.KerberosTicket; import javax.security.auth.Subject; +import javax.security.auth.login.LoginException; import org.ietf.jgss.GSSName; import sun.security.jgss.GSSUtil; +import sun.security.krb5.Config; import sun.security.krb5.PrincipalName; public class ReferralsTest { private static final boolean DEBUG = true; private static final String krbConfigName = "krb5-localkdc.conf"; + private static final String krbConfigNameNoCanonicalize = + "krb5-localkdc-nocanonicalize.conf"; private static final String realmKDC1 = "RABBIT.HOLE"; private static final String realmKDC2 = "DEV.RABBIT.HOLE"; private static final char[] password = "123qwe@Z".toCharArray(); @@ -100,6 +104,7 @@ public class ReferralsTest { testDelegation(); testImpersonation(); testDelegationWithReferrals(); + testNoCanonicalize(); } finally { cleanup(); } @@ -139,14 +144,20 @@ public class ReferralsTest { kdc2.setOption(KDC.Option.ALLOW_S4U2PROXY, mapKDC2); KDC.saveConfig(krbConfigName, kdc1, kdc2, - "forwardable=true"); + "forwardable=true", "canonicalize=true"); + KDC.saveConfig(krbConfigNameNoCanonicalize, kdc1, kdc2, + "forwardable=true"); System.setProperty("java.security.krb5.conf", krbConfigName); } private static void cleanup() { - File f = new File(krbConfigName); - if (f.exists()) { - f.delete(); + String[] configFiles = new String[]{krbConfigName, + krbConfigNameNoCanonicalize}; + for (String configFile : configFiles) { + File f = new File(configFile); + if (f.exists()) { + f.delete(); + } } } @@ -325,4 +336,23 @@ public class ReferralsTest { throw new Exception("Unexpected initiator or acceptor names"); } } + + /* + * The client tries to get a TGT (AS protocol) as in testSubjectCredentials + * but without the canonicalize setting in krb5.conf. The KDC + * must not return a referral but a failure because the client + * is not in the local database. + */ + private static void testNoCanonicalize() throws Exception { + System.setProperty("java.security.krb5.conf", + krbConfigNameNoCanonicalize); + Config.refresh(); + try { + Context.fromUserPass(new Subject(), + clientKDC1Name, password, false); + throw new Exception("should not succeed"); + } catch (LoginException e) { + // expected + } + } } From 2254cf5a244e38a27df1e0f4d761dac68ebd55da Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Tue, 5 May 2020 11:02:43 -0700 Subject: [PATCH 38/88] 8244247: Build failures after sjavac cleanup Reviewed-by: ihse, tbell --- make/InitSupport.gmk | 12 ++++++------ make/autoconf/bootcycle-spec.gmk.in | 3 ++- make/autoconf/spec.gmk.in | 6 +++--- make/common/JavaCompilation.gmk | 2 +- test/make/TestJavaCompilation.gmk | 9 ++------- 5 files changed, 14 insertions(+), 18 deletions(-) diff --git a/make/InitSupport.gmk b/make/InitSupport.gmk index 4484cffe211..a73855d6ad8 100644 --- a/make/InitSupport.gmk +++ b/make/InitSupport.gmk @@ -471,15 +471,15 @@ else # $(HAS_SPEC)=true # Remove any javac server logs and port files. This # prevents a new make run to reuse the previous servers. define PrepareSmartJavac - $(if $(SJAVAC_SERVER_DIR), \ - $(RM) -r $(SJAVAC_SERVER_DIR) 2> /dev/null && \ - $(MKDIR) -p $(SJAVAC_SERVER_DIR) \ + $(if $(JAVAC_SERVER_DIR), \ + $(RM) -r $(JAVAC_SERVER_DIR) 2> /dev/null && \ + $(MKDIR) -p $(JAVAC_SERVER_DIR) \ ) endef define CleanupSmartJavac - [ -f $(SJAVAC_SERVER_DIR)/server.port ] && $(ECHO) Stopping sjavac server && \ - $(TOUCH) $(SJAVAC_SERVER_DIR)/server.port.stop; true + [ -f $(JAVAC_SERVER_DIR)/server.port ] && $(ECHO) Stopping sjavac server && \ + $(TOUCH) $(JAVAC_SERVER_DIR)/server.port.stop; true endef ifeq ($(call isBuildOs, windows), true) @@ -488,7 +488,7 @@ else # $(HAS_SPEC)=true # synchronization process, wait for a while and hope it helps. This is only # used by build comparisons. define WaitForSmartJavacFinish - $(if $(SJAVAC_SERVER_DIR), \ + $(if $(JAVAC_SERVER_DIR), \ sleep 5\ ) endef diff --git a/make/autoconf/bootcycle-spec.gmk.in b/make/autoconf/bootcycle-spec.gmk.in index 13f28af3ee2..590a9170c6c 100644 --- a/make/autoconf/bootcycle-spec.gmk.in +++ b/make/autoconf/bootcycle-spec.gmk.in @@ -44,7 +44,8 @@ BOOT_JDK := $(JDK_IMAGE_DIR) # The bootcycle build has a different output directory OLD_OUTPUTDIR:=@OUTPUTDIR@ OUTPUTDIR:=$(OLD_OUTPUTDIR)/bootcycle-build -SJAVAC_SERVER_DIR:=$(patsubst $(OLD_OUTPUTDIR)%, $(OUTPUTDIR)%, $(SJAVAC_SERVER_DIR)) +# No spaces in patsubst to avoid leading space in variable +JAVAC_SERVER_DIR:=$(patsubst $(OLD_OUTPUTDIR)%,$(OUTPUTDIR)%,$(JAVAC_SERVER_DIR)) JAVA_CMD:=$(BOOT_JDK)/bin/java JAVAC_CMD:=$(BOOT_JDK)/bin/javac diff --git a/make/autoconf/spec.gmk.in b/make/autoconf/spec.gmk.in index bbbf3cd4443..d2fa64d12ab 100644 --- a/make/autoconf/spec.gmk.in +++ b/make/autoconf/spec.gmk.in @@ -356,9 +356,9 @@ BOOT_JDK_SOURCETARGET:=@BOOT_JDK_SOURCETARGET@ NUM_CORES:=@NUM_CORES@ MEMORY_SIZE:=@MEMORY_SIZE@ ENABLE_JAVAC_SERVER:=@ENABLE_JAVAC_SERVER@ -# Store sjavac server synchronization files here, and -# the sjavac server log files. -SJAVAC_SERVER_DIR=$(MAKESUPPORT_OUTPUTDIR)/javacservers +# Store javac server synchronization files here, and +# the javac server log files. +JAVAC_SERVER_DIR=$(MAKESUPPORT_OUTPUTDIR)/javacservers # Number of parallel jobs to use for compilation JOBS?=@JOBS@ diff --git a/make/common/JavaCompilation.gmk b/make/common/JavaCompilation.gmk index 22a5e5b07cb..ade1b6bcdfa 100644 --- a/make/common/JavaCompilation.gmk +++ b/make/common/JavaCompilation.gmk @@ -216,7 +216,7 @@ define SetupJavaCompilationBody # The port file contains the tcp/ip on which the server listens # and the cookie necessary to talk to the server. - $1_JAVA_SERVER_FLAGS := --server:portfile=$$(SJAVAC_SERVER_DIR)/server.port,sjavac=$$($1_ESCAPED_CMD) + $1_JAVA_SERVER_FLAGS := --server:portfile=$$(JAVAC_SERVER_DIR)/server.port,sjavac=$$($1_ESCAPED_CMD) # Always use small to launch client $1_JAVAC_CMD := $$(JAVA_SMALL) $$($1_JAVA_FLAGS) $$($1_JAVAC) $$($1_JAVA_SERVER_FLAGS) diff --git a/test/make/TestJavaCompilation.gmk b/test/make/TestJavaCompilation.gmk index bf39bbf5406..4c951e68dc4 100644 --- a/test/make/TestJavaCompilation.gmk +++ b/test/make/TestJavaCompilation.gmk @@ -239,11 +239,6 @@ TEST_TARGETS += $(OUTPUT_DIR)/_jar3_updated ################################################################################ # Test SetupJavaCompilation overrides of java files -$(eval $(call SetupJavaCompiler,BOOT_JAVAC, \ - JAVAC := $(JAVAC), \ - DISABLE_SJAVAC := true, \ -)) - JAVA_SRC_ROOT1 := $(OUTPUT_DIR)/javaroot1 JAVA_SRC_ROOT2 := $(OUTPUT_DIR)/javaroot2 @@ -285,7 +280,7 @@ $(call CreateTextFile,$(JAVA_SRC_ROOT2)/a/c.properties,#javaroot2\nname=value2\n # otherwise $(wildcard ) will not find the directories and the sanity check in # SetupJavaCompilation will fail. $(eval $(call SetupJavaCompilation, BUILD_ROOT1_FIRST, \ - SETUP := BOOT_JAVAC, \ + TARGET_RELEASE := $(TARGET_RELEASE_BOOTJDK), \ SRC := $(JAVA_SRC_ROOT1)/ $(JAVA_SRC_ROOT2)/, \ COPY := .txt .java, \ CLEAN := .properties, \ @@ -317,7 +312,7 @@ verify-root1-first: $(BUILD_ROOT1_FIRST) fi $(eval $(call SetupJavaCompilation, BUILD_ROOT2_FIRST, \ - SETUP := BOOT_JAVAC, \ + TARGET_RELEASE := $(TARGET_RELEASE_BOOTJDK), \ SRC := $(JAVA_SRC_ROOT2)/ $(JAVA_SRC_ROOT1)/, \ COPY := .txt, \ CLEAN := .properties, \ From 5868c76ec6ead5e6476fe810c521c3d00514ce40 Mon Sep 17 00:00:00 2001 From: Alexander Matveev Date: Tue, 5 May 2020 15:25:27 -0400 Subject: [PATCH 39/88] 8233166: jpackage tool skips empty directories Reviewed-by: herrick, asemenyuk --- .../jpackage/internal/DeployParams.java | 5 +- .../tools/jpackage/share/EmptyFolderBase.java | 72 +++++++++++++++++++ .../share/EmptyFolderPackageTest.java | 61 ++++++++++++++++ .../tools/jpackage/share/EmptyFolderTest.java | 63 ++++++++++++++++ 4 files changed, 200 insertions(+), 1 deletion(-) create mode 100644 test/jdk/tools/jpackage/share/EmptyFolderBase.java create mode 100644 test/jdk/tools/jpackage/share/EmptyFolderPackageTest.java create mode 100644 test/jdk/tools/jpackage/share/EmptyFolderTest.java diff --git a/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/DeployParams.java b/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/DeployParams.java index 695177ce4a3..3a5c4728a7f 100644 --- a/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/DeployParams.java +++ b/src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/DeployParams.java @@ -83,10 +83,13 @@ public class DeployParams { if (!Files.isSymbolicLink(root.toPath())) { if (root.isDirectory()) { File[] children = root.listFiles(); - if (children != null) { + if (children != null && children.length > 0) { for (File f : children) { files.addAll(expandFileset(f)); } + } else { + // Include empty folders + files.add(root); } } else { files.add(root); diff --git a/test/jdk/tools/jpackage/share/EmptyFolderBase.java b/test/jdk/tools/jpackage/share/EmptyFolderBase.java new file mode 100644 index 00000000000..092996ad039 --- /dev/null +++ b/test/jdk/tools/jpackage/share/EmptyFolderBase.java @@ -0,0 +1,72 @@ +/* + * 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. + */ + +import java.io.File; +import java.io.IOException; +import java.nio.file.Path; +import jdk.jpackage.test.TKit; + +public class EmptyFolderBase { + + // Note: To specify file use ".txt" extension. + // Note: createDirStrcture() will call mkdir() or createNewFile() for paths defined + // in dirStruct, so make sure paths are defined in order. + + // folder-empty + // folder-not-empty + // folder-not-empty/folder-empty + // folder-not-empty/another-folder-empty + // folder-not-empty/folder-non-empty2 + // folder-not-empty/folder-non-empty2/file.txt + private static final String [] DIR_STRUCT = { + "folder-empty", + "folder-not-empty", + "folder-not-empty" + File.separator + "folder-empty", + "folder-not-empty" + File.separator + "another-folder-empty", + "folder-not-empty" + File.separator + "folder-non-empty2", + "folder-not-empty" + File.separator + "folder-non-empty2" + File.separator + + "file.txt" + }; + + // See dirStruct + public static void createDirStrcture(Path inputPath) throws IOException { + File input = new File(inputPath.toString()); + input.mkdir(); + + for (String p : DIR_STRUCT) { + File f = new File(input, p); + if (p.endsWith(".txt")) { + f.createNewFile(); + } else { + f.mkdir(); + } + } + } + + public static void validateDirStrcture(Path appDirPath) { + for (String p : DIR_STRUCT) { + Path path = appDirPath.resolve(p); + TKit.assertPathExists(path, true); + } + } +} diff --git a/test/jdk/tools/jpackage/share/EmptyFolderPackageTest.java b/test/jdk/tools/jpackage/share/EmptyFolderPackageTest.java new file mode 100644 index 00000000000..7893d43f092 --- /dev/null +++ b/test/jdk/tools/jpackage/share/EmptyFolderPackageTest.java @@ -0,0 +1,61 @@ +/* + * 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. + */ + +import java.nio.file.Path; +import jdk.incubator.jpackage.internal.ApplicationLayout; +import jdk.jpackage.test.PackageTest; +import jdk.jpackage.test.TKit; + +/** + * Tests generation of packages with input folder containing empty folders. + */ + +/* + * @test + * @summary jpackage with input containing empty folders + * @library ../helpers + * @library /test/lib + * @key jpackagePlatformPackage + * @build EmptyFolderBase + * @build jdk.jpackage.test.* + * @modules jdk.incubator.jpackage/jdk.incubator.jpackage.internal + * @run main/othervm -Xmx512m EmptyFolderPackageTest + */ +public class EmptyFolderPackageTest { + + public static void main(String[] args) throws Exception { + TKit.run(args, () -> { + new PackageTest().configureHelloApp() + .addInitializer(cmd -> { + Path input = cmd.inputDir(); + EmptyFolderBase.createDirStrcture(input); + }) + .addInstallVerifier(cmd -> { + ApplicationLayout appLayout = cmd.appLayout(); + Path appDir = appLayout.appDirectory(); + EmptyFolderBase.validateDirStrcture(appDir); + }) + .run(); + }); + } +} diff --git a/test/jdk/tools/jpackage/share/EmptyFolderTest.java b/test/jdk/tools/jpackage/share/EmptyFolderTest.java new file mode 100644 index 00000000000..aefaeadbddc --- /dev/null +++ b/test/jdk/tools/jpackage/share/EmptyFolderTest.java @@ -0,0 +1,63 @@ +/* + * 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. + */ + +import java.nio.file.Path; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.TKit; +import jdk.incubator.jpackage.internal.ApplicationLayout; + +/** + * Tests generation of app image with input folder containing empty folders. + */ + +/* + * @test + * @summary jpackage with input containing empty folders + * @library ../helpers + * @library /test/lib + * @build EmptyFolderBase + * @build jdk.jpackage.test.* + * @modules jdk.incubator.jpackage/jdk.incubator.jpackage.internal + * @run main/othervm -Xmx512m EmptyFolderTest + */ +public class EmptyFolderTest { + + public static void main(String[] args) throws Exception { + TKit.run(args, () -> { + JPackageCommand cmd = JPackageCommand.helloAppImage(); + + // Add more files into input folder + Path input = cmd.inputDir(); + EmptyFolderBase.createDirStrcture(input); + + // Create app image + cmd.executeAndAssertHelloAppImageCreated(); + + // Verify directory strcture + ApplicationLayout appLayout = cmd.appLayout(); + Path appDir = appLayout.appDirectory(); + EmptyFolderBase.validateDirStrcture(appDir); + }); + } + +} From 98cbf4660cd9f2f5c305156c1091ad555c89a253 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Tue, 5 May 2020 13:02:30 -0700 Subject: [PATCH 40/88] 8242532: convert tests to use Text Blocks Reviewed-by: hannesw --- .../doclet/AccessAsciiArt/AccessAsciiArt.java | 11 +- .../jdk/javadoc/doclet/AccessH1/AccessH1.java | 3 +- .../doclet/AccessSkipNav/AccessSkipNav.java | 20 +- .../doclet/AccessSummary/AccessSummary.java | 9 +- .../jdk/javadoc/doclet/AuthorDD/AuthorDD.java | 5 +- .../doclet/DocRootSlash/DocRootSlash.java | 3 +- .../JavascriptWinTitle.java | 6 +- .../jdk/javadoc/doclet/MetaTag/MetaTag.java | 21 +- .../TestConstantValuesDriver.java | 57 +- .../TestAbstractMethod.java | 97 +- .../testAnchorNames/TestAnchorNames.java | 125 +- .../TestAnnotationOptional.java | 3 +- .../TestAnnotationTypes.java | 65 +- .../javadoc/doclet/testAuthor/TestAuthor.java | 21 +- .../TestAutoLoadTaglets.java | 46 +- .../testBreakIterator/TestBreakIterator.java | 22 +- .../doclet/testCharset/TestCharset.java | 18 +- .../TestCharsetDocencodingOptions.java | 6 +- .../TestClassCrossReferences.java | 68 +- .../doclet/testClassLinks/TestClassLinks.java | 51 +- .../doclet/testClassTree/TestClassTree.java | 52 +- .../TestConstructorIndent.java | 12 +- .../testConstructors/TestConstructors.java | 70 +- .../doclet/testCopyFiles/TestCopyFiles.java | 149 +- .../TestDeprecatedDocs.java | 476 ++--- .../testDocEncoding/TestDocEncoding.java | 10 +- .../doclet/testDocFiles/TestDocFiles.java | 30 +- .../testDocLintOption/TestDocLintOption.java | 58 +- .../TestDocRootInlineTag.java | 17 +- .../testDocRootLink/TestDocRootLink.java | 80 +- .../testDupParamWarn/TestDupParamWarn.java | 3 +- .../TestEnumConstructor.java | 22 +- .../TestExternalOverriddenMethod.java | 22 +- .../TestGenericMethodLinkTaglet.java | 3 +- .../doclet/testGroupName/TestGroupName.java | 14 +- .../doclet/testHeadings/TestHeadings.java | 50 +- .../doclet/testHelpFile/TestHelpFile.java | 34 +- .../doclet/testHelpOption/TestHelpOption.java | 9 +- .../testHiddenMembers/TestHiddenMembers.java | 3 +- .../doclet/testHiddenTag/TestHiddenTag.java | 49 +- .../jdk/javadoc/doclet/testHref/TestHref.java | 20 +- .../TestHtmlDefinitionListTag.java | 420 +++-- .../TestHtmlLandmarkRegions.java | 66 +- .../testHtmlStrongTag/TestHtmlStrongTag.java | 4 +- .../TestHtmlTableStyles.java | 38 +- .../testHtmlTableTags/TestHtmlTableTags.java | 495 +++--- .../doclet/testHtmlTag/TestHtmlTag.java | 159 +- .../testHtmlVersion/TestHtmlVersion.java | 1371 +++++++++------ .../testIndentation/TestIndentation.java | 13 +- .../javadoc/doclet/testIndex/TestIndex.java | 51 +- .../doclet/testIndexFiles/TestIndexFiles.java | 20 +- .../TestIndexInDocFiles.java | 130 +- .../TestIndexInPackageFiles.java | 73 +- .../testIndexTaglet/TestIndexTaglet.java | 14 +- .../TestIndexWithModules.java | 27 +- .../TestInlineLinkLabel.java | 6 +- .../doclet/testInterface/TestInterface.java | 173 +- .../javadoc/doclet/testJavaFX/TestJavaFX.java | 440 ++--- .../doclet/testJavaFX/TestJavaFxMode.java | 20 +- .../doclet/testJavascript/TestJavascript.java | 24 +- .../testLambdaFeature/TestLambdaFeature.java | 85 +- .../testLeadingSpaces/LeadingSpaces.java | 15 +- .../testLegacyTaglet/TestLegacyTaglet.java | 10 +- .../doclet/testLinkOption/TestLinkOption.java | 116 +- .../TestLinkOptionWithAutomaticModule.java | 15 +- .../TestLinkOptionWithModule.java | 28 +- .../testLinkOption/TestOptionOrder.java | 21 +- .../testLinkOption/TestRedirectLinks.java | 17 +- .../doclet/testLinkTaglet/TestLinkTaglet.java | 32 +- .../TestLinkToSerialForm.java | 6 +- .../TestLinksWithNoDeprecatedOption.java | 16 +- .../javadoc/doclet/testLists/TestLists.java | 262 +-- .../TestLiteralCodeInPre.java | 110 +- .../TestMemberInheritance.java | 273 +-- .../testMemberSummary/TestMemberSummary.java | 34 +- .../doclet/testMetadata/TestMetadata.java | 31 +- .../TestMethodSignature.java | 157 +- .../testMethodTypes/TestMethodTypes.java | 92 +- .../doclet/testModifierEx/TestModifierEx.java | 15 +- .../doclet/testModuleDirs/TestModuleDirs.java | 13 +- .../TestModuleSpecificStylesheet.java | 20 +- .../testModules/TestIndirectExportsOpens.java | 52 +- .../testModules/TestModulePackages.java | 87 +- .../testModules/TestModuleServices.java | 356 ++-- .../testModules/TestModuleServicesLink.java | 27 +- .../doclet/testModules/TestModules.java | 1531 ++++++++++------- .../testNavigation/TestModuleNavigation.java | 80 +- .../doclet/testNavigation/TestNavigation.java | 269 +-- .../TestNestedGenerics.java | 6 +- .../TestNewLanguageFeatures.java | 836 ++++----- .../doclet/testNoFrames/TestNoFrames.java | 5 +- .../TestNonInlineHtmlTagRemoval.java | 36 +- .../testNotifications/TestNotifications.java | 6 +- .../doclet/testOptions/TestOptions.java | 150 +- .../doclet/testOrdering/TestOrdering.java | 252 ++- .../TestBadOverride.java | 14 +- .../TestMultiInheritance.java | 30 +- .../TestOverriddenDeprecatedMethods.java | 28 +- .../TestOverriddenMethodDocCopy.java | 6 +- .../TestOverriddenPrivateMethods.java | 28 +- ...erriddenPrivateMethodsWithPackageFlag.java | 42 +- ...erriddenPrivateMethodsWithPrivateFlag.java | 30 +- .../TestOverrideMethods.java | 210 ++- .../doclet/testOverview/TestOverview.java | 12 +- .../TestPackageAnnotation.java | 38 +- .../TestPackageDeprecation.java | 11 +- .../TestPackageDescription.java | 6 +- .../testPackageHtml/TestPackageHtml.java | 24 +- .../testPackagePage/TestPackagePage.java | 65 +- .../TestPackageSpecificStylesheet.java | 12 +- .../TestPackageSummary.java | 46 +- .../testParamTaglet/TestParamTaglet.java | 14 +- .../TestPrivateClasses.java | 191 +- .../doclet/testProperty/TestProperty.java | 98 +- .../testRecordTypes/TestRecordTypes.java | 276 +-- .../testRelativeLinks/TestRelativeLinks.java | 57 +- .../TestRepeatedAnnotations.java | 140 +- .../javadoc/doclet/testSearch/TestSearch.java | 607 ++++--- .../javadoc/doclet/testSeeTag/TestSeeTag.java | 26 +- .../doclet/testSerialTag/TestSerialTag.java | 18 +- .../TestSerializedForm.java | 115 +- .../TestSerializedFormDeprecationInfo.java | 101 +- .../TestSerializedFormWithClassFile.java | 12 +- .../doclet/testSimpleTag/TestSimpleTag.java | 5 +- .../TestSimpleTagInherit.java | 10 +- .../doclet/testSinceTag/TestSinceTag.java | 14 +- .../doclet/testStylesheet/TestStylesheet.java | 364 ++-- .../doclet/testSubTitle/TestSubTitle.java | 16 +- .../doclet/testSummaryTag/TestSummaryTag.java | 98 +- .../TestSuperClassInSerialForm.java | 5 +- .../TestSystemPropertyPage.java | 83 +- .../TestSystemPropertyTaglet.java | 343 ++-- .../TestTagInheritence.java | 6 +- .../doclet/testTagOutput/TestTagOutput.java | 17 +- .../doclet/testThrowsTag/TestThrowsTag.java | 17 +- .../testTitleInHref/TestTitleInHref.java | 12 +- .../TestTypeAnnotations.java | 1094 ++++++------ .../testTypeParams/TestTypeParameters.java | 32 +- .../TestTypeVariableLinks.java | 14 +- .../TestUnnamedPackage.java | 93 +- .../doclet/testUseOption/TestUseOption.java | 90 +- .../doclet/testValueTag/TestValueTag.java | 119 +- .../testValueTag/TestValueTagInModule.java | 7 +- .../doclet/testVersionTag/TestVersionTag.java | 21 +- .../TestWarnBadParamNames.java | 9 +- .../doclet/testWarnings/TestWarnings.java | 9 +- .../jdk/javadoc/tool/6227454/Test.java | 4 +- .../jdk/javadoc/tool/8025693/Test.java | 14 +- test/langtools/jdk/javadoc/tool/MaxWarns.java | 3 +- test/langtools/jdk/javadoc/tool/NoStar.java | 9 +- .../jdk/javadoc/tool/TestScriptInComment.java | 3 +- .../tool/api/basic/DocletPathTest.java | 51 +- .../jdk/javadoc/tool/doclint/DocLintTest.java | 12 +- .../jdk/javadoc/tool/modules/Modules.java | 10 +- .../javadoc/tool/modules/PatchModules.java | 34 +- .../tool/removeOldDoclet/RemoveOldDoclet.java | 5 +- .../testLocaleOption/TestLocaleOption.java | 52 +- .../testWErrorOption/TestWErrorOption.java | 27 +- 158 files changed, 8723 insertions(+), 6681 deletions(-) diff --git a/test/langtools/jdk/javadoc/doclet/AccessAsciiArt/AccessAsciiArt.java b/test/langtools/jdk/javadoc/doclet/AccessAsciiArt/AccessAsciiArt.java index d7464d299a6..9714154b9b3 100644 --- a/test/langtools/jdk/javadoc/doclet/AccessAsciiArt/AccessAsciiArt.java +++ b/test/langtools/jdk/javadoc/doclet/AccessAsciiArt/AccessAsciiArt.java @@ -49,10 +49,15 @@ public class AccessAsciiArt extends JavadocTester { checkOutput("p1/subpkg/SSC.html", true, // Test the top line of the class tree - "
p1.C", + """ +
p1.C""", // Test the second line of the class tree - "
p1.SC", + """ +
p1.SC""", // Test the third line of the class tree - "
p1.subpkg.SSC
\n
\n
"); + """ +
p1.subpkg.SSC
+
+
"""); } } diff --git a/test/langtools/jdk/javadoc/doclet/AccessH1/AccessH1.java b/test/langtools/jdk/javadoc/doclet/AccessH1/AccessH1.java index 185656cf8fb..e199f232c54 100644 --- a/test/langtools/jdk/javadoc/doclet/AccessH1/AccessH1.java +++ b/test/langtools/jdk/javadoc/doclet/AccessH1/AccessH1.java @@ -57,6 +57,7 @@ public class AccessH1 extends JavadocTester { // Test the doc title in the overview page checkOutput("index.html", true, - "

Document Title

"); + """ +

Document Title

"""); } } diff --git a/test/langtools/jdk/javadoc/doclet/AccessSkipNav/AccessSkipNav.java b/test/langtools/jdk/javadoc/doclet/AccessSkipNav/AccessSkipNav.java index 4d3c7f11545..73bed39266e 100644 --- a/test/langtools/jdk/javadoc/doclet/AccessSkipNav/AccessSkipNav.java +++ b/test/langtools/jdk/javadoc/doclet/AccessSkipNav/AccessSkipNav.java @@ -50,16 +50,20 @@ public class AccessSkipNav extends JavadocTester { // Testing only for the presence of the and checkOutput("p1/C1.html", true, // Top navbar - "Skip navigation links", + """ + Skip navigation links""", // Top navbar - "\n" - + "\n" - + "", + """ + + + """, // Bottom navbar - "Skip navigation links", + """ + Skip navigation links""", // Bottom navbar - "\n" - + "\n" - + ""); + """ + + + """); } } diff --git a/test/langtools/jdk/javadoc/doclet/AccessSummary/AccessSummary.java b/test/langtools/jdk/javadoc/doclet/AccessSummary/AccessSummary.java index cc44ee11e49..dd4377fcc11 100644 --- a/test/langtools/jdk/javadoc/doclet/AccessSummary/AccessSummary.java +++ b/test/langtools/jdk/javadoc/doclet/AccessSummary/AccessSummary.java @@ -55,14 +55,17 @@ public class AccessSummary extends JavadocTester { void checkSummary(boolean found) { checkOutput("index.html", found, - "summary=\"Package Summary table, listing packages, and an explanation\""); + """ + summary="Package Summary table, listing packages, and an explanation\""""); // Test that the summary attribute appears or not checkOutput("p1/C1.html", found, - "summary=\"Constructor Summary table, listing constructors, and an explanation\""); + """ + summary="Constructor Summary table, listing constructors, and an explanation\""""); // Test that the summary attribute appears or not checkOutput("constant-values.html", found, - "summary=\"Constant Field Values table, listing constant fields, and values\""); + """ + summary="Constant Field Values table, listing constant fields, and values\""""); } } diff --git a/test/langtools/jdk/javadoc/doclet/AuthorDD/AuthorDD.java b/test/langtools/jdk/javadoc/doclet/AuthorDD/AuthorDD.java index de1af0fd43c..bbd89fee15a 100644 --- a/test/langtools/jdk/javadoc/doclet/AuthorDD/AuthorDD.java +++ b/test/langtools/jdk/javadoc/doclet/AuthorDD/AuthorDD.java @@ -59,7 +59,8 @@ public class AuthorDD extends JavadocTester { "
Since:
\n" + "
JDK 1.0
", // Test multiple @author tags: - "
Author:
\n" - + "
Alice, Bob, Eve
"); + """ +
Author:
+
Alice, Bob, Eve
"""); } } diff --git a/test/langtools/jdk/javadoc/doclet/DocRootSlash/DocRootSlash.java b/test/langtools/jdk/javadoc/doclet/DocRootSlash/DocRootSlash.java index d31c2656ec9..4ffd10e994a 100644 --- a/test/langtools/jdk/javadoc/doclet/DocRootSlash/DocRootSlash.java +++ b/test/langtools/jdk/javadoc/doclet/DocRootSlash/DocRootSlash.java @@ -56,7 +56,8 @@ public class DocRootSlash extends JavadocTester { javadoc("-d", "out", "-Xdoclint:none", "-overview", (srcdir + "/overview.html"), - "-header", "{@docroot} {@docRoot}", + "-header", """ + {@docroot} {@docRoot}""", "-sourcepath", srcdir, "p1", "p2"); diff --git a/test/langtools/jdk/javadoc/doclet/JavascriptWinTitle/JavascriptWinTitle.java b/test/langtools/jdk/javadoc/doclet/JavascriptWinTitle/JavascriptWinTitle.java index 873e2c44e11..766765c6912 100644 --- a/test/langtools/jdk/javadoc/doclet/JavascriptWinTitle/JavascriptWinTitle.java +++ b/test/langtools/jdk/javadoc/doclet/JavascriptWinTitle/JavascriptWinTitle.java @@ -54,10 +54,12 @@ public class JavascriptWinTitle extends JavadocTester { checkExit(Exit.OK); checkOutput("index.html", true, "\n" - + "\n" - + "
\n"); + """ + """, + """ + + + +
+ """); } } diff --git a/test/langtools/jdk/javadoc/doclet/testIndentation/TestIndentation.java b/test/langtools/jdk/javadoc/doclet/testIndentation/TestIndentation.java index b1109ed0d2c..3ac5f835dfa 100644 --- a/test/langtools/jdk/javadoc/doclet/testIndentation/TestIndentation.java +++ b/test/langtools/jdk/javadoc/doclet/testIndentation/TestIndentation.java @@ -48,12 +48,13 @@ public class TestIndentation extends JavadocTester { checkExit(Exit.OK); checkOutput("p/Indent.html", true, - "
public " - + "<T> " - + "void m" - + "​(T t1,\n" - + "T t2)\n" - + " throws java.lang.Exception
"); + """ +
public <T> void m​(T&nbs\ + p;t1, + T t2) + throws java.lang.Exception
"""); // Test indentation of annotations and annotated method arguments checkOutput("p/IndentAnnot.html", false, diff --git a/test/langtools/jdk/javadoc/doclet/testIndex/TestIndex.java b/test/langtools/jdk/javadoc/doclet/testIndex/TestIndex.java index fd72f1b3d89..3a1f87f3156 100644 --- a/test/langtools/jdk/javadoc/doclet/testIndex/TestIndex.java +++ b/test/langtools/jdk/javadoc/doclet/testIndex/TestIndex.java @@ -51,29 +51,32 @@ public class TestIndex extends JavadocTester { //Test index-all.html checkOutput("index-all.html", true, - "C" - + " - Class in pkg", - "" - + "Interface - Interface in " - + "pkg", - "" - + "AnnotationType - Annotation Type in " - + "pkg", - "" - + "Coin - Enum in " - + "pkg", - "Class in <Unnamed>", - "
\n" - + "
" - + "Java - Static variable in class pkg.C
\n" - + "
 
\n" - + "
JDK " - + "- Static variable in class pkg." - + "C
\n" - + "
 
\n" - + "
", - "
Enum" - + " - Search tag in enum pkg.Coin
"); + """ + C<\ + /a> - Class in pkg""", + """ + Interface - Interface in pkg""", + """ + AnnotationType - Annotation Type in pkg""", + """ + Coin - Enum in pkg""", + """ + Class in <Unnamed>""", + """ +
+
Java - S\ + tatic variable in class pkg.C
+
 
+
JDK - Sta\ + tic variable in class pkg.C
+
 
+
""", + """ +
Enum - Search tag in enum pkg.Coin
"""); } } diff --git a/test/langtools/jdk/javadoc/doclet/testIndexFiles/TestIndexFiles.java b/test/langtools/jdk/javadoc/doclet/testIndexFiles/TestIndexFiles.java index 195c6414a56..904061cb8aa 100644 --- a/test/langtools/jdk/javadoc/doclet/testIndexFiles/TestIndexFiles.java +++ b/test/langtools/jdk/javadoc/doclet/testIndexFiles/TestIndexFiles.java @@ -50,16 +50,20 @@ public class TestIndexFiles extends JavadocTester { void checkIndexFiles(boolean found) { checkOutput("index-files/index-1.html", found, - "
  • Prev Letter
  • \n" - + "
  • Next Letter
  • "); + """ +
  • Prev Letter
  • +
  • Next Letter
  • """); checkOutput("index-files/index-5.html", found, - "
  • Prev Letter
  • \n" - + "
  • Next Letter
  • "); + """ +
  • Prev Letter
  • +
  • Next Letter
  • """); checkOutput("index-files/index-1.html", found, - "
  • Prev Letter
  • \n" - + "
  • Next Letter
  • "); + """ +
  • Prev Letter
  • +
  • Next Letter
  • """); checkOutput("index-files/index-5.html", found, - "
  • Prev Letter
  • \n" - + "
  • Next Letter
  • "); + """ +
  • Prev Letter
  • +
  • Next Letter
  • """); } } diff --git a/test/langtools/jdk/javadoc/doclet/testIndexInDocFiles/TestIndexInDocFiles.java b/test/langtools/jdk/javadoc/doclet/testIndexInDocFiles/TestIndexInDocFiles.java index 2aaddc43544..75d848b424d 100644 --- a/test/langtools/jdk/javadoc/doclet/testIndexInDocFiles/TestIndexInDocFiles.java +++ b/test/langtools/jdk/javadoc/doclet/testIndexInDocFiles/TestIndexInDocFiles.java @@ -70,24 +70,28 @@ public class TestIndexInDocFiles extends JavadocTester { // write the top level (unnamed package) doc file Path topLevelDocFiles = src.resolve("doc-files"); tb.writeFile(topLevelDocFiles.resolve("top-level-file.html"), - "\n" - + "Top level HTML file\n" - + "

    Package HTML file

    \n" - + "{@index top-level-index additional info}\n" - + "{@systemProperty top.level.property}\n" - + "File content\n" - + "\n"); + """ + + Top level HTML file +

    Package HTML file

    + {@index top-level-index additional info} + {@systemProperty top.level.property} + File content + + """); // write the (named) package level doc file Path pkgDocFiles = src.resolve("p").resolve("q").resolve("doc-files"); tb.writeFile(pkgDocFiles.resolve("package-file.html"), - "\n" - + "Package HTML file\n" - + "

    Package HTML file

    \n" - + "{@index package-index additional info}\n" - + "{@systemProperty package.property}\n" - + "File content\n" - + "\n"); + """ + + Package HTML file +

    Package HTML file

    + {@index package-index additional info} + {@systemProperty package.property} + File content + + """); javadoc("-d", base.resolve("out").toString(), "--source-path", src.toString(), @@ -95,22 +99,27 @@ public class TestIndexInDocFiles extends JavadocTester { checkExit(Exit.OK); checkOutput("doc-files/top-level-file.html", true, - "

    Package HTML file

    \n" - + "top-level-index\n" - + "top.level.property\n"); + """ +

    Package HTML file

    + top-level-index + top.level.property + """); checkOutput("p/q/doc-files/package-file.html", true, - "

    Package HTML file

    \n" - + "package-index\n" - + "package.property\n"); + """ +

    Package HTML file

    + package-index + package.property + """); checkOutput("tag-search-index.js", true, - "{\"l\":\"package-index\",\"h\":\"package p.q\",\"d\":\"additional info\"," - + "\"u\":\"p/q/doc-files/package-file.html#package-index\"}", - "{\"l\":\"package.property\",\"h\":\"package p.q\",\"d\":\"System Property\"," - + "\"u\":\"p/q/doc-files/package-file.html#package.property\"}", - "{\"l\":\"top-level-index\",\"h\":\"unnamed package\",\"d\":\"additional info\"," - + "\"u\":\"doc-files/top-level-file.html#top-level-index\"}", - "{\"l\":\"top.level.property\",\"h\":\"unnamed package\",\"d\":\"System Property\"," - + "\"u\":\"doc-files/top-level-file.html#top.level.property\"}"); + """ + {"l":"package-index","h":"package p.q","d":"additional info","u":"p/q/doc-files/package-file.html#package-index"}""", + """ + {"l":"package.property","h":"package p.q","d":"System Property","u":"p/q/doc-files/package-file.html#package.property"}""", + """ + {"l":"top-level-index","h":"unnamed package","d":"additional info","u":"doc-files/top-level-file.html#top-level-index"}""", + """ + {"l":"top.level.property","h":"unnamed package","d":"System Property","u":"doc-f\ + iles/top-level-file.html#top.level.property"}"""); } /** @@ -131,24 +140,28 @@ public class TestIndexInDocFiles extends JavadocTester { // write the doc files for the module Path mdlDocFiles = src.resolve("doc-files"); tb.writeFile(mdlDocFiles.resolve("module-file.html"), - "\n" - + "Module HTML file\n" - + "

    Module HTML file

    \n" - + "{@index module-index additional info}\n" - + "{@systemProperty module.property}\n" - + "File content\n" - + "\n"); + """ + + Module HTML file +

    Module HTML file

    + {@index module-index additional info} + {@systemProperty module.property} + File content + + """); // write the doc files for a package in the module Path pkgDocFiles = src.resolve("p").resolve("q").resolve("doc-files"); tb.writeFile(pkgDocFiles.resolve("package-file.html"), - "\n" - + "Package HTML file\n" - + "

    Package HTML file

    \n" - + "{@index package-index additional info}\n" - + "{@systemProperty package.property}\n" - + "File content\n" - + "\n"); + """ + + Package HTML file +

    Package HTML file

    + {@index package-index additional info} + {@systemProperty package.property} + File content + + """); javadoc("-d", base.resolve("out").toString(), "--source-path", src.toString(), @@ -156,21 +169,26 @@ public class TestIndexInDocFiles extends JavadocTester { checkExit(Exit.OK); checkOutput("m.n/doc-files/module-file.html", true, - "

    Module HTML file

    \n" - + "module-index\n" - + "module.property\n"); + """ +

    Module HTML file

    + module-index + module.property + """); checkOutput("m.n/p/q/doc-files/package-file.html", true, - "

    Package HTML file

    \n" - + "package-index\n" - + "package.property\n"); + """ +

    Package HTML file

    + package-index + package.property + """); checkOutput("tag-search-index.js", true, - "{\"l\":\"module-index\",\"h\":\"module m.n\",\"d\":\"additional info\"," - + "\"u\":\"m.n/doc-files/module-file.html#module-index\"}", - "{\"l\":\"package-index\",\"h\":\"package p.q\",\"d\":\"additional info\"," - + "\"u\":\"m.n/p/q/doc-files/package-file.html#package-index\"}", - "{\"l\":\"module.property\",\"h\":\"module m.n\",\"d\":\"System Property\"," - + "\"u\":\"m.n/doc-files/module-file.html#module.property\"}", - "{\"l\":\"package.property\",\"h\":\"package p.q\",\"d\":\"System Property\"," - + "\"u\":\"m.n/p/q/doc-files/package-file.html#package.property\"}"); + """ + {"l":"module-index","h":"module m.n","d":"additional info","u":"m.n/doc-files/module-file.html#module-index"}""", + """ + {"l":"package-index","h":"package p.q","d":"additional info","u":"m.n/p/q/doc-files/package-file.html#package-index"}""", + """ + {"l":"module.property","h":"module m.n","d":"System Property","u":"m.n/doc-files/module-file.html#module.property"}""", + """ + {"l":"package.property","h":"package p.q","d":"System Property","u":"m.n/p/q/doc\ + -files/package-file.html#package.property"}"""); } } diff --git a/test/langtools/jdk/javadoc/doclet/testIndexInPackageFiles/TestIndexInPackageFiles.java b/test/langtools/jdk/javadoc/doclet/testIndexInPackageFiles/TestIndexInPackageFiles.java index 92cca0d04dd..02b510d310e 100644 --- a/test/langtools/jdk/javadoc/doclet/testIndexInPackageFiles/TestIndexInPackageFiles.java +++ b/test/langtools/jdk/javadoc/doclet/testIndexInPackageFiles/TestIndexInPackageFiles.java @@ -50,28 +50,35 @@ public class TestIndexInPackageFiles extends JavadocTester { public void test() throws IOException { Path src = Path.of("src"); tb.writeJavaFiles(src, - "/**\n" - + " * Summary.\n" - + " * {@index test.name.1 additional info}\n" - + " * {@systemProperty test.property.1}\n" - + " */\n" - + "package p.q;", - "package p.q;\n" - + "/** This is a class in p.q. */\n" - + "public class C { }\n"); + """ + /** + * Summary. + * {@index test.name.1 additional info} + * {@systemProperty test.property.1} + */ + package p.q;""", + """ + package p.q; + /** This is a class in p.q. */ + public class C { } + """); tb.writeFile(src.resolve("p/q/doc-files/extra.html"), - "Extra\n" - + "

    Extra

    \n" - + "{@index test.name.2 additional info}\n" - + "{@systemProperty test.property.2}\n" - + "\n"); + """ + Extra +

    Extra

    + {@index test.name.2 additional info} + {@systemProperty test.property.2} + + """); tb.writeFile("overview.html", - "Overview\n" - + "

    Overview

    \n" - + "{@index test.name.3 additional info}\n" - + "\n"); + """ + Overview +

    Overview

    + {@index test.name.3 additional info} + + """); javadoc("-d", "out", @@ -88,22 +95,32 @@ public class TestIndexInPackageFiles extends JavadocTester { // to match the A-Z index files checked here. checkOutput("p/q/package-summary.html", true, - "test.name.1", - "test.property.1"); + """ + test.name.1""", + """ + test.property.1"""); checkOutput("p/q/doc-files/extra.html", true, - "test.name.2", - "test.property.2"); + """ + test.name.2""", + """ + test.property.2"""); checkOutput("index.html", true, - "test.name.3"); + """ + test.name.3"""); checkOutput("index-all.html", true, - "test.name.1", - "test.name.2", - "test.name.3 - Search tag in Overview", - "test.property.1", - "test.property.2"); + """ + test.name.1""", + """ + test.name.2""", + """ + test.name.3 - Search tag in Overview""", + """ + test.property.1""", + """ + test.property.2"""); } } diff --git a/test/langtools/jdk/javadoc/doclet/testIndexTaglet/TestIndexTaglet.java b/test/langtools/jdk/javadoc/doclet/testIndexTaglet/TestIndexTaglet.java index a937d156f95..e14b42f4527 100644 --- a/test/langtools/jdk/javadoc/doclet/testIndexTaglet/TestIndexTaglet.java +++ b/test/langtools/jdk/javadoc/doclet/testIndexTaglet/TestIndexTaglet.java @@ -76,12 +76,14 @@ public class TestIndexTaglet extends JavadocTester { checkOrder("pkg/A.html", "

    Method Details

    \n", - "
    test description with search_phrase_a
    "); + """ +
    test description with search_phrase_a
    """); checkOrder("pkg/A.html", "

    Method Summary

    \n", - "
    test description with search_phrase_a
    "); + """ +
    test description with search_phrase_a
    """); } @Test @@ -124,7 +126,9 @@ public class TestIndexTaglet extends JavadocTester { checkExit(Exit.OK); checkOutput("pkg/A.html", true, - "This is a class. Here is foo.", - "This is a method. Here is foo."); + """ + This is a class. Here is foo.""", + """ + This is a method. Here is foo."""); } } diff --git a/test/langtools/jdk/javadoc/doclet/testIndexWithModules/TestIndexWithModules.java b/test/langtools/jdk/javadoc/doclet/testIndexWithModules/TestIndexWithModules.java index 86014f25fc4..4c22c7ccf19 100644 --- a/test/langtools/jdk/javadoc/doclet/testIndexWithModules/TestIndexWithModules.java +++ b/test/langtools/jdk/javadoc/doclet/testIndexWithModules/TestIndexWithModules.java @@ -76,7 +76,8 @@ public class TestIndexWithModules extends JavadocTester { checkOrder("index.html", "The overview summary page header", "Modules", - "m1"); + """ + m1"""); } @@ -94,9 +95,12 @@ public class TestIndexWithModules extends JavadocTester { "window.location.replace('index.html')"); checkOrder("index.html", "Modules", - "m1", - "m3", - "m4"); + """ + m1""", + """ + m3""", + """ + m4"""); } //multiple modules with out frames @@ -111,9 +115,12 @@ public class TestIndexWithModules extends JavadocTester { checkExit(Exit.OK); checkOrder("index.html", "Modules", - "m1", - "m3", - "m4"); + """ + m1""", + """ + m3""", + """ + m4"""); } @Test @@ -148,8 +155,10 @@ public class TestIndexWithModules extends JavadocTester { checkExit(Exit.OK); checkOrder("index.html", "Packages", - "P1", - "P2"); + """ + P1""", + """ + P2"""); } diff --git a/test/langtools/jdk/javadoc/doclet/testInlineLinkLabel/TestInlineLinkLabel.java b/test/langtools/jdk/javadoc/doclet/testInlineLinkLabel/TestInlineLinkLabel.java index 2c65e4a715b..f1170dff030 100644 --- a/test/langtools/jdk/javadoc/doclet/testInlineLinkLabel/TestInlineLinkLabel.java +++ b/test/langtools/jdk/javadoc/doclet/testInlineLinkLabel/TestInlineLinkLabel.java @@ -49,8 +49,10 @@ public class TestInlineLinkLabel extends JavadocTester { checkOutput("pkg/C1.html", true, //Search for the label to the package link. - "Here is a link to a package", + """ + Here is a link to a package""", //Search for the label to the class link - "Here is a link to a class"); + """ + Here is a link to a class"""); } } diff --git a/test/langtools/jdk/javadoc/doclet/testInterface/TestInterface.java b/test/langtools/jdk/javadoc/doclet/testInterface/TestInterface.java index 133c6f91081..88b42ef07ea 100644 --- a/test/langtools/jdk/javadoc/doclet/testInterface/TestInterface.java +++ b/test/langtools/jdk/javadoc/doclet/testInterface/TestInterface.java @@ -66,52 +66,54 @@ public class TestInterface extends JavadocTester { checkExit(Exit.OK); checkOutput("pkg/Interface.html", true, - "
    int " - + "method()
    ", - "
    static final " - + "int field
    ", + """ +
    int method()
    """, + """ +
    static final <\ + span class="return-type">int field<\ + /div>""", // Make sure known implementing class list is correct and omits type parameters. - "
    \n" - + "
    All Known Implementing Classes:
    \n" - + "
    Child" - + ", Parent" - + "
    \n" - + "
    "); + """ +
    +
    All Known Implementing Classes:
    +
    Child, Parent
    +
    """); checkOutput("pkg/Child.html", true, // Make sure "All Implemented Interfaces": has substituted type parameters - "
    \n" - + "
    All Implemented Interfaces:
    \n" - + "
    " - + "Interface<CE>
    \n" - + "
    ", + """ +
    +
    All Implemented Interfaces:
    +
    Interface<CE>
    +
    """, //Make sure Class Tree has substituted type parameters. - "
    java.lang.Object\n" - + "
    pkg.Parent<CE>\n" - + "
    pkg.Child<CE>
    \n" - + "
    \n
    ", + """ +
    java.lang.Object +
    pkg.Parent<CE> +
    pkg.Child<CE>
    +
    +
    """, //Make sure "Specified By" has substituted type parameters. - "
    Specified by:
    \n" - + "
    method" - + " in interface " - + "" - + "Interface<" - + "CE>
    ", + """ +
    Specified by:
    +
    method in interface&\ + nbsp;Interface<CE>
    """, //Make sure "Overrides" has substituted type parameters. - "
    Overrides:
    \n" - + "
    method" - + " in class Parent<CE>
    "); + """ +
    Overrides:
    +
    method in class Parent<CE>
    """); checkOutput("pkg/Parent.html", true, //Make sure "Direct Known Subclasses" omits type parameters - "
    \n" - + "
    Direct Known Subclasses:
    \n" - + "
    Child" - + "
    \n" - + "
    "); + """ +
    +
    Direct Known Subclasses:
    +
    Child
    +
    """); checkOutput("pkg/Interface.html", false, "public int method--", @@ -123,34 +125,39 @@ public class TestInterface extends JavadocTester { "
    Specified by:
    \n"); checkOutput("pkg/ClassWithStaticMembers.html", true, - "
    \n" - + "

    f

    \n" - + "
    public static " - + "int f
    \n" - + "
    A hider field
    ", + """ +
    +

    f

    +
    public static \ + int f +
    A hider field
    """, - "static void\n" - + "" - + "m()\n" - + "\n" - + "
    A hider method
    \n" - + "\n", + """ + static void + m() + +
    A hider method
    + + """, - "
    \n" - + "

    staticMethod

    \n" - + "
    public static " - + "void staticMethod()
    \n" - + "
    " - + "Description copied from interface: " - + "" - + "InterfaceWithStaticMembers
    \n" - + "
    A static method
    \n"); + """ +
    +

    staticMethod

    +
    public static \ + void staticMetho\ + d()
    +
    Description copied from inte\ + rface: Inter\ + faceWithStaticMembers
    +
    A static method
    + """); checkOutput("pkg/ClassWithStaticMembers.InnerClass.html", true, - "
    public static class "
    -                + "ClassWithStaticMembers.InnerClass\n"
    -                + "extends java.lang.Object
    \n" - + "
    A hider inner class
    "); + """ +
    public static class ClassWithStaticMembers.InnerClass
    +                    extends java.lang.Object
    +
    A hider inner class
    """); } @Test @@ -162,11 +169,11 @@ public class TestInterface extends JavadocTester { checkOutput("pkg1/Child.html", true, // Ensure the correct Overrides in the inheritance hierarchy is reported - "
    Overrides:
    \n" + - "
    method1" + - " in class " + - "GrandParent" + - "<CE>"); + """ +
    Overrides:
    +
    method1 in class&\ + nbsp;GrandParent<<\ + a href="Child.html" title="type parameter in Child">CE>"""); } @Test @@ -179,23 +186,23 @@ public class TestInterface extends JavadocTester { checkOutput("pkg2/Spliterator.OfDouble.html", true, // Ensure the correct type parameters are displayed correctly - "

    " - + "Nested classes/interfaces inherited from interface pkg2." - + "Spliterator

    \n" - + "" - + "Spliterator.OfDouble, Spliterator.OfInt<" - + "" - + "Integer>, " - + "Spliterator.OfPrimitive<T,​T_CONS,​" - + "" - + "T_SPLITR extends " - + "Spliterator.OfPrimitive<T,​" - + "" - + "T_CONS,​" - + "T_SPLITR>>"); + """ +

    Nested classes/int\ + erfaces inherited from interface pkg2.Spliterator

    + Spliterator.\ + OfDouble, Spliter\ + ator.OfInt<Integer>, Spliterator.OfPrimitive<T,​T\ + _CONS,​T_SPLITR extends Spliterator.OfPrimitive<T,&#\ + 8203;T_CONS,​T_SPLITR>>"""); } } diff --git a/test/langtools/jdk/javadoc/doclet/testJavaFX/TestJavaFX.java b/test/langtools/jdk/javadoc/doclet/testJavaFX/TestJavaFX.java index d7ec085d585..971b31ca6c9 100644 --- a/test/langtools/jdk/javadoc/doclet/testJavaFX/TestJavaFX.java +++ b/test/langtools/jdk/javadoc/doclet/testJavaFX/TestJavaFX.java @@ -53,142 +53,171 @@ public class TestJavaFX extends JavadocTester { checkExit(Exit.OK); checkOutput("pkg1/C.html", true, - "
    See Also:
    \n" - + "
    getRate(), \n" - + "setRate(double)
    ", - "
    public final " - + "void setRate​" - + "(double value)
    \n" - + "
    Sets the value of the property rate.
    \n" - + "
    \n" - + "
    Property description:
    ", - "
    public final " - + "double getRate()
    \n" - + "
    Gets the value of the property rate.
    \n" - + "
    \n" - + "
    Property description:
    ", - "C.DoubleProperty\n" - + "" - + "rate\n" - + "\n" - + "
    Defines the direction/speed at which the " - + "Timeline is expected to\n" - + " be played.
    \n", + """ +
    See Also:
    +
    getRate(),\s + setRate(double)
    """, + """ +
    public final <\ + span class="return-type">void setRate​(double value)
    +
    Sets the value of the property rate.
    +
    +
    Property description:
    """, + """ +
    public final <\ + span class="return-type">double getRate()
    +
    Gets the value of the property rate.
    +
    +
    Property description:
    """, + """ + C.DoubleProperty + rate + +
    Defines the direction/speed at which the Timeline is expected to + be played.
    + """, "
    Default value:
    ", - "
    Since:
    \n" - + "
    JavaFX 8.0
    ", + """ +
    Since:
    +
    JavaFX 8.0
    """, "
    Property description:
    ", - "" - + "" - + "setTestMethodProperty()", - "" - + "paused\n" - + "\n" - + "
    Defines if paused.
    ", - "
    \n" - + "

    paused

    \n" - + "
    public final " - + "" - + "C.BooleanProperty pausedProperty
    \n" - + "
    Defines if paused. The second line.
    ", - "
    \n" - + "

    isPaused

    \n" - + "
    public final " - + "double isPaused()
    \n" - + "
    Gets the value of the property paused.
    ", - "
    \n" - + "

    setPaused

    \n" - + "
    public final " - + "void setPaused​" - + "(boolean value)
    \n" - + "
    Sets the value of the property paused.
    \n" - + "
    \n" - + "
    Property description:
    \n" - + "
    Defines if paused. The second line.
    \n" - + "
    Default value:
    \n" - + "
    false
    ", - "
    \n" - + "

    isPaused

    \n" - + "
    public final " - + "double isPaused()
    \n" - + "
    Gets the value of the property paused.
    \n" - + "
    \n" - + "
    Property description:
    \n" - + "
    Defines if paused. The second line.
    \n" - + "
    Default value:
    \n" - + "
    false
    ", - "
    \n" - + "

    rate

    \n" - + "
    public final " - + "" - + "C.DoubleProperty rateProperty
    \n" - + "
    Defines the direction/speed at which the " - + "Timeline is expected to\n" - + " be played. This is the second line.
    ", - "
    \n" - + "

    setRate

    \n" - + "
    public final " - + "void setRate​" - + "(double value)
    \n" - + "
    Sets the value of the property rate.
    \n" - + "
    \n" - + "
    Property description:
    \n" - + "
    Defines the direction/speed at which the Timeline is expected to\n" - + " be played. This is the second line.
    \n" - + "
    Default value:
    \n" - + "
    11
    \n" - + "
    Since:
    \n" - + "
    JavaFX 8.0
    ", - "
    \n" - + "

    getRate

    \n" - + "
    public final " - + "double getRate()
    \n" - + "
    Gets the value of the property rate.
    \n" - + "
    \n" - + "
    Property description:
    \n" - + "
    Defines the direction/speed at which the Timeline is expected to\n" - + " be played. This is the second line.
    \n" - + "
    Default value:
    \n" - + "
    11
    \n" - + "
    Since:
    \n" - + "
    JavaFX 8.0
    ", - "
    \n" - + "

    Property Summary

    \n" - + "
    \n\n" - + "", - "\n" - + "\n", - "\n" - + "\n"); + """ + """, + """ + + + """, + """ +
    +
    Properties
    C.BooleanProperty
    C.DoublePropertysetTestMethodProperty()paused +
    Defines if paused.
    """, + """ +
    +

    paused

    +
    public final <\ + span class="return-type">\ + C.BooleanProperty pausedProperty
    +
    Defines if paused. The second line.
    """, + """ +
    +

    isPaused

    +
    public final <\ + span class="return-type">double isPaused()
    +
    Gets the value of the property paused.
    """, + """ +
    +

    setPaused

    +
    public final <\ + span class="return-type">void setPaused​(boolean value)
    +
    Sets the value of the property paused.
    +
    +
    Property description:
    +
    Defines if paused. The second line.
    +
    Default value:
    +
    false
    """, + """ +
    +

    isPaused

    +
    public final <\ + span class="return-type">double isPaused()
    +
    Gets the value of the property paused.
    +
    +
    Property description:
    +
    Defines if paused. The second line.
    +
    Default value:
    +
    false
    """, + """ +
    +

    rate

    +
    public final <\ + span class="return-type">C\ + .DoubleProperty rateProperty +
    Defines the direction/speed at which the Timeline is expected to + be played. This is the second line.
    """, + """ +
    +

    setRate

    +
    public final <\ + span class="return-type">void setRate​(double value)
    +
    Sets the value of the property rate.
    +
    +
    Property description:
    +
    Defines the direction/speed at which the Timeline is expected to + be played. This is the second line.
    +
    Default value:
    +
    11
    +
    Since:
    +
    JavaFX 8.0
    """, + """ +
    +

    getRate

    +
    public final <\ + span class="return-type">double getRate()
    +
    Gets the value of the property rate.
    +
    +
    Property description:
    +
    Defines the direction/speed at which the Timeline is expected to + be played. This is the second line.
    +
    Default value:
    +
    11
    +
    Since:
    +
    JavaFX 8.0
    """, + """ +
    +

    Property Summary

    +
    + + """, + """ + + + """, + """ + + + """); checkOutput("pkg1/C.html", false, "A()", - "

    Property Summary

    \n" - + "
    \n" - + "
    " - + "
    ", - "
    \n" - + "\n", - "\n" - + "\n"); + """ +

    Property Summary

    +
    +
    """, + """ +
    + + """, + """ + + + """); checkOutput("index-all.html", true, - "
    Gets the value of the property paused.
    ", - "
    Defines if paused.
    "); + """ +
    Gets the value of the property paused.
    """, + """ +
    Defines if paused.
    """); checkOutput("pkg1/D.html", true, - "

    Properties inherited from class pkg1." - + "C

    \n" - + "" - + "paused, rate"); + """ +

    Properties inherited from class&\ + nbsp;pkg1.C

    + paused, rate"""); checkOutput("pkg1/D.html", false, "shouldNotAppear"); } @@ -207,52 +236,55 @@ public class TestJavaFX extends JavadocTester { "pkg2"); checkExit(Exit.OK); checkOutput("pkg2/Test.html", true, - "
    \n" - + "

    Property Details

    \n" - + "
      \n" - + "
    • \n" - + "
      \n" - + "

      beta

      \n" - + "
      public " - + "java.lang.Object" - + " betaProperty
      \n" - + "
      \n" - + "
    • \n" - + "
    • \n" - + "
      \n" - + "

      gamma

      \n" - + "
      public final " - + "java.util.List<java.lang.String>" - + " gammaProperty
      \n" - + "
      \n" - + "
    • \n" - + "
    • \n" - + "
      \n" - + "

      delta

      \n" - + "
      public final " - + "java.util.List<java.util.Set<? super java.lang.Object>>" - + " deltaProperty
      \n" - + "
      \n" - + "
    • \n" - + "
    \n" - + "
    ", - "
    \n" - + "

    Property Summary

    \n" - + "
    \n
    Properties
    C.BooleanProperty
    C.DoubleProperty
    C.BooleanProperty
    C.DoubleProperty
    C.BooleanProperty
    C.DoubleProperty
    \n" - + ""); + """ +
    +

    Property Details

    +
      +
    • +
      +

      beta

      +
      public java.lang.Object betaPr\ + operty
      +
      +
    • +
    • +
      +

      gamma

      +
      public final <\ + span class="return-type">java.util.List<java.lang.String> gammaProperty
      +
      +
    • +
    • +
      +

      delta

      +
      public final <\ + span class="return-type">java.util.List<java.util.Set<? super java.lang.Ob\ + ject>> deltaProperty
      +
      +
    • +
    +
    """, + """ +
    +

    Property Summary

    +
    +
    Properties
    + """); checkOutput("pkg2/Test.html", false, - "

    Property Summary

    \n" - + "
    \n" - + "
    " - + "
    "); + """ +

    Property Summary

    +
    +
    """); } /* @@ -268,39 +300,39 @@ public class TestJavaFX extends JavadocTester { checkExit(Exit.OK); checkOutput("pkg2/Test.html", false, "

    Property Summary

    "); checkOutput("pkg2/Test.html", true, - "
    \n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "" + """ + + + + + + + + + + + + + + + + + + + + + + + + + + + """ ); } diff --git a/test/langtools/jdk/javadoc/doclet/testJavaFX/TestJavaFxMode.java b/test/langtools/jdk/javadoc/doclet/testJavaFX/TestJavaFxMode.java index dbb67dc3bec..ae3155823d8 100644 --- a/test/langtools/jdk/javadoc/doclet/testJavaFX/TestJavaFxMode.java +++ b/test/langtools/jdk/javadoc/doclet/testJavaFX/TestJavaFxMode.java @@ -82,19 +82,21 @@ public class TestJavaFxMode extends JavadocTester { "javafx.beans.property.Property", "prop", "Method Summary", "getProp", "Gets the value of the property prop.", - "propProperty", "Sets the value of the property prop."); + """ + propProperty""", "Sets the value of the property prop."); } void createTestClass(Path src) throws Exception { tb.writeJavaFiles(src, - "package pkg;\n" - + "import javafx.beans.property.Property;\n" - + "public class A {\n" - + " public Property prop;\n" - + " public Property propProperty(){return null;}\n" - + " public Property getProp(){return null;}\n" - + " public void setProp(Property prop){}\n" - + "}"); + """ + package pkg; + import javafx.beans.property.Property; + public class A { + public Property prop; + public Property propProperty(){return null;} + public Property getProp(){return null;} + public void setProp(Property prop){} + }"""); } } diff --git a/test/langtools/jdk/javadoc/doclet/testJavascript/TestJavascript.java b/test/langtools/jdk/javadoc/doclet/testJavascript/TestJavascript.java index ea640c7bec9..6cc05346a66 100644 --- a/test/langtools/jdk/javadoc/doclet/testJavascript/TestJavascript.java +++ b/test/langtools/jdk/javadoc/doclet/testJavascript/TestJavascript.java @@ -48,19 +48,23 @@ public class TestJavascript extends JavadocTester { checkExit(Exit.OK); checkOutput("pkg/C.html", false, - ""); + """ + """); checkOutput("index.html", false, - "\n" - + "
    The overview summary page header.
    \n" - + "\n" - + "
    \n" - + "
    Properties
    Modifier and TypeMethodDescription
    <T> java.lang.Object" - + "alphaProperty" - + "​(java.util.List<T> foo) 
    java.lang.Object" - + "betaProperty() 
    java.util.List<java.util.Set<? super java.lang.Object>>" - + "" - + "deltaProperty() 
    java.util.List<java.lang.String>" - + "gammaProperty() 
    Modifier and TypeMethodDescription
    <T> java.lang.ObjectalphaProperty​(java.util.List&\ + lt;T> foo) 
    java.lang.ObjectbetaProperty() 
    java.util.List<java.util.Set<? super java.lang.Object>>deltaProperty() 
    java.util.List<java.lang.String>gammaProperty() 
    \n" - + ""); + """ + +
    The overview summary page header.
    + +
    +
    Modules 
    + """); checkOutput("index.html", false, - "
    Modules 
    \n" - + "
    \n" - + "
    The overview summary page header.
    \n" - + "
    \n" - + "
    \n" - + "\n" - + ""); + """ +
    Modules 
    +
    +
    The overview summary page header.
    + +
    + + """); } void checkNoDescription(boolean found) { checkOutput("moduleA/module-summary.html", found, - "
    \n" - + "

    @Deprecated(forRemoval=true)\n" - + "

    \n" - + "

    Module moduleA

    \n" - + "
    " - + "
      \n" - + "
    • \n" - + "
        \n" - + "
      • \n" - + ""); + """ +
        +

        @Deprecated(forRemoval=true) +

        +

        Module moduleA

        +
          +
        • +
            +
          • + """); checkOutput("moduleB/module-summary.html", found, - "
              \n" - + "
            • \n" - + "
                \n" - + "
              • \n" - + ""); + """ +
                  +
                • +
                    +
                  • + """); } void checkHtml5Description(boolean found) { checkOutput("moduleA/module-summary.html", found, - "
                    \n" - + "
                    Deprecated, for removal:" - + " This API element is subject to removal in a future version.\n" - + "
                    This module is deprecated.
                    \n" - + "
                    \n" - + "\n" - + "
                    This is a test description for the moduleA module with a Search " - + "phrase search phrase.
                    "); + """ +
                    +
                    Deprecated, for re\ + moval: This API element is subject to removal in a future version. +
                    This module is deprecated.
                    +
                    + +
                    This is a test description for the moduleA module with a Sear\ + ch phrase search phrase\ + .
                    """); checkOutput("moduleB/module-summary.html", found, - "
                    \n" - + "\n" - + "
                    This is a test description for the moduleB module. Search " - + "word search_word with no description.
                    "); + """ +
                    + +
                    This is a test description for the moduleB module. Search wor\ + d search_word with no de\ + scription.
                    """); checkOutput("index.html", found, - "\n" - + "\n" - + "
                    \n" - + "
                    \n" - + "
                    The overview summary page header.
                    \n" - + "
                    \n
    Modules 
    \n" - + ""); + """ + + +
    +
    +
    The overview summary page header.
    +
    +
    Modules
    + """); checkOutput("index.html", false, - "
    Modules
    \n" - + "
    \n" - + "\n" - + "
    \n" - + "
    The overview summary page header.
    \n" - + "\n" - + "
    \n\n" - + ""); + """ +
    Modules<
    +
    +
    +
    +
    The overview summary page header.
    + +
    + + """); } void checkHtml5NoDescription(boolean found) { checkOutput("moduleA/module-summary.html", found, - "
    \n" - + "

    @Deprecated(forRemoval=true)\n" - + "

    \n" - + "

    Module moduleA

    \n" - + "
    \n" - + "
    \n" - + "
      \n" - + "
    • \n" - + "
      \n" - + ""); + """ +
      +

      @Deprecated(forRemoval=true) +

      +

      Module moduleA

      +
      +
      +
        +
      • +
        + """); checkOutput("moduleB/module-summary.html", found, - "

        @AnnotationType" - + "(optional=\"Module Annotation\",\n" - + " required=2016)\n" - + "

        \n" - + "

        Module moduleB

        \n" - + "\n" - + "
        \n" - + "
          \n" - + "
        • \n" - + "
          \n" - + ""); + """ +

          @\ + AnnotationType(optional\ + ="Module Annotation", + required=2016) +

          +

          Module moduleB

          + +
          +
            +
          • +
            + """); } void checkModuleLink() { checkOutput("index.html", true, "
          • Module
          • "); checkOutput("moduleA/module-summary.html", true, - "
          • Module
          • "); + """ + """); checkOutput("moduleB/module-summary.html", true, - "
          • Module
          • "); + """ + """); checkOutput("moduleA/testpkgmdlA/class-use/TestClassInModuleA.html", true, - "
          • Module
          • "); + """ +
          • Module
          • """); checkOutput("moduleB/testpkgmdlB/package-summary.html", true, - "
          • Module
          • "); + """ +
          • Module
          • """); checkOutput("moduleB/testpkgmdlB/TestClassInModuleB.html", true, - "
          • Module
          • "); + """ +
          • Module
          • """); checkOutput("moduleB/testpkgmdlB/class-use/TestClassInModuleB.html", true, - "
          • Module
          • "); + """ +
          • Module
          • """); } void checkNoModuleLink() { checkOutput("testpkgnomodule/package-summary.html", true, - "
              \n" - + "
            • Package
            • "); + """ +
    Modules<
    \n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + ""); + """ +
    +
    Modules
    ModuleDescription
    + + + + + + + """); checkOutput("overview-summary.html", false, - "
    \n" - + "
    Modules
    ModuleDescription
    \n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + ""); + """ +
    +
    Packages
    PackageDescription
    + + + + + + + """); } void checkOverviewSummaryPackages() { checkOutput("index.html", false, - "
    \n" - + "
    Packages
    PackageDescription
    \n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "", - "
    Modules
    ModuleDescription
    \n" - + "
    \n" - + "
    The overview summary page header.
    \n" - + "\n" - + "
    \n" - + "\n" - + ""); + """ +
    +
    Packages
    + + + + + + + """, + """ +
    Modules
    ModuleDescription
    +
    +
    The overview summary page header.
    + +
    + + """); checkOutput("index.html", true, - "
    \n" - + "
    Packages
    \n" - + "\n" - + "n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n", - "\n" - + "
    The overview summary page header.
    \n" - + "\n" - + "
    \n" - + "
    Packages
    PackageDescription
    \n" - + ""); + """ +
    +
    Packages
    + + n + + + + + """, + """ + +
    The overview summary page header.
    + +
    +
    Packages
    PackageDescription
    + """); } void checkHtml5OverviewSummaryModules() { checkOutput("index.html", true, - "
    \n" - + "
    Packages
    \n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + ""); + """ +
    +
    Modules
    ModuleDescription
    + + + + + + + """); checkOutput("overview-summary.html", false, - "
    \n" - + "
    Modules
    ModuleDescription
    \n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + ""); + """ +
    +
    Packages
    PackageDescription
    + + + + + + + """); } void checkHtml5OverviewSummaryPackages() { checkOutput("index.html", false, - "
    \n" - + "
    Packages
    PackageDescription
    \n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "", - "
    Modules
    ModuleDescription
    \n" - + "
    \n" - + "
    \n" - + "
    \n" - + "
    The overview summary page header.
    \n" - + "\n" - + "\n" - + "\n" - + "\n" - + "
    \n" - + "\n" - + ""); + """ +
    +
    Packages
    + + + + + + + """, + """ +
    Modules
    ModuleDescription
    +
    +
    +
    +
    The overview summary page header.
    + + + + +
    + + """); checkOutput("index.html", true, - "
    \n
    Packages
    \n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "", - "\n" - + "\n" - + "
    \n" - + "
    \n" - + "
    The overview summary page header.
    \n" - + "
    \n
    Packages
    PackageDescription
    \n" - + ""); + """ +
    +
    Packages
    + + + + + + + """, + """ + + +
    +
    +
    The overview summary page header.
    +
    +
    Packages
    PackageDescription
    + """); } void checkModuleSummary() { checkOutput("moduleA/module-summary.html", true, - "", - "
    \n" - + "\n" - + "

    Modules

    ", - "
    \n" - + "\n" - + "\n" - + "", - "
    \n" - + "\n" - + "

    Packages

    ", - "
    \n" - + "\n" - + "\n" - + "\n" - + ""); + """ + """, + """ +
    + +

    Modules

    """, + """ +
    + + + """, + """ +
    + +

    Packages

    """, + """ +
    + + + + """); checkOutput("moduleB/module-summary.html", true, - "
  • Description | 
  • \n" - + "
  • Modules | 
  • \n" - + "
  • Packages | 
  • \n" - + "
  • Services
  • ", - "\n" - + "

    Packages

    ", - "\n" - + "\n" - + "\n" - + "", - "\n" - + "

    Packages

    ", - "\n" - + "

    Services

    ", - "\n" - + "\n" - + "\n" - + "", - "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "", - "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "", - "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + ""); + """ +
  • Description | 
  • +
  • Modules | 
  • +
  • Packages | 
  • +
  • Services
  • """, + """ + +

    Packages

    """, + """ + + + + """, + """ + +

    Packages

    """, + """ + +

    Services

    """, + """ + + + + """, + """ + + + + + + + """, + """ + + + + + + + """, + """ + + + + + + + """); } void checkAggregatorModuleSummary() { checkOutput("moduleT/module-summary.html", true, - "
    \n" - + "

    Module moduleT

    \n" - + "
    ", - "
    This is a test description for the moduleT module. " - + "Search phrase search phrase. " - + "Make sure there are no exported packages.
    ", - "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + ""); + """ +
    +

    Module moduleT

    +
    """, + """ +
    This is a test description for the moduleT module. Search phr\ + ase search phrase. Make\ + sure there are no exported packages.
    """, + """ + + + + + + + + + + + + """); } void checkNegatedModuleSummary() { checkOutput("moduleA/module-summary.html", false, - "\n" - + "

    Services

    "); + """ + +

    Services

    """); } void checkModuleFilesAndLinks(boolean found) { checkFileAndOutput("moduleA/testpkgmdlA/package-summary.html", found, - "
  • Module
  • ", - "
    Module " - + "moduleA
    "); + """ +
  • Module
  • """, + """ +
    Module \ + moduleA
    """); checkFileAndOutput("moduleA/testpkgmdlA/TestClassInModuleA.html", found, - "
  • Module
  • ", - "
    Module " - + "moduleA
    "); + """ +
  • Module
  • """, + """ +
    Module moduleA
    """); checkFileAndOutput("moduleB/testpkgmdlB/AnnotationType.html", found, - "
    Module " - + "moduleB
    ", - "
    " - + "Package testpkgmdlB
    "); + """ +
    Module moduleB
    """, + """ +
    Package <\ + a href="package-summary.html">testpkgmdlB
    """); checkFiles(found, "moduleA/module-summary.html"); } void checkModulesInSearch(boolean found) { checkOutput("index-all.html", found, - "
    \n" - + "
    moduleA - module moduleA
    \n" - + "
    \n" - + "
    This is a test description for the moduleA module with a Search " - + "phrase search phrase.
    \n" - + "
    \n" - + "
    moduleB - module moduleB
    \n" - + "
    \n" - + "
    This is a test description for the moduleB module.
    \n" - + "
    \n" - + "
    ", - "
    \n" - + "
    " - + "search_word - Search tag in module moduleB
    \n" - + "
     
    \n" - + "
    " - + "search phrase - Search tag in module moduleA
    \n" - + "
    with description
    \n" - + "
    "); + """ +
    +
    moduleA - module moduleA
    +
    +
    This is a test description for the moduleA module with a Search phrase search phrase.
    +
    +
    moduleB - module moduleB
    +
    +
    This is a test description for the moduleB module.
    +
    +
    """, + """ +
    +
    search_word - Search tag in module moduleB
    +
     
    +
    search phrase - Search tag in module moduleA
    +
    with description
    +
    """); checkOutput("index-all.html", false, - "
    " - + "search phrase - Search tag in module moduleA
    \n" - + "
    with description
    \n" - + "
    " - + "search phrase - Search tag in module moduleA
    \n" - + "
    with description
    "); + """ +
    search phrase - Search tag in module moduleA
    +
    with description
    +
    search phrase - Search tag in module moduleA
    +
    with description
    """); } void checkModuleModeCommon() { checkOutput("index.html", true, - "\n" - + "", - "\n" - + "", - "\n" - + ""); + """ + + """, + """ + + """, + """ + + """); checkOutput("moduleA/module-summary.html", true, - "
  • Description | 
  • \n" - + "
  • Modules | 
  • \n" - + "
  • Packages | 
  • \n" - + "
  • Services
  • ", - "\n" - + "\n"); + """ +
  • Description | 
  • +
  • Modules | 
  • +
  • Packages | 
  • +
  • Services
  • """, + """ + + + """); checkOutput("moduleB/module-summary.html", true, - "\n" - + "\n"); + """ + + + """); checkOutput("moduletags/module-summary.html", true, - "
  • Description | 
  • \n" - + "
  • Modules | 
  • \n" - + "
  • Packages | 
  • \n" - + "
  • Services
  • ", - "
    \n
    Packages
    testpkgmdlA 
    transitivemoduleB\n" - + "
    This is a test description for the moduleB module.
    \n" - + "
    testpkgmdlA 
    transitivemoduleB +
    This is a test description for the moduleB module.
    +
    testpkgmdlB 
    TestClassInModuleB\n" - + "
    With a test description for uses.
    \n
    Opens
    PackageDescription
    Uses
    TypeDescription
    Provides
    TypeDescription
    testpkgmdlB 
    TestClassInModuleB +
    With a test description for uses.
    +
    Opens
    PackageDescription
    Uses
    TypeDescription
    Provides
    TypeDescription
    transitivemoduleA\n" - + "
    This is a test description for the moduleA module with a Search " - + "phrase search phrase.
    \n" - + "
    transitivemoduleB\n" - + "
    This is a test description for the moduleB module.
    \n" - + "
    transitivemoduleA +
    This is a test description for the moduleA module with a Search phrase search phrase.
    +
    transitivemoduleB +
    This is a test description for the moduleB module.
    +
    moduleA\n" - + "
    This is a test description for the moduleA module with a Search " - + "phrase search phrase.
    \n" - + "
    moduleB\n" - + "
    This is a test description for the moduleB module.
    \n" - + "
    moduletags\n" - + "
    This is a test description for the moduletags module.
    \n" - + " Type Link: TestClassInModuleTags.
    \n" - + " Member Link: testMethod(String).
    \n" - + " Package Link: testpkgmdltags.
    \n" - + "
    moduleA +
    This is a test description for the moduleA module with a Search phrase search phrase.
    +
    moduleB +
    This is a test description for the moduleB module.
    +
    moduletags +
    This is a test description for the moduletags module.
    + Type Link: TestClassInModuleTags.
    + Member Link: testMethod(String).
    + Package Link: testpkgmdltags.
    +
    moduleBtestpkgmdlBmoduleBtestpkgmdlBTestClassInModuleB\n" - + "
    With a test description for uses.
    \n
    TestClassInModuleB +
    With a test description for uses.
    +
    \n" - + "", - "\n" - + "\n" - + "", - "
    \n
    Indirect Requires
    transitivemoduleB\n" - + "
    This is a test description for the moduleB module.
    \n" - + "
    \n" - + "", - "\n" - + "\n" - + "", - "
    \n
    Indirect Exports
    transitive staticmoduleA\n" - + "
    This is a test description for the moduleA module with a Search " - + "phrase search phrase.
    \n" - + "
    \n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "", - "
    \n
    Requires
    ModifierModuleDescription
    \n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "", - "
    \n
    Indirect Requires
    ModifierModuleDescription
    \n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n", - "\n" - + "\n"); + """ +
  • Description | 
  • +
  • Modules | 
  • +
  • Packages | 
  • +
  • Services
  • """, + """ +
    +
    Indirect Opens
    FromPackages
    moduleBtestpkgmdlB
    + """, + """ + + + """, + """ +
    +
    Indirect Requires
    transitivemoduleB +
    This is a test description for the moduleB module.
    +
    + """, + """ + + + """, + """ +
    +
    Indirect Exports
    transitive staticmoduleA +
    This is a test description for the moduleA module with a Search phrase search phrase.
    +
    + + + + + + """, + """ +
    +
    Requires
    ModifierModuleDescription
    + + + + + + """, + """ +
    +
    Indirect Requires
    ModifierModuleDescription
    + + + + + + + """, + """ + + + """); } void checkModuleModeApi(boolean found) { checkOutput("moduleA/module-summary.html", found, - "\n" - + ""); + """ + + """); checkOutput("moduleB/module-summary.html", found, - "
  • Description | 
  • \n" - + "
  • Modules | 
  • \n" - + "
  • Packages | 
  • \n" - + "
  • Services
  • ", - "\n" - + "", - "
    \n
    Indirect Opens
    FromPackages
    moduleBtestpkgmdlBtestpkgmdlA testpkgmdlA testpkgmdlB 
    \n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "\n" - + "
    Opens
    PackageDescription
    testpkgmdlB 
    "); + """ +
  • Description | 
  • +
  • Modules | 
  • +
  • Packages | 
  • +
  • Services
  • """, + """ +
    testpkgmdlB 
    + + + + + + + + + + + + + +
    Opens
    PackageDescription
    testpkgmdlB 
    """); checkOutput("moduletags/module-summary.html", true, - "testpkgmdltags\n" - + " "); + """ + testpkgmdltags +  """); } void checkModuleModeAll(boolean found) { checkOutput("moduleA/module-summary.html", found, - " \n" - + "java.base\n" - + " ", - " \n" - + "moduleC\n" - + "\n" - + "
    This is a test description for the moduleC module.
    \n" - + "", - "moduleC\n" - + "testpkgmdlC", - "testpkgmdlA\n" - + "All Modules\n" - + " ", - "
    ", - "concealedpkgmdlA\n" - + "None\n" - + " "); + """ + + java.base +  """, + """ + + moduleC + +
    This is a test description for the moduleC module.
    + """, + """ + moduleC + testpkgmdlC""", + """ + testpkgmdlA + All Modules +  """, + """ +
    """, + """ + concealedpkgmdlA + None +  """); checkOutput("moduleB/module-summary.html", found, - "
  • Description | 
  • \n" - + "
  • Modules | 
  • \n" - + "
  • Packages | 
  • \n" - + "
  • Services
  • ", - "testpkgmdlB\n" - + "None\n" - + "All Modules\n" - + " ", - " \n" - + "java.base\n" - + " ", - "TestClass2InModuleB\n" - + " ", - "TestInterface2InModuleB\n" - + " 
    (Implementation(s): TestClass2InModuleB)", - "TestInterfaceInModuleB\n" - + " 
    (Implementation(s): TestClassInModuleB)", - "
    "); + """ +
  • Description | 
  • +
  • Modules | 
  • +
  • Packages | 
  • +
  • Services
  • """, + """ + testpkgmdlB + None + All Modules +  """, + """ + + java.base +  """, + """ + TestClass2InModuleB +  """, + """ + TestInterface2InModuleB +  
    (Implementatio\ + n(s): TestClass2InModuleB)""", + """ + TestInterfaceInModuleB +  
    (Implementatio\ + n(s): TestClassInModuleB)""", + """ +
    """); checkOutput("moduleC/module-summary.html", found, - "Exports\n" - + "\n" - + "\n" - + "Package\n" - + "Exported To Modules\n" - + "Description\n" - + "\n" - + ""); + """ + Exports + + + Package + Exported To Modules + Description + + """); checkOutput("moduletags/module-summary.html", true, - "testpkgmdltags\n" - + " "); + """ + testpkgmdltags +  """); } void checkModuleDeprecation(boolean found) { checkOutput("moduleA/module-summary.html", found, - "
    Deprecated, for removal:" - + " This API element is subject to removal in a future version.\n" - + "
    This module is deprecated.
    \n" - + "
    "); + """ +
    Deprecated, for re\ + moval: This API element is subject to removal in a future version. +
    This module is deprecated.
    +
    """); checkOutput("deprecated-list.html", found, - "", - "\n" - + "moduleA\n" - + "\n" - + "
    This module is deprecated.
    \n" - + "\n" - + ""); + """ + """, + """ + + moduleA + +
    This module is deprecated.
    + + """); checkOutput("moduleB/module-summary.html", !found, - "
    Deprecated.\n" - + "
    This module is deprecated using just the javadoc tag.
    \n"); + """ +
    Deprecated. +
    This module is deprecated using just the javadoc tag.
    + """); checkOutput("moduletags/module-summary.html", found, "

    @Deprecated\n" + "

    ", - "
    Deprecated.
    "); + """ +
    Deprecated.
    """); } void checkModuleAnnotation() { checkOutput("moduleB/module-summary.html", true, - "

    @AnnotationType(optional=\"Module Annotation\",\n" - + " required=2016)\n" - + "

    "); + """ +

    @\ + AnnotationType(optional\ + ="Module Annotation", + required=2016) +

    """); checkOutput("moduleB/module-summary.html", false, "@AnnotationTypeUndocumented"); } void checkModuleSummaryNoExported(boolean found) { checkOutput("moduleNoExport/module-summary.html", found, - "\n" - + "

    Packages

    ", + """ + +

    Packages

    """, "Concealed"); } void checkGroupOption() { checkOutput("index.html", true, - "
    \n" - + "
    " - + "" - + "Other Modules
    \n" - + "
    \n" - + "", - "var data = {\"i0\":1,\"i1\":2,\"i2\":2,\"i3\":4};\n" - + "var tabs = {65535:[\"t0\",\"All Modules\"],1:[\"t1\",\"Module Group A\"],2:[\"t2\",\"Module Group B & C\"],4:[\"t4\",\"Other Modules\"]};\n" - + "var altColor = \"alt-color\";\n" - + "var rowColor = \"row-color\";\n" - + "var tableTab = \"table-tab\";\n" - + "var activeTableTab = \"active-table-tab\";"); + """ +
    +
    +
    +
    """, + """ + var data = {"i0":1,"i1":2,"i2":2,"i3":4}; + var tabs = {65535:["t0","All Modules"],1:["t1","Module Group A"],2:["t2","Module\ + Group B & C"],4:["t4","Other Modules"]}; + var altColor = "alt-color"; + var rowColor = "row-color"; + var tableTab = "table-tab"; + var activeTableTab = "active-table-tab";"""); checkOutput("index.html", false, - "
    \n
    \n" - + "", + """ +
    +
    Modules
    + """, "Java SE Modules"); } void checkGroupOptionOrdering() { checkOutput("index.html", true, - "
    " - + "
    ", - "var tabs = {65535:[\"t0\",\"All Modules\"],1:[\"t1\",\"B Group\"],2:[\"t2\",\"C Group\"]," - + "4:[\"t4\",\"A Group\"],8:[\"t8\",\"Other Modules\"]};"); + """ +
    """, + """ + var tabs = {65535:["t0","All Modules"],1:["t1","B Group"],2:["t2","C Group"],4:[\ + "t4","A Group"],8:["t8","Other Modules"]};"""); checkOutput("index.html", false, - "
    " - + "
    ", + """ +
    """, "Java SE Modules"); } void checkUnnamedModuleGroupOption() { checkOutput("index.html", true, - "
    The overview summary page header.
    \n" - + "
    \n" - + "
    " - + "
    \n" - + "
    \n" - + "
    Modules
    ", - "var data = {\"i0\":1,\"i1\":2};\n" - + "var tabs = {65535:[\"t0\",\"All Packages\"],1:[\"t1\",\"Package Group 0\"],2:[\"t2\",\"Package Group 1\"]};\n" - + "var altColor = \"alt-color\";\n" - + "var rowColor = \"row-color\";\n" - + "var tableTab = \"table-tab\";\n" - + "var activeTableTab = \"active-table-tab\";"); + """ +
    The overview summary page header.
    +
    +
    +
    +
    """, + """ + var data = {"i0":1,"i1":2}; + var tabs = {65535:["t0","All Packages"],1:["t1","Package Group 0"],2:["t2","Package Group 1"]}; + var altColor = "alt-color"; + var rowColor = "row-color"; + var tableTab = "table-tab"; + var activeTableTab = "active-table-tab";"""); } void checkGroupOptionPackageOrdering() { checkOutput("index.html", true, - "
    " - + "
    ", - "var tabs = {65535:[\"t0\",\"All Packages\"],1:[\"t1\",\"Z Group\"],2:[\"t2\",\"A Group\"]};"); + """ +
    """, + """ + var tabs = {65535:["t0","All Packages"],1:["t1","Z Group"],2:["t2","A Group"]};"""); } void checkGroupOptionSingleModule() { @@ -1212,112 +1365,152 @@ public class TestModules extends JavadocTester { void checkModuleName(boolean found) { checkOutput("test.moduleFullName/module-summary.html", found, - "
    \n" - + "

    Module test.moduleFullName

    \n" - + "
    "); + """ +
    +

    Module test.moduleFullName

    +
    """); checkOutput("index-all.html", found, - "

    T

    \n" - + "
    \n" - + "
    test.moduleFullName - module test.moduleFullName
    \n" - + "
    \n" - + "
    This is a test description for the test.moduleFullName.
    \n" - + "
    "); + """ +

    T

    +
    +
    test.moduleFullName - module test.moduleFullName
    +
    +
    This is a test description for the test.moduleFullName.
    +
    """); checkOutput("test.moduleFullName/module-summary.html", !found, - "
    \n" - + "

    Module moduleFullName

    \n" - + "
    "); + """ +
    +

    Module moduleFullName

    +
    """); checkOutput("index-all.html", !found, - "
    \n" - + "
    moduleFullName - module moduleFullName
    \n" - + "
    \n" - + "
    This is a test description for the test.moduleFullName.
    \n" - + "
    \n" - + "
    "); + """ +
    +
    moduleFullName - module moduleFullName
    +
    +
    This is a test description for the test.moduleFullName.
    +
    +
    """); } void checkLinkOffline() { checkOutput("moduleB/testpkg3mdlB/package-summary.html", true, - "Link to String Class"); + """ + Link to \ + String Class"""); checkOutput("moduleB/testpkg3mdlB/package-summary.html", true, - "Link to java.lang package"); + """ + Link to java.lang package"""); checkOutput("moduleB/testpkg3mdlB/package-summary.html", true, - "Link to java.base module"); + """ + Link to java.base module"""); } void checkLinkSource(boolean includePrivate) { checkOutput("moduleA/module-summary.html", !includePrivate, - "
    \n\n" - + "\n\n\n" - + "\n\n\n" - + "\n\n" - + "\n" - + "\n\n\n
    Exports
    PackageDescription
    testpkgmdlA 
    "); + """ + + + + + + + + + + + + + + +
    Exports
    PackageDescription
    testpkgmdlA 
    """); checkOutput("moduleA/testpkgmdlA/TestClassInModuleA.html", true, - "
    \n
    \n" - + "
    public class "
    -                + "TestClassInModuleA\nextends java.lang.Object
    \n
    "); + """ +
    +
    +
    public class TestClassInModuleA
    +                    extends java.lang.Object
    +
    """); checkOutput("src-html/moduleA/testpkgmdlA/TestClassInModuleA.html", true, - "019 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA\n" - + "020 * or visit www.oracle.com if you need additional information or have any\n" - + "021 * questions.\n" - + "022 */\n" - + "023package testpkgmdlA;\n" - + "024\n" - + "025public class TestClassInModuleA {\n" - + "026}"); + """ + 019 * Please contact Orac\ + le, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + 020 * or visit www.oracle\ + .com if you need additional information or have any + 021 * questions. + 022 */ + 023package testpkgmdlA; + 024 + 025public class TestClassInModuleA { + 026}"""); if (includePrivate) { checkOutput("src-html/moduleA/concealedpkgmdlA/ConcealedClassInModuleA.html", true, - "024package concealedpkgmdlA;\n" - + "025\n" - + "026public class ConcealedClassInModuleA {\n" - + "027 public void testMethodConcealedClass() { }\n" - + "028}"); + """ + 024package concealedpkgmdlA; + 025 + 026public class ConcealedClassInModuleA { + 027 public void testMethodConcealedClass() { } + 028}"""); } } void checkAllPkgsAllClasses(boolean found) { checkOutput("allclasses-index.html", true, - "
    " - + "
    \n", - "\n" - + "\n" - + "Class\n" - + "Description\n" - + "\n" - + "\n"); + """ +
    + """, + """ + + + Class + Description + + + """); checkOutput("allpackages-index.html", true, - "Package Summary\n" - + "\n" - + "\n" - + "Package\n" - + "Description\n" - + "\n" - + ""); + """ + Package Summary + + + Package + Description + + """); checkOutput("allclasses-index.html", found, - "\n"); + """ +
    + """); checkOutput("allpackages-index.html", found, - "
    \n
    \n"); + """ +
    +
    + """); checkOutput("allclasses-index.html", !found, - "
    "); + """ +
    """); checkOutput("allpackages-index.html", !found, - "
    \n" - + "
    "); + """ +
    +
    """); checkOutput("type-search-index.js", true, - "{\"l\":\"All Classes\",\"u\":\"allclasses-index.html\"}"); + """ + {"l":"All Classes","u":"allclasses-index.html"}"""); checkOutput("package-search-index.js", true, - "{\"l\":\"All Packages\",\"u\":\"allpackages-index.html\"}"); + """ + {"l":"All Packages","u":"allpackages-index.html"}"""); checkOutput("index-all.html", true, - "
    All Classes" - + "|" - + "All Packages"); + """ +
    All Classes|All Packages"""); } } diff --git a/test/langtools/jdk/javadoc/doclet/testNavigation/TestModuleNavigation.java b/test/langtools/jdk/javadoc/doclet/testNavigation/TestModuleNavigation.java index fc8a327d3cb..2b4a367e6d4 100644 --- a/test/langtools/jdk/javadoc/doclet/testNavigation/TestModuleNavigation.java +++ b/test/langtools/jdk/javadoc/doclet/testNavigation/TestModuleNavigation.java @@ -84,71 +84,87 @@ public class TestModuleNavigation extends JavadocTester { "Prev", "Next", "All Classes", - "", true), // script tag in Lower Case UC("", true), // script tag in Upper Case WS("< script >#ALERT", false, "-Xdoclint:none"), // script tag with invalid white space - SP("", true), // script tag with an attribute + SP(""" + """, true), // script tag with an attribute ON("x", true), // event handler attribute OME("1", true), // onmouseenter event handler attribute OML("1", true), // onmouseleave event handler attribute diff --git a/test/langtools/jdk/javadoc/tool/api/basic/DocletPathTest.java b/test/langtools/jdk/javadoc/tool/api/basic/DocletPathTest.java index 91df89a7bd3..5214d992581 100644 --- a/test/langtools/jdk/javadoc/tool/api/basic/DocletPathTest.java +++ b/test/langtools/jdk/javadoc/tool/api/basic/DocletPathTest.java @@ -98,30 +98,31 @@ public class DocletPathTest extends APITest { private static final String TEST_STRING = "DocletOnDocletPath found and running"; private static final String docletSrcText = - "import jdk.javadoc.doclet.*;\n" + - "import javax.lang.model.SourceVersion;\n" + - "import java.util.List;\n" + - "import java.util.Collections;\n" + - "import java.util.Set;\n" + - "import jdk.javadoc.doclet.Doclet;\n" + - "import java.util.Locale;\n" + - "import jdk.javadoc.doclet.Reporter;\n" + - "public class DocletOnDocletPath implements Doclet {\n" + - " public boolean run(DocletEnvironment doc) {\n" + - " reporter.print(javax.tools.Diagnostic.Kind.NOTE, " + - " \"" + TEST_STRING + "\");\n" + - " return true;\n" + - " }\n" + - " public Set getSupportedOptions() {return Collections.emptySet();}\n" + - " public SourceVersion getSupportedSourceVersion() {\n" + - " return SourceVersion.latestSupported();\n" + - " }\n" + - " Reporter reporter;\n" + - " public void init(Locale locale, Reporter reporter) {\n" + - " this.reporter = reporter;\n" + - " return;\n" + - " }" + - " public String getName() { return \"DocletOnPath\"; }\n" + - "}\n"; + """ + import jdk.javadoc.doclet.*; + import javax.lang.model.SourceVersion; + import java.util.List; + import java.util.Collections; + import java.util.Set; + import jdk.javadoc.doclet.Doclet; + import java.util.Locale; + import jdk.javadoc.doclet.Reporter; + public class DocletOnDocletPath implements Doclet { + public boolean run(DocletEnvironment doc) { + reporter.print(javax.tools.Diagnostic.Kind.NOTE, \"""" + TEST_STRING + """ + "); + return true; + } + public Set getSupportedOptions() {return Collections.emptySet();} + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latestSupported(); + } + Reporter reporter; + public void init(Locale locale, Reporter reporter) { + this.reporter = reporter; + return; + } public String getName() { return "DocletOnPath"; } + } + """; } diff --git a/test/langtools/jdk/javadoc/tool/doclint/DocLintTest.java b/test/langtools/jdk/javadoc/tool/doclint/DocLintTest.java index c4ff5a81d3a..b7ae7bea38e 100644 --- a/test/langtools/jdk/javadoc/tool/doclint/DocLintTest.java +++ b/test/langtools/jdk/javadoc/tool/doclint/DocLintTest.java @@ -68,13 +68,19 @@ public class DocLintTest { /* 04 */ " public void method() { }\n" + /* 05 */ "\n" + /* 06 */ " /** Syntax < error. */\n" + - /* 07 */ " private void syntaxError() { }\n" + + /* 07 */ """ + \s private void syntaxError() { } + """ + /* 08 */ "\n" + /* 09 */ " /** @see DoesNotExist */\n" + - /* 10 */ " protected void referenceError() { }\n" + + /* 10 */ """ + \s protected void referenceError() { } + """ + /* 11 */ "\n" + /* 12 */ " /** @return */\n" + - /* 13 */ " public int emptyReturn() { return 0; }\n" + + /* 13 */ """ + \s public int emptyReturn() { return 0; } + """ + /* 14 */ "}\n"; final String p1Code = diff --git a/test/langtools/jdk/javadoc/tool/modules/Modules.java b/test/langtools/jdk/javadoc/tool/modules/Modules.java index a1a3cbd4aac..8712782da8c 100644 --- a/test/langtools/jdk/javadoc/tool/modules/Modules.java +++ b/test/langtools/jdk/javadoc/tool/modules/Modules.java @@ -467,10 +467,12 @@ public class Modules extends ModuleTestBase { .write(src); // build the patching module - tb.writeJavaFiles(patchSrc, "package pkg1;\n" + - "/** Class A */ public class A extends java.util.ArrayList { }"); - tb.writeJavaFiles(patchSrc, "package pkg1;\n" - + "/** Class B */ public class B { }"); + tb.writeJavaFiles(patchSrc, """ + package pkg1; + /** Class A */ public class A extends java.util.ArrayList { }"""); + tb.writeJavaFiles(patchSrc, """ + package pkg1; + /** Class B */ public class B { }"""); execTask("--module-source-path", src.toString(), "--patch-module", "java.base=" + patchSrc.toString(), diff --git a/test/langtools/jdk/javadoc/tool/modules/PatchModules.java b/test/langtools/jdk/javadoc/tool/modules/PatchModules.java index 0cba257d6ae..10101a33ec6 100644 --- a/test/langtools/jdk/javadoc/tool/modules/PatchModules.java +++ b/test/langtools/jdk/javadoc/tool/modules/PatchModules.java @@ -132,13 +132,15 @@ public class PatchModules extends ModuleTestBase { Path patchSrc = base.resolve("patch"); // build the patching sources - tb.writeJavaFiles(patchSrc, "package java.util;\n" + - "/** Class Collection */\n" + - "public interface Collection {}"); + tb.writeJavaFiles(patchSrc, """ + package java.util; + /** Class Collection */ + public interface Collection {}"""); - tb.writeJavaFiles(patchSrc, "package java.util;\n" - + "/** Class MyCollection */\n" + - "public interface MyCollection extends Collection {}"); + tb.writeJavaFiles(patchSrc, """ + package java.util; + /** Class MyCollection */ + public interface MyCollection extends Collection {}"""); execTask("-hasDocComments", "--patch-module", "java.base=" + patchSrc.toString(), "java.util"); @@ -161,10 +163,12 @@ public class PatchModules extends ModuleTestBase { .write(src); // build the patching module - tb.writeJavaFiles(patchSrc, "package pkg1;\n" + - "/** Class A */ public class A extends java.util.ArrayList { }"); - tb.writeJavaFiles(patchSrc, "package pkg1;\n" - + "/** Class B */ public class B { }"); + tb.writeJavaFiles(patchSrc, """ + package pkg1; + /** Class A */ public class A extends java.util.ArrayList { }"""); + tb.writeJavaFiles(patchSrc, """ + package pkg1; + /** Class B */ public class B { }"""); Path m1src = Paths.get(src.toString(), "m1"); @@ -190,10 +194,12 @@ public class PatchModules extends ModuleTestBase { .write(src); // build the patching module - tb.writeJavaFiles(patchSrc, "package pkg1;\n" + - "/** Class A */ public class A extends java.util.ArrayList { }"); - tb.writeJavaFiles(patchSrc, "package pkg1;\n" - + "/** Class B */ public class B { }"); + tb.writeJavaFiles(patchSrc, """ + package pkg1; + /** Class A */ public class A extends java.util.ArrayList { }"""); + tb.writeJavaFiles(patchSrc, """ + package pkg1; + /** Class B */ public class B { }"""); execTask("--module-source-path", src.toString(), diff --git a/test/langtools/jdk/javadoc/tool/removeOldDoclet/RemoveOldDoclet.java b/test/langtools/jdk/javadoc/tool/removeOldDoclet/RemoveOldDoclet.java index c0ff69c528c..bd18cb05d18 100644 --- a/test/langtools/jdk/javadoc/tool/removeOldDoclet/RemoveOldDoclet.java +++ b/test/langtools/jdk/javadoc/tool/removeOldDoclet/RemoveOldDoclet.java @@ -71,8 +71,9 @@ public class RemoveOldDoclet extends JavadocTester { checkExit(Exit.ERROR); checkOutput(Output.OUT, true, - "javadoc: error - Class " + Doclet_CLASS_NAME + " is not a valid doclet.\n" - + "Note: As of JDK 13, the com.sun.javadoc API is no longer supported."); + "javadoc: error - Class " + Doclet_CLASS_NAME + """ + is not a valid doclet. + Note: As of JDK 13, the com.sun.javadoc API is no longer supported."""); } static class TestDoclet { diff --git a/test/langtools/jdk/javadoc/tool/testLocaleOption/TestLocaleOption.java b/test/langtools/jdk/javadoc/tool/testLocaleOption/TestLocaleOption.java index 12ce6c4efe3..aa5d783ffc9 100644 --- a/test/langtools/jdk/javadoc/tool/testLocaleOption/TestLocaleOption.java +++ b/test/langtools/jdk/javadoc/tool/testLocaleOption/TestLocaleOption.java @@ -93,12 +93,14 @@ public class TestLocaleOption extends TestRunner { srcDir = Path.of("src"); tb.writeJavaFiles(srcDir, - "package p;\n" - + "public class HelloWorld {\n" - + " public static void main(String... args) {\n" - + " System.out.println(\"Hello World!\");\n" - + " }\n" - + "}\n"); + """ + package p; + public class HelloWorld { + public static void main(String... args) { + System.out.println("Hello World!"); + } + } + """); runTests(m -> new Object[]{Path.of(m.getName())}); } @@ -125,12 +127,14 @@ public class TestLocaleOption extends TestRunner { if (Objects.equals(defaultLocale, ALLCAPS)) { checkContains(stdOut, - "USAGE:\n" - + " JAVADOC [OPTIONS] [PACKAGENAMES] [SOURCEFILES] [@FILES]"); + """ + USAGE: + JAVADOC [OPTIONS] [PACKAGENAMES] [SOURCEFILES] [@FILES]"""); } else { checkContains(stdOut, - "Usage:\n" - + " javadoc [options] [packagenames] [sourcefiles] [@files]"); + """ + Usage: + javadoc [options] [packagenames] [sourcefiles] [@files]"""); } } @@ -162,12 +166,14 @@ public class TestLocaleOption extends TestRunner { // check console messages if (Objects.equals(defaultLocale, ALLCAPS)) { checkContains(stdOut, - "LOADING SOURCE FILES FOR PACKAGE p...\n" - + "CONSTRUCTING JAVADOC INFORMATION..."); + """ + LOADING SOURCE FILES FOR PACKAGE p... + CONSTRUCTING JAVADOC INFORMATION..."""); } else { checkContains(stdOut, - "Loading source files for package p...\n" - + "Constructing Javadoc information..."); + """ + Loading source files for package p... + Constructing Javadoc information..."""); } // check generated files @@ -176,15 +182,21 @@ public class TestLocaleOption extends TestRunner { if (Objects.equals(docLocale, ALLCAPS)) { checkContains(hw, "

    METHOD SUMMARY

    ", - "
    ", - "", - ""); + """ + """, + """ + """, + """ + """); } else { checkContains(hw, "

    Method Summary

    ", - "", - "", - ""); + """ + """, + """ + """, + """ + """); } } diff --git a/test/langtools/jdk/javadoc/tool/testWErrorOption/TestWErrorOption.java b/test/langtools/jdk/javadoc/tool/testWErrorOption/TestWErrorOption.java index 634fa6d1c25..129cdf6f1a1 100644 --- a/test/langtools/jdk/javadoc/tool/testWErrorOption/TestWErrorOption.java +++ b/test/langtools/jdk/javadoc/tool/testWErrorOption/TestWErrorOption.java @@ -75,9 +75,11 @@ public class TestWErrorOption extends JavadocTester { checkExit(Exit.ERROR); checkOutput(Output.OUT, true, "C.java:6: warning - @return tag cannot be used in method with void return type.", - "javadoc: error - warnings found and -Werror specified\n" - + "1 error\n" - + "1 warning\n"); + """ + javadoc: error - warnings found and -Werror specified + 1 error + 1 warning + """); } @Test @@ -86,19 +88,22 @@ public class TestWErrorOption extends JavadocTester { "--help"); checkExit(Exit.OK); checkOutput(Output.OUT, true, - "-Werror Report an error if any warnings occur\n"); + """ + -Werror Report an error if any warnings occur + """); } private void generateSrc(Path base) throws IOException { Path src = base.resolve("src"); tb.writeJavaFiles(src, - "package p;\n" - + "public class C {\n" - + " /** Comment.\n" - + " * @return warning\n" - + " */\n" - + " public void m() { }\n" - + "}"); + """ + package p; + public class C { + /** Comment. + * @return warning + */ + public void m() { } + }"""); } } From 957eb270f0836e2b25dc8d0e2ab239a428639617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20Walln=C3=B6fer?= Date: Tue, 5 May 2020 22:56:01 +0200 Subject: [PATCH 41/88] 8243388: Moving search result selection clears search input Reviewed-by: prappo --- .../javadoc/internal/doclets/formats/html/resources/search.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js index 0713fadcf7e..9a684ca1b55 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/search.js @@ -310,6 +310,9 @@ $(function() { } }, autoFocus: true, + focus: function(event, ui) { + return false; + }, position: { collision: "flip" }, From eadcb08c3cc41dbb05b083bf3e83eaf1d2670cfe Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Tue, 5 May 2020 11:10:02 -0700 Subject: [PATCH 42/88] 8241071: Generation of classes.jsa with -Xshare:dump is not deterministic Reviewed-by: dholmes, stuefe --- make/hotspot/symbols/symbols-unix | 3 +- src/hotspot/share/classfile/symbolTable.cpp | 11 ++ .../classfile/systemDictionaryShared.cpp | 14 +- src/hotspot/share/include/jvm.h | 3 + src/hotspot/share/memory/dynamicArchive.cpp | 5 +- src/hotspot/share/memory/filemap.cpp | 38 +++--- src/hotspot/share/memory/heapShared.cpp | 4 + src/hotspot/share/memory/metaspaceShared.cpp | 129 +++++++++++++----- src/hotspot/share/memory/metaspaceShared.hpp | 31 ++--- src/hotspot/share/oops/instanceKlass.cpp | 4 - src/hotspot/share/oops/klass.cpp | 5 + src/hotspot/share/oops/symbol.cpp | 25 ++++ src/hotspot/share/oops/symbol.hpp | 3 +- src/hotspot/share/prims/jvm.cpp | 23 ++++ .../java/util/ImmutableCollections.java | 12 +- .../share/classes/jdk/internal/misc/VM.java | 4 +- src/java.base/share/native/libjava/VM.c | 7 +- test/hotspot/jtreg/TEST.groups | 5 +- .../jtreg/runtime/cds/DeterministicDump.java | 113 +++++++++++++++ .../runtime/cds/SpaceUtilizationCheck.java | 22 +-- 20 files changed, 369 insertions(+), 92 deletions(-) create mode 100644 test/hotspot/jtreg/runtime/cds/DeterministicDump.java diff --git a/make/hotspot/symbols/symbols-unix b/make/hotspot/symbols/symbols-unix index 50a16fafa68..5c17fd8f3ce 100644 --- a/make/hotspot/symbols/symbols-unix +++ b/make/hotspot/symbols/symbols-unix @@ -1,5 +1,5 @@ # -# Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2016, 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 @@ -122,6 +122,7 @@ JVM_GetNestMembers JVM_GetPrimitiveArrayElement JVM_GetProperties JVM_GetProtectionDomain +JVM_GetRandomSeedForCDSDump JVM_GetRecordComponents JVM_GetSimpleBinaryName JVM_GetStackAccessControlContext diff --git a/src/hotspot/share/classfile/symbolTable.cpp b/src/hotspot/share/classfile/symbolTable.cpp index c2530653191..5d254da077f 100644 --- a/src/hotspot/share/classfile/symbolTable.cpp +++ b/src/hotspot/share/classfile/symbolTable.cpp @@ -176,6 +176,11 @@ void SymbolTable::create_table () { } void SymbolTable::delete_symbol(Symbol* sym) { + if (Arguments::is_dumping_archive()) { + // Do not delete symbols as we may be in the middle of preparing the + // symbols for dumping. + return; + } if (sym->is_permanent()) { MutexLocker ml(SymbolArena_lock, Mutex::_no_safepoint_check_flag); // Protect arena // Deleting permanent symbol should not occur very often (insert race condition), @@ -221,12 +226,18 @@ Symbol* SymbolTable::allocate_symbol(const char* name, int len, bool c_heap) { Symbol* sym; if (Arguments::is_dumping_archive()) { + // Need to make all symbols permanent -- or else some symbols may be GC'ed + // during the archive dumping code that's executed outside of a safepoint. c_heap = false; } if (c_heap) { // refcount starts as 1 sym = new (len) Symbol((const u1*)name, len, 1); assert(sym != NULL, "new should call vm_exit_out_of_memory if C_HEAP is exhausted"); + } else if (DumpSharedSpaces) { + // See comments inside Symbol::operator new(size_t, int) + sym = new (len) Symbol((const u1*)name, len, PERM_REFCOUNT); + assert(sym != NULL, "new should call vm_exit_out_of_memory if failed to allocate symbol during DumpSharedSpaces"); } else { // Allocate to global arena MutexLocker ml(SymbolArena_lock, Mutex::_no_safepoint_check_flag); // Protect arena diff --git a/src/hotspot/share/classfile/systemDictionaryShared.cpp b/src/hotspot/share/classfile/systemDictionaryShared.cpp index 3c9cae9f179..ad1d7f7b3a2 100644 --- a/src/hotspot/share/classfile/systemDictionaryShared.cpp +++ b/src/hotspot/share/classfile/systemDictionaryShared.cpp @@ -174,10 +174,22 @@ public: } }; +inline unsigned DumpTimeSharedClassTable_hash(InstanceKlass* const& k) { + if (DumpSharedSpaces) { + // Deterministic archive contents + uintx delta = k->name() - MetaspaceShared::symbol_rs_base(); + return primitive_hash(delta); + } else { + // Deterministic archive is not possible because classes can be loaded + // in multiple threads. + return primitive_hash(k); + } +} + class DumpTimeSharedClassTable: public ResourceHashtable< InstanceKlass*, DumpTimeSharedClassInfo, - primitive_hash, + &DumpTimeSharedClassTable_hash, primitive_equals, 15889, // prime number ResourceObj::C_HEAP> diff --git a/src/hotspot/share/include/jvm.h b/src/hotspot/share/include/jvm.h index 6db1b264369..331924f5939 100644 --- a/src/hotspot/share/include/jvm.h +++ b/src/hotspot/share/include/jvm.h @@ -176,6 +176,9 @@ JVM_GetVmArguments(JNIEnv *env); JNIEXPORT void JNICALL JVM_InitializeFromArchive(JNIEnv* env, jclass cls); +JNIEXPORT jlong JNICALL +JVM_GetRandomSeedForCDSDump(); + /* * java.lang.Throwable */ diff --git a/src/hotspot/share/memory/dynamicArchive.cpp b/src/hotspot/share/memory/dynamicArchive.cpp index 41cd492f446..ed6143b7d14 100644 --- a/src/hotspot/share/memory/dynamicArchive.cpp +++ b/src/hotspot/share/memory/dynamicArchive.cpp @@ -503,14 +503,13 @@ private: void write_archive(char* serialized_data); void init_first_dump_space(address reserved_bottom) { - address first_space_base = reserved_bottom; DumpRegion* mc_space = MetaspaceShared::misc_code_dump_space(); DumpRegion* rw_space = MetaspaceShared::read_write_dump_space(); // Use the same MC->RW->RO ordering as in the base archive. - MetaspaceShared::init_shared_dump_space(mc_space, first_space_base); + MetaspaceShared::init_shared_dump_space(mc_space); _current_dump_space = mc_space; - _last_verified_top = first_space_base; + _last_verified_top = reserved_bottom; _num_dump_regions_used = 1; } diff --git a/src/hotspot/share/memory/filemap.cpp b/src/hotspot/share/memory/filemap.cpp index 789c6ac2a86..b3d74ed7932 100644 --- a/src/hotspot/share/memory/filemap.cpp +++ b/src/hotspot/share/memory/filemap.cpp @@ -1177,6 +1177,10 @@ void FileMapRegion::init(int region_index, char* base, size_t size, bool read_on _mapped_base = NULL; } +static const char* region_names[] = { + "mc", "rw", "ro", "bm", "ca0", "ca1", "oa0", "oa1" +}; + void FileMapInfo::write_region(int region, char* base, size_t size, bool read_only, bool allow_exec) { Arguments::assert_is_dumping_archive(); @@ -1184,6 +1188,9 @@ void FileMapInfo::write_region(int region, char* base, size_t size, FileMapRegion* si = space_at(region); char* target_base; + const int num_regions = sizeof(region_names)/sizeof(region_names[0]); + assert(0 <= region && region < num_regions, "sanity"); + if (region == MetaspaceShared::bm) { target_base = NULL; // always NULL for bm region. } else { @@ -1197,11 +1204,13 @@ void FileMapInfo::write_region(int region, char* base, size_t size, si->set_file_offset(_file_offset); char* requested_base = (target_base == NULL) ? NULL : target_base + MetaspaceShared::final_delta(); - log_debug(cds)("Shared file region %d: " SIZE_FORMAT_HEX_W(08) - " bytes, addr " INTPTR_FORMAT " file offset " SIZE_FORMAT_HEX_W(08), - region, size, p2i(requested_base), _file_offset); - int crc = ClassLoader::crc32(0, base, (jint)size); + if (size > 0) { + log_debug(cds)("Shared file region (%-3s) %d: " SIZE_FORMAT_W(8) + " bytes, addr " INTPTR_FORMAT " file offset " SIZE_FORMAT_HEX_W(08) + " crc 0x%08x", + region_names[region], region, size, p2i(requested_base), _file_offset, crc); + } si->init(region, target_base, size, read_only, allow_exec, crc); if (base != NULL) { @@ -1246,8 +1255,6 @@ void FileMapInfo::write_bitmap_region(const CHeapBitMap* ptrmap, write_oopmaps(open_oopmaps, curr_offset, buffer); } - log_debug(cds)("ptrmap = " INTPTR_FORMAT " (" SIZE_FORMAT " bytes)", - p2i(buffer), size_in_bytes); write_region(MetaspaceShared::bm, (char*)buffer, size_in_bytes, /*read_only=*/true, /*allow_exec=*/false); } @@ -1297,23 +1304,20 @@ size_t FileMapInfo::write_archive_heap_regions(GrowableArray *heap_me } size_t total_size = 0; - for (int i = first_region_id, arr_idx = 0; - i < first_region_id + max_num_regions; - i++, arr_idx++) { + for (int i = 0; i < max_num_regions; i++) { char* start = NULL; size_t size = 0; - if (arr_idx < arr_len) { - start = (char*)heap_mem->at(arr_idx).start(); - size = heap_mem->at(arr_idx).byte_size(); + if (i < arr_len) { + start = (char*)heap_mem->at(i).start(); + size = heap_mem->at(i).byte_size(); total_size += size; } - log_debug(cds)("Archive heap region %d: " INTPTR_FORMAT " - " INTPTR_FORMAT " = " SIZE_FORMAT_W(8) " bytes", - i, p2i(start), p2i(start + size), size); - write_region(i, start, size, false, false); + int region_idx = i + first_region_id; + write_region(region_idx, start, size, false, false); if (size > 0) { - space_at(i)->init_oopmap(oopmaps->at(arr_idx)._offset, - oopmaps->at(arr_idx)._oopmap_size_in_bits); + space_at(region_idx)->init_oopmap(oopmaps->at(i)._offset, + oopmaps->at(i)._oopmap_size_in_bits); } } return total_size; diff --git a/src/hotspot/share/memory/heapShared.cpp b/src/hotspot/share/memory/heapShared.cpp index 22ef0b30f98..7eaaf74b19f 100644 --- a/src/hotspot/share/memory/heapShared.cpp +++ b/src/hotspot/share/memory/heapShared.cpp @@ -142,6 +142,10 @@ oop HeapShared::archive_heap_object(oop obj, Thread* THREAD) { if (archived_oop != NULL) { Copy::aligned_disjoint_words(cast_from_oop(obj), cast_from_oop(archived_oop), len); MetaspaceShared::relocate_klass_ptr(archived_oop); + // Clear age -- it might have been set if a GC happened during -Xshare:dump + markWord mark = archived_oop->mark_raw(); + mark = mark.set_age(0); + archived_oop->set_mark_raw(mark); ArchivedObjectCache* cache = archived_object_cache(); cache->put(obj, archived_oop); log_debug(cds, heap)("Archived heap object " PTR_FORMAT " ==> " PTR_FORMAT, diff --git a/src/hotspot/share/memory/metaspaceShared.cpp b/src/hotspot/share/memory/metaspaceShared.cpp index cbea64ff2d7..5bc8df59570 100644 --- a/src/hotspot/share/memory/metaspaceShared.cpp +++ b/src/hotspot/share/memory/metaspaceShared.cpp @@ -77,6 +77,8 @@ ReservedSpace MetaspaceShared::_shared_rs; VirtualSpace MetaspaceShared::_shared_vs; +ReservedSpace MetaspaceShared::_symbol_rs; +VirtualSpace MetaspaceShared::_symbol_vs; MetaspaceSharedStats MetaspaceShared::_stats; bool MetaspaceShared::_has_error_classes; bool MetaspaceShared::_archive_loading_failed = false; @@ -120,21 +122,24 @@ char* DumpRegion::expand_top_to(char* newtop) { MetaspaceShared::report_out_of_space(_name, newtop - _top); ShouldNotReachHere(); } - uintx delta; - if (DynamicDumpSharedSpaces) { - delta = DynamicArchive::object_delta_uintx(newtop); - } else { - delta = MetaspaceShared::object_delta_uintx(newtop); - } - if (delta > MAX_SHARED_DELTA) { - // This is just a sanity check and should not appear in any real world usage. This - // happens only if you allocate more than 2GB of shared objects and would require - // millions of shared classes. - vm_exit_during_initialization("Out of memory in the CDS archive", - "Please reduce the number of shared classes."); + + if (_rs == MetaspaceShared::shared_rs()) { + uintx delta; + if (DynamicDumpSharedSpaces) { + delta = DynamicArchive::object_delta_uintx(newtop); + } else { + delta = MetaspaceShared::object_delta_uintx(newtop); + } + if (delta > MAX_SHARED_DELTA) { + // This is just a sanity check and should not appear in any real world usage. This + // happens only if you allocate more than 2GB of shared objects and would require + // millions of shared classes. + vm_exit_during_initialization("Out of memory in the CDS archive", + "Please reduce the number of shared classes."); + } } - MetaspaceShared::commit_shared_space_to(newtop); + MetaspaceShared::commit_to(_rs, _vs, newtop); _top = newtop; return _top; } @@ -172,26 +177,35 @@ void DumpRegion::print_out_of_space_msg(const char* failing_region, size_t neede } } +void DumpRegion::init(ReservedSpace* rs, VirtualSpace* vs) { + _rs = rs; + _vs = vs; + // Start with 0 committed bytes. The memory will be committed as needed by + // MetaspaceShared::commit_to(). + if (!_vs->initialize(*_rs, 0)) { + fatal("Unable to allocate memory for shared space"); + } + _base = _top = _rs->base(); + _end = _rs->end(); +} + void DumpRegion::pack(DumpRegion* next) { assert(!is_packed(), "sanity"); _end = (char*)align_up(_top, Metaspace::reserve_alignment()); _is_packed = true; if (next != NULL) { + next->_rs = _rs; + next->_vs = _vs; next->_base = next->_top = this->_end; - next->_end = MetaspaceShared::shared_rs()->end(); + next->_end = _rs->end(); } } -static DumpRegion _mc_region("mc"), _ro_region("ro"), _rw_region("rw"); +static DumpRegion _mc_region("mc"), _ro_region("ro"), _rw_region("rw"), _symbol_region("symbols"); static size_t _total_closed_archive_region_size = 0, _total_open_archive_region_size = 0; -void MetaspaceShared::init_shared_dump_space(DumpRegion* first_space, address first_space_bottom) { - // Start with 0 committed bytes. The memory will be committed as needed by - // MetaspaceShared::commit_shared_space_to(). - if (!_shared_vs.initialize(_shared_rs, 0)) { - fatal("Unable to allocate memory for shared space"); - } - first_space->init(&_shared_rs, (char*)first_space_bottom); +void MetaspaceShared::init_shared_dump_space(DumpRegion* first_space) { + first_space->init(&_shared_rs, &_shared_vs); } DumpRegion* MetaspaceShared::misc_code_dump_space() { @@ -211,6 +225,10 @@ void MetaspaceShared::pack_dump_space(DumpRegion* current, DumpRegion* next, current->pack(next); } +char* MetaspaceShared::symbol_space_alloc(size_t num_bytes) { + return _symbol_region.allocate(num_bytes); +} + char* MetaspaceShared::misc_code_space_alloc(size_t num_bytes) { return _mc_region.allocate(num_bytes); } @@ -320,6 +338,14 @@ void MetaspaceShared::initialize_dumptime_shared_and_meta_spaces() { SharedBaseAddress = (size_t)_shared_rs.base(); log_info(cds)("Allocated shared space: " SIZE_FORMAT " bytes at " PTR_FORMAT, _shared_rs.size(), p2i(_shared_rs.base())); + + size_t symbol_rs_size = LP64_ONLY(3 * G) NOT_LP64(128 * M); + _symbol_rs = ReservedSpace(symbol_rs_size); + if (!_symbol_rs.is_reserved()) { + vm_exit_during_initialization("Unable to reserve memory for symbols", + err_msg(SIZE_FORMAT " bytes.", symbol_rs_size)); + } + _symbol_region.init(&_symbol_rs, &_symbol_vs); } // Called by universe_post_init() @@ -397,33 +423,37 @@ void MetaspaceShared::read_extra_data(const char* filename, TRAPS) { } } -void MetaspaceShared::commit_shared_space_to(char* newtop) { +void MetaspaceShared::commit_to(ReservedSpace* rs, VirtualSpace* vs, char* newtop) { Arguments::assert_is_dumping_archive(); - char* base = _shared_rs.base(); + char* base = rs->base(); size_t need_committed_size = newtop - base; - size_t has_committed_size = _shared_vs.committed_size(); + size_t has_committed_size = vs->committed_size(); if (need_committed_size < has_committed_size) { return; } size_t min_bytes = need_committed_size - has_committed_size; size_t preferred_bytes = 1 * M; - size_t uncommitted = _shared_vs.reserved_size() - has_committed_size; + size_t uncommitted = vs->reserved_size() - has_committed_size; size_t commit =MAX2(min_bytes, preferred_bytes); commit = MIN2(commit, uncommitted); assert(commit <= uncommitted, "sanity"); - bool result = _shared_vs.expand_by(commit, false); - ArchivePtrMarker::expand_ptr_end((address*)_shared_vs.high()); + bool result = vs->expand_by(commit, false); + if (rs == &_shared_rs) { + ArchivePtrMarker::expand_ptr_end((address*)vs->high()); + } if (!result) { vm_exit_during_initialization(err_msg("Failed to expand shared space to " SIZE_FORMAT " bytes", need_committed_size)); } - log_debug(cds)("Expanding shared spaces by " SIZE_FORMAT_W(7) " bytes [total " SIZE_FORMAT_W(9) " bytes ending at %p]", - commit, _shared_vs.actual_committed_size(), _shared_vs.high()); + assert(rs == &_shared_rs || rs == &_symbol_rs, "must be"); + const char* which = (rs == &_shared_rs) ? "shared" : "symbol"; + log_debug(cds)("Expanding %s spaces by " SIZE_FORMAT_W(7) " bytes [total " SIZE_FORMAT_W(9) " bytes ending at %p]", + which, commit, vs->actual_committed_size(), vs->high()); } void MetaspaceShared::initialize_ptr_marker(CHeapBitMap* ptrmap) { @@ -506,6 +536,10 @@ uintx MetaspaceShared::object_delta_uintx(void* obj) { // is run at a safepoint just before exit, this is the entire set of classes. static GrowableArray* _global_klass_objects; +static int global_klass_compare(Klass** a, Klass **b) { + return a[0]->name()->fast_compare(b[0]->name()); +} + GrowableArray* MetaspaceShared::collected_klasses() { return _global_klass_objects; } @@ -1331,7 +1365,14 @@ public: RefRelocator ext_reloc; iterate_roots(&ext_reloc); } - + { + log_info(cds)("Fixing symbol identity hash ... "); + os::init_random(0x12345678); + GrowableArray* symbols = _ssc->get_sorted_symbols(); + for (int i=0; ilength(); i++) { + symbols->at(i)->update_identity_hash(); + } + } #ifdef ASSERT { log_info(cds)("Verifying external roots ... "); @@ -1364,6 +1405,21 @@ public: } static void iterate_roots(MetaspaceClosure* it) { + // To ensure deterministic contents in the archive, we just need to ensure that + // we iterate the MetsapceObjs in a deterministic order. It doesn't matter where + // the MetsapceObjs are located originally, as they are copied sequentially into + // the archive during the iteration. + // + // The only issue here is that the symbol table and the system directories may be + // randomly ordered, so we copy the symbols and klasses into two arrays and sort + // them deterministically. + // + // During -Xshare:dump, the order of Symbol creation is strictly determined by + // the SharedClassListFile (class loading is done in a single thread and the JIT + // is disabled). Also, Symbols are allocated in monotonically increasing addresses + // (see Symbol::operator new(size_t, int)). So if we iterate the Symbols by + // ascending address order, we ensure that all Symbols are copied into deterministic + // locations in the archive. GrowableArray* symbols = _ssc->get_sorted_symbols(); for (int i=0; ilength(); i++) { it->push(symbols->adr_at(i)); @@ -1525,6 +1581,7 @@ void VM_PopulateDumpSharedSpace::doit() { _global_klass_objects = new GrowableArray(1000); CollectClassesClosure collect_classes; ClassLoaderDataGraph::loaded_classes_do(&collect_classes); + _global_klass_objects->sort(global_klass_compare); print_class_stats(); @@ -1558,8 +1615,10 @@ void VM_PopulateDumpSharedSpace::doit() { _ro_region.pack(); // The vtable clones contain addresses of the current process. - // We don't want to write these addresses into the archive. + // We don't want to write these addresses into the archive. Same for i2i buffer. MetaspaceShared::zero_cpp_vtable_clones_for_writing(); + memset(MetaspaceShared::i2i_entry_code_buffers(), 0, + MetaspaceShared::i2i_entry_code_buffers_size()); // relocate the data so that it can be mapped to Arguments::default_SharedBaseAddress() // without runtime relocation. @@ -1631,7 +1690,7 @@ void VM_PopulateDumpSharedSpace::print_region_stats(FileMapInfo *map_info) { _mc_region.print(total_reserved); _rw_region.print(total_reserved); _ro_region.print(total_reserved); - print_bitmap_region_stats(bitmap_reserved, total_reserved); + print_bitmap_region_stats(bitmap_used, total_reserved); print_heap_region_stats(_closed_archive_heap_regions, "ca", total_reserved); print_heap_region_stats(_open_archive_heap_regions, "oa", total_reserved); @@ -1640,8 +1699,8 @@ void VM_PopulateDumpSharedSpace::print_region_stats(FileMapInfo *map_info) { } void VM_PopulateDumpSharedSpace::print_bitmap_region_stats(size_t size, size_t total_size) { - log_debug(cds)("bm space: " SIZE_FORMAT_W(9) " [ %4.1f%% of total] out of " SIZE_FORMAT_W(9) " bytes [100.0%% used] at " INTPTR_FORMAT, - size, size/double(total_size)*100.0, size, p2i(NULL)); + log_debug(cds)("bm space: " SIZE_FORMAT_W(9) " [ %4.1f%% of total] out of " SIZE_FORMAT_W(9) " bytes [100.0%% used]", + size, size/double(total_size)*100.0, size); } void VM_PopulateDumpSharedSpace::print_heap_region_stats(GrowableArray *heap_mem, diff --git a/src/hotspot/share/memory/metaspaceShared.hpp b/src/hotspot/share/memory/metaspaceShared.hpp index 3de86c53ca7..4a4ee709f89 100644 --- a/src/hotspot/share/memory/metaspaceShared.hpp +++ b/src/hotspot/share/memory/metaspaceShared.hpp @@ -63,6 +63,8 @@ private: char* _top; char* _end; bool _is_packed; + ReservedSpace* _rs; + VirtualSpace* _vs; public: DumpRegion(const char* name) : _name(name), _base(NULL), _top(NULL), _end(NULL), _is_packed(false) {} @@ -85,19 +87,7 @@ public: void print(size_t total_bytes) const; void print_out_of_space_msg(const char* failing_region, size_t needed_bytes); - void init(const ReservedSpace* rs, char* base) { - if (base == NULL) { - base = rs->base(); - } - assert(rs->contains(base), "must be"); - _base = _top = base; - _end = rs->end(); - } - void init(char* b, char* t, char* e) { - _base = b; - _top = t; - _end = e; - } + void init(ReservedSpace* rs, VirtualSpace* vs); void pack(DumpRegion* next = NULL); @@ -178,6 +168,8 @@ class MetaspaceShared : AllStatic { // CDS support static ReservedSpace _shared_rs; static VirtualSpace _shared_vs; + static ReservedSpace _symbol_rs; + static VirtualSpace _symbol_vs; static int _max_alignment; static MetaspaceSharedStats _stats; static bool _has_error_classes; @@ -222,11 +214,15 @@ class MetaspaceShared : AllStatic { NOT_CDS(return NULL); } + static Symbol* symbol_rs_base() { + return (Symbol*)_symbol_rs.base(); + } + static void set_shared_rs(ReservedSpace rs) { CDS_ONLY(_shared_rs = rs); } - static void commit_shared_space_to(char* newtop) NOT_CDS_RETURN; + static void commit_to(ReservedSpace* rs, VirtualSpace* vs, char* newtop) NOT_CDS_RETURN; static void initialize_dumptime_shared_and_meta_spaces() NOT_CDS_RETURN; static void initialize_runtime_shared_and_meta_spaces() NOT_CDS_RETURN; static void post_initialize(TRAPS) NOT_CDS_RETURN; @@ -302,7 +298,7 @@ class MetaspaceShared : AllStatic { #if INCLUDE_CDS static ReservedSpace reserve_shared_space(size_t size, char* requested_address = NULL); static size_t reserved_space_alignment(); - static void init_shared_dump_space(DumpRegion* first_space, address first_space_bottom = NULL); + static void init_shared_dump_space(DumpRegion* first_space); static DumpRegion* misc_code_dump_space(); static DumpRegion* read_write_dump_space(); static DumpRegion* read_only_dump_space(); @@ -312,7 +308,10 @@ class MetaspaceShared : AllStatic { static void rewrite_nofast_bytecodes_and_calculate_fingerprints(Thread* thread, InstanceKlass* ik); #endif - // Allocate a block of memory from the "mc", "ro", or "rw" regions. + // Allocate a block of memory from the temporary "symbol" region. + static char* symbol_space_alloc(size_t num_bytes); + + // Allocate a block of memory from the "mc" or "ro" regions. static char* misc_code_space_alloc(size_t num_bytes); static char* read_only_space_alloc(size_t num_bytes); diff --git a/src/hotspot/share/oops/instanceKlass.cpp b/src/hotspot/share/oops/instanceKlass.cpp index 6fabc30001d..a6b0b87d61a 100644 --- a/src/hotspot/share/oops/instanceKlass.cpp +++ b/src/hotspot/share/oops/instanceKlass.cpp @@ -505,10 +505,6 @@ InstanceKlass::InstanceKlass(const ClassFileParser& parser, unsigned kind, Klass assert(is_instance_klass(), "is layout incorrect?"); assert(size_helper() == parser.layout_size(), "incorrect size_helper?"); - if (Arguments::is_dumping_archive()) { - SystemDictionaryShared::init_dumptime_info(this); - } - // Set biased locking bit for all instances of this class; it will be // cleared if revocation occurs too often for this type if (UseBiasedLocking && BiasedLocking::enabled()) { diff --git a/src/hotspot/share/oops/klass.cpp b/src/hotspot/share/oops/klass.cpp index 5f67159e8e2..8d093a2d76d 100644 --- a/src/hotspot/share/oops/klass.cpp +++ b/src/hotspot/share/oops/klass.cpp @@ -29,6 +29,7 @@ #include "classfile/javaClasses.hpp" #include "classfile/moduleEntry.hpp" #include "classfile/systemDictionary.hpp" +#include "classfile/systemDictionaryShared.hpp" #include "classfile/vmSymbols.hpp" #include "gc/shared/collectedHeap.inline.hpp" #include "logging/log.hpp" @@ -79,6 +80,10 @@ void Klass::set_is_cloneable() { void Klass::set_name(Symbol* n) { _name = n; if (_name != NULL) _name->increment_refcount(); + + if (Arguments::is_dumping_archive() && is_instance_klass()) { + SystemDictionaryShared::init_dumptime_info(InstanceKlass::cast(this)); + } } bool Klass::is_subclass_of(const Klass* k) const { diff --git a/src/hotspot/share/oops/symbol.cpp b/src/hotspot/share/oops/symbol.cpp index 356d9bdf3b0..4b13cb11b2f 100644 --- a/src/hotspot/share/oops/symbol.cpp +++ b/src/hotspot/share/oops/symbol.cpp @@ -30,6 +30,7 @@ #include "logging/log.hpp" #include "logging/logStream.hpp" #include "memory/allocation.inline.hpp" +#include "memory/metaspaceShared.hpp" #include "memory/resourceArea.hpp" #include "memory/universe.hpp" #include "oops/symbol.hpp" @@ -56,6 +57,20 @@ Symbol::Symbol(const u1* name, int length, int refcount) { } void* Symbol::operator new(size_t sz, int len) throw() { + if (DumpSharedSpaces) { + // To get deterministic output from -Xshare:dump, we ensure that Symbols are allocated in + // increasing addresses. When the symbols are copied into the archive, we preserve their + // relative address order (see SortedSymbolClosure in metaspaceShared.cpp) + // + // We cannot use arena because arena chunks are allocated by the OS. As a result, for example, + // the archived symbol of "java/lang/Object" may sometimes be lower than "java/lang/String", and + // sometimes be higher. This would cause non-deterministic contents in the archive. + DEBUG_ONLY(static void* last = 0); + void* p = (void*)MetaspaceShared::symbol_space_alloc(size(len)*wordSize); + assert(p > last, "must increase monotonically"); + DEBUG_ONLY(last = p); + return p; + } int alloc_size = size(len)*wordSize; address res = (address) AllocateHeap(alloc_size, mtSymbol); return res; @@ -72,11 +87,21 @@ void Symbol::operator delete(void *p) { FreeHeap(p); } +#if INCLUDE_CDS +void Symbol::update_identity_hash() { + // This is called at a safepoint during dumping of a static CDS archive. The caller should have + // called os::init_random() with a deterministic seed and then iterate all archived Symbols in + // a deterministic order. + assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint"); + _hash_and_refcount = pack_hash_and_refcount((short)os::random(), PERM_REFCOUNT); +} + void Symbol::set_permanent() { // This is called at a safepoint during dumping of a dynamic CDS archive. assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint"); _hash_and_refcount = pack_hash_and_refcount(extract_hash(_hash_and_refcount), PERM_REFCOUNT); } +#endif // ------------------------------------------------------------------ // Symbol::index_of diff --git a/src/hotspot/share/oops/symbol.hpp b/src/hotspot/share/oops/symbol.hpp index 789214f8696..18bc0ae387f 100644 --- a/src/hotspot/share/oops/symbol.hpp +++ b/src/hotspot/share/oops/symbol.hpp @@ -168,7 +168,8 @@ class Symbol : public MetaspaceObj { bool is_permanent() const { return (refcount() == PERM_REFCOUNT); } - void set_permanent(); + void update_identity_hash() NOT_CDS_RETURN; + void set_permanent() NOT_CDS_RETURN; void make_permanent(); // Function char_at() returns the Symbol's selected u1 byte as a char type. diff --git a/src/hotspot/share/prims/jvm.cpp b/src/hotspot/share/prims/jvm.cpp index ca52fef5ff1..600f58ef967 100644 --- a/src/hotspot/share/prims/jvm.cpp +++ b/src/hotspot/share/prims/jvm.cpp @@ -3733,6 +3733,29 @@ JVM_ENTRY(void, JVM_InitializeFromArchive(JNIEnv* env, jclass cls)) HeapShared::initialize_from_archived_subgraph(k); JVM_END +JVM_ENTRY_NO_ENV(jlong, JVM_GetRandomSeedForCDSDump()) + JVMWrapper("JVM_GetRandomSeedForCDSDump"); + if (DumpSharedSpaces) { + const char* release = Abstract_VM_Version::vm_release(); + const char* dbg_level = Abstract_VM_Version::jdk_debug_level(); + const char* version = VM_Version::internal_vm_info_string(); + jlong seed = (jlong)(java_lang_String::hash_code((const jbyte*)release, (int)strlen(release)) ^ + java_lang_String::hash_code((const jbyte*)dbg_level, (int)strlen(dbg_level)) ^ + java_lang_String::hash_code((const jbyte*)version, (int)strlen(version))); + seed += (jlong)Abstract_VM_Version::vm_major_version(); + seed += (jlong)Abstract_VM_Version::vm_minor_version(); + seed += (jlong)Abstract_VM_Version::vm_security_version(); + seed += (jlong)Abstract_VM_Version::vm_patch_version(); + if (seed == 0) { // don't let this ever be zero. + seed = 0x87654321; + } + log_debug(cds)("JVM_GetRandomSeedForCDSDump() = " JLONG_FORMAT, seed); + return seed; + } else { + return 0; + } +JVM_END + // Returns an array of all live Thread objects (VM internal JavaThreads, // jvmti agent threads, and JNI attaching threads are skipped) // See CR 6404306 regarding JNI attaching threads diff --git a/src/java.base/share/classes/java/util/ImmutableCollections.java b/src/java.base/share/classes/java/util/ImmutableCollections.java index 91fe4c6965d..ccf92e2f421 100644 --- a/src/java.base/share/classes/java/util/ImmutableCollections.java +++ b/src/java.base/share/classes/java/util/ImmutableCollections.java @@ -64,14 +64,22 @@ class ImmutableCollections { private static final boolean REVERSE; static { // to generate a reasonably random and well-mixed SALT, use an arbitrary - // value (a slice of pi), multiply with the System.nanoTime, then pick + // value (a slice of pi), multiply with a random seed, then pick // the mid 32-bits from the product. By picking a SALT value in the // [0 ... 0xFFFF_FFFFL == 2^32-1] range, we ensure that for any positive // int N, (SALT32L * N) >> 32 is a number in the [0 ... N-1] range. This // property will be used to avoid more expensive modulo-based // calculations. long color = 0x243F_6A88_85A3_08D3L; // slice of pi - long seed = System.nanoTime(); + + // When running with -Xshare:dump, the VM will supply a "random" seed that's + // derived from the JVM build/version, so can we generate the exact same + // CDS archive for the same JDK build. This makes it possible to verify the + // consistency of the JDK build. + long seed = VM.getRandomSeedForCDSDump(); + if (seed == 0) { + seed = System.nanoTime(); + } SALT32L = (int)((color * seed) >> 16) & 0xFFFF_FFFFL; // use the lowest bit to determine if we should reverse iteration REVERSE = (SALT32L & 1) == 0; diff --git a/src/java.base/share/classes/jdk/internal/misc/VM.java b/src/java.base/share/classes/jdk/internal/misc/VM.java index 4de92b3c60a..168706b7cb5 100644 --- a/src/java.base/share/classes/jdk/internal/misc/VM.java +++ b/src/java.base/share/classes/jdk/internal/misc/VM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -421,6 +421,8 @@ public class VM { */ public static native void initializeFromArchive(Class c); + public static native long getRandomSeedForCDSDump(); + /** * Provides access to information on buffer usage. */ diff --git a/src/java.base/share/native/libjava/VM.c b/src/java.base/share/native/libjava/VM.c index 3ef64cc9451..a4bd4b60cd3 100644 --- a/src/java.base/share/native/libjava/VM.c +++ b/src/java.base/share/native/libjava/VM.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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 @@ -61,3 +61,8 @@ Java_jdk_internal_misc_VM_initializeFromArchive(JNIEnv *env, jclass ignore, jclass c) { JVM_InitializeFromArchive(env, c); } + +JNIEXPORT jlong JNICALL +Java_jdk_internal_misc_VM_getRandomSeedForCDSDump(JNIEnv *env, jclass ignore) { + return JVM_GetRandomSeedForCDSDump(); +} diff --git a/test/hotspot/jtreg/TEST.groups b/test/hotspot/jtreg/TEST.groups index fe78b3b3bd3..bcd942aa21a 100644 --- a/test/hotspot/jtreg/TEST.groups +++ b/test/hotspot/jtreg/TEST.groups @@ -1,5 +1,5 @@ # -# Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2013, 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 @@ -348,7 +348,8 @@ hotspot_cds_relocation = \ runtime/modules/PatchModule/PatchModuleCDS.java \ runtime/modules/PatchModule/PatchModuleClassList.java \ runtime/NMT \ - serviceability/sa + serviceability/sa \ + -runtime/cds/DeterministicDump.java # A subset of AppCDS tests to be run in tier1 tier1_runtime_appcds = \ diff --git a/test/hotspot/jtreg/runtime/cds/DeterministicDump.java b/test/hotspot/jtreg/runtime/cds/DeterministicDump.java new file mode 100644 index 00000000000..4a7e7c40664 --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/DeterministicDump.java @@ -0,0 +1,113 @@ +/* + * 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 8241071 + * @summary The same JDK build should always generate the same archive file (no randomness). + * @requires vm.cds + * @library /test/lib + * @run driver DeterministicDump + */ + +import jdk.test.lib.cds.CDSTestUtils; +import jdk.test.lib.Platform; +import jdk.test.lib.process.ProcessTools; +import jdk.test.lib.process.OutputAnalyzer; +import java.io.FileInputStream; +import java.io.IOException; + +public class DeterministicDump { + public static void main(String[] args) throws Exception { + for (int c = 0; c < 2; c++) { // oop/klass compression + String sign = (c == 0) ? "+" : "-"; + String coop = "-XX:" + sign + "UseCompressedOops"; + String ckls = "-XX:" + sign + "UseCompressedClassPointers"; + + if (!Platform.is64bit()) { + coop = "-showversion"; // no-op + ckls = "-showversion"; // no-op + } + + for (int gc = 0; gc < 2; gc++) { // should we trigger GC during dump + for (int i = 0; i < 2; i++) { + String metaspaceSize = "-showversion"; // no-op + if (gc == 1 && i == 1) { + // This will cause GC to happen after we've allocated 1MB of metaspace objects + // while processing the built-in SharedClassListFile. + metaspaceSize = "-XX:MetaspaceSize=1M"; + } + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( + coop, ckls, metaspaceSize, + "-XX:SharedArchiveFile=SharedArchiveFile" + i + ".jsa", + "-Xshare:dump", "-Xlog:cds=debug"); + OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, "SharedArchiveFile" + i); + CDSTestUtils.checkDump(out); + } + compare("SharedArchiveFile0.jsa", "SharedArchiveFile1.jsa"); + } + } + } + + static void compare(String file0, String file1) throws Exception { + byte[] buff0 = new byte[4096]; + byte[] buff1 = new byte[4096]; + try (FileInputStream in0 = new FileInputStream(file0); + FileInputStream in1 = new FileInputStream(file1)) { + int total = 0; + while (true) { + int n0 = read(in0, buff0); + int n1 = read(in1, buff1); + if (n0 != n1) { + throw new RuntimeException("File contents (file sizes?) are different after " + total + " bytes; n0 = " + + n0 + ", n1 = " + n1); + } + if (n0 == 0) { + System.out.println("File contents are the same: " + total + " bytes"); + break; + } + for (int i = 0; i < n0; i++) { + byte b0 = buff0[i]; + byte b1 = buff1[i]; + if (b0 != b1) { + throw new RuntimeException("File content different at byte #" + (total + i) + ", b0 = " + b0 + ", b1 = " + b1); + } + } + total += n0; + } + } + } + + static int read(FileInputStream in, byte[] buff) throws IOException { + int total = 0; + while (total < buff.length) { + int n = in.read(buff, total, buff.length - total); + if (n <= 0) { + return total; + } + total += n; + } + + return total; + } +} diff --git a/test/hotspot/jtreg/runtime/cds/SpaceUtilizationCheck.java b/test/hotspot/jtreg/runtime/cds/SpaceUtilizationCheck.java index 187fb1f1ab9..470e0d690aa 100644 --- a/test/hotspot/jtreg/runtime/cds/SpaceUtilizationCheck.java +++ b/test/hotspot/jtreg/runtime/cds/SpaceUtilizationCheck.java @@ -43,6 +43,7 @@ import java.util.Hashtable; import java.lang.Integer; public class SpaceUtilizationCheck { + // For the MC/RW/RO regions: // [1] Each region must have strictly less than // WhiteBox.metaspaceReserveAlignment() bytes of unused space. // [2] There must be no gap between two consecutive regions. @@ -64,11 +65,21 @@ public class SpaceUtilizationCheck { opts.addSuffix(extra_options); OutputAnalyzer output = CDSTestUtils.createArchive(opts); CDSTestUtils.checkDump(output); - Pattern pattern = Pattern.compile("(..) *space: *([0-9]+).* out of *([0-9]+) bytes .* at 0x([0-9a0-f]+)"); + Pattern pattern = Pattern.compile("(..) space: *([0-9]+).* out of *([0-9]+) bytes .* at 0x([0-9a0-f]+)"); WhiteBox wb = WhiteBox.getWhiteBox(); long reserve_alignment = wb.metaspaceReserveAlignment(); System.out.println("Metaspace::reserve_alignment() = " + reserve_alignment); + // Look for output like this. The pattern will only match the first 3 regions, which is what we need to check + // + // [4.682s][debug][cds] mc space: 24912 [ 0.2% of total] out of 28672 bytes [ 86.9% used] at 0x0000000800000000 + // [4.682s][debug][cds] rw space: 4391632 [ 33.7% of total] out of 4395008 bytes [ 99.9% used] at 0x0000000800007000 + // [4.682s][debug][cds] ro space: 7570632 [ 58.0% of total] out of 7573504 bytes [100.0% used] at 0x0000000800438000 + // [4.682s][debug][cds] bm space: 213528 [ 1.6% of total] out of 213528 bytes [100.0% used] + // [4.682s][debug][cds] ca0 space: 507904 [ 3.9% of total] out of 507904 bytes [100.0% used] at 0x00000000fff00000 + // [4.682s][debug][cds] oa0 space: 327680 [ 2.5% of total] out of 327680 bytes [100.0% used] at 0x00000000ffe00000 + // [4.682s][debug][cds] total : 13036288 [100.0% of total] out of 13049856 bytes [ 99.9% used] + long last_region = -1; Hashtable checked = new Hashtable<>(); for (String line : output.getStdout().split("\n")) { @@ -76,13 +87,8 @@ public class SpaceUtilizationCheck { Matcher matcher = pattern.matcher(line); if (matcher.find()) { String name = matcher.group(1); - if (name.equals("bm")) { - // Bitmap space does not have a requested address. - break; - } else { - System.out.println("Checking " + name + " in : " + line); - checked.put(name, name); - } + System.out.println("Checking " + name + " in : " + line); + checked.put(name, name); long used = Long.parseLong(matcher.group(2)); long capacity = Long.parseLong(matcher.group(3)); long address = Long.parseLong(matcher.group(4), 16); From bc8065facdad7ecc05a3c30222d370d3cb6e71a4 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Tue, 5 May 2020 14:55:23 -0700 Subject: [PATCH 43/88] 8244485: runtime/cds/appcds/TestZGCWithCDS.java fails after 8244385 Reviewed-by: dcubed --- test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithCDS.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithCDS.java b/test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithCDS.java index 3c078619b5d..af0ad861b55 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithCDS.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithCDS.java @@ -26,6 +26,8 @@ * @requires vm.cds * @requires vm.bits == 64 * @requires vm.gc.Z + * @comment assuming that default GC supports both UseCompressedOops and UseCompressedClassPointers + * @requires vm.gc == null * @comment Graal does not support ZGC * @requires !vm.graal.enabled * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds From 0c0d485c378aed151670f95c192e933e8140fc44 Mon Sep 17 00:00:00 2001 From: Yumin Qi Date: Tue, 5 May 2020 15:40:18 -0700 Subject: [PATCH 44/88] 8237750: Load libzip.so only if necessary Libzip.so is unconditionally loaded even without usage. Fix by on demand loading. Reviewed-by: dlong, iklam, ccheung --- src/hotspot/share/classfile/classLoader.cpp | 14 ++++++++++++-- src/hotspot/share/classfile/classLoader.hpp | 5 +++++ src/hotspot/share/classfile/classLoader.inline.hpp | 8 +++++++- src/hotspot/share/runtime/mutexLocker.cpp | 2 ++ src/hotspot/share/runtime/mutexLocker.hpp | 1 + .../jtreg/serviceability/sa/ClhsdbPmap.java | 2 +- 6 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/hotspot/share/classfile/classLoader.cpp b/src/hotspot/share/classfile/classLoader.cpp index 9d465eb6746..a79db15c787 100644 --- a/src/hotspot/share/classfile/classLoader.cpp +++ b/src/hotspot/share/classfile/classLoader.cpp @@ -95,6 +95,7 @@ static FindEntry_t FindEntry = NULL; static ReadEntry_t ReadEntry = NULL; static GetNextEntry_t GetNextEntry = NULL; static Crc32_t Crc32 = NULL; +int ClassLoader::_libzip_loaded = 0; // Entry points for jimage.dll for loading jimage file entries @@ -747,6 +748,7 @@ ClassPathEntry* ClassLoader::create_class_path_entry(const char *path, const str // enable call to C land ThreadToNativeFromVM ttn(thread); HandleMark hm(thread); + load_zip_library_if_needed(); zip = (*ZipOpen)(canonical_path, &error_msg); } if (zip != NULL && error_msg == NULL) { @@ -796,6 +798,7 @@ ClassPathZipEntry* ClassLoader::create_class_path_zip_entry(const char *path, bo JavaThread* thread = JavaThread::current(); ThreadToNativeFromVM ttn(thread); HandleMark hm(thread); + load_zip_library_if_needed(); zip = (*ZipOpen)(canonical_path, &error_msg); } if (zip != NULL && error_msg == NULL) { @@ -967,6 +970,14 @@ void ClassLoader::load_java_library() { CanonicalizeEntry = CAST_TO_FN_PTR(canonicalize_fn_t, dll_lookup(javalib_handle, "JDK_Canonicalize", NULL)); } +void ClassLoader::release_load_zip_library() { + MutexLocker locker(Zip_lock, Monitor::_no_safepoint_check_flag); + if (_libzip_loaded == 0) { + load_zip_library(); + Atomic::release_store(&_libzip_loaded, 1); + } +} + void ClassLoader::load_zip_library() { assert(ZipOpen == NULL, "should not load zip library twice"); char path[JVM_MAXPATHLEN]; @@ -1008,6 +1019,7 @@ void ClassLoader::load_jimage_library() { } int ClassLoader::crc32(int crc, const char* buf, int len) { + load_zip_library_if_needed(); return (*Crc32)(crc, (const jbyte*)buf, len); } @@ -1466,8 +1478,6 @@ void ClassLoader::initialize() { // lookup java library entry points load_java_library(); - // lookup zip library entry points - load_zip_library(); // jimage library entry points are loaded below, in lookup_vm_options setup_bootstrap_search_path(); } diff --git a/src/hotspot/share/classfile/classLoader.hpp b/src/hotspot/share/classfile/classLoader.hpp index 849e10d907a..e314dba35e8 100644 --- a/src/hotspot/share/classfile/classLoader.hpp +++ b/src/hotspot/share/classfile/classLoader.hpp @@ -252,6 +252,11 @@ class ClassLoader: AllStatic { static void load_zip_library(); static void load_jimage_library(); + private: + static int _libzip_loaded; // used to sync loading zip. + static void release_load_zip_library(); + static inline void load_zip_library_if_needed(); + public: static ClassPathEntry* create_class_path_entry(const char *path, const struct stat* st, bool throw_exception, diff --git a/src/hotspot/share/classfile/classLoader.inline.hpp b/src/hotspot/share/classfile/classLoader.inline.hpp index 7cca7e16952..3cfa9e78ea7 100644 --- a/src/hotspot/share/classfile/classLoader.inline.hpp +++ b/src/hotspot/share/classfile/classLoader.inline.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -56,6 +56,12 @@ inline ClassPathEntry* ClassLoader::classpath_entry(int n) { } } +inline void ClassLoader::load_zip_library_if_needed() { + if (Atomic::load_acquire(&_libzip_loaded) == 0) { + release_load_zip_library(); + } +} + #if INCLUDE_CDS // Helper function used by CDS code to get the number of boot classpath diff --git a/src/hotspot/share/runtime/mutexLocker.cpp b/src/hotspot/share/runtime/mutexLocker.cpp index 0f084ab4750..c84b9ed1a1a 100644 --- a/src/hotspot/share/runtime/mutexLocker.cpp +++ b/src/hotspot/share/runtime/mutexLocker.cpp @@ -120,6 +120,7 @@ Monitor* Notification_lock = NULL; Monitor* PeriodicTask_lock = NULL; Monitor* RedefineClasses_lock = NULL; Mutex* Verify_lock = NULL; +Monitor* Zip_lock = NULL; #if INCLUDE_JFR Mutex* JfrStacktrace_lock = NULL; @@ -309,6 +310,7 @@ void mutex_init() { def(PeriodicTask_lock , PaddedMonitor, nonleaf+5, true, _safepoint_check_always); def(RedefineClasses_lock , PaddedMonitor, nonleaf+5, true, _safepoint_check_always); def(Verify_lock , PaddedMutex, nonleaf+5, true, _safepoint_check_always); + def(Zip_lock , PaddedMonitor, leaf, true, _safepoint_check_never); if (WhiteBoxAPI) { def(Compilation_lock , PaddedMonitor, leaf, false, _safepoint_check_never); diff --git a/src/hotspot/share/runtime/mutexLocker.hpp b/src/hotspot/share/runtime/mutexLocker.hpp index f618beb9962..33dfa5b52ff 100644 --- a/src/hotspot/share/runtime/mutexLocker.hpp +++ b/src/hotspot/share/runtime/mutexLocker.hpp @@ -115,6 +115,7 @@ extern Monitor* Notification_lock; // a lock used for notification extern Monitor* PeriodicTask_lock; // protects the periodic task structure extern Monitor* RedefineClasses_lock; // locks classes from parallel redefinition extern Mutex* Verify_lock; // synchronize initialization of verify library +extern Monitor* Zip_lock; // synchronize initialization of zip library extern Monitor* ThreadsSMRDelete_lock; // Used by ThreadsSMRSupport to take pressure off the Threads_lock extern Mutex* ThreadIdTableCreate_lock; // Used by ThreadIdTable to lazily create the thread id table extern Mutex* SharedDecoder_lock; // serializes access to the decoder during normal (not error reporting) use diff --git a/test/hotspot/jtreg/serviceability/sa/ClhsdbPmap.java b/test/hotspot/jtreg/serviceability/sa/ClhsdbPmap.java index 18c6aa9d32b..c7db967eef5 100644 --- a/test/hotspot/jtreg/serviceability/sa/ClhsdbPmap.java +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbPmap.java @@ -57,7 +57,7 @@ public class ClhsdbPmap { List.of("Not available on Mac OS X")); } else { expStrMap.put("pmap", - List.of("jvm", "java", "net", "nio", "jimage", "zip")); + List.of("jvm", "java", "net", "nio", "jimage")); } test.run(theApp.getPid(), cmds, expStrMap, null); From 317bd88e33a91fc2258b81af6df2faf7c04f9892 Mon Sep 17 00:00:00 2001 From: Jie Fu Date: Wed, 6 May 2020 09:00:30 +0800 Subject: [PATCH 45/88] 8244489: Zero and minimal VM build failure after JDK-8241071 (MetaspaceShared::symbol_space_alloc is undefined) Reviewed-by: dholmes --- src/hotspot/share/oops/symbol.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hotspot/share/oops/symbol.cpp b/src/hotspot/share/oops/symbol.cpp index 4b13cb11b2f..bcd9771c494 100644 --- a/src/hotspot/share/oops/symbol.cpp +++ b/src/hotspot/share/oops/symbol.cpp @@ -57,6 +57,7 @@ Symbol::Symbol(const u1* name, int length, int refcount) { } void* Symbol::operator new(size_t sz, int len) throw() { +#if INCLUDE_CDS if (DumpSharedSpaces) { // To get deterministic output from -Xshare:dump, we ensure that Symbols are allocated in // increasing addresses. When the symbols are copied into the archive, we preserve their @@ -71,6 +72,7 @@ void* Symbol::operator new(size_t sz, int len) throw() { DEBUG_ONLY(last = p); return p; } +#endif int alloc_size = size(len)*wordSize; address res = (address) AllocateHeap(alloc_size, mtSymbol); return res; From 7ae3bea21285185c29abb83084930a8f30587c7a Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Tue, 5 May 2020 22:34:54 -0400 Subject: [PATCH 46/88] 8243961: ForceNUMA and only one available NUMA node fails assertion on Windows Improve ergnomics for UseNUMA and UseNUMAInterleaving Reviewed-by: tschatzl, sjohanss --- src/hotspot/os/aix/os_aix.cpp | 7 +++---- src/hotspot/os/bsd/os_bsd.cpp | 4 ++++ src/hotspot/os/linux/os_linux.cpp | 10 ++++++++-- src/hotspot/os/solaris/os_solaris.cpp | 7 ++++++- src/hotspot/os/windows/os_windows.cpp | 11 +++++++---- src/hotspot/share/runtime/arguments.cpp | 8 -------- 6 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/hotspot/os/aix/os_aix.cpp b/src/hotspot/os/aix/os_aix.cpp index 293a0eb3179..1c460ce2e8f 100644 --- a/src/hotspot/os/aix/os_aix.cpp +++ b/src/hotspot/os/aix/os_aix.cpp @@ -3549,10 +3549,9 @@ jint os::init_2(void) { return JNI_ERR; } - if (UseNUMA) { - UseNUMA = false; - warning("NUMA optimizations are not available on this OS."); - } + // Not supported. + FLAG_SET_ERGO(UseNUMA, false); + FLAG_SET_ERGO(UseNUMAInterleaving, false); if (MaxFDLimit) { // Set the number of file descriptors to max. print out error diff --git a/src/hotspot/os/bsd/os_bsd.cpp b/src/hotspot/os/bsd/os_bsd.cpp index 64e34170719..0e190e736de 100644 --- a/src/hotspot/os/bsd/os_bsd.cpp +++ b/src/hotspot/os/bsd/os_bsd.cpp @@ -3140,6 +3140,10 @@ jint os::init_2(void) { return JNI_ERR; } + // Not supported. + FLAG_SET_ERGO(UseNUMA, false); + FLAG_SET_ERGO(UseNUMAInterleaving, false); + if (MaxFDLimit) { // set the number of file descriptors to max. print out error // if getrlimit/setrlimit fails but continue regardless. diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index 2a9f5182024..dd791970163 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -5175,7 +5175,8 @@ void os::Linux::numa_init() { // bitmask when externally configured to run on all or fewer nodes. if (!Linux::libnuma_init()) { - UseNUMA = false; + FLAG_SET_ERGO(UseNUMA, false); + FLAG_SET_ERGO(UseNUMAInterleaving, false); // Also depends on libnuma. } else { if ((Linux::numa_max_node() < 1) || Linux::is_bound_to_single_node()) { // If there's only one node (they start from 0) or if the process @@ -5208,6 +5209,11 @@ void os::Linux::numa_init() { } } + // When NUMA requested, not-NUMA-aware allocations default to interleaving. + if (UseNUMA && !UseNUMAInterleaving) { + FLAG_SET_ERGO_IF_DEFAULT(UseNUMAInterleaving, true); + } + if (UseParallelGC && UseNUMA && UseLargePages && !can_commit_large_page_memory()) { // With SHM and HugeTLBFS large pages we cannot uncommit a page, so there's no way // we can make the adaptive lgrp chunk resizing work. If the user specified both @@ -5272,7 +5278,7 @@ jint os::init_2(void) { log_info(os)("HotSpot is running with %s, %s", Linux::glibc_version(), Linux::libpthread_version()); - if (UseNUMA) { + if (UseNUMA || UseNUMAInterleaving) { Linux::numa_init(); } diff --git a/src/hotspot/os/solaris/os_solaris.cpp b/src/hotspot/os/solaris/os_solaris.cpp index 98671360d65..5b2a1a6cba2 100644 --- a/src/hotspot/os/solaris/os_solaris.cpp +++ b/src/hotspot/os/solaris/os_solaris.cpp @@ -3916,7 +3916,7 @@ jint os::init_2(void) { if (UseNUMA) { if (!Solaris::liblgrp_init()) { - UseNUMA = false; + FLAG_SET_ERGO(UseNUMA, false); } else { size_t lgrp_limit = os::numa_get_groups_num(); int *lgrp_ids = NEW_C_HEAP_ARRAY(int, lgrp_limit, mtInternal); @@ -3930,6 +3930,11 @@ jint os::init_2(void) { } } + // When NUMA requested, not-NUMA-aware allocations default to interleaving. + if (UseNUMA && !UseNUMAInterleaving) { + FLAG_SET_ERGO_IF_DEFAULT(UseNUMAInterleaving, true); + } + Solaris::signal_sets_init(); Solaris::init_signal_mem(); Solaris::install_signal_handlers(); diff --git a/src/hotspot/os/windows/os_windows.cpp b/src/hotspot/os/windows/os_windows.cpp index de35f16da82..5abb1ad039a 100644 --- a/src/hotspot/os/windows/os_windows.cpp +++ b/src/hotspot/os/windows/os_windows.cpp @@ -4096,10 +4096,13 @@ jint os::init_2(void) { UseNUMA = false; // We don't fully support this yet } - if (UseNUMAInterleaving) { - // first check whether this Windows OS supports VirtualAllocExNuma, if not ignore this flag - bool success = numa_interleaving_init(); - if (!success) UseNUMAInterleaving = false; + if (UseNUMAInterleaving || (UseNUMA && FLAG_IS_DEFAULT(UseNUMAInterleaving))) { + if (!numa_interleaving_init()) { + FLAG_SET_ERGO(UseNUMAInterleaving, false); + } else if (!UseNUMAInterleaving) { + // When NUMA requested, not-NUMA-aware allocations default to interleaving. + FLAG_SET_ERGO(UseNUMAInterleaving, true); + } } if (initSock() != JNI_OK) { diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index d70ebeffc30..fb92c365f18 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -4158,14 +4158,6 @@ jint Arguments::adjust_after_os() { FLAG_SET_DEFAULT(MinHeapDeltaBytes, 64*M); } } - // UseNUMAInterleaving is set to ON for all collectors and platforms when - // UseNUMA is set to ON. NUMA-aware collectors will interleave old gen and - // survivor spaces on top of NUMA allocation policy for the eden space. - // Non NUMA-aware collectors will interleave all of the heap spaces across - // NUMA nodes. - if (FLAG_IS_DEFAULT(UseNUMAInterleaving)) { - FLAG_SET_ERGO(UseNUMAInterleaving, true); - } } return JNI_OK; } From 98d41015ca58f52e8e0603465cb546d3ec2468f2 Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Wed, 6 May 2020 00:28:12 -0400 Subject: [PATCH 47/88] 8244307: Improve assertions against taskqueue underflow Added assert_not_underflow. Reviewed-by: tschatzl, sjohanss --- src/hotspot/share/gc/shared/taskqueue.hpp | 19 ++++++++++++++++--- .../share/gc/shared/taskqueue.inline.hpp | 10 +++++----- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/hotspot/share/gc/shared/taskqueue.hpp b/src/hotspot/share/gc/shared/taskqueue.hpp index 876138dfcbc..9b88180bc92 100644 --- a/src/hotspot/share/gc/shared/taskqueue.hpp +++ b/src/hotspot/share/gc/shared/taskqueue.hpp @@ -202,12 +202,24 @@ protected: // threads attempting to perform the pop_global will all perform the same // CAS, and only one can succeed.) Any stealing thread that reads after // either the increment or decrement will see an empty queue, and will not - // join the competitors. The "sz == -1 || sz == N-1" state will not be - // modified by concurrent queues, so the owner thread can reset the state to - // _bottom == top so subsequent pushes will be performed normally. + // join the competitors. The "sz == -1" / "sz == N-1" state will not be + // modified by concurrent threads, so the owner thread can reset the state + // to _bottom == top so subsequent pushes will be performed normally. return (sz == N - 1) ? 0 : sz; } + // Assert that we're not in the underflow state where bottom has + // been decremented past top, so that _bottom+1 mod N == top. See + // the discussion in clean_size. + + void assert_not_underflow(uint bot, uint top) const { + assert_not_underflow(dirty_size(bot, top)); + } + + void assert_not_underflow(uint dirty_size) const { + assert(dirty_size != N - 1, "invariant"); + } + private: DEFINE_PAD_MINUS_SIZE(0, DEFAULT_CACHE_LINE_SIZE, 0); @@ -313,6 +325,7 @@ protected: using TaskQueueSuper::decrement_index; using TaskQueueSuper::dirty_size; using TaskQueueSuper::clean_size; + using TaskQueueSuper::assert_not_underflow; public: using TaskQueueSuper::max_elems; diff --git a/src/hotspot/share/gc/shared/taskqueue.inline.hpp b/src/hotspot/share/gc/shared/taskqueue.inline.hpp index 395b68cd65d..3e377a7a7a9 100644 --- a/src/hotspot/share/gc/shared/taskqueue.inline.hpp +++ b/src/hotspot/share/gc/shared/taskqueue.inline.hpp @@ -123,7 +123,7 @@ bool GenericTaskQueue::pop_local_slow(uint localBot, Age oldAge) { Age tempAge = cmpxchg_age(oldAge, newAge); if (tempAge == oldAge) { // We win. - assert(dirty_size(localBot, age_top_relaxed()) != N - 1, "sanity"); + assert_not_underflow(localBot, age_top_relaxed()); TASKQUEUE_STATS_ONLY(stats.record_pop_slow()); return true; } @@ -132,7 +132,7 @@ bool GenericTaskQueue::pop_local_slow(uint localBot, Age oldAge) { // and top is greater than bottom. Fix this representation of the empty queue // to become the canonical one. set_age_relaxed(newAge); - assert(dirty_size(localBot, age_top_relaxed()) != N - 1, "sanity"); + assert_not_underflow(localBot, age_top_relaxed()); return false; } @@ -144,7 +144,7 @@ GenericTaskQueue::pop_local(E& t, uint threshold) { // resets the size to 0 before the next call (which is sequential, // since this is pop_local.) uint dirty_n_elems = dirty_size(localBot, age_top_relaxed()); - assert(dirty_n_elems != N - 1, "Shouldn't be possible..."); + assert_not_underflow(dirty_n_elems); if (dirty_n_elems <= threshold) return false; localBot = decrement_index(localBot); set_bottom_relaxed(localBot); @@ -158,7 +158,7 @@ GenericTaskQueue::pop_local(E& t, uint threshold) { // a "pop_global" operation, and we're done. idx_t tp = age_top_relaxed(); if (clean_size(localBot, tp) > 0) { - assert(dirty_size(localBot, tp) != N - 1, "sanity"); + assert_not_underflow(localBot, tp); TASKQUEUE_STATS_ONLY(stats.record_pop()); return true; } else { @@ -241,7 +241,7 @@ bool GenericTaskQueue::pop_global(E& t) { // Note that using "bottom" here might fail, since a pop_local might // have decremented it. - assert(dirty_size(localBot, newAge.top()) != N - 1, "sanity"); + assert_not_underflow(localBot, newAge.top()); return resAge == oldAge; } From 611fda672f29721f5c56754450e78d69d701ff2a Mon Sep 17 00:00:00 2001 From: Jie Fu Date: Wed, 6 May 2020 13:41:11 +0800 Subject: [PATCH 48/88] 8244497: [TESTBUG] Incompatible types conversion error in vmTestbase/vm/runtime/defmeth/StressTest.java after JDK-8243432 Reviewed-by: dholmes --- .../hotspot/jtreg/vmTestbase/vm/runtime/defmeth/StressTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/StressTest.java b/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/StressTest.java index a12dcba649d..1b8eb98be43 100644 --- a/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/StressTest.java +++ b/test/hotspot/jtreg/vmTestbase/vm/runtime/defmeth/StressTest.java @@ -55,7 +55,7 @@ public class StressTest implements Runnable { private StressOptions opts = new StressOptions(); @Option(name="seed", default_value="0", description="force deterministic behavior") - private int seed; + private long seed; @Option(name="redefine", default_value="false", description="use scenarios w/ class redefinition") private boolean doRedefine; From 5b066096a4f4d3b5f7343f88167fbdeffd7a4c59 Mon Sep 17 00:00:00 2001 From: Kim Barrett Date: Wed, 6 May 2020 00:23:51 -0400 Subject: [PATCH 49/88] 8243325: Cleanup TaskQueueSuper<>::peek Replaced uses of peek with new assert_empty. Reviewed-by: tschatzl, sjohanss --- .../share/gc/shared/taskTerminator.cpp | 20 +++++++------- .../share/gc/shared/taskTerminator.hpp | 5 ++-- src/hotspot/share/gc/shared/taskqueue.hpp | 26 ++++++++++--------- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/hotspot/share/gc/shared/taskTerminator.cpp b/src/hotspot/share/gc/shared/taskTerminator.cpp index b3afb19bfa1..3b896896470 100644 --- a/src/hotspot/share/gc/shared/taskTerminator.cpp +++ b/src/hotspot/share/gc/shared/taskTerminator.cpp @@ -39,8 +39,10 @@ TaskTerminator::TaskTerminator(uint n_threads, TaskQueueSetSuper* queue_set) : } TaskTerminator::~TaskTerminator() { - assert(_offered_termination == 0 || !peek_in_queue_set(), "Precondition"); - assert(_offered_termination == 0 || _offered_termination == _n_threads, "Terminated or aborted" ); + if (_offered_termination != 0) { + assert(_offered_termination == _n_threads, "Must be terminated or aborted"); + assert_queue_set_empty(); + } assert(_spin_master == NULL, "Should have been reset"); assert(_blocker != NULL, "Can not be NULL"); @@ -48,8 +50,8 @@ TaskTerminator::~TaskTerminator() { } #ifdef ASSERT -bool TaskTerminator::peek_in_queue_set() { - return _queue_set->peek(); +void TaskTerminator::assert_queue_set_empty() const { + _queue_set->assert_empty(); } #endif @@ -87,7 +89,7 @@ bool TaskTerminator::offer_termination(TerminatorTerminator* terminator) { // Single worker, done if (_n_threads == 1) { _offered_termination = 1; - assert(!peek_in_queue_set(), "Precondition"); + assert_queue_set_empty(); return true; } @@ -97,7 +99,7 @@ bool TaskTerminator::offer_termination(TerminatorTerminator* terminator) { if (_offered_termination == _n_threads) { _blocker->notify_all(); _blocker->unlock(); - assert(!peek_in_queue_set(), "Precondition"); + assert_queue_set_empty(); return true; } @@ -110,7 +112,7 @@ bool TaskTerminator::offer_termination(TerminatorTerminator* terminator) { if (do_spin_master_work(terminator)) { assert(_offered_termination == _n_threads, "termination condition"); - assert(!peek_in_queue_set(), "Precondition"); + assert_queue_set_empty(); return true; } else { _blocker->lock_without_safepoint_check(); @@ -118,7 +120,7 @@ bool TaskTerminator::offer_termination(TerminatorTerminator* terminator) { // before returning from do_spin_master_work() and acquiring lock above. if (_offered_termination == _n_threads) { _blocker->unlock(); - assert(!peek_in_queue_set(), "Precondition"); + assert_queue_set_empty(); return true; } } @@ -127,7 +129,7 @@ bool TaskTerminator::offer_termination(TerminatorTerminator* terminator) { if (_offered_termination == _n_threads) { _blocker->unlock(); - assert(!peek_in_queue_set(), "Precondition"); + assert_queue_set_empty(); return true; } } diff --git a/src/hotspot/share/gc/shared/taskTerminator.hpp b/src/hotspot/share/gc/shared/taskTerminator.hpp index 83e006285b5..8823797e6aa 100644 --- a/src/hotspot/share/gc/shared/taskTerminator.hpp +++ b/src/hotspot/share/gc/shared/taskTerminator.hpp @@ -57,9 +57,8 @@ class TaskTerminator : public CHeapObj { volatile uint _offered_termination; DEFINE_PAD_MINUS_SIZE(1, DEFAULT_CACHE_LINE_SIZE, sizeof(volatile uint)); -#ifdef ASSERT - bool peek_in_queue_set(); -#endif + void assert_queue_set_empty() const NOT_DEBUG_RETURN; + void yield(); Monitor* _blocker; diff --git a/src/hotspot/share/gc/shared/taskqueue.hpp b/src/hotspot/share/gc/shared/taskqueue.hpp index 9b88180bc92..7a6896384fa 100644 --- a/src/hotspot/share/gc/shared/taskqueue.hpp +++ b/src/hotspot/share/gc/shared/taskqueue.hpp @@ -240,10 +240,10 @@ private: public: TaskQueueSuper() : _bottom(0), _age() {} - // Return true if the TaskQueue contains any tasks. + // Assert the queue is empty. // Unreliable if there are concurrent pushes or pops. - bool peek() const { - return bottom_relaxed() != age_top_relaxed(); + void assert_empty() const { + assert(bottom_relaxed() == age_top_relaxed(), "not empty"); } bool is_empty() const { @@ -439,8 +439,10 @@ private: class TaskQueueSetSuper { public: - // Returns "true" if some TaskQueue in the set contains a task. - virtual bool peek() = 0; + // Assert all queues in the set are empty. + NOT_DEBUG(void assert_empty() const {}) + DEBUG_ONLY(virtual void assert_empty() const = 0;) + // Tasks in queue virtual uint tasks() const = 0; }; @@ -471,8 +473,9 @@ public: // Returns if stealing succeeds, and sets "t" to the stolen task. bool steal(uint queue_num, E& t); - bool peek(); - uint tasks() const; + DEBUG_ONLY(virtual void assert_empty() const;) + + virtual uint tasks() const; uint size() const { return _n; } }; @@ -488,15 +491,14 @@ GenericTaskQueueSet::queue(uint i) { return _queues[i]; } +#ifdef ASSERT template -bool GenericTaskQueueSet::peek() { - // Try all the queues. +void GenericTaskQueueSet::assert_empty() const { for (uint j = 0; j < _n; j++) { - if (_queues[j]->peek()) - return true; + _queues[j]->assert_empty(); } - return false; } +#endif // ASSERT template uint GenericTaskQueueSet::tasks() const { From a3443d0fd1de170f6811968cc0e9eac314b4bcd4 Mon Sep 17 00:00:00 2001 From: Michael Zucchi Date: Mon, 27 Apr 2020 11:00:29 +0200 Subject: [PATCH 50/88] 8243656: Shell built-in test in configure depends on help Help might not be available to check for built-ins: Use 'command -v' instead Reviewed-by: erikj --- make/autoconf/util.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/autoconf/util.m4 b/make/autoconf/util.m4 index 432abd81673..8b775db241d 100644 --- a/make/autoconf/util.m4 +++ b/make/autoconf/util.m4 @@ -573,7 +573,7 @@ AC_DEFUN([UTIL_REQUIRE_BUILTIN_PROGS], UTIL_SETUP_TOOL($1, [AC_PATH_PROGS($1, $2, , $3)]) if test "x[$]$1" = x; then AC_MSG_NOTICE([Required tool $2 not found in PATH, checking built-in]) - if help $2 > /dev/null 2>&1; then + if command -v $2 > /dev/null 2>&1; then AC_MSG_NOTICE([Found $2 as shell built-in. Using it]) $1="$2" else From ca371c95368b1383868e483bb678abaed69c7e3f Mon Sep 17 00:00:00 2001 From: Erik Gahlin Date: Wed, 6 May 2020 13:31:00 +0200 Subject: [PATCH 51/88] 8244463: JFR: Clean up jdk.jfr.internal.RepositoryChunk Reviewed-by: jbachorik, mgronlun --- .../jdk/jfr/internal/PlatformRecorder.java | 25 +++++---- .../classes/jdk/jfr/internal/Repository.java | 9 +-- .../jdk/jfr/internal/RepositoryChunk.java | 56 ++++++------------- .../share/classes/jdk/jfr/internal/Utils.java | 26 ++++++++- 4 files changed, 60 insertions(+), 56 deletions(-) diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java index 2ddd96e00ce..7f1f25d61d5 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/PlatformRecorder.java @@ -36,6 +36,7 @@ import java.security.AccessControlContext; import java.security.AccessController; import java.time.Duration; import java.time.Instant; +import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -219,7 +220,8 @@ public final class PlatformRecorder { synchronized long start(PlatformRecording recording) { // State can only be NEW or DELAYED because of previous checks - Instant now = Instant.now(); + ZonedDateTime zdtNow = ZonedDateTime.now(); + Instant now = zdtNow.toInstant(); recording.setStartTime(now); recording.updateTimer(); Duration duration = recording.getDuration(); @@ -242,8 +244,8 @@ public final class PlatformRecorder { if (beginPhysical) { RepositoryChunk newChunk = null; if (toDisk) { - newChunk = repository.newChunk(now); - MetadataRepository.getInstance().setOutput(newChunk.getUnfinishedFile().toString()); + newChunk = repository.newChunk(zdtNow); + MetadataRepository.getInstance().setOutput(newChunk.getFile().toString()); } else { MetadataRepository.getInstance().setOutput(null); } @@ -256,9 +258,9 @@ public final class PlatformRecorder { } else { RepositoryChunk newChunk = null; if (toDisk) { - newChunk = repository.newChunk(now); + newChunk = repository.newChunk(zdtNow); RequestEngine.doChunkEnd(); - MetadataRepository.getInstance().setOutput(newChunk.getUnfinishedFile().toString()); + MetadataRepository.getInstance().setOutput(newChunk.getFile().toString()); startNanos = jvm.getChunkStartNanos(); } recording.setState(RecordingState.RUNNING); @@ -286,7 +288,8 @@ public final class PlatformRecorder { if (Utils.isBefore(state, RecordingState.RUNNING)) { throw new IllegalStateException("Recording must be started before it can be stopped."); } - Instant now = Instant.now(); + ZonedDateTime zdtNow = ZonedDateTime.now(); + Instant now = zdtNow.toInstant(); boolean toDisk = false; boolean endPhysical = true; long streamInterval = Long.MAX_VALUE; @@ -325,8 +328,8 @@ public final class PlatformRecorder { RequestEngine.doChunkEnd(); updateSettingsButIgnoreRecording(recording); if (toDisk) { - newChunk = repository.newChunk(now); - MetadataRepository.getInstance().setOutput(newChunk.getUnfinishedFile().toString()); + newChunk = repository.newChunk(zdtNow); + MetadataRepository.getInstance().setOutput(newChunk.getFile().toString()); } else { MetadataRepository.getInstance().setOutput(null); } @@ -375,13 +378,13 @@ public final class PlatformRecorder { synchronized void rotateDisk() { - Instant now = Instant.now(); + ZonedDateTime now = ZonedDateTime.now(); RepositoryChunk newChunk = repository.newChunk(now); RequestEngine.doChunkEnd(); - MetadataRepository.getInstance().setOutput(newChunk.getUnfinishedFile().toString()); + MetadataRepository.getInstance().setOutput(newChunk.getFile().toString()); writeMetaEvents(); if (currentChunk != null) { - finishChunk(currentChunk, now, null); + finishChunk(currentChunk, now.toInstant(), null); } currentChunk = newChunk; RequestEngine.doChunkBegin(); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/Repository.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/Repository.java index f170be10094..c33693db0eb 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/Repository.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/Repository.java @@ -27,9 +27,8 @@ package jdk.jfr.internal; import java.io.IOException; import java.nio.file.Path; -import java.time.Instant; import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; +import java.time.ZonedDateTime; import java.util.HashSet; import java.util.Set; @@ -41,8 +40,6 @@ public final class Repository { private static final JVM jvm = JVM.getJVM(); private static final Repository instance = new Repository(); - public final static DateTimeFormatter REPO_DATE_FORMAT = DateTimeFormatter - .ofPattern("yyyy_MM_dd_HH_mm_ss"); private static final String JFR_REPOSITORY_LOCATION_PROPERTY = "jdk.jfr.repository"; private final Set cleanupDirectories = new HashSet<>(); @@ -80,7 +77,7 @@ public final class Repository { } } - synchronized RepositoryChunk newChunk(Instant timestamp) { + synchronized RepositoryChunk newChunk(ZonedDateTime timestamp) { try { if (!SecuritySupport.existDirectory(repository)) { this.repository = createRepository(baseLocation); @@ -101,7 +98,7 @@ public final class Repository { SafePath canonicalBaseRepositoryPath = createRealBasePath(basePath); SafePath f = null; - String basename = REPO_DATE_FORMAT.format(LocalDateTime.now()) + "_" + JVM.getJVM().getPid(); + String basename = Utils.formatDateTime(LocalDateTime.now()) + "_" + JVM.getJVM().getPid(); String name = basename; int i = 0; diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/RepositoryChunk.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/RepositoryChunk.java index 33f66f9bc66..66e3aed14cc 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/RepositoryChunk.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/RepositoryChunk.java @@ -33,12 +33,12 @@ import java.time.Instant; import java.time.LocalDateTime; import java.time.ZonedDateTime; import java.util.Comparator; -import java.util.Objects; import jdk.jfr.internal.SecuritySupport.SafePath; final class RepositoryChunk { private static final int MAX_CHUNK_NAMES = 100; + private static final String FILE_EXTENSION = ".jfr"; static final Comparator END_TIME_COMPARATOR = new Comparator() { @Override @@ -48,8 +48,7 @@ final class RepositoryChunk { }; private final SafePath repositoryPath; - private final SafePath unFinishedFile; - private final SafePath file; + private final SafePath chunkFile; private final Instant startTime; private final RandomAccessFile unFinishedRAF; @@ -57,36 +56,28 @@ final class RepositoryChunk { private int refCount = 0; private long size; - RepositoryChunk(SafePath path, Instant startTime) throws Exception { - ZonedDateTime z = ZonedDateTime.now(); - String fileName = Repository.REPO_DATE_FORMAT.format( - LocalDateTime.ofInstant(startTime, z.getZone())); - this.startTime = startTime; + RepositoryChunk(SafePath path, ZonedDateTime timestamp) throws Exception { + this.startTime = timestamp.toInstant(); this.repositoryPath = path; - this.unFinishedFile = findFileName(repositoryPath, fileName, ".jfr"); - this.file = findFileName(repositoryPath, fileName, ".jfr"); - this.unFinishedRAF = SecuritySupport.createRandomAccessFile(unFinishedFile); - // SecuritySupport.touch(file); + this.chunkFile = findFileName(repositoryPath, timestamp.toLocalDateTime()); + this.unFinishedRAF = SecuritySupport.createRandomAccessFile(chunkFile); } - private static SafePath findFileName(SafePath directory, String name, String extension) throws Exception { - Path p = directory.toPath().resolve(name + extension); + private static SafePath findFileName(SafePath directory, LocalDateTime time) throws Exception { + String filename = Utils.formatDateTime(time); + Path p = directory.toPath().resolve(filename + FILE_EXTENSION); for (int i = 1; i < MAX_CHUNK_NAMES; i++) { SafePath s = new SafePath(p); if (!SecuritySupport.exists(s)) { return s; } - String extendedName = String.format("%s_%02d%s", name, i, extension); + String extendedName = String.format("%s_%02d%s", filename, i, FILE_EXTENSION); p = directory.toPath().resolve(extendedName); } - p = directory.toPath().resolve(name + "_" + System.currentTimeMillis() + extension); + p = directory.toPath().resolve(filename + "_" + System.currentTimeMillis() + FILE_EXTENSION); return SecuritySupport.toRealPath(new SafePath(p)); } - public SafePath getUnfinishedFile() { - return unFinishedFile; - } - void finish(Instant endTime) { try { finishWithException(endTime); @@ -97,15 +88,9 @@ final class RepositoryChunk { private void finishWithException(Instant endTime) throws IOException { unFinishedRAF.close(); - this.size = finish(unFinishedFile, file); + this.size = SecuritySupport.getFileSize(chunkFile); this.endTime = endTime; - Logger.log(LogTag.JFR_SYSTEM, LogLevel.DEBUG, () -> "Chunk finished: " + file); - } - - private static long finish(SafePath unFinishedFile, SafePath file) throws IOException { - Objects.requireNonNull(unFinishedFile); - Objects.requireNonNull(file); - return SecuritySupport.getFileSize(file); + Logger.log(LogTag.JFR_SYSTEM, LogLevel.DEBUG, () -> "Chunk finished: " + chunkFile); } public Instant getStartTime() { @@ -134,13 +119,11 @@ final class RepositoryChunk { if (!isFinished()) { finish(Instant.MIN); } - if (file != null) { - delete(file); - } + delete(chunkFile); try { unFinishedRAF.close(); } catch (IOException e) { - Logger.log(LogTag.JFR, LogLevel.ERROR, () -> "Could not close random access file: " + unFinishedFile.toString() + ". File will not be deleted due to: " + e.getMessage()); + Logger.log(LogTag.JFR, LogLevel.ERROR, () -> "Could not close random access file: " + chunkFile.toString() + ". File will not be deleted due to: " + e.getMessage()); } } @@ -181,17 +164,14 @@ final class RepositoryChunk { @Override public String toString() { - if (isFinished()) { - return file.toString(); - } - return unFinishedFile.toString(); + return chunkFile.toString(); } ReadableByteChannel newChannel() throws IOException { if (!isFinished()) { throw new IOException("Chunk not finished"); } - return ((SecuritySupport.newFileChannelToRead(file))); + return ((SecuritySupport.newFileChannelToRead(chunkFile))); } public boolean inInterval(Instant startTime, Instant endTime) { @@ -205,6 +185,6 @@ final class RepositoryChunk { } public SafePath getFile() { - return file; + return chunkFile; } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java index 3b56f64612c..264f7e7e182 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/Utils.java @@ -180,6 +180,30 @@ public final class Utils { return String.format("%d%s%s", value, separation, result.text); } + // This method reduces the number of loaded classes + // compared to DateTimeFormatter + static String formatDateTime(LocalDateTime time) { + StringBuilder sb = new StringBuilder(19); + sb.append(time.getYear() / 100); + appendPadded(sb, time.getYear() % 100, true); + appendPadded(sb, time.getMonth().getValue(), true); + appendPadded(sb, time.getDayOfMonth(), true); + appendPadded(sb, time.getHour(), true); + appendPadded(sb, time.getMinute(), true); + appendPadded(sb, time.getSecond(), false); + return sb.toString(); + } + + private static void appendPadded(StringBuilder text, int number, boolean separator) { + if (number < 10) { + text.append('0'); + } + text.append(number); + if (separator) { + text.append('_'); + } + } + public static long parseTimespanWithInfinity(String s) { if (INFINITY.equals(s)) { return Long.MAX_VALUE; @@ -604,7 +628,7 @@ public final class Utils { public static String makeFilename(Recording recording) { String pid = JVM.getJVM().getPid(); - String date = Repository.REPO_DATE_FORMAT.format(LocalDateTime.now()); + String date = formatDateTime(LocalDateTime.now()); String idText = recording == null ? "" : "-id-" + Long.toString(recording.getId()); return "hotspot-" + "pid-" + pid + idText + "-" + date + ".jfr"; } From 463e377053c52eb3209839a9c88cc0dcc11bd965 Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Thu, 30 Apr 2020 17:37:59 +0200 Subject: [PATCH 52/88] 8244196: adjust output in os_linux Reviewed-by: dholmes, mdoerr --- src/hotspot/os/linux/os_linux.cpp | 74 ++++++++++++------------------- 1 file changed, 28 insertions(+), 46 deletions(-) diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index dd791970163..219e62d2055 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -2060,7 +2060,7 @@ static bool _print_ascii_file(const char* filename, outputStream* st, const char } static void _print_ascii_file_h(const char* header, const char* filename, outputStream* st) { - st->print("%s", header); + st->print_cr("%s:", header); if (!_print_ascii_file(filename, st)) { st->print_cr(""); } @@ -2291,39 +2291,24 @@ void os::Linux::print_libversion_info(outputStream* st) { void os::Linux::print_proc_sys_info(outputStream* st) { st->cr(); - st->print_cr("/proc/sys/kernel/threads-max (system-wide limit on the number of threads):"); - _print_ascii_file("/proc/sys/kernel/threads-max", st); - st->cr(); - st->cr(); - - st->print_cr("/proc/sys/vm/max_map_count (maximum number of memory map areas a process may have):"); - _print_ascii_file("/proc/sys/vm/max_map_count", st); - st->cr(); - st->cr(); - - st->print_cr("/proc/sys/kernel/pid_max (system-wide limit on number of process identifiers):"); - _print_ascii_file("/proc/sys/kernel/pid_max", st); - st->cr(); - st->cr(); + _print_ascii_file_h("/proc/sys/kernel/threads-max (system-wide limit on the number of threads)", + "/proc/sys/kernel/threads-max", st); + _print_ascii_file_h("/proc/sys/vm/max_map_count (maximum number of memory map areas a process may have)", + "/proc/sys/vm/max_map_count", st); + _print_ascii_file_h("/proc/sys/kernel/pid_max (system-wide limit on number of process identifiers)", + "/proc/sys/kernel/pid_max", st); } void os::Linux::print_full_memory_info(outputStream* st) { - st->print("\n/proc/meminfo:\n"); - _print_ascii_file("/proc/meminfo", st); + _print_ascii_file_h("\n/proc/meminfo", "/proc/meminfo", st); st->cr(); // some information regarding THPs; for details see // https://www.kernel.org/doc/Documentation/vm/transhuge.txt - st->print_cr("/sys/kernel/mm/transparent_hugepage/enabled:"); - if (!_print_ascii_file("/sys/kernel/mm/transparent_hugepage/enabled", st)) { - st->print_cr(" "); - } - st->cr(); - st->print_cr("/sys/kernel/mm/transparent_hugepage/defrag (defrag/compaction efforts parameter):"); - if (!_print_ascii_file("/sys/kernel/mm/transparent_hugepage/defrag", st)) { - st->print_cr(" "); - } - st->cr(); + _print_ascii_file_h("/sys/kernel/mm/transparent_hugepage/enabled", + "/sys/kernel/mm/transparent_hugepage/enabled", st); + _print_ascii_file_h("/sys/kernel/mm/transparent_hugepage/defrag (defrag/compaction efforts parameter)", + "/sys/kernel/mm/transparent_hugepage/defrag", st); } void os::Linux::print_ld_preload_file(outputStream* st) { @@ -2510,8 +2495,8 @@ static bool print_model_name_and_flags(outputStream* st, char* buf, size_t bufle // additional information about CPU e.g. available frequency ranges static void print_sys_devices_cpu_info(outputStream* st, char* buf, size_t buflen) { - _print_ascii_file_h("Online cpus:", "/sys/devices/system/cpu/online", st); - _print_ascii_file_h("Offline cpus:", "/sys/devices/system/cpu/offline", st); + _print_ascii_file_h("Online cpus", "/sys/devices/system/cpu/online", st); + _print_ascii_file_h("Offline cpus", "/sys/devices/system/cpu/offline", st); if (ExtensiveErrorReports) { // cache related info (cpu 0, should be similar for other CPUs) @@ -2525,44 +2510,41 @@ static void print_sys_devices_cpu_info(outputStream* st, char* buf, size_t bufle snprintf(hbuf_size, 60, "/sys/devices/system/cpu/cpu0/cache/index%u/size", i); snprintf(hbuf_coherency_line_size, 80, "/sys/devices/system/cpu/cpu0/cache/index%u/coherency_line_size", i); if (file_exists(hbuf_level)) { - _print_ascii_file_h("cache level:", hbuf_level, st); - _print_ascii_file_h("cache type:", hbuf_type, st); - _print_ascii_file_h("cache size:", hbuf_size, st); - _print_ascii_file_h("cache coherency line size:", hbuf_coherency_line_size, st); + _print_ascii_file_h("cache level", hbuf_level, st); + _print_ascii_file_h("cache type", hbuf_type, st); + _print_ascii_file_h("cache size", hbuf_size, st); + _print_ascii_file_h("cache coherency line size", hbuf_coherency_line_size, st); } } } // we miss the cpufreq entries on Power and s390x #if defined(IA32) || defined(AMD64) - _print_ascii_file_h("BIOS frequency limitation:", "/sys/devices/system/cpu/cpu0/cpufreq/bios_limit", st); - _print_ascii_file_h("Frequency switch latency (ns):", "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_transition_latency", st); - _print_ascii_file_h("Available cpu frequencies:", "/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies", st); + _print_ascii_file_h("BIOS frequency limitation", "/sys/devices/system/cpu/cpu0/cpufreq/bios_limit", st); + _print_ascii_file_h("Frequency switch latency (ns)", "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_transition_latency", st); + _print_ascii_file_h("Available cpu frequencies", "/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies", st); // min and max should be in the Available range but still print them (not all info might be available for all kernels) if (ExtensiveErrorReports) { - _print_ascii_file_h("Maximum cpu frequency:", "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq", st); - _print_ascii_file_h("Minimum cpu frequency:", "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq", st); - _print_ascii_file_h("Current cpu frequency:", "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq", st); + _print_ascii_file_h("Maximum cpu frequency", "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq", st); + _print_ascii_file_h("Minimum cpu frequency", "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq", st); + _print_ascii_file_h("Current cpu frequency", "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq", st); } // governors are power schemes, see https://wiki.archlinux.org/index.php/CPU_frequency_scaling if (ExtensiveErrorReports) { - _print_ascii_file_h("Available governors:", "/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors", st); + _print_ascii_file_h("Available governors", "/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors", st); } - _print_ascii_file_h("Current governor:", "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", st); + _print_ascii_file_h("Current governor", "/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor", st); // Core performance boost, see https://www.kernel.org/doc/Documentation/cpu-freq/boost.txt // Raise operating frequency of some cores in a multi-core package if certain conditions apply, e.g. // whole chip is not fully utilized - _print_ascii_file_h("Core performance/turbo boost:", "/sys/devices/system/cpu/cpufreq/boost", st); + _print_ascii_file_h("Core performance/turbo boost", "/sys/devices/system/cpu/cpufreq/boost", st); #endif } void os::pd_print_cpu_info(outputStream* st, char* buf, size_t buflen) { // Only print the model name if the platform provides this as a summary if (!print_model_name_and_flags(st, buf, buflen)) { - st->print("\n/proc/cpuinfo:\n"); - if (!_print_ascii_file("/proc/cpuinfo", st)) { - st->print_cr(" "); - } + _print_ascii_file_h("\n/proc/cpuinfo", "/proc/cpuinfo", st); } print_sys_devices_cpu_info(st, buf, buflen); } From 72704aaba1dd27a77cf9595cf18962737ced4a87 Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Wed, 6 May 2020 15:51:49 +0200 Subject: [PATCH 53/88] 8244413: Avoid rebinds in MethodHandle.viewAsType Reviewed-by: mchung, jrose --- .../lang/invoke/DelegatingMethodHandle.java | 14 +++ .../java/lang/invoke/DirectMethodHandle.java | 91 ++++++++++++++----- .../java/lang/invoke/MethodHandle.java | 16 ++-- .../java/lang/invoke/MethodHandles.java | 7 +- 4 files changed, 92 insertions(+), 36 deletions(-) diff --git a/src/java.base/share/classes/java/lang/invoke/DelegatingMethodHandle.java b/src/java.base/share/classes/java/lang/invoke/DelegatingMethodHandle.java index 2bcc33a3802..37f7237cc2c 100644 --- a/src/java.base/share/classes/java/lang/invoke/DelegatingMethodHandle.java +++ b/src/java.base/share/classes/java/lang/invoke/DelegatingMethodHandle.java @@ -61,6 +61,20 @@ abstract class DelegatingMethodHandle extends MethodHandle { return getTarget().internalMemberName(); } + @Override + boolean isCrackable() { + MemberName member = internalMemberName(); + return member != null && + (member.isResolved() || + member.isMethodHandleInvoke() || + member.isVarHandleMethodInvoke()); + } + + @Override + MethodHandle viewAsType(MethodType newType, boolean strict) { + return getTarget().viewAsType(newType, strict); + } + @Override boolean isInvokeSpecial() { return getTarget().isInvokeSpecial(); diff --git a/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java b/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java index f98fa3f5186..81a70cfcdc9 100644 --- a/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java +++ b/src/java.base/share/classes/java/lang/invoke/DirectMethodHandle.java @@ -51,9 +51,10 @@ import static java.lang.invoke.MethodTypeForm.*; */ class DirectMethodHandle extends MethodHandle { final MemberName member; + final boolean crackable; // Constructors and factory methods in this class *must* be package scoped or private. - private DirectMethodHandle(MethodType mtype, LambdaForm form, MemberName member) { + private DirectMethodHandle(MethodType mtype, LambdaForm form, MemberName member, boolean crackable) { super(mtype, form); if (!member.isResolved()) throw new InternalError(); @@ -70,6 +71,7 @@ class DirectMethodHandle extends MethodHandle { } this.member = member; + this.crackable = crackable; } // Factory methods: @@ -92,18 +94,18 @@ class DirectMethodHandle extends MethodHandle { throw new InternalError("callerClass must not be null for REF_invokeSpecial"); } LambdaForm lform = preparedLambdaForm(member, callerClass.isInterface()); - return new Special(mtype, lform, member, callerClass); + return new Special(mtype, lform, member, true, callerClass); } case REF_invokeInterface: { // for interfaces we always need the receiver typecheck, // so we always pass 'true' to ensure we adapt if needed // to include the REF_invokeSpecial case LambdaForm lform = preparedLambdaForm(member, true); - return new Interface(mtype, lform, member, refc); + return new Interface(mtype, lform, member, true, refc); } default: { LambdaForm lform = preparedLambdaForm(member); - return new DirectMethodHandle(mtype, lform, member); + return new DirectMethodHandle(mtype, lform, member, true); } } } else { @@ -111,11 +113,11 @@ class DirectMethodHandle extends MethodHandle { if (member.isStatic()) { long offset = MethodHandleNatives.staticFieldOffset(member); Object base = MethodHandleNatives.staticFieldBase(member); - return new StaticAccessor(mtype, lform, member, base, offset); + return new StaticAccessor(mtype, lform, member, true, base, offset); } else { long offset = MethodHandleNatives.objectFieldOffset(member); assert(offset == (int)offset); - return new Accessor(mtype, lform, member, (int)offset); + return new Accessor(mtype, lform, member, true, (int)offset); } } } @@ -139,7 +141,7 @@ class DirectMethodHandle extends MethodHandle { LambdaForm lform = preparedLambdaForm(ctor); MemberName init = ctor.asSpecial(); assert(init.getMethodType().returnType() == void.class); - return new Constructor(mtype, lform, ctor, init, instanceClass); + return new Constructor(mtype, lform, ctor, true, init, instanceClass); } @Override @@ -150,7 +152,22 @@ class DirectMethodHandle extends MethodHandle { @Override MethodHandle copyWith(MethodType mt, LambdaForm lf) { assert(this.getClass() == DirectMethodHandle.class); // must override in subclasses - return new DirectMethodHandle(mt, lf, member); + return new DirectMethodHandle(mt, lf, member, crackable); + } + + @Override + MethodHandle viewAsType(MethodType newType, boolean strict) { + // No actual conversions, just a new view of the same method. + // However, we must not expose a DMH that is crackable into a + // MethodHandleInfo, so we return a cloned, uncrackable DMH + assert(viewAsTypeChecks(newType, strict)); + assert(this.getClass() == DirectMethodHandle.class); // must override in subclasses + return new DirectMethodHandle(newType, form, member, false); + } + + @Override + boolean isCrackable() { + return crackable; } @Override @@ -406,8 +423,8 @@ class DirectMethodHandle extends MethodHandle { /** This subclass represents invokespecial instructions. */ static class Special extends DirectMethodHandle { private final Class caller; - private Special(MethodType mtype, LambdaForm form, MemberName member, Class caller) { - super(mtype, form, member); + private Special(MethodType mtype, LambdaForm form, MemberName member, boolean crackable, Class caller) { + super(mtype, form, member, crackable); this.caller = caller; } @Override @@ -416,7 +433,12 @@ class DirectMethodHandle extends MethodHandle { } @Override MethodHandle copyWith(MethodType mt, LambdaForm lf) { - return new Special(mt, lf, member, caller); + return new Special(mt, lf, member, crackable, caller); + } + @Override + MethodHandle viewAsType(MethodType newType, boolean strict) { + assert(viewAsTypeChecks(newType, strict)); + return new Special(newType, form, member, false, caller); } Object checkReceiver(Object recv) { if (!caller.isInstance(recv)) { @@ -431,14 +453,19 @@ class DirectMethodHandle extends MethodHandle { /** This subclass represents invokeinterface instructions. */ static class Interface extends DirectMethodHandle { private final Class refc; - private Interface(MethodType mtype, LambdaForm form, MemberName member, Class refc) { - super(mtype, form, member); - assert refc.isInterface() : refc; + private Interface(MethodType mtype, LambdaForm form, MemberName member, boolean crackable, Class refc) { + super(mtype, form, member, crackable); + assert(refc.isInterface()) : refc; this.refc = refc; } @Override MethodHandle copyWith(MethodType mt, LambdaForm lf) { - return new Interface(mt, lf, member, refc); + return new Interface(mt, lf, member, crackable, refc); + } + @Override + MethodHandle viewAsType(MethodType newType, boolean strict) { + assert(viewAsTypeChecks(newType, strict)); + return new Interface(newType, form, member, false, refc); } @Override Object checkReceiver(Object recv) { @@ -456,22 +483,26 @@ class DirectMethodHandle extends MethodHandle { throw new InternalError("Should only be invoked on a subclass"); } - /** This subclass handles constructor references. */ static class Constructor extends DirectMethodHandle { final MemberName initMethod; final Class instanceClass; private Constructor(MethodType mtype, LambdaForm form, MemberName constructor, - MemberName initMethod, Class instanceClass) { - super(mtype, form, constructor); + boolean crackable, MemberName initMethod, Class instanceClass) { + super(mtype, form, constructor, crackable); this.initMethod = initMethod; this.instanceClass = instanceClass; assert(initMethod.isResolved()); } @Override MethodHandle copyWith(MethodType mt, LambdaForm lf) { - return new Constructor(mt, lf, member, initMethod, instanceClass); + return new Constructor(mt, lf, member, crackable, initMethod, instanceClass); + } + @Override + MethodHandle viewAsType(MethodType newType, boolean strict) { + assert(viewAsTypeChecks(newType, strict)); + return new Constructor(newType, form, member, false, initMethod, instanceClass); } } @@ -492,8 +523,8 @@ class DirectMethodHandle extends MethodHandle { final Class fieldType; final int fieldOffset; private Accessor(MethodType mtype, LambdaForm form, MemberName member, - int fieldOffset) { - super(mtype, form, member); + boolean crackable, int fieldOffset) { + super(mtype, form, member, crackable); this.fieldType = member.getFieldType(); this.fieldOffset = fieldOffset; } @@ -503,7 +534,12 @@ class DirectMethodHandle extends MethodHandle { } @Override MethodHandle copyWith(MethodType mt, LambdaForm lf) { - return new Accessor(mt, lf, member, fieldOffset); + return new Accessor(mt, lf, member, crackable, fieldOffset); + } + @Override + MethodHandle viewAsType(MethodType newType, boolean strict) { + assert(viewAsTypeChecks(newType, strict)); + return new Accessor(newType, form, member, false, fieldOffset); } } @@ -535,8 +571,8 @@ class DirectMethodHandle extends MethodHandle { private final long staticOffset; private StaticAccessor(MethodType mtype, LambdaForm form, MemberName member, - Object staticBase, long staticOffset) { - super(mtype, form, member); + boolean crackable, Object staticBase, long staticOffset) { + super(mtype, form, member, crackable); this.fieldType = member.getFieldType(); this.staticBase = staticBase; this.staticOffset = staticOffset; @@ -547,7 +583,12 @@ class DirectMethodHandle extends MethodHandle { } @Override MethodHandle copyWith(MethodType mt, LambdaForm lf) { - return new StaticAccessor(mt, lf, member, staticBase, staticOffset); + return new StaticAccessor(mt, lf, member, crackable, staticBase, staticOffset); + } + @Override + MethodHandle viewAsType(MethodType newType, boolean strict) { + assert(viewAsTypeChecks(newType, strict)); + return new StaticAccessor(newType, form, member, false, staticBase, staticOffset); } } diff --git a/src/java.base/share/classes/java/lang/invoke/MethodHandle.java b/src/java.base/share/classes/java/lang/invoke/MethodHandle.java index 6b8f565e61f..d1c63526d79 100644 --- a/src/java.base/share/classes/java/lang/invoke/MethodHandle.java +++ b/src/java.base/share/classes/java/lang/invoke/MethodHandle.java @@ -1640,12 +1640,9 @@ assertEquals("[three, thee, tee]", asListFix.invoke((Object)argv).toString()); /*non-public*/ MethodHandle viewAsType(MethodType newType, boolean strict) { // No actual conversions, just a new view of the same method. - // Note that this operation must not produce a DirectMethodHandle, - // because retyped DMHs, like any transformed MHs, - // cannot be cracked into MethodHandleInfo. - assert viewAsTypeChecks(newType, strict); - BoundMethodHandle mh = rebind(); - return mh.copyWith(newType, mh.form); + // Overridden in DMH, which has special rules + assert(viewAsTypeChecks(newType, strict)); + return copyWith(newType, form); } /*non-public*/ @@ -1693,7 +1690,7 @@ assertEquals("[three, thee, tee]", asListFix.invoke((Object)argv).toString()); } else { // The following case is rare. Mask the internalMemberName by wrapping the MH in a BMH. MethodHandle result = rebind(); - assert (result.internalMemberName() == null); + assert(result.internalMemberName() == null); return result; } } @@ -1703,6 +1700,11 @@ assertEquals("[three, thee, tee]", asListFix.invoke((Object)argv).toString()); return false; // DMH.Special returns true } + /*non-public*/ + boolean isCrackable() { + return false; + } + /*non-public*/ Object internalValues() { return null; diff --git a/src/java.base/share/classes/java/lang/invoke/MethodHandles.java b/src/java.base/share/classes/java/lang/invoke/MethodHandles.java index 59ce89cf988..ffb491c2bf7 100644 --- a/src/java.base/share/classes/java/lang/invoke/MethodHandles.java +++ b/src/java.base/share/classes/java/lang/invoke/MethodHandles.java @@ -3282,11 +3282,10 @@ return mh1; * @since 1.8 */ public MethodHandleInfo revealDirect(MethodHandle target) { - MemberName member = target.internalMemberName(); - if (member == null || (!member.isResolved() && - !member.isMethodHandleInvoke() && - !member.isVarHandleMethodInvoke())) + if (!target.isCrackable()) { throw newIllegalArgumentException("not a direct method handle"); + } + MemberName member = target.internalMemberName(); Class defc = member.getDeclaringClass(); byte refKind = member.getReferenceKind(); assert(MethodHandleNatives.refKindIsValid(refKind)); From 5e83cb6ca55343f85207a20d332b9f99779e9d45 Mon Sep 17 00:00:00 2001 From: Jim Laskey Date: Wed, 6 May 2020 12:49:58 -0300 Subject: [PATCH 54/88] 8241602: jlink does not produce reproducible jimage files Reviewed-by: alanb, ihse --- .../jdk/tools/jlink/internal/DirArchive.java | 16 ++++++ .../jdk/tools/jlink/internal/JarArchive.java | 17 ++++++ .../jdk/tools/jlink/internal/JmodArchive.java | 16 ++++++ .../tools/jlink/JLinkReproducible2Test.java | 54 +++++++++++++++++++ 4 files changed, 103 insertions(+) create mode 100644 test/jdk/tools/jlink/JLinkReproducible2Test.java diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/DirArchive.java b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/DirArchive.java index d24054bafc3..4cbfedea534 100644 --- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/DirArchive.java +++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/DirArchive.java @@ -153,4 +153,20 @@ public class DirArchive implements Archive { private static String getPathName(Path path) { return path.toString().replace(File.separatorChar, '/'); } + + @Override + public int hashCode() { + return Objects.hash(dirPath, moduleName); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof DirArchive) { + DirArchive other = (DirArchive)obj; + return Objects.equals(dirPath, other.dirPath) && + Objects.equals(moduleName, other.moduleName); + } + + return false; + } } diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JarArchive.java b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JarArchive.java index 5782f3022ba..b410ccef558 100644 --- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JarArchive.java +++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JarArchive.java @@ -133,4 +133,21 @@ public abstract class JarArchive implements Archive { protected JarFile getJarFile() { return jarFile; } + + @Override + public int hashCode() { + return Objects.hash(file, moduleName, version); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof JarArchive) { + JarArchive other = (JarArchive)obj; + return Objects.equals(file, other.file) && + Objects.equals(moduleName, other.moduleName) && + Objects.equals(version, other.version); + } + + return false; + } } diff --git a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JmodArchive.java b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JmodArchive.java index 2450db657ee..bbb25a5bac4 100644 --- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JmodArchive.java +++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JmodArchive.java @@ -174,4 +174,20 @@ public class JmodArchive implements Archive { return new JmodEntry(path, resourceName, type, entry); } + + @Override + public int hashCode() { + return Objects.hash(file, moduleName); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof JmodArchive) { + JmodArchive other = (JmodArchive)obj; + return Objects.equals(file, other.file) && + Objects.equals(moduleName, other.moduleName); + } + + return false; + } } diff --git a/test/jdk/tools/jlink/JLinkReproducible2Test.java b/test/jdk/tools/jlink/JLinkReproducible2Test.java new file mode 100644 index 00000000000..c11025c30fe --- /dev/null +++ b/test/jdk/tools/jlink/JLinkReproducible2Test.java @@ -0,0 +1,54 @@ +/* + * 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. + */ + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.spi.ToolProvider; + +/* + * @test + * @summary Make sure that jimages are consistent when created by jlink. + * @bug 8241602 + * @modules jdk.jlink + * java.se + * @run main JLinkReproducible2Test + */ +public class JLinkReproducible2Test { + static final ToolProvider JLINK_TOOL = ToolProvider.findFirst("jlink") + .orElseThrow(() -> + new RuntimeException("jlink tool not found") + ); + + public static void main(String[] args) throws Exception { + Path image1 = Paths.get("./image1"); + Path image2 = Paths.get("./image2"); + + JLINK_TOOL.run(System.out, System.err, "--add-modules", "java.se", "--output", image1.toString()); + JLINK_TOOL.run(System.out, System.err, "--add-modules", "java.se", "--output", image2.toString()); + + if (Files.mismatch(image1.resolve("lib").resolve("modules"), image2.resolve("lib").resolve("modules")) != -1L) { + new RuntimeException("jlink producing inconsistent result"); + } + } +} From 9f86d94580535a53c791a9eb429480ceecb33699 Mon Sep 17 00:00:00 2001 From: Igor Ignatyev Date: Tue, 5 May 2020 18:02:11 -0700 Subject: [PATCH 55/88] 8244491: make runtime/cds/appcds/TestZGCWithCDS.java test more robust Reviewed-by: dholmes --- .../runtime/cds/appcds/TestZGCWithCDS.java | 36 ++++++------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithCDS.java b/test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithCDS.java index af0ad861b55..5d378e090c0 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithCDS.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithCDS.java @@ -26,7 +26,7 @@ * @requires vm.cds * @requires vm.bits == 64 * @requires vm.gc.Z - * @comment assuming that default GC supports both UseCompressedOops and UseCompressedClassPointers + * @requires vm.gc.Serial * @requires vm.gc == null * @comment Graal does not support ZGC * @requires !vm.graal.enabled @@ -44,7 +44,6 @@ public class TestZGCWithCDS { public final static String ERR_MSG = "The saved state of UseCompressedOops and UseCompressedClassPointers is different from runtime, CDS will be disabled."; public static void main(String... args) throws Exception { String helloJar = JarBuilder.build("hello", "Hello"); - // 0. dump with ZGC System.out.println("0. Dump with ZGC"); OutputAnalyzer out = TestCommon .dump(helloJar, @@ -54,7 +53,6 @@ public class TestZGCWithCDS { out.shouldContain("Dumping shared data to file:"); out.shouldHaveExitValue(0); - // 1. Run with same args of dump System.out.println("1. Run with same args of dump"); out = TestCommon .exec(helloJar, @@ -64,23 +62,10 @@ public class TestZGCWithCDS { out.shouldContain(HELLO); out.shouldHaveExitValue(0); - // 2. Run with ZGC turned off - System.out.println("2. Run with ZGC turned off"); - out = TestCommon - .exec(helloJar, - "-XX:-UseZGC", - "-XX:+UseCompressedOops", // in case turned off by vmoptions - "-XX:+UseCompressedClassPointers", // by jtreg - "-Xlog:cds", - "Hello"); - out.shouldContain(UNABLE_TO_USE_ARCHIVE); - out.shouldContain(ERR_MSG); - out.shouldHaveExitValue(1); - - // 3. Run with -UseCompressedOops -UseCompressedClassPointers - System.out.println("3. Run with -UseCompressedOops -UseCompressedClassPointers"); + System.out.println("2. Run with -UseCompressedOops -UseCompressedClassPointers"); out = TestCommon .exec(helloJar, + "-XX:+UseSerialGC", "-XX:-UseCompressedOops", "-XX:-UseCompressedClassPointers", "-Xlog:cds", @@ -88,10 +73,10 @@ public class TestZGCWithCDS { out.shouldContain(HELLO); out.shouldHaveExitValue(0); - // 4. Run with +UseCompressedOops -UseCompressedClassPointers - System.out.println("4. Run with +UseCompressedOops -UseCompressedClassPointers"); + System.out.println("3. Run with +UseCompressedOops -UseCompressedClassPointers"); out = TestCommon .exec(helloJar, + "-XX:+UseSerialGC", "-XX:+UseCompressedOops", "-XX:-UseCompressedClassPointers", "-Xlog:cds", @@ -100,10 +85,10 @@ public class TestZGCWithCDS { out.shouldContain(ERR_MSG); out.shouldHaveExitValue(1); - // 5. Run with +UseCompressedOops +UseCompressedClassPointers - System.out.println("5. Run with +UseCompressedOops +UseCompressedClassPointers"); + System.out.println("4. Run with +UseCompressedOops +UseCompressedClassPointers"); out = TestCommon .exec(helloJar, + "-XX:+UseSerialGC", "-XX:+UseCompressedOops", "-XX:+UseCompressedClassPointers", "-Xlog:cds", @@ -112,19 +97,18 @@ public class TestZGCWithCDS { out.shouldContain(ERR_MSG); out.shouldHaveExitValue(1); - // 6. dump with -UseCompressedOops -UseCompressedClassPointers - System.out.println("6. Dump with -UseCompressedOops -UseCompressedClassPointers"); + System.out.println("5. Dump with -UseCompressedOops -UseCompressedClassPointers"); out = TestCommon .dump(helloJar, new String[] {"Hello"}, + "-XX:+UseSerialGC", "-XX:-UseCompressedOops", "-XX:-UseCompressedClassPointers", "-Xlog:cds"); out.shouldContain("Dumping shared data to file:"); out.shouldHaveExitValue(0); - // 7. Run with ZGC - System.out.println("7. Run with ZGC"); + System.out.println("6. Run with ZGC"); out = TestCommon .exec(helloJar, "-XX:+UseZGC", From ed24927500ed3bb95da6e1c4140331d5f5ccac3e Mon Sep 17 00:00:00 2001 From: Rahul Yadav Date: Wed, 6 May 2020 17:33:32 +0100 Subject: [PATCH 56/88] =?UTF-8?q?8240666:=20Websocket=20client=E2=80=99s?= =?UTF-8?q?=20OpeningHandshake=20discards=20the=20HTTP=20response=20body?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The fix updates jdk.internal.net.http.websocket. OpeningHandshake.send() method to process the response body from server Reviewed-by: chegar, dfuchs, prappo --- .../jdk/internal/net/http/websocket/OpeningHandshake.java | 2 +- .../httpclient/websocket/WSHandshakeExceptionTest.java | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/websocket/OpeningHandshake.java b/src/java.net.http/share/classes/jdk/internal/net/http/websocket/OpeningHandshake.java index 63270bf5a5c..79397ad99d9 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/websocket/OpeningHandshake.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/websocket/OpeningHandshake.java @@ -188,7 +188,7 @@ public class OpeningHandshake { public CompletableFuture send() { PrivilegedAction> pa = () -> - client.sendAsync(this.request, BodyHandlers.discarding()) + client.sendAsync(this.request, BodyHandlers.ofString()) .thenCompose(this::resultFrom); return AccessController.doPrivileged(pa); } diff --git a/test/jdk/java/net/httpclient/websocket/WSHandshakeExceptionTest.java b/test/jdk/java/net/httpclient/websocket/WSHandshakeExceptionTest.java index 8702a49549f..d25d6c8e5ea 100644 --- a/test/jdk/java/net/httpclient/websocket/WSHandshakeExceptionTest.java +++ b/test/jdk/java/net/httpclient/websocket/WSHandshakeExceptionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -23,6 +23,7 @@ /* * @test + * @bug 8240666 * @summary Basic test for WebSocketHandshakeException * @library /test/lib * @build jdk.test.lib.net.SimpleSSLContext @@ -55,7 +56,9 @@ import java.util.concurrent.Executors; import static java.net.http.HttpClient.Builder.NO_PROXY; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail; +import static java.lang.System.out; public class WSHandshakeExceptionTest { @@ -107,6 +110,9 @@ public class WSHandshakeExceptionTest { } WebSocketHandshakeException wse = (WebSocketHandshakeException) t; assertNotNull(wse.getResponse()); + out.println("Status code is " + wse.getResponse().statusCode()); + out.println("Response is " + wse.getResponse().body()); + assertTrue(((String)wse.getResponse().body()).contains("404")); assertEquals(wse.getResponse().statusCode(), 404); } } From 09287ab1ac2e0989231777a465ba2eed01a6daef Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Wed, 6 May 2020 10:26:22 -0700 Subject: [PATCH 57/88] 8244459: Optimize the hash map size in LocaleProviderAdapters Reviewed-by: joehw, plevart, smarks --- .../share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java | 2 +- .../sun/util/locale/provider/JRELocaleProviderAdapter.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java b/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java index f737545d2e1..c33cd9bc3e3 100644 --- a/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java +++ b/src/java.base/share/classes/sun/util/cldr/CLDRLocaleProviderAdapter.java @@ -225,7 +225,7 @@ public class CLDRLocaleProviderAdapter extends JRELocaleProviderAdapter { return Collections.emptySet(); } StringTokenizer tokens = new StringTokenizer(supportedLocaleString); - Set tagset = new HashSet<>(Math.max((int)(tokens.countTokens() / 0.75f) + 1, 16)); + Set tagset = new HashSet<>((tokens.countTokens() * 4 + 2) / 3); while (tokens.hasMoreTokens()) { tagset.add(tokens.nextToken()); } diff --git a/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java b/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java index 431f72e2dd8..16b77ba55e8 100644 --- a/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java +++ b/src/java.base/share/classes/sun/util/locale/provider/JRELocaleProviderAdapter.java @@ -445,7 +445,7 @@ public class JRELocaleProviderAdapter extends LocaleProviderAdapter implements R return Collections.emptySet(); } StringTokenizer tokens = new StringTokenizer(supportedLocaleString); - Set tagset = new HashSet<>(Math.max((int)(tokens.countTokens() / 0.75f) + 1, 16)); + Set tagset = new HashSet<>((tokens.countTokens() * 4 + 2) / 3); while (tokens.hasMoreTokens()) { tagset.add(tokens.nextToken()); } From 1f31afd855b60fea52257e3ce7d274afe7005b26 Mon Sep 17 00:00:00 2001 From: Gerard Ziemski Date: Wed, 6 May 2020 12:40:50 -0500 Subject: [PATCH 58/88] 8237777: "Dumping core ..." is shown despite claiming that "# No core dump will be written." Remove the unneeded and possibly misleading message. Reviewed-by: dholmes, ysuenaga --- src/hotspot/os/aix/os_aix.cpp | 8 -------- src/hotspot/os/bsd/os_bsd.cpp | 8 -------- src/hotspot/os/linux/os_linux.cpp | 8 -------- src/hotspot/os/solaris/os_solaris.cpp | 8 -------- 4 files changed, 32 deletions(-) diff --git a/src/hotspot/os/aix/os_aix.cpp b/src/hotspot/os/aix/os_aix.cpp index 1c460ce2e8f..e9ab20ad2ee 100644 --- a/src/hotspot/os/aix/os_aix.cpp +++ b/src/hotspot/os/aix/os_aix.cpp @@ -1180,14 +1180,6 @@ void os::shutdown() { void os::abort(bool dump_core, void* siginfo, const void* context) { os::shutdown(); if (dump_core) { -#ifndef PRODUCT - fdStream out(defaultStream::output_fd()); - out.print_raw("Current thread is "); - char buf[16]; - jio_snprintf(buf, sizeof(buf), UINTX_FORMAT, os::current_thread_id()); - out.print_raw_cr(buf); - out.print_raw_cr("Dumping core ..."); -#endif ::abort(); // dump core } diff --git a/src/hotspot/os/bsd/os_bsd.cpp b/src/hotspot/os/bsd/os_bsd.cpp index 0e190e736de..1a9a45e77e0 100644 --- a/src/hotspot/os/bsd/os_bsd.cpp +++ b/src/hotspot/os/bsd/os_bsd.cpp @@ -1070,14 +1070,6 @@ void os::shutdown() { void os::abort(bool dump_core, void* siginfo, const void* context) { os::shutdown(); if (dump_core) { -#ifndef PRODUCT - fdStream out(defaultStream::output_fd()); - out.print_raw("Current thread is "); - char buf[16]; - jio_snprintf(buf, sizeof(buf), UINTX_FORMAT, os::current_thread_id()); - out.print_raw_cr(buf); - out.print_raw_cr("Dumping core ..."); -#endif ::abort(); // dump core } diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index 219e62d2055..277ea9a83b6 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -1520,14 +1520,6 @@ void os::abort(bool dump_core, void* siginfo, const void* context) { if (DumpPrivateMappingsInCore) { ClassLoader::close_jrt_image(); } -#ifndef PRODUCT - fdStream out(defaultStream::output_fd()); - out.print_raw("Current thread is "); - char buf[16]; - jio_snprintf(buf, sizeof(buf), UINTX_FORMAT, os::current_thread_id()); - out.print_raw_cr(buf); - out.print_raw_cr("Dumping core ..."); -#endif ::abort(); // dump core } diff --git a/src/hotspot/os/solaris/os_solaris.cpp b/src/hotspot/os/solaris/os_solaris.cpp index 5b2a1a6cba2..ee268a683c2 100644 --- a/src/hotspot/os/solaris/os_solaris.cpp +++ b/src/hotspot/os/solaris/os_solaris.cpp @@ -1147,14 +1147,6 @@ void os::shutdown() { void os::abort(bool dump_core, void* siginfo, const void* context) { os::shutdown(); if (dump_core) { -#ifndef PRODUCT - fdStream out(defaultStream::output_fd()); - out.print_raw("Current thread is "); - char buf[16]; - jio_snprintf(buf, sizeof(buf), UINTX_FORMAT, os::current_thread_id()); - out.print_raw_cr(buf); - out.print_raw_cr("Dumping core ..."); -#endif ::abort(); // dump core (for debugging) } From 91ed3fc599583270d180c44efc3f1793dfa69325 Mon Sep 17 00:00:00 2001 From: Gerard Ziemski Date: Wed, 6 May 2020 12:42:28 -0500 Subject: [PATCH 59/88] 8236177: assert(status == 0) failed: error ETIMEDOUT(60), cond_wait Extend the assert to cover the new case. Reviewed-by: dholmes, kbarrett --- src/hotspot/os/posix/os_posix.cpp | 9 ++++++--- src/hotspot/share/utilities/macros.hpp | 8 ++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/hotspot/os/posix/os_posix.cpp b/src/hotspot/os/posix/os_posix.cpp index 5f470ce2adb..08c303a8787 100644 --- a/src/hotspot/os/posix/os_posix.cpp +++ b/src/hotspot/os/posix/os_posix.cpp @@ -1967,7 +1967,8 @@ void os::PlatformEvent::park() { // AKA "down()" while (_event < 0) { // OS-level "spurious wakeups" are ignored status = pthread_cond_wait(_cond, _mutex); - assert_status(status == 0, status, "cond_wait"); + assert_status(status == 0 MACOS_ONLY(|| status == ETIMEDOUT), + status, "cond_wait"); } --_nParked; @@ -2158,7 +2159,8 @@ void Parker::park(bool isAbsolute, jlong time) { if (time == 0) { _cur_index = REL_INDEX; // arbitrary choice when not timed status = pthread_cond_wait(&_cond[_cur_index], _mutex); - assert_status(status == 0, status, "cond_timedwait"); + assert_status(status == 0 MACOS_ONLY(|| status == ETIMEDOUT), + status, "cond_wait"); } else { _cur_index = isAbsolute ? ABS_INDEX : REL_INDEX; @@ -2339,7 +2341,8 @@ int os::PlatformMonitor::wait(jlong millis) { return ret; } else { int status = pthread_cond_wait(cond(), mutex()); - assert_status(status == 0, status, "cond_wait"); + assert_status(status == 0 MACOS_ONLY(|| status == ETIMEDOUT), + status, "cond_wait"); return OS_OK; } } diff --git a/src/hotspot/share/utilities/macros.hpp b/src/hotspot/share/utilities/macros.hpp index 89195330550..b5df488ea5c 100644 --- a/src/hotspot/share/utilities/macros.hpp +++ b/src/hotspot/share/utilities/macros.hpp @@ -404,6 +404,14 @@ #define NOT_LINUX(code) code #endif +#ifdef __APPLE__ +#define MACOS_ONLY(code) code +#define NOT_MACOS(code) +#else +#define MACOS_ONLY(code) +#define NOT_MACOS(code) code +#endif + #ifdef AIX #define AIX_ONLY(code) code #define NOT_AIX(code) From a2c35a6acb9d73fbe743ccac3c9638b7522d96a7 Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Wed, 6 May 2020 19:19:38 +0100 Subject: [PATCH 60/88] 8244205: HTTP/2 tunnel connections through proxy may be reused regardless of which proxy is selected The key used in the HTTP/2 connection pool is updated to take into account the proxy address in case of tunnel connections Reviewed-by: chegar --- .../internal/net/http/AsyncSSLConnection.java | 7 +- .../net/http/AsyncSSLTunnelConnection.java | 7 +- .../internal/net/http/Http2Connection.java | 62 ++- .../jdk/internal/net/http/HttpConnection.java | 10 +- .../net/http/PlainHttpConnection.java | 6 +- .../net/http/PlainProxyConnection.java | 7 +- .../net/http/PlainTunnelingConnection.java | 6 +- .../net/httpclient/ProxySelectorTest.java | 462 ++++++++++++++++++ .../internal/net/http/ConnectionPoolTest.java | 3 +- 9 files changed, 539 insertions(+), 31 deletions(-) create mode 100644 test/jdk/java/net/httpclient/ProxySelectorTest.java diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/AsyncSSLConnection.java b/src/java.net.http/share/classes/jdk/internal/net/http/AsyncSSLConnection.java index 84ad59b949d..41ee0a81614 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/AsyncSSLConnection.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/AsyncSSLConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -91,6 +91,11 @@ class AsyncSSLConnection extends AbstractAsyncSSLConnection { return false; } + @Override + InetSocketAddress proxy() { + return null; + } + @Override SocketChannel channel() { return plainConnection.channel(); diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/AsyncSSLTunnelConnection.java b/src/java.net.http/share/classes/jdk/internal/net/http/AsyncSSLTunnelConnection.java index 138a4758017..00e48c965d0 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/AsyncSSLTunnelConnection.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/AsyncSSLTunnelConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -123,6 +123,11 @@ class AsyncSSLTunnelConnection extends AbstractAsyncSSLConnection { return true; } + @Override + InetSocketAddress proxy() { + return plainConnection.proxyAddr; + } + @Override SSLTube getConnectionFlow() { return flow; diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java b/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java index 13f5bf03efa..004ca5656a8 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -514,45 +514,59 @@ class Http2Connection { boolean isProxy = connection.isProxied(); // tunnel or plain clear connection through proxy boolean isSecure = connection.isSecure(); InetSocketAddress addr = connection.address(); + InetSocketAddress proxyAddr = connection.proxy(); + assert isProxy == (proxyAddr != null); - return keyString(isSecure, isProxy, addr.getHostString(), addr.getPort()); + return keyString(isSecure, proxyAddr, addr.getHostString(), addr.getPort()); } static String keyFor(URI uri, InetSocketAddress proxy) { boolean isSecure = uri.getScheme().equalsIgnoreCase("https"); - boolean isProxy = proxy != null; - String host; - int port; - - if (proxy != null && !isSecure) { - // clear connection through proxy: use - // proxy host / proxy port - host = proxy.getHostString(); - port = proxy.getPort(); - } else { - // either secure tunnel connection through proxy - // or direct connection to host, but in either - // case only that host can be reached through - // the connection: use target host / target port - host = uri.getHost(); - port = uri.getPort(); - } - return keyString(isSecure, isProxy, host, port); + String host = uri.getHost(); + int port = uri.getPort(); + return keyString(isSecure, proxy, host, port); } - // {C,S}:{H:P}:host:port + + // Compute the key for an HttpConnection in the Http2ClientImpl pool: + // The key string follows one of the three forms below: + // {C,S}:H:host:port + // C:P:proxy-host:proxy-port + // S:T:H:host:port;P:proxy-host:proxy-port // C indicates clear text connection "http" // S indicates secure "https" // H indicates host (direct) connection // P indicates proxy - // Eg: "S:H:foo.com:80" - static String keyString(boolean secure, boolean proxy, String host, int port) { + // T indicates a tunnel connection through a proxy + // + // The first form indicates a direct connection to a server: + // - direct clear connection to an HTTP host: + // e.g.: "C:H:foo.com:80" + // - direct secure connection to an HTTPS host: + // e.g.: "S:H:foo.com:443" + // The second form indicates a clear connection to an HTTP/1.1 proxy: + // e.g.: "C:P:myproxy:8080" + // The third form indicates a secure tunnel connection to an HTTPS + // host through an HTTP/1.1 proxy: + // e.g: "S:T:H:foo.com:80;P:myproxy:8080" + static String keyString(boolean secure, InetSocketAddress proxy, String host, int port) { if (secure && port == -1) port = 443; else if (!secure && port == -1) port = 80; - return (secure ? "S:" : "C:") + (proxy ? "P:" : "H:") + host + ":" + port; + var key = (secure ? "S:" : "C:"); + if (proxy != null && !secure) { + // clear connection through proxy + key = key + "P:" + proxy.getHostString() + ":" + proxy.getPort(); + } else if (proxy == null) { + // direct connection to host + key = key + "H:" + host + ":" + port; + } else { + // tunnel connection through proxy + key = key + "T:H:" + host + ":" + port + ";P:" + proxy.getHostString() + ":" + proxy.getPort(); + } + return key; } String key() { diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/HttpConnection.java b/src/java.net.http/share/classes/jdk/internal/net/http/HttpConnection.java index ecd7950bc72..138d64e9adf 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/HttpConnection.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/HttpConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -136,6 +136,14 @@ abstract class HttpConnection implements Closeable { */ abstract boolean isProxied(); + /** + * Returns the address of the proxy used by this connection. + * Returns the proxy address for tunnel connections, or + * clear connection to any host through proxy. + * Returns {@code null} otherwise. + */ + abstract InetSocketAddress proxy(); + /** Tells whether, or not, this connection is open. */ final boolean isOpen() { return channel().isOpen() && diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/PlainHttpConnection.java b/src/java.net.http/share/classes/jdk/internal/net/http/PlainHttpConnection.java index 3256e3c6d36..2ccab8e41d4 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/PlainHttpConnection.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/PlainHttpConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -302,4 +302,8 @@ class PlainHttpConnection extends HttpConnection { return false; } + @Override + InetSocketAddress proxy() { + return null; + } } diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/PlainProxyConnection.java b/src/java.net.http/share/classes/jdk/internal/net/http/PlainProxyConnection.java index 3864a7ee08b..6d8ffda7465 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/PlainProxyConnection.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/PlainProxyConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -40,4 +40,9 @@ class PlainProxyConnection extends PlainHttpConnection { @Override public boolean isProxied() { return true; } + + @Override + InetSocketAddress proxy() { + return address; + } } diff --git a/src/java.net.http/share/classes/jdk/internal/net/http/PlainTunnelingConnection.java b/src/java.net.http/share/classes/jdk/internal/net/http/PlainTunnelingConnection.java index cdc8657fe97..85e656ba021 100644 --- a/src/java.net.http/share/classes/jdk/internal/net/http/PlainTunnelingConnection.java +++ b/src/java.net.http/share/classes/jdk/internal/net/http/PlainTunnelingConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 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 @@ -171,4 +171,8 @@ final class PlainTunnelingConnection extends HttpConnection { return true; } + @Override + InetSocketAddress proxy() { + return proxyAddr; + } } diff --git a/test/jdk/java/net/httpclient/ProxySelectorTest.java b/test/jdk/java/net/httpclient/ProxySelectorTest.java new file mode 100644 index 00000000000..b2a8c450ab8 --- /dev/null +++ b/test/jdk/java/net/httpclient/ProxySelectorTest.java @@ -0,0 +1,462 @@ +/* + * 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 8244205 + * @summary checks that a different proxy returned for + * the same host:port is taken into account + * @modules java.base/sun.net.www.http + * java.net.http/jdk.internal.net.http.common + * java.net.http/jdk.internal.net.http.frame + * java.net.http/jdk.internal.net.http.hpack + * java.logging + * jdk.httpserver + * java.base/sun.net.www.http + * java.base/sun.net.www + * java.base/sun.net + * @library /test/lib http2/server + * @build HttpServerAdapters DigestEchoServer Http2TestServer ProxySelectorTest + * @build jdk.test.lib.net.SimpleSSLContext + * @run testng/othervm + * -Djdk.http.auth.tunneling.disabledSchemes + * -Djdk.httpclient.HttpClient.log=headers,requests + * -Djdk.internal.httpclient.debug=true + * ProxySelectorTest + */ + +import com.sun.net.httpserver.HttpServer; +import com.sun.net.httpserver.HttpsConfigurator; +import com.sun.net.httpserver.HttpsServer; +import jdk.test.lib.net.SimpleSSLContext; +import org.testng.ITestContext; +import org.testng.annotations.AfterClass; +import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeTest; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import javax.net.ssl.SSLContext; +import java.io.IOException; +import java.io.InputStream; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.Proxy; +import java.net.ProxySelector; +import java.net.SocketAddress; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.net.http.HttpResponse.BodyHandlers; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Executor; +import java.util.concurrent.Executors; +import java.util.concurrent.atomic.AtomicLong; + +import static java.lang.System.err; +import static java.lang.System.out; +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.testng.Assert.assertEquals; + +public class ProxySelectorTest implements HttpServerAdapters { + + SSLContext sslContext; + HttpTestServer httpTestServer; // HTTP/1.1 + HttpTestServer proxyHttpTestServer; // HTTP/1.1 + HttpTestServer authProxyHttpTestServer; // HTTP/1.1 + HttpTestServer http2TestServer; // HTTP/2 ( h2c ) + HttpTestServer httpsTestServer; // HTTPS/1.1 + HttpTestServer https2TestServer; // HTTP/2 ( h2 ) + DigestEchoServer.TunnelingProxy proxy; + DigestEchoServer.TunnelingProxy authproxy; + String httpURI; + String httpsURI; + String proxyHttpURI; + String authProxyHttpURI; + String http2URI; + String https2URI; + HttpClient client; + + final ReferenceTracker TRACKER = ReferenceTracker.INSTANCE; + static final long SLEEP_AFTER_TEST = 0; // milliseconds + static final int ITERATIONS = 3; + static final Executor executor = new TestExecutor(Executors.newCachedThreadPool()); + static final ConcurrentMap FAILURES = new ConcurrentHashMap<>(); + static volatile boolean tasksFailed; + static final AtomicLong serverCount = new AtomicLong(); + static final AtomicLong clientCount = new AtomicLong(); + static final long start = System.nanoTime(); + public static String now() { + long now = System.nanoTime() - start; + long secs = now / 1000_000_000; + long mill = (now % 1000_000_000) / 1000_000; + long nan = now % 1000_000; + return String.format("[%d s, %d ms, %d ns] ", secs, mill, nan); + } + + static class TestExecutor implements Executor { + final AtomicLong tasks = new AtomicLong(); + Executor executor; + TestExecutor(Executor executor) { + this.executor = executor; + } + + @Override + public void execute(Runnable command) { + long id = tasks.incrementAndGet(); + executor.execute(() -> { + try { + command.run(); + } catch (Throwable t) { + tasksFailed = true; + out.printf(now() + "Task %s failed: %s%n", id, t); + err.printf(now() + "Task %s failed: %s%n", id, t); + FAILURES.putIfAbsent("Task " + id, t); + throw t; + } + }); + } + } + + protected boolean stopAfterFirstFailure() { + return Boolean.getBoolean("jdk.internal.httpclient.debug"); + } + + @BeforeMethod + void beforeMethod(ITestContext context) { + if (stopAfterFirstFailure() && context.getFailedTests().size() > 0) { + throw new RuntimeException("some tests failed"); + } + } + + @AfterClass + static final void printFailedTests() { + out.println("\n========================="); + try { + out.printf("%n%sCreated %d servers and %d clients%n", + now(), serverCount.get(), clientCount.get()); + if (FAILURES.isEmpty()) return; + out.println("Failed tests: "); + FAILURES.entrySet().forEach((e) -> { + out.printf("\t%s: %s%n", e.getKey(), e.getValue()); + e.getValue().printStackTrace(out); + e.getValue().printStackTrace(); + }); + if (tasksFailed) { + out.println("WARNING: Some tasks failed"); + } + } finally { + out.println("\n=========================\n"); + } + } + + /* + * NOT_MODIFIED status code results from a conditional GET where + * the server does not (must not) return a response body because + * the condition specified in the request disallows it + */ + static final int UNAUTHORIZED = 401; + static final int PROXY_UNAUTHORIZED = 407; + static final int HTTP_OK = 200; + static final String MESSAGE = "Unauthorized"; + enum Schemes { + HTTP, HTTPS + } + @DataProvider(name = "all") + public Object[][] positive() { + return new Object[][] { + { Schemes.HTTP, HttpClient.Version.HTTP_1_1, httpURI, true}, + { Schemes.HTTP, HttpClient.Version.HTTP_2, http2URI, true}, + { Schemes.HTTPS, HttpClient.Version.HTTP_1_1, httpsURI, true}, + { Schemes.HTTPS, HttpClient.Version.HTTP_2, https2URI, true}, + { Schemes.HTTP, HttpClient.Version.HTTP_1_1, httpURI, false}, + { Schemes.HTTP, HttpClient.Version.HTTP_2, http2URI, false}, + { Schemes.HTTPS, HttpClient.Version.HTTP_1_1, httpsURI, false}, + { Schemes.HTTPS, HttpClient.Version.HTTP_2, https2URI, false}, + }; + } + + static final AtomicLong requestCounter = new AtomicLong(); + + static final AtomicLong sleepCount = new AtomicLong(); + + @Test(dataProvider = "all") + void test(Schemes scheme, HttpClient.Version version, String uri, boolean async) + throws Throwable + { + var name = String.format("test(%s, %s, %s)", scheme, version, async); + out.printf("%n---- starting %s ----%n", name); + + for (int i=0; i 1) out.printf("---- ITERATION %d%n",i); + try { + doTest(scheme, version, uri, async); + long count = sleepCount.incrementAndGet(); + System.err.println(now() + " Sleeping: " + count); + Thread.sleep(SLEEP_AFTER_TEST); + System.err.println(now() + " Waking up: " + count); + } catch (Throwable x) { + FAILURES.putIfAbsent(name, x); + throw x; + } + } + } + + private HttpResponse send(HttpClient client, + URI uri, + HttpResponse.BodyHandler handler, + boolean async) throws Throwable { + HttpRequest.Builder requestBuilder = HttpRequest + .newBuilder(uri) + .GET(); + + HttpRequest request = requestBuilder.build(); + out.println("Sending request: " + request.uri()); + + HttpResponse response = null; + if (async) { + response = client.send(request, handler); + } else { + try { + response = client.sendAsync(request, handler).get(); + } catch (ExecutionException ex) { + throw ex.getCause(); + } + } + return response; + } + + private void doTest(Schemes scheme, + HttpClient.Version version, + String uriString, + boolean async) throws Throwable { + + URI uri1 = URI.create(uriString + "/server/ProxySelectorTest"); + URI uri2 = URI.create(uriString + "/proxy/noauth/ProxySelectorTest"); + URI uri3 = URI.create(uriString + "/proxy/auth/ProxySelectorTest"); + + HttpResponse response; + + // First request should go with a direct connection. + // A plain server or https server should serve it, and we should get 200 OK + response = send(client, uri1, BodyHandlers.ofString(), async); + out.println("Got response from plain server: " + response); + assertEquals(response.statusCode(), HTTP_OK); + assertEquals(response.headers().firstValue("X-value"), + scheme == Schemes.HTTPS ? Optional.of("https-server") : Optional.of("plain-server")); + + // Second request should go through a non authenticating proxy. + // For a clear connection - a proxy-server should serve it, and we should get 200 OK + // For an https connection - a tunnel should be established through the non + // authenticating proxy - and we should receive 200 OK from an https-server + response = send(client, uri2, BodyHandlers.ofString(), async); + out.println("Got response through noauth proxy: " + response); + assertEquals(response.statusCode(), HTTP_OK); + assertEquals(response.headers().firstValue("X-value"), + scheme == Schemes.HTTPS ? Optional.of("https-server") : Optional.of("proxy-server")); + + // Third request should go through an authenticating proxy. + // For a clear connection - an auth-proxy-server should serve it, and we + // should get 407 + // For an https connection - a tunnel should be established through an + // authenticating proxy - and we should receive 407 directly from the + // proxy - so the X-value header will be absent + response = send(client, uri3, BodyHandlers.ofString(), async); + out.println("Got response through auth proxy: " + response); + assertEquals(response.statusCode(), PROXY_UNAUTHORIZED); + assertEquals(response.headers().firstValue("X-value"), + scheme == Schemes.HTTPS ? Optional.empty() : Optional.of("auth-proxy-server")); + + } + + // -- Infrastructure + + @BeforeTest + public void setup() throws Exception { + sslContext = new SimpleSSLContext().get(); + if (sslContext == null) + throw new AssertionError("Unexpected null sslContext"); + + InetSocketAddress sa = new InetSocketAddress(InetAddress.getLoopbackAddress(), 0); + + httpTestServer = HttpTestServer.of(HttpServer.create(sa, 0)); + httpTestServer.addHandler(new PlainServerHandler("plain-server"), "/http1/"); + httpURI = "http://" + httpTestServer.serverAuthority() + "/http1"; + proxyHttpTestServer = HttpTestServer.of(HttpServer.create(sa, 0)); + proxyHttpTestServer.addHandler(new PlainServerHandler("proxy-server"), "/http1/proxy/"); + proxyHttpTestServer.addHandler(new PlainServerHandler("proxy-server"), "/http2/proxy/"); + proxyHttpURI = "http://" + httpTestServer.serverAuthority() + "/http1"; + authProxyHttpTestServer = HttpTestServer.of(HttpServer.create(sa, 0)); + authProxyHttpTestServer.addHandler(new UnauthorizedHandler("auth-proxy-server"), "/http1/proxy/"); + authProxyHttpTestServer.addHandler(new UnauthorizedHandler("auth-proxy-server"), "/http2/proxy/"); + proxyHttpURI = "http://" + httpTestServer.serverAuthority() + "/http1"; + + HttpsServer httpsServer = HttpsServer.create(sa, 0); + httpsServer.setHttpsConfigurator(new HttpsConfigurator(sslContext)); + httpsTestServer = HttpTestServer.of(httpsServer); + httpsTestServer.addHandler(new PlainServerHandler("https-server"),"/https1/"); + httpsURI = "https://" + httpsTestServer.serverAuthority() + "/https1"; + + http2TestServer = HttpTestServer.of(new Http2TestServer("localhost", false, 0)); + http2TestServer.addHandler(new PlainServerHandler("plain-server"), "/http2/"); + http2URI = "http://" + http2TestServer.serverAuthority() + "/http2"; + https2TestServer = HttpTestServer.of(new Http2TestServer("localhost", true, sslContext)); + https2TestServer.addHandler(new PlainServerHandler("https-server"), "/https2/"); + https2URI = "https://" + https2TestServer.serverAuthority() + "/https2"; + + proxy = DigestEchoServer.createHttpsProxyTunnel(DigestEchoServer.HttpAuthSchemeType.NONE); + authproxy = DigestEchoServer.createHttpsProxyTunnel(DigestEchoServer.HttpAuthSchemeType.BASIC); + + client = TRACKER.track(HttpClient.newBuilder() + .proxy(new TestProxySelector()) + .sslContext(sslContext) + .executor(executor) + .build()); + clientCount.incrementAndGet(); + + + httpTestServer.start(); + serverCount.incrementAndGet(); + proxyHttpTestServer.start(); + serverCount.incrementAndGet(); + authProxyHttpTestServer.start(); + serverCount.incrementAndGet(); + httpsTestServer.start(); + serverCount.incrementAndGet(); + http2TestServer.start(); + serverCount.incrementAndGet(); + https2TestServer.start(); + serverCount.incrementAndGet(); + } + + @AfterTest + public void teardown() throws Exception { + client = null; + Thread.sleep(100); + AssertionError fail = TRACKER.check(500); + + proxy.stop(); + authproxy.stop(); + httpTestServer.stop(); + proxyHttpTestServer.stop(); + authProxyHttpTestServer.stop(); + httpsTestServer.stop(); + http2TestServer.stop(); + https2TestServer.stop(); + } + + class TestProxySelector extends ProxySelector { + @Override + public List select(URI uri) { + String path = uri.getPath(); + out.println("Selecting proxy for: " + uri); + if (path.contains("/proxy/")) { + if (path.contains("/http1/") || path.contains("/http2/")) { + // Simple proxying + var p = path.contains("/auth/") ? authProxyHttpTestServer : proxyHttpTestServer; + return List.of(new Proxy(Proxy.Type.HTTP, p.getAddress())); + } else { + // Both HTTPS or HTTPS/2 require tunnelling + var p = path.contains("/auth/") ? authproxy : proxy; + return List.of(new Proxy(Proxy.Type.HTTP, p.getProxyAddress())); + } + } + System.out.print("NO_PROXY for " + uri); + return List.of(Proxy.NO_PROXY); + } + @Override + public void connectFailed(URI uri, SocketAddress sa, IOException ioe) { + System.err.printf("Connect failed for: uri=\"%s\", sa=\"%s\", ioe=%s%n", uri, sa, ioe); + } + } + + static class PlainServerHandler implements HttpTestHandler { + + final String serverType; + PlainServerHandler(String serverType) { + this.serverType = serverType; + } + + @Override + public void handle(HttpTestExchange t) throws IOException { + readAllRequestData(t); // shouldn't be any + String method = t.getRequestMethod(); + String path = t.getRequestURI().getPath(); + HttpTestRequestHeaders reqh = t.getRequestHeaders(); + HttpTestResponseHeaders rsph = t.getResponseHeaders(); + + String xValue = serverType; + rsph.addHeader("X-value", serverType); + + t.getResponseHeaders().addHeader("X-value", xValue); + byte[] body = "RESPONSE".getBytes(UTF_8); + t.sendResponseHeaders(HTTP_OK, body.length); + try (var out = t.getResponseBody()) { + out.write(body); + } + } + } + + static class UnauthorizedHandler implements HttpTestHandler { + + final String serverType; + UnauthorizedHandler(String serverType) { + this.serverType = serverType; + } + + @Override + public void handle(HttpTestExchange t) throws IOException { + readAllRequestData(t); // shouldn't be any + String method = t.getRequestMethod(); + String path = t.getRequestURI().getPath(); + HttpTestRequestHeaders reqh = t.getRequestHeaders(); + HttpTestResponseHeaders rsph = t.getResponseHeaders(); + + String xValue = serverType; + String srv = path.contains("/proxy/") ? "proxy" : "server"; + String prefix = path.contains("/proxy/") ? "Proxy-" : "WWW-"; + int code = path.contains("/proxy/") ? PROXY_UNAUTHORIZED : UNAUTHORIZED; + String resp = prefix + "Unauthorized"; + rsph.addHeader(prefix + "Authenticate", "Basic realm=\"earth\", charset=\"UTF-8\""); + + byte[] body = resp.getBytes(UTF_8); + t.getResponseHeaders().addHeader("X-value", xValue); + t.sendResponseHeaders(code, body.length); + try (var out = t.getResponseBody()) { + out.write(body); + } + } + } + + static void readAllRequestData(HttpTestExchange t) throws IOException { + try (InputStream is = t.getRequestBody()) { + is.readAllBytes(); + } + } +} diff --git a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/ConnectionPoolTest.java b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/ConnectionPoolTest.java index 5d30b19562b..6c97e3d831a 100644 --- a/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/ConnectionPoolTest.java +++ b/test/jdk/java/net/httpclient/whitebox/java.net.http/jdk/internal/net/http/ConnectionPoolTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 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 @@ -481,6 +481,7 @@ public class ConnectionPoolTest { @Override boolean connected() {return !closed;} @Override boolean isSecure() {return secured;} @Override boolean isProxied() {return proxy!=null;} + @Override InetSocketAddress proxy() { return proxy; } @Override ConnectionPool.CacheKey cacheKey() {return key;} @Override FlowTube getConnectionFlow() {return flow;} @Override SocketChannel channel() {return channel;} From b24c0d21ee0b6cdfa3a7bb76cb6a8bd7ac5a130d Mon Sep 17 00:00:00 2001 From: Leonid Mesnik Date: Wed, 6 May 2020 11:58:41 -0700 Subject: [PATCH 61/88] 8244267: Improve serviceability task definitions in CI Reviewed-by: cjplummer, sspitsyn --- test/hotspot/jtreg/TEST.groups | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/hotspot/jtreg/TEST.groups b/test/hotspot/jtreg/TEST.groups index bcd942aa21a..d92dbd7570f 100644 --- a/test/hotspot/jtreg/TEST.groups +++ b/test/hotspot/jtreg/TEST.groups @@ -377,17 +377,15 @@ hotspot_appcds_with_jfr = \ -runtime/cds/appcds/jigsaw/modulepath/MainModuleOnly.java tier1_serviceability = \ - serviceability/dcmd/compiler \ + serviceability/ \ -serviceability/dcmd/compiler/CompilerQueueTest.java \ - serviceability/jvmti/RedefineClasses \ -serviceability/jvmti/RedefineClasses/RedefineLeak.java \ -serviceability/jvmti/RedefineClasses/RedefinePreviousVersions.java \ -serviceability/jvmti/RedefineClasses/RedefineRunningMethods.java \ -serviceability/jvmti/RedefineClasses/RedefineRunningMethodsWithBacktrace.java \ -serviceability/jvmti/RedefineClasses/TestRedefineObject.java \ - serviceability/logging \ - serviceability/sa \ -serviceability/sa/ClhsdbScanOops.java \ + -serviceability/sa/ClhsdbJstackXcompStress.java \ -serviceability/sa/TestJmapCore.java \ -serviceability/sa/TestJmapCoreMetaspace.java From d2e63399923159ac5ab55d3a2d592ee8a62df673 Mon Sep 17 00:00:00 2001 From: Jayashree Sk1 Date: Wed, 6 May 2020 12:48:32 -0700 Subject: [PATCH 62/88] 6415694: Clarification in Javadoc for java.rmi.AlreadyBoundException Reviewed-by: rriggs --- .../share/classes/java/rmi/AlreadyBoundException.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/java.rmi/share/classes/java/rmi/AlreadyBoundException.java b/src/java.rmi/share/classes/java/rmi/AlreadyBoundException.java index e24524c8b94..82d5db01ec0 100644 --- a/src/java.rmi/share/classes/java/rmi/AlreadyBoundException.java +++ b/src/java.rmi/share/classes/java/rmi/AlreadyBoundException.java @@ -26,8 +26,8 @@ package java.rmi; /** * An AlreadyBoundException is thrown if an attempt - * is made to bind an object in the registry to a name that already - * has an associated binding. + * is made to bind an object to a name that already + * has an associated binding in the registry. * * @since 1.1 * @author Ann Wollrath From 0cf828153cf8ee337645645b0632e77b8733a734 Mon Sep 17 00:00:00 2001 From: Zhengyu Gu Date: Wed, 6 May 2020 16:02:10 -0400 Subject: [PATCH 63/88] 8241086: Test runtime/NMT/HugeArenaTracking.java is failing on 32bit Windows Reviewed-by: stuefe --- test/hotspot/jtreg/runtime/NMT/HugeArenaTracking.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/hotspot/jtreg/runtime/NMT/HugeArenaTracking.java b/test/hotspot/jtreg/runtime/NMT/HugeArenaTracking.java index e55c27a2a8f..c322ab83ca5 100644 --- a/test/hotspot/jtreg/runtime/NMT/HugeArenaTracking.java +++ b/test/hotspot/jtreg/runtime/NMT/HugeArenaTracking.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Red Hat, Inc. All rights reserved. + * Copyright (c) 2019, 2020, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,6 +26,7 @@ * @test * @key nmt jcmd randomness * @library /test/lib + * @requires vm.bits == 64 * @modules java.base/jdk.internal.misc * java.management * @build sun.hotspot.WhiteBox From 6a9d0579ca37da8e80b56dedae0804b9828dc225 Mon Sep 17 00:00:00 2001 From: Volker Simonis Date: Wed, 6 May 2020 22:06:16 +0200 Subject: [PATCH 64/88] 8244094: Fix Amazon copyright in various test files Reviewed-by: phh --- .../jdk/java/lang/RuntimeTests/loadLibrary/LoadLibraryTest.java | 2 +- test/jdk/java/text/Format/DateFormat/Bug8235699.java | 2 +- .../DateFormat/java.base/java/text/CalendarBuilderTest.java | 2 +- test/jdk/jdk/nio/zipfs/ReleaseDeflater.java | 2 +- test/micro/org/openjdk/bench/java/util/zip/Streams.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/jdk/java/lang/RuntimeTests/loadLibrary/LoadLibraryTest.java b/test/jdk/java/lang/RuntimeTests/loadLibrary/LoadLibraryTest.java index f08c60dfa3a..720bc1ac612 100644 --- a/test/jdk/java/lang/RuntimeTests/loadLibrary/LoadLibraryTest.java +++ b/test/jdk/java/lang/RuntimeTests/loadLibrary/LoadLibraryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Amazon and/or its affiliates. All rights reserved. + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * Copyright (c) 2019, Azul Systems, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/test/jdk/java/text/Format/DateFormat/Bug8235699.java b/test/jdk/java/text/Format/DateFormat/Bug8235699.java index ea6ad05f3eb..4abea150da7 100644 --- a/test/jdk/java/text/Format/DateFormat/Bug8235699.java +++ b/test/jdk/java/text/Format/DateFormat/Bug8235699.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Amazon and/or its affiliates. All rights reserved. + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/test/jdk/java/text/Format/DateFormat/java.base/java/text/CalendarBuilderTest.java b/test/jdk/java/text/Format/DateFormat/java.base/java/text/CalendarBuilderTest.java index b6007b3218e..51e60497053 100644 --- a/test/jdk/java/text/Format/DateFormat/java.base/java/text/CalendarBuilderTest.java +++ b/test/jdk/java/text/Format/DateFormat/java.base/java/text/CalendarBuilderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Amazon and/or its affiliates. All rights reserved. + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/test/jdk/jdk/nio/zipfs/ReleaseDeflater.java b/test/jdk/jdk/nio/zipfs/ReleaseDeflater.java index 2f90235edc4..82369b4fe39 100644 --- a/test/jdk/jdk/nio/zipfs/ReleaseDeflater.java +++ b/test/jdk/jdk/nio/zipfs/ReleaseDeflater.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/test/micro/org/openjdk/bench/java/util/zip/Streams.java b/test/micro/org/openjdk/bench/java/util/zip/Streams.java index 46d1b7822e8..50a8f072ca5 100644 --- a/test/micro/org/openjdk/bench/java/util/zip/Streams.java +++ b/test/micro/org/openjdk/bench/java/util/zip/Streams.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Amazon and/or its affiliates. All rights reserved. + * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it From b0f7ebc26b00fb4d54ffe20db32b864874478930 Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Wed, 6 May 2020 14:20:35 -0700 Subject: [PATCH 65/88] 8244542: ProblemList cds/DeterministicDump.java for Windows Reviewed-by: ccheung --- test/hotspot/jtreg/ProblemList.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index 457bd05491f..429afc335e5 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -95,6 +95,7 @@ gc/metaspace/CompressedClassSpaceSizeInJmapHeap.java 8241293 macosx-x64 runtime/jni/terminatedThread/TestTerminatedThread.java 8219652 aix-ppc64 runtime/ReservedStack/ReservedStackTest.java 8231031 generic-all +runtime/cds/DeterministicDump.java 8244536 windows-all ############################################################################# From 28f6cd5917ada73a60e0ffd271ba8ff7f0cb54c1 Mon Sep 17 00:00:00 2001 From: Jesper Wilhelmsson Date: Thu, 7 May 2020 02:45:49 +0200 Subject: [PATCH 66/88] Added tag jdk-15+22 for changeset 7223c6d61034 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index b013607d06a..aef3a9b21aa 100644 --- a/.hgtags +++ b/.hgtags @@ -632,3 +632,4 @@ dd5198db2e5b1ebcafe065d987c03ba9fcb50fc3 jdk-15+17 7cc27caabe6e342151e8baf549beb07a9c755ec2 jdk-15+19 46bca5e5e6fb26efd07245d26fe96a9c3260f51e jdk-15+20 12b55fad80f30d24b1f8fdb3b947ea6465ef9518 jdk-15+21 +7223c6d610343fd8323af9d07d501e01fa1a7696 jdk-15+22 From 6dd84434934544542137f7b7567158e067e68590 Mon Sep 17 00:00:00 2001 From: Erik Gahlin Date: Thu, 7 May 2020 03:18:49 +0200 Subject: [PATCH 67/88] 8243452: JFR: Could not create chunk in repository with over 200 recordings Reviewed-by: mgronlun --- src/jdk.jfr/share/classes/jdk/jfr/internal/Repository.java | 2 +- src/jdk.jfr/share/classes/jdk/jfr/internal/RepositoryChunk.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/Repository.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/Repository.java index c33693db0eb..258b5bf52fa 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/Repository.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/Repository.java @@ -87,7 +87,7 @@ public final class Repository { } return new RepositoryChunk(repository, timestamp); } catch (Exception e) { - String errorMsg = String.format("Could not create chunk in repository %s, %s", repository, e.getMessage()); + String errorMsg = String.format("Could not create chunk in repository %s, %s: %s", repository, e.getClass(), e.getMessage()); Logger.log(LogTag.JFR, LogLevel.ERROR, errorMsg); jvm.abort(errorMsg); throw new InternalError("Could not abort after JFR disk creation error"); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/RepositoryChunk.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/RepositoryChunk.java index 66e3aed14cc..b8e23b049f5 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/RepositoryChunk.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/RepositoryChunk.java @@ -75,7 +75,7 @@ final class RepositoryChunk { p = directory.toPath().resolve(extendedName); } p = directory.toPath().resolve(filename + "_" + System.currentTimeMillis() + FILE_EXTENSION); - return SecuritySupport.toRealPath(new SafePath(p)); + return new SafePath(p); } void finish(Instant endTime) { From 0ef6d1dff53d0ba2c2cd710c82b33266f0caa02d Mon Sep 17 00:00:00 2001 From: Yumin Qi Date: Wed, 6 May 2020 19:43:57 -0700 Subject: [PATCH 68/88] 8244495: Some jlink tests crash on Windows after JDK-8237750 Fix of 8237750 changed the loading zip library to on-demand loading, on Windows, jlink/jimage still assume that zip has been loaded already. Fix to load zip on not loaded. Reviewed-by: kbarrett, mchung, dholmes, dcubed --- src/java.base/share/native/libjimage/imageDecompressor.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/java.base/share/native/libjimage/imageDecompressor.cpp b/src/java.base/share/native/libjimage/imageDecompressor.cpp index 9ef7dce3306..5deebe350f7 100644 --- a/src/java.base/share/native/libjimage/imageDecompressor.cpp +++ b/src/java.base/share/native/libjimage/imageDecompressor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -61,7 +61,10 @@ static void* findEntry(const char* name) { #ifdef WIN32 HMODULE handle = GetModuleHandle("zip.dll"); if (handle == NULL) { - return NULL; + handle = LoadLibrary("zip.dll"); + } + if (handle == NULL) { + return NULL; } addr = (void*) GetProcAddress(handle, name); return addr; From 76507eef639c41bffe9a4bb2b8a5083291f41383 Mon Sep 17 00:00:00 2001 From: Hai-May Chao Date: Thu, 7 May 2020 10:48:06 +0800 Subject: [PATCH 69/88] 8242060: Add revocation checking to jarsigner Reviewed-by: mullan, weijun --- .../certpath/DistributionPointFetcher.java | 5 +- .../sun/security/provider/certpath/OCSP.java | 5 +- .../classes/sun/security/util/Event.java | 58 ++++++++++++ .../sun/security/tools/jarsigner/Main.java | 15 ++- .../security/tools/jarsigner/Resources.java | 4 + .../tools/jarsigner/EnableRevocation.java | 93 +++++++++++++++++++ .../sun/security/util/Resources/Usages.java | 9 +- 7 files changed, 185 insertions(+), 4 deletions(-) create mode 100644 src/java.base/share/classes/sun/security/util/Event.java create mode 100644 test/jdk/sun/security/tools/jarsigner/EnableRevocation.java diff --git a/src/java.base/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java b/src/java.base/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java index 5715842beef..3fe104c6ff9 100644 --- a/src/java.base/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java +++ b/src/java.base/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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 @@ -33,6 +33,7 @@ import javax.security.auth.x500.X500Principal; import java.util.*; import sun.security.util.Debug; +import sun.security.util.Event; import sun.security.validator.Validator; import static sun.security.x509.PKIXExtensions.*; import sun.security.x509.*; @@ -246,6 +247,8 @@ public class DistributionPointFetcher { if (debug != null) { debug.println("Trying to fetch CRL from DP " + uri); } + + Event.report("event.crl.check", uri.toString()); CertStore ucs = null; try { ucs = URICertStore.getInstance(new URICertStoreParameters(uri)); diff --git a/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java b/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java index dce73028cd0..1b9e8f9dea8 100644 --- a/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java +++ b/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -45,6 +45,7 @@ import java.util.Map; import sun.security.action.GetIntegerAction; import sun.security.util.Debug; +import sun.security.util.Event; import sun.security.validator.Validator; import sun.security.x509.AccessDescription; import sun.security.x509.AuthorityInfoAccessExtension; @@ -232,6 +233,8 @@ public final class OCSP { if (debug != null) { debug.println("connecting to OCSP service at: " + url); } + + Event.report("event.ocsp.check", url.toString()); HttpURLConnection con = (HttpURLConnection)url.openConnection(); con.setConnectTimeout(CONNECT_TIMEOUT); con.setReadTimeout(CONNECT_TIMEOUT); diff --git a/src/java.base/share/classes/sun/security/util/Event.java b/src/java.base/share/classes/sun/security/util/Event.java new file mode 100644 index 00000000000..70b0d88d215 --- /dev/null +++ b/src/java.base/share/classes/sun/security/util/Event.java @@ -0,0 +1,58 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.security.util; + +/** + * This class implements an event model with services for reporter and listener. + * Reporter uses report() method to generate an event. + * Listener uses setReportListener() to register for listening to an event, + * and uses clearReportListener() to unregister a listening session. + * Listener should implement the event handling of the Reporter interface. + */ +public final class Event { + private Event() {} + + public interface Reporter { + public void handle(String type, Object... args); + } + + private static Reporter reporter; + public static void setReportListener(Reporter re) { + reporter = re; + } + + public static void clearReportListener() { + reporter = null; + } + + public static void report(String type, Object... args) { + Reporter currentReporter = reporter; + + if (currentReporter != null) { + currentReporter.handle(type, args); + } + } +} diff --git a/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java b/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java index 6ae3e484a3f..d56433d3983 100644 --- a/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java +++ b/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java @@ -158,6 +158,7 @@ public class Main { boolean signManifest = true; // "sign" the whole manifest boolean externalSF = true; // leave the .SF out of the PKCS7 block boolean strict = false; // treat warnings as error + boolean revocationCheck = false; // Revocation check flag // read zip entry raw bytes private String altSignerClass = null; @@ -293,6 +294,7 @@ public class Main { Arrays.fill(storepass, ' '); storepass = null; } + Event.clearReportListener(); } if (strict) { @@ -484,6 +486,8 @@ public class Main { // -help: legacy. collator.compare(flags, "-help") == 0) { fullusage(); + } else if (collator.compare(flags, "-revCheck") == 0) { + revocationCheck = true; } else { System.err.println( rb.getString("Illegal.option.") + flags); @@ -626,6 +630,9 @@ public class Main { System.out.println(rb.getString (".certs.display.certificates.when.verbose.and.verifying")); System.out.println(); + System.out.println(rb.getString + (".certs.revocation.check")); + System.out.println(); System.out.println(rb.getString (".tsa.url.location.of.the.Timestamping.Authority")); System.out.println(); @@ -2053,7 +2060,13 @@ public class Main { .map(c -> new TrustAnchor(c, null)) .collect(Collectors.toSet()), null); - pkixParameters.setRevocationEnabled(false); + + if (revocationCheck) { + Security.setProperty("ocsp.enable", "true"); + System.setProperty("com.sun.security.enableCRLDP", "true"); + Event.setReportListener((t, o) -> System.out.println(String.format(rb.getString(t), o))); + } + pkixParameters.setRevocationEnabled(revocationCheck); } catch (InvalidAlgorithmParameterException ex) { // Only if tas is empty } diff --git a/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Resources.java b/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Resources.java index bf2052589c9..adb314189c0 100644 --- a/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Resources.java +++ b/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Resources.java @@ -83,6 +83,8 @@ public class Resources extends java.util.ListResourceBundle { " suboptions can be all, grouped or summary"}, {".certs.display.certificates.when.verbose.and.verifying", "[-certs] display certificates when verbose and verifying"}, + {".certs.revocation.check", + "[-revCheck] Enable certificate revocation check"}, {".tsa.url.location.of.the.Timestamping.Authority", "[-tsa ] location of the Timestamping Authority"}, {".tsacert.alias.public.key.certificate.for.Timestamping.Authority", @@ -310,6 +312,8 @@ public class Resources extends java.util.ListResourceBundle { {"Cannot.find.environment.variable.", "Cannot find environment variable: "}, {"Cannot.find.file.", "Cannot find file: "}, + {"event.ocsp.check", "Contacting OCSP server at %s ..."}, + {"event.crl.check", "Downloading CRL from %s ..."}, }; /** diff --git a/test/jdk/sun/security/tools/jarsigner/EnableRevocation.java b/test/jdk/sun/security/tools/jarsigner/EnableRevocation.java new file mode 100644 index 00000000000..2af1ef7c381 --- /dev/null +++ b/test/jdk/sun/security/tools/jarsigner/EnableRevocation.java @@ -0,0 +1,93 @@ +/* + * 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 8242060 + * @summary Add a test to enable revocation check in jarsigner + * @library /test/lib + */ + +import jdk.test.lib.SecurityTools; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.util.JarUtils; + +import java.nio.file.Path; + +public class EnableRevocation { + + static OutputAnalyzer kt(String cmd, String ks) throws Exception { + return SecurityTools.keytool("-storepass changeit " + cmd + + " -keystore " + ks); + } + + static void gencert(String owner, String cmd) throws Exception { + kt("-certreq -alias " + owner + " -file tmp.req", "ks"); + kt("-gencert -infile tmp.req -outfile tmp.cert " + cmd, "ks"); + kt("-importcert -alias " + owner + " -file tmp.cert", "ks"); + } + + public static void main(String[] args) throws Exception { + + kt("-genkeypair -keyalg rsa -alias ca -dname CN=CA -ext bc:c", "ks"); + kt("-genkeypair -keyalg rsa -alias ca1 -dname CN=CA1", "ks"); + kt("-genkeypair -keyalg rsa -alias e1 -dname CN=E1", "ks"); + + gencert("ca1", "-alias ca -ext san=dns:ca1 -ext bc:c " + + "-ext crldp=URI:http://localhost:7000/crl.pem " + + "-ext aia=ocsp:URI:http://localhost:7200"); + + gencert("e1", "-alias ca1 -ext san=dns:e1 " + + "-ext crldp=URI:http://localhost:7000/crl.pem " + + "-ext aia=ocsp:URI:http://localhost:7100"); + + JarUtils.createJarFile(Path.of("a.jar"), Path.of("."), Path.of("ks")); + + //Signing with -revCheck option + SecurityTools.jarsigner("-keystore ks -storepass changeit " + + "-signedjar signeda.jar " + + "-sigalg SHA256withRSA " + + " a.jar e1 -revCheck") + .shouldContain("Contacting OCSP server at") + .shouldContain("Downloading CRL from") + .shouldHaveExitValue(0); + + kt("-exportcert -alias ca -rfc -file cacert", "ks"); + kt("-importcert -noprompt -file cacert", "caks"); + + // Verifying with -revCheck option + SecurityTools.jarsigner("-verify -certs signeda.jar " + + "-keystore caks -storepass changeit -verbose -debug -revCheck") + .shouldContain("Contacting OCSP server at") + .shouldContain("Downloading CRL from") + .shouldHaveExitValue(0); + + // Verifying with -revCheck and -strict options + SecurityTools.jarsigner("-verify -certs signeda.jar " + + "-keystore caks -storepass changeit " + + "-strict -verbose -debug -revCheck") + .shouldContain("Contacting OCSP server at") + .shouldContain("Downloading CRL from") + .shouldHaveExitValue(4); + } +} diff --git a/test/jdk/sun/security/util/Resources/Usages.java b/test/jdk/sun/security/util/Resources/Usages.java index d0d58780859..76d83f9b9e6 100644 --- a/test/jdk/sun/security/util/Resources/Usages.java +++ b/test/jdk/sun/security/util/Resources/Usages.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 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 @@ -74,6 +74,9 @@ public class Usages { static Pattern RB_GETSTRING = Pattern.compile( "(?m)rb[ \\n]*\\.getString[ \\n]*\\([ \\n]*\"(.*?)\"\\)"); + static Pattern EVENT_OCSP_CRL = Pattern.compile( + "Event\\.report\\(\"(.*?)\","); + // Command and Option enums in keytool static Pattern KT_ENUM = Pattern.compile("\\n +[A-Z]+\\(.*\"(.*)\""); @@ -116,6 +119,10 @@ public class Usages { new sun.security.tools.jarsigner.Resources(), List.of( new Pair("jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java", List.of(RB_GETSTRING)), + new Pair("java.base/share/classes/sun/security/provider/certpath/OCSP.java", + List.of(EVENT_OCSP_CRL)), + new Pair("java.base/share/classes/sun/security/provider/certpath/DistributionPointFetcher.java", + List.of(EVENT_OCSP_CRL)), new Pair("java.base/share/classes/sun/security/tools/KeyStoreUtil.java", List.of(RB_GETSTRING))), new sun.security.util.Resources(), List.of( From 2f9cfb11785154ebad8af57dbf64b6a74cbe8661 Mon Sep 17 00:00:00 2001 From: Roman Kennke Date: Wed, 6 May 2020 16:09:24 +0200 Subject: [PATCH 70/88] 8244523: Shenandoah: Remove null-handling in LRB expansion Reviewed-by: shade, roland --- .../shenandoah/c2/shenandoahBarrierSetC2.cpp | 34 ++- .../shenandoah/c2/shenandoahBarrierSetC2.hpp | 4 +- .../gc/shenandoah/c2/shenandoahSupport.cpp | 287 +----------------- .../gc/shenandoah/c2/shenandoahSupport.hpp | 4 - 4 files changed, 44 insertions(+), 285 deletions(-) diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp index 13f39fe9fba..6e582518751 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp @@ -481,16 +481,16 @@ const TypeFunc* ShenandoahBarrierSetC2::shenandoah_clone_barrier_Type() { return TypeFunc::make(domain, range); } -const TypeFunc* ShenandoahBarrierSetC2::shenandoah_load_reference_barrier_Type() { +const TypeFunc* ShenandoahBarrierSetC2::shenandoah_load_reference_barrier_Type(const Type* value_type) { const Type **fields = TypeTuple::fields(2); - fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // original field value + fields[TypeFunc::Parms+0] = value_type; // original field value fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // original load address const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields); // create result type (range) fields = TypeTuple::fields(1); - fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; + fields[TypeFunc::Parms+0] = value_type; const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields); return TypeFunc::make(domain, range); @@ -1045,6 +1045,20 @@ void ShenandoahBarrierSetC2::verify_gc_barriers(Compile* compile, CompilePhase p } #endif +bool ShenandoahBarrierSetC2::maybe_skip_barrier(Node* n, uint i, PhaseGVN* phase) const { + PhaseIterGVN* igvn = phase->is_IterGVN(); + Node* in = step_over_gc_barrier(n->in(i)); + if (in != n->in(i)) { + if (igvn != NULL) { + n->set_req_X(i, in, igvn); + } else { + n->set_req(i, in); + } + return true; + } + return false; +} + Node* ShenandoahBarrierSetC2::ideal_node(PhaseGVN* phase, Node* n, bool can_reshape) const { if (is_shenandoah_wb_pre_call(n)) { uint cnt = ShenandoahBarrierSetC2::write_ref_field_pre_entry_Type()->domain()->cnt(); @@ -1086,6 +1100,20 @@ Node* ShenandoahBarrierSetC2::ideal_node(PhaseGVN* phase, Node* n, bool can_resh } return n; } + } else if (n->Opcode() == Op_CallStaticJava) { + if (n->as_CallStaticJava()->uncommon_trap_request() != 0) { + // Uncommon traps don't need barriers, values are handled + // during deoptimization. It also affects optimizing null-checks + // into implicit null-checks. + PhaseIterGVN* igvn = phase->is_IterGVN(); + Node* ret = NULL; + for (uint i = TypeFunc::Parms; i < n->len(); i++) { + if (maybe_skip_barrier(n, i, phase)) { + ret = n; + } + } + return ret; + } } else if (can_reshape && n->Opcode() == Op_If && ShenandoahBarrierC2Support::is_heap_stable_test(n) && diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp index db494012805..35899d14469 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp @@ -81,6 +81,8 @@ private: static bool clone_needs_barrier(Node* src, PhaseGVN& gvn); + bool maybe_skip_barrier(Node* n, uint i, PhaseGVN* phase) const; + protected: virtual Node* load_at_resolved(C2Access& access, const Type* val_type) const; virtual Node* store_at_resolved(C2Access& access, C2AccessValue& val) const; @@ -103,7 +105,7 @@ public: static const TypeFunc* write_ref_field_pre_entry_Type(); static const TypeFunc* shenandoah_clone_barrier_Type(); - static const TypeFunc* shenandoah_load_reference_barrier_Type(); + static const TypeFunc* shenandoah_load_reference_barrier_Type(const Type* value_type); virtual bool has_load_barrier_nodes() const { return true; } // This is the entry-point for the backend to perform accesses through the Access API. diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp index c7766cc02e4..2bed0341502 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp @@ -909,76 +909,6 @@ void ShenandoahBarrierC2Support::test_null(Node*& ctrl, Node* val, Node*& null_c } } -Node* ShenandoahBarrierC2Support::clone_null_check(Node*& c, Node* val, Node* unc_ctrl, PhaseIdealLoop* phase) { - IdealLoopTree *loop = phase->get_loop(c); - Node* iff = unc_ctrl->in(0); - assert(iff->is_If(), "broken"); - Node* new_iff = iff->clone(); - new_iff->set_req(0, c); - phase->register_control(new_iff, loop, c); - Node* iffalse = new IfFalseNode(new_iff->as_If()); - phase->register_control(iffalse, loop, new_iff); - Node* iftrue = new IfTrueNode(new_iff->as_If()); - phase->register_control(iftrue, loop, new_iff); - c = iftrue; - const Type *t = phase->igvn().type(val); - assert(val->Opcode() == Op_CastPP, "expect cast to non null here"); - Node* uncasted_val = val->in(1); - val = new CastPPNode(uncasted_val, t); - val->init_req(0, c); - phase->register_new_node(val, c); - return val; -} - -void ShenandoahBarrierC2Support::fix_null_check(Node* unc, Node* unc_ctrl, Node* new_unc_ctrl, - Unique_Node_List& uses, PhaseIdealLoop* phase) { - IfNode* iff = unc_ctrl->in(0)->as_If(); - Node* proj = iff->proj_out(0); - assert(proj != unc_ctrl, "bad projection"); - Node* use = proj->unique_ctrl_out(); - - assert(use == unc || use->is_Region(), "what else?"); - - uses.clear(); - if (use == unc) { - phase->set_idom(use, new_unc_ctrl, phase->dom_depth(use)); - for (uint i = 1; i < unc->req(); i++) { - Node* n = unc->in(i); - if (phase->has_ctrl(n) && phase->get_ctrl(n) == proj) { - uses.push(n); - } - } - } else { - assert(use->is_Region(), "what else?"); - uint idx = 1; - for (; use->in(idx) != proj; idx++); - for (DUIterator_Fast imax, i = use->fast_outs(imax); i < imax; i++) { - Node* u = use->fast_out(i); - if (u->is_Phi() && phase->get_ctrl(u->in(idx)) == proj) { - uses.push(u->in(idx)); - } - } - } - for(uint next = 0; next < uses.size(); next++ ) { - Node *n = uses.at(next); - assert(phase->get_ctrl(n) == proj, "bad control"); - phase->set_ctrl_and_loop(n, new_unc_ctrl); - if (n->in(0) == proj) { - phase->igvn().replace_input_of(n, 0, new_unc_ctrl); - } - for (uint i = 0; i < n->req(); i++) { - Node* m = n->in(i); - if (m != NULL && phase->has_ctrl(m) && phase->get_ctrl(m) == proj) { - uses.push(m); - } - } - } - - phase->igvn().rehash_node_delayed(use); - int nb = use->replace_edge(proj, new_unc_ctrl); - assert(nb == 1, "only use expected"); -} - void ShenandoahBarrierC2Support::in_cset_fast_test(Node*& ctrl, Node*& not_cset_ctrl, Node* val, Node* raw_mem, PhaseIdealLoop* phase) { IdealLoopTree *loop = phase->get_loop(ctrl); Node* raw_rbtrue = new CastP2XNode(ctrl, val); @@ -1026,7 +956,7 @@ void ShenandoahBarrierC2Support::call_lrb_stub(Node*& ctrl, Node*& val, Node* lo address calladdr = is_native ? CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_native) : target; const char* name = is_native ? "load_reference_barrier_native" : "load_reference_barrier"; - Node* call = new CallLeafNode(ShenandoahBarrierSetC2::shenandoah_load_reference_barrier_Type(), calladdr, name, TypeRawPtr::BOTTOM); + Node* call = new CallLeafNode(ShenandoahBarrierSetC2::shenandoah_load_reference_barrier_Type(obj_type), calladdr, name, TypeRawPtr::BOTTOM); call->init_req(TypeFunc::Control, ctrl); call->init_req(TypeFunc::I_O, phase->C->top()); @@ -1042,8 +972,6 @@ void ShenandoahBarrierC2Support::call_lrb_stub(Node*& ctrl, Node*& val, Node* lo phase->register_new_node(result_mem, call); val = new ProjNode(call, TypeFunc::Parms); phase->register_new_node(val, call); - val = new CheckCastPPNode(ctrl, val, obj_type); - phase->register_new_node(val, ctrl); } void ShenandoahBarrierC2Support::fix_ctrl(Node* barrier, Node* region, const MemoryGraphFixer& fixer, Unique_Node_List& uses, Unique_Node_List& uses_to_ignore, uint last, PhaseIdealLoop* phase) { @@ -1149,119 +1077,6 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) { } Node* ctrl = phase->get_ctrl(lrb); - Node* val = lrb->in(ShenandoahLoadReferenceBarrierNode::ValueIn); - - CallStaticJavaNode* unc = NULL; - Node* unc_ctrl = NULL; - Node* uncasted_val = val; - - for (DUIterator_Fast imax, i = lrb->fast_outs(imax); i < imax; i++) { - Node* u = lrb->fast_out(i); - if (u->Opcode() == Op_CastPP && - u->in(0) != NULL && - phase->is_dominator(u->in(0), ctrl)) { - const Type* u_t = phase->igvn().type(u); - - if (u_t->meet(TypePtr::NULL_PTR) != u_t && - u->in(0)->Opcode() == Op_IfTrue && - u->in(0)->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none) && - u->in(0)->in(0)->is_If() && - u->in(0)->in(0)->in(1)->Opcode() == Op_Bool && - u->in(0)->in(0)->in(1)->as_Bool()->_test._test == BoolTest::ne && - u->in(0)->in(0)->in(1)->in(1)->Opcode() == Op_CmpP && - u->in(0)->in(0)->in(1)->in(1)->in(1) == val && - u->in(0)->in(0)->in(1)->in(1)->in(2)->bottom_type() == TypePtr::NULL_PTR) { - IdealLoopTree* loop = phase->get_loop(ctrl); - IdealLoopTree* unc_loop = phase->get_loop(u->in(0)); - - if (!unc_loop->is_member(loop)) { - continue; - } - - Node* branch = no_branches(ctrl, u->in(0), false, phase); - assert(branch == NULL || branch == NodeSentinel, "was not looking for a branch"); - if (branch == NodeSentinel) { - continue; - } - - phase->igvn().replace_input_of(u, 1, val); - phase->igvn().replace_input_of(lrb, ShenandoahLoadReferenceBarrierNode::ValueIn, u); - phase->set_ctrl(u, u->in(0)); - phase->set_ctrl(lrb, u->in(0)); - unc = u->in(0)->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none); - unc_ctrl = u->in(0); - val = u; - - for (DUIterator_Fast jmax, j = val->fast_outs(jmax); j < jmax; j++) { - Node* u = val->fast_out(j); - if (u == lrb) continue; - phase->igvn().rehash_node_delayed(u); - int nb = u->replace_edge(val, lrb); - --j; jmax -= nb; - } - - RegionNode* r = new RegionNode(3); - IfNode* iff = unc_ctrl->in(0)->as_If(); - - Node* ctrl_use = unc_ctrl->unique_ctrl_out(); - Node* unc_ctrl_clone = unc_ctrl->clone(); - phase->register_control(unc_ctrl_clone, loop, iff); - Node* c = unc_ctrl_clone; - Node* new_cast = clone_null_check(c, val, unc_ctrl_clone, phase); - r->init_req(1, new_cast->in(0)->in(0)->as_If()->proj_out(0)); - - phase->igvn().replace_input_of(unc_ctrl, 0, c->in(0)); - phase->set_idom(unc_ctrl, c->in(0), phase->dom_depth(unc_ctrl)); - phase->lazy_replace(c, unc_ctrl); - c = NULL;; - phase->igvn().replace_input_of(val, 0, unc_ctrl_clone); - phase->set_ctrl(val, unc_ctrl_clone); - - IfNode* new_iff = new_cast->in(0)->in(0)->as_If(); - fix_null_check(unc, unc_ctrl_clone, r, uses, phase); - Node* iff_proj = iff->proj_out(0); - r->init_req(2, iff_proj); - phase->register_control(r, phase->ltree_root(), iff); - - Node* new_bol = new_iff->in(1)->clone(); - Node* new_cmp = new_bol->in(1)->clone(); - assert(new_cmp->Opcode() == Op_CmpP, "broken"); - assert(new_cmp->in(1) == val->in(1), "broken"); - new_bol->set_req(1, new_cmp); - new_cmp->set_req(1, lrb); - phase->register_new_node(new_bol, new_iff->in(0)); - phase->register_new_node(new_cmp, new_iff->in(0)); - phase->igvn().replace_input_of(new_iff, 1, new_bol); - phase->igvn().replace_input_of(new_cast, 1, lrb); - - for (DUIterator_Fast imax, i = lrb->fast_outs(imax); i < imax; i++) { - Node* u = lrb->fast_out(i); - if (u == new_cast || u == new_cmp) { - continue; - } - phase->igvn().rehash_node_delayed(u); - int nb = u->replace_edge(lrb, new_cast); - assert(nb > 0, "no update?"); - --i; imax -= nb; - } - - for (DUIterator_Fast imax, i = val->fast_outs(imax); i < imax; i++) { - Node* u = val->fast_out(i); - if (u == lrb) { - continue; - } - phase->igvn().rehash_node_delayed(u); - int nb = u->replace_edge(val, new_cast); - assert(nb > 0, "no update?"); - --i; imax -= nb; - } - - ctrl = unc_ctrl_clone; - phase->set_ctrl_and_loop(lrb, ctrl); - break; - } - } - } if ((ctrl->is_Proj() && ctrl->in(0)->is_CallJava()) || ctrl->is_CallJava()) { CallNode* call = ctrl->is_Proj() ? ctrl->in(0)->as_CallJava() : ctrl->as_CallJava(); if (call->entry_point() == OptoRuntime::rethrow_stub()) { @@ -1402,90 +1217,45 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) { Node* ctrl = phase->get_ctrl(lrb); Node* val = lrb->in(ShenandoahLoadReferenceBarrierNode::ValueIn); - Node* orig_ctrl = ctrl; Node* raw_mem = fixer.find_mem(ctrl, lrb); Node* init_raw_mem = raw_mem; Node* raw_mem_for_ctrl = fixer.find_mem(ctrl, NULL); - IdealLoopTree *loop = phase->get_loop(ctrl); - CallStaticJavaNode* unc = lrb->pin_and_expand_null_check(phase->igvn()); - Node* unc_ctrl = NULL; - if (unc != NULL) { - if (val->in(ShenandoahLoadReferenceBarrierNode::Control) != ctrl) { - unc = NULL; - } else { - unc_ctrl = val->in(ShenandoahLoadReferenceBarrierNode::Control); - } - } - - Node* uncasted_val = val; - if (unc != NULL) { - uncasted_val = val->in(1); - } - - Node* heap_stable_ctrl = NULL; - Node* null_ctrl = NULL; + IdealLoopTree* loop = phase->get_loop(ctrl); assert(val->bottom_type()->make_oopptr(), "need oop"); assert(val->bottom_type()->make_oopptr()->const_oop() == NULL, "expect non-constant"); - enum { _heap_stable = 1, _not_cset, _evac_path, _null_path, PATH_LIMIT }; + enum { _heap_stable = 1, _not_cset, _evac_path, PATH_LIMIT }; Node* region = new RegionNode(PATH_LIMIT); - Node* val_phi = new PhiNode(region, uncasted_val->bottom_type()->is_oopptr()); + Node* val_phi = new PhiNode(region, val->bottom_type()->is_oopptr()); Node* raw_mem_phi = PhiNode::make(region, raw_mem, Type::MEMORY, TypeRawPtr::BOTTOM); // Stable path. + Node* heap_stable_ctrl = NULL; test_heap_state(ctrl, raw_mem, heap_stable_ctrl, phase, ShenandoahHeap::HAS_FORWARDED); IfNode* heap_stable_iff = heap_stable_ctrl->in(0)->as_If(); // Heap stable case region->init_req(_heap_stable, heap_stable_ctrl); - val_phi->init_req(_heap_stable, uncasted_val); + val_phi->init_req(_heap_stable, val); raw_mem_phi->init_req(_heap_stable, raw_mem); - Node* reg2_ctrl = NULL; - // Null case - test_null(ctrl, val, null_ctrl, phase); - if (null_ctrl != NULL) { - reg2_ctrl = null_ctrl->in(0); - region->init_req(_null_path, null_ctrl); - val_phi->init_req(_null_path, uncasted_val); - raw_mem_phi->init_req(_null_path, raw_mem); - } else { - region->del_req(_null_path); - val_phi->del_req(_null_path); - raw_mem_phi->del_req(_null_path); - } - // Test for in-cset. // Wires !in_cset(obj) to slot 2 of region and phis Node* not_cset_ctrl = NULL; - in_cset_fast_test(ctrl, not_cset_ctrl, uncasted_val, raw_mem, phase); + in_cset_fast_test(ctrl, not_cset_ctrl, val, raw_mem, phase); if (not_cset_ctrl != NULL) { - if (reg2_ctrl == NULL) reg2_ctrl = not_cset_ctrl->in(0); region->init_req(_not_cset, not_cset_ctrl); - val_phi->init_req(_not_cset, uncasted_val); + val_phi->init_req(_not_cset, val); raw_mem_phi->init_req(_not_cset, raw_mem); } - // Resolve object when orig-value is in cset. - // Make the unconditional resolve for fwdptr. - Node* new_val = uncasted_val; - if (unc_ctrl != NULL) { - // Clone the null check in this branch to allow implicit null check - new_val = clone_null_check(ctrl, val, unc_ctrl, phase); - fix_null_check(unc, unc_ctrl, ctrl->in(0)->as_If()->proj_out(0), uses, phase); - - IfNode* iff = unc_ctrl->in(0)->as_If(); - phase->igvn().replace_input_of(iff, 1, phase->igvn().intcon(1)); - } - // Call lrb-stub and wire up that path in slots 4 Node* result_mem = NULL; - Node* fwd = new_val; Node* addr; if (ShenandoahSelfFixing) { VectorSet visited(Thread::current()->resource_area()); @@ -1518,9 +1288,9 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) { } } } - call_lrb_stub(ctrl, fwd, addr, result_mem, raw_mem, lrb->is_native(), phase); + call_lrb_stub(ctrl, val, addr, result_mem, raw_mem, lrb->is_native(), phase); region->init_req(_evac_path, ctrl); - val_phi->init_req(_evac_path, fwd); + val_phi->init_req(_evac_path, val); raw_mem_phi->init_req(_evac_path, result_mem); phase->register_control(region, loop, heap_stable_iff); @@ -1532,20 +1302,6 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) { ctrl = orig_ctrl; - if (unc != NULL) { - for (DUIterator_Fast imax, i = val->fast_outs(imax); i < imax; i++) { - Node* u = val->fast_out(i); - Node* c = phase->ctrl_or_self(u); - if (u != lrb && (c != ctrl || is_dominator_same_ctrl(c, lrb, u, phase))) { - phase->igvn().rehash_node_delayed(u); - int nb = u->replace_edge(val, out_val); - --i, imax -= nb; - } - } - if (val->outcnt() == 0) { - phase->igvn()._worklist.push(val); - } - } phase->igvn().replace_node(lrb, out_val); follow_barrier_uses(out_val, ctrl, uses, phase); @@ -3314,26 +3070,3 @@ bool ShenandoahLoadReferenceBarrierNode::is_redundant() { // No need for barrier found. return true; } - -CallStaticJavaNode* ShenandoahLoadReferenceBarrierNode::pin_and_expand_null_check(PhaseIterGVN& igvn) { - Node* val = in(ValueIn); - - const Type* val_t = igvn.type(val); - - if (val_t->meet(TypePtr::NULL_PTR) != val_t && - val->Opcode() == Op_CastPP && - val->in(0) != NULL && - val->in(0)->Opcode() == Op_IfTrue && - val->in(0)->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none) && - val->in(0)->in(0)->is_If() && - val->in(0)->in(0)->in(1)->Opcode() == Op_Bool && - val->in(0)->in(0)->in(1)->as_Bool()->_test._test == BoolTest::ne && - val->in(0)->in(0)->in(1)->in(1)->Opcode() == Op_CmpP && - val->in(0)->in(0)->in(1)->in(1)->in(1) == val->in(1) && - val->in(0)->in(0)->in(1)->in(1)->in(2)->bottom_type() == TypePtr::NULL_PTR) { - assert(val->in(0)->in(0)->in(1)->in(1)->in(1) == val->in(1), ""); - CallStaticJavaNode* unc = val->in(0)->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none); - return unc; - } - return NULL; -} diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp index da4ab2e3359..097f6554aa1 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp @@ -61,9 +61,6 @@ private: static void test_heap_state(Node*& ctrl, Node* raw_mem, Node*& heap_stable_ctrl, PhaseIdealLoop* phase, int flags); static void call_lrb_stub(Node*& ctrl, Node*& val, Node* load_addr, Node*& result_mem, Node* raw_mem, bool is_native, PhaseIdealLoop* phase); - static Node* clone_null_check(Node*& c, Node* val, Node* unc_ctrl, PhaseIdealLoop* phase); - static void fix_null_check(Node* unc, Node* unc_ctrl, Node* new_unc_ctrl, Unique_Node_List& uses, - PhaseIdealLoop* phase); static void in_cset_fast_test(Node*& ctrl, Node*& not_cset_ctrl, Node* val, Node* raw_mem, PhaseIdealLoop* phase); static void move_heap_stable_test_out_of_loop(IfNode* iff, PhaseIdealLoop* phase); static void merge_back_to_back_tests(Node* n, PhaseIdealLoop* phase); @@ -254,7 +251,6 @@ public: virtual bool cmp( const Node &n ) const; bool is_redundant(); - CallStaticJavaNode* pin_and_expand_null_check(PhaseIterGVN& igvn); private: bool needs_barrier(PhaseGVN* phase, Node* n); From 441e4cd91bae0e67f306e6b2cd142f1629a61dec Mon Sep 17 00:00:00 2001 From: Roman Kennke Date: Thu, 7 May 2020 12:03:08 +0200 Subject: [PATCH 71/88] 8244594: [BACKOUT] 8244523: Shenandoah: Remove null-handling in LRB expansion Reviewed-by: shade --- .../shenandoah/c2/shenandoahBarrierSetC2.cpp | 34 +-- .../shenandoah/c2/shenandoahBarrierSetC2.hpp | 4 +- .../gc/shenandoah/c2/shenandoahSupport.cpp | 287 +++++++++++++++++- .../gc/shenandoah/c2/shenandoahSupport.hpp | 4 + 4 files changed, 285 insertions(+), 44 deletions(-) diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp index 6e582518751..13f39fe9fba 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp @@ -481,16 +481,16 @@ const TypeFunc* ShenandoahBarrierSetC2::shenandoah_clone_barrier_Type() { return TypeFunc::make(domain, range); } -const TypeFunc* ShenandoahBarrierSetC2::shenandoah_load_reference_barrier_Type(const Type* value_type) { +const TypeFunc* ShenandoahBarrierSetC2::shenandoah_load_reference_barrier_Type() { const Type **fields = TypeTuple::fields(2); - fields[TypeFunc::Parms+0] = value_type; // original field value + fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // original field value fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // original load address const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields); // create result type (range) fields = TypeTuple::fields(1); - fields[TypeFunc::Parms+0] = value_type; + fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields); return TypeFunc::make(domain, range); @@ -1045,20 +1045,6 @@ void ShenandoahBarrierSetC2::verify_gc_barriers(Compile* compile, CompilePhase p } #endif -bool ShenandoahBarrierSetC2::maybe_skip_barrier(Node* n, uint i, PhaseGVN* phase) const { - PhaseIterGVN* igvn = phase->is_IterGVN(); - Node* in = step_over_gc_barrier(n->in(i)); - if (in != n->in(i)) { - if (igvn != NULL) { - n->set_req_X(i, in, igvn); - } else { - n->set_req(i, in); - } - return true; - } - return false; -} - Node* ShenandoahBarrierSetC2::ideal_node(PhaseGVN* phase, Node* n, bool can_reshape) const { if (is_shenandoah_wb_pre_call(n)) { uint cnt = ShenandoahBarrierSetC2::write_ref_field_pre_entry_Type()->domain()->cnt(); @@ -1100,20 +1086,6 @@ Node* ShenandoahBarrierSetC2::ideal_node(PhaseGVN* phase, Node* n, bool can_resh } return n; } - } else if (n->Opcode() == Op_CallStaticJava) { - if (n->as_CallStaticJava()->uncommon_trap_request() != 0) { - // Uncommon traps don't need barriers, values are handled - // during deoptimization. It also affects optimizing null-checks - // into implicit null-checks. - PhaseIterGVN* igvn = phase->is_IterGVN(); - Node* ret = NULL; - for (uint i = TypeFunc::Parms; i < n->len(); i++) { - if (maybe_skip_barrier(n, i, phase)) { - ret = n; - } - } - return ret; - } } else if (can_reshape && n->Opcode() == Op_If && ShenandoahBarrierC2Support::is_heap_stable_test(n) && diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp index 35899d14469..db494012805 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp @@ -81,8 +81,6 @@ private: static bool clone_needs_barrier(Node* src, PhaseGVN& gvn); - bool maybe_skip_barrier(Node* n, uint i, PhaseGVN* phase) const; - protected: virtual Node* load_at_resolved(C2Access& access, const Type* val_type) const; virtual Node* store_at_resolved(C2Access& access, C2AccessValue& val) const; @@ -105,7 +103,7 @@ public: static const TypeFunc* write_ref_field_pre_entry_Type(); static const TypeFunc* shenandoah_clone_barrier_Type(); - static const TypeFunc* shenandoah_load_reference_barrier_Type(const Type* value_type); + static const TypeFunc* shenandoah_load_reference_barrier_Type(); virtual bool has_load_barrier_nodes() const { return true; } // This is the entry-point for the backend to perform accesses through the Access API. diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp index 2bed0341502..c7766cc02e4 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp @@ -909,6 +909,76 @@ void ShenandoahBarrierC2Support::test_null(Node*& ctrl, Node* val, Node*& null_c } } +Node* ShenandoahBarrierC2Support::clone_null_check(Node*& c, Node* val, Node* unc_ctrl, PhaseIdealLoop* phase) { + IdealLoopTree *loop = phase->get_loop(c); + Node* iff = unc_ctrl->in(0); + assert(iff->is_If(), "broken"); + Node* new_iff = iff->clone(); + new_iff->set_req(0, c); + phase->register_control(new_iff, loop, c); + Node* iffalse = new IfFalseNode(new_iff->as_If()); + phase->register_control(iffalse, loop, new_iff); + Node* iftrue = new IfTrueNode(new_iff->as_If()); + phase->register_control(iftrue, loop, new_iff); + c = iftrue; + const Type *t = phase->igvn().type(val); + assert(val->Opcode() == Op_CastPP, "expect cast to non null here"); + Node* uncasted_val = val->in(1); + val = new CastPPNode(uncasted_val, t); + val->init_req(0, c); + phase->register_new_node(val, c); + return val; +} + +void ShenandoahBarrierC2Support::fix_null_check(Node* unc, Node* unc_ctrl, Node* new_unc_ctrl, + Unique_Node_List& uses, PhaseIdealLoop* phase) { + IfNode* iff = unc_ctrl->in(0)->as_If(); + Node* proj = iff->proj_out(0); + assert(proj != unc_ctrl, "bad projection"); + Node* use = proj->unique_ctrl_out(); + + assert(use == unc || use->is_Region(), "what else?"); + + uses.clear(); + if (use == unc) { + phase->set_idom(use, new_unc_ctrl, phase->dom_depth(use)); + for (uint i = 1; i < unc->req(); i++) { + Node* n = unc->in(i); + if (phase->has_ctrl(n) && phase->get_ctrl(n) == proj) { + uses.push(n); + } + } + } else { + assert(use->is_Region(), "what else?"); + uint idx = 1; + for (; use->in(idx) != proj; idx++); + for (DUIterator_Fast imax, i = use->fast_outs(imax); i < imax; i++) { + Node* u = use->fast_out(i); + if (u->is_Phi() && phase->get_ctrl(u->in(idx)) == proj) { + uses.push(u->in(idx)); + } + } + } + for(uint next = 0; next < uses.size(); next++ ) { + Node *n = uses.at(next); + assert(phase->get_ctrl(n) == proj, "bad control"); + phase->set_ctrl_and_loop(n, new_unc_ctrl); + if (n->in(0) == proj) { + phase->igvn().replace_input_of(n, 0, new_unc_ctrl); + } + for (uint i = 0; i < n->req(); i++) { + Node* m = n->in(i); + if (m != NULL && phase->has_ctrl(m) && phase->get_ctrl(m) == proj) { + uses.push(m); + } + } + } + + phase->igvn().rehash_node_delayed(use); + int nb = use->replace_edge(proj, new_unc_ctrl); + assert(nb == 1, "only use expected"); +} + void ShenandoahBarrierC2Support::in_cset_fast_test(Node*& ctrl, Node*& not_cset_ctrl, Node* val, Node* raw_mem, PhaseIdealLoop* phase) { IdealLoopTree *loop = phase->get_loop(ctrl); Node* raw_rbtrue = new CastP2XNode(ctrl, val); @@ -956,7 +1026,7 @@ void ShenandoahBarrierC2Support::call_lrb_stub(Node*& ctrl, Node*& val, Node* lo address calladdr = is_native ? CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_native) : target; const char* name = is_native ? "load_reference_barrier_native" : "load_reference_barrier"; - Node* call = new CallLeafNode(ShenandoahBarrierSetC2::shenandoah_load_reference_barrier_Type(obj_type), calladdr, name, TypeRawPtr::BOTTOM); + Node* call = new CallLeafNode(ShenandoahBarrierSetC2::shenandoah_load_reference_barrier_Type(), calladdr, name, TypeRawPtr::BOTTOM); call->init_req(TypeFunc::Control, ctrl); call->init_req(TypeFunc::I_O, phase->C->top()); @@ -972,6 +1042,8 @@ void ShenandoahBarrierC2Support::call_lrb_stub(Node*& ctrl, Node*& val, Node* lo phase->register_new_node(result_mem, call); val = new ProjNode(call, TypeFunc::Parms); phase->register_new_node(val, call); + val = new CheckCastPPNode(ctrl, val, obj_type); + phase->register_new_node(val, ctrl); } void ShenandoahBarrierC2Support::fix_ctrl(Node* barrier, Node* region, const MemoryGraphFixer& fixer, Unique_Node_List& uses, Unique_Node_List& uses_to_ignore, uint last, PhaseIdealLoop* phase) { @@ -1077,6 +1149,119 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) { } Node* ctrl = phase->get_ctrl(lrb); + Node* val = lrb->in(ShenandoahLoadReferenceBarrierNode::ValueIn); + + CallStaticJavaNode* unc = NULL; + Node* unc_ctrl = NULL; + Node* uncasted_val = val; + + for (DUIterator_Fast imax, i = lrb->fast_outs(imax); i < imax; i++) { + Node* u = lrb->fast_out(i); + if (u->Opcode() == Op_CastPP && + u->in(0) != NULL && + phase->is_dominator(u->in(0), ctrl)) { + const Type* u_t = phase->igvn().type(u); + + if (u_t->meet(TypePtr::NULL_PTR) != u_t && + u->in(0)->Opcode() == Op_IfTrue && + u->in(0)->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none) && + u->in(0)->in(0)->is_If() && + u->in(0)->in(0)->in(1)->Opcode() == Op_Bool && + u->in(0)->in(0)->in(1)->as_Bool()->_test._test == BoolTest::ne && + u->in(0)->in(0)->in(1)->in(1)->Opcode() == Op_CmpP && + u->in(0)->in(0)->in(1)->in(1)->in(1) == val && + u->in(0)->in(0)->in(1)->in(1)->in(2)->bottom_type() == TypePtr::NULL_PTR) { + IdealLoopTree* loop = phase->get_loop(ctrl); + IdealLoopTree* unc_loop = phase->get_loop(u->in(0)); + + if (!unc_loop->is_member(loop)) { + continue; + } + + Node* branch = no_branches(ctrl, u->in(0), false, phase); + assert(branch == NULL || branch == NodeSentinel, "was not looking for a branch"); + if (branch == NodeSentinel) { + continue; + } + + phase->igvn().replace_input_of(u, 1, val); + phase->igvn().replace_input_of(lrb, ShenandoahLoadReferenceBarrierNode::ValueIn, u); + phase->set_ctrl(u, u->in(0)); + phase->set_ctrl(lrb, u->in(0)); + unc = u->in(0)->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none); + unc_ctrl = u->in(0); + val = u; + + for (DUIterator_Fast jmax, j = val->fast_outs(jmax); j < jmax; j++) { + Node* u = val->fast_out(j); + if (u == lrb) continue; + phase->igvn().rehash_node_delayed(u); + int nb = u->replace_edge(val, lrb); + --j; jmax -= nb; + } + + RegionNode* r = new RegionNode(3); + IfNode* iff = unc_ctrl->in(0)->as_If(); + + Node* ctrl_use = unc_ctrl->unique_ctrl_out(); + Node* unc_ctrl_clone = unc_ctrl->clone(); + phase->register_control(unc_ctrl_clone, loop, iff); + Node* c = unc_ctrl_clone; + Node* new_cast = clone_null_check(c, val, unc_ctrl_clone, phase); + r->init_req(1, new_cast->in(0)->in(0)->as_If()->proj_out(0)); + + phase->igvn().replace_input_of(unc_ctrl, 0, c->in(0)); + phase->set_idom(unc_ctrl, c->in(0), phase->dom_depth(unc_ctrl)); + phase->lazy_replace(c, unc_ctrl); + c = NULL;; + phase->igvn().replace_input_of(val, 0, unc_ctrl_clone); + phase->set_ctrl(val, unc_ctrl_clone); + + IfNode* new_iff = new_cast->in(0)->in(0)->as_If(); + fix_null_check(unc, unc_ctrl_clone, r, uses, phase); + Node* iff_proj = iff->proj_out(0); + r->init_req(2, iff_proj); + phase->register_control(r, phase->ltree_root(), iff); + + Node* new_bol = new_iff->in(1)->clone(); + Node* new_cmp = new_bol->in(1)->clone(); + assert(new_cmp->Opcode() == Op_CmpP, "broken"); + assert(new_cmp->in(1) == val->in(1), "broken"); + new_bol->set_req(1, new_cmp); + new_cmp->set_req(1, lrb); + phase->register_new_node(new_bol, new_iff->in(0)); + phase->register_new_node(new_cmp, new_iff->in(0)); + phase->igvn().replace_input_of(new_iff, 1, new_bol); + phase->igvn().replace_input_of(new_cast, 1, lrb); + + for (DUIterator_Fast imax, i = lrb->fast_outs(imax); i < imax; i++) { + Node* u = lrb->fast_out(i); + if (u == new_cast || u == new_cmp) { + continue; + } + phase->igvn().rehash_node_delayed(u); + int nb = u->replace_edge(lrb, new_cast); + assert(nb > 0, "no update?"); + --i; imax -= nb; + } + + for (DUIterator_Fast imax, i = val->fast_outs(imax); i < imax; i++) { + Node* u = val->fast_out(i); + if (u == lrb) { + continue; + } + phase->igvn().rehash_node_delayed(u); + int nb = u->replace_edge(val, new_cast); + assert(nb > 0, "no update?"); + --i; imax -= nb; + } + + ctrl = unc_ctrl_clone; + phase->set_ctrl_and_loop(lrb, ctrl); + break; + } + } + } if ((ctrl->is_Proj() && ctrl->in(0)->is_CallJava()) || ctrl->is_CallJava()) { CallNode* call = ctrl->is_Proj() ? ctrl->in(0)->as_CallJava() : ctrl->as_CallJava(); if (call->entry_point() == OptoRuntime::rethrow_stub()) { @@ -1217,45 +1402,90 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) { Node* ctrl = phase->get_ctrl(lrb); Node* val = lrb->in(ShenandoahLoadReferenceBarrierNode::ValueIn); + Node* orig_ctrl = ctrl; Node* raw_mem = fixer.find_mem(ctrl, lrb); Node* init_raw_mem = raw_mem; Node* raw_mem_for_ctrl = fixer.find_mem(ctrl, NULL); - IdealLoopTree* loop = phase->get_loop(ctrl); + IdealLoopTree *loop = phase->get_loop(ctrl); + CallStaticJavaNode* unc = lrb->pin_and_expand_null_check(phase->igvn()); + Node* unc_ctrl = NULL; + if (unc != NULL) { + if (val->in(ShenandoahLoadReferenceBarrierNode::Control) != ctrl) { + unc = NULL; + } else { + unc_ctrl = val->in(ShenandoahLoadReferenceBarrierNode::Control); + } + } + + Node* uncasted_val = val; + if (unc != NULL) { + uncasted_val = val->in(1); + } + + Node* heap_stable_ctrl = NULL; + Node* null_ctrl = NULL; assert(val->bottom_type()->make_oopptr(), "need oop"); assert(val->bottom_type()->make_oopptr()->const_oop() == NULL, "expect non-constant"); - enum { _heap_stable = 1, _not_cset, _evac_path, PATH_LIMIT }; + enum { _heap_stable = 1, _not_cset, _evac_path, _null_path, PATH_LIMIT }; Node* region = new RegionNode(PATH_LIMIT); - Node* val_phi = new PhiNode(region, val->bottom_type()->is_oopptr()); + Node* val_phi = new PhiNode(region, uncasted_val->bottom_type()->is_oopptr()); Node* raw_mem_phi = PhiNode::make(region, raw_mem, Type::MEMORY, TypeRawPtr::BOTTOM); // Stable path. - Node* heap_stable_ctrl = NULL; test_heap_state(ctrl, raw_mem, heap_stable_ctrl, phase, ShenandoahHeap::HAS_FORWARDED); IfNode* heap_stable_iff = heap_stable_ctrl->in(0)->as_If(); // Heap stable case region->init_req(_heap_stable, heap_stable_ctrl); - val_phi->init_req(_heap_stable, val); + val_phi->init_req(_heap_stable, uncasted_val); raw_mem_phi->init_req(_heap_stable, raw_mem); + Node* reg2_ctrl = NULL; + // Null case + test_null(ctrl, val, null_ctrl, phase); + if (null_ctrl != NULL) { + reg2_ctrl = null_ctrl->in(0); + region->init_req(_null_path, null_ctrl); + val_phi->init_req(_null_path, uncasted_val); + raw_mem_phi->init_req(_null_path, raw_mem); + } else { + region->del_req(_null_path); + val_phi->del_req(_null_path); + raw_mem_phi->del_req(_null_path); + } + // Test for in-cset. // Wires !in_cset(obj) to slot 2 of region and phis Node* not_cset_ctrl = NULL; - in_cset_fast_test(ctrl, not_cset_ctrl, val, raw_mem, phase); + in_cset_fast_test(ctrl, not_cset_ctrl, uncasted_val, raw_mem, phase); if (not_cset_ctrl != NULL) { + if (reg2_ctrl == NULL) reg2_ctrl = not_cset_ctrl->in(0); region->init_req(_not_cset, not_cset_ctrl); - val_phi->init_req(_not_cset, val); + val_phi->init_req(_not_cset, uncasted_val); raw_mem_phi->init_req(_not_cset, raw_mem); } + // Resolve object when orig-value is in cset. + // Make the unconditional resolve for fwdptr. + Node* new_val = uncasted_val; + if (unc_ctrl != NULL) { + // Clone the null check in this branch to allow implicit null check + new_val = clone_null_check(ctrl, val, unc_ctrl, phase); + fix_null_check(unc, unc_ctrl, ctrl->in(0)->as_If()->proj_out(0), uses, phase); + + IfNode* iff = unc_ctrl->in(0)->as_If(); + phase->igvn().replace_input_of(iff, 1, phase->igvn().intcon(1)); + } + // Call lrb-stub and wire up that path in slots 4 Node* result_mem = NULL; + Node* fwd = new_val; Node* addr; if (ShenandoahSelfFixing) { VectorSet visited(Thread::current()->resource_area()); @@ -1288,9 +1518,9 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) { } } } - call_lrb_stub(ctrl, val, addr, result_mem, raw_mem, lrb->is_native(), phase); + call_lrb_stub(ctrl, fwd, addr, result_mem, raw_mem, lrb->is_native(), phase); region->init_req(_evac_path, ctrl); - val_phi->init_req(_evac_path, val); + val_phi->init_req(_evac_path, fwd); raw_mem_phi->init_req(_evac_path, result_mem); phase->register_control(region, loop, heap_stable_iff); @@ -1302,6 +1532,20 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) { ctrl = orig_ctrl; + if (unc != NULL) { + for (DUIterator_Fast imax, i = val->fast_outs(imax); i < imax; i++) { + Node* u = val->fast_out(i); + Node* c = phase->ctrl_or_self(u); + if (u != lrb && (c != ctrl || is_dominator_same_ctrl(c, lrb, u, phase))) { + phase->igvn().rehash_node_delayed(u); + int nb = u->replace_edge(val, out_val); + --i, imax -= nb; + } + } + if (val->outcnt() == 0) { + phase->igvn()._worklist.push(val); + } + } phase->igvn().replace_node(lrb, out_val); follow_barrier_uses(out_val, ctrl, uses, phase); @@ -3070,3 +3314,26 @@ bool ShenandoahLoadReferenceBarrierNode::is_redundant() { // No need for barrier found. return true; } + +CallStaticJavaNode* ShenandoahLoadReferenceBarrierNode::pin_and_expand_null_check(PhaseIterGVN& igvn) { + Node* val = in(ValueIn); + + const Type* val_t = igvn.type(val); + + if (val_t->meet(TypePtr::NULL_PTR) != val_t && + val->Opcode() == Op_CastPP && + val->in(0) != NULL && + val->in(0)->Opcode() == Op_IfTrue && + val->in(0)->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none) && + val->in(0)->in(0)->is_If() && + val->in(0)->in(0)->in(1)->Opcode() == Op_Bool && + val->in(0)->in(0)->in(1)->as_Bool()->_test._test == BoolTest::ne && + val->in(0)->in(0)->in(1)->in(1)->Opcode() == Op_CmpP && + val->in(0)->in(0)->in(1)->in(1)->in(1) == val->in(1) && + val->in(0)->in(0)->in(1)->in(1)->in(2)->bottom_type() == TypePtr::NULL_PTR) { + assert(val->in(0)->in(0)->in(1)->in(1)->in(1) == val->in(1), ""); + CallStaticJavaNode* unc = val->in(0)->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none); + return unc; + } + return NULL; +} diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp index 097f6554aa1..da4ab2e3359 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp @@ -61,6 +61,9 @@ private: static void test_heap_state(Node*& ctrl, Node* raw_mem, Node*& heap_stable_ctrl, PhaseIdealLoop* phase, int flags); static void call_lrb_stub(Node*& ctrl, Node*& val, Node* load_addr, Node*& result_mem, Node* raw_mem, bool is_native, PhaseIdealLoop* phase); + static Node* clone_null_check(Node*& c, Node* val, Node* unc_ctrl, PhaseIdealLoop* phase); + static void fix_null_check(Node* unc, Node* unc_ctrl, Node* new_unc_ctrl, Unique_Node_List& uses, + PhaseIdealLoop* phase); static void in_cset_fast_test(Node*& ctrl, Node*& not_cset_ctrl, Node* val, Node* raw_mem, PhaseIdealLoop* phase); static void move_heap_stable_test_out_of_loop(IfNode* iff, PhaseIdealLoop* phase); static void merge_back_to_back_tests(Node* n, PhaseIdealLoop* phase); @@ -251,6 +254,7 @@ public: virtual bool cmp( const Node &n ) const; bool is_redundant(); + CallStaticJavaNode* pin_and_expand_null_check(PhaseIterGVN& igvn); private: bool needs_barrier(PhaseGVN* phase, Node* n); From 1c136aae13a0d86a3668c2f3125ea508ea02a24f Mon Sep 17 00:00:00 2001 From: Roman Kennke Date: Thu, 7 May 2020 12:36:59 +0200 Subject: [PATCH 72/88] 8244595: [REDO] 8244523: Shenandoah: Remove null-handling in LRB expansion Reviewed-by: shade --- .../shenandoah/c2/shenandoahBarrierSetC2.cpp | 41 +-- .../shenandoah/c2/shenandoahBarrierSetC2.hpp | 2 +- .../gc/shenandoah/c2/shenandoahSupport.cpp | 292 +----------------- .../gc/shenandoah/c2/shenandoahSupport.hpp | 4 - 4 files changed, 23 insertions(+), 316 deletions(-) diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp index 13f39fe9fba..f9daff6d616 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.cpp @@ -481,16 +481,16 @@ const TypeFunc* ShenandoahBarrierSetC2::shenandoah_clone_barrier_Type() { return TypeFunc::make(domain, range); } -const TypeFunc* ShenandoahBarrierSetC2::shenandoah_load_reference_barrier_Type() { +const TypeFunc* ShenandoahBarrierSetC2::shenandoah_load_reference_barrier_Type(const Type* value_type) { const Type **fields = TypeTuple::fields(2); - fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; // original field value + fields[TypeFunc::Parms+0] = value_type; // original field value fields[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // original load address const TypeTuple *domain = TypeTuple::make(TypeFunc::Parms+2, fields); // create result type (range) fields = TypeTuple::fields(1); - fields[TypeFunc::Parms+0] = TypeInstPtr::NOTNULL; + fields[TypeFunc::Parms+0] = value_type; const TypeTuple *range = TypeTuple::make(TypeFunc::Parms+1, fields); return TypeFunc::make(domain, range); @@ -1059,37 +1059,10 @@ Node* ShenandoahBarrierSetC2::ideal_node(PhaseGVN* phase, Node* n, bool can_resh } } } - if (n->Opcode() == Op_CmpP) { - Node* in1 = n->in(1); - Node* in2 = n->in(2); - if (in1->bottom_type() == TypePtr::NULL_PTR) { - in2 = step_over_gc_barrier(in2); - } - if (in2->bottom_type() == TypePtr::NULL_PTR) { - in1 = step_over_gc_barrier(in1); - } - PhaseIterGVN* igvn = phase->is_IterGVN(); - if (in1 != n->in(1)) { - if (igvn != NULL) { - n->set_req_X(1, in1, igvn); - } else { - n->set_req(1, in1); - } - assert(in2 == n->in(2), "only one change"); - return n; - } - if (in2 != n->in(2)) { - if (igvn != NULL) { - n->set_req_X(2, in2, igvn); - } else { - n->set_req(2, in2); - } - return n; - } - } else if (can_reshape && - n->Opcode() == Op_If && - ShenandoahBarrierC2Support::is_heap_stable_test(n) && - n->in(0) != NULL) { + if (can_reshape && + n->Opcode() == Op_If && + ShenandoahBarrierC2Support::is_heap_stable_test(n) && + n->in(0) != NULL) { Node* dom = n->in(0); Node* prev_dom = n; int op = n->Opcode(); diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp index db494012805..d985deb67fe 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp @@ -103,7 +103,7 @@ public: static const TypeFunc* write_ref_field_pre_entry_Type(); static const TypeFunc* shenandoah_clone_barrier_Type(); - static const TypeFunc* shenandoah_load_reference_barrier_Type(); + static const TypeFunc* shenandoah_load_reference_barrier_Type(const Type* value_type); virtual bool has_load_barrier_nodes() const { return true; } // This is the entry-point for the backend to perform accesses through the Access API. diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp index c7766cc02e4..e24fbcb9e82 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp @@ -909,76 +909,6 @@ void ShenandoahBarrierC2Support::test_null(Node*& ctrl, Node* val, Node*& null_c } } -Node* ShenandoahBarrierC2Support::clone_null_check(Node*& c, Node* val, Node* unc_ctrl, PhaseIdealLoop* phase) { - IdealLoopTree *loop = phase->get_loop(c); - Node* iff = unc_ctrl->in(0); - assert(iff->is_If(), "broken"); - Node* new_iff = iff->clone(); - new_iff->set_req(0, c); - phase->register_control(new_iff, loop, c); - Node* iffalse = new IfFalseNode(new_iff->as_If()); - phase->register_control(iffalse, loop, new_iff); - Node* iftrue = new IfTrueNode(new_iff->as_If()); - phase->register_control(iftrue, loop, new_iff); - c = iftrue; - const Type *t = phase->igvn().type(val); - assert(val->Opcode() == Op_CastPP, "expect cast to non null here"); - Node* uncasted_val = val->in(1); - val = new CastPPNode(uncasted_val, t); - val->init_req(0, c); - phase->register_new_node(val, c); - return val; -} - -void ShenandoahBarrierC2Support::fix_null_check(Node* unc, Node* unc_ctrl, Node* new_unc_ctrl, - Unique_Node_List& uses, PhaseIdealLoop* phase) { - IfNode* iff = unc_ctrl->in(0)->as_If(); - Node* proj = iff->proj_out(0); - assert(proj != unc_ctrl, "bad projection"); - Node* use = proj->unique_ctrl_out(); - - assert(use == unc || use->is_Region(), "what else?"); - - uses.clear(); - if (use == unc) { - phase->set_idom(use, new_unc_ctrl, phase->dom_depth(use)); - for (uint i = 1; i < unc->req(); i++) { - Node* n = unc->in(i); - if (phase->has_ctrl(n) && phase->get_ctrl(n) == proj) { - uses.push(n); - } - } - } else { - assert(use->is_Region(), "what else?"); - uint idx = 1; - for (; use->in(idx) != proj; idx++); - for (DUIterator_Fast imax, i = use->fast_outs(imax); i < imax; i++) { - Node* u = use->fast_out(i); - if (u->is_Phi() && phase->get_ctrl(u->in(idx)) == proj) { - uses.push(u->in(idx)); - } - } - } - for(uint next = 0; next < uses.size(); next++ ) { - Node *n = uses.at(next); - assert(phase->get_ctrl(n) == proj, "bad control"); - phase->set_ctrl_and_loop(n, new_unc_ctrl); - if (n->in(0) == proj) { - phase->igvn().replace_input_of(n, 0, new_unc_ctrl); - } - for (uint i = 0; i < n->req(); i++) { - Node* m = n->in(i); - if (m != NULL && phase->has_ctrl(m) && phase->get_ctrl(m) == proj) { - uses.push(m); - } - } - } - - phase->igvn().rehash_node_delayed(use); - int nb = use->replace_edge(proj, new_unc_ctrl); - assert(nb == 1, "only use expected"); -} - void ShenandoahBarrierC2Support::in_cset_fast_test(Node*& ctrl, Node*& not_cset_ctrl, Node* val, Node* raw_mem, PhaseIdealLoop* phase) { IdealLoopTree *loop = phase->get_loop(ctrl); Node* raw_rbtrue = new CastP2XNode(ctrl, val); @@ -1026,7 +956,7 @@ void ShenandoahBarrierC2Support::call_lrb_stub(Node*& ctrl, Node*& val, Node* lo address calladdr = is_native ? CAST_FROM_FN_PTR(address, ShenandoahRuntime::load_reference_barrier_native) : target; const char* name = is_native ? "load_reference_barrier_native" : "load_reference_barrier"; - Node* call = new CallLeafNode(ShenandoahBarrierSetC2::shenandoah_load_reference_barrier_Type(), calladdr, name, TypeRawPtr::BOTTOM); + Node* call = new CallLeafNode(ShenandoahBarrierSetC2::shenandoah_load_reference_barrier_Type(obj_type), calladdr, name, TypeRawPtr::BOTTOM); call->init_req(TypeFunc::Control, ctrl); call->init_req(TypeFunc::I_O, phase->C->top()); @@ -1042,8 +972,6 @@ void ShenandoahBarrierC2Support::call_lrb_stub(Node*& ctrl, Node*& val, Node* lo phase->register_new_node(result_mem, call); val = new ProjNode(call, TypeFunc::Parms); phase->register_new_node(val, call); - val = new CheckCastPPNode(ctrl, val, obj_type); - phase->register_new_node(val, ctrl); } void ShenandoahBarrierC2Support::fix_ctrl(Node* barrier, Node* region, const MemoryGraphFixer& fixer, Unique_Node_List& uses, Unique_Node_List& uses_to_ignore, uint last, PhaseIdealLoop* phase) { @@ -1149,119 +1077,6 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) { } Node* ctrl = phase->get_ctrl(lrb); - Node* val = lrb->in(ShenandoahLoadReferenceBarrierNode::ValueIn); - - CallStaticJavaNode* unc = NULL; - Node* unc_ctrl = NULL; - Node* uncasted_val = val; - - for (DUIterator_Fast imax, i = lrb->fast_outs(imax); i < imax; i++) { - Node* u = lrb->fast_out(i); - if (u->Opcode() == Op_CastPP && - u->in(0) != NULL && - phase->is_dominator(u->in(0), ctrl)) { - const Type* u_t = phase->igvn().type(u); - - if (u_t->meet(TypePtr::NULL_PTR) != u_t && - u->in(0)->Opcode() == Op_IfTrue && - u->in(0)->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none) && - u->in(0)->in(0)->is_If() && - u->in(0)->in(0)->in(1)->Opcode() == Op_Bool && - u->in(0)->in(0)->in(1)->as_Bool()->_test._test == BoolTest::ne && - u->in(0)->in(0)->in(1)->in(1)->Opcode() == Op_CmpP && - u->in(0)->in(0)->in(1)->in(1)->in(1) == val && - u->in(0)->in(0)->in(1)->in(1)->in(2)->bottom_type() == TypePtr::NULL_PTR) { - IdealLoopTree* loop = phase->get_loop(ctrl); - IdealLoopTree* unc_loop = phase->get_loop(u->in(0)); - - if (!unc_loop->is_member(loop)) { - continue; - } - - Node* branch = no_branches(ctrl, u->in(0), false, phase); - assert(branch == NULL || branch == NodeSentinel, "was not looking for a branch"); - if (branch == NodeSentinel) { - continue; - } - - phase->igvn().replace_input_of(u, 1, val); - phase->igvn().replace_input_of(lrb, ShenandoahLoadReferenceBarrierNode::ValueIn, u); - phase->set_ctrl(u, u->in(0)); - phase->set_ctrl(lrb, u->in(0)); - unc = u->in(0)->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none); - unc_ctrl = u->in(0); - val = u; - - for (DUIterator_Fast jmax, j = val->fast_outs(jmax); j < jmax; j++) { - Node* u = val->fast_out(j); - if (u == lrb) continue; - phase->igvn().rehash_node_delayed(u); - int nb = u->replace_edge(val, lrb); - --j; jmax -= nb; - } - - RegionNode* r = new RegionNode(3); - IfNode* iff = unc_ctrl->in(0)->as_If(); - - Node* ctrl_use = unc_ctrl->unique_ctrl_out(); - Node* unc_ctrl_clone = unc_ctrl->clone(); - phase->register_control(unc_ctrl_clone, loop, iff); - Node* c = unc_ctrl_clone; - Node* new_cast = clone_null_check(c, val, unc_ctrl_clone, phase); - r->init_req(1, new_cast->in(0)->in(0)->as_If()->proj_out(0)); - - phase->igvn().replace_input_of(unc_ctrl, 0, c->in(0)); - phase->set_idom(unc_ctrl, c->in(0), phase->dom_depth(unc_ctrl)); - phase->lazy_replace(c, unc_ctrl); - c = NULL;; - phase->igvn().replace_input_of(val, 0, unc_ctrl_clone); - phase->set_ctrl(val, unc_ctrl_clone); - - IfNode* new_iff = new_cast->in(0)->in(0)->as_If(); - fix_null_check(unc, unc_ctrl_clone, r, uses, phase); - Node* iff_proj = iff->proj_out(0); - r->init_req(2, iff_proj); - phase->register_control(r, phase->ltree_root(), iff); - - Node* new_bol = new_iff->in(1)->clone(); - Node* new_cmp = new_bol->in(1)->clone(); - assert(new_cmp->Opcode() == Op_CmpP, "broken"); - assert(new_cmp->in(1) == val->in(1), "broken"); - new_bol->set_req(1, new_cmp); - new_cmp->set_req(1, lrb); - phase->register_new_node(new_bol, new_iff->in(0)); - phase->register_new_node(new_cmp, new_iff->in(0)); - phase->igvn().replace_input_of(new_iff, 1, new_bol); - phase->igvn().replace_input_of(new_cast, 1, lrb); - - for (DUIterator_Fast imax, i = lrb->fast_outs(imax); i < imax; i++) { - Node* u = lrb->fast_out(i); - if (u == new_cast || u == new_cmp) { - continue; - } - phase->igvn().rehash_node_delayed(u); - int nb = u->replace_edge(lrb, new_cast); - assert(nb > 0, "no update?"); - --i; imax -= nb; - } - - for (DUIterator_Fast imax, i = val->fast_outs(imax); i < imax; i++) { - Node* u = val->fast_out(i); - if (u == lrb) { - continue; - } - phase->igvn().rehash_node_delayed(u); - int nb = u->replace_edge(val, new_cast); - assert(nb > 0, "no update?"); - --i; imax -= nb; - } - - ctrl = unc_ctrl_clone; - phase->set_ctrl_and_loop(lrb, ctrl); - break; - } - } - } if ((ctrl->is_Proj() && ctrl->in(0)->is_CallJava()) || ctrl->is_CallJava()) { CallNode* call = ctrl->is_Proj() ? ctrl->in(0)->as_CallJava() : ctrl->as_CallJava(); if (call->entry_point() == OptoRuntime::rethrow_stub()) { @@ -1402,90 +1217,45 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) { Node* ctrl = phase->get_ctrl(lrb); Node* val = lrb->in(ShenandoahLoadReferenceBarrierNode::ValueIn); - Node* orig_ctrl = ctrl; Node* raw_mem = fixer.find_mem(ctrl, lrb); Node* init_raw_mem = raw_mem; Node* raw_mem_for_ctrl = fixer.find_mem(ctrl, NULL); - IdealLoopTree *loop = phase->get_loop(ctrl); - CallStaticJavaNode* unc = lrb->pin_and_expand_null_check(phase->igvn()); - Node* unc_ctrl = NULL; - if (unc != NULL) { - if (val->in(ShenandoahLoadReferenceBarrierNode::Control) != ctrl) { - unc = NULL; - } else { - unc_ctrl = val->in(ShenandoahLoadReferenceBarrierNode::Control); - } - } - - Node* uncasted_val = val; - if (unc != NULL) { - uncasted_val = val->in(1); - } - - Node* heap_stable_ctrl = NULL; - Node* null_ctrl = NULL; + IdealLoopTree* loop = phase->get_loop(ctrl); assert(val->bottom_type()->make_oopptr(), "need oop"); assert(val->bottom_type()->make_oopptr()->const_oop() == NULL, "expect non-constant"); - enum { _heap_stable = 1, _not_cset, _evac_path, _null_path, PATH_LIMIT }; + enum { _heap_stable = 1, _not_cset, _evac_path, PATH_LIMIT }; Node* region = new RegionNode(PATH_LIMIT); - Node* val_phi = new PhiNode(region, uncasted_val->bottom_type()->is_oopptr()); + Node* val_phi = new PhiNode(region, val->bottom_type()->is_oopptr()); Node* raw_mem_phi = PhiNode::make(region, raw_mem, Type::MEMORY, TypeRawPtr::BOTTOM); // Stable path. + Node* heap_stable_ctrl = NULL; test_heap_state(ctrl, raw_mem, heap_stable_ctrl, phase, ShenandoahHeap::HAS_FORWARDED); IfNode* heap_stable_iff = heap_stable_ctrl->in(0)->as_If(); // Heap stable case region->init_req(_heap_stable, heap_stable_ctrl); - val_phi->init_req(_heap_stable, uncasted_val); + val_phi->init_req(_heap_stable, val); raw_mem_phi->init_req(_heap_stable, raw_mem); - Node* reg2_ctrl = NULL; - // Null case - test_null(ctrl, val, null_ctrl, phase); - if (null_ctrl != NULL) { - reg2_ctrl = null_ctrl->in(0); - region->init_req(_null_path, null_ctrl); - val_phi->init_req(_null_path, uncasted_val); - raw_mem_phi->init_req(_null_path, raw_mem); - } else { - region->del_req(_null_path); - val_phi->del_req(_null_path); - raw_mem_phi->del_req(_null_path); - } - // Test for in-cset. // Wires !in_cset(obj) to slot 2 of region and phis Node* not_cset_ctrl = NULL; - in_cset_fast_test(ctrl, not_cset_ctrl, uncasted_val, raw_mem, phase); + in_cset_fast_test(ctrl, not_cset_ctrl, val, raw_mem, phase); if (not_cset_ctrl != NULL) { - if (reg2_ctrl == NULL) reg2_ctrl = not_cset_ctrl->in(0); region->init_req(_not_cset, not_cset_ctrl); - val_phi->init_req(_not_cset, uncasted_val); + val_phi->init_req(_not_cset, val); raw_mem_phi->init_req(_not_cset, raw_mem); } - // Resolve object when orig-value is in cset. - // Make the unconditional resolve for fwdptr. - Node* new_val = uncasted_val; - if (unc_ctrl != NULL) { - // Clone the null check in this branch to allow implicit null check - new_val = clone_null_check(ctrl, val, unc_ctrl, phase); - fix_null_check(unc, unc_ctrl, ctrl->in(0)->as_If()->proj_out(0), uses, phase); - - IfNode* iff = unc_ctrl->in(0)->as_If(); - phase->igvn().replace_input_of(iff, 1, phase->igvn().intcon(1)); - } - // Call lrb-stub and wire up that path in slots 4 Node* result_mem = NULL; - Node* fwd = new_val; Node* addr; if (ShenandoahSelfFixing) { VectorSet visited(Thread::current()->resource_area()); @@ -1518,9 +1288,9 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) { } } } - call_lrb_stub(ctrl, fwd, addr, result_mem, raw_mem, lrb->is_native(), phase); + call_lrb_stub(ctrl, val, addr, result_mem, raw_mem, lrb->is_native(), phase); region->init_req(_evac_path, ctrl); - val_phi->init_req(_evac_path, fwd); + val_phi->init_req(_evac_path, val); raw_mem_phi->init_req(_evac_path, result_mem); phase->register_control(region, loop, heap_stable_iff); @@ -1532,20 +1302,6 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) { ctrl = orig_ctrl; - if (unc != NULL) { - for (DUIterator_Fast imax, i = val->fast_outs(imax); i < imax; i++) { - Node* u = val->fast_out(i); - Node* c = phase->ctrl_or_self(u); - if (u != lrb && (c != ctrl || is_dominator_same_ctrl(c, lrb, u, phase))) { - phase->igvn().rehash_node_delayed(u); - int nb = u->replace_edge(val, out_val); - --i, imax -= nb; - } - } - if (val->outcnt() == 0) { - phase->igvn()._worklist.push(val); - } - } phase->igvn().replace_node(lrb, out_val); follow_barrier_uses(out_val, ctrl, uses, phase); @@ -3173,6 +2929,11 @@ bool ShenandoahLoadReferenceBarrierNode::is_redundant() { bool visit_users = false; switch (n->Opcode()) { case Op_CallStaticJava: + // Uncommon traps don't need barriers, values are handled during deoptimization. It also affects + // optimizing null-checks into implicit null-checks. + if (n->as_CallStaticJava()->uncommon_trap_request() != 0) { + break; + } case Op_CallDynamicJava: case Op_CallLeaf: case Op_CallLeafNoFP: @@ -3314,26 +3075,3 @@ bool ShenandoahLoadReferenceBarrierNode::is_redundant() { // No need for barrier found. return true; } - -CallStaticJavaNode* ShenandoahLoadReferenceBarrierNode::pin_and_expand_null_check(PhaseIterGVN& igvn) { - Node* val = in(ValueIn); - - const Type* val_t = igvn.type(val); - - if (val_t->meet(TypePtr::NULL_PTR) != val_t && - val->Opcode() == Op_CastPP && - val->in(0) != NULL && - val->in(0)->Opcode() == Op_IfTrue && - val->in(0)->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none) && - val->in(0)->in(0)->is_If() && - val->in(0)->in(0)->in(1)->Opcode() == Op_Bool && - val->in(0)->in(0)->in(1)->as_Bool()->_test._test == BoolTest::ne && - val->in(0)->in(0)->in(1)->in(1)->Opcode() == Op_CmpP && - val->in(0)->in(0)->in(1)->in(1)->in(1) == val->in(1) && - val->in(0)->in(0)->in(1)->in(1)->in(2)->bottom_type() == TypePtr::NULL_PTR) { - assert(val->in(0)->in(0)->in(1)->in(1)->in(1) == val->in(1), ""); - CallStaticJavaNode* unc = val->in(0)->as_Proj()->is_uncommon_trap_if_pattern(Deoptimization::Reason_none); - return unc; - } - return NULL; -} diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp index da4ab2e3359..097f6554aa1 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp @@ -61,9 +61,6 @@ private: static void test_heap_state(Node*& ctrl, Node* raw_mem, Node*& heap_stable_ctrl, PhaseIdealLoop* phase, int flags); static void call_lrb_stub(Node*& ctrl, Node*& val, Node* load_addr, Node*& result_mem, Node* raw_mem, bool is_native, PhaseIdealLoop* phase); - static Node* clone_null_check(Node*& c, Node* val, Node* unc_ctrl, PhaseIdealLoop* phase); - static void fix_null_check(Node* unc, Node* unc_ctrl, Node* new_unc_ctrl, Unique_Node_List& uses, - PhaseIdealLoop* phase); static void in_cset_fast_test(Node*& ctrl, Node*& not_cset_ctrl, Node* val, Node* raw_mem, PhaseIdealLoop* phase); static void move_heap_stable_test_out_of_loop(IfNode* iff, PhaseIdealLoop* phase); static void merge_back_to_back_tests(Node* n, PhaseIdealLoop* phase); @@ -254,7 +251,6 @@ public: virtual bool cmp( const Node &n ) const; bool is_redundant(); - CallStaticJavaNode* pin_and_expand_null_check(PhaseIterGVN& igvn); private: bool needs_barrier(PhaseGVN* phase, Node* n); From 1ac381171ef2caea76bb292c6684dabe8a703e2a Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Wed, 6 May 2020 11:40:27 +0200 Subject: [PATCH 73/88] 8244509: Shenandoah: refactor ShenandoahBarrierC2Support::test_* methods Reviewed-by: rkennke, roland --- .../gc/shenandoah/c2/shenandoahSupport.cpp | 152 ++++++++++-------- .../gc/shenandoah/c2/shenandoahSupport.hpp | 10 +- 2 files changed, 88 insertions(+), 74 deletions(-) diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp index e24fbcb9e82..3c0f231ec8e 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp @@ -68,7 +68,7 @@ bool ShenandoahBarrierC2Support::expand(Compile* C, PhaseIterGVN& igvn) { return true; } -bool ShenandoahBarrierC2Support::is_heap_state_test(Node* iff, int mask) { +bool ShenandoahBarrierC2Support::is_gc_state_test(Node* iff, int mask) { if (!UseShenandoahGC) { return false; } @@ -102,7 +102,7 @@ bool ShenandoahBarrierC2Support::is_heap_state_test(Node* iff, int mask) { } bool ShenandoahBarrierC2Support::is_heap_stable_test(Node* iff) { - return is_heap_state_test(iff, ShenandoahHeap::HAS_FORWARDED); + return is_gc_state_test(iff, ShenandoahHeap::HAS_FORWARDED); } bool ShenandoahBarrierC2Support::is_gc_state_load(Node *n) { @@ -860,82 +860,96 @@ static void hide_strip_mined_loop(OuterStripMinedLoopNode* outer, CountedLoopNod inner->clear_strip_mined(); } -void ShenandoahBarrierC2Support::test_heap_state(Node*& ctrl, Node* raw_mem, Node*& heap_stable_ctrl, - PhaseIdealLoop* phase, int flags) { +void ShenandoahBarrierC2Support::test_gc_state(Node*& ctrl, Node* raw_mem, Node*& test_fail_ctrl, + PhaseIdealLoop* phase, int flags) { + PhaseIterGVN& igvn = phase->igvn(); + Node* old_ctrl = ctrl; + + Node* thread = new ThreadLocalNode(); + Node* gc_state_offset = igvn.MakeConX(in_bytes(ShenandoahThreadLocalData::gc_state_offset())); + Node* gc_state_addr = new AddPNode(phase->C->top(), thread, gc_state_offset); + Node* gc_state = new LoadBNode(old_ctrl, raw_mem, gc_state_addr, + DEBUG_ONLY(phase->C->get_adr_type(Compile::AliasIdxRaw)) NOT_DEBUG(NULL), + TypeInt::BYTE, MemNode::unordered); + Node* gc_state_and = new AndINode(gc_state, igvn.intcon(flags)); + Node* gc_state_cmp = new CmpINode(gc_state_and, igvn.zerocon(T_INT)); + Node* gc_state_bool = new BoolNode(gc_state_cmp, BoolTest::ne); + + IfNode* gc_state_iff = new IfNode(old_ctrl, gc_state_bool, PROB_UNLIKELY(0.999), COUNT_UNKNOWN); + ctrl = new IfTrueNode(gc_state_iff); + test_fail_ctrl = new IfFalseNode(gc_state_iff); + IdealLoopTree* loop = phase->get_loop(ctrl); - Node* thread = new ThreadLocalNode(); - phase->register_new_node(thread, ctrl); - Node* offset = phase->igvn().MakeConX(in_bytes(ShenandoahThreadLocalData::gc_state_offset())); - phase->set_ctrl(offset, phase->C->root()); - Node* gc_state_addr = new AddPNode(phase->C->top(), thread, offset); - phase->register_new_node(gc_state_addr, ctrl); - uint gc_state_idx = Compile::AliasIdxRaw; - const TypePtr* gc_state_adr_type = NULL; // debug-mode-only argument - debug_only(gc_state_adr_type = phase->C->get_adr_type(gc_state_idx)); + phase->register_control(gc_state_iff, loop, old_ctrl); + phase->register_control(ctrl, loop, gc_state_iff); + phase->register_control(test_fail_ctrl, loop, gc_state_iff); - Node* gc_state = new LoadBNode(ctrl, raw_mem, gc_state_addr, gc_state_adr_type, TypeInt::BYTE, MemNode::unordered); - phase->register_new_node(gc_state, ctrl); - Node* heap_stable_and = new AndINode(gc_state, phase->igvn().intcon(flags)); - phase->register_new_node(heap_stable_and, ctrl); - Node* heap_stable_cmp = new CmpINode(heap_stable_and, phase->igvn().zerocon(T_INT)); - phase->register_new_node(heap_stable_cmp, ctrl); - Node* heap_stable_test = new BoolNode(heap_stable_cmp, BoolTest::ne); - phase->register_new_node(heap_stable_test, ctrl); - IfNode* heap_stable_iff = new IfNode(ctrl, heap_stable_test, PROB_UNLIKELY(0.999), COUNT_UNKNOWN); - phase->register_control(heap_stable_iff, loop, ctrl); + phase->register_new_node(thread, old_ctrl); + phase->register_new_node(gc_state_addr, old_ctrl); + phase->register_new_node(gc_state, old_ctrl); + phase->register_new_node(gc_state_and, old_ctrl); + phase->register_new_node(gc_state_cmp, old_ctrl); + phase->register_new_node(gc_state_bool, old_ctrl); - heap_stable_ctrl = new IfFalseNode(heap_stable_iff); - phase->register_control(heap_stable_ctrl, loop, heap_stable_iff); - ctrl = new IfTrueNode(heap_stable_iff); - phase->register_control(ctrl, loop, heap_stable_iff); + phase->set_ctrl(gc_state_offset, phase->C->root()); - assert(is_heap_state_test(heap_stable_iff, flags), "Should match the shape"); + assert(is_gc_state_test(gc_state_iff, flags), "Should match the shape"); } void ShenandoahBarrierC2Support::test_null(Node*& ctrl, Node* val, Node*& null_ctrl, PhaseIdealLoop* phase) { - const Type* val_t = phase->igvn().type(val); + Node* old_ctrl = ctrl; + PhaseIterGVN& igvn = phase->igvn(); + + const Type* val_t = igvn.type(val); if (val_t->meet(TypePtr::NULL_PTR) == val_t) { - IdealLoopTree* loop = phase->get_loop(ctrl); - Node* null_cmp = new CmpPNode(val, phase->igvn().zerocon(T_OBJECT)); - phase->register_new_node(null_cmp, ctrl); - Node* null_test = new BoolNode(null_cmp, BoolTest::ne); - phase->register_new_node(null_test, ctrl); - IfNode* null_iff = new IfNode(ctrl, null_test, PROB_LIKELY(0.999), COUNT_UNKNOWN); - phase->register_control(null_iff, loop, ctrl); - ctrl = new IfTrueNode(null_iff); - phase->register_control(ctrl, loop, null_iff); - null_ctrl = new IfFalseNode(null_iff); + Node* null_cmp = new CmpPNode(val, igvn.zerocon(T_OBJECT)); + Node* null_test = new BoolNode(null_cmp, BoolTest::ne); + + IfNode* null_iff = new IfNode(old_ctrl, null_test, PROB_LIKELY(0.999), COUNT_UNKNOWN); + ctrl = new IfTrueNode(null_iff); + null_ctrl = new IfFalseNode(null_iff); + + IdealLoopTree* loop = phase->get_loop(old_ctrl); + phase->register_control(null_iff, loop, old_ctrl); + phase->register_control(ctrl, loop, null_iff); phase->register_control(null_ctrl, loop, null_iff); + + phase->register_new_node(null_cmp, old_ctrl); + phase->register_new_node(null_test, old_ctrl); } } -void ShenandoahBarrierC2Support::in_cset_fast_test(Node*& ctrl, Node*& not_cset_ctrl, Node* val, Node* raw_mem, PhaseIdealLoop* phase) { - IdealLoopTree *loop = phase->get_loop(ctrl); - Node* raw_rbtrue = new CastP2XNode(ctrl, val); - phase->register_new_node(raw_rbtrue, ctrl); - Node* cset_offset = new URShiftXNode(raw_rbtrue, phase->igvn().intcon(ShenandoahHeapRegion::region_size_bytes_shift_jint())); - phase->register_new_node(cset_offset, ctrl); - Node* in_cset_fast_test_base_addr = phase->igvn().makecon(TypeRawPtr::make(ShenandoahHeap::in_cset_fast_test_addr())); - phase->set_ctrl(in_cset_fast_test_base_addr, phase->C->root()); - Node* in_cset_fast_test_adr = new AddPNode(phase->C->top(), in_cset_fast_test_base_addr, cset_offset); - phase->register_new_node(in_cset_fast_test_adr, ctrl); - uint in_cset_fast_test_idx = Compile::AliasIdxRaw; - const TypePtr* in_cset_fast_test_adr_type = NULL; // debug-mode-only argument - debug_only(in_cset_fast_test_adr_type = phase->C->get_adr_type(in_cset_fast_test_idx)); - Node* in_cset_fast_test_load = new LoadBNode(ctrl, raw_mem, in_cset_fast_test_adr, in_cset_fast_test_adr_type, TypeInt::BYTE, MemNode::unordered); - phase->register_new_node(in_cset_fast_test_load, ctrl); - Node* in_cset_fast_test_cmp = new CmpINode(in_cset_fast_test_load, phase->igvn().zerocon(T_INT)); - phase->register_new_node(in_cset_fast_test_cmp, ctrl); - Node* in_cset_fast_test_test = new BoolNode(in_cset_fast_test_cmp, BoolTest::eq); - phase->register_new_node(in_cset_fast_test_test, ctrl); - IfNode* in_cset_fast_test_iff = new IfNode(ctrl, in_cset_fast_test_test, PROB_UNLIKELY(0.999), COUNT_UNKNOWN); - phase->register_control(in_cset_fast_test_iff, loop, ctrl); +void ShenandoahBarrierC2Support::test_in_cset(Node*& ctrl, Node*& not_cset_ctrl, Node* val, Node* raw_mem, PhaseIdealLoop* phase) { + Node* old_ctrl = ctrl; + PhaseIterGVN& igvn = phase->igvn(); - not_cset_ctrl = new IfTrueNode(in_cset_fast_test_iff); - phase->register_control(not_cset_ctrl, loop, in_cset_fast_test_iff); + Node* raw_val = new CastP2XNode(old_ctrl, val); + Node* cset_idx = new URShiftXNode(raw_val, igvn.intcon(ShenandoahHeapRegion::region_size_bytes_shift_jint())); + Node* cset_addr = igvn.makecon(TypeRawPtr::make(ShenandoahHeap::in_cset_fast_test_addr())); + Node* cset_load_addr = new AddPNode(phase->C->top(), cset_addr, cset_idx); + Node* cset_load = new LoadBNode(old_ctrl, raw_mem, cset_load_addr, + DEBUG_ONLY(phase->C->get_adr_type(Compile::AliasIdxRaw)) NOT_DEBUG(NULL), + TypeInt::BYTE, MemNode::unordered); + Node* cset_cmp = new CmpINode(cset_load, igvn.zerocon(T_INT)); + Node* cset_bool = new BoolNode(cset_cmp, BoolTest::eq); - ctrl = new IfFalseNode(in_cset_fast_test_iff); - phase->register_control(ctrl, loop, in_cset_fast_test_iff); + IfNode* cset_iff = new IfNode(old_ctrl, cset_bool, PROB_UNLIKELY(0.999), COUNT_UNKNOWN); + not_cset_ctrl = new IfTrueNode(cset_iff); + ctrl = new IfFalseNode(cset_iff); + + IdealLoopTree *loop = phase->get_loop(old_ctrl); + phase->register_control(cset_iff, loop, old_ctrl); + phase->register_control(not_cset_ctrl, loop, cset_iff); + phase->register_control(ctrl, loop, cset_iff); + + phase->set_ctrl(cset_addr, phase->C->root()); + + phase->register_new_node(raw_val, old_ctrl); + phase->register_new_node(cset_idx, old_ctrl); + phase->register_new_node(cset_load_addr, old_ctrl); + phase->register_new_node(cset_load, old_ctrl); + phase->register_new_node(cset_cmp, old_ctrl); + phase->register_new_node(cset_bool, old_ctrl); } void ShenandoahBarrierC2Support::call_lrb_stub(Node*& ctrl, Node*& val, Node* load_addr, Node*& result_mem, Node* raw_mem, bool is_native, PhaseIdealLoop* phase) { @@ -1235,7 +1249,7 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) { // Stable path. Node* heap_stable_ctrl = NULL; - test_heap_state(ctrl, raw_mem, heap_stable_ctrl, phase, ShenandoahHeap::HAS_FORWARDED); + test_gc_state(ctrl, raw_mem, heap_stable_ctrl, phase, ShenandoahHeap::HAS_FORWARDED); IfNode* heap_stable_iff = heap_stable_ctrl->in(0)->as_If(); // Heap stable case @@ -1246,7 +1260,7 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) { // Test for in-cset. // Wires !in_cset(obj) to slot 2 of region and phis Node* not_cset_ctrl = NULL; - in_cset_fast_test(ctrl, not_cset_ctrl, val, raw_mem, phase); + test_in_cset(ctrl, not_cset_ctrl, val, raw_mem, phase); if (not_cset_ctrl != NULL) { region->init_req(_not_cset, not_cset_ctrl); val_phi->init_req(_not_cset, val); @@ -1364,7 +1378,7 @@ void ShenandoahBarrierC2Support::pin_and_expand(PhaseIdealLoop* phase) { Node* phi2 = PhiNode::make(region2, raw_mem, Type::MEMORY, TypeRawPtr::BOTTOM); // Stable path. - test_heap_state(ctrl, raw_mem, heap_stable_ctrl, phase, ShenandoahHeap::MARKING); + test_gc_state(ctrl, raw_mem, heap_stable_ctrl, phase, ShenandoahHeap::MARKING); region->init_req(_heap_stable, heap_stable_ctrl); phi->init_req(_heap_stable, raw_mem); @@ -1546,7 +1560,7 @@ Node* ShenandoahBarrierC2Support::get_load_addr(PhaseIdealLoop* phase, VectorSet } -void ShenandoahBarrierC2Support::move_heap_stable_test_out_of_loop(IfNode* iff, PhaseIdealLoop* phase) { +void ShenandoahBarrierC2Support::move_gc_state_test_out_of_loop(IfNode* iff, PhaseIdealLoop* phase) { IdealLoopTree *loop = phase->get_loop(iff); Node* loop_head = loop->_head; Node* entry_c = loop_head->in(LoopNode::EntryControl); @@ -1740,7 +1754,7 @@ void ShenandoahBarrierC2Support::optimize_after_expansion(VectorSet &visited, No if (head->as_Loop()->is_strip_mined()) { head->as_Loop()->verify_strip_mined(0); } - move_heap_stable_test_out_of_loop(iff, phase); + move_gc_state_test_out_of_loop(iff, phase); AutoNodeBudget node_budget(phase); diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp index 097f6554aa1..3e15fa09937 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.hpp @@ -53,16 +53,16 @@ private: #endif static Node* dom_mem(Node* mem, Node* ctrl, int alias, Node*& mem_ctrl, PhaseIdealLoop* phase); static Node* no_branches(Node* c, Node* dom, bool allow_one_proj, PhaseIdealLoop* phase); - static bool is_heap_state_test(Node* iff, int mask); + static bool is_gc_state_test(Node* iff, int mask); static bool has_safepoint_between(Node* start, Node* stop, PhaseIdealLoop *phase); static Node* find_bottom_mem(Node* ctrl, PhaseIdealLoop* phase); static void follow_barrier_uses(Node* n, Node* ctrl, Unique_Node_List& uses, PhaseIdealLoop* phase); static void test_null(Node*& ctrl, Node* val, Node*& null_ctrl, PhaseIdealLoop* phase); - static void test_heap_state(Node*& ctrl, Node* raw_mem, Node*& heap_stable_ctrl, - PhaseIdealLoop* phase, int flags); + static void test_gc_state(Node*& ctrl, Node* raw_mem, Node*& heap_stable_ctrl, + PhaseIdealLoop* phase, int flags); static void call_lrb_stub(Node*& ctrl, Node*& val, Node* load_addr, Node*& result_mem, Node* raw_mem, bool is_native, PhaseIdealLoop* phase); - static void in_cset_fast_test(Node*& ctrl, Node*& not_cset_ctrl, Node* val, Node* raw_mem, PhaseIdealLoop* phase); - static void move_heap_stable_test_out_of_loop(IfNode* iff, PhaseIdealLoop* phase); + static void test_in_cset(Node*& ctrl, Node*& not_cset_ctrl, Node* val, Node* raw_mem, PhaseIdealLoop* phase); + static void move_gc_state_test_out_of_loop(IfNode* iff, PhaseIdealLoop* phase); static void merge_back_to_back_tests(Node* n, PhaseIdealLoop* phase); static bool identical_backtoback_ifs(Node *n, PhaseIdealLoop* phase); static void fix_ctrl(Node* barrier, Node* region, const MemoryGraphFixer& fixer, Unique_Node_List& uses, Unique_Node_List& uses_to_ignore, uint last, PhaseIdealLoop* phase); From b231ad70c89e8fb223643bd48c33d6ab7e7ab2bf Mon Sep 17 00:00:00 2001 From: Aleksey Shipilev Date: Thu, 7 May 2020 12:48:21 +0200 Subject: [PATCH 74/88] 8244510: Shenandoah: invert SHC2Support::is_in_cset condition Reviewed-by: rkennke, roland --- src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp index 3c0f231ec8e..0d73eb89e34 100644 --- a/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp +++ b/src/hotspot/share/gc/shenandoah/c2/shenandoahSupport.cpp @@ -931,16 +931,16 @@ void ShenandoahBarrierC2Support::test_in_cset(Node*& ctrl, Node*& not_cset_ctrl, DEBUG_ONLY(phase->C->get_adr_type(Compile::AliasIdxRaw)) NOT_DEBUG(NULL), TypeInt::BYTE, MemNode::unordered); Node* cset_cmp = new CmpINode(cset_load, igvn.zerocon(T_INT)); - Node* cset_bool = new BoolNode(cset_cmp, BoolTest::eq); + Node* cset_bool = new BoolNode(cset_cmp, BoolTest::ne); IfNode* cset_iff = new IfNode(old_ctrl, cset_bool, PROB_UNLIKELY(0.999), COUNT_UNKNOWN); - not_cset_ctrl = new IfTrueNode(cset_iff); - ctrl = new IfFalseNode(cset_iff); + ctrl = new IfTrueNode(cset_iff); + not_cset_ctrl = new IfFalseNode(cset_iff); IdealLoopTree *loop = phase->get_loop(old_ctrl); phase->register_control(cset_iff, loop, old_ctrl); - phase->register_control(not_cset_ctrl, loop, cset_iff); phase->register_control(ctrl, loop, cset_iff); + phase->register_control(not_cset_ctrl, loop, cset_iff); phase->set_ctrl(cset_addr, phase->C->root()); From 62bf2d07e7864cff2c8759acfb17580725cdfd0a Mon Sep 17 00:00:00 2001 From: Roman Kennke Date: Thu, 7 May 2020 08:00:30 -0400 Subject: [PATCH 75/88] 8244551: Shenandoah: Fix racy update of update_watermark Reviewed-by: shade --- .../share/gc/shenandoah/shenandoahHeap.cpp | 2 +- .../gc/shenandoah/shenandoahHeapRegion.hpp | 18 ++++-------------- .../shenandoah/shenandoahHeapRegion.inline.hpp | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp index 2f118317dc1..522d2494450 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp @@ -1484,7 +1484,7 @@ public: // Remember limit for updating refs. It's guaranteed that we get no // from-space-refs written from here on. - r->set_update_watermark(r->top()); + r->set_update_watermark_at_safepoint(r->top()); } else { assert(!r->has_live(), "Region " SIZE_FORMAT " should have no live data", r->index()); assert(_ctx->top_at_mark_start(r) == r->top(), diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.hpp index a45bb7620b2..766ab496c44 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.hpp @@ -243,7 +243,7 @@ private: volatile size_t _live_data; volatile size_t _critical_pins; - HeapWord* _update_watermark; + HeapWord* volatile _update_watermark; public: ShenandoahHeapRegion(HeapWord* start, size_t index, bool committed); @@ -382,19 +382,9 @@ public: size_t get_tlab_allocs() const; size_t get_gclab_allocs() const; - HeapWord* get_update_watermark() const { - // Updates to the update-watermark only happen at safepoints. - // Since those updates are only monotonically increasing, possibly reading - // a stale value is only conservative - we would not miss to update any fields. - HeapWord* watermark = _update_watermark; - assert(bottom() <= watermark && watermark <= top(), "within bounds"); - return watermark; - } - - void set_update_watermark(HeapWord* w) { - assert(bottom() <= w && w <= top(), "within bounds"); - _update_watermark = w; - } + inline HeapWord* get_update_watermark() const; + inline void set_update_watermark(HeapWord* w); + inline void set_update_watermark_at_safepoint(HeapWord* w); private: void do_commit(); diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.inline.hpp index be5ac605c12..c02c00b7d4f 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeapRegion.inline.hpp @@ -114,4 +114,22 @@ inline size_t ShenandoahHeapRegion::garbage() const { return result; } +inline HeapWord* ShenandoahHeapRegion::get_update_watermark() const { + HeapWord* watermark = Atomic::load_acquire(&_update_watermark); + assert(bottom() <= watermark && watermark <= top(), "within bounds"); + return watermark; +} + +inline void ShenandoahHeapRegion::set_update_watermark(HeapWord* w) { + assert(bottom() <= w && w <= top(), "within bounds"); + Atomic::release_store(&_update_watermark, w); +} + +// Fast version that avoids synchronization, only to be used at safepoints. +inline void ShenandoahHeapRegion::set_update_watermark_at_safepoint(HeapWord* w) { + assert(bottom() <= w && w <= top(), "within bounds"); + assert(SafepointSynchronize::is_at_safepoint(), "Should be at Shenandoah safepoint"); + _update_watermark = w; +} + #endif // SHARE_GC_SHENANDOAH_SHENANDOAHHEAPREGION_INLINE_HPP From c2780c9556eaa51fd3eb5e6acf5a433f5a766759 Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Thu, 7 May 2020 14:09:20 +0200 Subject: [PATCH 76/88] 8244550: Unsafe::allocateInstance does redundant transitions Reviewed-by: coleenp, mchung, dholmes --- src/hotspot/share/c1/c1_Runtime1.cpp | 1 + .../share/classfile/classListParser.cpp | 1 + src/hotspot/share/classfile/javaClasses.cpp | 8 ------- .../share/classfile/javaClasses.inline.hpp | 8 +++++++ .../jfr/leakprofiler/chains/edgeUtils.cpp | 2 +- .../checkpoint/objectSampleDescription.cpp | 2 +- .../checkpoint/types/traceid/jfrTraceId.cpp | 1 + .../share/jvmci/jvmciCodeInstaller.cpp | 1 + src/hotspot/share/jvmci/jvmciRuntime.cpp | 1 + src/hotspot/share/oops/instanceKlass.hpp | 1 + .../share/oops/instanceKlass.inline.hpp | 12 ++++++++++ src/hotspot/share/prims/jni.cpp | 23 ++++--------------- src/hotspot/share/prims/unsafe.cpp | 6 +++-- src/hotspot/share/prims/whitebox.cpp | 1 + src/hotspot/share/runtime/deoptimization.cpp | 1 + src/hotspot/share/runtime/vframe.cpp | 2 +- 16 files changed, 40 insertions(+), 31 deletions(-) diff --git a/src/hotspot/share/c1/c1_Runtime1.cpp b/src/hotspot/share/c1/c1_Runtime1.cpp index 54ea68a11a9..5ed06b70ab5 100644 --- a/src/hotspot/share/c1/c1_Runtime1.cpp +++ b/src/hotspot/share/c1/c1_Runtime1.cpp @@ -30,6 +30,7 @@ #include "c1/c1_LIRAssembler.hpp" #include "c1/c1_MacroAssembler.hpp" #include "c1/c1_Runtime1.hpp" +#include "classfile/javaClasses.inline.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "code/codeBlob.hpp" diff --git a/src/hotspot/share/classfile/classListParser.cpp b/src/hotspot/share/classfile/classListParser.cpp index 470c2e04897..3d7ba9d99f2 100644 --- a/src/hotspot/share/classfile/classListParser.cpp +++ b/src/hotspot/share/classfile/classListParser.cpp @@ -27,6 +27,7 @@ #include "jimage.hpp" #include "classfile/classListParser.hpp" #include "classfile/classLoaderExt.hpp" +#include "classfile/javaClasses.inline.hpp" #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/systemDictionaryShared.hpp" diff --git a/src/hotspot/share/classfile/javaClasses.cpp b/src/hotspot/share/classfile/javaClasses.cpp index 347437f8778..92b01bb83ab 100644 --- a/src/hotspot/share/classfile/javaClasses.cpp +++ b/src/hotspot/share/classfile/javaClasses.cpp @@ -1495,14 +1495,6 @@ oop java_lang_Class::create_basic_type_mirror(const char* basic_type_name, Basic } -Klass* java_lang_Class::as_Klass(oop java_class) { - //%note memory_2 - assert(java_lang_Class::is_instance(java_class), "must be a Class object"); - Klass* k = ((Klass*)java_class->metadata_field(_klass_offset)); - assert(k == NULL || k->is_klass(), "type check"); - return k; -} - Klass* java_lang_Class::as_Klass_raw(oop java_class) { //%note memory_2 assert(java_lang_Class::is_instance(java_class), "must be a Class object"); diff --git a/src/hotspot/share/classfile/javaClasses.inline.hpp b/src/hotspot/share/classfile/javaClasses.inline.hpp index a003943bde4..efdcfd8642b 100644 --- a/src/hotspot/share/classfile/javaClasses.inline.hpp +++ b/src/hotspot/share/classfile/javaClasses.inline.hpp @@ -211,6 +211,14 @@ inline bool java_lang_Class::is_instance(oop obj) { return obj != NULL && obj->klass() == SystemDictionary::Class_klass(); } +inline Klass* java_lang_Class::as_Klass(oop java_class) { + //%note memory_2 + assert(java_lang_Class::is_instance(java_class), "must be a Class object"); + Klass* k = ((Klass*)java_class->metadata_field(_klass_offset)); + assert(k == NULL || k->is_klass(), "type check"); + return k; +} + inline bool java_lang_Class::is_primitive(oop java_class) { // should assert: //assert(java_lang_Class::is_instance(java_class), "must be a Class object"); diff --git a/src/hotspot/share/jfr/leakprofiler/chains/edgeUtils.cpp b/src/hotspot/share/jfr/leakprofiler/chains/edgeUtils.cpp index 68fc980efbe..dff2e144220 100644 --- a/src/hotspot/share/jfr/leakprofiler/chains/edgeUtils.cpp +++ b/src/hotspot/share/jfr/leakprofiler/chains/edgeUtils.cpp @@ -23,7 +23,7 @@ */ #include "precompiled.hpp" -#include "classfile/javaClasses.hpp" +#include "classfile/javaClasses.inline.hpp" #include "jfr/leakprofiler/chains/edge.hpp" #include "jfr/leakprofiler/chains/edgeStore.hpp" #include "jfr/leakprofiler/chains/edgeUtils.hpp" diff --git a/src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleDescription.cpp b/src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleDescription.cpp index 2399275712a..189394b6ec2 100644 --- a/src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleDescription.cpp +++ b/src/hotspot/share/jfr/leakprofiler/checkpoint/objectSampleDescription.cpp @@ -23,7 +23,7 @@ */ #include "precompiled.hpp" -#include "classfile/javaClasses.hpp" +#include "classfile/javaClasses.inline.hpp" #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" #include "jfr/leakprofiler/checkpoint/objectSampleDescription.hpp" diff --git a/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.cpp b/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.cpp index 8a994d00b0f..66617db77aa 100644 --- a/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.cpp +++ b/src/hotspot/share/jfr/recorder/checkpoint/types/traceid/jfrTraceId.cpp @@ -24,6 +24,7 @@ #include "precompiled.hpp" #include "classfile/classLoaderData.inline.hpp" +#include "classfile/javaClasses.inline.hpp" #include "classfile/symbolTable.hpp" #include "jfr/recorder/checkpoint/types/traceid/jfrTraceId.inline.hpp" #include "jfr/utilities/jfrTypes.hpp" diff --git a/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp b/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp index bf2c27b6527..8aed5c87ffc 100644 --- a/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp +++ b/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp @@ -22,6 +22,7 @@ */ #include "precompiled.hpp" +#include "classfile/javaClasses.inline.hpp" #include "code/compiledIC.hpp" #include "compiler/compileBroker.hpp" #include "jvmci/jvmciCodeInstaller.hpp" diff --git a/src/hotspot/share/jvmci/jvmciRuntime.cpp b/src/hotspot/share/jvmci/jvmciRuntime.cpp index c23287775a3..e603452618f 100644 --- a/src/hotspot/share/jvmci/jvmciRuntime.cpp +++ b/src/hotspot/share/jvmci/jvmciRuntime.cpp @@ -22,6 +22,7 @@ */ #include "precompiled.hpp" +#include "classfile/javaClasses.inline.hpp" #include "classfile/symbolTable.hpp" #include "compiler/compileBroker.hpp" #include "jvmci/jniAccessMark.inline.hpp" diff --git a/src/hotspot/share/oops/instanceKlass.hpp b/src/hotspot/share/oops/instanceKlass.hpp index fa57a4dc083..a431a8606e2 100644 --- a/src/hotspot/share/oops/instanceKlass.hpp +++ b/src/hotspot/share/oops/instanceKlass.hpp @@ -958,6 +958,7 @@ public: } // allocation instanceOop allocate_instance(TRAPS); + static instanceOop allocate_instance(oop cls, TRAPS); // additional member function to return a handle instanceHandle allocate_instance_handle(TRAPS); diff --git a/src/hotspot/share/oops/instanceKlass.inline.hpp b/src/hotspot/share/oops/instanceKlass.inline.hpp index 06402664251..b2038ea496e 100644 --- a/src/hotspot/share/oops/instanceKlass.inline.hpp +++ b/src/hotspot/share/oops/instanceKlass.inline.hpp @@ -157,4 +157,16 @@ ALWAYSINLINE void InstanceKlass::oop_oop_iterate_bounded(oop obj, OopClosureType oop_oop_iterate_oop_maps_bounded(obj, closure, mr); } +inline instanceOop InstanceKlass::allocate_instance(oop java_class, TRAPS) { + Klass* k = java_lang_Class::as_Klass(java_class); + if (k == NULL) { + ResourceMark rm(THREAD); + THROW_(vmSymbols::java_lang_InstantiationException(), NULL); + } + InstanceKlass* ik = cast(k); + ik->check_valid_for_instantiation(false, CHECK_NULL); + ik->initialize(CHECK_NULL); + return ik->allocate_instance(THREAD); +} + #endif // SHARE_OOPS_INSTANCEKLASS_INLINE_HPP diff --git a/src/hotspot/share/prims/jni.cpp b/src/hotspot/share/prims/jni.cpp index c87d309ca85..a18d4801aa6 100644 --- a/src/hotspot/share/prims/jni.cpp +++ b/src/hotspot/share/prims/jni.cpp @@ -49,7 +49,7 @@ #include "memory/universe.hpp" #include "oops/access.inline.hpp" #include "oops/arrayOop.inline.hpp" -#include "oops/instanceKlass.hpp" +#include "oops/instanceKlass.inline.hpp" #include "oops/instanceOop.hpp" #include "oops/markWord.hpp" #include "oops/method.hpp" @@ -1064,19 +1064,6 @@ static void jni_invoke_nonstatic(JNIEnv *env, JavaValue* result, jobject receive } } - -static instanceOop alloc_object(jclass clazz, TRAPS) { - Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz)); - if (k == NULL) { - ResourceMark rm(THREAD); - THROW_(vmSymbols::java_lang_InstantiationException(), NULL); - } - k->check_valid_for_instantiation(false, CHECK_NULL); - k->initialize(CHECK_NULL); - instanceOop ih = InstanceKlass::cast(k)->allocate_instance(THREAD); - return ih; -} - DT_RETURN_MARK_DECL(AllocObject, jobject , HOTSPOT_JNI_ALLOCOBJECT_RETURN(_ret_ref)); @@ -1088,7 +1075,7 @@ JNI_ENTRY(jobject, jni_AllocObject(JNIEnv *env, jclass clazz)) jobject ret = NULL; DT_RETURN_MARK(AllocObject, jobject, (const jobject&)ret); - instanceOop i = alloc_object(clazz, CHECK_NULL); + instanceOop i = InstanceKlass::allocate_instance(JNIHandles::resolve_non_null(clazz), CHECK_NULL); ret = JNIHandles::make_local(env, i); return ret; JNI_END @@ -1104,7 +1091,7 @@ JNI_ENTRY(jobject, jni_NewObjectA(JNIEnv *env, jclass clazz, jmethodID methodID, jobject obj = NULL; DT_RETURN_MARK(NewObjectA, jobject, (const jobject)obj); - instanceOop i = alloc_object(clazz, CHECK_NULL); + instanceOop i = InstanceKlass::allocate_instance(JNIHandles::resolve_non_null(clazz), CHECK_NULL); obj = JNIHandles::make_local(env, i); JavaValue jvalue(T_VOID); JNI_ArgumentPusherArray ap(methodID, args); @@ -1124,7 +1111,7 @@ JNI_ENTRY(jobject, jni_NewObjectV(JNIEnv *env, jclass clazz, jmethodID methodID, jobject obj = NULL; DT_RETURN_MARK(NewObjectV, jobject, (const jobject&)obj); - instanceOop i = alloc_object(clazz, CHECK_NULL); + instanceOop i = InstanceKlass::allocate_instance(JNIHandles::resolve_non_null(clazz), CHECK_NULL); obj = JNIHandles::make_local(env, i); JavaValue jvalue(T_VOID); JNI_ArgumentPusherVaArg ap(methodID, args); @@ -1144,7 +1131,7 @@ JNI_ENTRY(jobject, jni_NewObject(JNIEnv *env, jclass clazz, jmethodID methodID, jobject obj = NULL; DT_RETURN_MARK(NewObject, jobject, (const jobject&)obj); - instanceOop i = alloc_object(clazz, CHECK_NULL); + instanceOop i = InstanceKlass::allocate_instance(JNIHandles::resolve_non_null(clazz), CHECK_NULL); obj = JNIHandles::make_local(env, i); va_list args; va_start(args, methodID); diff --git a/src/hotspot/share/prims/unsafe.cpp b/src/hotspot/share/prims/unsafe.cpp index 670b17a5ed2..003b73e6785 100644 --- a/src/hotspot/share/prims/unsafe.cpp +++ b/src/hotspot/share/prims/unsafe.cpp @@ -27,12 +27,14 @@ #include "jvm.h" #include "classfile/classFileStream.hpp" #include "classfile/classLoader.hpp" +#include "classfile/javaClasses.inline.hpp" #include "classfile/vmSymbols.hpp" #include "jfr/jfrEvents.hpp" #include "memory/allocation.inline.hpp" #include "memory/resourceArea.hpp" #include "oops/access.inline.hpp" #include "oops/fieldStreams.inline.hpp" +#include "oops/instanceKlass.inline.hpp" #include "oops/objArrayOop.inline.hpp" #include "oops/oop.inline.hpp" #include "oops/typeArrayOop.inline.hpp" @@ -353,8 +355,8 @@ UNSAFE_LEAF(void, Unsafe_FullFence(JNIEnv *env, jobject unsafe)) { ////// Allocation requests UNSAFE_ENTRY(jobject, Unsafe_AllocateInstance(JNIEnv *env, jobject unsafe, jclass cls)) { - ThreadToNativeFromVM ttnfv(thread); - return env->AllocObject(cls); + instanceOop i = InstanceKlass::allocate_instance(JNIHandles::resolve_non_null(cls), CHECK_NULL); + return JNIHandles::make_local(env, i); } UNSAFE_END UNSAFE_ENTRY(jlong, Unsafe_AllocateMemory0(JNIEnv *env, jobject unsafe, jlong size)) { diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp index e749d23f62b..b749201c131 100644 --- a/src/hotspot/share/prims/whitebox.cpp +++ b/src/hotspot/share/prims/whitebox.cpp @@ -27,6 +27,7 @@ #include #include "classfile/classLoaderDataGraph.hpp" +#include "classfile/javaClasses.inline.hpp" #include "classfile/modules.hpp" #include "classfile/protectionDomainCache.hpp" #include "classfile/stringTable.hpp" diff --git a/src/hotspot/share/runtime/deoptimization.cpp b/src/hotspot/share/runtime/deoptimization.cpp index 4f300b144db..013c2a8d101 100644 --- a/src/hotspot/share/runtime/deoptimization.cpp +++ b/src/hotspot/share/runtime/deoptimization.cpp @@ -26,6 +26,7 @@ #include "precompiled.hpp" #include "jvm.h" +#include "classfile/javaClasses.inline.hpp" #include "classfile/symbolTable.hpp" #include "classfile/systemDictionary.hpp" #include "code/codeCache.hpp" diff --git a/src/hotspot/share/runtime/vframe.cpp b/src/hotspot/share/runtime/vframe.cpp index 52958f58832..8bad7b29ba9 100644 --- a/src/hotspot/share/runtime/vframe.cpp +++ b/src/hotspot/share/runtime/vframe.cpp @@ -23,7 +23,7 @@ */ #include "precompiled.hpp" -#include "classfile/javaClasses.hpp" +#include "classfile/javaClasses.inline.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" #include "code/codeCache.hpp" From 93b0516d5d6e88a7e93f3ac06e02c9771def753f Mon Sep 17 00:00:00 2001 From: Pavel Rappo Date: Thu, 7 May 2020 13:59:18 +0100 Subject: [PATCH 77/88] 8224613: javadoc should better handle bad options Reviewed-by: jjg --- .../javadoc/internal/tool/JavadocTool.java | 6 +- .../jdk/javadoc/internal/tool/Main.java | 8 +- .../jdk/javadoc/internal/tool/Start.java | 53 ++- .../javadoc/internal/tool/ToolOptions.java | 4 +- .../8224613/OptionProcessingFailureTest.java | 335 ++++++++++++++++++ 5 files changed, 383 insertions(+), 23 deletions(-) create mode 100644 test/langtools/jdk/javadoc/tool/8224613/OptionProcessingFailureTest.java diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java index 319364356c7..c01a9f23ee8 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/JavadocTool.java @@ -127,8 +127,10 @@ public class JavadocTool extends com.sun.tools.javac.main.JavaCompiler { } public DocletEnvironment getEnvironment(ToolOptions toolOptions, - List javaNames, - Iterable fileObjects) throws ToolException { + List javaNames, + Iterable fileObjects) + throws ToolException + { toolEnv = ToolEnvironment.instance(context); toolEnv.initialize(toolOptions); ElementsTable etable = new ElementsTable(context, toolOptions); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Main.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Main.java index 5925c226c54..467c28adba1 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Main.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Main.java @@ -46,7 +46,7 @@ public class Main { * The main entry point called by the launcher. This will call * System.exit with an appropriate return value. * - * @param args The command line parameters. + * @param args the command-line parameters */ public static void main(String... args) { System.exit(execute(args)); @@ -55,7 +55,7 @@ public class Main { /** * Programmatic interface. * - * @param args The command line parameters. + * @param args the command-line parameters * @return The return code. */ public static int execute(String... args) { @@ -67,7 +67,7 @@ public class Main { * Programmatic interface. * * @param writer a stream for all output - * @param args The command line parameters. + * @param args the command-line parameters * @return The return code. */ public static int execute(String[] args, PrintWriter writer) { @@ -80,7 +80,7 @@ public class Main { * * @param outWriter a stream for expected output * @param errWriter a stream for diagnostic output - * @param args The command line parameters. + * @param args the command-line parameters * @return The return code. */ public static int execute(String[] args, PrintWriter outWriter, PrintWriter errWriter) { diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java index bc237e8773e..bb213615f1b 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java @@ -495,7 +495,12 @@ public class Start { arguments.allowEmpty(); doclet.init(locale, messager); - parseArgs(argList, javaNames); + int beforeCount = messager.nerrors; + boolean success = parseArgs(argList, javaNames); + int afterCount = messager.nerrors; + if (!success && beforeCount == afterCount) { // if there were failures but they have not been reported + return CMDERR; + } if (!arguments.handleReleaseOptions(extra -> true)) { // Arguments does not always increase the error count in the @@ -579,8 +584,13 @@ public class Start { } private Set docletOptions = null; - int handleDocletOption(int idx, List args, boolean isToolOption) - throws OptionException { + + /* + * Consumes an option along with its arguments. Returns an advanced index + * modulo the sign. If the value is negative, it means there was a failure + * processing one or more options. + */ + int consumeDocletOption(int idx, List args, boolean isToolOption) throws OptionException { if (docletOptions == null) { docletOptions = getSupportedOptionsOf(doclet); } @@ -594,6 +604,7 @@ public class Start { argBase = arg; argVal = null; } + int m = 1; String text = null; for (Doclet.Option opt : docletOptions) { if (matches(opt, argBase)) { @@ -603,21 +614,25 @@ public class Start { text = messager.getText("main.unnecessary_arg_provided", argBase); throw new OptionException(ERROR, this::showUsage, text); case 1: - opt.process(arg, Arrays.asList(argVal)); + if (!opt.process(arg, Collections.singletonList(argVal))) { + m = -1; + } break; default: text = messager.getText("main.only_one_argument_with_equals", argBase); throw new OptionException(ERROR, this::showUsage, text); } } else { - if (args.size() - idx -1 < opt.getArgumentCount()) { + if (args.size() - idx - 1 < opt.getArgumentCount()) { text = messager.getText("main.requires_argument", arg); throw new OptionException(ERROR, this::showUsage, text); } - opt.process(arg, args.subList(idx + 1, args.size())); + if (!opt.process(arg, args.subList(idx + 1, idx + 1 + opt.getArgumentCount()))) { + m = -1; + } idx += opt.getArgumentCount(); } - return idx; + return m * idx; } } // check if arg is accepted by the tool before emitting error @@ -625,7 +640,7 @@ public class Start { text = messager.getText("main.invalid_flag", arg); throw new OptionException(ERROR, this::showUsage, text); } - return idx; + return m * idx; } private static Set getSupportedOptionsOf(Doclet doclet) { @@ -649,8 +664,7 @@ public class Start { * @throws ToolException if an error occurs initializing the doclet * @throws OptionException if an error occurs while processing an option */ - private Doclet preprocess(List argv) - throws ToolException, OptionException { + private Doclet preprocess(List argv) throws ToolException, OptionException { // doclet specifying arguments String userDocletPath = null; String userDocletName = null; @@ -774,15 +788,19 @@ public class Start { } } - private void parseArgs(List args, List javaNames) throws ToolException, - OptionException, com.sun.tools.javac.main.Option.InvalidValueException { + private boolean parseArgs(List args, List javaNames) + throws OptionException, com.sun.tools.javac.main.Option.InvalidValueException + { + boolean success = true; for (int i = 0; i < args.size(); i++) { String arg = args.get(i); ToolOption o = options.getOption(arg); if (o != null) { // handle a doclet argument that may be needed however // don't increment the index, and allow the tool to consume args - handleDocletOption(i, args, true); + if (consumeDocletOption(i, args, true) < 0) { + success = false; + } if (o.hasArg) { if (arg.startsWith("--") && arg.contains("=")) { o.process(arg.substring(arg.indexOf('=') + 1)); @@ -800,14 +818,19 @@ public class Start { String s = arg.substring("-XD".length()); int eq = s.indexOf('='); String key = (eq < 0) ? s : s.substring(0, eq); - String value = (eq < 0) ? s : s.substring(eq+1); + String value = (eq < 0) ? s : s.substring(eq + 1); options.compilerOptions().put(key, value); } else if (arg.startsWith("-")) { - i = handleDocletOption(i, args, false); + i = consumeDocletOption(i, args, false); + if (i < 0) { + i = -i; + success = false; + } } else { javaNames.add(arg); } } + return success; } private boolean isEmpty(Iterable iter) { diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOptions.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOptions.java index 1fe138b3804..160d4c01660 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOptions.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ToolOptions.java @@ -696,7 +696,7 @@ public class ToolOptions { } void setDumpOnError(boolean v) { - dumpOnError = true; + dumpOnError = v; } /** @@ -816,7 +816,7 @@ public class ToolOptions { /** * Returns an {@code IllegalOptionValue} exception. * - * @param arg the arghument to include in the detail message + * @param arg the argument to include in the detail message * @return the exception */ private IllegalOptionValue illegalOptionValue(String arg) { diff --git a/test/langtools/jdk/javadoc/tool/8224613/OptionProcessingFailureTest.java b/test/langtools/jdk/javadoc/tool/8224613/OptionProcessingFailureTest.java new file mode 100644 index 00000000000..dab4144d335 --- /dev/null +++ b/test/langtools/jdk/javadoc/tool/8224613/OptionProcessingFailureTest.java @@ -0,0 +1,335 @@ +/* + * 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 8224613 + * @library /tools/lib ../../lib + * @modules jdk.javadoc/jdk.javadoc.internal.tool + * @build javadoc.tester.* toolbox.ToolBox builder.ClassBuilder + * @run main/othervm OptionProcessingFailureTest + */ + +import builder.ClassBuilder; +import javadoc.tester.JavadocTester; +import jdk.javadoc.doclet.Doclet; +import jdk.javadoc.doclet.DocletEnvironment; +import jdk.javadoc.doclet.Reporter; +import toolbox.ToolBox; + +import javax.lang.model.SourceVersion; +import javax.tools.Diagnostic; +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; + +/* + * Tests that a particular error is raised only if a doclet has not reported any + * errors (to Reporter), and yet at least one of that Doclet's options returned + * `false` from the `Doclet.Option.process` method. + * + * This test explores scenarios generated by combining a few independent factors + * involved in failing a doclet run. These factors are: + * + * 1. Reporting errors in Doclet.init(...) + * 2. Reporting errors in Doclet.Option.process(...) + * 3. Returning `false` from Doclet.Option.process(...) + * + * A doclet that behaves according to a scenario is run by the javadoc tool. An + * output of that run is then examined for presence of a particular error. That + * error must be in the output if and only if one or more options returned + * `false` from Doclet.Option.process(...) and no other errors were reported. + * + * Configuration of the doclet is performed out-of-band, using System Properties + * (when running the javadoc tool from the command line this could be achieved + * using -J-Dsystem.property.name=value syntax). The "puppet" doclet is + * instructed on which options is has, how many errors it should report, + * and how each individual option should be processed. + */ +public class OptionProcessingFailureTest extends JavadocTester { + + private final ToolBox tb = new ToolBox(); + + public static void main(String... args) throws Exception { + new OptionProcessingFailureTest().runTests(m -> new Object[]{Paths.get(m.getName())}); + } + + @Test + public void test(Path base) throws IOException { + Path srcDir = base.resolve("src"); + + // Since the minimal successful run of the javadoc tool with a custom + // doclet involves source files, a package with a class in it is generated: + new ClassBuilder(tb, "pkg.A") + .setModifiers("public", "class") + .write(srcDir); + + generateScenarios(base, this::testScenario); + } + + private static void generateScenarios(Path base, ScenarioConsumer consumer) { + for (int nInitErrors : List.of(0, 1)) { // the number of errors the Doclet.init method should report + for (int nOptions : List.of(0, 1, 2)) { // the number of options a doclet should have + generateOptionsCombinations(base, nInitErrors, nOptions, consumer); + } + } + } + + private static void generateOptionsCombinations(Path base, + int nInitErrors, + int nOptions, + ScenarioConsumer consumer) { + var emptyDescriptions = new PuppetOption.Description[nOptions]; + generateOptionsCombinations(base, nInitErrors, 0, emptyDescriptions, consumer); + } + + + private static void generateOptionsCombinations(Path base, + int nInitErrors, + int descriptionsIndex, + PuppetOption.Description[] descriptions, + ScenarioConsumer consumer) { + if (descriptionsIndex >= descriptions.length) { + consumer.consume(base, nInitErrors, List.of(descriptions)); + return; + } + for (boolean success : List.of(true, false)) { // return values of Doclet.Options.process + for (int nErrors : List.of(0, 1)) { // the number of errors Doclet.Options.process should report + String optionName = "--doclet-option-" + descriptionsIndex; + descriptions[descriptionsIndex] = new PuppetOption.Description(optionName, success, nErrors); + generateOptionsCombinations(base, nInitErrors, descriptionsIndex + 1, descriptions, consumer); + } + } + } + + private void testScenario(Path base, + int nInitErrors, + List optionDescriptions) { + System.out.printf("nInitErrors=%s, optionDescriptions=%s%n", nInitErrors, optionDescriptions); + + List args = new ArrayList<>( + List.of("-doclet", PuppetDoclet.class.getName(), + "-docletpath", System.getProperty("test.classes", "."), + "-sourcepath", base.resolve("src").toString(), + "pkg")); + + optionDescriptions.forEach(d -> args.add(d.name)); // options passed to the doclet + + /* The puppet doclet does not create any output directories, so there is + no need for any related checks; other checks are disabled to speed up + the processing and reduce the size of the output. */ + + setOutputDirectoryCheck(DirectoryCheck.NONE); + setAutomaticCheckAccessibility(false); + setAutomaticCheckLinks(false); + + /* Ideally, the system properties should've been passed to the `javadoc` + method below. However, since there's no such option, the system + properties are manipulated in an external fashion. */ + + String descriptions = System.getProperty("puppet.descriptions"); + if (descriptions != null) { + throw new IllegalStateException(descriptions); + } + String errors = System.getProperty("puppet.errors"); + if (errors != null) { + throw new IllegalStateException(errors); + } + try { + System.setProperty("puppet.descriptions", PuppetDoclet.descriptionsToString(optionDescriptions)); + System.setProperty("puppet.errors", String.valueOf(nInitErrors)); + javadoc(args.toArray(new String[0])); + } finally { + System.clearProperty("puppet.descriptions"); + System.clearProperty("puppet.errors"); + } + + long sumErrors = optionDescriptions.stream().mapToLong(d -> d.nProcessErrors).sum() + nInitErrors; + boolean success = optionDescriptions.stream().allMatch(d -> d.success); + + checkOutput(Output.OUT, sumErrors != 0 || !success, "error - "); + } + + /* Creating a specialized consumer is even more lightweight than creating a POJO */ + @FunctionalInterface + public interface ScenarioConsumer { + void consume(Path src, int nInitErrors, List optionDescriptions); + } + + public static final class PuppetDoclet implements Doclet { + + private final int nErrorsInInit; + private final Set descriptions; + private Set
    MODIFIER AND TYPEMETHODDESCRIPTIONMODIFIER AND TYPEMETHODDESCRIPTIONModifier and TypeMethodDescriptionModifier and TypeMethodDescription