Skip to content

Commit

Permalink
Update XX flag requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinjwalls committed Apr 8, 2024
1 parent 17f22d6 commit 44fc23d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions src/hotspot/share/runtime/globals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ const int ObjectAlignmentInBytes = 8;
product(bool, AlwaysSafeConstructors, false, EXPERIMENTAL, \
"Force safe construction, as if all fields are final.") \
\
product(bool, UnlockDiagnosticVMFeatures, trueInDebug, \
"Enable VM features relating to field diagnostics") \
\
product(bool, UnlockDiagnosticVMOptions, trueInDebug, DIAGNOSTIC, \
"Enable normal processing of flags relating to field diagnostics")\
\
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/services/diagnosticCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1251,8 +1251,8 @@ VMInspectDCmd::VMInspectDCmd(outputStream* output, bool heap) :
void VMInspectDCmd::execute(DCmdSource source, TRAPS) {
DebuggingContext dc{}; // avoid asserts

if (!UnlockDiagnosticVMOptions) {
output()->print_cr("-XX:+UnlockDiagnosticVMOptions is required");
if (!UnlockDiagnosticVMFeatures) {
output()->print_cr("-XX:+UnlockDiagnosticVMFeatures is required");
return;
}
if (!_address.has_value()) {
Expand Down
8 changes: 4 additions & 4 deletions test/hotspot/jtreg/serviceability/dcmd/vm/VMInspectTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @summary Test of diagnostic command VM.inspect
* @library /test/lib
* @modules java.base/jdk.internal.misc
* @run testng/othervm -Dvminspect.enabled=true -XX:+UnlockDiagnosticVMOptions VMInspectTest
* @run testng/othervm -Dvminspect.enabled=true -XX:+UnlockDiagnosticVMFeatures VMInspectTest
*/

/*
Expand Down Expand Up @@ -81,14 +81,14 @@ public void run(CommandExecutor executor) throws ClassNotFoundException {
BigInteger ptr = null;
OutputAnalyzer output = null;

// Testing VM.inspect requires UnlockDiagnosticVMOptions or a debug JVM.
// This test runs with a System Property set as a hint whether UnlockDiagnosticVMOptions is set.
// Testing VM.inspect requires UnlockDiagnosticVMFeatures or a debug JVM.
// This test runs with a System Property set as a hint whether UnlockDiagnosticVMFeatures is set.
boolean enabled = Platform.isDebugBuild() || Boolean.getBoolean("vminspect.enabled");
System.out.println("VM.inspect should be enabled = " + enabled);
if (!enabled) {
// Use any pointer, command should be refused:
output = executor.execute("VM.inspect 0x0");
output.shouldContain("-XX:+UnlockDiagnosticVMOptions is required");
output.shouldContain("-XX:+UnlockDiagnosticVMFeatures is required");
return; // no more testing
}

Expand Down

0 comments on commit 44fc23d

Please sign in to comment.