Use external classes in @run driver

Liu, Xin xxinliu at
Mon Jun 15 23:21:13 UTC 2020

Hi, Jonathan,

Thank you! I got the idea. 
code and document are correct.  My understanding is right. 
Even my initial change was right.  After I delete those files in test/lib/*, I left the empty directory test/lib in hotspot/test. 
That's why jtreg had trouble to pick up the classes suggested from external.lib.roots and @library.  Lesson learned. 


On 6/15/20, 11:21 AM, "Jonathan Gibbons" <jonathan.gibbons at> wrote:

    CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.


    Yes, this is the primary use case for external.lib.roots.

    You may need to adjust the order of items in external.lib.roots,
    especially as you seem to have an anti-pattern going on, of one library
    inside another, as indicated by

    external.lib.roots=../../jdk ../../jdk/test/lib

    Poking around the 8u/8u forest, the reference to ../../jdk seems
    questionable as that seems to indicate the the top of the jdk repo. That
    being said ...

    Poking around a bit more, I see there is
    8U-FOREST/jdk/test/lib/jdk/test/lib, and that is in
    `package jdk.test.lib` which means that the package root for the class
    is 8U-FOREST/jdk/test/lib

    This means that you need an entry in external.lib.roots and a @library
    that together form the path ../../jdk/test/lib

    Can you find any other tests in the hotspot test repo that are using
    external.lib.roots?  I'm guessing maybe not, since I don't see an entry
    in the hotspot/test TEST.ROOT file.

    Separately, I will investigate why jtreg is reporting an invalid value
    for the number of seconds it took.

    -- Jon

    On 6/15/20 10:14 AM, Liu, Xin wrote:
    > Hi, Jonathan,
    > Thank you to look into it.
    > I am using " jtreg, version 5.1 dev 821".  It's not 5.2.  my bad.
    > I am working on jdk8u/hotspot + vmTestbase.  You probably know that test directories are separated in jdk8u.
    > I'd like to reuse in ../../jdk/test/lib/jdk/test/lib.  Otherwise, I need a clone of tes/lib/* in hotspot/test.
    > Do you think it's a reasonable use-case?  if so, is it possible to access external classes in annotation @run?
    > The output was written by jtreg.  Something weird happened. I think I need to put FileInstaller in its classpath first.
    > thanks,
    > --lx
    > On 6/15/20, 7:44 AM, "jtreg-use on behalf of Jonathan Gibbons" <jtreg-use-bounces at on behalf of jonathan.gibbons at> wrote:
    >      CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe.
    >      Hi,
    >      There's at least a couple of things going on here.
    >      1. external.lib.roots is only used for library code that is outside the
    >      current test suite (i.e. outside the directory containing TEST.ROOT)
    >           It provides root directories in which to resolve @library
    >      directories that begin with '/'.
    >           In other words, if you have
    >               @library /my/lib
    >           and you have
    >               external.lib.roots=../A ../B
    >           Then jtreg will look for library files in TESTROOTDIR/my/lib,
    >           where TESTROOTDIR is the root directory of the test suite.
    >      2. There's something weird the output you posted:
    >      TIME: .lib.FileInstaller seconds
    >           If that's what jtreg wrote, that is an unexpected error in jtreg
    >      3. Minor: the current released version of jtreg is 5.1, as indicated by
    >      the Mercurial tag jtreg5.1-b01
    >           The default version of 5.2 in the tip changeset will be the version
    >      of the next update.
    >      -- Jon
    >      On 6/14/20 1:18 AM, Liu, Xin wrote:
    >      > Hi,
    >      >
    >      > I'd like to use some external classes in @run driver.  Those classes are “external” in the sense of directory.  They locate out of my current test directory.
    >      > Eg. “@run driver jdk.test.lib.FileInstaller . .”  and the class FileInstaller is here.
    >      > $find ../../ -name
    >      > ../../jdk/test/lib/jdk/test/lib/
    >      >
    >      > I am now using the latest jreg(5.2). Doc says that jtreg acts like adding an “@build classname” before @run driver.
    >      > About how to discover the classes, quote the corresponding description in Action Types/build (,
    >      > "
    >      > To locate a source file for a named class, the harness takes the first matching file found by looking in the test-source directory and then in each appropriate directory of the library path list.
    >      > "
    >      > quote end. I don't understand the definition of library path list here.  Is it the same thing as @library? I try to tell jtreg that use these two external roots in TEST.ROOT.
    >      > # depends on jdk/test
    >      > external.lib.roots=../../jdk ../../jdk/test/lib
    >      >
    >      > and also, I see that the test does have the annotation @library.
    >      > * @library /vmTestbase
    >      > *          /test/lib
    >      > * @run driver jdk.test.lib.FileInstaller . .
    >      >
    >      > But it doesn’t work. I still get the error message as follows.
    >      > ACTION: build -- Not run. Test running...
    >      > REASON: Named class compiled on demand
    >      > TIME:   .lib.FileInstaller seconds
    >      > messages:
    >      > command: build jdk.test.lib.FileInstaller
    >      > reason: Named class compiled on demand
    >      >
    >      > TEST RESULT: Error. can't find jdk.test.lib.FileInstaller in test directory or libraries
    >      >
    >      > Could you educate me the right usage?
    >      > Thank you in advance.
    >      > --lx
    >      >
    >      >

More information about the jtreg-use mailing list