Uploaded image for project: 'Code Tools'
  1. Code Tools
  2. CODETOOLS-7903046

Extend computation of test class path in non-installed run mode

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • None
    • None
    • tools
    • None

      JTReg uses this code to compute the test class path in method `getJavaTestClassPath()` of class `RegressionParameters` in package `com.sun.javatest.regtest.config`:

                      // append jtreg.jar to the path
                      javaTestClassPath.append(new File(installDir, "jtreg.jar"));

      Note: if that JAR file is not present, the append call is a silent no-op.

      Running jtreg's main entry point in a custom setup, like directly from within an IDE, is not possible, because `jtreg.jar` is not available.

      However, all classes that make up jtreg are available in an exploded form, generated by an IDE. Hence, if `jtreg.jar` is not available at the expected location, we should instead add the directory of the current class' code source location. Possibly, using the following snippet:

                      // append jtreg.jar or exploded directory to the search path
                      File jtreg = new File(installDir, "jtreg.jar");
                      if (jtreg.exists()) {
                          javaTestClassPath.append(jtreg);
                      } else try {
                          // use code source location of this class instead
                          URL location = getClass().getProtectionDomain().getCodeSource().getLocation();
                          javaTestClassPath.append(new File(location.toURI()));
                      } catch (Exception e) {
                          throw new RuntimeException(e);
                      }

            cstein Christian Stein
            cstein Christian Stein
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: