Community
Participate
Working Groups
Given a base class mypack.base.Base Given a team class mypack.teams.MyTeam I try to create a role file Role playedBy Base, but I get this exception: java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:477) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:372) at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:1029) at org.eclipse.jdt.internal.ui.wizards.NewElementWizard.performFinish(NewElementWizard.java:134) at org.eclipse.objectteams.otdt.internal.ui.wizards.NewTypeCreationWizard.performFinish(NewTypeCreationWizard.java:54) ... ... Caused by: java.lang.IllegalStateException at org.eclipse.jdt.internal.corext.refactoring.TypeContextChecker.resolveSuperClass(TypeContextChecker.java:756) at org.eclipse.objectteams.otdt.internal.ui.wizards.typecreation.RoleCreator.writeBaseClass(RoleCreator.java:72) at org.eclipse.objectteams.otdt.internal.ui.wizards.typecreation.RoleCreator.writeInheritanceRelations(RoleCreator.java:54) at org.eclipse.objectteams.otdt.internal.ui.wizards.typecreation.TypeCreator.constructTypeStub(TypeCreator.java:581) at org.eclipse.objectteams.otdt.internal.ui.wizards.typecreation.TypeCreator.createType(TypeCreator.java:187) at org.eclipse.objectteams.otdt.internal.ui.wizards.NewTypeCreationWizard.finishPage(NewTypeCreationWizard.java:70) at org.eclipse.jdt.internal.ui.wizards.NewElementWizard$2.run(NewElementWizard.java:118) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:39) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:728) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:4889) at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:106) at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464)
Created attachment 196291 [details] Fix The root cause for trouble was: The base class was resolved using a stub like: team class MyTeam { class MyRole extends mypack.base.Base {} } Here the qualified name including a 'base' fragment caused a parse error inside the team. Fixed by using a different pattern for the stub when resolving the base class: public class MyTeam {} class MyRole extends mypack.base.Base { } This avoids putting the scanner into OT/J mode. I'm not sure if this could cause resolving to pick a wrong class, but I couldn't find any example for this. The patch also fixes issues wrt base imports for a role file: if "[ ] inlined" is unchecked maintain two compilation units and their import rewrites: one for the role file and one for the enclosing team.
Committed as r1618
Verified using build 201105311237