Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8335060

ClassCastException after JDK-8294960

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 24
    • 24
    • core-libs
    • None

      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)

            asotona Adam Sotona
            jeisl Josef Eisl
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: