Bug 65562 - Java AST creation failure
Summary: Java AST creation failure
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.0 RC2   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-06-03 11:40 EDT by Adrian Sampaleanu CLA
Modified: 2004-06-11 07:29 EDT (History)
0 users

See Also:


Attachments
Patch to apply on HEAD (3.34 KB, patch)
2004-06-03 15:56 EDT, Olivier Thomann CLA
no flags Details | Diff
Patch for the converter tests (16.84 KB, patch)
2004-06-03 16:00 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adrian Sampaleanu CLA 2004-06-03 11:40:07 EDT
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)
Comment 1 Olivier Thomann CLA 2004-06-03 11:43:53 EDT
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.
Comment 2 Adrian Sampaleanu CLA 2004-06-03 11:47:14 EDT
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.
Comment 3 Adrian Sampaleanu CLA 2004-06-03 11:52:52 EDT
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";

Comment 4 Olivier Thomann CLA 2004-06-03 12:03:16 EDT
I could not reproduce the problem using your test case. Could you please provide
the full source of your class?
Comment 5 Olivier Thomann CLA 2004-06-03 12:18:10 EDT
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.
Comment 6 Adrian Sampaleanu CLA 2004-06-03 13:07:57 EDT
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.
Comment 7 Olivier Thomann CLA 2004-06-03 13:59:02 EDT
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.
Comment 8 Adrian Sampaleanu CLA 2004-06-03 14:09:20 EDT
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
Comment 9 Olivier Thomann CLA 2004-06-03 14:15:49 EDT
I will ask the administrator to get rid of this attachment.
Comment 10 Olivier Thomann CLA 2004-06-03 14:40:33 EDT
I have a fix for it. It needs to be revised before being released.
Comment 11 Mark Martin CLA 2004-06-03 15:19:42 EDT
Attachment has been removed.
Comment 12 Olivier Thomann CLA 2004-06-03 15:56:10 EDT
Created attachment 11564 [details]
Patch to apply on HEAD
Comment 13 Olivier Thomann CLA 2004-06-03 16:00:04 EDT
Created attachment 11565 [details]
Patch for the converter tests

New regression tests. Also need to update the converter library.
Comment 14 Olivier Thomann CLA 2004-06-07 12:02:43 EDT
Fixed and released in HEAD.
Regression tests added.
Comment 15 David Audel CLA 2004-06-11 07:29:24 EDT
Verified for 3.0RC2