Skip to content

Commit 75e8b6e

Browse files
committed
8230854: Cleanup SuppressWarnings in test lib and remove noisy traces in StreamPumper
Reviewed-by: stuefe, dholmes
1 parent 2f5ce4c commit 75e8b6e

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

test/lib/jdk/test/lib/Platform.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,6 @@ private static boolean canPtraceAttachLinux() throws IOException {
265265
return false;
266266
}
267267
} catch (PrivilegedActionException e) {
268-
@SuppressWarnings("unchecked")
269268
IOException t = (IOException) e.getException();
270269
throw t;
271270
}
@@ -289,7 +288,6 @@ private static boolean canPtraceAttachLinux() throws IOException {
289288
return false;
290289
}
291290
} catch (PrivilegedActionException e) {
292-
@SuppressWarnings("unchecked")
293291
IOException t = (IOException) e.getException();
294292
throw t;
295293
}

test/lib/jdk/test/lib/Utils.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import java.io.File;
2727
import java.io.IOException;
28+
import java.lang.annotation.Annotation;
2829
import java.net.InetAddress;
2930
import java.net.InetSocketAddress;
3031
import java.net.MalformedURLException;
@@ -749,13 +750,14 @@ public static String distro() {
749750
// until the method main() is found; the class containing that method is the
750751
// main test class and will be returned as the name of the test.
751752
// Special handling is used for testng tests.
753+
@SuppressWarnings("unchecked")
752754
public static String getTestName() {
753755
String result = null;
754756
// If we are using testng, then we should be able to load the "Test" annotation.
755-
Class testClassAnnotation;
757+
Class<? extends Annotation> testClassAnnotation;
756758

757759
try {
758-
testClassAnnotation = Class.forName("org.testng.annotations.Test");
760+
testClassAnnotation = (Class<? extends Annotation>)Class.forName("org.testng.annotations.Test");
759761
} catch (ClassNotFoundException e) {
760762
testClassAnnotation = null;
761763
}
@@ -776,7 +778,7 @@ public static String getTestName() {
776778
// annotation. If present, then use the name of this class.
777779
if (testClassAnnotation != null) {
778780
try {
779-
Class c = Class.forName(className);
781+
Class<?> c = Class.forName(className);
780782
if (c.isAnnotationPresent(testClassAnnotation)) {
781783
result = className;
782784
break;

test/lib/jdk/test/lib/process/ProcessTools.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,6 @@ private static Process privilegedStart(ProcessBuilder pb) throws IOException {
495495
return AccessController.doPrivileged(
496496
(PrivilegedExceptionAction<Process>) () -> pb.start());
497497
} catch (PrivilegedActionException e) {
498-
@SuppressWarnings("unchecked")
499498
IOException t = (IOException) e.getException();
500499
throw t;
501500
}

test/lib/jdk/test/lib/process/StreamPumper.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -144,7 +144,9 @@ public void run() {
144144
}
145145

146146
} catch (IOException e) {
147-
e.printStackTrace();
147+
if (!e.getMessage().equalsIgnoreCase("stream closed")) {
148+
e.printStackTrace();
149+
}
148150
} finally {
149151
for (OutputStream out : outStreams) {
150152
try {

0 commit comments

Comments
 (0)