JDK 12 RFR of JDK-8219254: Update explicit uses of latest source/target in langtools tests to a property

Joe Darcy joe.darcy at oracle.com
Tue Feb 19 18:23:24 UTC 2019


Hello,

Please review the changes to address:

     JDK-8219254: Update explicit uses of latest source/target in 
langtools tests to a property
     https://bugs.openjdk.java.net/browse/JDK-8219254
     http://cr.openjdk.java.net/~darcy/8219254.0/

Some background, dozens of langtools tests are written to have an 
explicit use of the latest -source or -target value, currently primarily 
in support of enable preview features where an explicit -source value 
needs to be passed in to turn on the language feature. (The langtools 
tests over the years have generally been written or updated to assume 
the latest source/target and not need an explicit option.)

Needing to update dozens of these tests cause a maintenance hassle when 
a new release comes around (JDK-8205626), especially as a new release 
now comes around every six months and a preview language feature is 
likely to stay in preview for more than one release cycle (JDK-8214825).

To improve this situation, the tests in question are refactored to take 
advantage of the new jtreg capability to pass in named properties in the 
test definition tags (CODETOOLS-7902352). Separately, the diags/messages 
testing subsystem can be updated analogously (JDK-8219256: Update javac 
diags tests to use properties).

A few notes on the updates:

The minimum jtreg needed for langtools tests is bumped up in 
test/langtools/TEST.ROOT. Before this change is pushed, I'll 
double-check to make sure the new jtreg is installed on the various CI 
systems.

The file tools/javac/6330997/T6330997.java didn't actually seem to need 
-source/-target values and I've therefore just removed them.

The most straightforward change to a file is something like:

--- old/test/langtools/tools/javac/ConditionalWithVoid.java 2019-02-18 
11:36:51.028460917 -0800
+++ new/test/langtools/tools/javac/ConditionalWithVoid.java 2019-02-18 
11:36:50.720460917 -0800
@@ -4,7 +4,7 @@
   * @summary The compiler was allowing void types in its parsing of 
conditional expressions.
   * @author tball
   *
- * @compile/fail/ref=ConditionalWithVoid.out --enable-preview -source 
13 -XDrawDiagnostics ConditionalWithVoid.java
+ * @compile/fail/ref=ConditionalWithVoid.out --enable-preview -source 
${jdk.version} -XDrawDiagnostics ConditionalWithVoid.java
   */
  public class ConditionalWithVoid {

Other tests had to add in explicit @build and @run tags since the 
default implicit ones are not sufficient:

--- old/test/langtools/tools/javac/parser/JavacParserTest.java 
2019-02-18 11:36:52.240460917 -0800
+++ new/test/langtools/tools/javac/parser/JavacParserTest.java 
2019-02-18 11:36:51.928460917 -0800
@@ -29,6 +29,8 @@
   * @modules jdk.compiler/com.sun.tools.javac.api
   *          jdk.compiler/com.sun.tools.javac.main
   *          jdk.compiler/com.sun.tools.javac.tree
+ * @build JavacParserTest
+ * @run main JavacParserTest ${jdk.version}
   */

Additionally, in such a test the version information then has to be 
threaded through to internal programmatic calls to javac.

I looked for candidate files to update running commands like:

     find . -name "*.java" | xargs grep "\-source" | grep 13

Besides the future work files under diags/examples, after the changes in 
the webrev, the remaining uses of "-source 13" are in

     ./tools/javac/expswitch/ExpSwitchNestingTest.java

This is a testng test with its own test root. I wasn't sure how to add 
the necessary tags to pass the information in, but would be happy to do so.

Before the changes are pushed, I'll update the copyrights, etc.

Thanks,

-Joe



More information about the compiler-dev mailing list