-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
7, 8
Longstanding behavior of invokespecial in HotSpot is to produce an error if, for an invokespecial (other than <init>) the objectref on the stack is not an instanceof the current class.
---
Example (seeJDK-8009697):
public class A {
public void m() { System.out.println("A.m"); }
}
public class Test extends A {
public static void main(String[] args) {
new A
dup
invokespecial A/<init>()V
invokespecial A/m()V
}
}
Exception in thread "main" java.lang.VerifyError: Bad type on operand stack in method
---
I cannot find this specified. Possibilities:
- It's specified somewhere (perhaps 4.10, which I don't understand very well?), and there's no bug
- By virtue of being common practice, it should be added to the spec
- HotSpot is being too restrictive, and should change (this is not a bug,JDK-8009697 is)
Related rules in the spec:
- Per 4.9.2, invokespecial must name <init>, or a method in the current class or one of its supers
- Per 6.5-invokespecial, _protected_ methods have a restriction like this outside of their package
---
Example (see
public class A {
public void m() { System.out.println("A.m"); }
}
public class Test extends A {
public static void main(String[] args) {
new A
dup
invokespecial A/<init>()V
invokespecial A/m()V
}
}
Exception in thread "main" java.lang.VerifyError: Bad type on operand stack in method
---
I cannot find this specified. Possibilities:
- It's specified somewhere (perhaps 4.10, which I don't understand very well?), and there's no bug
- By virtue of being common practice, it should be added to the spec
- HotSpot is being too restrictive, and should change (this is not a bug,
Related rules in the spec:
- Per 4.9.2, invokespecial must name <init>, or a method in the current class or one of its supers
- Per 6.5-invokespecial, _protected_ methods have a restriction like this outside of their package
- blocks
-
JDK-8009697 invokespecial triggers surprising VerifyError
-
- Closed
-