This is the mail archive of the
kawa@sources.redhat.com
mailing list for the Kawa project.
gnu.bytecode: Method without Code Attribute
- To: kawa at sourceware dot cygnus dot com
- Subject: gnu.bytecode: Method without Code Attribute
- From: Chris Wolfe <cwolfe at globetrotter dot qc dot ca>
- Date: Tue, 17 Apr 2001 22:28:06 -0400
It appears that a Code attribute must be created (initCode) for a
Method to actually be written to output. Section 4.7.3 of the
Java VM specs, however, seems to consider it an error to have a
Code segment for abstract or native methods. I can remove the
Code using the setSkipped() method, but avoiding its creation
completely would be nice -- any ideas?
ClassType type = new ClassType("Test");
type.setModifiers(Access.PUBLIC | Access.INTERFACE);
Method method = type.addMethod("foo", Access.PUBLIC |
Access.ABSTRACT, new Type[0], Type.void_type);
// Required for the method to be generated
method.initCode();
// Workaround to prevent Code attribute from being written
method.getAttributes().setSkipped();
type.writeToFile();
Thanks,
Chris