Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8187806

executeTestJava handles -cp differently in jdk.test.lib.process.ProcessTools and jdk.testlibrary.ProcessTools

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P3 P3
    • tbd
    • 10
    • hotspot

      jdk.test.lib.process.ProcessTools.executeTestJava always adds -cp, while jdk.testlibrary.ProcessTools.executeTestJava does not.

      See details:
      (all created by createJavaProcessBuilder(false, command))

      jdk.test.lib.process.ProcessTools:
          public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions, String... command) {
      ...
      329: args.add("-cp");
      330: args.add(System.getProperty("java.class.path"));
      331:
      332: if (addTestVmAndJavaOptions) {
      333: Collections.addAll(args, Utils.getTestJavaOpts());
      334: }


      jdk.testlibrary.ProcessTools:
          public static ProcessBuilder createJavaProcessBuilder(boolean addTestVmAndJavaOptions, String... command) {
      ...
      288: if (addTestVmAndJavaOptions) {
      289: // -cp is needed to make sure the same classpath is used whether the test is
      290: // run in AgentVM mode or OtherVM mode. It was added to the hotspot version
      291: // of this API as part of 8077608. However, for the jdk version it is only
      292: // added when addTestVmAndJavaOptions is true in order to minimize
      293: // disruption to existing JDK tests, which have yet to be tested with -cp
      294: // being added. At some point -cp should always be added to be consistent
      295: // with what the hotspot version does.
      296: args.add("-cp");
      297: args.add(System.getProperty("java.class.path"));
      298: Collections.addAll(args, Utils.getTestJavaOpts());
      299: }

      In case test need to run with specified "-cp", jdk.testlibrary.ProcessTools.executeTestJava make it easier (example: test/jdk/java/lang/reflect/Proxy/ProxyTest.java).

      This inconsistent needs to be resolved while trying to remove jdk.testlibrary.ProcessTools

            iignatyev Igor Ignatyev (Inactive)
            amlu Amy Lu (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: