Questions about the JVM .class bytecode format or instruction set.
Questions tagged [jvm-bytecode]
188 questions
4
votes
2 answers
Why interface Member from Java 1.0.2 does not have ACC_ABSTRACT set?
I've written a simple Java bytecode parser to do some experimentation and recently it failed in an unexpected place. While reading java/lang/reflect/Member.java from Java 1.1.8.16's rt.jar, my parser got mad because Member starts out like so (note…

0xbe5077ed
- 4,565
- 6
- 35
- 77
4
votes
2 answers
ClassWriter COMPUTE_FRAMES in ASM
I've been trying to understand how stack map frames work in Java by playing around with jumps in ASM. I created a simple method to try some things out: (disassembled with Krakatau):
L0: ldc 'hello'
L2: astore_1
L3: …

konsolas
- 1,041
- 11
- 24
4
votes
1 answer
Unsed local variables Java 8 - java.lang.VerifyError: Inconsistent stackmap frames
I have recently upgraded my project to Java 1.8 from 1.7.
I get an exception for inconsistent stackmap for a method in one of my Classes.
Initializing some unassigned local variables in the method resolved it, but can somebody please explain why…

Rk R Bairi
- 1,289
- 7
- 15
- 39
4
votes
1 answer
What does AOT instrumentation mean?
I know what bytecode instrumentation is. It is simply changing .class files bytecodes during runtime, which seems to be available since JDK 1.5. However, it's said to be during class loading not exactly runtime.
Now my question is, what is AOT or…

Alireza Mohamadi
- 751
- 1
- 6
- 22
4
votes
2 answers
Can a Synchronized Block be simplified to a Try-Finally Block on the Bytecode Level?
Writing my own compiler for a Java-like language, I am having trouble compiling synchronized blocks. I come up with the following idea to simplify them to try-finally blocks:
synchonized (obj) {
statements...
}
Can be replaced with
Object…

Clashsoft
- 11,553
- 5
- 40
- 79
3
votes
0 answers
What bytecode will Kotlin compiller produce if jvmToolchain is set to 11 and jvmTarget to 1.8?
I have a Kotlin project that I want to compile to Java 1.8 bytecode so that it could also be used on Android as well. I use the com.vanniktech.maven.publish Gradle plugin to publish the library to Maven Central. This plugin works only when I set…

Sasha Shpota
- 9,436
- 14
- 75
- 148
3
votes
1 answer
How to resolve SwitchTree Expression type in Java Annotation Processor?
Let's consider the following code:
switch ( switchTreeExpression ) {
cases
}
I want to find out, what type for switchTreeExpression is .
I have the following code draft:
...
MethodTree methodTree =…

Denis
- 3,595
- 12
- 52
- 86
3
votes
1 answer
What is the use of the "dup2_x2" instruction in JVM bytecode?
Java has a dup2_x2 instruction which, according to the documentation, has the following behavior:
Duplicate the top one or two values on the operand stack and insert the duplicated values, in the original order, into the operand stack.
Does javac…

fxshlein
- 83
- 1
- 5
3
votes
1 answer
How JVM knows line numbers during runtime?
When a .java file is compiled, it produces a .class file containing bytecode. JVM takes that bytecode and executes it. Byte during this step, if an exception is thrown, there is also a mention of in which line did this error occurred in source code.…

Sourav Kannantha B
- 2,860
- 1
- 11
- 35
3
votes
1 answer
What is the role of operand stack in JVM?
JVM Run-time Data Areas separate stack for each method being executed. It contains operand stack and local variables. Every time you load a variable, you need to const to the operand stack and then store to the local variables. Why not directly…

jiangyongbing24
- 55
- 4
3
votes
1 answer
Where is the reference to the lambda function?
I'm trying to understand exactly how lambdas and higher order functions work at the JVM level in modern Java. I wrote this simple test class:
public final class Main {
public static void main(String[] args) {
var s = new Object[] { 1.0,…

rwallace
- 31,405
- 40
- 123
- 242
3
votes
1 answer
Which Java code generates Wide instruction
I am creating a JVM and trying to understand the bytecode instructions. I am trying to write java code that when compiled generates a .class file with wide instruction. Which java code would generate that kind of extended instruction? I am a little…

Skalwalker
- 299
- 3
- 23
3
votes
1 answer
Why are there differences in the executed bytecode of a java program logged with -XX:TraceBytecodes
I'm trying to understand how the java interpreter works.
To see exactly what bytecodes are executed i build myself a jdk fastdebug build and used the -XX:+TraceBytecodes option.
Additionally i turned off the JIT-Compiler with -XX:-UseCompiler.
My…

Neintanke
- 85
- 5
3
votes
1 answer
JVM INVOKESPECIAL private constructor with ASM
I'm using ASM to generate some bytecode and execute it dinamically.
But there is a case where I need to invoke a private constructor, but i cound't figure out how. I know it is possible to invoke private constructor throug reflection…

Guilherme Pohlmann
- 63
- 4
3
votes
2 answers
Why Kotlin decompiler generates null.INSTANCE
I am trying to understand few of the Kotlin features by checking how it looks in Java side.
So as an experiment, I tried with this:
val printKotlin = fun () {
print("Hello Kotlin")
}
So the output for the above snippet is:
public final class…

Chandra Sekhar
- 18,914
- 16
- 84
- 125