Bug 465185

Summary: ajc syntax parsing error on (before < after).
Product: [Tools] AspectJ Reporter: Kyungmin Lee <mini.lee>
Component: CompilerAssignee: aspectj inbox <aspectj-inbox>
Status: NEW --- QA Contact:
Severity: blocker    
Priority: P3 CC: aclement
Version: 1.8.5   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Kyungmin Lee CLA 2015-04-22 07:12:29 EDT
Hi, I found abnormal compile behavior.

for example, 
-------------------------------------------------------------
Random r = new Random();
float before = r.nextFloat();
float after = r.nextFloat();

int i = 10;

int index = (before < after) ? i - 1 : i;
System.out.println(index + " index!");
-------------------------------------------------------------

Then,

-------------------------------------------------------------
    [iajc] error at int index = (before < after) ? i - 1 : i;
    [iajc]             ^^^^^^^
    [iajc] MainActivity.java:48:0::0 The operator << is undefined for the argument type(s) float, float
    [iajc] error at int index = (before < after) ? i - 1 : i;
    [iajc]
    [iajc] MainActivity.java:48:0::0 Synax error on token "<", << expected
-------------------------------------------------------------

But, when I remove the both parenthesis from "(before < after) ? i - 1 : i" 
to "before < after ? i - 1 : i", I can compile successfully.
Comment 1 Andrew Clement CLA 2015-04-23 15:44:00 EDT
workaround is likely to change your names so they don't clash with aspectj keywords.

One of the grammar patches where we modify JDT must not be using the right token identifier. Normally we allow it. I'll try to remember to take a look next time the parser is open for changes.