Download Jar. Uses 1311K of libraries. Click here for Pure Java version (80L/1K).
1 | !7 |
2 | |
3 | set flag LeanMode. |
4 | |
5 | !include once #1019934 // BCEL [Include] |
6 | |
7 | import org.apache.bcel.generic.Type; |
8 | |
9 | p { |
10 | ClassGen cg = new("BadClassFile", "java.lang.Object", null, |
11 | Const.ACC_PUBLIC, new S[0]); |
12 | cg.addEmptyConstructor(Const.ACC_PUBLIC); |
13 | |
14 | ConstantPoolGen cp = cg.getConstantPool(); |
15 | new InstructionList il; |
16 | |
17 | MethodGen mg = new((short) (Const.ACC_PUBLIC | Const.ACC_STATIC), |
18 | Type.VOID, new Type[] { new ArrayType(new ObjectType("java.lang.String"), 1) }, |
19 | null, "main", cg.getClassName(), il, cp); |
20 | il.append(new LDC(cp.addClass("java.lang.Object"))); |
21 | il.append(new ASTORE(1)); |
22 | il.append(new RETURN); |
23 | |
24 | mg.stripAttributes(true); |
25 | mg.setMaxStack(); |
26 | mg.setMaxLocals(); |
27 | cg.addMethod(mg.getMethod()); |
28 | |
29 | JavaClass baked = cg.getJavaClass(); |
30 | var bytes = baked.getBytes(); |
31 | saveBinaryFile_simple(baked.getClassName() + ".class", bytes); |
32 | } |
Began life as a copy of #1034332
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
Snippet ID: | #1034334 |
Snippet name: | BCEL LDC class constant problem spike without MethodMaker [dev.] |
Eternal ID of this version: | #1034334/5 |
Text MD5: | 26c2149aadc7bd610af96d4837be1fc8 |
Transpilation MD5: | c4f320a7a9167ad61381e996cb3c1d90 |
Author: | stefan |
Category: | javax / transpiling |
Type: | JavaX source code (desktop) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2022-02-02 21:32:16 |
Source code size: | 905 bytes / 32 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 232 / 779 |
Version history: | 4 change(s) |
Referenced in: | [show references] |