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

Class.isAnonymousClass() returns false when class major number is 48.

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 8u20
    • Fix Version/s: tbd_major
    • Component/s: core-libs
    • Labels:

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_20"
      Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
      Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Linux debian 3.14-2-amd64 #1 SMP Debian 3.14.15-2 (2014-08-09) x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      Consider the following Java class:

      public class A {
        public static void main(String[] argv) {
          Object o = new Object () {
            public String toString() {
              return "abcd";
            }
          };
          System.out.println("obj is: "+ o.toString());

        }
      }

      You can compile it with:
      $ javac A.java
      in which case the major number of the class will be 51 or 51

      Or with
      $ javac -source 1.4 -target 1.4 A.java
      in which case the major number of the class will be 48

      Then consider the following class:
      public class Check {
        public static void main(String[] args) {
          boolean b = A$1.class.isAnonymousClass();
          System.out.println("isAnonymous: "+ b);
        }
      }

      isAnonymousClass() returns true, as expected, when the major version of the A$1 class is 51 or 52.
      However, it returns false when the major version of class A$1 is 48 which is wrong.
      There may be some subtleties with major version numbers. If so, please redirect me to the text in the specifications describing this.





      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      See Description.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Class.isAnonymousClass() should have returned true.
      ACTUAL -
      Class.isAnonymousClass() returned false on an anonymous class.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      See description.
      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated: