I append here the answers to some mails, maybe they will be useful for somebody else. ========================================================================== ========================================================================== Yes, you have to write code for doing the actual refactoring. In "origin" you have the subclass. In "superClass" you have the superclass. You have to take all the methods from origin and copy them (with empty bodies) to the superClass (IF they do not exist there). Empty body means you have to add a return statement if the method type (call getMethodType on it) is different than "void": return 1; if the return type is int return true; if the return type is boolean return NULL; if the return type is any other object Use "attach" to attach the methods to the superClass. Otherwise the Codemorpher won't sense that change. Look into: /home/TDDB84/codemorpher/jreb2/src/com/xptools/jrb/refactoring to see more examples on how to use "attach" In order to create statements (to add them to the return statements) use: ProgramFactory factory = ServiceRepository.getServiceConfig().getProgramFactory(); Return bodyStatement = factory.createReturn(fieldRef); To compile go to your: TDDB84/labs/lab3 change the FormSupersetInterface.java then compile like this: javac -d . -classpath ~TDDB84/codemorpher/jreb2/jar/codemorpher.jar *.java Then run Codemorpher ~TDDB84/codemorpher/codemorpher and test your stuff. Also use System.out.println to test your transform code if problems appear. Have fun, and sorry for the late answer. Hit me with mails if you get stuck on the way. ========================================================================== ========================================================================== > Hi, > > I have a few questions regarding exercise 1 in lab3. I could wait until > Monday, but that's the last scheduled lab opportunity, and I imagine > that might be the deadline for all labs (?) > > I'd really appreciate a few quick answers if you have time. > > 1. How does one choose the position to attach a new method declaration > to the superClass? Right now, I'm just feeding attach() with position > zero, which means all method declarations are inserted before all other > methods. It would look nicer to insert the new method declarations after > already existing ones (at least that's what it looks like in the files > showing the expected result). That's easy. Just give superClass.getMembers().size() instead of zero. > > 2. Is there a method available in codemorpher or recoder to create a > "null behavior"-StatementBody, given the return type of a method? Or > should one look to see if the return type is an object and then return > null, or a boolean and then return false, and so on? You will need a ProgramFactory for this. Look at other refactorings here how to do stuff: /home/TDDB84/codemorpher/jreb2/src/com/xptools/jrb/refactoring In order to create statements (to add them to the return statements) use: ProgramFactory factory = ServiceRepository.getServiceConfig().getProgramFactory(); Return bodyStatement = factory.createReturn(factory.createNull()); I think is like this, i don't remeber from the head, but you'll manage :) > > 3. The method isPublic() return true for me even when I use it on > methods declared protected. Do you know why that might be? This sounds strange. I will look into this. Have you got the methods with getMembers? Maybe you have to cast it to (MethodDeclaration)member. ==========================================================================