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

Anonymous inner class is not final

    XMLWordPrintable

Details

    • Bug
    • Resolution: Not an Issue
    • P4
    • None
    • 8u45, 8u60, 9
    • tools
    • x86_64
    • windows_7

    Description

      FULL PRODUCT VERSION :
      java version "1.8.0_45"
      Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
      Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.1.7601]

      A DESCRIPTION OF THE PROBLEM :
      The Java compiler does not add "final" modifier to anonymous inner class whereas 15.9.5 of JLS requires this.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile and run the code from "Source code" field; check the console ouput.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Class is final: true
      ACTUAL -
      Class is final: false

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.lang.reflect.Modifier;

      public class TestClass {
          public static void main(String args[]) {
              Object o = new Object() { };
              System.out.println("Class is final: " + Modifier.isFinal(o.getClass().getModifiers()));
          }
      }

      ---------- END SOURCE ----------

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: