MethodHandles.constant(...) throws undocumented NPE

XMLWordPrintable

    • Type: Sub-task
    • Resolution: Unresolved
    • Priority: P4
    • None
    • Affects Version/s: 8
    • Component/s: core-libs
    • None

      When calling MethodHandles.constant(...) with a primitive type and a null value (e.g. MethodHandles.constant(int.class, null)), a NullPointerException is thrown.

      However, the specification says:

      @throws NullPointerException if the {@code type} argument is null

      and

      @throws ClassCastException if the value cannot be converted to the required return type

      So, either the specification should be changed to include this scenario in the throws NPE case, or the implementation should be changed to throw a CCE instead.

            Assignee:
            Unassigned
            Reporter:
            Hannes Greule
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: