| Summary: | [dom] IllegalArgumentException in very broken source | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Tools] Objectteams | Reporter: | Stephan Herrmann <stephan.herrmann> | ||||
| Component: | OTDT | Assignee: | Stephan Herrmann <stephan.herrmann> | ||||
| Status: | VERIFIED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | ||||||
| Version: | 0.7 | ||||||
| Target Milestone: | 0.7 | ||||||
| Hardware: | PC | ||||||
| OS: | Linux | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Created attachment 171791 [details]
test & fix
Due to extra quotes, the parser created a deeper nesting structure
than intended and made some roles into nested teams.
For one role with an explicit super class this meant that the Team
infrastructure was generated (rather than inherited from o.o.Team).
One of these generated fields was then converted although it had
no valid source range.
The fix is simply to skip generated fields in ASTConverter.
Fix has been committed as r472, r473. Verified using build 201007011455. |
I pasted a string from a test into a team class and started removing leading and trailing '"' and '\n"'. During this process I got plenty of IllegalArgumentExceptions. The source looked like this: package stringtoclass; public team class MyTeam { precedence R2_R, R1_R; protected abstract class R playedBy T73Mab1 {\n" + @SuppressWarnings(\"basecall\")\n" + callin void foo() { System.out.print(getClass().getName()); }\n" + @SuppressWarnings(\"def-bind-ambiguity\")\n" + foo <- replace test; // lifting not recommended\n" + }\n" + protected class R1_R extends R\n" + base when (Team73Mab1.this.hasRole(base, R1_R.class))\n" + {\n" + }\n" + protected class R2_R extends R\n" + base when (Team73Mab1.this.hasRole(base, R2_R.class))\n" + {\n" + }\n" + \n" + Team73Mab1 (T73Mab1 as R1_R o) {}\n" + public static void main(String[] args) {\n" + T73Mab1 o = new T73Mab1();\n" + Team73Mab1 t = new Team73Mab1(o);\n" + t.activate();\n" + o.test();\n" + } } The exception is here (this is from copying the source for this report): java.lang.IllegalArgumentException at org.eclipse.jdt.core.dom.ASTNode.setSourceRange(ASTNode.java:2752) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2947) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2111) at org.eclipse.jdt.core.dom.ASTConverter.convertToVariableDeclarationFragment(ASTConverter.java:3963) at org.eclipse.jdt.core.dom.ASTConverter.checkAndAddMultipleFieldDeclaration(ASTConverter.java:501) at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations(ASTConverter.java:247) at org.eclipse.jdt.core.dom.ASTConverter.buildRoleTypeDeclaration(ASTConverter.java:3551) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:3452) at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations(ASTConverter.java:282) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:3442) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1786) at org.eclipse.jdt.core.dom.CompilationUnitResolver.convert(CompilationUnitResolver.java:301) at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST(ASTParser.java:1216) at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:806) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider$1.run(ASTProvider.java:543) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST(ASTProvider.java:536) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST(ASTProvider.java:479) at org.eclipse.jdt.ui.SharedASTProvider.getAST(SharedASTProvider.java:126) at org.eclipse.jdt.internal.ui.javaeditor.ClipboardOperationAction.getClipboardData(ClipboardOperationAction.java:406)