-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.1.4, 1.2.0
-
generic
-
generic
allan.jacobs@Eng 1997-10-13
A method extends a superclass in another package and a superinterface.
The superclass and the superinterface both define a field with the
same name. The instance in the superclass has default access so it
is not inherited by the (main) subclass. Yet, the two field
declarations create an ambiguity that javac cannot handle.
Discovered with Modena test c0814703.
algol% cat ambig2.java
import Spack.S;
interface I {
int i=1;
}
// public class S {
// int i=-1;
// int getI(){ return i; }
// void setI( int j ){ i=j; }
// }
public class Ambig2 extends S{
public static void main( String[] argv ) {
Ambig2 a = new Ambig2();
System.out.println(a.i);
}
}
algol% cat S.java
package Spack;
public class S {
int i=-1;
int getI(){ return i; }
void setI( int j ){ i=j; }
}
algol% setenv CLASSPATH .
algol% java -fullversion
java full version "1.1.4n:1997.09.11"
algol% javac -d . S.java
algol% javac -d . Ambig2.java
Ambig2.java:15: Variable i in class Ambig2 not accessible from class Ambig2.
System.out.println(a.i);
^
1 error
- duplicates
-
JDK-4053724 reports non-ambiguous field access as ambiguous
-
- Closed
-