Skip to content

Commit

Permalink
8260522: Clean up warnings in hotspot JTReg runtime tests
Browse files Browse the repository at this point in the history
Reviewed-by: lfoltan, coleenp
  • Loading branch information
Harold Seigel committed Feb 1, 2021
1 parent 02d586e commit 181d63f
Show file tree
Hide file tree
Showing 15 changed files with 60 additions and 49 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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 @@ -63,8 +63,8 @@ public static void main(String[] args) throws Exception {
public static class runJcmd {

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

Asserts.assertGT(minHeapFreeRatio, 0, "MinHeapFreeRatio must be greater than 0");
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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 @@ -76,7 +76,7 @@ public DoubleJVMOption(String name, double min, double max) {
*/
@Override
void setMin(String min) {
this.min = new Double(min);
this.min = Double.valueOf(min);
}

/**
Expand All @@ -96,7 +96,7 @@ String getMin() {
*/
@Override
void setMax(String max) {
this.max = new Double(max);
this.max = Double.valueOf(max);
}

/**
Expand Down
12 changes: 7 additions & 5 deletions test/hotspot/jtreg/runtime/LoadClass/LongBCP.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 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 @@ -39,6 +39,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.spi.ToolProvider;
import jdk.test.lib.compiler.CompilerUtils;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
Expand All @@ -47,6 +48,9 @@ public class LongBCP {

private static final int MAX_PATH = 260;

private static final ToolProvider JAR = ToolProvider.findFirst("jar")
.orElseThrow(() -> new RuntimeException("ToolProvider for jar not found"));

public static void main(String args[]) throws Exception {
Path sourceDir = Paths.get(System.getProperty("test.src"), "test-classes");
Path classDir = Paths.get(System.getProperty("test.classes"));
Expand Down Expand Up @@ -85,11 +89,9 @@ public static void main(String args[]) throws Exception {
.shouldHaveExitValue(0);

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

// run with long bootclasspath to hello.jar
Expand Down
4 changes: 2 additions & 2 deletions test/hotspot/jtreg/runtime/LoadClass/TriggerResize.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 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 @@ -89,7 +89,7 @@ public static void main(String args[]) throws Exception
{
int count = 0;
if (args.length >= 1) {
Integer i = new Integer(args[0]);
Integer i = Integer.parseInt(args[0]);
count = i.intValue();
}

Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 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 @@ -50,7 +50,6 @@ public class CommandLineFlagCombo {
// shared base address test table
private static final String[] testTable = {
"-XX:+UseG1GC", "-XX:+UseSerialGC", "-XX:+UseParallelGC",
"-XX:+FlightRecorder",
"-XX:+UseLargePages", // may only take effect on machines with large-pages
"-XX:+UseCompressedClassPointers",
"-XX:+UseCompressedOops",
Expand Down Expand Up @@ -122,7 +121,7 @@ private static boolean skipTestCase(String testEntry) throws Exception {
}
}

if (!WhiteBox.getWhiteBox().isJFRIncludedInVmBuild() && testEntry.equals("-XX:+FlightRecorder"))
if (!WhiteBox.getWhiteBox().isJFRIncludedInVmBuild())
{
System.out.println("JFR does not exist");
return true;
Expand Down
3 changes: 1 addition & 2 deletions test/hotspot/jtreg/runtime/cds/appcds/TestWithProfiler.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 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 @@ -49,7 +49,6 @@ public static void main(String[] args) throws Exception {
output = TestCommon.exec(appJar,
"-XX:+UnlockDiagnosticVMOptions",
"-Xint",
"-XX:+FlightRecorder",
"-XX:StartFlightRecording=duration=15s,filename=myrecording.jfr,settings=profile,dumponexit=true",
"TestWithProfilerHelper");
TestCommon.checkExec(output);
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 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 @@ -45,7 +45,7 @@ public class MirrorWithReferenceFieldsApp {

public MirrorWithReferenceFieldsApp() {
non_archived_field_1 = new Object();
non_archived_field_2 = new Integer(1);
non_archived_field_2 = Integer.valueOf(1);
}

public static void main(String args[]) throws Exception {
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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 @@ -31,13 +31,16 @@

import java.io.File;
import java.util.ArrayList;
import sun.tools.jar.Main;
import java.util.spi.ToolProvider;

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

private static final ToolProvider JAR = ToolProvider.findFirst("jar")
.orElseThrow(() -> new RuntimeException("ToolProvider for jar not found"));

public static void build(boolean classesInWorkDir, String jarName,
String ...classNames) throws Exception {

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

private static void createJar(ArrayList<String> args) {
Main jarTool = new Main(System.out, System.err, "jar");
if (!jarTool.run(args.toArray(new String[1]))) {
if (JAR.run(System.out, System.err, args.toArray(new String[1])) != 0) {
throw new RuntimeException("jar operation failed");
}
}
Expand Down
12 changes: 8 additions & 4 deletions test/hotspot/jtreg/runtime/records/RedefineRecord.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 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 @@ -28,7 +28,6 @@
* @summary Test that a class that is a record can be redefined.
* @modules java.base/jdk.internal.misc
* @modules java.instrument
* jdk.jartool/sun.tools.jar
* @requires vm.jvmti
* @run main RedefineRecord buildagent
* @run main/othervm/timeout=6000 RedefineRecord runtest
Expand All @@ -41,11 +40,15 @@
import java.lang.instrument.Instrumentation;
import java.security.ProtectionDomain;
import java.lang.instrument.IllegalClassFormatException;
import java.util.spi.ToolProvider;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;

public class RedefineRecord {

private static final ToolProvider JAR = ToolProvider.findFirst("jar")
.orElseThrow(() -> new RuntimeException("ToolProvider for jar not found"));

record Tester(int x, String y, long z) { }

static class LoggingTransformer implements ClassFileTransformer {
Expand All @@ -67,6 +70,7 @@ public static void premain(String agentArgs, Instrumentation inst) throws Except
inst.retransformClasses(demoClass);
}
}

private static void buildAgent() {
try {
ClassFileInstaller.main("RedefineRecord");
Expand All @@ -85,11 +89,11 @@ private static void buildAgent() {
throw new RuntimeException("Could not write manifest file for the agent", e);
}

sun.tools.jar.Main jarTool = new sun.tools.jar.Main(System.out, System.err, "jar");
if (!jarTool.run(new String[] { "-cmf", "MANIFEST.MF", "redefineagent.jar", "RedefineRecord.class" })) {
if (JAR.run(System.out, System.err, "-cmf", "MANIFEST.MF", "redefineagent.jar", "RedefineRecord.class") != 0) {
throw new RuntimeException("Could not write the agent jar file");
}
}

public static void main(String argv[]) throws Exception {
if (argv.length == 1 && argv[0].equals("buildagent")) {
buildAgent();
Expand Down
4 changes: 2 additions & 2 deletions test/hotspot/jtreg/runtime/reflect/ArrayGetIntException.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 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 @@ -32,7 +32,7 @@

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

// this access is legal
try {
Expand Down
Expand Up @@ -29,7 +29,6 @@
class, can be redefined.
* @modules java.base/jdk.internal.misc
* @modules java.instrument
* jdk.jartool/sun.tools.jar
* @requires vm.jvmti
* @compile --enable-preview -source ${jdk.version} RedefinePermittedSubclass.java
* @run main/othervm --enable-preview RedefinePermittedSubclass buildagent
Expand All @@ -41,13 +40,17 @@
import java.lang.RuntimeException;
import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.Instrumentation;
import java.security.ProtectionDomain;
import java.lang.instrument.IllegalClassFormatException;
import java.security.ProtectionDomain;
import java.util.spi.ToolProvider;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;

public class RedefinePermittedSubclass {

private static final ToolProvider JAR = ToolProvider.findFirst("jar")
.orElseThrow(() -> new RuntimeException("ToolProvider for jar not found"));

non-sealed class A extends Tester {
public void printIt() { System.out.println("In A"); }
}
Expand Down Expand Up @@ -99,8 +102,8 @@ private static void buildAgent() {
throw new RuntimeException("Could not write manifest file for the agent", e);
}

sun.tools.jar.Main jarTool = new sun.tools.jar.Main(System.out, System.err, "jar");
if (!jarTool.run(new String[] { "-cmf", "MANIFEST.MF", "redefineagent.jar", "RedefinePermittedSubclass.class" })) {
if (JAR.run(System.out, System.err, "-cmf", "MANIFEST.MF", "redefineagent.jar",
"RedefinePermittedSubclass.class") != 0) {
throw new RuntimeException("Could not write the agent jar file");
}
}
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 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 @@ -28,7 +28,6 @@
* @summary Test that a class that is a sealed class can be redefined.
* @modules java.base/jdk.internal.misc
* @modules java.instrument
* jdk.jartool/sun.tools.jar
* @requires vm.jvmti
* @compile --enable-preview -source ${jdk.version} RedefineSealedClass.java
* @run main/othervm --enable-preview RedefineSealedClass buildagent
Expand All @@ -40,13 +39,17 @@
import java.lang.RuntimeException;
import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.Instrumentation;
import java.security.ProtectionDomain;
import java.lang.instrument.IllegalClassFormatException;
import java.security.ProtectionDomain;
import java.util.spi.ToolProvider;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;

public class RedefineSealedClass {

private static final ToolProvider JAR = ToolProvider.findFirst("jar")
.orElseThrow(() -> new RuntimeException("ToolProvider for jar not found"));

final class A extends Tester { }
final class B extends Tester { }

Expand Down Expand Up @@ -90,8 +93,7 @@ private static void buildAgent() {
throw new RuntimeException("Could not write manifest file for the agent", e);
}

sun.tools.jar.Main jarTool = new sun.tools.jar.Main(System.out, System.err, "jar");
if (!jarTool.run(new String[] { "-cmf", "MANIFEST.MF", "redefineagent.jar", "RedefineSealedClass.class" })) {
if (JAR.run(System.out, System.err, "-cmf", "MANIFEST.MF", "redefineagent.jar", "RedefineSealedClass.class") != 0) {
throw new RuntimeException("Could not write the agent jar file");
}
}
Expand Down
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 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 @@ -71,10 +71,10 @@ void run(String... args) {
}
void testLostOverloadedMethod() {
C c = new C();
assertEquals(c.bbb(new Integer(1)), 22);
assertEquals(c.bbb(new Float(1.1)), 33);
assertEquals(c.bbb(new Long(1L)), 44);
assertEquals(c.bbb(new Double(0.01)), 55);
assertEquals(c.bbb(Integer.valueOf(1)), 22);
assertEquals(c.bbb(Float.valueOf(1.1F)), 33);
assertEquals(c.bbb(Long.valueOf(1L)), 44);
assertEquals(c.bbb(Double.valueOf(0.01)), 55);
assertEquals(c.bbb(new String("")), 66);
}
// Test to ensure that the inference verifier accepts older classfiles
Expand Down
6 changes: 3 additions & 3 deletions test/hotspot/jtreg/testlibrary/jvmti/TransformerAgent.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 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 @@ -98,9 +98,9 @@ private static boolean shouldTransform(String name) {
static Integer incrCounter(String className) {
Integer i = counterMap.get(className);
if (i == null) {
i = new Integer(1);
i = Integer.valueOf(1);
} else {
i = new Integer(i.intValue() + 1);
i = Integer.valueOf(i.intValue() + 1);
}
counterMap.put(className, i);
return i;
Expand Down
4 changes: 2 additions & 2 deletions test/lib/jdk/test/lib/classloader/GeneratingClassLoader.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 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 @@ -173,7 +173,7 @@ private void getOffsets(byte[] bytecode) {
if (i == bytecode.length) {
break;
}
offsets.add(new Integer(i));
offsets.add(i);
i++;
}
} catch (UnsupportedEncodingException e) {
Expand Down

1 comment on commit 181d63f

@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.