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

javac's error messages are not appropriate for a private field.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • None
    • 1.2.0
    • tools
    • sparc
    • solaris_2.5.1



      Name: clC74495 Date: 03/24/98


      (1) About the test program TP1 below:

      Since "java" as a field of class S is private, it cannot be referenced
      from class C. Consequently, "java" of "java.lang.System...." should
      be interpreted as a package name, not as a field of class S.

      ======TP1======
      1 class C extends S {
      2 void f(){
      3 java.lang.System.out.println("foo");
      4 }
      5 }
      6
      7 class S {
      8 private int java;
      9 }
      ======
      % javac C.java
      C.java:3: Variable java in class S not accessible from class C.
              java.lang.System.out.println("foo");
              ^
      C.java:3: Attempt to reference field lang in a int.
              java.lang.System.out.println("foo");
                  ^
      2 errors
      ======

      -----------------------------------
      (2) About the test program TP2 below:

      Java's users cannot know private field names of the API core
      library. However, for example, "table" is a private field of
      java.util.Hashtable, and when users define "table" as a private
      field of a user-defined class, an error message occurs that
      should not occur.
      ======TP2======
      1 class A {
      2 int table;
      3 int table1;
      4 class MyHashtable extends java.util.Hashtable {
      5 int i = table; // NG
      6 int j = table1; // OK
      7 }
      8 }
      ======
      % javac A.java
      A.java:5: Variable table in class java.util.Hashtable not accessible from inner class A. MyHashtable.
              int i = table; // NG
                      ^
      A.java:5: Incompatible type for Identifier. Can't convert java.util.HashtableEntry[] to int.
              int i = table; // NG
                      ^
      2 errors
      ======

      ===============================================================
      Carlos.Lucasius@Canada (Mar 24, 1998):

      Verified that the reported errors occur for both test programs
      (TP1 and TP2). See also: 4053724

      (Review ID: 27060)
      ======================================================================

            iris Iris Clark
            clucasius Carlos Lucasius (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: