-
Enhancement
-
Resolution: Unresolved
-
P4
-
None
-
6
-
Cause Known
-
generic
-
generic
Consider the example below. The error message is not actually wrong, but
a more helpful message would have suggested using Test.this.hashCode
instead.
$ cat -n Test.java 1 class Test {
2 class Inner {
3 public int hashCode() {
4 return Test.hashCode(null);
5 }
6 }
7 int hashCode(Object o) { return o.hashCode(); }
8 }
$ javac Test.java
Test.java:4: non-static method hashCode(java.lang.Object) cannot be referenced from a static context
return Test.hashCode(null);
^
1 error
###@###.### 10/28/04 02:48 GMT
a more helpful message would have suggested using Test.this.hashCode
instead.
$ cat -n Test.java 1 class Test {
2 class Inner {
3 public int hashCode() {
4 return Test.hashCode(null);
5 }
6 }
7 int hashCode(Object o) { return o.hashCode(); }
8 }
$ javac Test.java
Test.java:4: non-static method hashCode(java.lang.Object) cannot be referenced from a static context
return Test.hashCode(null);
^
1 error
###@###.### 10/28/04 02:48 GMT