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

JShell: Intersection types cause NoSuchFieldError

    XMLWordPrintable

Details

    • 9
    • b08
    • x86_64
    • generic
    • Verified

    Description

      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


      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: