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

JShell: NoSuchFieldError occurred due to accessing variables of intersection type inferred by `var`

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 10
    • tools
    • Fix Understood
    • 10
    • generic
    • generic

      bitter_fox@bitterfox-MacBookPro% ~/bin/jdk-10/bin/jshell -J-Duser.language=en
      | Welcome to JShell -- Version 10
      | For an introduction type: /help intro

      jshell> <Z extends Runnable & CharSequence> Z get1() { return null; }
      | created method get1()

      jshell> var z = get1()
      z ==> null

      jshell> z.run()
      | java.lang.NoSuchFieldError thrown: z
      | at (#3:1)

      jshell> void m() {z.run();}
      | created method m()

      jshell> m()
      | java.lang.NoSuchFieldError thrown: z
      | at m (#4:1)
      | at (#5:1)

      jshell>

      Examples above are based on VariablesTest#lvti, but the testing is not completeness.

            jlahoda Jan Lahoda
            shinyafox Shinya Yoshida
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: