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

5.4.3.5: Which linkage errors are enforced by MethodHandle resolution?

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • None
    • specification
    • vm

      5.4.3.5 lists a few cases analogous to linkage errors that cause the MethodHandle to fail to resolve:
      - any failure of Class/Fieldref/Methodref resolution
      - Constraints on protected access
      - mismatch in the 'static' flag
      - '<init>' in a superclass

      But it doesn't mention other cases listed as causes of linkage errors in the corresponding instruction specs:
      - 'final' flag on putfield/putstatic
      - errors thrown by 'invokevirtual' of signature polymorphic VarHandle methods
      - 'new' on an interface or abstract class (<init> would fail to resolve anyway in the interface case...)
      - a number of specified *runtime exceptions* for invokespecial that could be checked at resolution time: abstract method, unsatisfied link for native method, conflicting default methods

      Some experimenting with MethodHandles.Lookup shows that, at least for that API, 'new' on an abstract class will resolve, but 'invokespecial' of an abstract method and 'putstatic' of a final field will not. (Specs for methods in that API should probably also be clarified.)

            dlsmith Dan Smith
            dlsmith Dan Smith
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: