OpenJDK / jdk / jdk
changeset 57825:8180290b2faa
8237111: LingeredApp should be started with getTestJavaOpts
Reviewed-by: cjplummer, dholmes
line wrap: on
line diff
--- a/test/hotspot/jtreg/ProblemList-zgc.txt Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/ProblemList-zgc.txt Fri Jan 24 10:31:45 2020 +0100 @@ -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
--- a/test/hotspot/jtreg/resourcehogs/serviceability/sa/ClhsdbRegionDetailsScanOopsForG1.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/resourcehogs/serviceability/sa/ClhsdbRegionDetailsScanOopsForG1.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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");
--- a/test/hotspot/jtreg/resourcehogs/serviceability/sa/TestHeapDumpForLargeArray.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/resourcehogs/serviceability/sa/TestHeapDumpForLargeArray.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ // 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);
--- a/test/hotspot/jtreg/serviceability/sa/CDSJMapClstats.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/serviceability/sa/CDSJMapClstats.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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) {
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSJstackPrintAll.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbCDSJstackPrintAll.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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.
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbFindPC.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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 @@ System.out.println("Test PASSED"); } } -
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbFlags.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbFlags.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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 @@ 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());
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbInspect.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbInspect.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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*,
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbJhisto.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbJhisto.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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");
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbJstack.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbJstack.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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) {
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackXcompStress.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbJstackXcompStress.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 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");
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAll.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbPrintAll.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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");
--- a/test/hotspot/jtreg/serviceability/sa/ClhsdbScanOops.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/serviceability/sa/ClhsdbScanOops.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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());
--- a/test/hotspot/jtreg/serviceability/sa/DeadlockDetectionTest.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/serviceability/sa/DeadlockDetectionTest.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ } 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());
--- a/test/hotspot/jtreg/serviceability/sa/JhsdbThreadInfoTest.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/serviceability/sa/JhsdbThreadInfoTest.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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");
--- a/test/hotspot/jtreg/serviceability/sa/TestClhsdbJstackLock.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/serviceability/sa/TestClhsdbJstackLock.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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 @@ System.out.println("Test PASSED"); } } -
--- a/test/hotspot/jtreg/serviceability/sa/TestCpoolForInvokeDynamic.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/serviceability/sa/TestCpoolForInvokeDynamic.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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 {
--- a/test/hotspot/jtreg/serviceability/sa/TestDefaultMethods.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/serviceability/sa/TestDefaultMethods.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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 {
--- a/test/hotspot/jtreg/serviceability/sa/TestG1HeapRegion.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/serviceability/sa/TestG1HeapRegion.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 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);
--- a/test/hotspot/jtreg/serviceability/sa/TestHeapDumpForInvokeDynamic.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/serviceability/sa/TestHeapDumpForInvokeDynamic.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ } 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);
--- a/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSize.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSize.java Fri Jan 24 10:31:45 2020 +0100 @@ -73,9 +73,7 @@ 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 @@ } } } -
--- a/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSizeForInterface.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/serviceability/sa/TestInstanceKlassSizeForInterface.java Fri Jan 24 10:31:45 2020 +0100 @@ -150,9 +150,8 @@ 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 {
--- a/test/hotspot/jtreg/serviceability/sa/TestIntConstant.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/serviceability/sa/TestIntConstant.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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());
--- a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLock.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackLock.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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");
--- a/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixed.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/serviceability/sa/TestJhsdbJstackMixed.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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");
--- a/test/hotspot/jtreg/serviceability/sa/TestPrintMdo.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/serviceability/sa/TestPrintMdo.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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());
--- a/test/hotspot/jtreg/serviceability/sa/TestRevPtrsForInvokeDynamic.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/serviceability/sa/TestRevPtrsForInvokeDynamic.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 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);
--- a/test/hotspot/jtreg/serviceability/sa/TestType.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/serviceability/sa/TestType.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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");
--- a/test/hotspot/jtreg/serviceability/sa/TestUniverse.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/serviceability/sa/TestUniverse.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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 {
--- a/test/hotspot/jtreg/vmTestbase/nsk/jdi/AttachingConnector/attach/attach004/TestDriver.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/hotspot/jtreg/vmTestbase/nsk/jdi/AttachingConnector/attach/attach004/TestDriver.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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 @@ 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(),
--- a/test/jdk/com/sun/jdi/JdwpAllowTest.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/jdk/com/sun/jdi/JdwpAllowTest.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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 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 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 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 {
--- a/test/jdk/com/sun/jdi/JdwpAttachTest.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/jdk/com/sun/jdi/JdwpAttachTest.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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");
--- a/test/jdk/sun/jvmstat/monitor/MonitoredVm/TestPollingInterval.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/jdk/sun/jvmstat/monitor/MonitoredVm/TestPollingInterval.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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");
--- a/test/jdk/sun/management/jmxremote/bootstrap/AbstractFilePermissionTest.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/jdk/sun/management/jmxremote/bootstrap/AbstractFilePermissionTest.java Fri Jan 24 10:31:45 2020 +0100 @@ -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.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 @@ 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");
--- a/test/jdk/sun/management/jmxremote/bootstrap/LocalManagementTest.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/jdk/sun/management/jmxremote/bootstrap/LocalManagementTest.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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);
--- a/test/jdk/sun/management/jmxremote/bootstrap/RmiRegistrySslTest.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/jdk/sun/management/jmxremote/bootstrap/RmiRegistrySslTest.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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));
--- a/test/jdk/sun/tools/jhsdb/BasicLauncherTest.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/jdk/sun/tools/jhsdb/BasicLauncherTest.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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 @@ 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();
--- a/test/jdk/sun/tools/jhsdb/HeapDumpTest.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/jdk/sun/tools/jhsdb/HeapDumpTest.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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());
--- a/test/jdk/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/jdk/sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ "MaxHeapFreeRatio", "MaxHeapSize", "NewSize", - "MaxNewSize", "OldSize", "NewRatio", "SurvivorRatio", @@ -60,7 +60,9 @@ "CompressedClassSpaceSize", "G1HeapRegionSize"}; - // ignoring MaxMetaspaceSize + // Test can't deal with negative jlongs: + // ignoring MaxMetaspaceSize + // ignoring MaxNewSize static final String desiredMaxHeapSize = "-Xmx128m"; @@ -126,7 +128,7 @@ } 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 @@ // 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 @@ 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); }
--- a/test/jdk/sun/tools/jhsdb/heapconfig/TmtoolTestScenario.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/jdk/sun/tools/jhsdb/heapconfig/TmtoolTestScenario.java Fri Jan 24 10:31:45 2020 +0100 @@ -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.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 @@ * @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 void launch(String... appArgs) throws IOException { - launch(Arrays.asList(appArgs)); - } - private TmtoolTestScenario(String toolName, String[] toolArgs) { this.toolName = toolName; this.toolArgs = toolArgs;
--- a/test/jdk/sun/tools/jinfo/JInfoTest.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/jdk/sun/tools/jinfo/JInfoTest.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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 @@ 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 @@ // Sometime there is LingeredApp's from other test still around class JInfoTestLingeredApp extends LingeredApp { } -
--- a/test/jdk/sun/tools/jps/JpsHelper.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/jdk/sun/tools/jps/JpsHelper.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ -94,20 +94,19 @@ } /** - * 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 @@ /** * 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; }
--- a/test/jdk/sun/tools/jps/LingeredApp.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/jdk/sun/tools/jps/LingeredApp.java Fri Jan 24 10:31:45 2020 +0100 @@ -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.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 @@ * 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 @@ 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); - } - } + // Propagate getTestJavaOpts() to LingeredApp + vmArguments = Utils.getTestJavaOpts(); + } else { + // Lets user manage LingeredApp options } - 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 @@ * @param vmArguments * @throws IOException */ - public void runApp(List<String> vmArguments) + public void runApp(String[] vmArguments) throws IOException { List<String> cmd = runAppPrepare(vmArguments); @@ -368,36 +363,13 @@ * High level interface for test writers */ /** - * Factory method that creates LingeredApp object with ready to use application + * Factory method that starts pre-created LingeredApp * lock name is autogenerated - * @param cmd - vm options, could be null to auto add testvm.options - * @return LingeredApp object + * @param cmd - vm options, could be null to auto add Utils.getTestJavaOpts() + * @param theApp - app to start * @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 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 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 {
--- a/test/jdk/sun/tools/jps/LingeredAppForJps.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/jdk/sun/tools/jps/LingeredAppForJps.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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 @@ 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());
--- a/test/jdk/sun/tools/jps/TestJps.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/jdk/sun/tools/jps/TestJps.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 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 @@ // 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 {
--- a/test/jdk/sun/tools/jstack/DeadlockDetectionTest.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/jdk/sun/tools/jstack/DeadlockDetectionTest.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ } 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());
--- a/test/lib-test/jdk/test/lib/apps/LingeredAppTest.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/lib-test/jdk/test/lib/apps/LingeredAppTest.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ 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();
--- a/test/lib/jdk/test/lib/Utils.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/lib/jdk/test/lib/Utils.java Fri Jan 24 10:31:45 2020 +0100 @@ -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 @@ -145,15 +145,6 @@ } /** - * 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. * * @return The list of VM options with -J prefix @@ -183,7 +174,7 @@ * 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); @@ -191,6 +182,27 @@ } /** + * 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 * Used when a test need to set its own GC version. Then any
--- a/test/lib/jdk/test/lib/apps/LingeredApp.java Fri Jan 24 09:27:07 2020 +0100 +++ b/test/lib/jdk/test/lib/apps/LingeredApp.java Fri Jan 24 10:31:45 2020 +0100 @@ -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.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 @@ * 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 @@ 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 @@ * @param vmArguments * @throws IOException */ - public void runApp(List<String> vmArguments) + public void runApp(String[] vmArguments) throws IOException { List<String> cmd = runAppPrepare(vmArguments); @@ -392,38 +389,13 @@ * High level interface for test writers */ /** - * Factory method that creates LingeredApp object with ready to use application + * Factory method that starts pre-created LingeredApp * lock name is autogenerated - * @param cmd - vm options, could be null to auto add testvm.options - * @return LingeredApp object + * @param cmd - vm options, could be null to auto add Utils.getTestJavaOpts() + * @param theApp - app to start * @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 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 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 {