JDK-8335060 : ClassCastException after JDK-8294960
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang.invoke
  • Affected Version: 24
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2024-06-25
  • Updated: 2024-07-01
  • Resolved: 2024-07-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 24
24 masterFixed
Related Reports
Relates :  
Description
The following code that used to execute fine, throws ClassCastException after JDK-8294960:

import java.util.function.Predicate;
public class Test {
    public static void main(String[] args) {
        doTest(Test::predicate, 'x');
    }
    public static boolean doTest(Predicate<Character> predicate, char c) {
        return predicate.test(c);
    }
    public static boolean predicate(int c) {
        return '0' <= c && c <= '9';
    }
}

Exception in thread "main" java.lang.ClassCastException: class java.lang.Character cannot be cast to class java.lang.Number (java.lang.Character and java.lang.Number are in module java.base of loader 'bootstrap')
        at Test.doTest(Test.java:10)
        at Test.main(Test.java:6)

Comments
Changeset: 3ca2bcd4 Author: Adam Sotona <asotona@openjdk.org> Date: 2024-07-01 11:51:13 +0000 URL: https://git.openjdk.org/jdk/commit/3ca2bcd402042791d7460dd79ee16a3f88436b3e
01-07-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/19898 Date: 2024-06-26 06:53:28 +0000
26-06-2024

TypeConvertingMethodAdpter::convertType handles arguments arg=Object target=int functional=Character incorrectly.
25-06-2024