8081565: javac lint warnings in jdk testlibrary
authorrriggs
Mon, 01 Jun 2015 10:27:24 -0400
changeset 30902 cf3d869e9f79
parent 30901 3a319ea18158
child 30903 0c7d705209c6
8081565: javac lint warnings in jdk testlibrary Reviewed-by: lancea
jdk/test/lib/security/CheckBlacklistedCerts.java
jdk/test/lib/testlibrary/AssertsTest.java
jdk/test/lib/testlibrary/jdk/testlibrary/JarUtils.java
jdk/test/lib/testlibrary/jdk/testlibrary/OutputBuffer.java
jdk/test/lib/testlibrary/jdk/testlibrary/ParentLastURLClassLoader.java
jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java
jdk/test/lib/testlibrary/jdk/testlibrary/StreamPumper.java
--- a/jdk/test/lib/security/CheckBlacklistedCerts.java	Sat May 30 15:19:15 2015 +0300
+++ b/jdk/test/lib/security/CheckBlacklistedCerts.java	Mon Jun 01 10:27:24 2015 -0400
@@ -45,7 +45,7 @@
         File file = new File(home, "lib/security/cacerts");
         KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
         try (FileInputStream fis = new FileInputStream(file)) {
-            ks.load(new FileInputStream(file), null);
+            ks.load(fis, null);
         }
         System.out.println("Check for cacerts: " + ks.size());
         for (String alias: Collections.list(ks.aliases())) {
--- a/jdk/test/lib/testlibrary/AssertsTest.java	Sat May 30 15:19:15 2015 +0300
+++ b/jdk/test/lib/testlibrary/AssertsTest.java	Mon Jun 01 10:27:24 2015 -0400
@@ -21,6 +21,8 @@
  * questions.
  */
 
+import java.lang.SuppressWarnings;
+
 import static jdk.testlibrary.Asserts.*;
 
 /* @test
@@ -75,7 +77,7 @@
 
     private static void testEquals() throws Exception {
         expectPass(Assertion.EQ, 1, 1);
-        expectPass(Assertion.EQ, (Comparable)null, (Comparable)null);
+        expectPass(Assertion.EQ, (Integer)null, (Integer)null);
 
         Foo f1 = new Foo(1);
         expectPass(Assertion.EQ, f1, f1);
@@ -112,13 +114,13 @@
         Foo f2 = new Foo(1);
         expectPass(Assertion.NE, f1, f2);
 
-        expectFail(Assertion.NE, (Comparable)null, (Comparable)null);
+        expectFail(Assertion.NE, (Integer)null, (Integer)null);
         expectFail(Assertion.NE, f1, f1);
         expectFail(Assertion.NE, 1, 1);
     }
 
     private static void testNull() throws Exception {
-        expectPass(Assertion.NULL, (Comparable)null);
+        expectPass(Assertion.NULL, (Integer)null);
 
         expectFail(Assertion.NULL, 1);
     }
@@ -126,7 +128,7 @@
     private static void testNotNull() throws Exception {
         expectPass(Assertion.NOTNULL, 1);
 
-        expectFail(Assertion.NOTNULL, (Comparable)null);
+        expectFail(Assertion.NOTNULL, (Integer)null);
     }
 
     private static void testTrue() throws Exception {
@@ -169,13 +171,13 @@
         }
     }
 
-
-
+    @SuppressWarnings("unchecked")
     private static <T extends Comparable<T>> void expectPass(Assertion assertion, T ... args)
         throws Exception {
         Assertion.run(assertion, args);
     }
 
+    @SuppressWarnings("unchecked")
     private static <T extends Comparable<T>> void expectFail(Assertion assertion, T ... args)
         throws Exception {
         try {
@@ -192,8 +194,9 @@
 enum Assertion {
     LT, LTE, EQ, GTE, GT, NE, NULL, NOTNULL, FALSE, TRUE;
 
+    @SuppressWarnings("unchecked")
     public static <T extends Comparable<T>> void run(Assertion assertion, T ... args) {
-        String msg = "Expected " + format(assertion, args) + " to pass";
+        String msg = "Expected " + format(assertion, (Object[])args) + " to pass";
         switch (assertion) {
             case LT:
                 assertLessThan(args[0], args[1], msg);
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/JarUtils.java	Sat May 30 15:19:15 2015 +0300
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/JarUtils.java	Mon Jun 01 10:27:24 2015 -0400
@@ -72,9 +72,9 @@
             // is in the updated list
             List<String> updatedFiles = new ArrayList<>();
             try (JarFile srcJarFile = new JarFile(src)) {
-                Enumeration entries = srcJarFile.entries();
+                Enumeration<JarEntry> entries = srcJarFile.entries();
                 while (entries.hasMoreElements()) {
-                    JarEntry entry = (JarEntry) entries.nextElement();
+                    JarEntry entry = entries.nextElement();
                     String name = entry.getName();
                     boolean found = false;
                     for (String file : files) {
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/OutputBuffer.java	Sat May 30 15:19:15 2015 +0300
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/OutputBuffer.java	Mon Jun 01 10:27:24 2015 -0400
@@ -30,6 +30,8 @@
 
 class OutputBuffer {
     private static class OutputBufferException extends RuntimeException {
+        private static final long serialVersionUID = 8528687792643129571L;
+
         public OutputBufferException(Throwable cause) {
             super(cause);
         }
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/ParentLastURLClassLoader.java	Sat May 30 15:19:15 2015 +0300
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/ParentLastURLClassLoader.java	Mon Jun 01 10:27:24 2015 -0400
@@ -38,7 +38,7 @@
     @Override
     public Class<?> loadClass(String name) throws ClassNotFoundException {
         try {
-            Class c = findClass(name);
+            Class<?> c = findClass(name);
             if (c != null) {
                 return c;
             }
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java	Sat May 30 15:19:15 2015 +0300
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java	Mon Jun 01 10:27:24 2015 -0400
@@ -72,7 +72,7 @@
     public static Process startProcess(String name,
                                        ProcessBuilder processBuilder)
     throws IOException {
-        return startProcess(name, processBuilder, (Consumer)null);
+        return startProcess(name, processBuilder, (Consumer<String>)null);
     }
 
     /**
@@ -85,6 +85,7 @@
      * @return Returns the initialized process
      * @throws IOException
      */
+    @SuppressWarnings("overloads")
     public static Process startProcess(String name,
                                        ProcessBuilder processBuilder,
                                        Consumer<String> consumer)
@@ -239,6 +240,7 @@
      * @throws InterruptedException
      * @throws TimeoutException
      */
+    @SuppressWarnings("overloads")
     public static Process startProcess(String name,
                                        ProcessBuilder processBuilder,
                                        final Predicate<String> linePredicate)
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/StreamPumper.java	Sat May 30 15:19:15 2015 +0300
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/StreamPumper.java	Mon Jun 01 10:27:24 2015 -0400
@@ -77,7 +77,7 @@
     private final Set<LinePump> linePumps = new HashSet<>();
 
     private final AtomicBoolean processing = new AtomicBoolean(false);
-    private final FutureTask<Void> processingTask = new FutureTask(this, null);
+    private final FutureTask<Void> processingTask = new FutureTask<>(this, null);
 
     public StreamPumper(InputStream in) {
         this.in = in;