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

methods inherited from non-public super class are volatile

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P5
    • Resolution: Not an Issue
    • Affects Version/s: 6u21
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:

      Description

      FULL PRODUCT VERSION :
      java version "1.6.0_11"
      Java(TM) SE Runtime Environment (build 1.6.0_11-b03)
      Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode, sharing)
      1.6.0_21-b07

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      If a class extends a non-public super class, the methods inherited will be volatile, and the getDeclaringClass() of such methods will be subclass, not superclass.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      compile the java files: javac *.java
      then run Child: java Child

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      public static void Child.main(java.lang.String[]), declaring class is class Child
      public int Father.getID(), declaring class is class Father
      ACTUAL -
      public static void Child.main(java.lang.String[]), declaring class is class Child
      public int Child.getID(), declaring class is class Child
              isVolatile

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Father.java:
      class Father {
        protected int id;

        public int getID() {
          return id;
        }

      }

      Child.java:
      import java.lang.reflect.Method;
      import java.lang.reflect.Modifier;

      public class Child extends Father {
        public static void main(String[] args) {
          Method[] ms = Child.class.getMethods();
          for (Method m : ms) {
            if (!m.getDeclaringClass().equals(Object.class)) {
              String oo = m.toString();
              System.out.println(oo);

              if (Modifier.isVolatile(m.getModifiers())) {
                System.out.println("\tisVolatile, and its declaring class is "
                  + m.getDeclaringClass());
              }
            }

          }
        }

      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      make superclass public. Then run Child can get the expected result.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                darcy Joe Darcy
                Reporter:
                ndcosta Nelson Dcosta (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: