Warning: session_start(): open(/var/lib/php/sessions/sess_i1k0u5noo89ml73u48gmmbqeem, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
set flag AllPublic.
!include once #1019934 // BCEL
import org.apache.bcel.Const;
import org.apache.bcel.generic.*;
p {
ClassGen cg = new("User123", "java.lang.Object", null,
Const.ACC_PUBLIC, new S[] { className(IF0) });
cg.addEmptyConstructor(Const.ACC_PUBLIC);
// make code for get() method
new InstructionList il;
ConstantPoolGen cp = cg.getConstantPool();
var factory = new InstructionFactory(cg);
var mg = new MethodGen(Const.ACC_PUBLIC,
new ObjectType(className(S)),
new org.apache.bcel.generic.Type[] {}, null, "get", cg.getClassName(), il, cp);
il.append(new PUSH(cp, "Hello world"));
il.append(InstructionConst.ARETURN);
mg.stripAttributes(true);
mg.setMaxStack();
mg.setMaxLocals();
cg.addMethod(mg.getMethod());
// bake class
JavaClass baked = cg.getJavaClass();
// print class overview
print(baked);
// print the methods
for (method : baked.getMethods()) {
print("\n" + method);
print(method.getCode());
}
byte[] bytes = baked.getBytes();
var cl = new InMemoryClassLoader(myClassLoader());
Class extends IF0> c = cast cl.defineAClass("User123", bytes);
print(c);
IF0 f = newInstance(c);
print(f);
print(value := f!);
}