changeset 1111:3b6a26e95f58

7901284: Demote incremental compilation warnings to notes.
author shade
date Fri, 30 Jan 2015 12:05:32 +0300
parents f3dff16bc5c3
children 492a000a7aea
files jmh-core-ct/src/test/java/org/openjdk/jmh/ct/InMemoryGeneratorDestination.java jmh-core-ct/src/test/java/org/openjdk/jmh/ct/multsession/MultipleSessionsTest.java jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java jmh-core/src/main/java/org/openjdk/jmh/generators/core/FileSystemDestination.java jmh-core/src/main/java/org/openjdk/jmh/generators/core/GeneratorDestination.java jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APGeneratorDestinaton.java
diffstat 6 files changed, 40 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/InMemoryGeneratorDestination.java	Fri Jan 30 11:36:41 2015 +0300
+++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/InMemoryGeneratorDestination.java	Fri Jan 30 12:05:32 2015 +0300
@@ -42,6 +42,7 @@
 
     private List<String> errors = new ArrayList<String>();
     private List<String> warnings = new ArrayList<String>();
+    private List<String> infos = new ArrayList<String>();
 
     private Map<String, StringWriter> classBodies = new HashMap<String, StringWriter>();
     private Map<String, StringWriter> resourceBodies = new HashMap<String, StringWriter>();
@@ -130,4 +131,18 @@
         }
         return result;
     }
+
+    @Override
+    public void printNote(String message) {
+        infos.add(message);
+    }
+
+    public boolean hasNotes() {
+        return !infos.isEmpty();
+    }
+
+    public List<String> getNotes() {
+        return infos;
+    }
+
 }
--- a/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/multsession/MultipleSessionsTest.java	Fri Jan 30 11:36:41 2015 +0300
+++ b/jmh-core-ct/src/test/java/org/openjdk/jmh/ct/multsession/MultipleSessionsTest.java	Fri Jan 30 12:05:32 2015 +0300
@@ -48,6 +48,7 @@
 
             Assert.assertFalse("First stage error", dst.hasErrors());
             Assert.assertFalse("First stage warnings", dst.hasWarnings());
+            Assert.assertFalse("First stage infos", dst.hasNotes());
 
             String[] list = dst.getResources().get(BenchmarkList.BENCHMARK_LIST.substring(1)).split("\n");
             Assert.assertEquals("First stage should have only 1 benchmark", 1, list.length);
@@ -64,6 +65,7 @@
 
             Assert.assertFalse("Second stage error", dst.hasErrors());
             Assert.assertFalse("Second stage warnings", dst.hasWarnings());
+            Assert.assertFalse("Second stage notes", dst.hasNotes());
 
             String[] list = dst.getResources().get(BenchmarkList.BENCHMARK_LIST.substring(1)).split("\n");
             Assert.assertEquals("Second stage should have 2 benchmarks", 2, list.length);
@@ -85,6 +87,7 @@
 
             Assert.assertFalse("First stage error", dst.hasErrors());
             Assert.assertFalse("First stage warnings", dst.hasWarnings());
+            Assert.assertFalse("First stage notes", dst.hasNotes());
 
             String[] list = dst.getResources().get(BenchmarkList.BENCHMARK_LIST.substring(1)).split("\n");
             Assert.assertEquals("First stage should have only 1 benchmark", 1, list.length);
@@ -100,12 +103,13 @@
             gen.complete(src, dst);
 
             Assert.assertFalse("Second stage error", dst.hasErrors());
-            Assert.assertTrue("Second stage warnings", dst.hasWarnings());
-            boolean hasOurWarning = false;
-            for (String warning : dst.getWarnings()) {
-                hasOurWarning |= (warning.contains("Benchmark1") && warning.contains("overwriting"));
+            Assert.assertFalse("Second stage warnings", dst.hasWarnings());
+            Assert.assertTrue("Second stage notes", dst.hasNotes());
+            boolean hasOurInfo = false;
+            for (String warning : dst.getNotes()) {
+                hasOurInfo |= (warning.contains("Benchmark1") && warning.contains("overwriting"));
             }
-            Assert.assertTrue("Should have our warning: " + dst.getWarnings(), hasOurWarning);
+            Assert.assertTrue("Should have our note: " + dst.getNotes(), hasOurInfo);
 
             String[] list = dst.getResources().get(BenchmarkList.BENCHMARK_LIST.substring(1)).split("\n");
             Assert.assertEquals("Second stage should have 1 benchmark", 1, list.length);
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java	Fri Jan 30 11:36:41 2015 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/BenchmarkGenerator.java	Fri Jan 30 12:05:32 2015 +0300
@@ -203,7 +203,7 @@
                         );
 
                         if (entries.contains(br)) {
-                            destination.printWarning("Benchmark entry " + br + " already exists, overwriting");
+                            destination.printNote("Benchmark entry " + br + " already exists, overwriting");
                             entries.remove(br);
                         }
 
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/FileSystemDestination.java	Fri Jan 30 11:36:41 2015 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/FileSystemDestination.java	Fri Jan 30 12:05:32 2015 +0300
@@ -124,4 +124,8 @@
         return sourceWarnings;
     }
 
+    @Override
+    public void printNote(String message) {
+        // do nothing
+    }
 }
--- a/jmh-core/src/main/java/org/openjdk/jmh/generators/core/GeneratorDestination.java	Fri Jan 30 11:36:41 2015 +0300
+++ b/jmh-core/src/main/java/org/openjdk/jmh/generators/core/GeneratorDestination.java	Fri Jan 30 12:05:32 2015 +0300
@@ -117,4 +117,11 @@
      */
     void printWarning(String message, Throwable throwable);
 
+    /**
+     * Print the informative message.
+     * Calling this method should not terminate anything.
+     *
+     * @param message message.
+     */
+    void printNote(String message);
 }
--- a/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APGeneratorDestinaton.java	Fri Jan 30 11:36:41 2015 +0300
+++ b/jmh-generator-annprocess/src/main/java/org/openjdk/jmh/generators/annotations/APGeneratorDestinaton.java	Fri Jan 30 12:05:32 2015 +0300
@@ -91,4 +91,8 @@
         printWarning(message + " " + Utils.throwableToString(throwable));
     }
 
+    @Override
+    public void printNote(String message) {
+        processingEnv.getMessager().printMessage(Diagnostic.Kind.NOTE, message);
+    }
 }