Summary: | IAE while opening ASTView | ||||||
---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Frederic Fusier <frederic_fusier> | ||||
Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> | ||||
Status: | VERIFIED FIXED | QA Contact: | |||||
Severity: | normal | ||||||
Priority: | P3 | CC: | jeem | ||||
Version: | 3.1 | ||||||
Target Milestone: | 3.1 M6 | ||||||
Hardware: | PC | ||||||
OS: | Windows XP | ||||||
Whiteboard: | |||||||
Attachments: |
|
Description
Frederic Fusier
2005-03-23 08:16:32 EST
Olivier, it seems that it comes from the fact that instanciated AST always creates a Scanner with source level at ClassFileConstants.JDK1_3 even for JLS3... Created attachment 19108 [details]
This patch to fixes the problem...
...But i don't know if this is the right thing to do.
I would not change the source level, but I would set the compliance level to be 1.5. This patch: Index: AST.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/AST.java,v retrieving revision 1.138 diff -u -r1.138 AST.java --- AST.java 15 Mar 2005 04:30:05 -0000 1.138 +++ AST.java 23 Mar 2005 17:06:32 -0000 @@ -196,17 +196,23 @@ * @since 3.0 */ private AST(int level) { - if ((level != AST.JLS2) - && (level != AST.JLS3)) { - throw new IllegalArgumentException(); + long complianceLevel = ClassFileConstants.JDK1_3; + switch (level) { + case AST.JLS3: + complianceLevel = ClassFileConstants.JDK1_5; + case AST.JLS2: + this.apiLevel = level; + break; + default: + throw new IllegalArgumentException(); } - this.apiLevel = level; // initialize a scanner this.scanner = new Scanner( true /*comment*/, true /*whitespace*/, false /*nls*/, ClassFileConstants.JDK1_3 /*sourceLevel*/, + complianceLevel /*complianceLevel*/, null/*taskTag*/, null/*taskPriorities*/, true/*taskCaseSensitive*/); @@ -296,12 +302,20 @@ } else if (JavaCore.VERSION_1_5.equals(sourceLevelOption)) { sourceLevel = ClassFileConstants.JDK1_5; } + Object complianceLevelOption = options.get(JavaCore.COMPILER_COMPLIANCE); + long complianceLevel = ClassFileConstants.JDK1_3; + if (JavaCore.VERSION_1_4.equals(complianceLevelOption)) { + complianceLevel = ClassFileConstants.JDK1_4; + } else if (JavaCore.VERSION_1_5.equals(complianceLevelOption)) { + complianceLevel = ClassFileConstants.JDK1_5; + } // override scanner if 1.4 or 1.5 asked for this.scanner = new Scanner( true /*comment*/, true /*whitespace*/, false /*nls*/, sourceLevel /*sourceLevel*/, + complianceLevel /*complianceLevel*/, null/*taskTag*/, null/*taskPriorities*/, true/*taskCaseSensitive*/); is passing your test case without failing ASTTest. Let me know if this looks good for you. Fine with me Jim, do you believe that we should treat JLS2 and JLS3 differently regarding to the decoding of Unicode 4 identifiers? I could set the compliance level to be 1.5 in all cases. This would enable the Unicode 4 support indenpendly from the source level. So "assert" or "enum" would still be considered as valid identifiers and identifiers written using Unicode 4 would also be valid identifiers. +1 - Handle JLS2 and JLS3 the same way regarding to the decoding of Unicode 4 identifiers (using 1.5 rules) and classification of keywords (using 1.3 rules). Fixed and released in HEAD. Added regression test ASTConverter15Test.test0153. Verified in 20050330-0500 |