Questions tagged [bytecode]

"bytecode" is a blanket term for opcodes that are consumed by a virtual machine. For example, the JVM runs bytecode stored in .class files and the CPython interpreter runs bytecode stored in .pyc files.

Bytecode, also known as p-code (portable code), is a form of instruction set designed for efficient execution by a software interpreter. Unlike human-readable source code, bytecodes are compact numeric codes, constants, and references (normally numeric addresses) which encode the result of parsing and semantic analysis of things like type, scope, and nesting depths of program objects. They therefore allow much better performance than direct interpretation of source code.

The name bytecode stems from instruction sets which have one-byte opcodes followed by optional parameters. Intermediate representations such as bytecode may be output by programming language implementations to ease interpretation, or it may be used to reduce hardware and operating system dependence by allowing the same code to run on different platforms. Bytecode may often be either directly executed on a virtual machine (i.e. interpreter), or it may be further compiled into machine code for better performance.

Since bytecode instructions are processed by software, they may be arbitrarily complex, but are nonetheless often akin to traditional hardware instructions; virtual stack machines are the most common, but virtual register machines have also been built. Different parts may often be stored in separate files, similar to object modules, but dynamically loaded during execution.

Source: Wikipedia (Bytecode)

Understanding bytecode makes you a better programmer https://www.ibm.com/developerworks/ibm/library/it-haggar_bytecode/

2276 questions
1
vote
1 answer

Inlining tryCatchBlock results in Current frame's stack size doesn't match stackmap exception

I am using ASM to inline body of Callee::calcualte(int,int)int, which contains a try-catch block, to the Caller::test method. The generated bytecode seems OK but verification fails due to Exception: Exception in thread "main" java.lang.VerifyError:…
shijie xu
  • 1,975
  • 21
  • 52
1
vote
1 answer

Why javac sometimes creates unnecessary copies of variables?

I have code looks like this: boolean[] array = new boolean[200]; int[] indexes = {10, 42, 62, 74}; while(true) { //some code here StringBuilder sb = new StringBuilder(); for (int j : indexes) { sb.append(array[j] ? '1' : '0'); …
saroff
  • 688
  • 9
  • 20
1
vote
1 answer

ByteBuddy fails when trying to redefine sun.reflect.GeneratedMethodAccessor1

Driven by curiosity, I tried to export the bytecode of GeneratedMethodAccessor1 (generated by the JVM when using reflection). I try to get the bytecode of the class the following way: public class MethodExtractor { public static void…
reegnz
  • 837
  • 9
  • 16
1
vote
1 answer

Taintflow analysis in dotnet

I want to do taint flow analysis in dotnet bytecode. I want to find all the tainted sources in the given dotnet bytecode and then all the program points affected by these tainted sources in it. I want to do static analysis of dotnet bytecode but I…
ashishk
  • 299
  • 1
  • 3
  • 17
1
vote
1 answer

Why not sending JavaScript files in browser-specific bytecode?

There is no universal bytecode for JavaScript, but most JavaScript engines have their own bytecode. Since JavaScript files travel as source code string, they have to parse/compile source code string into bytecode at before execution. However, as we…
jray319
  • 31
  • 4
1
vote
2 answers

I am trying to learn java asm framework for bytecode instrumentation but not able to find sufficient docs or tutorials on it

I am trying to learn java asm framework for bytecode instrumentation but not able to find sufficient docs or tutorials on it. I have studied about ClassReader, ClassWriter and ClassVisitor and some more alike APIs but not very clear about how to…
Shubham Chaurasia
  • 2,472
  • 2
  • 15
  • 22
1
vote
1 answer

Different Java bytecode decompile to exactly the same p-code and java code

I have generated two java bytecode files 1.class and 2.class, they are different if using hex file viewer inspect them: However the decompiled p-code are all the same: 1.class -> 1.java 2.class -> 2.java I can also use jd-gui to decompile them…
Gelin Luo
  • 14,035
  • 27
  • 86
  • 139
1
vote
1 answer

Compile java source from string to bytecode in byte array using janino

How can I use the janino compiler to compile a simple java source from string to bytecode in byte array? I have so far been trying to make sense of the janino documentation here (under SimpleCompiler) and here on how to go about compiling one…
Mr. Developerdude
  • 9,118
  • 10
  • 57
  • 95
1
vote
2 answers

Why there are JVM instructions `monitorenter/monitorexit` but no `wait/notifyAll` (they are native calls)?

When we write synchronized(some_object){} we can see two JVM instructions monitorenter/monitorexit issued as the byte code. When we write synchronized(some_object){some_object.wait()} i would expect to see special JVM instructions like wait, but…
Ayrat
  • 1,221
  • 1
  • 18
  • 36
1
vote
1 answer

Determine if last parameter is used

I'm using the ASM library and trying to figure out how it gets its numbering and how to determine whether or not the last parameter is used.. What I did so far was: Collection classes = readJar("..."); for (ClassNode c : classes) { …
Brandon
  • 22,723
  • 11
  • 93
  • 186
1
vote
1 answer

How can the JVM determine if a stack entry is an int or a long

Almost all bytecodes know the type of their operands to be found on the stack at runtime, the bytecode verifier will have checked that only these types will actually be found at runtime (for every path) so the interpreter can just go ahead poping…
1
vote
1 answer

transmit a java.lang.reflect.Proxy over a network

Is there a convenient way to transmit an object including its code (the class) over a network (not just the instance data)? Don't ask me why I want to do this. It's in an assignment. I asked several times if that is really what they meant and the…
panzi
  • 7,517
  • 5
  • 42
  • 54
1
vote
2 answers

Cross JVM instrumentation

I'm spending sometime with DynaTrace. I'm impressed by its feature related to cross jvm instrumentation. In simple words, DynaTrace is able to instrument Java code creating trace with some statistical information. This is nothing new. There is a…
DocJava
  • 11
  • 4
1
vote
1 answer

Java ASM Opcodes: "H_" prefixed mnemonics (e.g. Opcodes.H_GETFIELD vs. Opcodes.GETFIELD)

I'm using the ASM Framework for java bytecode manipulations. Some of the opcode-mnemonics existing twice in ASM, they are prefixed with "H_": Opcodes.H_GETFIELD vs. Opcodes.GETFIELD Opcodes.H_GETSTATIC vs.…
svema
  • 35
  • 6
1
vote
1 answer

Odd Bytecodes from Groovy CompileStatic

I'm seeing some strange results when i view the bytecode for a Groovy Script that was compiled with @groovy.transform.CompileStatic Here is the simplest class that duplicates the problem: @groovy.transform.CompileStatic class ScriptTestClass{ …
user1680772
  • 143
  • 2
  • 7
1 2 3
99
100