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

java.lang.invoke.MemberName information wrong for method handles created with findConstructor

    XMLWordPrintable

Details

    • b82
    • x86
    • linux

    Description

      The method MethodHandleNatives.getMethodName:
            static MemberName getMethodName(MethodHandle self) { ... }

      takes a method handle and returns a MemberName describing it. A MemberName should encode enough information to nominally recreate the method handle via Lookup.find{Virtual,Static,Constructor}, LDC, or reflection.

      If you create a method handle with Lookup.findConstructor:
          MethodHandle mh = MethodHandles.lookup().findConstructor(String.class,
                                MethodType.methodType(void.class, char[].class));
          MemberName mn = MethodHandleNatives.getMethodName(mh);

      you would expect the following results:
        mn.getName() => <init>
        mn.getDeclaringClass() => String.class
        mh.getMethodType() => (char[])String or (char[])V
        mh.isConstructor => true

      Instead, you get the following results:

        mn.getName() => identity
        mn.getDeclaringClass() => com.sun.invoke.util.ValueConversions
        mh.getMethodType() => (Object)Object
        mh.isConstructor => false

      Attachments

        Issue Links

          Activity

            People

              jrose John Rose
              briangoetz Brian Goetz
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: