8081565: javac lint warnings in jdk testlibrary

Reviewed-by: lancea
This commit is contained in:
Roger Riggs 2015-06-01 10:27:24 -04:00
parent efaa3744a2
commit 0b4d0d4fec
7 changed files with 20 additions and 13 deletions

View File

@ -45,7 +45,7 @@ public class CheckBlacklistedCerts {
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())) {

View File

@ -21,6 +21,8 @@
* questions.
*/
import java.lang.SuppressWarnings;
import static jdk.testlibrary.Asserts.*;
/* @test
@ -75,7 +77,7 @@ public class AssertsTest {
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 @@ public class AssertsTest {
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 @@ public class AssertsTest {
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 @@ public class AssertsTest {
}
}
@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 @@ public class AssertsTest {
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);

View File

@ -72,9 +72,9 @@ public final class JarUtils {
// 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) {

View File

@ -30,6 +30,8 @@ import java.util.concurrent.Future;
class OutputBuffer {
private static class OutputBufferException extends RuntimeException {
private static final long serialVersionUID = 8528687792643129571L;
public OutputBufferException(Throwable cause) {
super(cause);
}

View File

@ -38,7 +38,7 @@ public class ParentLastURLClassLoader extends URLClassLoader {
@Override
public Class<?> loadClass(String name) throws ClassNotFoundException {
try {
Class c = findClass(name);
Class<?> c = findClass(name);
if (c != null) {
return c;
}

View File

@ -72,7 +72,7 @@ public final class ProcessTools {
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 @@ public final class ProcessTools {
* @return Returns the initialized process
* @throws IOException
*/
@SuppressWarnings("overloads")
public static Process startProcess(String name,
ProcessBuilder processBuilder,
Consumer<String> consumer)
@ -239,6 +240,7 @@ public final class ProcessTools {
* @throws InterruptedException
* @throws TimeoutException
*/
@SuppressWarnings("overloads")
public static Process startProcess(String name,
ProcessBuilder processBuilder,
final Predicate<String> linePredicate)

View File

@ -77,7 +77,7 @@ public final class StreamPumper implements Runnable {
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;