Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 325681 - [compiler] syntax error in role file may cause NPE in RoleModel.getTeamModel()
Summary: [compiler] syntax error in role file may cause NPE in RoleModel.getTeamModel()
Status: VERIFIED FIXED
Alias: None
Product: Objectteams
Classification: Tools
Component: OTJ (show other bugs)
Version: 0.7   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 0.7.1   Edit
Assignee: Stephan Herrmann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-18 11:41 EDT by Stephan Herrmann CLA
Modified: 2010-09-23 17:42 EDT (History)
0 users

See Also:


Attachments
test and fix (17.68 KB, patch)
2010-09-18 20:41 EDT, Stephan Herrmann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Herrmann CLA 2010-09-18 11:41:50 EDT
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.
Comment 1 Stephan Herrmann CLA 2010-09-18 19:17:45 EDT
I filed bug 325690 against JDT/Core for that part that causes entry into 
the parser with garbled source (Parser.parseMemberValue(..))
Comment 2 Stephan Herrmann CLA 2010-09-18 20:41:34 EDT
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.
Comment 3 Stephan Herrmann CLA 2010-09-18 20:44:05 EDT
Patch has been committed as r826 / r827.
Comment 4 Stephan Herrmann CLA 2010-09-23 17:42:03 EDT
Verified using I201009211735