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. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # 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/ClhsdbInspect.java 8220624 generic-all
serviceability/sa/ClhsdbJdis.java 8220624 generic-all serviceability/sa/ClhsdbJdis.java 8220624 generic-all
serviceability/sa/ClhsdbJhisto.java 8220624 generic-all serviceability/sa/ClhsdbJhisto.java 8220624 generic-all
serviceability/sa/ClhsdbJstack.java 8220624 generic-all serviceability/sa/ClhsdbJstack.java 8220624 generic-all
serviceability/sa/ClhsdbPrintAs.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/ClhsdbPstack.java 8220624 generic-all
serviceability/sa/ClhsdbSource.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/TestClhsdbJstackLock.java 8220624 generic-all
serviceability/sa/TestHeapDumpForInvokeDynamic.java 8220624 generic-all serviceability/sa/TestHeapDumpForInvokeDynamic.java 8220624 generic-all
serviceability/sa/TestHeapDumpForLargeArray.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/TestJmapCore.java 8220624 generic-all
serviceability/sa/TestJmapCoreMetaspace.java 8219443 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -45,13 +45,12 @@ public class ClhsdbRegionDetailsScanOopsForG1 {
LingeredAppWithLargeStringArray theApp = null; LingeredAppWithLargeStringArray theApp = null;
try { try {
ClhsdbLauncher test = new ClhsdbLauncher(); 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(); 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()); System.out.println("Started LingeredAppWithLargeStringArray with pid " + theApp.getPid());
List<String> cmds = List.of("g1regiondetails"); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 // Need to add the default arguments first to have explicit
// -Xmx8g last, otherwise test will fail if default // -Xmx8g last, otherwise test will fail if default
// arguments contain a smaller -Xmx. // arguments contain a smaller -Xmx.
List<String> vmArgs = new ArrayList<String>(); String[] vmArgs = Utils.prependTestJavaOpts(
vmArgs.addAll(Utils.getVmOptions()); "-XX:+UsePerfData",
vmArgs.add("-XX:+UsePerfData"); "-Xmx8g");
vmArgs.add("-Xmx8g");
theApp = new LingeredAppWithLargeArray(); theApp = new LingeredAppWithLargeArray();
LingeredApp.startApp(vmArgs, theApp); LingeredApp.startApp(theApp, vmArgs);
attachAndDump(heapDumpFileName, theApp.getPid()); attachAndDump(heapDumpFileName, theApp.getPid());
} finally { } finally {
LingeredApp.stopApp(theApp); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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); CDSOptions opts = (new CDSOptions()).setArchiveName(sharedArchiveName);
CDSTestUtils.createArchiveAndCheck(opts); CDSTestUtils.createArchiveAndCheck(opts);
List<String> vmArgs = Arrays.asList( theApp = LingeredApp.startApp(
"-XX:+UnlockDiagnosticVMOptions", "-XX:+UnlockDiagnosticVMOptions",
"-XX:SharedArchiveFile=" + sharedArchiveName, "-XX:SharedArchiveFile=" + sharedArchiveName,
"-Xshare:auto"); "-Xshare:auto");
theApp = LingeredApp.startApp(vmArgs);
System.out.println("Started LingeredApp with pid " + theApp.getPid()); System.out.println("Started LingeredApp with pid " + theApp.getPid());
runClstats(theApp.getPid()); runClstats(theApp.getPid());
} catch (Exception ex) { } 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -51,11 +51,10 @@ public class ClhsdbCDSJstackPrintAll {
CDSTestUtils.createArchiveAndCheck(opts); CDSTestUtils.createArchiveAndCheck(opts);
ClhsdbLauncher test = new ClhsdbLauncher(); ClhsdbLauncher test = new ClhsdbLauncher();
List<String> vmArgs = Arrays.asList( theApp = LingeredApp.startApp(
"-XX:+UnlockDiagnosticVMOptions", "-XX:+UnlockDiagnosticVMOptions",
"-XX:SharedArchiveFile=" + sharedArchiveName, "-XX:SharedArchiveFile=" + sharedArchiveName,
"-Xshare:auto"); "-Xshare:auto");
theApp = LingeredApp.startApp(vmArgs);
System.out.println("Started LingeredApp with pid " + theApp.getPid()); System.out.println("Started LingeredApp with pid " + theApp.getPid());
// Ensure that UseSharedSpaces is turned on. // 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -48,9 +48,9 @@ public class ClhsdbFindPC {
theApp = new LingeredAppWithTrivialMain(); theApp = new LingeredAppWithTrivialMain();
if (withXcomp) { if (withXcomp) {
LingeredApp.startApp(List.of("-Xcomp"), theApp); LingeredApp.startApp(theApp, "-Xcomp");
} else { } else {
LingeredApp.startApp(List.of("-Xint"), theApp); LingeredApp.startApp(theApp, "-Xint");
} }
System.out.print("Started LingeredApp "); System.out.print("Started LingeredApp ");
if (withXcomp) { if (withXcomp) {
@ -114,4 +114,3 @@ public class ClhsdbFindPC {
System.out.println("Test PASSED"); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -49,11 +49,10 @@ public class ClhsdbFlags {
LingeredApp theApp = null; LingeredApp theApp = null;
try { try {
ClhsdbLauncher test = new ClhsdbLauncher(); ClhsdbLauncher test = new ClhsdbLauncher();
List<String> vmArgs = new ArrayList<String>(); String[] vmArgs = Utils.appendTestJavaOpts(
vmArgs.add("-XX:+UnlockExperimentalVMOptions"); "-XX:+UnlockExperimentalVMOptions",
vmArgs.add("-XX:+UnlockDiagnosticVMOptions"); "-XX:+UnlockDiagnosticVMOptions",
vmArgs.add("-XX:-MaxFDLimit"); "-XX:-MaxFDLimit");
vmArgs.addAll(Utils.getVmOptions());
theApp = LingeredApp.startApp(vmArgs); theApp = LingeredApp.startApp(vmArgs);
System.out.println("Started LingeredApp with pid " + theApp.getPid()); System.out.println("Started LingeredApp with pid " + theApp.getPid());
@ -100,18 +99,18 @@ public class ClhsdbFlags {
LingeredApp theApp = null; LingeredApp theApp = null;
try { try {
ClhsdbLauncher test = new ClhsdbLauncher(); ClhsdbLauncher test = new ClhsdbLauncher();
List<String> vmArgs = new ArrayList<String>(); // *Prepend* options to prevent interference with flags below
vmArgs.add("-XX:+UnlockDiagnosticVMOptions"); // bool String[] vmArgs = Utils.prependTestJavaOpts(
vmArgs.add("-XX:ActiveProcessorCount=1"); // int "-XX:+UnlockDiagnosticVMOptions", // bool
vmArgs.add("-XX:ParallelGCThreads=1"); // uint "-XX:ActiveProcessorCount=1", // int
vmArgs.add("-XX:MaxJavaStackTraceDepth=1024"); // intx "-XX:ParallelGCThreads=1", // uint
vmArgs.add("-XX:LogEventsBufferEntries=10"); // uintx "-XX:MaxJavaStackTraceDepth=1024", // intx
vmArgs.add("-XX:HeapSizePerGCThread=32m"); // size_t "-XX:LogEventsBufferEntries=10", // uintx
vmArgs.add("-XX:NativeMemoryTracking=off"); // ccstr "-XX:HeapSizePerGCThread=32m", // size_t
vmArgs.add("-XX:OnError='echo error'"); // ccstrlist "-XX:NativeMemoryTracking=off", // ccstr
vmArgs.add("-XX:CompileThresholdScaling=1.0"); // double "-XX:OnError='echo error'", // ccstrlist
vmArgs.add("-XX:ErrorLogTimeout=120"); // uint64_t "-XX:CompileThresholdScaling=1.0", // double
vmArgs.addAll(Utils.getVmOptions()); "-XX:ErrorLogTimeout=120"); // uint64_t
theApp = LingeredApp.startApp(vmArgs); theApp = LingeredApp.startApp(vmArgs);
System.out.println("Started LingeredApp with pid " + theApp.getPid()); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -47,7 +47,7 @@ public class ClhsdbInspect {
ClhsdbLauncher test = new ClhsdbLauncher(); ClhsdbLauncher test = new ClhsdbLauncher();
theApp = new LingeredAppWithLock(); theApp = new LingeredAppWithLock();
LingeredApp.startApp(null, theApp); LingeredApp.startApp(theApp);
System.out.println("Started LingeredApp with pid " + theApp.getPid()); System.out.println("Started LingeredApp with pid " + theApp.getPid());
// Run the 'jstack -v' command to get the address of a Method*, // 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -47,11 +47,9 @@ public class ClhsdbJhisto {
LingeredAppWithInterface theApp = null; LingeredAppWithInterface theApp = null;
try { try {
ClhsdbLauncher test = new ClhsdbLauncher(); ClhsdbLauncher test = new ClhsdbLauncher();
List<String> vmArgs = new ArrayList<String>();
vmArgs.addAll(Utils.getVmOptions());
theApp = new LingeredAppWithInterface(); theApp = new LingeredAppWithInterface();
LingeredApp.startApp(vmArgs, theApp); LingeredApp.startApp(theApp);
System.out.println("Started LingeredApp with pid " + theApp.getPid()); System.out.println("Started LingeredApp with pid " + theApp.getPid());
List<String> cmds = List.of("jhisto"); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -43,7 +43,7 @@ public class ClhsdbJstack {
LingeredApp theApp = null; LingeredApp theApp = null;
try { try {
ClhsdbLauncher test = new ClhsdbLauncher(); ClhsdbLauncher test = new ClhsdbLauncher();
theApp = withXcomp ? LingeredApp.startApp(List.of("-Xcomp")) theApp = withXcomp ? LingeredApp.startApp("-Xcomp")
: LingeredApp.startApp(); : LingeredApp.startApp();
System.out.print("Started LingeredApp "); System.out.print("Started LingeredApp ");
if (withXcomp) { 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. * Copyright (c) 2019, Red Hat Inc. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * 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 { public static void main(String... args) throws Exception {
LingeredApp app = null; LingeredApp app = null;
try { 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(); 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()); System.out.println("Started LingeredAppWithRecComputation with pid " + app.getPid());
runJstackInLoop(app); runJstackInLoop(app);
System.out.println("Test Completed"); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -46,7 +46,7 @@ public class ClhsdbPrintAll {
ClhsdbLauncher test = new ClhsdbLauncher(); ClhsdbLauncher test = new ClhsdbLauncher();
theApp = new LingeredAppWithEnum(); theApp = new LingeredAppWithEnum();
LingeredApp.startApp(null, theApp); LingeredApp.startApp(theApp);
System.out.println("Started LingeredAppWithEnum with pid " + theApp.getPid()); System.out.println("Started LingeredAppWithEnum with pid " + theApp.getPid());
List<String> cmds = List.of("printall"); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -46,9 +46,7 @@ public class ClhsdbScanOops {
try { try {
ClhsdbLauncher test = new ClhsdbLauncher(); ClhsdbLauncher test = new ClhsdbLauncher();
List<String> vmArgs = new ArrayList<String>(); theApp = LingeredApp.startApp(gc);
vmArgs.add(gc);
theApp = LingeredApp.startApp(vmArgs);
System.out.println ("Started LingeredApp with the GC option " + gc + System.out.println ("Started LingeredApp with the GC option " + gc +
" and pid " + theApp.getPid()); " 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -78,12 +78,10 @@ public class DeadlockDetectionTest {
} }
try { try {
List<String> vmArgs = new ArrayList<String>(); String[] vmArgs = Utils.appendTestJavaOpts("-XX:+UsePerfData");
vmArgs.add("-XX:+UsePerfData");
vmArgs.addAll(Utils.getVmOptions());
theApp = new LingeredAppWithDeadlock(); theApp = new LingeredAppWithDeadlock();
LingeredApp.startApp(vmArgs, theApp); LingeredApp.startApp(theApp, vmArgs);
OutputAnalyzer output = jstack("--pid", Long.toString(theApp.getPid())); OutputAnalyzer output = jstack("--pid", Long.toString(theApp.getPid()));
System.out.println(output.getOutput()); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -45,7 +45,7 @@ public class JhsdbThreadInfoTest {
LingeredApp app = null; LingeredApp app = null;
try { try {
app = LingeredApp.startApp(Utils.getVmOptions()); app = LingeredApp.startApp();
System.out.println("Started LingeredApp with pid " + app.getPid()); System.out.println("Started LingeredApp with pid " + app.getPid());
JDKToolLauncher jhsdbLauncher = JDKToolLauncher.createUsingTestJDK("jhsdb"); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -43,10 +43,9 @@ public class TestClhsdbJstackLock {
LingeredAppWithLock app = null; LingeredAppWithLock app = null;
try { try {
ClhsdbLauncher test = new ClhsdbLauncher(); ClhsdbLauncher test = new ClhsdbLauncher();
List<String> vmArgs = new ArrayList<String>(Utils.getVmOptions());
app = new LingeredAppWithLock(); app = new LingeredAppWithLock();
LingeredApp.startApp(vmArgs, app); LingeredApp.startApp(app);
System.out.println ("Started LingeredAppWithLock with pid " + app.getPid()); System.out.println ("Started LingeredAppWithLock with pid " + app.getPid());
@ -73,4 +72,3 @@ public class TestClhsdbJstackLock {
System.out.println("Test PASSED"); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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) { if (args == null || args.length == 0) {
try { try {
List<String> vmArgs = new ArrayList<String>(); String[] vmArgs = Utils.appendTestJavaOpts(
vmArgs.add("-XX:+UsePerfData"); "-XX:+UsePerfData");
vmArgs.addAll(Utils.getVmOptions());
theApp = new LingeredAppWithInvokeDynamic(); theApp = new LingeredAppWithInvokeDynamic();
LingeredApp.startApp(vmArgs, theApp); LingeredApp.startApp(theApp, vmArgs);
createAnotherToAttach(instanceKlassNames, createAnotherToAttach(instanceKlassNames,
theApp.getPid()); theApp.getPid());
} finally { } 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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) { if (args == null || args.length == 0) {
try { try {
List<String> vmArgs = new ArrayList<String>(); String[] vmArgs = Utils.appendTestJavaOpts("-XX:+UsePerfData");
vmArgs.add("-XX:+UsePerfData");
vmArgs.addAll(Utils.getVmOptions());
theApp = new LingeredAppWithDefaultMethods(); theApp = new LingeredAppWithDefaultMethods();
LingeredApp.startApp(vmArgs, theApp); LingeredApp.startApp(theApp, vmArgs);
createAnotherToAttach(instanceKlassNames, createAnotherToAttach(instanceKlassNames,
theApp.getPid()); theApp.getPid());
} finally { } 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 { public static void main (String... args) throws Exception {
if (args == null || args.length == 0) { if (args == null || args.length == 0) {
try { try {
List<String> vmArgs = new ArrayList<String>(); String[] vmArgs = Utils.appendTestJavaOpts(
vmArgs.add("-XX:+UsePerfData"); "-XX:+UsePerfData",
vmArgs.add("-XX:+UseG1GC"); "-XX:+UseG1GC");
vmArgs.addAll(Utils.getVmOptions());
theApp = new LingeredApp(); theApp = new LingeredApp();
LingeredApp.startApp(vmArgs, theApp); LingeredApp.startApp(theApp, vmArgs);
createAnotherToAttach(theApp.getPid()); createAnotherToAttach(theApp.getPid());
} finally { } finally {
LingeredApp.stopApp(theApp); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -121,13 +121,12 @@ public class TestHeapDumpForInvokeDynamic {
} }
try { try {
List<String> vmArgs = new ArrayList<String>(); String[] vmArgs = Utils.appendTestJavaOpts(
vmArgs.add("-XX:+UsePerfData"); "-XX:+UsePerfData",
vmArgs.add("-Xmx512m"); "-Xmx512m");
vmArgs.addAll(Utils.getVmOptions());
theApp = new LingeredAppWithInvokeDynamic(); theApp = new LingeredAppWithInvokeDynamic();
LingeredApp.startApp(vmArgs, theApp); LingeredApp.startApp(theApp, vmArgs);
attachDumpAndVerify(heapDumpFileName, theApp.getPid()); attachDumpAndVerify(heapDumpFileName, theApp.getPid());
} finally { } finally {
LingeredApp.stopApp(theApp); LingeredApp.stopApp(theApp);

View File

@ -73,9 +73,7 @@ public class TestInstanceKlassSize {
LingeredApp app = null; LingeredApp app = null;
OutputAnalyzer output = null; OutputAnalyzer output = null;
try { try {
List<String> vmArgs = new ArrayList<String>(); String[] vmArgs = Utils.appendTestJavaOpts("-XX:+UsePerfData");
vmArgs.add("-XX:+UsePerfData");
vmArgs.addAll(Arrays.asList(Utils.getTestJavaOpts()));
app = LingeredApp.startApp(vmArgs); app = LingeredApp.startApp(vmArgs);
System.out.println ("Started LingeredApp with pid " + app.getPid()); System.out.println ("Started LingeredApp with pid " + app.getPid());
} catch (Exception ex) { } 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) { if (args == null || args.length == 0) {
try { try {
List<String> vmArgs = Arrays.asList(Utils.getTestJavaOpts());
theApp = new LingeredAppWithInterface(); theApp = new LingeredAppWithInterface();
LingeredApp.startApp(vmArgs, theApp); LingeredApp.startApp(theApp);
createAnotherToAttach(instanceKlassNames, createAnotherToAttach(instanceKlassNames,
(int)theApp.getPid()); (int)theApp.getPid());
} finally { } 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -46,9 +46,8 @@ public class TestIntConstant {
LingeredApp app = null; LingeredApp app = null;
try { try {
ClhsdbLauncher test = new ClhsdbLauncher(); 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()); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -51,10 +51,8 @@ public class TestJhsdbJstackLock {
LingeredApp app = null; LingeredApp app = null;
try { try {
List<String> vmArgs = new ArrayList<String>(Utils.getVmOptions());
app = new LingeredAppWithLock(); app = new LingeredAppWithLock();
LingeredApp.startApp(vmArgs, app); LingeredApp.startApp(app);
System.out.println ("Started LingeredApp with pid " + app.getPid()); System.out.println ("Started LingeredApp with pid " + app.getPid());
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb"); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -165,15 +165,14 @@ public class TestJhsdbJstackMixed {
LingeredApp app = null; LingeredApp app = null;
try { try {
List<String> vmArgs = new ArrayList<String>(Utils.getVmOptions());
// Needed for LingeredApp to be able to resolve native library. // Needed for LingeredApp to be able to resolve native library.
String libPath = System.getProperty("java.library.path"); String libPath = System.getProperty("java.library.path");
if (libPath != null) { String[] vmArgs = (libPath != null)
vmArgs.add("-Djava.library.path=" + libPath); ? Utils.prependTestJavaOpts("-Djava.library.path=" + libPath)
} : Utils.getTestJavaOpts();
app = new LingeredAppWithNativeMethod(); app = new LingeredAppWithNativeMethod();
LingeredApp.startApp(vmArgs, app); LingeredApp.startApp(app, vmArgs);
System.out.println("Started LingeredApp with pid " + app.getPid()); System.out.println("Started LingeredApp with pid " + app.getPid());
runJstackMixedInLoop(app); runJstackMixedInLoop(app);
System.out.println("Test Completed"); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -46,9 +46,8 @@ public class TestPrintMdo {
LingeredApp app = null; LingeredApp app = null;
try { try {
ClhsdbLauncher test = new ClhsdbLauncher(); ClhsdbLauncher test = new ClhsdbLauncher();
List<String> vmArgs = new ArrayList<String>(); String[] vmArgs = Utils.appendTestJavaOpts(
vmArgs.add("-XX:+ProfileInterpreter"); "-XX:+ProfileInterpreter");
vmArgs.addAll(Utils.getVmOptions());
app = LingeredApp.startApp(vmArgs); app = LingeredApp.startApp(vmArgs);
System.out.println ("Started LingeredApp with pid " + app.getPid()); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 { public static void main (String... args) throws Exception {
if (args == null || args.length == 0) { if (args == null || args.length == 0) {
try { try {
List<String> vmArgs = new ArrayList<String>(); String[] vmArgs = Utils.appendTestJavaOpts("-XX:+UsePerfData");
vmArgs.add("-XX:+UsePerfData");
vmArgs.addAll(Utils.getVmOptions());
theApp = new LingeredAppWithInvokeDynamic(); theApp = new LingeredAppWithInvokeDynamic();
LingeredApp.startApp(vmArgs, theApp); LingeredApp.startApp(theApp, vmArgs);
createAnotherToAttach(theApp.getPid()); createAnotherToAttach(theApp.getPid());
} finally { } finally {
LingeredApp.stopApp(theApp); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -47,9 +47,8 @@ public class TestType {
LingeredApp app = null; LingeredApp app = null;
try { try {
ClhsdbLauncher test = new ClhsdbLauncher(); 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()); System.out.println ("Started LingeredApp with pid " + app.getPid());
List<String> cmds = List.of("type", "type InstanceKlass"); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 { private static void test(GC gc) throws Exception {
LingeredApp app = null; LingeredApp app = null;
try { 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()); System.out.println ("Started LingeredApp with " + gc + "GC and pid " + app.getPid());
testClhsdbForUniverse(app.getPid(), gc); testClhsdbForUniverse(app.getPid(), gc);
} finally { } 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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<>(); List<String> cmd = new ArrayList<>();
Class<?> debuggeeClass = attach004t.class; Class<?> debuggeeClass = attach004t.class;
cmd.add(JDKToolFinder.getJDKTool("java")); cmd.add(JDKToolFinder.getJDKTool("java"));
Collections.addAll(cmd, Utils.addTestJavaOpts( Collections.addAll(cmd, Utils.prependTestJavaOpts(
"-cp", "-cp",
Utils.TEST_CLASS_PATH, Utils.TEST_CLASS_PATH,
"-Xdebug", "-Xdebug",
@ -119,7 +119,7 @@ public class TestDriver {
List<String> cmd = new ArrayList<>(); List<String> cmd = new ArrayList<>();
Class<?> debuggerClass = attach004.class; Class<?> debuggerClass = attach004.class;
cmd.add(JDKToolFinder.getJDKTool("java")); cmd.add(JDKToolFinder.getJDKTool("java"));
Collections.addAll(cmd, Utils.addTestJavaOpts( Collections.addAll(cmd, Utils.prependTestJavaOpts(
"-cp", "-cp",
Utils.TEST_CLASS_PATH, Utils.TEST_CLASS_PATH,
debuggerClass.getName(), 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -69,14 +69,11 @@ public class JdwpAllowTest {
return res; return res;
} }
public static ArrayList<String> prepareCmd(String allowOpt) { public static String[] prepareCmd(String allowOpt) {
ArrayList<String> cmd = new ArrayList<>();
String jdwpArgs = "-agentlib:jdwp=transport=dt_socket,server=y," + String jdwpArgs = "-agentlib:jdwp=transport=dt_socket,server=y," +
"suspend=n,address=*:0" "suspend=n,address=*:0"
+ (allowOpt == null ? "" : ",allow=" + allowOpt); + (allowOpt == null ? "" : ",allow=" + allowOpt);
cmd.add(jdwpArgs); return new String[] { jdwpArgs };
return cmd;
} }
private static Pattern listenRegexp = Pattern.compile("Listening for transport \\b(.+)\\b at address: \\b(\\d+)\\b"); 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) public static void positiveTest(String testName, String allowOpt)
throws InterruptedException, IOException { throws InterruptedException, IOException {
System.err.println("\nStarting " + testName); System.err.println("\nStarting " + testName);
ArrayList<String> cmd = prepareCmd(allowOpt); String[] cmd = prepareCmd(allowOpt);
LingeredApp a = LingeredApp.startApp(cmd); LingeredApp a = LingeredApp.startApp(cmd);
int res; int res;
@ -124,7 +121,7 @@ public class JdwpAllowTest {
public static void negativeTest(String testName, String allowOpt) public static void negativeTest(String testName, String allowOpt)
throws InterruptedException, IOException { throws InterruptedException, IOException {
System.err.println("\nStarting " + testName); System.err.println("\nStarting " + testName);
ArrayList<String> cmd = prepareCmd(allowOpt); String[] cmd = prepareCmd(allowOpt);
LingeredApp a = LingeredApp.startApp(cmd); LingeredApp a = LingeredApp.startApp(cmd);
int res; int res;
@ -144,7 +141,7 @@ public class JdwpAllowTest {
public static void badAllowOptionTest(String testName, String allowOpt) public static void badAllowOptionTest(String testName, String allowOpt)
throws InterruptedException, IOException { throws InterruptedException, IOException {
System.err.println("\nStarting " + testName); System.err.println("\nStarting " + testName);
ArrayList<String> cmd = prepareCmd(allowOpt); String[] cmd = prepareCmd(allowOpt);
LingeredApp a; LingeredApp a;
try { 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -127,11 +127,11 @@ public class JdwpAttachTest {
try { try {
LingeredApp debuggee = LingeredApp.startApp( LingeredApp debuggee = LingeredApp.startApp(
Arrays.asList("-agentlib:jdwp=transport=dt_socket" "-agentlib:jdwp=transport=dt_socket"
+ ",address=" + connectAddress + ":" + port + ",address=" + connectAddress + ":" + port
+ ",server=n,suspend=n" + ",server=n,suspend=n"
// if failure is expected set small timeout (default is 20 sec) // if failure is expected set small timeout (default is 20 sec)
+ (!expectedResult ? ",timeout=1000" : ""))); + (!expectedResult ? ",timeout=1000" : ""));
debuggee.stopApp(); debuggee.stopApp();
if (expectedResult) { if (expectedResult) {
log("OK: attached as expected"); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -54,9 +54,7 @@ public class TestPollingInterval {
MonitorException, URISyntaxException { MonitorException, URISyntaxException {
LingeredApp app = null; LingeredApp app = null;
try { try {
List<String> vmArgs = new ArrayList<String>(); String[] vmArgs = Utils.appendTestJavaOpts("-XX:+UsePerfData");
vmArgs.add("-XX:+UsePerfData");
vmArgs.addAll(Utils.getVmOptions());
app = LingeredApp.startApp(vmArgs); app = LingeredApp.startApp(vmArgs);
MonitoredHost localHost = MonitoredHost.getMonitoredHost("localhost"); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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.nio.file.attribute.PosixFilePermission;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; 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(); final String pp = "-Dcom.sun.management.jmxremote.port=" + jdk.test.lib.Utils.getFreePort();
List<String> command = new ArrayList<>(); 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(mp);
command.add(pp); command.add(pp);
command.add("-cp"); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
@ -98,7 +99,7 @@ public class LocalManagementTest {
private static boolean doTest(String testId, String arg) throws Exception { private static boolean doTest(String testId, String arg) throws Exception {
List<String> args = new ArrayList<>(); List<String> args = new ArrayList<>();
args.add("-XX:+UsePerfData"); args.add("-XX:+UsePerfData");
args.addAll(Utils.getVmOptions()); Collections.addAll(args, Utils.getTestJavaOpts());
args.add("-cp"); args.add("-cp");
args.add(TEST_CLASSPATH); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -180,7 +180,7 @@ public class RmiRegistrySslTest {
initTestEnvironment(); initTestEnvironment();
List<String> command = new ArrayList<>(); List<String> command = new ArrayList<>();
command.addAll(Utils.getVmOptions()); Collections.addAll(command, Utils.getTestJavaOpts());
command.add("-Dtest.src=" + TEST_SRC); command.add("-Dtest.src=" + TEST_SRC);
command.add("-Dtest.rmi.port=" + port); command.add("-Dtest.rmi.port=" + port);
command.addAll(Arrays.asList(args)); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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"); System.out.println("Starting LingeredApp");
try { try {
theApp = LingeredApp.startApp(Arrays.asList("-Xmx256m")); theApp = LingeredApp.startApp("-Xmx256m");
System.out.println("Starting jstack against " + theApp.getPid()); System.out.println("Starting jstack against " + theApp.getPid());
JDKToolLauncher launcher = createSALauncher(); JDKToolLauncher launcher = createSALauncher();
@ -164,7 +164,7 @@ public class BasicLauncherTest {
System.out.println("Starting LingeredApp"); System.out.println("Starting LingeredApp");
try { try {
theApp = LingeredApp.startApp(Arrays.asList("-Xmx256m")); theApp = LingeredApp.startApp("-Xmx256m");
System.out.println("Starting " + toolArgs.get(0) + " against " + theApp.getPid()); System.out.println("Starting " + toolArgs.get(0) + " against " + theApp.getPid());
JDKToolLauncher launcher = createSALauncher(); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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"); System.out.println("Starting LingeredApp");
try { try {
theApp = new LingeredAppWithExtendedChars(); theApp = new LingeredAppWithExtendedChars();
LingeredApp.startApp(Arrays.asList("-Xmx256m"), theApp); LingeredApp.startApp(theApp, "-Xmx256m");
System.out.println(theApp.\u00CB); System.out.println(theApp.\u00CB);
System.out.println("Starting " + toolArgs.get(0) + " against " + theApp.getPid()); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -24,6 +24,7 @@
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -52,7 +53,6 @@ public class JMapHeapConfigTest {
"MaxHeapFreeRatio", "MaxHeapFreeRatio",
"MaxHeapSize", "MaxHeapSize",
"NewSize", "NewSize",
"MaxNewSize",
"OldSize", "OldSize",
"NewRatio", "NewRatio",
"SurvivorRatio", "SurvivorRatio",
@ -60,7 +60,9 @@ public class JMapHeapConfigTest {
"CompressedClassSpaceSize", "CompressedClassSpaceSize",
"G1HeapRegionSize"}; "G1HeapRegionSize"};
// ignoring MaxMetaspaceSize // Test can't deal with negative jlongs:
// ignoring MaxMetaspaceSize
// ignoring MaxNewSize
static final String desiredMaxHeapSize = "-Xmx128m"; static final String desiredMaxHeapSize = "-Xmx128m";
@ -126,7 +128,7 @@ public class JMapHeapConfigTest {
} }
boolean mx_found = false; boolean mx_found = false;
List<String> jvmOptions = Utils.getVmOptions(); String[] jvmOptions = Utils.getTestJavaOpts();
for (String option : jvmOptions) { for (String option : jvmOptions) {
if (option.startsWith("-Xmx")) { if (option.startsWith("-Xmx")) {
System.out.println("INFO: maximum heap size set by JTREG as " + option); System.out.println("INFO: maximum heap size set by JTREG as " + option);
@ -137,7 +139,7 @@ public class JMapHeapConfigTest {
// Forward vm options to LingeredApp // Forward vm options to LingeredApp
ArrayList<String> cmd = new ArrayList(); ArrayList<String> cmd = new ArrayList();
cmd.addAll(Utils.getVmOptions()); Collections.addAll(cmd, Utils.getTestJavaOpts());
if (!mx_found) { if (!mx_found) {
cmd.add(desiredMaxHeapSize); cmd.add(desiredMaxHeapSize);
System.out.println("INFO: maximum heap size set explicitly as " + desiredMaxHeapSize); System.out.println("INFO: maximum heap size set explicitly as " + desiredMaxHeapSize);
@ -145,7 +147,7 @@ public class JMapHeapConfigTest {
cmd.add("-XX:+PrintFlagsFinal"); cmd.add("-XX:+PrintFlagsFinal");
TmtoolTestScenario tmt = TmtoolTestScenario.create("jmap", "--heap"); TmtoolTestScenario tmt = TmtoolTestScenario.create("jmap", "--heap");
int exitcode = tmt.launch(cmd); int exitcode = tmt.launch(cmd.toArray(new String[0]));
if (exitcode != 0) { if (exitcode != 0) {
throw new RuntimeException("Test FAILED jmap exits with non zero exit code " + exitcode); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -90,14 +91,14 @@ public class TmtoolTestScenario {
* @param vmArgs - vm and java arguments to launch test app * @param vmArgs - vm and java arguments to launch test app
* @return exit code of tool * @return exit code of tool
*/ */
public int launch(List<String> vmArgs) { public int launch(String... vmArgs) {
System.out.println("Starting LingeredApp"); System.out.println("Starting LingeredApp");
try { try {
try { try {
List<String> vmArgsExtended = new ArrayList<String>(); List<String> vmArgsExtended = new ArrayList<String>();
vmArgsExtended.add("-XX:+UsePerfData"); vmArgsExtended.add("-XX:+UsePerfData");
vmArgsExtended.addAll(vmArgs); Collections.addAll(vmArgsExtended, vmArgs);
theApp = LingeredApp.startApp(vmArgsExtended); theApp = LingeredApp.startApp(vmArgsExtended.toArray(new String[0]));
System.out.println("Starting " + toolName + " against " + theApp.getPid()); System.out.println("Starting " + toolName + " against " + theApp.getPid());
JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("jhsdb"); 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) { private TmtoolTestScenario(String toolName, String[] toolArgs) {
this.toolName = toolName; this.toolName = toolName;
this.toolArgs = toolArgs; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 app1 = new JInfoTestLingeredApp();
LingeredApp app2 = new JInfoTestLingeredApp(); LingeredApp app2 = new JInfoTestLingeredApp();
try { try {
ArrayList<String> params = new ArrayList<String>(); String[] params = new String[0];;
LingeredApp.startApp(params, app1); LingeredApp.startApp(app1, params);
LingeredApp.startApp(params, app2); LingeredApp.startApp(app2, params);
OutputAnalyzer output = jinfo("-flag", "MinHeapFreeRatio=1", "JInfoTestLingeredApp"); OutputAnalyzer output = jinfo("-flag", "MinHeapFreeRatio=1", "JInfoTestLingeredApp");
output.shouldHaveExitValue(0); output.shouldHaveExitValue(0);
output = jinfo("-flag", "MinHeapFreeRatio", "JInfoTestLingeredApp"); output = jinfo("-flag", "MinHeapFreeRatio", "JInfoTestLingeredApp");
@ -84,9 +84,9 @@ public class JInfoTest {
LingeredApp app1 = new JInfoTestLingeredApp(); LingeredApp app1 = new JInfoTestLingeredApp();
LingeredApp app2 = new JInfoTestLingeredApp(); LingeredApp app2 = new JInfoTestLingeredApp();
try { try {
ArrayList<String> params = new ArrayList<String>(); String[] params = new String[0];
LingeredApp.startApp(params, app1); LingeredApp.startApp(app1, params);
LingeredApp.startApp(params, app2); LingeredApp.startApp(app2, params);
OutputAnalyzer output = jinfo("JInfoTestLingeredApp"); OutputAnalyzer output = jinfo("JInfoTestLingeredApp");
output.shouldHaveExitValue(0); output.shouldHaveExitValue(0);
// "Runtime Environment" written once per proc // "Runtime Environment" written once per proc
@ -122,4 +122,3 @@ public class JInfoTest {
// Sometime there is LingeredApp's from other test still around // Sometime there is LingeredApp's from other test still around
class JInfoTestLingeredApp extends LingeredApp { 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 * VM flag to start test application with
*/ */
public static final String VM_FLAG = "+DisableExplicitGC"; public static final String VM_FLAG = "+DisableExplicitGC";
private static File vmFlagsFile = null; 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; private static File manifestFile = null;
/** /**
@ -127,11 +126,9 @@ public final class JpsHelper {
/** /**
* Return a list of VM arguments * Return a list of VM arguments
*/ */
public static List<String> getVmArgs() throws IOException { public static String[] getVmArgs() throws IOException {
if (testVmArgs == null) { if (testVmArgs[testVmArgs.length - 1] == null) {
testVmArgs = new ArrayList<>(); testVmArgs[testVmArgs.length - 1] = "-XX:Flags=" + getVmFlagsFile().getAbsolutePath();
testVmArgs.addAll(Arrays.asList(VM_ARGS));
testVmArgs.add("-XX:Flags=" + getVmFlagsFile().getAbsolutePath());
} }
return testVmArgs; 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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.BasicFileAttributes;
import java.nio.file.attribute.FileTime; import java.nio.file.attribute.FileTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import jdk.test.lib.Utils;
/** /**
* This is a framework to launch an app that could be synchronized with caller * 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 * Analyze an environment and prepare a command line to
* run the app, app name should be added explicitly * 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, // We should always use testjava or throw an exception,
// so we can't use JDKToolFinder.getJDKTool("java"); // so we can't use JDKToolFinder.getJDKTool("java");
// that falls back to compile java on error // that falls back to compile java on error
@ -278,20 +280,13 @@ public class LingeredApp {
List<String> cmd = new ArrayList<String>(); List<String> cmd = new ArrayList<String>();
cmd.add(javapath); cmd.add(javapath);
if (vmArguments == null) { if (vmArguments == null) {
// Propagate test.vm.options to LingeredApp, filter out possible empty options // Propagate getTestJavaOpts() to LingeredApp
String testVmOpts[] = System.getProperty("test.vm.opts","").split("\\s+"); vmArguments = Utils.getTestJavaOpts();
for (String s : testVmOpts) { } else {
if (!s.equals("")) {
cmd.add(s);
}
}
}
else{
// Lets user manage LingeredApp options // Lets user manage LingeredApp options
cmd.addAll(vmArguments);
} }
Collections.addAll(cmd, vmArguments);
// Make sure we set correct classpath to run the app // Make sure we set correct classpath to run the app
cmd.add("-cp"); cmd.add("-cp");
@ -326,7 +321,7 @@ public class LingeredApp {
* @param vmArguments * @param vmArguments
* @throws IOException * @throws IOException
*/ */
public void runApp(List<String> vmArguments) public void runApp(String[] vmArguments)
throws IOException { throws IOException {
List<String> cmd = runAppPrepare(vmArguments); List<String> cmd = runAppPrepare(vmArguments);
@ -367,37 +362,14 @@ public class LingeredApp {
/** /**
* High level interface for test writers * 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 * Factory method that starts pre-created LingeredApp
* lock name is autogenerated * 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 * @param theApp - app to start
* @return LingeredApp object
* @throws IOException * @throws IOException
*/ */
public static void startApp(LingeredApp theApp, String... cmd) throws IOException {
public static void startApp(List<String> cmd, LingeredApp theApp) throws IOException {
theApp.createLock(); theApp.createLock();
try { try {
theApp.runApp(cmd); 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 { 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 { public class LingeredAppForJps extends LingeredApp {
// Copy runApp logic here to be able to run an app from JarFile // 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 { throws IOException {
List<String> cmd = runAppPrepare(vmArguments); List<String> cmd = runAppPrepare(vmArguments);
@ -52,7 +52,7 @@ public class LingeredAppForJps extends LingeredApp {
startGobblerPipe(); 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(); app.createLock();
try { try {
app.runAppWithName(cmd, jar.getAbsolutePath()); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 { public static void testJpsClass() throws Throwable {
LingeredApp app = new LingeredAppForJps(); LingeredApp app = new LingeredAppForJps();
try { try {
LingeredApp.startApp(JpsHelper.getVmArgs(), app); LingeredApp.startApp(app, JpsHelper.getVmArgs());
JpsHelper.runJpsVariants(app.getPid(), JpsHelper.runJpsVariants(app.getPid(),
LingeredAppForJps.getProcessName(), LingeredAppForJps.getFullProcessName(), app.getLockFileName()); LingeredAppForJps.getProcessName(), LingeredAppForJps.getFullProcessName(), app.getLockFileName());
@ -64,7 +64,7 @@ public class TestJps {
// Jar created go to the main test // Jar created go to the main test
LingeredAppForJps app = new LingeredAppForJps(); LingeredAppForJps app = new LingeredAppForJps();
try { try {
LingeredAppForJps.startAppJar(JpsHelper.getVmArgs(), app, jar); LingeredAppForJps.startAppJar(app, JpsHelper.getVmArgs(), jar);
JpsHelper.runJpsVariants(app.getPid(), JpsHelper.runJpsVariants(app.getPid(),
LingeredAppForJps.getProcessName(jar), LingeredAppForJps.getFullProcessName(jar), app.getLockFileName()); LingeredAppForJps.getProcessName(jar), LingeredAppForJps.getFullProcessName(jar), app.getLockFileName());
} finally { } 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -75,12 +75,10 @@ public class DeadlockDetectionTest {
} }
try { try {
List<String> vmArgs = new ArrayList<String>(); String[] vmArgs = Utils.appendTestJavaOpts("-XX:+UsePerfData");
vmArgs.add("-XX:+UsePerfData");
vmArgs.addAll(Utils.getVmOptions());
theApp = new LingeredAppWithDeadlock(); theApp = new LingeredAppWithDeadlock();
LingeredApp.startApp(vmArgs, theApp); LingeredApp.startApp(theApp, vmArgs);
OutputAnalyzer output = jstack(Long.toString(theApp.getPid())); OutputAnalyzer output = jstack(Long.toString(theApp.getPid()));
System.out.println(output.getOutput()); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -52,7 +52,7 @@ public class LingeredAppTest {
cmd.add("-XX:+PrintFlagsFinal"); 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()); System.out.printf("App pid: %d\n", a.getPid());
a.stopApp(); 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 // 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. * 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 * 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. * @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>(); List<String> opts = new ArrayList<String>();
Collections.addAll(opts, getTestJavaOpts()); Collections.addAll(opts, getTestJavaOpts());
Collections.addAll(opts, userArgs); Collections.addAll(opts, userArgs);
return opts.toArray(new String[0]); 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 specifying which GC to use, for example "-XX:+UseG1GC".
* Removes any options matching: -XX:(+/-)Use*GC * 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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.BasicFileAttributes;
import java.nio.file.attribute.FileTime; import java.nio.file.attribute.FileTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.UUID; import java.util.UUID;
import jdk.test.lib.Utils;
import jdk.test.lib.process.OutputBuffer; import jdk.test.lib.process.OutputBuffer;
import jdk.test.lib.process.StreamPumper; import jdk.test.lib.process.StreamPumper;
@ -281,7 +283,7 @@ public class LingeredApp {
* Analyze an environment and prepare a command line to * Analyze an environment and prepare a command line to
* run the app, app name should be added explicitly * 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, // We should always use testjava or throw an exception,
// so we can't use JDKToolFinder.getJDKTool("java"); // so we can't use JDKToolFinder.getJDKTool("java");
// that falls back to compile java on error // that falls back to compile java on error
@ -303,17 +305,12 @@ public class LingeredApp {
cmd.add(javapath); cmd.add(javapath);
if (vmArguments == null) { if (vmArguments == null) {
// Propagate test.vm.options to LingeredApp, filter out possible empty options // Propagate getTestJavaOpts() to LingeredApp
String testVmOpts[] = System.getProperty("test.vm.opts","").split("\\s+"); vmArguments = Utils.getTestJavaOpts();
for (String s : testVmOpts) {
if (!s.equals("")) {
cmd.add(s);
}
}
} else { } else {
// Lets user manage LingeredApp options // Lets user manage LingeredApp options
cmd.addAll(vmArguments);
} }
Collections.addAll(cmd, vmArguments);
// Make sure we set correct classpath to run the app // Make sure we set correct classpath to run the app
cmd.add("-cp"); cmd.add("-cp");
@ -342,7 +339,7 @@ public class LingeredApp {
* @param vmArguments * @param vmArguments
* @throws IOException * @throws IOException
*/ */
public void runApp(List<String> vmArguments) public void runApp(String[] vmArguments)
throws IOException { throws IOException {
List<String> cmd = runAppPrepare(vmArguments); List<String> cmd = runAppPrepare(vmArguments);
@ -391,39 +388,14 @@ public class LingeredApp {
/** /**
* High level interface for test writers * 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 * Factory method that starts pre-created LingeredApp
* lock name is autogenerated * 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 * @param theApp - app to start
* @return LingeredApp object
* @throws IOException * @throws IOException
*/ */
public static void startApp(LingeredApp theApp, String... cmd) throws IOException {
public static void startApp(List<String> cmd, LingeredApp theApp) throws IOException {
theApp.createLock(); theApp.createLock();
try { try {
theApp.runApp(cmd); 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 { public static void stopApp(LingeredApp app) throws IOException {