Bug 465185 - ajc syntax parsing error on (before < after).
Summary: ajc syntax parsing error on (before < after).
Status: NEW
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.8.5   Edit
Hardware: PC Windows 7
: P3 blocker (vote)
Target Milestone: ---   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-22 07:12 EDT by Kyungmin Lee CLA
Modified: 2015-04-23 15:44 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.