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

MHs.Lookup.findConstructor returns handles for array classes

    Details

      Backports

        Description

        When passing an array class to MHs.Lookup.findConstructor(), that method will return a handle that, when invoked, creates an instance of Object. This is not in concordance with the bytecode behaviour rules for Lookup methods. Rather, a NoSuchMethodException should be thrown.

        A sample jshell session follows.

        -> import java.lang.invoke.*

        -> MethodHandle mh = MethodHandles.lookup().findConstructor(String[].class, MethodType.methodType(void.class));
        | Added variable mh of type MethodHandle with initial value MethodHandle()Object

        -> mh.invoke().getClass()
        | Expression value is: class java.lang.Object
        | assigned to temporary variable $3 of type Class<? extends Object>

        To round off the fix, and to provide more convenience, corresponding methods for array creation handle generation could be added to MethodHandles.

          Activity

          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/c0e1a94f27f5
          User: mhaupt
          Date: 2016-04-27 18:18:57 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/c0e1a94f27f5 User: mhaupt Date: 2016-04-27 18:18:57 +0000
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/c0e1a94f27f5
          User: lana
          Date: 2016-05-04 18:39:50 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/c0e1a94f27f5 User: lana Date: 2016-05-04 18:39:50 +0000

            People

            • Assignee:
              mhaupt Michael Haupt
              Reporter:
              mhaupt Michael Haupt
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: