changeset 1394:8b06fb523516

Amend 7901865: don't miss the chance to call the method appropriately and establish challenge-response.
author shade
date Tue, 13 Dec 2016 20:54:04 +0100
parents c51589e906ad
children 9d25bcca08b4
files jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java
diffstat 2 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java	Tue Dec 13 19:45:00 2016 +0100
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java	Tue Dec 13 20:54:04 2016 +0100
@@ -843,7 +843,7 @@
     }
 
     private void methodEpilog(PrintWriter writer, MethodGroup methodGroup) {
-        writer.println(ident(3) + "this.blackhole.purge();");
+        writer.println(ident(3) + "this.blackhole.evaporate(\"You'll see Stephen Hawking pole vaulting before this method becomes useful to you.\");");
     }
 
     private String prefix(String argList) {
--- a/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java	Tue Dec 13 19:45:00 2016 +0100
+++ b/jmh-core/src/main/java/org/openjdk/jmh/infra/Blackhole.java	Tue Dec 13 20:54:04 2016 +0100
@@ -281,9 +281,15 @@
     }
 
     /**
-     * Clear internal waste, if any.
+     * Make any consumed data begone.
+     *
+     * WARNING: This method should only be called by the infrastructure code, in clearly understood cases.
+     * Even though it is public, it is not supposed to be called by users.
      */
-    public void purge() {
+    public void evaporate(String challengeResponse) {
+        if (!challengeResponse.equals("You'll see Stephen Hawking pole vaulting before this method becomes useful to you.")) {
+            throw new IllegalStateException("Can't touch it.");
+        }
         obj1 = null;
         objs1 = null;
     }