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

rfe: same variable det in sub and superclass. need warnings.

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 1.1.4
    • tools
    • x86
    • windows_nt



      Name: joT67522 Date: 01/08/98


      compile (w/o warnings ?!?) and run:
      class tempSuper{
       String s = "in super";
       String S() { return s;}
      }

      public class temp extends tempSuper{
       String s = "in sub"; // double def of superclass var
       String A() { return s;}
       String SA() { return super.s;}

      // run it

       public static void main( String a[]){
        temp t = new temp();
        tempSuper tSuper = t, tSS;
        System.out.println(
          "\n" + t.S() + // prints "in super"
          "\n" + t.A() + // prints "in sub"
          "\n" + t.SA() + // prints "in super"
          "\n" + tSuper.S() + // prints "in super"
          "\n" + ((temp) tSuper).A()); // prints "in sub"
        System.out.println(
          "\n" + t.s + // prints "in sub"
          "\n" + tSuper.s + // prints "in super"
          "\n" + ((temp) tSuper).s); // prints "in sub"
        }
      }
      ---------------
      It is confusing for beginners in Java.
      We are reengenering 12,000,000 lines code
      into Java with special translators writen by me
      and there are "classes" by 20-30,000 lines.

      In future development we need about 200 programmers
      to be trained to work with this code. They will
      create new functions and can easely define some
      new dynamic variables which has a same name as
      one in superclass used by some method in
      a 25,000,000-lines big subclass.

      There will not be even a warning by javac about
      possible missuse of redefinition of supers vars.
      Old methods will stop to work. Some new methods
      in superclass will not be able to see
      changes because var was also defined in subclass.

      Do You can put some -v flag to get more
      error/warnings message out from compiler?

      I tryed to use private, protected, final etc
      to protect code, but without any succes. There
      are no mechanism in Java syntax to do it.
      (Review ID: 22384)
      ======================================================================

            dstoutamsunw David Stoutamire (Inactive)
            johsunw Joon Oh (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: