ces
Name: boT120536 Date: 03/20/2001
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)
When a sub class' inner class calls super, the virtual machine throws a
NoSuchMethodException. Here's the scenario.
=================== In file A.java =====================
public class A {
pubilc void init() {
System.out.println("I'm here");
}
}
=================== In file B.java =====================
public class B extends A {
private Y y;
public B() {
y = new Y();
}
protected interface X {
public void init();
}
protected class Y implements X {
public void init() {
B.super.init();
}
}
public void init() {
y.init();
}
public static void main(String[] args) {
B me = new B();
me.init();
}
}
=================
Then compile with:
javac -target 1.3 A.java B.java
Then attempt to run with:
java B
You will get:
Exception in thread "main" java.lang.NoSuchMethodError
at B$Y.init(B.java:14)
at B.init(B.java:19)
at B.main(B.java:25)
javac for 1.3 will compile this without any complaints. java will then throw a
NoSuchMethodException when it is run and B.one() is called
(Review ID: 118920)
======================================================================
Name: boT120536 Date: 03/20/2001
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)
When a sub class' inner class calls super, the virtual machine throws a
NoSuchMethodException. Here's the scenario.
=================== In file A.java =====================
public class A {
pubilc void init() {
System.out.println("I'm here");
}
}
=================== In file B.java =====================
public class B extends A {
private Y y;
public B() {
y = new Y();
}
protected interface X {
public void init();
}
protected class Y implements X {
public void init() {
B.super.init();
}
}
public void init() {
y.init();
}
public static void main(String[] args) {
B me = new B();
me.init();
}
}
=================
Then compile with:
javac -target 1.3 A.java B.java
Then attempt to run with:
java B
You will get:
Exception in thread "main" java.lang.NoSuchMethodError
at B$Y.init(B.java:14)
at B.init(B.java:19)
at B.main(B.java:25)
javac for 1.3 will compile this without any complaints. java will then throw a
NoSuchMethodException when it is run and B.one() is called
(Review ID: 118920)
======================================================================
- duplicates
-
JDK-4401977 javac -target 1.2 produces bad access method calls
- Closed