Community
Participate
Working Groups
I observed several NPEs while editing CreateMethodMappingCompletionProposal. On narrowing down the cause I see that the back reference from a role file type to its enclosing team type may break when the role file contains a (specific kind of) syntax error. The culprit is in Parser.buildInitialRecoveryState(), where nulling the package declaration of the enclosing CUD causes grief. Investigating.
I filed bug 325690 against JDT/Core for that part that causes entry into the parser with garbled source (Parser.parseMemberValue(..))
Created attachment 179196 [details] test and fix OK, here is what happened: after bug 325690 struck the parser would be called with garbage and on hitting a syntax error, it would wipe out the package declaration from the CU to start over, yet the current source would contain only a small fragment of the file (supposedly an annotation, but it was off). Later, that CU without a package declaration would fail in RoleFileHelper.getTeamOfRoleFile(..) thus the role file didn't get enclosingType set. Still later RoleModel.getTeamModel would dereference _ast.enclosingType and throw NPE. Fixed by making Parser.buildInitialRecoveryState() sensitive to what initial goal we are parsing for. Only when going for compilation unit or package declaration do we reset the package declaration now.
Patch has been committed as r826 / r827.
Verified using I201009211735