diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp
index b990ea55640..7fa9c65102c 100644
--- a/src/hotspot/share/prims/whitebox.cpp
+++ b/src/hotspot/share/prims/whitebox.cpp
@@ -2064,6 +2064,14 @@ WB_ENTRY(jboolean, WB_IsJFRIncluded(JNIEnv* env))
 #endif // INCLUDE_JFR
 WB_END
 
+WB_ENTRY(jboolean, WB_IsDTraceIncluded(JNIEnv* env))
+#if defined(DTRACE_ENABLED)
+  return true;
+#else
+  return false;
+#endif // DTRACE_ENABLED
+WB_END
+
 #if INCLUDE_CDS
 
 WB_ENTRY(jint, WB_GetCDSOffsetForName(JNIEnv* env, jobject o, jstring name))
@@ -2709,6 +2717,7 @@ static JNINativeMethod methods[] = {
   {CC"areOpenArchiveHeapObjectsMapped",   CC"()Z",    (void*)&WB_AreOpenArchiveHeapObjectsMapped},
   {CC"isCDSIncluded",                     CC"()Z",    (void*)&WB_IsCDSIncluded },
   {CC"isJFRIncluded",                     CC"()Z",    (void*)&WB_IsJFRIncluded },
+  {CC"isDTraceIncluded",                  CC"()Z",    (void*)&WB_IsDTraceIncluded },
   {CC"isC2OrJVMCIIncluded",               CC"()Z",    (void*)&WB_isC2OrJVMCIIncluded },
   {CC"isJVMCISupportedByGC",              CC"()Z",    (void*)&WB_IsJVMCISupportedByGC},
   {CC"canWriteJavaHeapArchive",           CC"()Z",    (void*)&WB_CanWriteJavaHeapArchive },
diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp
index fed6faa0ccd..b65e25edbbc 100644
--- a/src/hotspot/share/runtime/arguments.cpp
+++ b/src/hotspot/share/runtime/arguments.cpp
@@ -2906,6 +2906,18 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m
       jio_fprintf(defaultStream::error_stream(),
                   "ExtendedDTraceProbes flag is not applicable for this configuration\n");
       return JNI_EINVAL;
+    } else if (match_option(option, "-XX:+DTraceMethodProbes")) {
+      jio_fprintf(defaultStream::error_stream(),
+                  "DTraceMethodProbes flag is not applicable for this configuration\n");
+      return JNI_EINVAL;
+    } else if (match_option(option, "-XX:+DTraceAllocProbes")) {
+      jio_fprintf(defaultStream::error_stream(),
+                  "DTraceAllocProbes flag is not applicable for this configuration\n");
+      return JNI_EINVAL;
+    } else if (match_option(option, "-XX:+DTraceMonitorProbes")) {
+      jio_fprintf(defaultStream::error_stream(),
+                  "DTraceMonitorProbes flag is not applicable for this configuration\n");
+      return JNI_EINVAL;
 #endif // defined(DTRACE_ENABLED)
 #ifdef ASSERT
     } else if (match_option(option, "-XX:+FullGCALot")) {
diff --git a/test/hotspot/jtreg/TEST.ROOT b/test/hotspot/jtreg/TEST.ROOT
index 84ccf8ec91c..c4015b00fd5 100644
--- a/test/hotspot/jtreg/TEST.ROOT
+++ b/test/hotspot/jtreg/TEST.ROOT
@@ -63,6 +63,7 @@ requires.properties= \
     vm.debug \
     vm.hasSA \
     vm.hasJFR \
+    vm.hasDTrace \
     vm.rtm.cpu \
     vm.rtm.compiler \
     vm.cds \
diff --git a/test/hotspot/jtreg/compiler/runtime/Test8168712.java b/test/hotspot/jtreg/compiler/runtime/Test8168712.java
index 00cffa3e757..e411dc21479 100644
--- a/test/hotspot/jtreg/compiler/runtime/Test8168712.java
+++ b/test/hotspot/jtreg/compiler/runtime/Test8168712.java
@@ -22,11 +22,29 @@
  */
 
 /**
- * @test
+ * @test id=with-dtrace
+ * @requires vm.debug
+ * @requires vm.hasDTrace
+ * @bug 8168712
+ *
+ * @run main/othervm -XX:CompileCommand=compileonly,Test8168712.*
+ *                   -XX:CompileCommand=compileonly,*Object.*
+ *                   -XX:+DTraceMethodProbes
+ *                   -XX:-UseOnStackReplacement
+ *                   -XX:+DeoptimizeRandom
+ *                   compiler.runtime.Test8168712
+ */
+
+/**
+ * @test id=without-dtrace
  * @requires vm.debug
  * @bug 8168712
  *
- * @run main/othervm -XX:CompileCommand=compileonly,Test8168712.* -XX:CompileCommand=compileonly,*Object.* -XX:+DTraceMethodProbes -XX:-UseOnStackReplacement -XX:+DeoptimizeRandom compiler.runtime.Test8168712
+ * @run main/othervm -XX:CompileCommand=compileonly,Test8168712.*
+ *                   -XX:CompileCommand=compileonly,*Object.*
+ *                   -XX:-UseOnStackReplacement
+ *                   -XX:+DeoptimizeRandom
+ *                   compiler.runtime.Test8168712
  */
 package compiler.runtime;
 
diff --git a/test/hotspot/jtreg/serviceability/7170638/SDTProbesGNULinuxTest.java b/test/hotspot/jtreg/serviceability/7170638/SDTProbesGNULinuxTest.java
index 36759433112..d4a49247909 100644
--- a/test/hotspot/jtreg/serviceability/7170638/SDTProbesGNULinuxTest.java
+++ b/test/hotspot/jtreg/serviceability/7170638/SDTProbesGNULinuxTest.java
@@ -28,6 +28,7 @@
  * @summary Test SDT probes available on GNU/Linux when DTRACE_ENABLED
  * @requires os.family == "linux"
  * @requires vm.flagless
+ * @requires vm.hasDTrace
  *
  * @library /test/lib
  * @run driver SDTProbesGNULinuxTest
@@ -36,7 +37,6 @@
 import jdk.test.lib.Utils;
 import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.process.ProcessTools;
-import jtreg.SkippedException;
 
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -44,19 +44,7 @@ import java.nio.file.Paths;
 
 public class SDTProbesGNULinuxTest {
     public static void main(String[] args) throws Throwable {
-        {
-            var pb = ProcessTools.createJavaProcessBuilder(
-                    "-XX:+DTraceMethodProbes",
-                    "-XX:+DTraceAllocProbes",
-                    "-XX:+DTraceMonitorProbes",
-                    "-version");
-            var oa = new OutputAnalyzer(pb.start());
-            // This test only matters when build with DTRACE_ENABLED.
-            if (oa.getExitValue() != 0) {
-                throw new SkippedException("Not build using DTRACE_ENABLED");
-            }
-        }
-
+        // This test only matters when build with DTRACE_ENABLED.
         try (var libjvms = Files.walk(Paths.get(Utils.TEST_JDK))) {
             libjvms.filter(p -> "libjvm.so".equals(p.getFileName().toString()))
                    .map(Path::toAbsolutePath)
diff --git a/test/hotspot/jtreg/serviceability/dtrace/DTraceOptionsTest.java b/test/hotspot/jtreg/serviceability/dtrace/DTraceOptionsTest.java
new file mode 100644
index 00000000000..8822a9ed378
--- /dev/null
+++ b/test/hotspot/jtreg/serviceability/dtrace/DTraceOptionsTest.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2022, 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
+ * 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 id=enabled
+ * @bug 8281822
+ * @summary Test DTrace options are accepted on suitable builds
+ * @requires vm.flagless
+ * @requires vm.hasDTrace
+ *
+ * @library /test/lib
+ * @run driver DTraceOptionsTest true
+ */
+
+/*
+ * @test id=disabled
+ * @bug 8281822
+ * @summary Test DTrace options are rejected on unsuitable builds
+ * @requires vm.flagless
+ * @requires !vm.hasDTrace
+ *
+ * @library /test/lib
+ * @run driver DTraceOptionsTest disabled
+ */
+
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+
+public class DTraceOptionsTest {
+    public static void main(String[] args) throws Throwable {
+        boolean dtraceEnabled;
+        if (args.length > 0) {
+            dtraceEnabled = Boolean.parseBoolean(args[0]);
+        } else {
+            throw new IllegalArgumentException("Should provide the argument");
+        }
+
+        String[] options = {
+            "ExtendedDTraceProbes",
+            "DTraceMethodProbes",
+            "DTraceAllocProbes",
+            "DTraceMonitorProbes",
+        };
+
+        for (String opt : options) {
+            var pb = ProcessTools.createJavaProcessBuilder("-XX:+" + opt, "-version");
+            var oa = new OutputAnalyzer(pb.start());
+            if (dtraceEnabled) {
+                oa.shouldHaveExitValue(0);
+            } else {
+                oa.shouldNotHaveExitValue(0);
+                oa.shouldContain(opt + " flag is not applicable for this configuration");
+            }
+        }
+    }
+
+}
diff --git a/test/jtreg-ext/requires/VMProps.java b/test/jtreg-ext/requires/VMProps.java
index fac505a4585..86a47925b67 100644
--- a/test/jtreg-ext/requires/VMProps.java
+++ b/test/jtreg-ext/requires/VMProps.java
@@ -102,6 +102,7 @@ public class VMProps implements Callable<Map<String, String>> {
         // vm.hasJFR is "true" if JFR is included in the build of the VM and
         // so tests can be executed.
         map.put("vm.hasJFR", this::vmHasJFR);
+        map.put("vm.hasDTrace", this::vmHasDTrace);
         map.put("vm.jvmti", this::vmHasJVMTI);
         map.put("vm.cpu.features", this::cpuFeatures);
         map.put("vm.pageSize", this::vmPageSize);
@@ -368,6 +369,13 @@ public class VMProps implements Callable<Map<String, String>> {
         return "" + WB.isJVMTIIncluded();
     }
 
+    /**
+     * @return "true" if the VM is compiled with DTrace
+     */
+    protected String vmHasDTrace() {
+        return "" + WB.isDTraceIncluded();
+    }
+
     /**
      * @return true if compiler in use supports RTM and false otherwise.
      */
diff --git a/test/lib/jdk/test/whitebox/WhiteBox.java b/test/lib/jdk/test/whitebox/WhiteBox.java
index 6fa0fb4c47a..cdd6f6890cb 100644
--- a/test/lib/jdk/test/whitebox/WhiteBox.java
+++ b/test/lib/jdk/test/whitebox/WhiteBox.java
@@ -634,6 +634,7 @@ public class WhiteBox {
   public native boolean isSharedInternedString(String s);
   public native boolean isCDSIncluded();
   public native boolean isJFRIncluded();
+  public native boolean isDTraceIncluded();
   public native boolean canWriteJavaHeapArchive();
   public native Object  getResolvedReferences(Class<?> c);
   public native void    linkClass(Class<?> c);
diff --git a/test/lib/sun/hotspot/WhiteBox.java b/test/lib/sun/hotspot/WhiteBox.java
index e80f284eaed..7390cf19704 100644
--- a/test/lib/sun/hotspot/WhiteBox.java
+++ b/test/lib/sun/hotspot/WhiteBox.java
@@ -635,6 +635,7 @@ public class WhiteBox {
   public native boolean isSharedInternedString(String s);
   public native boolean isCDSIncluded();
   public native boolean isJFRIncluded();
+  public native boolean isDTraceIncluded();
   public native boolean canWriteJavaHeapArchive();
   public native Object  getResolvedReferences(Class<?> c);
   public native void    linkClass(Class<?> c);