changeset 339:2e689d5a271a

Static code analysis cleanups.
author shade
date Thu, 17 Nov 2016 16:01:03 +0100
parents 3159862dbcdb
children c16c2f7fa79b
files jcstress-core/src/main/java/org/openjdk/jcstress/ForkedMain.java jcstress-core/src/main/java/org/openjdk/jcstress/infra/grading/ConsoleReportPrinter.java jcstress-core/src/main/java/org/openjdk/jcstress/infra/grading/ExceptionReportPrinter.java jcstress-core/src/main/java/org/openjdk/jcstress/infra/processors/JCStressTestProcessor.java jcstress-core/src/main/java/org/openjdk/jcstress/infra/processors/TestInfo.java jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Control.java jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/TestList.java jcstress-core/src/main/java/org/openjdk/jcstress/link/BinaryLinkClient.java jcstress-core/src/main/java/org/openjdk/jcstress/util/HashMultimap.java jcstress-core/src/main/java/org/openjdk/jcstress/util/Reflections.java jcstress-core/src/main/java/org/openjdk/jcstress/util/TreeMultimap.java jcstress-core/src/main/java/org/openjdk/jcstress/util/TreesetMultimap.java jcstress-core/src/main/java/org/openjdk/jcstress/vm/ContendedTestMain.java jcstress-core/src/main/java/org/openjdk/jcstress/vm/VMSupport.java
diffstat 14 files changed, 13 insertions(+), 43 deletions(-) [+]
line wrap: on
line diff
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/ForkedMain.java	Thu Nov 17 13:02:04 2016 +0100
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/ForkedMain.java	Thu Nov 17 16:01:03 2016 +0100
@@ -28,8 +28,6 @@
 import org.openjdk.jcstress.link.BinaryLinkClient;
 import org.openjdk.jcstress.vm.WhiteBoxSupport;
 
-import java.io.IOException;
-
 /**
  * Entry point for the forked VM run.
  *
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/grading/ConsoleReportPrinter.java	Thu Nov 17 13:02:04 2016 +0100
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/grading/ConsoleReportPrinter.java	Thu Nov 17 16:01:03 2016 +0100
@@ -25,13 +25,9 @@
 package org.openjdk.jcstress.infra.grading;
 
 import org.openjdk.jcstress.Options;
-import org.openjdk.jcstress.annotations.Expect;
-import org.openjdk.jcstress.infra.StateCase;
-import org.openjdk.jcstress.infra.TestInfo;
 import org.openjdk.jcstress.infra.collectors.TestResult;
 import org.openjdk.jcstress.infra.collectors.TestResultCollector;
 import org.openjdk.jcstress.infra.runners.TestConfig;
-import org.openjdk.jcstress.infra.runners.TestList;
 import org.openjdk.jcstress.util.StringUtils;
 
 import java.io.FileNotFoundException;
@@ -47,7 +43,6 @@
 public class ConsoleReportPrinter implements TestResultCollector {
 
     private final boolean verbose;
-    private final Options opts;
     private final PrintWriter output;
     private final long expectedTests;
     private final long expectedIterations;
@@ -68,7 +63,6 @@
     private long hardErrors;
 
     public ConsoleReportPrinter(Options opts, PrintWriter pw, int expectedTests, int expectedForks) throws FileNotFoundException {
-        this.opts = opts;
         this.output = pw;
         this.expectedTests = expectedTests;
         this.expectedForks = expectedForks;
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/grading/ExceptionReportPrinter.java	Thu Nov 17 13:02:04 2016 +0100
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/grading/ExceptionReportPrinter.java	Thu Nov 17 16:01:03 2016 +0100
@@ -25,14 +25,8 @@
 package org.openjdk.jcstress.infra.grading;
 
 
-import org.openjdk.jcstress.Options;
-import org.openjdk.jcstress.infra.Status;
-import org.openjdk.jcstress.infra.TestInfo;
 import org.openjdk.jcstress.infra.collectors.InProcessCollector;
 import org.openjdk.jcstress.infra.collectors.TestResult;
-import org.openjdk.jcstress.infra.runners.TestConfig;
-import org.openjdk.jcstress.infra.runners.TestList;
-import org.openjdk.jcstress.util.*;
 
 import javax.xml.bind.JAXBException;
 import java.io.FileNotFoundException;
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/processors/JCStressTestProcessor.java	Thu Nov 17 13:02:04 2016 +0100
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/processors/JCStressTestProcessor.java	Thu Nov 17 16:01:03 2016 +0100
@@ -34,7 +34,6 @@
 
 import javax.annotation.processing.AbstractProcessor;
 import javax.annotation.processing.RoundEnvironment;
-import javax.annotation.processing.SupportedSourceVersion;
 import javax.lang.model.SourceVersion;
 import javax.lang.model.element.*;
 import javax.lang.model.util.ElementFilter;
@@ -46,7 +45,6 @@
 import java.io.Writer;
 import java.util.*;
 import java.util.concurrent.*;
-import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
 
 public class JCStressTestProcessor extends AbstractProcessor {
 
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/processors/TestInfo.java	Thu Nov 17 13:02:04 2016 +0100
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/processors/TestInfo.java	Thu Nov 17 16:01:03 2016 +0100
@@ -51,9 +51,9 @@
     private String description;
 
     public TestInfo() {
-        actors = new ArrayList<ExecutableElement>();
-        outcomes = new ArrayList<Outcome>();
-        refs = new ArrayList<String>();
+        actors = new ArrayList<>();
+        outcomes = new ArrayList<>();
+        refs = new ArrayList<>();
         actors = new ArrayList<>();
     }
 
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Control.java	Thu Nov 17 13:02:04 2016 +0100
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/Control.java	Thu Nov 17 16:01:03 2016 +0100
@@ -24,8 +24,6 @@
  */
 package org.openjdk.jcstress.infra.runners;
 
