package com.zarbosoft.semicompiled;
import java.lang.RuntimeException;
import java.lang.System;
import java.lang.Throwable;
class Main {
public static void myMain() {
try {
System.out.println("Okay");
} catch (RuntimeException e) {
e.printStackTrace();
} catch (Throwable e) {
int q = 1;
}
}
}
Classfile /tmp/semicompiled-J65TEQ3F-3053927804089808238/com/zarbosoft/semicompiled/Main.class
Last modified Jun 2, 2024; size 479 bytes
MD5 checksum a05ecc3e4689c67e0f8cb4ef46398635
class com.zarbosoft.semicompiled.Main
minor version: 0
major version: 52
flags: (0x0020) ACC_SUPER
this_class: #8 // com/zarbosoft/semicompiled/Main
super_class: #9 // java/lang/Object
interfaces: 0, fields: 0, methods: 2, attributes: 0
Constant pool:
#1 = Methodref #9.#15 // java/lang/Object."<init>":()V
#2 = Fieldref #16.#17 // java/lang/System.out:Ljava/io/PrintStream;
#3 = String #18 // Okay
#4 = Methodref #19.#20 // java/io/PrintStream.println:(Ljava/lang/String;)V
#5 = Class #21 // java/lang/RuntimeException
#6 = Methodref #5.#22 // java/lang/RuntimeException.printStackTrace:()V
#7 = Class #23 // java/lang/Throwable
#8 = Class #24 // com/zarbosoft/semicompiled/Main
#9 = Class #25 // java/lang/Object
#10 = Utf8 <init>
#11 = Utf8 ()V
#12 = Utf8 Code
#13 = Utf8 myMain
#14 = Utf8 StackMapTable
#15 = NameAndType #10:#11 // "<init>":()V
#16 = Class #26 // java/lang/System
#17 = NameAndType #27:#28 // out:Ljava/io/PrintStream;
#18 = Utf8 Okay
#19 = Class #29 // java/io/PrintStream
#20 = NameAndType #30:#31 // println:(Ljava/lang/String;)V
#21 = Utf8 java/lang/RuntimeException
#22 = NameAndType #32:#11 // printStackTrace:()V
#23 = Utf8 java/lang/Throwable
#24 = Utf8 com/zarbosoft/semicompiled/Main
#25 = Utf8 java/lang/Object
#26 = Utf8 java/lang/System
#27 = Utf8 out
#28 = Utf8 Ljava/io/PrintStream;
#29 = Utf8 java/io/PrintStream
#30 = Utf8 println
#31 = Utf8 (Ljava/lang/String;)V
#32 = Utf8 printStackTrace
{
com.zarbosoft.semicompiled.Main();
descriptor: ()V
flags: (0x0000)
Code:
stack=1, locals=1, args_size=1
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
public static void myMain();
descriptor: ()V
flags: (0x0009) ACC_PUBLIC, ACC_STATIC
Code:
stack=2, locals=2, args_size=0
0: getstatic #2 // Field java/lang/System.out:Ljava/io/PrintStream;
3: ldc #3 // String Okay
5: invokevirtual #4 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
8: goto 22
11: astore_0
12: aload_0
13: invokevirtual #6 // Method java/lang/RuntimeException.printStackTrace:()V
16: goto 22
19: astore_0
20: iconst_1
21: istore_1
22: return
Exception table:
from to target type
0 8 11 Class java/lang/RuntimeException
0 8 19 Class java/lang/Throwable
StackMapTable: number_of_entries = 3
frame_type = 75 /* same_locals_1_stack_item */
stack = [ class java/lang/RuntimeException ]
frame_type = 71 /* same_locals_1_stack_item */
stack = [ class java/lang/Throwable ]
frame_type = 2 /* same */
}
package asm.com.zarbosoft.semicompiled;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.Attribute;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.ConstantDynamic;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Handle;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.RecordComponentVisitor;
import org.objectweb.asm.Type;
import org.objectweb.asm.TypePath;
public class MainDump implements Opcodes {
public static byte[] dump() throws Exception {
ClassWriter classWriter = new ClassWriter(0);
FieldVisitor fieldVisitor;
RecordComponentVisitor recordComponentVisitor;
MethodVisitor methodVisitor;
AnnotationVisitor annotationVisitor0;
classWriter.visit(
V1_8, ACC_SUPER, "com/zarbosoft/semicompiled/Main", null, "java/lang/Object", null);
{
methodVisitor = classWriter.visitMethod(0, "<init>", "()V", null, null);
methodVisitor.visitCode();
methodVisitor.visitVarInsn(ALOAD, 0);
methodVisitor.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
methodVisitor.visitInsn(RETURN);
methodVisitor.visitMaxs(1, 1);
methodVisitor.visitEnd();
}
{
methodVisitor = classWriter.visitMethod(ACC_PUBLIC | ACC_STATIC, "myMain", "()V", null, null);
methodVisitor.visitCode();
Label label0 = new Label();
Label label1 = new Label();
Label label2 = new Label();
methodVisitor.visitTryCatchBlock(label0, label1, label2, "java/lang/RuntimeException");
Label label3 = new Label();
methodVisitor.visitTryCatchBlock(label0, label1, label3, "java/lang/Throwable");
methodVisitor.visitLabel(label0);
methodVisitor.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
methodVisitor.visitLdcInsn("Okay");
methodVisitor.visitMethodInsn(
INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false);
methodVisitor.visitLabel(label1);
Label label4 = new Label();
methodVisitor.visitJumpInsn(GOTO, label4);
methodVisitor.visitLabel(label2);
methodVisitor.visitFrame(
Opcodes.F_SAME1, 0, null, 1, new Object[] {"java/lang/RuntimeException"});
methodVisitor.visitVarInsn(ASTORE, 0);
methodVisitor.visitVarInsn(ALOAD, 0);
methodVisitor.visitMethodInsn(
INVOKEVIRTUAL, "java/lang/RuntimeException", "printStackTrace", "()V", false);
methodVisitor.visitJumpInsn(GOTO, label4);
methodVisitor.visitLabel(label3);
methodVisitor.visitFrame(Opcodes.F_SAME1, 0, null, 1, new Object[] {"java/lang/Throwable"});
methodVisitor.visitVarInsn(ASTORE, 0);
methodVisitor.visitInsn(ICONST_1);
methodVisitor.visitVarInsn(ISTORE, 1);
methodVisitor.visitLabel(label4);
methodVisitor.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
methodVisitor.visitInsn(RETURN);
methodVisitor.visitMaxs(2, 2);
methodVisitor.visitEnd();
}
classWriter.visitEnd();
return classWriter.toByteArray();
}
}
Classfile /tmp/semicompiled-J65TEQ3F-3053927804089808238/com/zarbosoft/semicompiled/Main.class
Last modified Jun 2, 2024; size 727 bytes
MD5 checksum e54005c3e2c7d028e7eabfc7579d6b90
Compiled from "Main.java"
class com.zarbosoft.semicompiled.Main
minor version: 0
major version: 52
flags: (0x0020) ACC_SUPER
this_class: #8 // com/zarbosoft/semicompiled/Main
super_class: #9 // java/lang/Object
interfaces: 0, fields: 0, methods: 2, attributes: 1
Constant pool:
#1 = Methodref #9.#24 // java/lang/Object."<init>":()V
#2 = Fieldref #25.#26 // java/lang/System.out:Ljava/io/PrintStream;
#3 = String #27 // Okay
#4 = Methodref #28.#29 // java/io/PrintStream.println:(Ljava/lang/String;)V
#5 = Class #30 // java/lang/RuntimeException
#6 = Methodref #5.#31 // java/lang/RuntimeException.printStackTrace:()V
#7 = Class #32 // java/lang/Throwable
#8 = Class #33 // com/zarbosoft/semicompiled/Main
#9 = Class #34 // java/lang/Object
#10 = Utf8 <init>
#11 = Utf8 ()V
#12 = Utf8 Code
#13 = Utf8 LineNumberTable
#14 = Utf8 LocalVariableTable
#15 = Utf8 this
#16 = Utf8 Lcom/zarbosoft/semicompiled/Main;
#17 = Utf8 myMain
#18 = Utf8 e
#19 = Utf8 Ljava/lang/RuntimeException;
#20 = Utf8 Ljava/lang/Throwable;
#21 = Utf8 StackMapTable
#22 = Utf8 SourceFile
#23 = Utf8 Main.java
#24 = NameAndType #10:#11 // "<init>":()V
#25 = Class #35 // java/lang/System
#26 = NameAndType #36:#37 // out:Ljava/io/PrintStream;
#27 = Utf8 Okay
#28 = Class #38 // java/io/PrintStream
#29 = NameAndType #39:#40 // println:(Ljava/lang/String;)V
#30 = Utf8 java/lang/RuntimeException
#31 = NameAndType #41:#11 // printStackTrace:()V
#32 = Utf8 java/lang/Throwable
#33 = Utf8 com/zarbosoft/semicompiled/Main
#34 = Utf8 java/lang/Object
#35 = Utf8 java/lang/System
#36 = Utf8 out
#37 = Utf8 Ljava/io/PrintStream;
#38 = Utf8 java/io/PrintStream
#39 = Utf8 println
#40 = Utf8 (Ljava/lang/String;)V
#41 = Utf8 printStackTrace
{
com.zarbosoft.semicompiled.Main();
descriptor: ()V
flags: (0x0000)
Code:
stack=1, locals=1, args_size=1
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
LineNumberTable:
line 7: 0
LocalVariableTable:
Start Length Slot Name Signature
0 5 0 this Lcom/zarbosoft/semicompiled/Main;
public static void myMain();
descriptor: ()V
flags: (0x0009) ACC_PUBLIC, ACC_STATIC
Code:
stack=2, locals=2, args_size=0
0: getstatic #2 // Field java/lang/System.out:Ljava/io/PrintStream;
3: ldc #3 // String Okay
5: invokevirtual #4 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
8: goto 22
11: astore_0
12: aload_0
13: invokevirtual #6 // Method java/lang/RuntimeException.printStackTrace:()V
16: goto 22
19: astore_0
20: iconst_1
21: istore_1
22: return
Exception table:
from to target type
0 8 11 Class java/lang/RuntimeException
0 8 19 Class java/lang/Throwable
LineNumberTable:
line 9: 0
line 10: 22
LocalVariableTable:
Start Length Slot Name Signature
12 4 0 e Ljava/lang/RuntimeException;
20 2 0 e Ljava/lang/Throwable;
StackMapTable: number_of_entries = 3
frame_type = 75 /* same_locals_1_stack_item */
stack = [ class java/lang/RuntimeException ]
frame_type = 71 /* same_locals_1_stack_item */
stack = [ class java/lang/Throwable ]
frame_type = 2 /* same */
}
SourceFile: "Main.java"
package asm.com.zarbosoft.semicompiled;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.Attribute;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.ConstantDynamic;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Handle;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.RecordComponentVisitor;
import org.objectweb.asm.Type;
import org.objectweb.asm.TypePath;
public class MainDump implements Opcodes {
public static byte[] dump() throws Exception {
ClassWriter classWriter = new ClassWriter(0);
FieldVisitor fieldVisitor;
RecordComponentVisitor recordComponentVisitor;
MethodVisitor methodVisitor;
AnnotationVisitor annotationVisitor0;
classWriter.visit(
V1_8, ACC_SUPER, "com/zarbosoft/semicompiled/Main", null, "java/lang/Object", null);
classWriter.visitSource("Main.java", null);
{
methodVisitor = classWriter.visitMethod(0, "<init>", "()V", null, null);
methodVisitor.visitCode();
Label label0 = new Label();
methodVisitor.visitLabel(label0);
methodVisitor.visitLineNumber(7, label0);
methodVisitor.visitVarInsn(ALOAD, 0);
methodVisitor.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V", false);
methodVisitor.visitInsn(RETURN);
Label label1 = new Label();
methodVisitor.visitLabel(label1);
methodVisitor.visitLocalVariable(
"this", "Lcom/zarbosoft/semicompiled/Main;", null, label0, label1, 0);
methodVisitor.visitMaxs(1, 1);
methodVisitor.visitEnd();
}
{
methodVisitor = classWriter.visitMethod(ACC_PUBLIC | ACC_STATIC, "myMain", "()V", null, null);
methodVisitor.visitCode();
Label label0 = new Label();
Label label1 = new Label();
Label label2 = new Label();
methodVisitor.visitTryCatchBlock(label0, label1, label2, "java/lang/RuntimeException");
Label label3 = new Label();
methodVisitor.visitTryCatchBlock(label0, label1, label3, "java/lang/Throwable");
methodVisitor.visitLabel(label0);
methodVisitor.visitLineNumber(9, label0);
methodVisitor.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
methodVisitor.visitLdcInsn("Okay");
methodVisitor.visitMethodInsn(
INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V", false);
methodVisitor.visitLabel(label1);
Label label4 = new Label();
methodVisitor.visitJumpInsn(GOTO, label4);
methodVisitor.visitLabel(label2);
methodVisitor.visitFrame(
Opcodes.F_SAME1, 0, null, 1, new Object[] {"java/lang/RuntimeException"});
methodVisitor.visitVarInsn(ASTORE, 0);
Label label5 = new Label();
methodVisitor.visitLabel(label5);
methodVisitor.visitVarInsn(ALOAD, 0);
methodVisitor.visitMethodInsn(
INVOKEVIRTUAL, "java/lang/RuntimeException", "printStackTrace", "()V", false);
Label label6 = new Label();
methodVisitor.visitLabel(label6);
methodVisitor.visitJumpInsn(GOTO, label4);
methodVisitor.visitLabel(label3);
methodVisitor.visitFrame(Opcodes.F_SAME1, 0, null, 1, new Object[] {"java/lang/Throwable"});
methodVisitor.visitVarInsn(ASTORE, 0);
Label label7 = new Label();
methodVisitor.visitLabel(label7);
methodVisitor.visitInsn(ICONST_1);
methodVisitor.visitVarInsn(ISTORE, 1);
methodVisitor.visitLabel(label4);
methodVisitor.visitLineNumber(10, label4);
methodVisitor.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
methodVisitor.visitInsn(RETURN);
methodVisitor.visitLocalVariable(
"e", "Ljava/lang/RuntimeException;", null, label5, label6, 0);
methodVisitor.visitLocalVariable("e", "Ljava/lang/Throwable;", null, label7, label4, 0);
methodVisitor.visitMaxs(2, 2);
methodVisitor.visitEnd();
}
classWriter.visitEnd();
return classWriter.toByteArray();
}
}
Join the thriving social scene at github.com/andrewbaxter/semicompiled.