Skip to content

Commit

Permalink
8278028: [test-library] Warnings cleanup of the test library
Browse files Browse the repository at this point in the history
Reviewed-by: dfuchs, mchung, naoto, lancea, lmesnik
  • Loading branch information
Roger Riggs committed Dec 14, 2021
1 parent a1dfe57 commit 03f647f
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 18 deletions.
4 changes: 2 additions & 2 deletions test/lib-test/jdk/test/lib/AssertsTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -38,7 +38,7 @@ public Foo(int id) {
}

public int compareTo(Foo f) {
return new Integer(id).compareTo(new Integer(f.id));
return Integer.valueOf(id).compareTo(Integer.valueOf(f.id));
}
public String toString() {
return "Foo(" + Integer.toString(id) + ")";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
*/
public class TestPlatformIsTieredSupported {
public static void main(String args[]) {
@SuppressWarnings("deprecation")
WhiteBox whiteBox = WhiteBox.getWhiteBox();
boolean tieredCompilation = whiteBox.getBooleanVMFlag(
"TieredCompilation");
Expand Down
5 changes: 3 additions & 2 deletions test/lib-test/jdk/test/lib/format/ArrayDiffTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -274,6 +274,7 @@ public void testToStringableObjects() {
class StrObj {
private final String value;
public boolean equals(Object another) { return ((StrObj)another).value.equals(value); }
public int hashCode() { return value.hashCode(); }
public StrObj(String value) { this.value = value; }
public String toString() { return value; }
}
Expand Down Expand Up @@ -363,7 +364,7 @@ public AssertBuilder thatFormattedValuesAre(
}

public void assertTwoWay() {
ArrayDiff diff;
ArrayDiff<?> diff;

// Direct
if (defaultParameters) {
Expand Down
1 change: 1 addition & 0 deletions test/lib-test/jdk/test/whitebox/OldWhiteBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

public class OldWhiteBox {
public static void main(String[] args) {
@SuppressWarnings("deprecation")
WhiteBox wb = WhiteBox.getWhiteBox();
if (wb.getHeapOopSize() < 0) {
throw new Error("wb.getHeapOopSize() < 0");
Expand Down
4 changes: 2 additions & 2 deletions test/lib-test/jdk/test/whitebox/vm_flags/VmFlagTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ protected static <T> void runTest(String existentFlag, Function<String, T> get)
protected static <T> void runTest(String existentFlag, T[] tests,
T[] results, BiConsumer<String, T> set, Function<String, T> get) {
if (existentFlag != null) {
new VmFlagTest(existentFlag, set, get, true).test(tests, results);
new VmFlagTest<T>(existentFlag, set, get, true).test(tests, results);
}
new VmFlagTest(NONEXISTENT_FLAG, set, get, false).test(tests, results);
new VmFlagTest<T>(NONEXISTENT_FLAG, set, get, false).test(tests, results);
}

public final void test(T[] tests, T[] results) {
Expand Down
4 changes: 2 additions & 2 deletions test/lib/RedefineClassHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static void premain(String agentArgs, Instrumentation inst) {
* @param clazz Class to redefine
* @param javacode String with the new java code for the class to be redefined
*/
public static void redefineClass(Class clazz, String javacode) throws Exception {
public static void redefineClass(Class<?> clazz, String javacode) throws Exception {
byte[] bytecode = InMemoryJavaCompiler.compile(clazz.getName(), javacode);
redefineClass(clazz, bytecode);
}
Expand All @@ -58,7 +58,7 @@ public static void redefineClass(Class clazz, String javacode) throws Exception
* @param clazz Class to redefine
* @param bytecode byte[] with the new class
*/
public static void redefineClass(Class clazz, byte[] bytecode) throws Exception {
public static void redefineClass(Class<?> clazz, byte[] bytecode) throws Exception {
instrumentation.redefineClasses(new ClassDefinition(clazz, bytecode));
}

Expand Down
1 change: 1 addition & 0 deletions test/lib/jdk/test/lib/NetworkConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ public static String interfaceInformation(NetworkInterface nif) {
}

/** Prints all the system interface information to the give stream. */
@SuppressWarnings("removal")
public static void printSystemConfiguration(PrintStream out) {
PrivilegedAction<Void> pa = () -> {
try {
Expand Down
5 changes: 3 additions & 2 deletions test/lib/jdk/test/lib/compiler/InMemoryJavaCompiler.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -36,6 +36,7 @@
import javax.tools.FileObject;
import javax.tools.JavaCompiler;
import javax.tools.JavaCompiler.CompilationTask;
import javax.tools.JavaFileManager;
import javax.tools.JavaFileObject;
import javax.tools.JavaFileObject.Kind;
import javax.tools.SimpleJavaFileObject;
Expand Down Expand Up @@ -106,7 +107,7 @@ public String getClassName() {
}
}

private static class FileManagerWrapper extends ForwardingJavaFileManager {
private static class FileManagerWrapper extends ForwardingJavaFileManager<JavaFileManager> {
private static final Location PATCH_LOCATION = new Location() {
@Override
public String getName() {
Expand Down
4 changes: 2 additions & 2 deletions test/lib/jdk/test/lib/format/ArrayCodec.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -141,7 +141,7 @@ public static ArrayCodec<Object> of(Object[] array) {
* @throws IllegalArgumentException if {@code array}'s component type is not supported
* @return an ArrayCodec for the provided array
*/
public static ArrayCodec of(Object array) {
public static ArrayCodec<?> of(Object array) {
var type = array.getClass().getComponentType();
if (type == byte.class) {
return ArrayCodec.of((byte[])array);
Expand Down
8 changes: 4 additions & 4 deletions test/lib/jdk/test/lib/format/ArrayDiff.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -93,7 +93,7 @@ private ArrayDiff(ArrayCodec<E> first, ArrayCodec<E> second,
* @param second the second array
* @return an ArrayDiff instance for the two arrays
*/
public static ArrayDiff of(Object first, Object second) {
public static ArrayDiff<?> of(Object first, Object second) {
return ArrayDiff.of(first, second, Diff.Defaults.WIDTH, Diff.Defaults.CONTEXT_BEFORE);
}

Expand All @@ -109,7 +109,8 @@ public static ArrayDiff of(Object first, Object second) {
* @throws NullPointerException if at least one of the arrays is null
* @return an ArrayDiff instance for the two arrays and formatting parameters provided
*/
public static ArrayDiff of(Object first, Object second, int width, int contextBefore) {
@SuppressWarnings("rawtypes")
public static ArrayDiff<?> of(Object first, Object second, int width, int contextBefore) {
Objects.requireNonNull(first);
Objects.requireNonNull(second);

Expand Down Expand Up @@ -204,4 +205,3 @@ private Optional<String> format(boolean bounded) {
}

}

1 change: 1 addition & 0 deletions test/lib/jdk/test/lib/hexdump/ASN1Formatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,7 @@ public static void main(String[] args) {
* @return the InputStream or the wrapped decoder of Base64Mime.
* @throws IOException if an I/O error occurs
*/
@SuppressWarnings("deprecation")
private static InputStream wrapIfBase64Mime(BufferedInputStream bis) throws IOException {
bis.mark(256);
DataInputStream dis = new DataInputStream(bis);
Expand Down
1 change: 1 addition & 0 deletions test/lib/jdk/test/lib/hexdump/StreamDump.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ static void dumpFile(InputStream fis, HexPrinter.Formatter formatter) throws IOE
* @return an InputStream, unchanged unless it is Base64 Mime
* @throws IOException if an I/O Error occurs
*/
@SuppressWarnings("deprecation")
static InputStream decodeMaybe(InputStream is) throws IOException {
DataInputStream dis = new DataInputStream(is);
is.mark(1024);
Expand Down
4 changes: 2 additions & 2 deletions test/lib/jdk/test/lib/process/Proc.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ public class Proc {

private List<String> args = new ArrayList<>();
private Map<String,String> env = new HashMap<>();
private Map<String,String> prop = new HashMap();
private Map<String,String> secprop = new HashMap();
private Map<String,String> prop = new HashMap<>();
private Map<String,String> secprop = new HashMap<>();
private boolean inheritIO = false;
private boolean noDump = false;

Expand Down
2 changes: 2 additions & 0 deletions test/lib/jdk/test/lib/process/ProcessTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ public static OutputAnalyzer executeProcess(ProcessBuilder pb, String input) thr
* the default charset.
* @return The {@linkplain OutputAnalyzer} instance wrapping the process.
*/
@SuppressWarnings("removal")
public static OutputAnalyzer executeProcess(ProcessBuilder pb, String input,
Charset cs) throws Exception {
OutputAnalyzer output = null;
Expand Down Expand Up @@ -604,6 +605,7 @@ public static ProcessBuilder addJvmLib(ProcessBuilder pb) throws Exception {
return pb;
}

@SuppressWarnings("removal")
private static Process privilegedStart(ProcessBuilder pb) throws IOException {
try {
return AccessController.doPrivileged(
Expand Down

1 comment on commit 03f647f

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.