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

HotSpot fails to wrap Exceptions from invokedynamic in a BootstrapMethodError

XMLWordPrintable

    • b67

        Observed behaviour:
        java.lang.IllegalAccessError: tried to access method C.m()V from class Exec
        at java.lang.invoke.MethodHandleNatives.resolve(Native Method)
        at java.lang.invoke.MemberName$Factory.resolve(MemberName.java:965)
        at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:990)
        at java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:1385)
        at java.lang.invoke.MethodHandles$Lookup.linkMethodHandleConstant(MethodHandles.java:1726)
        at java.lang.invoke.MethodHandleNatives.linkMethodHandleConstant(MethodHandleNatives.java:442)
        at Exec.invokeRef(Exec.java:4)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at Runner.run(Runner.java:15)
        at Runner.main(Runner.java:4)

        Expected behaviour:
        java.lang.BootstrapMethodError: java.lang.IllegalAccessError: tried to access method C.m()V from class Exec
        at Exec.invokeRef(Exec.java:4)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at Runner.run(Runner.java:15)
        at Runner.main(Runner.java:4)
        Caused by: java.lang.IllegalAccessError: tried to access method C.m()V from class Exec
        at java.lang.invoke.MethodHandleNatives.resolve(Native Method)
        at java.lang.invoke.MemberName$Factory.resolve(MemberName.java:965)
        at java.lang.invoke.MemberName$Factory.resolveOrFail(MemberName.java:990)
        at java.lang.invoke.MethodHandles$Lookup.resolveOrFail(MethodHandles.java:1385)
        at java.lang.invoke.MethodHandles$Lookup.linkMethodHandleConstant(MethodHandles.java:1726)
        at java.lang.invoke.MethodHandleNatives.linkMethodHandleConstant(MethodHandleNatives.java:442)


        From the JVM specification section 6.5. Invokedynamic:

        Linking Exceptions

        If resolution of the symbolic reference to the call site specifier throws an exception E, the invokedynamic instruction throws a BootstrapMethodError that wraps E.

        Otherwise, during the continuing resolution of the call site specifier, if invocation of the bootstrap method completes abruptly (§2.6.5) because of a throw of exception E, the invokedynamic instruction throws a BootstrapMethodError that wraps E. (This can occur if the bootstrap method has the wrong arity, parameter type, or return type, causing java.lang.invoke.MethodHandle . invoke to throw java.lang.invoke.WrongMethodTypeException.)

        Otherwise, during the continuing resolution of the call site specifier, if the result from the bootstrap method invocation is not a reference to an instance of java.lang.invoke.CallSite, the invokedynamic instruction throws a BootstrapMethodError.

        Otherwise, during the continuing resolution of the call site specifier, if the type descriptor of the target of the call site object is not semantically equal to the method descriptor in the call site specifier, the invokedynamic instruction throws a BootstrapMethodError.

              aeriksso Andreas Eriksson (Inactive)
              shadowbug Shadow Bug
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: