!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()); byte[] bytes = cg.getJavaClass().getBytes(); var cl = new InMemoryClassLoader(myClassLoader()); Class c = cast cl.defineAClass("User123", bytes); print(c); IF0 f = newInstance(c); print(f); print(value := f!); }