Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

32
LINES

< > BotCompany Repo | #1034334 // BCEL LDC class constant problem spike without MethodMaker [dev.]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Uses 1311K of libraries. Click here for Pure Java version (80L/1K).

!7

set flag LeanMode.

!include once #1019934 // BCEL [Include]

import org.apache.bcel.generic.Type;

p {
  ClassGen cg = new("BadClassFile", "java.lang.Object", null,
    Const.ACC_PUBLIC, new S[0]);
  cg.addEmptyConstructor(Const.ACC_PUBLIC);
    
  ConstantPoolGen cp = cg.getConstantPool();
  new InstructionList il;
  
  MethodGen mg = new((short) (Const.ACC_PUBLIC | Const.ACC_STATIC),
    Type.VOID, new Type[] { new ArrayType(new ObjectType("java.lang.String"), 1) },
    null, "main", cg.getClassName(), il, cp);
  il.append(new LDC(cp.addClass("java.lang.Object")));
  il.append(new ASTORE(1));
  il.append(new RETURN);
  
  mg.stripAttributes(true);
  mg.setMaxStack();
  mg.setMaxLocals();
  cg.addMethod(mg.getMethod());

  JavaClass baked = cg.getJavaClass();
  var bytes = baked.getBytes();
  saveBinaryFile_simple(baked.getClassName() + ".class", bytes);
}

Author comment

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: 231 / 778
Version history: 4 change(s)
Referenced in: [show references]