[jdk21u-dev] RFR: 8375080: The tools/jpackage/windows/Win8365790Test.java may fail with ClassNotFoundException: jtreg.SkippedException

Min Choi duke at openjdk.org
Thu Feb 12 18:31:59 UTC 2026


On Tue, 10 Feb 2026 18:46:45 GMT, Min Choi <duke at openjdk.org> wrote:

> `Win8365790Test` calls `TKit.throwSkippedException()` when the test environment doesn't support Ctrl+C signal delivery.
> 
> In JDK 17/21, `TKit.throwSkippedException()` uses reflection (`Class.forName("jtreg.SkippedException")`) to load the exception class, which requires `jtreg.SkippedException` to be on the classpath.
> 
> public static RuntimeException throwSkippedException(String reason) {
>     trace("Skip the test: " + reason);
>     RuntimeException ex = ThrowingSupplier.toSupplier(
>             () -> (RuntimeException) Class.forName("jtreg.SkippedException").getConstructor(
>                     String.class).newInstance(reason)).get();
>     currentTest.notifySkipped(ex);
>     throw ex;
> }
> 
> 
> The test was missing the jtreg directives to build this class:
> 
> @library /test/lib
> @build jtreg.SkippedException
> 
> 
> This pattern is already used by other jpackage tests that call `throwSkippedException()` (e.g., `SigningAppImageTest.java`).
> 
> Note: JDK 25+ has this fixed differently via [JDK-8352419](https://bugs.openjdk.org/browse/JDK-8352419) which [hardcodes](https://github.com/openjdk/jdk/commit/70e325004536eb9b79f4943f27eed4ac6cec8bd5#diff-409e0d5eb5d024e7613e041c416fe862752cce72f19c80bb585511239fab9399R1144-R1170) `SkippedException` directly in `TKit.java`.

Just checked whether jtreg 7.5.1+1 fixes the issue and the test still fails with ClassNotFoundException for me.

I also ran a very simple test against 7.5.1 and it fails.

import jdk.jpackage.test.Annotations.Test;
import jdk.jpackage.test.TKit;

/*
 * @test
 * @summary Test TKit.throwSkippedException() without @library /test/lib
 * @library /test/jdk/tools/jpackage/helpers
 * @build jdk.jpackage.test.*
 * @build TKitSkipTest
 * @run main/othervm -Xmx512m jdk.jpackage.test.Main
 *  --jpt-run=TKitSkipTest
 */
public class TKitSkipTest {

    @Test
    public void test() {
        TKit.throwSkippedException("Testing TKit.throwSkippedException()");
    }
}


I verified that this simple test skips correctly in 25.

Please let me know how I can make this test pass with bumping Jtreg to 7.5.1+1.

-------------

PR Comment: https://git.openjdk.org/jdk21u-dev/pull/2606#issuecomment-3892679583


More information about the jdk-updates-dev mailing list