Community
Participate
Working Groups
Following code fragment: ***************************** class Foo { public void bar () { long before = 0; long after = 0; System.out.println("... " + (before - after) + " ..."); } } ***************************** leads to following parser error ***************************** [...].java:25 [error] Syntax error on token "-", invalid AssignmentOperator System.out.println("... " + (before - after) + " ..."); ***************************** Problems seems to vanish when I rename the before variable.
Same applies if System.out.println("... " + (after - before) + " ..."); again, renaming after solves the problem
whilst Adrian has the parser open, he can take a look :)
Verified as happening on Windows 2000, PC hardware. I would switch the hardware to All if I had the power. Recommend that this never gets assigned as minor since some legacy/existing code cannot be changed to workaround this bug.
The problem is in the way that AspectJ handles its pseudo-keywords. Identifiers such as "aspect", "pointcut", "before", "after" etc. are treated as keywords in the context in which they may legitimately appear, but as identifiers in other contexts. This *should* allow you to name your variable before and after in the fragments of code shown in this bug report, but where the grammar has been extended to cope with the new features of Java5, we clearly haven't yet nailed all of the places where we need to be accomodating. Fix will be to find the grammar production for these expressions and ensure that any use of 'Identifier' is replaced by 'JavaIdentifier'. Still targetting to fix this as part of the current milestone (M3) development.
turns out a whole family of expressions fail, eg. before * after, before >>> x, after \ before etc.. all of these are now successfully compiled as expected. Fix committed to tree.