Questions tagged [jasmin]

Jasmin is an assembler for the Java Virtual Machine. It takes ASCII descriptions of Java classes, written in a simple assembler-like syntax using the Java Virtual Machine instruction set. It converts them into binary Java class files, suitable for loading by a Java runtime system.

Jasmin is an assembler for the Java Virtual Machine. It takes ASCII descriptions of Java classes, written in a simple assembler-like syntax using the Java Virtual Machine instruction set. It converts them into binary Java class files, suitable for loading by a Java runtime system.

Jasmin was originally created as a companion to the book "Java Virtual Machine", written by Jon Meyer and Troy Downing and published by O'Reilly Associates. Since then, it has become the de-facto standard assembly format for Java. It is used in dozens of compiler classes throughout the world, and has been ported and cloned multiple times. For better or worse, Jasmin remains the oldest and the original Java assembler.

The O'Reilly JVM book is now out of print. Jasmin continues to survive as a SourceForge Open Source project.

83 questions
75
votes
4 answers

Difference between JVM's LookupSwitch and TableSwitch?

I have some difficulty to understand LookUpSwitch and TableSwitch in Java bytecode. If I understand well, both LookUpSwitch and TableSwitch correspond to the switch statement of Java source? Why one JAVA statement generates 2 different bytecodes?…
zell
  • 9,830
  • 10
  • 62
  • 115
23
votes
1 answer

JVM instruction ALOAD_0 in the 'main' method points to 'args' instead of 'this'?

I am trying to implement a subset of Java for an academic study. Well, I'm in the last stages (code generation) and I wrote a rather simple program to see how method arguments are handled: class Main { public static void main(String[] args) { …
ArjunShankar
  • 23,020
  • 5
  • 61
  • 83
6
votes
3 answers

Dealing with Try/Catch Exceptions in Java bytecode? ("stack height inconsistent")

I am trying to do some error handling in java bytecode. I first tried to implement some catch-like subroutines, where I would check for the error condition, and jump to the appropriate subroutine, a little like: iconst_1 iconst_0 dup ifeq…
Jack
  • 2,153
  • 5
  • 28
  • 43
5
votes
2 answers

"throws" and "annotation for exception" in Dalvik bytecode

Why the byte code is generated as .annotation system Ldalvik/annotation/Throws; value = { Ljava/io/FileNotFoundException; } .end annotation rather than .throws Ljava/io/FileNotFoundException if a method declares…
monica
  • 1,035
  • 1
  • 9
  • 21
4
votes
1 answer

Java recursion using jsr instruction

I am using the Jasmin Java assembler to compile a toy language. But when I use the jsr instruction to recurse back into a subroutine, and run the output of Jasmin using java, I get the error "Recursive call to jsr entry". Here is the Jasmin code…
Alex
  • 1,581
  • 2
  • 18
  • 31
4
votes
1 answer

How to avoid "Illegal type in constant pool" using "ldc_w " in Jasmin?

I'm writing a compiler that generates Jasmin code and want to invoke a method that takes a Class as a parameter. public class CTest { public static void main(String[] args) throws Exception { …
JD Brennan
  • 992
  • 1
  • 10
  • 20
4
votes
2 answers

Instantiate class in Jasmin

I'm trying to instantiate a class in Jasmin like this: new Ljava/lang/Object; dup invokespecial java/lang/Object/()V This does compile but the class vierifier complains: "VerifyError: Call to wrong initialization method." What's the correct…
oddin
  • 391
  • 3
  • 11
3
votes
1 answer

Jasmin HelloWorld Example Failing

I'm having a problem executing a newly compiled HelloWorld.j from the jasmin-2.4 distribution. I downloaded jasmin-2.4. I can compile ok using: java -jar jasmin.jar examples\HelloWorld.j the output is: Generated: NoJad\j.class When I execute the…
BSalita
  • 8,420
  • 10
  • 51
  • 68
3
votes
1 answer

Linking to JVM asm-defined classes from Kotlin using Gradle

I have the following setup for an Android app: ├── build.gradle └── src └── main ├── AndroidManifest.xml ├── asm │   └── SomeJVMClass.j ├── kotlin │   └── activity.kt └── res └──…
Cactus
  • 27,075
  • 9
  • 69
  • 149
3
votes
1 answer

Conversion to Dalvik failed - uninitialized variable somewhere

I'm trying to link my Android app with a JAR that was compiled with Free Pascal. I'm getting the following build error: [2012-09-14 16:08:38 - MyApp] Dx EXCEPTION FROM SIMULATION: [2012-09-14 16:08:38 - MyApp] Dx local 0009: invalid [2012-09-14…
Seva Alekseyev
  • 59,826
  • 25
  • 160
  • 281
2
votes
2 answers

Java to Java Bytecode Compiler: How Do I Get Java Class Library Information?

I'm writing a Java to Java Bytecode compiler by compiling to Jasmin code, and assembling that. I'm creating it with the intention that source code files will be able to reference and use Java Library classes (you pretty much have to for Strings,…
Will Sewell
  • 2,593
  • 2
  • 20
  • 39
2
votes
1 answer

Jasmin Assembler: 'l2d' Instruction Giving "java.lang.VerifyError: ... Attempt to split long or double on the stack"

I'm writing a compiler to compile a subset of Java to Java bytecode using the Jasmin assembler I'm having trouble with the 'l2d' instruction (and related ones - but I think they will all work once I have figured out why this one isn't…
Will Sewell
  • 2,593
  • 2
  • 20
  • 39
2
votes
1 answer

Jasminbytecode says it's missing arguments for instruction goto

I'm trying to implement branching in my jasmin byte code program but whatever I try I always get a syntax error on the branching. The code should check if the 2 numbers are equal and if true print "true" else jump to the end label and quit…
user7137459
2
votes
1 answer

How to Create a Data Pool in Jasmin?

Does Jasmin have the ability to specify a constant pool? I need to be able to create a descriptor area of thousands of bytes. The area will contain arbitrary byte data including nulls. Here's an example of a typical assembly directive to declare…
BSalita
  • 8,420
  • 10
  • 51
  • 68
2
votes
1 answer

Jasmin IDE plugin or editor

I have a .class file I need to edit and Jasmin would be a viable way to do it. I found the Jasclipse plugin, but that's apparently too old and I cannot install it into newer Eclipse IDE. Do you know of good way to edit .class files with Jasmin code?…
PetrV
  • 1,368
  • 2
  • 15
  • 30
1
2 3 4 5 6