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

JShell anonymous class has incorrect reflection properties

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 20
    • tools
    • None

      An anonymous class appearing in JShell is rewritten to something that gets interpreted as a member class:

      jshell> new Object(){}.getClass()
      $1 ==> class $0

      jshell> $1.isAnonymousClass()
      $2 ==> false

      jshell> $1.isLocalClass()
      $3 ==> false

      jshell> $1.isMemberClass()
      $4 ==> true

      This affects the behavior of other methods like 'getSimpleName' and 'getCanonicalName'.

      I don't know the translation strategy, but perhaps it could be adjusted to give javac a true anonymous class?

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

              Created:
              Updated: