JDK-7044591 : MethodHandle.asCollector throws undocumented NPE
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang.invoke
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2011-05-13
  • Updated: 2012-03-22
  • Resolved: 2011-05-14
Related Reports
Duplicate :  
Description
Please see the minimized test below to reproduce the issue.

Minimized test:
===============
$ cat test.java
import java.lang.invoke.*;
import java.util.Arrays;

public class test {
    public static void main(String[] args) throws Throwable {
        MethodHandle dts = MethodHandles.publicLookup().findStatic(
                Arrays.class,
                "deepToString",
                MethodType.methodType(String.class, Object[].class));
        dts.asCollector((Class) null, 1);
    }
}

Minimized test output:
======================
$ java -version
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b142)
Java HotSpot(TM) Server VM (build 21.0-b12, mixed mode)

$ java -verify test
Exception in thread "main" java.lang.NullPointerException
        at java.lang.invoke.MethodHandle.asCollector(MethodHandle.java:783)
        at test.main(test.java:10)

If the behaviour just need to be documented in javadoc then please feel free to close this CR as duplicate of 7032323.

Comments
EVALUATION Correct behavior. Have covered it in 7032323.
14-05-2011