JDK-8240698 : LingeredApp does not pass getTestJavaOpts() to the children process if vmArguments is already specified
  • Type: Bug
  • Component: hotspot
  • Sub-Component: test
  • Affected Version: 15
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • Submitted: 2020-03-07
  • Updated: 2020-04-17
  • Resolved: 2020-04-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 15
15 b18Fixed
Related Reports
Blocks :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
This bug limits test coverage for ClhsdbCDSJstackPrintAll.java. When jtreg -vmoption:-XX:+UseZGC is used:

+ the test dumps a CDS archive with ZGC enabled (use compressed oops = false)

+ because of this bug, the test tries to use the CDS archive without enabling ZGC, so we have compressed oops = true. As a result, the VM cannot load this CDS archive because the oop compression mode doesn't match.

--------

in runAppPrepare:
        if (vmArguments == null) {
            // Propagate getTestJavaOpts() to LingeredApp
            vmArguments = Utils.getTestJavaOpts();
        } else {
            // Lets user manage LingeredApp options
        }
When vmArguments specified, the testing java options are not passed into children process. This  may lead to inconsistency for CDS dump/run.
Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/d8c2f47ea47d User: lmesnik Date: 2020-04-01 23:27:42 +0000
01-04-2020

Assuming that ignoring test options is not a good thing, I think it would be better to change startApp to add options and force people to start custom LingeredApp if they want to ignore external opts.
24-03-2020

Statistic says that usually people just want to add additional options and not to completely override them. See Append: TestPollingInterval.java, tools/jstack/DeadlockDetectionTest.java, JMapHeapConfigTest.java (via TmtoolTestScenario.java), TestHeapDumpForLargeArray, ClhsdbFlags, ClhsdbJstack, TestInstanceKlassSize, TestPrintMdo Append/mistakenly override: JdwpAllowTest.java, JdwpAttachTest.java, HeapDumpTest.java, BasicLauncherTest.java, CDSJMapClstats, ClhsdbCDSJstackPrintAll, Override: JInfoTest.java?, ClhsdbRegionDetailsScanOopsForG1, ClhsdbScanOops, TestUniverse N/A:
24-03-2020

Also, the doc clearly says how to set args to startApp /** * 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 { }
24-03-2020

I think that the original idea was just to use user-defined VM args or default TestJavaOpts. And it is a test responsibility to prepare vmArgs if they are not default. I looked through tests used LingereApp and indeed some tests correctly prepare arguments. Like: public class TestPollingInterval { private static final int INTERVAL = 2000; public static void main(String[] args) throws IOException, MonitorException, URISyntaxException { LingeredApp app = null; try { String[] vmArgs = Utils.appendTestJavaOpts("-XX:+UsePerfData"); app = LingeredApp.startApp(vmArgs); However a lot of other tests just add some arguments, like jdk/com/sun/jdi/JdwpAttachTest.java LingeredApp debuggee = LingeredApp.startApp( "-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" : "")); So all other arguments are ignored. And there are few tests were default VM arguments are not used intentionally, like in the ClhsdbRegionDetailsScanOopsForG1 LingeredApp.startApp(theApp, "-XX:+UseG1GC", "-Xmx8g", "-XX:G1HeapRegionSize=2m");
24-03-2020

I think the current behavior may be intentional -- in many cases, especially when with "jtreg -vmoption:-Xcomp", you probably don't want the LingerApp to run with -Xcomp. So we should have an API in LingerApp.startApp() to explicitly allow the passing of getTestJavaOpts() to the child process.
10-03-2020