Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JDK next compilation error: incompatible types: Class<CAP#1> cannot be converted #20428

Closed
JasonFengJ9 opened this issue Oct 29, 2024 · 9 comments · Fixed by #20433
Closed

JDK next compilation error: incompatible types: Class<CAP#1> cannot be converted #20428

JasonFengJ9 opened this issue Oct 29, 2024 · 9 comments · Fixed by #20433

Comments

@JasonFengJ9
Copy link
Member

https://openj9-jenkins.osuosl.org/job/Build_JDKnext_aarch64_linux_OpenJDK/665/consoleFull

00:52:25  /home/jenkins/workspace/Build_JDKnext_aarch64_linux_OpenJDK/src/java.base/share/classes/java/lang/Double.java:462: error: incompatible types: Class<CAP#1> cannot be converted to Class<Double>
00:52:25      public static final Class<Double> TYPE = Class.getPrimitiveClass("double");
00:52:25                                                                      ^
00:52:25    where CAP#1 is a fresh type-variable:
00:52:25      CAP#1 extends Object from capture of ?

00:52:25  /home/jenkins/workspace/Build_JDKnext_aarch64_linux_OpenJDK/src/java.base/share/classes/java/lang/Short.java:82: error: incompatible types: Class<CAP#1> cannot be converted to Class<Short>
00:52:25      public static final Class<Short> TYPE = Class.getPrimitiveClass("short");
00:52:25                                                                     ^
00:52:25    where CAP#1 is a fresh type-variable:
00:52:25      CAP#1 extends Object from capture of ?
00:52:25  Note: Some input files additionally use or override a deprecated API.
00:52:25  Note: Some input files additionally use or override a deprecated API that is marked for removal.
00:52:25  Note: Some input files additionally use unchecked or unsafe operations.
00:52:25  9 errors

This is due to openjdk change ibmruntimes/openj9-openjdk-jdk@0995dd6

Copy link

Issue Number: 20428
Status: Open
Recommended Components: comp:vm, comp:test, comp:build
Recommended Assignees: keithc-ca, jasonfengj9, hangshao0

@pshipton
Copy link
Member

I assume this is related to not using the latest bootjdk. We can back out the change until we are ready to move the bootjdk up.
@keithc-ca agreed?

@JasonFengJ9
Copy link
Member Author

ibmruntimes/openj9-openjdk-jdk@0995dd6
from:

    /*
     * Return the Virtual Machine's Class object for the named
     * primitive type.
    static native Class<?> getPrimitiveClass(String name);

to:

    /*
     * Returns the Class object for the named primitive type. Type parameter T
     * avoids redundant casts for trusted code.
     */
    static native <T> Class<T> getPrimitiveClass(String name);

I think similar change is needed at

public native Class<?> getComponentType();

@pshipton
Copy link
Member

Oh ok. Are you going to fix it?

@keithc-ca
Copy link
Contributor

I don't understand your comment about getComponentType(): I don't see how it could change and being public API, the signature must not change.

@JasonFengJ9
Copy link
Member Author

getPrimitiveClass() invokes getComponentType().

static Class<?> getPrimitiveClass(String name) {
if (name.equals("float")) //$NON-NLS-1$
return new float[0].getClass().getComponentType();

A quick way to unblock the build is to do a cast there return (Class<T>) new float[0].getClass().getComponentType(); along with the API change static <T> Class<T> getPrimitiveClass(String name).

@keithc-ca keithc-ca self-assigned this Oct 29, 2024
@keithc-ca
Copy link
Contributor

I was hoping the solution could follow the pattern of forPrimitiveName(String) (using e.g. int.class), but that has bootstrap problems.

@keithc-ca
Copy link
Contributor

I assume this is related to not using the latest bootjdk.

No, the same problem happens whether the bootjdk is Java 21 or Java 23.

Copy link

Issue Number: 20428
Status: Closed
Actual Components: comp:vm, test failure, blocker, jdk-head
Actual Assignees: No one :(
PR Assignees: keithc-ca

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants