changeset 103:158f5aae72ce

Fix a few FindBugs warnings.
author shade
date Thu, 08 Aug 2013 14:37:14 +0400
parents 62e726a16873
children 24e09cb79197
files jmh-core/src/main/java/org/openjdk/jmh/output/OutputFormatFactory.java jmh-core/src/main/java/org/openjdk/jmh/processor/internal/GenerateMicroBenchmarkProcessor.java jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java jmh-core/src/main/java/org/openjdk/jmh/util/ClassUtils.java
diffstat 4 files changed, 2 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/jmh-core/src/main/java/org/openjdk/jmh/output/OutputFormatFactory.java	Fri Jul 19 23:44:06 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/output/OutputFormatFactory.java	Thu Aug 08 14:37:14 2013 +0400
@@ -47,9 +47,7 @@
         // force verbose if non-default trace level is requested
         if (traceLevel > 0) { verbose = true; }
 
-        if (format == null) {
-            throw new AssertionError("Format: " + format + " is null");
-        }
+        assert (format != null) : "format is not null";
 
         switch (format) {
             case Pretty:
--- a/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/GenerateMicroBenchmarkProcessor.java	Fri Jul 19 23:44:06 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/processor/internal/GenerateMicroBenchmarkProcessor.java	Thu Aug 08 14:37:14 2013 +0400
@@ -265,22 +265,6 @@
         return String.valueOf(result);
     }
 
-    private String packageNameByType(Mode bt) {
-        switch (bt) {
-            case Throughput:
-                return "throughput";
-            case AverageTime:
-                return "avgtime";
-            case SampleTime:
-                return "sampletime";
-            case SingleShotTime:
-                return "oneshot";
-            default:
-                processingEnv.getMessager().printMessage(Kind.ERROR, "Unknown type of method to process - " + bt);
-                throw new AssertionError("Shouldn't be here");
-        }
-    }
-
     /**
      * Create and generate Java code for a class and it's methods
      *
@@ -610,20 +594,6 @@
         return null;
     }
 
-    private static String generateThreadsAnnotation(Element method, Mode kind) {
-        if (kind != Mode.SingleShotTime) {
-            Threads tAnnotation = method.getAnnotation(Threads.class);
-            if (tAnnotation != null && tAnnotation.value() >= 0) {
-                return "@" + Threads.class.getSimpleName() + "(" + tAnnotation.value() + ")";
-            }
-            tAnnotation = method.getEnclosingElement().getAnnotation(Threads.class);
-            if (tAnnotation != null && tAnnotation.value() >= 0) {
-                return "@" + Threads.class.getSimpleName() + "(" + tAnnotation.value() + ")";
-            }
-        }
-        return null;
-    }
-
     private static int getThreads(Element method) {
         Threads tAnnotation = method.getAnnotation(Threads.class);
         if (tAnnotation != null && tAnnotation.value() >= 0) {
--- a/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java	Fri Jul 19 23:44:06 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/runner/CompilerHints.java	Thu Aug 08 14:37:14 2013 +0400
@@ -33,7 +33,7 @@
 public class CompilerHints extends AbstractResourceReader {
 
     public static final String LIST = "/META-INF/CompilerHints";
-    public static CompilerHints defaultList = null;
+    private static volatile CompilerHints defaultList;
 
     private final Set<String> hints;
 
--- a/jmh-core/src/main/java/org/openjdk/jmh/util/ClassUtils.java	Fri Jul 19 23:44:06 2013 +0400
+++ b/jmh-core/src/main/java/org/openjdk/jmh/util/ClassUtils.java	Thu Aug 08 14:37:14 2013 +0400
@@ -53,34 +53,6 @@
     }
 
     /**
-     * Helper method for adding a URL to the given URLClassLoader. Uses reflection and Method.setAccessible.
-     *
-     * @param classLoader URLClassLoader to add a URL to
-     * @param urls        URLs to add
-     * @throws NoSuchMethodException
-     * @throws SecurityException
-     * @throws InvocationTargetException
-     * @throws IllegalAccessException
-     * @throws IllegalArgumentException
-     */
-    private static void addURLsToClassLoader(URLClassLoader classLoader, URL... urls) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
-        // addURL is a protected method, but we can use reflection to call it
-        Class<?>[] paraTypes = new Class[1];
-        paraTypes[0] = URL.class;
-        Method method;
-
-        method = URLClassLoader.class.getDeclaredMethod("addURL", paraTypes);
-
-        // change access to true, otherwise, it will throw exception
-        method.setAccessible(true);
-
-        for (URL url : urls) {
-            method.invoke(classLoader, url);
-        }
-
-    }
-
-    /**
      * Enumerates all methods in hierarchy. Note that is different from both Class.getDeclaredMethods() and
      * Class.getMethods().
      *