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

No error on changing instanceMethod in the superclass to classMethod in subclass

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Incomplete
    • Affects Version/s: 7
    • Fix Version/s: None
    • Component/s: tools
    • Subcomponent:
    • CPU:
    • OS:

      Description

      FULL PRODUCT VERSION :
      java version "1.7.0_03"
      Java(TM) SE Runtime Environment (build 1.7.0_03-b05)
      Java HotSpot(TM) Client VM (build 22.1-b02, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Windows Vista Home Premium

      A DESCRIPTION OF THE PROBLEM :
      No compile time error is thrown on changing an instance method in superclass the to a class method in subclass.

      Basically this table in the Summary section of following link does not hold true anymore :-
      http://docs.oracle.com/javase/tutorial/java/IandI/override.html



      REGRESSION. Last worked in version 6u29

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1.create superclass with instance method.
      2.create subclass and override the instance method.
      3.change type of this method to static.
      4.try to compile.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      compile time error.
      ACTUAL -
      No compile time error.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package HidingAndOverriding;

      public class Animal {
          public static void testClassMethod() {
              System.out.println("The class" +
                  " method in Animal.");
          }
          public void testInstanceMethod() {
              System.out.println("The instance "
                  + " method in Animal.");
          }
      }


      package HidingAndOverriding;

      public class Cat extends Animal {
          public void testClassMethod() {
              System.out.println("The class method" +
                                 " in Cat.");
          }
          public static void testInstanceMethod() {
              System.out.println("The instance method" +
                                 " in Cat.");
          }

          public static void main(String[] args) {
              Cat myCat = new Cat();
              Animal myAnimal = myCat;
              Animal.testClassMethod();
              myAnimal.testInstanceMethod();
              new Animal().testInstanceMethod();
          }
      }

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

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: