This message was deleted.
# feed
s
This message was deleted.
🧵 3
l
Are you looking for a description of what the bytecode means? Here is the official Oracle docs on JVM instructions: https://docs.oracle.com/javase/specs/jvms/se10/html/jvms-6.html#jvms-6.5
If I remember correctly: L4 defines a section of code on a given line. LINENUMBER 6 L4 indicates that this line is line 6 (useful for debugging) ILOAD 0 indicates that we should load the int in local variable 0 onto the stack IINC 0 1 says to increment the value of local variable 0 by 1 and store the result in local variable 0 ISTORE 0 says to store the value at the top of the stack into local variable 0
❤️ 1
The JVM is a Stack machine, meaning it performs operations on a stack (as opposed to registers like a normal CPU). It has a few slots called ‘local variables’ that are used for storing information in the short term. The JVM understands the instructions and either interprets them (very uncommon now) or Just In Time compiles the instructions to machine code.
❤️ 1
a
thanks, that's enough to understand it
but how intellij marking the value changed as not used
Copy code
num = num++ //The value changed at 'num++' is never used
v
You probably don't use
num
after that line
a
image.png
l
I once wrote a basic JVM (No allocation or anything, local variables and static function calls only) when I had a couple of days off from Uni. I've been meaning to rewrite one in Kotlin/Native.
👍 1
h
num++
is a postfix operator and increases
num
after the assignment.
Copy code
var num = 0
num = num++
println(num)
will print 0, because num (0) <=num (0) and then the operation num + 1 is executed, but the result is never used, the assignment is executed before the operation.
a
Please move a discussion to #getting-started or more specialized channel.
2
a
you can delete the thread if you need