This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

gnu.bytecode: Method without Code Attribute


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]