Community
Participate
Working Groups
Using build 200405290105 I'm getting the following exception with a file I'm working on. I can't seem to replicate the exception in a test class where only the surrounding lines are added. public class Blah { public static void main(String[] args) { // The following two lines are not exactly as in the class in question, // but are here just to make things be syntactically correct String[] lines = new String[1]; int count = 0; // This is exactly as in the offending class - not sure which instance triggers the exception if ( (/*X:press_any_key_b*/" ".length() > 1)) { lines[count++] = /*X:press_any_key_b*/" "; } } } !MESSAGE An internal error occurred during: "Java AST creation". !STACK 0 java.lang.IllegalArgumentException: Invalid string literal : >/*X:press_any_key_b*/" "< at org.eclipse.jdt.core.dom.StringLiteral.setEscapedValue (StringLiteral.java:179) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1450) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:889) at org.eclipse.jdt.core.dom.ASTConverter.convertToParenthesizedExpression (ASTConverter.java:936) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:819) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1738) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:913) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1606) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:901) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2053) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1836) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1909) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1812) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2054) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1836) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1909) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1812) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:2054) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:1836) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:769) at org.eclipse.jdt.core.dom.ASTConverter.buildBodyDeclarations (ASTConverter.java:335) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:273) at org.eclipse.jdt.core.dom.ASTConverter.convert(ASTConverter.java:151) at org.eclipse.jdt.core.dom.ASTParser.convert(ASTParser.java:708) at org.eclipse.jdt.core.dom.ASTParser.internalCreateAST (ASTParser.java:678) at org.eclipse.jdt.core.dom.ASTParser.createAST(ASTParser.java:574) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.createAST (ASTProvider.java:437) at org.eclipse.jdt.internal.ui.javaeditor.ASTProvider.getAST (ASTProvider.java:389) at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartList enerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:125) at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$1.run (SelectionListenerWithASTManager.java:102) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:66)
If you remove the comment in front of the " " string it should work. I will see why this comment is included in the position of the string literal.
OK, but it _is not_ generating an exception in the test class with the comment in place. BTW, it's not out source and I would rather not have to modify it since we might get an updated version of it.
Also, I forgot to mention that there are similar lines preceeding the ones listed above that don't seem to trigger the exception. e.g. the following immediately precede the ones in the first comment if( !( mode == gamemode_tournament || mode == gamemode_head2head ) ) { if( place == 0 ) { lines[ count++ ] = /*X:new_track*/"NEW TRACK"; lines[ count++ ] = /*X:record!*/"RECORD!"; } else if( place < Race.get_top_count( mode ) ) { lines[ count++ ] = /*X:local_rank:*/"RANK:"; lines[ count++ ] = rankstring(place); } } lines[ count++ ] = /*X:press_any_key_a*/"press any key";
I could not reproduce the problem using your test case. Could you please provide the full source of your class?
I tried to add source code from comment 3, but I cannot reproduce. Please provide the whole class. This would help us to reproduce the problem and fix it asap.
Created attachment 11548 I've included the offending class - it's huge, I know, but that's how we got it. I've renamed a few strings to protect the guilty and hopefully cover our butts.
Reproduced with this code: public class A { void foo() { if( (/*X:press_any_key_b*/" ").length() > 1 ); } } It is important that the parenthesized expression is only the string literal and its comment. I am investigating.
Could I ask that you remove the attachment now that you have reproduced the exception? I really should not have sent the source as I guess it's probably covered by an NDA. Thanks
I will ask the administrator to get rid of this attachment.
I have a fix for it. It needs to be revised before being released.
Attachment has been removed.
Created attachment 11564 [details] Patch to apply on HEAD
Created attachment 11565 [details] Patch for the converter tests New regression tests. Also need to update the converter library.
Fixed and released in HEAD. Regression tests added.
Verified for 3.0RC2