Referencing arbitrary `Builder` class inside Thread::run() causes compilation to fail with `java.lang.Thread.Builder is a preview API and is disabled by default` error. OpenJDK version: ``` openjdk version "19-ea" 2022-09-20 OpenJDK Runtime Environment (build 19-ea+25-1892) OpenJDK 64-Bit Server VM (build 19-ea+25-1892, mixed mode, sharing) ``` Reproducer sample class: ``` package com.example; public class Builder { public static void main(String[] args) { new Thread() { public void run() { final Builder builder = new com.example.Builder(); builder.buildNow(); } }.start(); } public void buildNow() { } } ``` Compiler error (using "$JAVA_HOME/bin/javac" com/example/Builder.java): ``` src\main\java\com\example\Builder.java:7: error: Builder is a preview API and is disabled by default. final Builder builder = new com.example.Builder(); ^ (use --enable-preview to enable preview APIs) src\main\java\com\example\Builder.java:7: error: incompatible types: com.example.Builder cannot be converted to java.lang.Thread.Builder final Builder builder = new com.example.Builder(); ^ src\main\java\com\example\Builder.java:8: error: cannot find symbol builder.buildNow(); ^ symbol: method buildNow() location: variable builder of type Builder 3 errors ``` The issue has been manifested in Apache CXF builds which we run regularly for every JDK early releases, it is a bit difficult to precisely pinpoint the build but it has been noticed first time in the OpenJDK 19-ea+22 and confirmed in 19-ea+25. [1] https://ci-builds.apache.org/job/CXF/job/CXF-JDK19/189/console
|