8237111: LingeredApp should be started with getTestJavaOpts

Reviewed-by: cjplummer, dholmes
This commit is contained in:
Stefan Karlsson 2020-01-24 10:31:45 +01:00
parent 46423b0f70
commit c8e7590899
49 changed files with 248 additions and 298 deletions

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2019, 2020, 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
@ -27,15 +27,24 @@
#
#############################################################################
resourcehogs/serviceability/sa/TestHeapDumpForLargeArray.java 8220624 generic-all
serviceability/sa/ClhsdbInspect.java 8220624 generic-all
serviceability/sa/ClhsdbJdis.java 8220624 generic-all
serviceability/sa/ClhsdbJhisto.java 8220624 generic-all
serviceability/sa/ClhsdbJstack.java 8220624 generic-all
serviceability/sa/ClhsdbPrintAs.java 8220624 generic-all
serviceability/sa/ClhsdbPrintStatics.java 8220624 generic-all
serviceability/sa/ClhsdbPstack.java 8220624 generic-all
serviceability/sa/ClhsdbSource.java 8220624 generic-all
serviceability/sa/ClhsdbThread.java 8220624 generic-all
serviceability/sa/ClhsdbWhere.java 8220624 generic-all
serviceability/sa/DeadlockDetectionTest.java 8220624 generic-all
serviceability/sa/JhsdbThreadInfoTest.java 8220624 generic-all
serviceability/sa/TestClhsdbJstackLock.java 8220624 generic-all
serviceability/sa/TestHeapDumpForInvokeDynamic.java 8220624 generic-all
serviceability/sa/TestHeapDumpForLargeArray.java 8220624 generic-all
serviceability/sa/TestJhsdbJstackLock.java 8220624 generic-all
serviceability/sa/TestJhsdbJstackMixed.java 8220624 generic-all
serviceability/sa/TestJmapCore.java 8220624 generic-all
serviceability/sa/TestJmapCoreMetaspace.java 8219443 generic-all
serviceability/sa/sadebugd/DebugdConnectTest.java 8220624 generic-all

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020, 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
@ -45,13 +45,12 @@ public class ClhsdbRegionDetailsScanOopsForG1 {
LingeredAppWithLargeStringArray theApp = null;
try {
ClhsdbLauncher test = new ClhsdbLauncher();
List<String> vmArgs = new ArrayList<String>();
vmArgs.add("-XX:+UseG1GC");
vmArgs.add("-Xmx8g");
vmArgs.add("-XX:G1HeapRegionSize=2m");
theApp = new LingeredAppWithLargeStringArray();
LingeredApp.startApp(vmArgs, theApp);
LingeredApp.startApp(theApp,
"-XX:+UseG1GC",
"-Xmx8g",
"-XX:G1HeapRegionSize=2m");
System.out.println("Started LingeredAppWithLargeStringArray with pid " + theApp.getPid());
List<String> cmds = List.of("g1regiondetails");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, 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
@ -98,13 +98,12 @@ public class TestHeapDumpForLargeArray {
// Need to add the default arguments first to have explicit
// -Xmx8g last, otherwise test will fail if default
// arguments contain a smaller -Xmx.
List<String> vmArgs = new ArrayList<String>();
vmArgs.addAll(Utils.getVmOptions());
vmArgs.add("-XX:+UsePerfData");
vmArgs.add("-Xmx8g");
String[] vmArgs = Utils.prependTestJavaOpts(
"-XX:+UsePerfData",
"-Xmx8g");
theApp = new LingeredAppWithLargeArray();
LingeredApp.startApp(vmArgs, theApp);
LingeredApp.startApp(theApp, vmArgs);
attachAndDump(heapDumpFileName, theApp.getPid());
} finally {
LingeredApp.stopApp(theApp);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020, 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
@ -71,11 +71,10 @@ public class CDSJMapClstats {
CDSOptions opts = (new CDSOptions()).setArchiveName(sharedArchiveName);
CDSTestUtils.createArchiveAndCheck(opts);
List<String> vmArgs = Arrays.asList(
theApp = LingeredApp.startApp(
"-XX:+UnlockDiagnosticVMOptions",
"-XX:SharedArchiveFile=" + sharedArchiveName,
"-Xshare:auto");
theApp = LingeredApp.startApp(vmArgs);
System.out.println("Started LingeredApp with pid " + theApp.getPid());
runClstats(theApp.getPid());
} catch (Exception ex) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020, 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
@ -51,11 +51,10 @@ public class ClhsdbCDSJstackPrintAll {
CDSTestUtils.createArchiveAndCheck(opts);
ClhsdbLauncher test = new ClhsdbLauncher();
List<String> vmArgs = Arrays.asList(
theApp = LingeredApp.startApp(
"-XX:+UnlockDiagnosticVMOptions",
"-XX:SharedArchiveFile=" + sharedArchiveName,
"-Xshare:auto");
theApp = LingeredApp.startApp(vmArgs);
System.out.println("Started LingeredApp with pid " + theApp.getPid());
// Ensure that UseSharedSpaces is turned on.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, 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
@ -48,9 +48,9 @@ public class ClhsdbFindPC {
theApp = new LingeredAppWithTrivialMain();
if (withXcomp) {
LingeredApp.startApp(List.of("-Xcomp"), theApp);
LingeredApp.startApp(theApp, "-Xcomp");
} else {
LingeredApp.startApp(List.of("-Xint"), theApp);
LingeredApp.startApp(theApp, "-Xint");
}
System.out.print("Started LingeredApp ");
if (withXcomp) {
@ -114,4 +114,3 @@ public class ClhsdbFindPC {
System.out.println("Test PASSED");
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, 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
@ -49,11 +49,10 @@ public class ClhsdbFlags {
LingeredApp theApp = null;
try {
ClhsdbLauncher test = new ClhsdbLauncher();
List<String> vmArgs = new ArrayList<String>();
vmArgs.add("-XX:+UnlockExperimentalVMOptions");
vmArgs.add("-XX:+UnlockDiagnosticVMOptions");
vmArgs.add("-XX:-MaxFDLimit");
vmArgs.addAll(Utils.getVmOptions());
String[] vmArgs = Utils.appendTestJavaOpts(
"-XX:+UnlockExperimentalVMOptions",
"-XX:+UnlockDiagnosticVMOptions",
"-XX:-MaxFDLimit");
theApp = LingeredApp.startApp(vmArgs);
System.out.println("Started LingeredApp with pid " + theApp.getPid());
@ -100,18 +99,18 @@ public class ClhsdbFlags {
LingeredApp theApp = null;
try {
ClhsdbLauncher test = new ClhsdbLauncher();
List<String> vmArgs = new ArrayList<String>();
vmArgs.add("-XX:+UnlockDiagnosticVMOptions"); // bool
vmArgs.add("-XX:ActiveProcessorCount=1"); // int
vmArgs.add("-XX:ParallelGCThreads=1"); // uint
vmArgs.add("-XX:MaxJavaStackTraceDepth=1024"); // intx
vmArgs.add("-XX:LogEventsBufferEntries=10"); // uintx
vmArgs.add("-XX:HeapSizePerGCThread=32m"); // size_t
vmArgs.add("-XX:NativeMemoryTracking=off"); // ccstr
vmArgs.add("-XX:OnError='echo error'"); // ccstrlist
vmArgs.add("-XX:CompileThresholdScaling=1.0"); // double
vmArgs.add("-XX:ErrorLogTimeout=120"); // uint64_t
vmArgs.addAll(Utils.getVmOptions());
// *Prepend* options to prevent interference with flags below
String[] vmArgs = Utils.prependTestJavaOpts(
"-XX:+UnlockDiagnosticVMOptions", // bool
"-XX:ActiveProcessorCount=1", // int
"-XX:ParallelGCThreads=1", // uint
"-XX:MaxJavaStackTraceDepth=1024", // intx
"-XX:LogEventsBufferEntries=10", // uintx
"-XX:HeapSizePerGCThread=32m", // size_t
"-XX:NativeMemoryTracking=off", // ccstr
"-XX:OnError='echo error'", // ccstrlist
"-XX:CompileThresholdScaling=1.0", // double
"-XX:ErrorLogTimeout=120"); // uint64_t
theApp = LingeredApp.startApp(vmArgs);
System.out.println("Started LingeredApp with pid " + theApp.getPid());

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, 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
@ -47,7 +47,7 @@ public class ClhsdbInspect {
ClhsdbLauncher test = new ClhsdbLauncher();
theApp = new LingeredAppWithLock();
LingeredApp.startApp(null, theApp);
LingeredApp.startApp(theApp);
System.out.println("Started LingeredApp with pid " + theApp.getPid());
// Run the 'jstack -v' command to get the address of a Method*,

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, 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
@ -47,11 +47,9 @@ public class ClhsdbJhisto {
LingeredAppWithInterface theApp = null;
try {
ClhsdbLauncher test = new ClhsdbLauncher();
List<String> vmArgs = new ArrayList<String>();
vmArgs.addAll(Utils.getVmOptions());
theApp = new LingeredAppWithInterface();
LingeredApp.startApp(vmArgs, theApp);
LingeredApp.startApp(theApp);
System.out.println("Started LingeredApp with pid " + theApp.getPid());
List<String> cmds = List.of("jhisto");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, 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
@ -43,7 +43,7 @@ public class ClhsdbJstack {
LingeredApp theApp = null;
try {
ClhsdbLauncher test = new ClhsdbLauncher();
theApp = withXcomp ? LingeredApp.startApp(List.of("-Xcomp"))
theApp = withXcomp ? LingeredApp.startApp("-Xcomp")
: LingeredApp.startApp();
System.out.print("Started LingeredApp ");
if (withXcomp) {

View File

@ -1,4 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, Red Hat Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -89,12 +90,12 @@ public class ClhsdbJstackXcompStress {
public static void main(String... args) throws Exception {
LingeredApp app = null;
try {
List<String> vmArgs = List.of("-Xcomp",
"-XX:CompileCommand=dontinline,LingeredAppWithRecComputation.factorial",
"-XX:CompileCommand=compileonly,LingeredAppWithRecComputation.testLoop",
"-XX:CompileCommand=compileonly,LingeredAppWithRecComputation.factorial");
app = new LingeredAppWithRecComputation();
LingeredApp.startApp(vmArgs, app);
LingeredApp.startApp(app,
"-Xcomp",
"-XX:CompileCommand=dontinline,LingeredAppWithRecComputation.factorial",
"-XX:CompileCommand=compileonly,LingeredAppWithRecComputation.testLoop",
"-XX:CompileCommand=compileonly,LingeredAppWithRecComputation.factorial");
System.out.println("Started LingeredAppWithRecComputation with pid " + app.getPid());
runJstackInLoop(app);
System.out.println("Test Completed");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020, 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
@ -46,7 +46,7 @@ public class ClhsdbPrintAll {
ClhsdbLauncher test = new ClhsdbLauncher();
theApp = new LingeredAppWithEnum();
LingeredApp.startApp(null, theApp);
LingeredApp.startApp(theApp);
System.out.println("Started LingeredAppWithEnum with pid " + theApp.getPid());
List<String> cmds = List.of("printall");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, 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
@ -46,9 +46,7 @@ public class ClhsdbScanOops {
try {
ClhsdbLauncher test = new ClhsdbLauncher();
List<String> vmArgs = new ArrayList<String>();
vmArgs.add(gc);
theApp = LingeredApp.startApp(vmArgs);
theApp = LingeredApp.startApp(gc);
System.out.println ("Started LingeredApp with the GC option " + gc +
" and pid " + theApp.getPid());

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2020, 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
@ -78,12 +78,10 @@ public class DeadlockDetectionTest {
}
try {
List<String> vmArgs = new ArrayList<String>();
vmArgs.add("-XX:+UsePerfData");
vmArgs.addAll(Utils.getVmOptions());
String[] vmArgs = Utils.appendTestJavaOpts("-XX:+UsePerfData");
theApp = new LingeredAppWithDeadlock();
LingeredApp.startApp(vmArgs, theApp);
LingeredApp.startApp(theApp, vmArgs);
OutputAnalyzer output = jstack("--pid", Long.toString(theApp.getPid()));
System.out.println(output.getOutput());

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, 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
@ -45,7 +45,7 @@ public class JhsdbThreadInfoTest {
LingeredApp app = null;
try {
app = LingeredApp.startApp(Utils.getVmOptions());
app = LingeredApp.startApp();
System.out.println("Started LingeredApp with pid " + app.getPid());
JDKToolLauncher jhsdbLauncher = JDKToolLauncher.createUsingTestJDK("jhsdb");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, 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
@ -43,10 +43,9 @@ public class TestClhsdbJstackLock {
LingeredAppWithLock app = null;
try {
ClhsdbLauncher test = new ClhsdbLauncher();
List<String> vmArgs = new ArrayList<String>(Utils.getVmOptions());
app = new LingeredAppWithLock();
LingeredApp.startApp(vmArgs, app);
LingeredApp.startApp(app);
System.out.println ("Started LingeredAppWithLock with pid " + app.getPid());
@ -73,4 +72,3 @@ public class TestClhsdbJstackLock {
System.out.println("Test PASSED");
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2020, 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
@ -122,12 +122,11 @@ public class TestCpoolForInvokeDynamic {
if (args == null || args.length == 0) {
try {
List<String> vmArgs = new ArrayList<String>();
vmArgs.add("-XX:+UsePerfData");
vmArgs.addAll(Utils.getVmOptions());
String[] vmArgs = Utils.appendTestJavaOpts(
"-XX:+UsePerfData");
theApp = new LingeredAppWithInvokeDynamic();
LingeredApp.startApp(vmArgs, theApp);
LingeredApp.startApp(theApp, vmArgs);
createAnotherToAttach(instanceKlassNames,
theApp.getPid());
} finally {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2020, 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
@ -133,12 +133,10 @@ public class TestDefaultMethods {
if (args == null || args.length == 0) {
try {
List<String> vmArgs = new ArrayList<String>();
vmArgs.add("-XX:+UsePerfData");
vmArgs.addAll(Utils.getVmOptions());
String[] vmArgs = Utils.appendTestJavaOpts("-XX:+UsePerfData");
theApp = new LingeredAppWithDefaultMethods();
LingeredApp.startApp(vmArgs, theApp);
LingeredApp.startApp(theApp, vmArgs);
createAnotherToAttach(instanceKlassNames,
theApp.getPid());
} finally {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020, 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
@ -90,13 +90,12 @@ public class TestG1HeapRegion {
public static void main (String... args) throws Exception {
if (args == null || args.length == 0) {
try {
List<String> vmArgs = new ArrayList<String>();
vmArgs.add("-XX:+UsePerfData");
vmArgs.add("-XX:+UseG1GC");
vmArgs.addAll(Utils.getVmOptions());
String[] vmArgs = Utils.appendTestJavaOpts(
"-XX:+UsePerfData",
"-XX:+UseG1GC");
theApp = new LingeredApp();
LingeredApp.startApp(vmArgs, theApp);
LingeredApp.startApp(theApp, vmArgs);
createAnotherToAttach(theApp.getPid());
} finally {
LingeredApp.stopApp(theApp);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2020, 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
@ -121,13 +121,12 @@ public class TestHeapDumpForInvokeDynamic {
}
try {
List<String> vmArgs = new ArrayList<String>();
vmArgs.add("-XX:+UsePerfData");
vmArgs.add("-Xmx512m");
vmArgs.addAll(Utils.getVmOptions());
String[] vmArgs = Utils.appendTestJavaOpts(
"-XX:+UsePerfData",
"-Xmx512m");
theApp = new LingeredAppWithInvokeDynamic();
LingeredApp.startApp(vmArgs, theApp);
LingeredApp.startApp(theApp, vmArgs);
attachDumpAndVerify(heapDumpFileName, theApp.getPid());
} finally {
LingeredApp.stopApp(theApp);

View File

@ -73,9 +73,7 @@ public class TestInstanceKlassSize {
LingeredApp app = null;
OutputAnalyzer output = null;
try {
List<String> vmArgs = new ArrayList<String>();
vmArgs.add("-XX:+UsePerfData");
vmArgs.addAll(Arrays.asList(Utils.getTestJavaOpts()));
String[] vmArgs = Utils.appendTestJavaOpts("-XX:+UsePerfData");
app = LingeredApp.startApp(vmArgs);
System.out.println ("Started LingeredApp with pid " + app.getPid());
} catch (Exception ex) {
@ -159,4 +157,3 @@ public class TestInstanceKlassSize {
}
}
}

View File

@ -150,9 +150,8 @@ public class TestInstanceKlassSizeForInterface {
if (args == null || args.length == 0) {
try {
List<String> vmArgs = Arrays.asList(Utils.getTestJavaOpts());
theApp = new LingeredAppWithInterface();
LingeredApp.startApp(vmArgs, theApp);
LingeredApp.startApp(theApp);
createAnotherToAttach(instanceKlassNames,
(int)theApp.getPid());
} finally {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, 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
@ -46,9 +46,8 @@ public class TestIntConstant {
LingeredApp app = null;
try {
ClhsdbLauncher test = new ClhsdbLauncher();
List<String> vmArgs = new ArrayList<String>(Utils.getVmOptions());
app = LingeredApp.startApp(vmArgs);
app = LingeredApp.startApp();
System.out.println ("Started LingeredApp with pid " + app.getPid());

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, 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
@ -51,10 +51,8 @@ public class TestJhsdbJstackLock {
LingeredApp app = null;
try {
List<String> vmArgs = new ArrayList<String>(Utils.getVmOptions());
app = new LingeredAppWithLock();
LingeredApp.startApp(vmArgs, app);
LingeredApp.startApp(app);
System.out.println ("Started LingeredApp with pid " + app.getPid());
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020, 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
@ -165,15 +165,14 @@ public class TestJhsdbJstackMixed {
LingeredApp app = null;
try {
List<String> vmArgs = new ArrayList<String>(Utils.getVmOptions());
// Needed for LingeredApp to be able to resolve native library.
String libPath = System.getProperty("java.library.path");
if (libPath != null) {
vmArgs.add("-Djava.library.path=" + libPath);
}
String[] vmArgs = (libPath != null)
? Utils.prependTestJavaOpts("-Djava.library.path=" + libPath)
: Utils.getTestJavaOpts();
app = new LingeredAppWithNativeMethod();
LingeredApp.startApp(vmArgs, app);
LingeredApp.startApp(app, vmArgs);
System.out.println("Started LingeredApp with pid " + app.getPid());
runJstackMixedInLoop(app);
System.out.println("Test Completed");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, 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
@ -46,9 +46,8 @@ public class TestPrintMdo {
LingeredApp app = null;
try {
ClhsdbLauncher test = new ClhsdbLauncher();
List<String> vmArgs = new ArrayList<String>();
vmArgs.add("-XX:+ProfileInterpreter");
vmArgs.addAll(Utils.getVmOptions());
String[] vmArgs = Utils.appendTestJavaOpts(
"-XX:+ProfileInterpreter");
app = LingeredApp.startApp(vmArgs);
System.out.println ("Started LingeredApp with pid " + app.getPid());

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, 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
@ -82,12 +82,10 @@ public class TestRevPtrsForInvokeDynamic {
public static void main (String... args) throws Exception {
if (args == null || args.length == 0) {
try {
List<String> vmArgs = new ArrayList<String>();
vmArgs.add("-XX:+UsePerfData");
vmArgs.addAll(Utils.getVmOptions());
String[] vmArgs = Utils.appendTestJavaOpts("-XX:+UsePerfData");
theApp = new LingeredAppWithInvokeDynamic();
LingeredApp.startApp(vmArgs, theApp);
LingeredApp.startApp(theApp, vmArgs);
createAnotherToAttach(theApp.getPid());
} finally {
LingeredApp.stopApp(theApp);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, 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
@ -47,9 +47,8 @@ public class TestType {
LingeredApp app = null;
try {
ClhsdbLauncher test = new ClhsdbLauncher();
List<String> vmArgs = new ArrayList<String>(Utils.getVmOptions());
app = LingeredApp.startApp(vmArgs);
app = LingeredApp.startApp();
System.out.println ("Started LingeredApp with pid " + app.getPid());
List<String> cmds = List.of("type", "type InstanceKlass");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, 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
@ -93,7 +93,7 @@ public class TestUniverse {
private static void test(GC gc) throws Exception {
LingeredApp app = null;
try {
app = LingeredApp.startApp(List.of("-XX:+UnlockExperimentalVMOptions", "-XX:+Use" + gc + "GC"));
app = LingeredApp.startApp("-XX:+UnlockExperimentalVMOptions", "-XX:+Use" + gc + "GC");
System.out.println ("Started LingeredApp with " + gc + "GC and pid " + app.getPid());
testClhsdbForUniverse(app.getPid(), gc);
} finally {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2020, 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
@ -89,7 +89,7 @@ public class TestDriver {
List<String> cmd = new ArrayList<>();
Class<?> debuggeeClass = attach004t.class;
cmd.add(JDKToolFinder.getJDKTool("java"));
Collections.addAll(cmd, Utils.addTestJavaOpts(
Collections.addAll(cmd, Utils.prependTestJavaOpts(
"-cp",
Utils.TEST_CLASS_PATH,
"-Xdebug",
@ -119,7 +119,7 @@ public class TestDriver {
List<String> cmd = new ArrayList<>();
Class<?> debuggerClass = attach004.class;
cmd.add(JDKToolFinder.getJDKTool("java"));
Collections.addAll(cmd, Utils.addTestJavaOpts(
Collections.addAll(cmd, Utils.prependTestJavaOpts(
"-cp",
Utils.TEST_CLASS_PATH,
debuggerClass.getName(),

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2020, 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
@ -69,14 +69,11 @@ public class JdwpAllowTest {
return res;
}
public static ArrayList<String> prepareCmd(String allowOpt) {
ArrayList<String> cmd = new ArrayList<>();
public static String[] prepareCmd(String allowOpt) {
String jdwpArgs = "-agentlib:jdwp=transport=dt_socket,server=y," +
"suspend=n,address=*:0"
+ (allowOpt == null ? "" : ",allow=" + allowOpt);
cmd.add(jdwpArgs);
return cmd;
return new String[] { jdwpArgs };
}
private static Pattern listenRegexp = Pattern.compile("Listening for transport \\b(.+)\\b at address: \\b(\\d+)\\b");
@ -106,7 +103,7 @@ public class JdwpAllowTest {
public static void positiveTest(String testName, String allowOpt)
throws InterruptedException, IOException {
System.err.println("\nStarting " + testName);
ArrayList<String> cmd = prepareCmd(allowOpt);
String[] cmd = prepareCmd(allowOpt);
LingeredApp a = LingeredApp.startApp(cmd);
int res;
@ -124,7 +121,7 @@ public class JdwpAllowTest {
public static void negativeTest(String testName, String allowOpt)
throws InterruptedException, IOException {
System.err.println("\nStarting " + testName);
ArrayList<String> cmd = prepareCmd(allowOpt);
String[] cmd = prepareCmd(allowOpt);
LingeredApp a = LingeredApp.startApp(cmd);
int res;
@ -144,7 +141,7 @@ public class JdwpAllowTest {
public static void badAllowOptionTest(String testName, String allowOpt)
throws InterruptedException, IOException {
System.err.println("\nStarting " + testName);
ArrayList<String> cmd = prepareCmd(allowOpt);
String[] cmd = prepareCmd(allowOpt);
LingeredApp a;
try {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2020, 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
@ -127,11 +127,11 @@ public class JdwpAttachTest {
try {
LingeredApp debuggee = LingeredApp.startApp(
Arrays.asList("-agentlib:jdwp=transport=dt_socket"
"-agentlib:jdwp=transport=dt_socket"
+ ",address=" + connectAddress + ":" + port
+ ",server=n,suspend=n"
// if failure is expected set small timeout (default is 20 sec)
+ (!expectedResult ? ",timeout=1000" : "")));
+ (!expectedResult ? ",timeout=1000" : ""));
debuggee.stopApp();
if (expectedResult) {
log("OK: attached as expected");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 2020, 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
@ -54,9 +54,7 @@ public class TestPollingInterval {
MonitorException, URISyntaxException {
LingeredApp app = null;
try {
List<String> vmArgs = new ArrayList<String>();
vmArgs.add("-XX:+UsePerfData");
vmArgs.addAll(Utils.getVmOptions());
String[] vmArgs = Utils.appendTestJavaOpts("-XX:+UsePerfData");
app = LingeredApp.startApp(vmArgs);
MonitoredHost localHost = MonitoredHost.getMonitoredHost("localhost");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2020, 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
@ -35,6 +35,7 @@ import java.nio.file.Path;
import java.nio.file.attribute.PosixFilePermission;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@ -164,7 +165,7 @@ public abstract class AbstractFilePermissionTest {
final String pp = "-Dcom.sun.management.jmxremote.port=" + jdk.test.lib.Utils.getFreePort();
List<String> command = new ArrayList<>();
command.addAll(jdk.test.lib.Utils.getVmOptions());
Collections.addAll(command, jdk.test.lib.Utils.getTestJavaOpts());
command.add(mp);
command.add(pp);
command.add("-cp");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2020, 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
@ -24,6 +24,7 @@
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicReference;
@ -98,7 +99,7 @@ public class LocalManagementTest {
private static boolean doTest(String testId, String arg) throws Exception {
List<String> args = new ArrayList<>();
args.add("-XX:+UsePerfData");
args.addAll(Utils.getVmOptions());
Collections.addAll(args, Utils.getTestJavaOpts());
args.add("-cp");
args.add(TEST_CLASSPATH);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2020, 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
@ -180,7 +180,7 @@ public class RmiRegistrySslTest {
initTestEnvironment();
List<String> command = new ArrayList<>();
command.addAll(Utils.getVmOptions());
Collections.addAll(command, Utils.getTestJavaOpts());
command.add("-Dtest.src=" + TEST_SRC);
command.add("-Dtest.rmi.port=" + port);
command.addAll(Arrays.asList(args));

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2020, 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
@ -131,7 +131,7 @@ public class BasicLauncherTest {
System.out.println("Starting LingeredApp");
try {
theApp = LingeredApp.startApp(Arrays.asList("-Xmx256m"));
theApp = LingeredApp.startApp("-Xmx256m");
System.out.println("Starting jstack against " + theApp.getPid());
JDKToolLauncher launcher = createSALauncher();
@ -164,7 +164,7 @@ public class BasicLauncherTest {
System.out.println("Starting LingeredApp");
try {
theApp = LingeredApp.startApp(Arrays.asList("-Xmx256m"));
theApp = LingeredApp.startApp("-Xmx256m");
System.out.println("Starting " + toolArgs.get(0) + " against " + theApp.getPid());
JDKToolLauncher launcher = createSALauncher();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2020, 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
@ -60,7 +60,7 @@ public class HeapDumpTest {
System.out.println("Starting LingeredApp");
try {
theApp = new LingeredAppWithExtendedChars();
LingeredApp.startApp(Arrays.asList("-Xmx256m"), theApp);
LingeredApp.startApp(theApp, "-Xmx256m");
System.out.println(theApp.\u00CB);
System.out.println("Starting " + toolArgs.get(0) + " against " + theApp.getPid());

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2020, 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
@ -24,6 +24,7 @@
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -52,7 +53,6 @@ public class JMapHeapConfigTest {
"MaxHeapFreeRatio",
"MaxHeapSize",
"NewSize",
"MaxNewSize",
"OldSize",
"NewRatio",
"SurvivorRatio",
@ -60,7 +60,9 @@ public class JMapHeapConfigTest {
"CompressedClassSpaceSize",
"G1HeapRegionSize"};
// ignoring MaxMetaspaceSize
// Test can't deal with negative jlongs:
// ignoring MaxMetaspaceSize
// ignoring MaxNewSize
static final String desiredMaxHeapSize = "-Xmx128m";
@ -126,7 +128,7 @@ public class JMapHeapConfigTest {
}
boolean mx_found = false;
List<String> jvmOptions = Utils.getVmOptions();
String[] jvmOptions = Utils.getTestJavaOpts();
for (String option : jvmOptions) {
if (option.startsWith("-Xmx")) {
System.out.println("INFO: maximum heap size set by JTREG as " + option);
@ -137,7 +139,7 @@ public class JMapHeapConfigTest {
// Forward vm options to LingeredApp
ArrayList<String> cmd = new ArrayList();
cmd.addAll(Utils.getVmOptions());
Collections.addAll(cmd, Utils.getTestJavaOpts());
if (!mx_found) {
cmd.add(desiredMaxHeapSize);
System.out.println("INFO: maximum heap size set explicitly as " + desiredMaxHeapSize);
@ -145,7 +147,7 @@ public class JMapHeapConfigTest {
cmd.add("-XX:+PrintFlagsFinal");
TmtoolTestScenario tmt = TmtoolTestScenario.create("jmap", "--heap");
int exitcode = tmt.launch(cmd);
int exitcode = tmt.launch(cmd.toArray(new String[0]));
if (exitcode != 0) {
throw new RuntimeException("Test FAILED jmap exits with non zero exit code " + exitcode);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2020, 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
@ -26,6 +26,7 @@ import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -90,14 +91,14 @@ public class TmtoolTestScenario {
* @param vmArgs - vm and java arguments to launch test app
* @return exit code of tool
*/
public int launch(List<String> vmArgs) {
public int launch(String... vmArgs) {
System.out.println("Starting LingeredApp");
try {
try {
List<String> vmArgsExtended = new ArrayList<String>();
vmArgsExtended.add("-XX:+UsePerfData");
vmArgsExtended.addAll(vmArgs);
theApp = LingeredApp.startApp(vmArgsExtended);
Collections.addAll(vmArgsExtended, vmArgs);
theApp = LingeredApp.startApp(vmArgsExtended.toArray(new String[0]));
System.out.println("Starting " + toolName + " against " + theApp.getPid());
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb");
@ -132,10 +133,6 @@ public class TmtoolTestScenario {
}
}
public void launch(String... appArgs) throws IOException {
launch(Arrays.asList(appArgs));
}
private TmtoolTestScenario(String toolName, String[] toolArgs) {
this.toolName = toolName;
this.toolArgs = toolArgs;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2020, 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
@ -59,9 +59,9 @@ public class JInfoTest {
LingeredApp app1 = new JInfoTestLingeredApp();
LingeredApp app2 = new JInfoTestLingeredApp();
try {
ArrayList<String> params = new ArrayList<String>();
LingeredApp.startApp(params, app1);
LingeredApp.startApp(params, app2);
String[] params = new String[0];;
LingeredApp.startApp(app1, params);
LingeredApp.startApp(app2, params);
OutputAnalyzer output = jinfo("-flag", "MinHeapFreeRatio=1", "JInfoTestLingeredApp");
output.shouldHaveExitValue(0);
output = jinfo("-flag", "MinHeapFreeRatio", "JInfoTestLingeredApp");
@ -84,9 +84,9 @@ public class JInfoTest {
LingeredApp app1 = new JInfoTestLingeredApp();
LingeredApp app2 = new JInfoTestLingeredApp();
try {
ArrayList<String> params = new ArrayList<String>();
LingeredApp.startApp(params, app1);
LingeredApp.startApp(params, app2);
String[] params = new String[0];
LingeredApp.startApp(app1, params);
LingeredApp.startApp(app2, params);
OutputAnalyzer output = jinfo("JInfoTestLingeredApp");
output.shouldHaveExitValue(0);
// "Runtime Environment" written once per proc
@ -122,4 +122,3 @@ public class JInfoTest {
// Sometime there is LingeredApp's from other test still around
class JInfoTestLingeredApp extends LingeredApp {
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2020, 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
@ -93,21 +93,20 @@ public final class JpsHelper {
}
/**
* VM arguments to start test application with.
* -XX:+UsePerfData is required for running the tests on embedded platforms.
*/
public static final String[] VM_ARGS = {
"-XX:+UsePerfData", "-Xmx512m", "-Xlog:gc",
"-Dmultiline.prop=value1\nvalue2\r\nvalue3"
};
/**
* VM flag to start test application with
*/
public static final String VM_FLAG = "+DisableExplicitGC";
private static File vmFlagsFile = null;
private static List<String> testVmArgs = null;
/**
* VM arguments to start test application with.
* -XX:+UsePerfData is required for running the tests on embedded platforms.
*/
private static String[] testVmArgs = {
"-XX:+UsePerfData", "-Xmx512m", "-Xlog:gc",
"-Dmultiline.prop=value1\nvalue2\r\nvalue3",
null /* lazily initialized -XX:Flags */};
private static File manifestFile = null;
/**
@ -127,11 +126,9 @@ public final class JpsHelper {
/**
* Return a list of VM arguments
*/
public static List<String> getVmArgs() throws IOException {
if (testVmArgs == null) {
testVmArgs = new ArrayList<>();
testVmArgs.addAll(Arrays.asList(VM_ARGS));
testVmArgs.add("-XX:Flags=" + getVmFlagsFile().getAbsolutePath());
public static String[] getVmArgs() throws IOException {
if (testVmArgs[testVmArgs.length - 1] == null) {
testVmArgs[testVmArgs.length - 1] = "-XX:Flags=" + getVmFlagsFile().getAbsolutePath();
}
return testVmArgs;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2020, 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
@ -32,10 +32,12 @@ import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import jdk.test.lib.Utils;
/**
* This is a framework to launch an app that could be synchronized with caller
@ -257,7 +259,7 @@ public class LingeredApp {
* Analyze an environment and prepare a command line to
* run the app, app name should be added explicitly
*/
public List<String> runAppPrepare(List<String> vmArguments) {
public List<String> runAppPrepare(String[] vmArguments) {
// We should always use testjava or throw an exception,
// so we can't use JDKToolFinder.getJDKTool("java");
// that falls back to compile java on error
@ -278,20 +280,13 @@ public class LingeredApp {
List<String> cmd = new ArrayList<String>();
cmd.add(javapath);
if (vmArguments == null) {
// Propagate test.vm.options to LingeredApp, filter out possible empty options
String testVmOpts[] = System.getProperty("test.vm.opts","").split("\\s+");
for (String s : testVmOpts) {
if (!s.equals("")) {
cmd.add(s);
}
}
}
else{
// Propagate getTestJavaOpts() to LingeredApp
vmArguments = Utils.getTestJavaOpts();
} else {
// Lets user manage LingeredApp options
cmd.addAll(vmArguments);
}
Collections.addAll(cmd, vmArguments);
// Make sure we set correct classpath to run the app
cmd.add("-cp");
@ -326,7 +321,7 @@ public class LingeredApp {
* @param vmArguments
* @throws IOException
*/
public void runApp(List<String> vmArguments)
public void runApp(String[] vmArguments)
throws IOException {
List<String> cmd = runAppPrepare(vmArguments);
@ -367,37 +362,14 @@ public class LingeredApp {
/**
* High level interface for test writers
*/
/**
* Factory method that creates LingeredApp object with ready to use application
* lock name is autogenerated
* @param cmd - vm options, could be null to auto add testvm.options
* @return LingeredApp object
* @throws IOException
*/
public static LingeredApp startApp(List<String> cmd) throws IOException {
LingeredApp a = new LingeredApp();
a.createLock();
try {
a.runApp(cmd);
a.waitAppReady(appWaitTime);
} catch (Exception ex) {
a.deleteLock();
throw ex;
}
return a;
}
/**
* Factory method that starts pre-created LingeredApp
* lock name is autogenerated
* @param cmd - vm options, could be null to auto add testvm.options
* @param cmd - vm options, could be null to auto add Utils.getTestJavaOpts()
* @param theApp - app to start
* @return LingeredApp object
* @throws IOException
*/
public static void startApp(List<String> cmd, LingeredApp theApp) throws IOException {
public static void startApp(LingeredApp theApp, String... cmd) throws IOException {
theApp.createLock();
try {
theApp.runApp(cmd);
@ -408,8 +380,17 @@ public class LingeredApp {
}
}
public static LingeredApp startApp() throws IOException {
return startApp(null);
/**
* Factory method that creates LingeredApp object with ready to use application
* lock name is autogenerated
* @param cmd - vm options, could be null to auto add Utils.getTestJavaOpts()
* @return LingeredApp object
* @throws IOException
*/
public static LingeredApp startApp(String... cmd) throws IOException {
LingeredApp a = new LingeredApp();
startApp(a, cmd);
return a;
}
public static void stopApp(LingeredApp app) throws IOException {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2020, 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
@ -32,7 +32,7 @@ import java.net.URL;
public class LingeredAppForJps extends LingeredApp {
// Copy runApp logic here to be able to run an app from JarFile
public void runAppWithName(List<String> vmArguments, String runName)
public void runAppWithName(String[] vmArguments, String runName)
throws IOException {
List<String> cmd = runAppPrepare(vmArguments);
@ -52,7 +52,7 @@ public class LingeredAppForJps extends LingeredApp {
startGobblerPipe();
}
public static LingeredApp startAppJar(List<String> cmd, LingeredAppForJps app, File jar) throws IOException {
public static LingeredApp startAppJar(LingeredAppForJps app, String[] cmd, File jar) throws IOException {
app.createLock();
try {
app.runAppWithName(cmd, jar.getAbsolutePath());

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2020, 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
@ -48,7 +48,7 @@ public class TestJps {
public static void testJpsClass() throws Throwable {
LingeredApp app = new LingeredAppForJps();
try {
LingeredApp.startApp(JpsHelper.getVmArgs(), app);
LingeredApp.startApp(app, JpsHelper.getVmArgs());
JpsHelper.runJpsVariants(app.getPid(),
LingeredAppForJps.getProcessName(), LingeredAppForJps.getFullProcessName(), app.getLockFileName());
@ -64,7 +64,7 @@ public class TestJps {
// Jar created go to the main test
LingeredAppForJps app = new LingeredAppForJps();
try {
LingeredAppForJps.startAppJar(JpsHelper.getVmArgs(), app, jar);
LingeredAppForJps.startAppJar(app, JpsHelper.getVmArgs(), jar);
JpsHelper.runJpsVariants(app.getPid(),
LingeredAppForJps.getProcessName(jar), LingeredAppForJps.getFullProcessName(jar), app.getLockFileName());
} finally {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2020, 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
@ -75,12 +75,10 @@ public class DeadlockDetectionTest {
}
try {
List<String> vmArgs = new ArrayList<String>();
vmArgs.add("-XX:+UsePerfData");
vmArgs.addAll(Utils.getVmOptions());
String[] vmArgs = Utils.appendTestJavaOpts("-XX:+UsePerfData");
theApp = new LingeredAppWithDeadlock();
LingeredApp.startApp(vmArgs, theApp);
LingeredApp.startApp(theApp, vmArgs);
OutputAnalyzer output = jstack(Long.toString(theApp.getPid()));
System.out.println(output.getOutput());

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2020, 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
@ -52,7 +52,7 @@ public class LingeredAppTest {
cmd.add("-XX:+PrintFlagsFinal");
LingeredApp a = LingeredApp.startApp(cmd);
LingeredApp a = LingeredApp.startApp(cmd.toArray(new String[cmd.length]);
System.out.printf("App pid: %d\n", a.getPid());
a.stopApp();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2020, 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
@ -144,15 +144,6 @@ public final class Utils {
// Private constructor to prevent class instantiation
}
/**
* Returns the list of VM options.
*
* @return List of VM options
*/
public static List<String> getVmOptions() {
return Arrays.asList(safeSplitString(VM_OPTIONS));
}
/**
* Returns the list of VM options with -J prefix.
*
@ -183,13 +174,34 @@ public final class Utils {
* This is the combination of JTReg arguments test.vm.opts and test.java.opts
* @return The combination of JTReg test java options and user args.
*/
public static String[] addTestJavaOpts(String... userArgs) {
public static String[] prependTestJavaOpts(String... userArgs) {
List<String> opts = new ArrayList<String>();
Collections.addAll(opts, getTestJavaOpts());
Collections.addAll(opts, userArgs);
return opts.toArray(new String[0]);
}
/**
* Combines given arguments with default JTReg arguments for a jvm running a test.
* This is the combination of JTReg arguments test.vm.opts and test.java.opts
* @return The combination of JTReg test java options and user args.
*/
public static String[] appendTestJavaOpts(String... userArgs) {
List<String> opts = new ArrayList<String>();
Collections.addAll(opts, userArgs);
Collections.addAll(opts, getTestJavaOpts());
return opts.toArray(new String[0]);
}
/**
* Combines given arguments with default JTReg arguments for a jvm running a test.
* This is the combination of JTReg arguments test.vm.opts and test.java.opts
* @return The combination of JTReg test java options and user args.
*/
public static String[] addTestJavaOpts(String... userArgs) {
return prependTestJavaOpts(userArgs);
}
/**
* Removes any options specifying which GC to use, for example "-XX:+UseG1GC".
* Removes any options matching: -XX:(+/-)Use*GC

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2020, 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
@ -34,11 +34,13 @@ import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.UUID;
import jdk.test.lib.Utils;
import jdk.test.lib.process.OutputBuffer;
import jdk.test.lib.process.StreamPumper;
@ -281,7 +283,7 @@ public class LingeredApp {
* Analyze an environment and prepare a command line to
* run the app, app name should be added explicitly
*/
public List<String> runAppPrepare(List<String> vmArguments) {
public List<String> runAppPrepare(String[] vmArguments) {
// We should always use testjava or throw an exception,
// so we can't use JDKToolFinder.getJDKTool("java");
// that falls back to compile java on error
@ -303,17 +305,12 @@ public class LingeredApp {
cmd.add(javapath);
if (vmArguments == null) {
// Propagate test.vm.options to LingeredApp, filter out possible empty options
String testVmOpts[] = System.getProperty("test.vm.opts","").split("\\s+");
for (String s : testVmOpts) {
if (!s.equals("")) {
cmd.add(s);
}
}
// Propagate getTestJavaOpts() to LingeredApp
vmArguments = Utils.getTestJavaOpts();
} else {
// Lets user manage LingeredApp options
cmd.addAll(vmArguments);
}
Collections.addAll(cmd, vmArguments);
// Make sure we set correct classpath to run the app
cmd.add("-cp");
@ -342,7 +339,7 @@ public class LingeredApp {
* @param vmArguments
* @throws IOException
*/
public void runApp(List<String> vmArguments)
public void runApp(String[] vmArguments)
throws IOException {
List<String> cmd = runAppPrepare(vmArguments);
@ -391,39 +388,14 @@ public class LingeredApp {
/**
* High level interface for test writers
*/
/**
* Factory method that creates LingeredApp object with ready to use application
* lock name is autogenerated
* @param cmd - vm options, could be null to auto add testvm.options
* @return LingeredApp object
* @throws IOException
*/
public static LingeredApp startApp(List<String> cmd) throws IOException {
LingeredApp a = new LingeredApp();
a.createLock();
try {
a.runApp(cmd);
a.waitAppReady(appWaitTime);
} catch (Exception ex) {
a.deleteLock();
System.err.println("LingeredApp failed to start: " + ex);
a.finishApp();
throw ex;
}
return a;
}
/**
* Factory method that starts pre-created LingeredApp
* lock name is autogenerated
* @param cmd - vm options, could be null to auto add testvm.options
* @param cmd - vm options, could be null to auto add Utils.getTestJavaOpts()
* @param theApp - app to start
* @return LingeredApp object
* @throws IOException
*/
public static void startApp(List<String> cmd, LingeredApp theApp) throws IOException {
public static void startApp(LingeredApp theApp, String... cmd) throws IOException {
theApp.createLock();
try {
theApp.runApp(cmd);
@ -434,8 +406,24 @@ public class LingeredApp {
}
}
public static LingeredApp startApp() throws IOException {
return startApp(null);
/**
* Factory method that creates LingeredApp object with ready to use application
* lock name is autogenerated
* @param cmd - vm options, could be null to auto add Utils.getTestJavaOpts()
* @return LingeredApp object
* @throws IOException
*/
public static LingeredApp startApp(String... cmd) throws IOException {
LingeredApp a = new LingeredApp();
try {
startApp(a, cmd);
} catch (Exception ex) {
System.err.println("LingeredApp failed to start: " + ex);
a.finishApp();
throw ex;
}
return a;
}
public static void stopApp(LingeredApp app) throws IOException {