private static byte[] loadBytecode()
{
String secureCallerClassName = SecureCaller.class.getName();
ClassFileWriter cfw = new ClassFileWriter(
secureCallerClassName + "Impl", secureCallerClassName,
"<generated>");
cfw.startMethod("<init>", "()V", ClassFileWriter.ACC_PUBLIC);
cfw.addALoad(0);
cfw.addInvoke(ByteCode.INVOKESPECIAL, secureCallerClassName,
"<init>", "()V");
cfw.add(ByteCode.RETURN);
cfw.stopMethod((short)1);
String callableCallSig =
"Lnet/sourceforge/htmlunit/corejs/javascript/Context;" +
"Lnet/sourceforge/htmlunit/corejs/javascript/Scriptable;" +
"Lnet/sourceforge/htmlunit/corejs/javascript/Scriptable;" +
"[Ljava/lang/Object;)Ljava/lang/Object;";
cfw.startMethod("call",
"(Lnet/sourceforge/htmlunit/corejs/javascript/Callable;" + callableCallSig,
(short)(ClassFileWriter.ACC_PUBLIC
| ClassFileWriter.ACC_FINAL));
for(int i = 1; i < 6; ++i) {
cfw.addALoad(i);
}
cfw.addInvoke(ByteCode.INVOKEINTERFACE,
"net/sourceforge/htmlunit/corejs/javascript/Callable", "call",
"(" + callableCallSig);
cfw.add(ByteCode.ARETURN);
cfw.stopMethod((short)6);
return cfw.toByteArray();
}