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

private method in a final class

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.3.0
    • tools
    • x86
    • windows_2000



      Name: boT120536 Date: 11/06/2000


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

      If you compile and run the following program it indicates that the value of the
      modifiers on method m is 2 and om is zero indicating that the method m is
      private and method pm has default access, however the JLS (2nd Ed) on page 172
      section 8.4.3.3 states that a Private method and all methods declared in a
      final class are implicitly final ......

      This would appear to indicate that the modifier values for m should be 0x12 and
      0x10 for pm.


      import java.lang.reflect.*;

      final class fc
      {

      private int m(){ return 1;}

      private class Inner {
      int pm(){ return 20;}
      }


      public static void main(String argv[])
      {

      try {
      Class cx = fc.class;
      java.lang.reflect.Method mt = cx.getDeclaredMethod("m",
      null);
      System.out.println("Modifiers for m are "+
      mt.getModifiers());

      cx = Inner.class;
      mt = cx.getDeclaredMethod("pm", null);
      System.out.println("Modifiers for pm are "+
      mt.getModifiers());

      }catch(Exception e) {
      e.printStackTrace();
      }

      }

      }
      (Review ID: 111557)
      ======================================================================

            gafter Neal Gafter (Inactive)
            bonealsunw Bret O'neal (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: