-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.4.0
-
generic
-
generic
Name: bsC130419 Date: 06/04/2001
java version "1.4.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b65)
Java HotSpot(TM) Client VM (build 1.4.0-beta-b65, mixed mode)
In an effort to fix bug 4030374, the compiler writers were overzealous, and
created a new bug with -target 1.4. Inner classes and polymorphic methods are
still broken, but now with a VerifyError instead of a NullPointerException.
class A {
int i;
abstract class B {
{ foo(); }
abstract void foo();
}
}
class C extends A {
int i;
public static void main(String[] args) {
new C().new D();
}
class D extends B {
int i;
void foo() {
System.out.println(C.super.i);
}
}
}
$ javac C.java
$ java C
Exception in thread "main" java.lang.NullPointerException
at C.access$001(C.java:38)
at C$D.foo(C.java:48)
at A$B.<init>(C.java:34)
at C$D.<init>(C.java:45)
at C.main(C.java:42)
$ javac -target 1.4 Foo.java
$ java C
Exception in thread "main" java.lang.VerifyError: (class: A$B, method: <init> si
gnature: (LA;)V) Expecting to find object/array on stack
at C.main(C.java:42)
$ javap -c A\$B
Compiled from Foo.java
abstract class A. B extends java.lang.Object
/* ACC_SUPER bit NOT set */
{
A.B(A);
abstract void foo();
}
Method A. B(A)
0 aload_0
1 aload_1
2 putfield #1 <Field A this$0>
5 aload_0
6 invokevirtual #2 <Method void foo()>
9 aload_0
10 invokespecial #3 <Method java.lang.Object()>
13 return
The culprit is the constructor in A.B. You correctly set this$0 before calling
the super-constructor (line 2), but then incorrectly call method foo() on an
uninitialized object (line 6) before calling the superconstructor (line 10).
The correct code should have lines 6 and 10 swapped.
(Review ID: 125766)
======================================================================
- duplicates
-
JDK-4416605 VM throws an error "java.lang.VerifyError" (-target 1.4 versus inner cls)
-
- Closed
-