0

i want to ask how i can write in bytecode, i need some example for sample things like make a function etc...

if someone can tell me how to write this code in bytecode i can mabey compare and learn from this.

how do i write this java code in bytecode ?

package Bytecode;

public class Main {

    public static void main(String[] args) {
        System.out.println(factorial(5));
    }

    public static int factorial(int value){
        if(value<=0 || value==1)
            return 1;

        return value*factorial(value-1);

    }
}
2
  • 1
    c the bytecode of the java code Commented Mar 2, 2014 at 8:07
  • 1
    See this question: [link] stackoverflow.com/questions/3150254/… Hope it's what you needed Commented Mar 2, 2014 at 8:14

3 Answers 3

3

You can check out Jasmin. From Wikipedia,

Some projects provide Java assemblers to enable writing Java bytecode by hand. Assembly code may be also generated by machine, for example by compiler targeting Java virtual machine. Notable Java assemblers include:

Jasmin, takes textual descriptions for Java classes, written in a simple assembly-like syntax using Java Virtual Machine instruction set and generates a Java class file.

Jamaica, a macro assembly language for the Java virtual machine. Java syntax is used for class or interface definition. Method bodies are specified using bytecode instructions.

Also you can see the byte code of ur class file using javap -c classname

Sign up to request clarification or add additional context in comments.

Comments

1

Here's a tutorial with examples for programming with Java bytecode that I wrote. Unfortunately I stopped due to lack of interest, but if you find it useful I can finish it.

Comments

0

You need a tool like this one http://commons.apache.org/proper/commons-bcel/manual.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.