You are here: Home JastAdd Forums The JastAdd Extensible Java Compiler (JastAddJ) Extending JastAddJ
Document Actions

Extending JastAddJ

Up to The JastAdd Extensible Java Compiler (JastAddJ)

Extending JastAddJ

Posted by Donna Malayeri at June 18. 2008

Hello,


I'm interested in extending JastAddJ to add support for a limited form of multiple inheritance. I've done a prototype by modifying Java1.4Frontend directly, but I know this is not the "right" way of doing this. What's the right approach here?  Do I create a new project with new AST declarations and grammar specification, then override everything that uses the current superclass() attribute?


thanks,
Donna


Re: Extending JastAddJ

Posted by Torbjörn Ekman at June 24. 2008

Hi Donna,


That sounds about right to me. The general strategy would be to extend the memberMethods(String name), memberFields(String name), and memberTypes(String name) attributes in ClassDecl to include method inherited from several superclasses. Right now methods from a single superclass and possibly methods from multiple interfaces are inherited. The inter-type declarations extension is doing something similar. The code is available here.


There are a few modules that should be of particular interest: DeclareParents* and IntertypeMethod*. DeclareParents shows how to extend the class hierarchy by adding additional interfaces or replacing the superclass. This can lead to problems with circularities which are handled in DeclareParentsAnalysis.jrag. IntertypeMethodsNameAnalysis.jrag shows how to extend the set of visible member methods in a class. Of particular interest is the zaps attribute that defines the precedence of multiply inherited methods.


Cheers
/Torbjorn


Powered by Ploneboard