Community
Participate
Working Groups
With Compiler/JDK Compliance/Compiler compliance level 1.4 get NullPointerException in following system. On any other level everything works fine. Interface A { int hashCode(); } Interface B extends A {} Class C implements B { int hashCode() { return super.hashCode(); } } Then I create object of class C and call hashCode() on it when object is typecasted to different classes. Object -> OK A -> OK B -> NullPointerException C -> OK Also tested exatly same with test() method declared in A, everything was OK. Then same with toString -> in case B again got NullPointerException. I have classes that show this error and can post them if requested.
I cannot reproduce with the following test case: interface A { int hashCode(); } interface B extends A { } class C implements B { public int hashCode(){ return super.hashCode(); } } public class Test { public static void main(String[] arguments) { C c = new C(); System.out.println("((A)c).hashCode() : "+ ((A)c).hashCode()); System.out.println("((B)c).hashCode() : "+ ((B)c).hashCode()); System.out.println("((C)c).hashCode() : "+ ((C)c).hashCode()); } } Can you provide exact test case ? It seems to depend on the fact that an Object method is involved, but I need exact case.
Created attachment 2138 [details] JAR containing class and java files for test case that showed error.
Tried your test case, works fine either in latest 2.1 integration build or 2.0.2: Object: 16032330 Object.toString(): C.toString() Interface A.test(): 16032330 Interface A.toString(): C.toString() Interface A.hashCode(): 16032330 Interface B.test(): 16032330 Interface B.hashCode(): 16032330 Interface B.toString(): C.toString() Class C.test():16032330 Class C.hashCode():16032330 Class C.toString(): C.toString()
Couldn't reproduce it either on 2.0.1. Could this be a VM bug ? Which JRE are you using. I am using Sun JDK 1.4.1 b18 (b14 had numerous issues on this front).
Installed Sun's SDK 1.4.1 and error was gone. When compiling with Eclipse and running 1.4.0 (01 and 02) it doesn't work. When compiling with normal 1.4.0 everything works. When compiling with Eclipse and running 1.4.1 it works.
Ok, then closing as VM bug.