JDK-8292629 : Compilation failure: incompatible types: jakarta.ws.rs.client.Invocation.Builder cannot be converted to java.lang.Thread.Builder
  • Type: Bug
  • Component: tools
  • Affected Version: 19
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: generic
  • CPU: generic
  • Submitted: 2022-08-16
  • Updated: 2022-09-02
  • Resolved: 2022-08-18
Related Reports
Relates :  
Relates :  
Description
A DESCRIPTION OF THE PROBLEM :
Compiler wrongly uses import classes.

import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.client.Invocation.Builder;
...
    public void doGetAndCheckResponse() throws Throwable {
        final WebTarget path = client.target(getSettings().targetUri.toString());
        final Builder builder = path.request(); //Invocation.Builder, not Thread.Builder
        final Response response = builder.get();
        final String responseMsg = response.readEntity(String.class);
        assertEquals(200, response.getStatus());
        assertEquals("Got it!", responseMsg);
    }

The class is https://github.com/eclipse-ee4j/jersey/blob/3.x/containers/grizzly2-http/src/test/java/org/glassfish/jersey/grizzly2/httpserver/test/tools/JerseyHttpClientThread.java



REGRESSION : Last worked in version 18.0.2

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
This occurs when building Jersey with JDK 19 java version "19.0.1" 2022-10-18
Java(TM) SE Runtime Environment (build 19.0.1+5-12)
Java HotSpot(TM) 64-Bit Server VM (build 19.0.1+5-12, mixed mode, sharing)

To reproduce, clone Jersey, branch 3.x:
git clone https://github.com/eclipse-ee4j/jersey.git .
git checkout 3.x
mvn clean install -DskipTests

Build fails after about 40s (longer when pulling dependencies).

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Build passes
ACTUAL -
Build fails

CUSTOMER SUBMITTED WORKAROUND :
Using JDK 18.


Comments
The issue has been addressed by the maintainers of eclipse-ee4j/jersey. Closing the issue as not an issue.
18-08-2022

This source compatibility issue is documented in the JDK 19 release notes as JDK-8288416. Separately, the maintainers of eclipse-ee4j/jersey seem to have addressed the issue already: https://github.com/eclipse-ee4j/jersey/commit/3e195a2654f32a39b1cac2eb793125728f819656
18-08-2022