Name: laC46010 Date: 06/25/99
It looks like new javac (jdk1.3-H) assumes that private fields are inherited by a subclass
and as result it fails to pass the following JCK-122 tests:
lang/ICLS/icls072/icls07204/icls07204.html
lang/CLSS/clss063/clss06302/clss06302.html
lang/NAME/name007/name00705/name00705.html
Note that these tests are based on examples from bug reports: 4097026, 4096353, 4122297.
Note also that oldjavac and javac-1.2 passes the tests successfully.
See sources and compiler outputs below.
------------------------------------------------------------------------------
// Ident: @(#)name00705.java 1.1 98/12/22
// Copyright 12/22/98 Sun Microsystems, Inc. All Rights Reserved
package javasoft.sqe.tests.lang.name007.name00705;
import java.io.PrintStream;
public class name00705 extends name00705a {
public static void main(String args[]) {
System.exit(run(args, System.out) + 95/*STATUS_TEMP*/);
}
public static int run(String args[],PrintStream out) {
java.lang.Long.toString(0);
return 0/*STATUS_PASSED*/;
}
}
class name00705a {
private int java;
}
-------------------------------- output --------------------------------------
lang/NAME/name007/name00705/name00705.java:15: variable java has private access in class javasoft.sqe.tests.lang.name007.name00705.name00705a
java.lang.Long.toString(0);
^
lang/NAME/name007/name00705/name00705.java:15: int cannot be dereferenced
java.lang.Long.toString(0);
^
2 errors
------------------------------------------------------------------------------
// Ident: @(#)icls07204.java 1.1 98/12/04
// Copyright 12/04/98 Sun Microsystems, Inc. All Rights Reserved
package javasoft.sqe.tests.lang.icls072.icls07204;
import java.io.PrintStream;
public class icls07204 {
public static void main(String argv[]) {
System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
}
public static int run(String argv[],PrintStream out) {
if (new icls07204().new IC().m())
return 2/*STATUS_FAILED*/;
return 0/*STATUS_PASSED*/;
}
Object p = new Object();
class IC extends SC {
boolean m() {
return (p == null);
}
}
}
class SC {
private Object p = null;
}
-------------------------------- output --------------------------------------
lang/ICLS/icls072/icls07204/icls07204.java:23: variable p has private access in class javasoft.sqe.tests.lang.icls072.icls07204.SC
return (p == null);
^
1 error
------------------------------------------------------------------------------
// Ident: @(#)clss06302.java 1.1 99/01/29
// Copyright 01/29/99 Sun Microsystems, Inc. All Rights Reserved
package javasoft.sqe.tests.lang.clss063.clss06302;
import java.io.PrintStream;
public class clss06302 {
private static int i = 1;
public static void main(String argv[]) {
System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
}
public static int run(String argv[],PrintStream out) {
clss06302c c = new clss06302c();
c.i = 0; // compile-time error
out.println("failed");
return 0/*STATUS_PASSED*/;
}
}
class clss06302c extends clss06302 {
}
-------------------------------- output --------------------------------------
The test is negative: compiler time error must be reported (see javac-1.2 output below)
but it isn't.
clss06302.java:17: No variable i defined in class javasoft.sqe.tests.lang.clss063.clss06302.clss06302c.
c.i = 0; // compile-time error
^
1 error
------------------------------------------------------------------------------
======================================================================
- duplicates
-
JDK-4240480 name00705.html: JLS6.3 private members should not be inherited from superclasses
- Closed