Note

[BUG] 8372325: Refactor tests in jdk/java/net/httpclient to use ${test.main.class}

I replaced the @run tag in the tests under HttpClient with ${test.main.class}.

Overview#

In the numerous tests under test/jdk/java/net/httpclient, the test class names were directly written in JTReg's (@run tag, a regression testing framework unique to OpenJDK). For example:

@run junit/othervm AltServiceUsageTest

However, having such self-referential test class names within the code can lead to some tricky issues. Since tests are often copied and pasted, forgetting to update them can result in unintended tests being executed.

Starting with JTReg 7.5.2, a placeholder ${test.main.class} was introduced1. This allows for meta-specification of classes annotated with JTReg annotations; if @run ${test.main.class} is present on the Main class, it effectively becomes @run Main.

In this update, we replaced explicit class names in @run tags with ${test.main.class}.

@run junit/othervm ${test.main.class}

The changes affected 313 files and were primarily mechanical replacements2.

Discovered on JBS 2026/03/18#

This issue was discovered via JBS, where I confirmed that many test files under java/net/httpclient directly wrote the test class names in @run tags. These forms included main, junit, othervm, and timeout.

In the PR, we decided to replace only the class names appearing as execution targets in @run tags with ${test.main.class}3. Meanwhile, explicit class names remaining in @build were left untouched since they might have different meanings related to build dependencies.

Despite being extensive, the changes consisted of simple replacements like:

- * @run main/othervm BasicAuthTest
+ * @run main/othervm ${test.main.class}
- * @run main/othervm CertificateTest GOOD_CERT expectSuccess
+ * @run main/othervm ${test.main.class} GOOD_CERT expectSuccess

Addressing Reviews on 2026/04/02#

Daniel Fuchs4 commented after reviewing the diffs, suggesting to incorporate changes from master and resolve conflicts.

SendaoYan5 also suggested replacing class names in @build or system properties with ${test.main.class}. However, according to Daniel Fuchs4, it was better not to touch these parts in this PR.

Later, SendaoYan5 pointed out that HttpVersionsTest.java had been overlooked and I made additional corrections for it.

Review on 2026/04/09#

SendaoYan5 and Daniel Fuchs4 reviewed the changes and approved them. After confirming the review, /integrate was performed.

Integration on 2026/04/09#

Daniel Fuchs4 sponsored it with /sponsor, integrating it into JDK as 261011a6.


Footnotes#

  1. 2 3 4
  2. 2 3