JShell: Intersection types cause NoSuchFieldError

XMLWordPrintable

    • 9
    • b08
    • x86_64
    • generic
    • Verified

      A DESCRIPTION OF THE PROBLEM :
      The JShell allows us to create a variable of an intersection type. However, we aren't able to use it because it throws NoSuchFieldError.

      The example using both Runnable and Serializable is the minimal case. It won't work with any other interface, though.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      JShell:
      ```
      jshell> var test = (Serializable & Runnable) () -> {};
      test ==> $Lambda$26/0x0000000800ba4248@5910e440

      jshell> test
      | Exception java.lang.NoSuchFieldError: test
      | at (#2:1)

      jshell> test.toString()
      | Exception java.lang.NoSuchFieldError: test
      | at (#3:1)

      ```

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Not get NoSuchFieldError
      ACTUAL -
      NoSuchFieldError is thrown

      FREQUENCY : always


            Assignee:
            Robert Field (Inactive)
            Reporter:
            Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: