Questions tagged [invokevirtual]
9 questions
5
votes
3 answers
Java bytecode operation 'invokevirtual' does not keep consistency for the methods inherited by Object
I have following codes.
public class Parent {
@Override
public int hashCode() {
return 0;
}
}
public class Child extends Parent {
public void test() {
this.toString();
this.hashCode();
}
}
As you…

Hozard
- 193
- 2
- 9
3
votes
1 answer
what does # do after invokevirtual
For example if int-variables a and b are stored in local variables 1 and 2, this code would compute this.f(3+b*a). (this-pointer is stored in variable 0)
iload_1
aload_0
icons_3
iload_1
iload_1
imul
iadd
invokevirtual #4
for what does #4 stand…

user3630068
- 33
- 7
3
votes
2 answers
InvokeExact on the object, whose type is dynamically loaded by classloader
I have spend whole day on this problem. My problem is how to make an MethodHandle.invokeExact invocation on an instance, whose class type is dynamically loaded at program runtime. To make problem more clear, i show my sample code below:
Class>…

shijie xu
- 1,975
- 21
- 52
2
votes
1 answer
Java Bytecode: invokevirtual methodref on an objectref with a different class
I am currently looking into how Java bytecode works.
I created this simple test class:
class Main {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
With javap -c Main.class I can get its…

Tim Engbrocks
- 23
- 2
2
votes
2 answers
Java final methods uses static binding, but JVM uses "invokevirtual" instruction when compiled
Many books said that java final instance methods(not private) use static binding, and other instance methods(not private) use dynamic binding. However When compiled, both of them use "invokevirtual" JVM instruction. Do final methods and non final…

yufengwang
- 21
- 1
1
vote
2 answers
How does the JVM know how many values to pop into a new frame when invoking a method via invokevirtual?
When a method is called via invokevirtual, the calling method pops off the values to pass to the called method along with the objectref and places them in the new stack frame.
How does it know which stack entry is the objectref? My guess is that it…

platypusguy
- 435
- 1
- 5
- 7
0
votes
1 answer
Is there any reason for not invokevirtual and invokeinteface bytecode instruction into one?
Is there any reason for making the instruction to invoke non-static non-constructor method into two distinct instruction instead of one unified instruction, like invokeinstance? Does it has anything to do with some random internal JVM mechanism or…

glee8e
- 6,180
- 4
- 31
- 51
0
votes
2 answers
Attempt to invoke virtual method 'android.view.View android.view.Window.findViewById(int)' on a null object reference
Basically this app is supposed to ask for your name, with an option to save, which when click, an alert dialog pops up and asks 'are you sure?', when yes is clicked, it should say 'welcome + whatever name put'. my problem is that the app keeps…

Aria
- 389
- 3
- 7
- 25
0
votes
2 answers
Java asm get "this" object from method variables
I need to know the name of the object which called invokevirtual operation(in the following format - Objectname@object_id). Is it possible given only MethodInsnNode object? I know that it is stored with the index 0 in local variables but I don't…

Sergey
- 11,548
- 24
- 76
- 113