Skip to content
Advertisement

Tag: jvm-bytecode

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 produce bytecode with this instruction? What are its potential use cases? Answer For example, the following code compiles to See,

I don’t understand this opcode in JVM Implementation

I am writing a JVM. I was implementing all opcodes one by one, until I faced dup2. The oracle instruction set https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-6.html#jvms-6.5.dup2 says Duplicate the top one or two values on the operand stack and push the duplicated value or values back onto the operand stack in the original order How am I supposed to choose which operation to perform?

Forge 1.12.2 Coremodding: java.lang.StringIndexOutOfBoundsException

I try to make a coremod on 1.12.2 Forge in order to patch some missing stuff in the Lost Cities mod. (Source: https://github.com/McJtyMods/LostCities/blob/1.12/src/main/java/mcjty/lostcities/dimensions/world/lost/BuildingInfo.java) A friend and I have written this LostCitiesClassTransformer.java: (Full source: https://github.com/Nick1st/LCPatches) The original code I want to patch (Bytecode Outline): The Bytecode Outline containing my changes: The stacktrace I get: Why do I monkey-patch a open-source mod?

Forge 1.12.2 Coremodding: java.lang.ClassCircularityError

I try to make a coremod on 1.12.2 Forge in order to patch some missing stuff in the Lost Cities mod. (Source: https://github.com/McJtyMods/LostCities/blob/1.12/src/main/java/mcjty/lostcities/dimensions/world/lost/BuildingInfo.java) A friend and I have written this LostCitiesClassTransformer.java: The original code we want to patch (Bytecode Outline): The Bytecode Outline containing our fix: The Stacktrace we get: What we tried: We tried to get the building using

Invokedynamic with non-static context

I learnt that invokedynamic instruction of bytecode calls a static method representation of lambda. Please let me know if that is incorrect. if correct, then how is below code working? Answer It’s not correct to say that lambda expressions were always compiled to a static method. It’s not specified, how they are compiled, which leaves room for two different strategies

short -> int -> long type promotion: is there any overhead?

If, for example, I define method’s return type/parameter as char, but both the caller and implementation actually immediately use it as an int, is there any overhead? If I understand correctly, the values on the stack are 32-bits aligned anyway, as are the ‘registers’ (I’m sorry, I’m not well versed in the byte code). A word of explanation: I am

Advertisement