ClassWriter.COMPUTE_FRAMES & Stack size too large
Bhaskar Maddala <[email protected]>
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <[email protected]> |
Hello,
I was playing around with ASM and as a newbie cannot seem to figure
out what I am doing wrong in the following code
public class VarianceOnReturnTypeGenerator {
public static void main(String[] args) throws Exception {
Class<?> clazz = writeClass();
Object o = clazz.newInstance();
}
private static Class<?> writeClass() {
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES);
cw.visit(V1_5, ACC_PUBLIC + ACC_SUPER, "OverriddenMethods", null,
"java/lang/Object", null);
writeConstructor(cw);
cw.visitEnd();
GeneratedClassLoader gcl = new GeneratedClassLoader();
return gcl.defineClass("OverriddenMethods", cw.toByteArray());
}
private static void writeConstructor(ClassWriter cw) {
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null,
null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitMethodInsn(INVOKESPECIAL, "java/lang/Object", "<init>", "()V");
mv.visitInsn(RETURN);
mv.visitEnd();
}
}
When attempting to create an instance of the object using newInstance,
I get the following exception
Exception in thread "main" java.lang.VerifyError: (class:
OverriddenMethods, method: <init> signature: ()V) Stack size too large
at java.lang.Class.getDeclaredConstructors0(Native Method)
Pointers much appreciated.
Thanks
Bhaskar
message-footer.txt
(text/plain, 238 B)
-- You receive this message as a subscriber of the [email protected] mailing list. To unsubscribe: mailto:[email protected] For general help: mailto:[email protected]?subject=help OW2 mailing lists service home page: http://www.ow2.org/wws