-import org.openjdk.jcstress.Options;
-
 /**
  * @author Aleksey Shipilev (aleksey.shipilev@oracle.com)
  */
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/TestList.java	Thu Nov 17 13:02:04 2016 +0100
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/infra/runners/TestList.java	Thu Nov 17 16:01:03 2016 +0100
@@ -33,7 +33,6 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
@@ -47,7 +46,7 @@
 
     private static Map<String, TestInfo> getTests() {
         if (tests == null) {
-            Map<String, TestInfo> m = new HashMap<String, TestInfo>();
+            Map<String, TestInfo> m = new HashMap<>();
             InputStream stream = null;
             try {
                 stream = TestList.class.getResourceAsStream(LIST);
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/link/BinaryLinkClient.java	Thu Nov 17 13:02:04 2016 +0100
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/link/BinaryLinkClient.java	Thu Nov 17 16:01:03 2016 +0100
@@ -62,8 +62,6 @@
                 oos.close();
                 ois.close();
                 return o;
-            } catch (IOException e) {
-                throw e;
             } catch (ClassNotFoundException e) {
                 throw new IOException(e);
             } finally {
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/util/HashMultimap.java	Thu Nov 17 13:02:04 2016 +0100
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/util/HashMultimap.java	Thu Nov 17 16:01:03 2016 +0100
@@ -76,7 +76,7 @@
     @Override
     public Collection<V> get(K key) {
         Collection<V> vs = map.get(key);
-        return (vs == null) ? Collections.<V>emptyList() : Collections.unmodifiableCollection(vs);
+        return (vs == null) ? Collections.emptyList() : Collections.unmodifiableCollection(vs);
     }
 
     @Override
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/util/Reflections.java	Thu Nov 17 13:02:04 2016 +0100
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/util/Reflections.java	Thu Nov 17 16:01:03 2016 +0100
@@ -24,15 +24,9 @@
  */
 package org.openjdk.jcstress.util;
 
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.lang.reflect.Modifier;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/util/TreeMultimap.java	Thu Nov 17 13:02:04 2016 +0100
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/util/TreeMultimap.java	Thu Nov 17 16:01:03 2016 +0100
@@ -76,7 +76,7 @@
     @Override
     public Collection<V> get(K key) {
         Collection<V> vs = map.get(key);
-        return (vs == null) ? Collections.<V>emptyList() : Collections.unmodifiableCollection(vs);
+        return (vs == null) ? Collections.emptyList() : Collections.unmodifiableCollection(vs);
     }
 
     @Override
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/util/TreesetMultimap.java	Thu Nov 17 13:02:04 2016 +0100
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/util/TreesetMultimap.java	Thu Nov 17 16:01:03 2016 +0100
@@ -77,7 +77,7 @@
     @Override
     public Collection<V> get(K key) {
         Collection<V> vs = map.get(key);
-        return (vs == null) ? Collections.<V>emptyList() : Collections.unmodifiableCollection(vs);
+        return (vs == null) ? Collections.emptyList() : Collections.unmodifiableCollection(vs);
     }
 
     @Override
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/vm/ContendedTestMain.java	Thu Nov 17 13:02:04 2016 +0100
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/vm/ContendedTestMain.java	Thu Nov 17 16:01:03 2016 +0100
@@ -25,7 +25,6 @@
 package org.openjdk.jcstress.vm;
 
 import org.openjdk.jcstress.annotations.Result;
-import org.openjdk.jcstress.annotations.State;
 import org.openjdk.jcstress.infra.runners.StateHolder;
 import org.openjdk.jcstress.util.Reflections;
 import org.openjdk.jcstress.util.UnsafeHolder;
--- a/jcstress-core/src/main/java/org/openjdk/jcstress/vm/VMSupport.java	Thu Nov 17 13:02:04 2016 +0100
+++ b/jcstress-core/src/main/java/org/openjdk/jcstress/vm/VMSupport.java	Thu Nov 17 16:01:03 2016 +0100
@@ -211,14 +211,12 @@
     }
 
     private static String getDefaultJvm() {
-        StringBuilder javaExecutable = new StringBuilder();
-        javaExecutable.append(System.getProperty("java.home"));
-        javaExecutable.append(File.separator);
-        javaExecutable.append("bin");
-        javaExecutable.append(File.separator);
-        javaExecutable.append("java");
-        javaExecutable.append(isWindows() ? ".exe" : "");
-        return javaExecutable.toString();
+        return System.getProperty("java.home") +
+                File.separator +
+                "bin" +
+                File.separator +
+                "java" +
+                (isWindows() ? ".exe" : "");
     }
 
     private static boolean isWindows() {