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

JShell: Intersection types cause NoSuchFieldError

    Details

    • Subcomponent:
    • Introduced In Version:
      9
    • CPU:
      x86_64
    • OS:
      generic

      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

          Activity

            People

            • Assignee:
              rfield Robert Field
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: