Skip to content

Commit 181d63f

Browse files
author
Harold Seigel
committed
8260522: Clean up warnings in hotspot JTReg runtime tests
Reviewed-by: lfoltan, coleenp
1 parent 02d586e commit 181d63f

File tree

15 files changed

+60
-49
lines changed

15 files changed

+60
-49
lines changed

test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/TestJcmdOutput.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2021, 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
@@ -63,8 +63,8 @@ public static void main(String[] args) throws Exception {
6363
public static class runJcmd {
6464

6565
public static void main(String[] args) throws Exception {
66-
int minHeapFreeRatio = new Integer((new DynamicVMOption("MinHeapFreeRatio")).getValue());
67-
int maxHeapFreeRatio = new Integer((new DynamicVMOption("MaxHeapFreeRatio")).getValue());
66+
int minHeapFreeRatio = Integer.valueOf((new DynamicVMOption("MinHeapFreeRatio")).getValue());
67+
int maxHeapFreeRatio = Integer.valueOf((new DynamicVMOption("MaxHeapFreeRatio")).getValue());
6868
PidJcmdExecutor executor = new PidJcmdExecutor();
6969

7070
Asserts.assertGT(minHeapFreeRatio, 0, "MinHeapFreeRatio must be greater than 0");

test/hotspot/jtreg/runtime/CommandLine/OptionsValidation/common/optionsvalidation/DoubleJVMOption.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2021, 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
@@ -76,7 +76,7 @@ public DoubleJVMOption(String name, double min, double max) {
7676
*/
7777
@Override
7878
void setMin(String min) {
79-
this.min = new Double(min);
79+
this.min = Double.valueOf(min);
8080
}
8181

8282
/**
@@ -96,7 +96,7 @@ String getMin() {
9696
*/
9797
@Override
9898
void setMax(String max) {
99-
this.max = new Double(max);
99+
this.max = Double.valueOf(max);
100100
}
101101

102102
/**

test/hotspot/jtreg/runtime/LoadClass/LongBCP.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2021, 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
@@ -39,6 +39,7 @@
3939
import java.nio.file.Path;
4040
import java.nio.file.Paths;
4141
import java.util.Arrays;
42+
import java.util.spi.ToolProvider;
4243
import jdk.test.lib.compiler.CompilerUtils;
4344
import jdk.test.lib.process.ProcessTools;
4445
import jdk.test.lib.process.OutputAnalyzer;
@@ -47,6 +48,9 @@ public class LongBCP {
4748

4849
private static final int MAX_PATH = 260;
4950

51+
private static final ToolProvider JAR = ToolProvider.findFirst("jar")
52+
.orElseThrow(() -> new RuntimeException("ToolProvider for jar not found"));
53+
5054
public static void main(String args[]) throws Exception {
5155
Path sourceDir = Paths.get(System.getProperty("test.src"), "test-classes");
5256
Path classDir = Paths.get(System.getProperty("test.classes"));
@@ -85,11 +89,9 @@ public static void main(String args[]) throws Exception {
8589
.shouldHaveExitValue(0);
8690

8791
// create a hello.jar
88-
sun.tools.jar.Main jarTool = new sun.tools.jar.Main(System.out, System.err, "jar");
8992
String helloJar = destDir.toString() + File.separator + "hello.jar";
90-
if (!jarTool.run(new String[]
91-
{"-cf", helloJar, "-C", destDir.toString(), "Hello.class"})) {
92-
throw new RuntimeException("Could not write the Hello jar file");
93+
if (JAR.run(System.out, System.err, "-cf", helloJar, "-C", destDir.toString(), "Hello.class") != 0) {
94+
throw new RuntimeException("jar operation for hello.jar failed");
9395
}
9496

9597
// run with long bootclasspath to hello.jar

test/hotspot/jtreg/runtime/LoadClass/TriggerResize.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2021, 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
@@ -89,7 +89,7 @@ public static void main(String args[]) throws Exception
8989
{
9090
int count = 0;
9191
if (args.length >= 1) {
92-
Integer i = new Integer(args[0]);
92+
Integer i = Integer.parseInt(args[0]);
9393
count = i.intValue();
9494
}
9595

test/hotspot/jtreg/runtime/cds/appcds/CommandLineFlagCombo.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2021, 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
@@ -50,7 +50,6 @@ public class CommandLineFlagCombo {
5050
// shared base address test table
5151
private static final String[] testTable = {
5252
"-XX:+UseG1GC", "-XX:+UseSerialGC", "-XX:+UseParallelGC",
53-
"-XX:+FlightRecorder",
5453
"-XX:+UseLargePages", // may only take effect on machines with large-pages
5554
"-XX:+UseCompressedClassPointers",
5655
"-XX:+UseCompressedOops",
@@ -122,7 +121,7 @@ private static boolean skipTestCase(String testEntry) throws Exception {
122121
}
123122
}
124123

125-
if (!WhiteBox.getWhiteBox().isJFRIncludedInVmBuild() && testEntry.equals("-XX:+FlightRecorder"))
124+
if (!WhiteBox.getWhiteBox().isJFRIncludedInVmBuild())
126125
{
127126
System.out.println("JFR does not exist");
128127
return true;

test/hotspot/jtreg/runtime/cds/appcds/TestWithProfiler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2021, 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
@@ -49,7 +49,6 @@ public static void main(String[] args) throws Exception {
4949
output = TestCommon.exec(appJar,
5050
"-XX:+UnlockDiagnosticVMOptions",
5151
"-Xint",
52-
"-XX:+FlightRecorder",
5352
"-XX:StartFlightRecording=duration=15s,filename=myrecording.jfr,settings=profile,dumponexit=true",
5453
"TestWithProfilerHelper");
5554
TestCommon.checkExec(output);

test/hotspot/jtreg/runtime/cds/appcds/cacheObject/MirrorWithReferenceFieldsApp.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2018, 2021, 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
@@ -45,7 +45,7 @@ public class MirrorWithReferenceFieldsApp {
4545

4646
public MirrorWithReferenceFieldsApp() {
4747
non_archived_field_1 = new Object();
48-
non_archived_field_2 = new Integer(1);
48+
non_archived_field_2 = Integer.valueOf(1);
4949
}
5050

5151
public static void main(String args[]) throws Exception {

test/hotspot/jtreg/runtime/modules/PatchModule/BasicJarBuilder.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2021, 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
@@ -31,13 +31,16 @@
3131

3232
import java.io.File;
3333
import java.util.ArrayList;
34-
import sun.tools.jar.Main;
34+
import java.util.spi.ToolProvider;
3535

3636
// Using JarBuilder requires that all to-be-jarred classes should be placed
3737
// in the current working directory, aka "."
3838
public class BasicJarBuilder {
3939
private static final String classDir = System.getProperty("test.classes");
4040

41+
private static final ToolProvider JAR = ToolProvider.findFirst("jar")
42+
.orElseThrow(() -> new RuntimeException("ToolProvider for jar not found"));
43+
4144
public static void build(boolean classesInWorkDir, String jarName,
4245
String ...classNames) throws Exception {
4346

@@ -73,8 +76,7 @@ private static void addClassArgs(ArrayList<String> args, String jarclassDir,
7376
}
7477

7578
private static void createJar(ArrayList<String> args) {
76-
Main jarTool = new Main(System.out, System.err, "jar");
77-
if (!jarTool.run(args.toArray(new String[1]))) {
79+
if (JAR.run(System.out, System.err, args.toArray(new String[1])) != 0) {
7880
throw new RuntimeException("jar operation failed");
7981
}
8082
}

test/hotspot/jtreg/runtime/records/RedefineRecord.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2019, 2021, 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
@@ -28,7 +28,6 @@
2828
* @summary Test that a class that is a record can be redefined.
2929
* @modules java.base/jdk.internal.misc
3030
* @modules java.instrument
31-
* jdk.jartool/sun.tools.jar
3231
* @requires vm.jvmti
3332
* @run main RedefineRecord buildagent
3433
* @run main/othervm/timeout=6000 RedefineRecord runtest
@@ -41,11 +40,15 @@
4140
import java.lang.instrument.Instrumentation;
4241
import java.security.ProtectionDomain;
4342
import java.lang.instrument.IllegalClassFormatException;
43+
import java.util.spi.ToolProvider;
4444
import jdk.test.lib.process.ProcessTools;
4545
import jdk.test.lib.process.OutputAnalyzer;
4646

4747
public class RedefineRecord {
4848

49+
private static final ToolProvider JAR = ToolProvider.findFirst("jar")
50+
.orElseThrow(() -> new RuntimeException("ToolProvider for jar not found"));
51+
4952
record Tester(int x, String y, long z) { }
5053

5154
static class LoggingTransformer implements ClassFileTransformer {
@@ -67,6 +70,7 @@ public static void premain(String agentArgs, Instrumentation inst) throws Except
6770
inst.retransformClasses(demoClass);
6871
}
6972
}
73+
7074
private static void buildAgent() {
7175
try {
7276
ClassFileInstaller.main("RedefineRecord");
@@ -85,11 +89,11 @@ private static void buildAgent() {
8589
throw new RuntimeException("Could not write manifest file for the agent", e);
8690
}
8791

88-
sun.tools.jar.Main jarTool = new sun.tools.jar.Main(System.out, System.err, "jar");
89-
if (!jarTool.run(new String[] { "-cmf", "MANIFEST.MF", "redefineagent.jar", "RedefineRecord.class" })) {
92+
if (JAR.run(System.out, System.err, "-cmf", "MANIFEST.MF", "redefineagent.jar", "RedefineRecord.class") != 0) {
9093
throw new RuntimeException("Could not write the agent jar file");
9194
}
9295
}
96+
9397
public static void main(String argv[]) throws Exception {
9498
if (argv.length == 1 && argv[0].equals("buildagent")) {
9599
buildAgent();

test/hotspot/jtreg/runtime/reflect/ArrayGetIntException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2021, 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
@@ -32,7 +32,7 @@
3232

3333
public class ArrayGetIntException {
3434
public static void main(String[] args) throws Exception {
35-
Object[] objArray = {new Integer(Integer.MAX_VALUE)};
35+
Object[] objArray = {Integer.valueOf(Integer.MAX_VALUE)};
3636

3737
// this access is legal
3838
try {

0 commit comments

Comments
 (0)