From f82e6f25e306cefb9278e46df2abd3765582ff36 Mon Sep 17 00:00:00 2001 From: acolyer Date: Mon, 14 Mar 2005 21:39:32 +0000 Subject: [PATCH] fix for missing syntax error on execution((@XXX *) Foo.new(..)) ^^^ --- tests/java5/annotations/SyntaxError.aj | 21 ++++++++++++++++++ .../systemtest/ajc150/Ajc150Tests.java | 4 ++++ .../org/aspectj/systemtest/ajc150/ajc150.xml | 8 ++++++- .../weaver/patterns/PatternParser.java | 22 ++++++++++--------- 4 files changed, 44 insertions(+), 11 deletions(-) create mode 100644 tests/java5/annotations/SyntaxError.aj diff --git a/tests/java5/annotations/SyntaxError.aj b/tests/java5/annotations/SyntaxError.aj new file mode 100644 index 000000000..ed0085c74 --- /dev/null +++ b/tests/java5/annotations/SyntaxError.aj @@ -0,0 +1,21 @@ +public aspect SyntaxError { + + after(Object x) : execution((@Alien *) Passenger+.new(..)) && this(x) { + System.out.println("after alien..."); + } + +} + +@interface Alien{} + +class Passenger { + + @Alien Passenger() {} + +} + +class SubPassenger extends Passenger { + + @Alien SubPassenger() { super(); } + +} \ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index a1aeb6d77..3d75b53c7 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -137,6 +137,10 @@ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { runTest("declare soft w. catch block"); } + public void testSyntaxError() { + runTest("invalid cons syntax"); + } + // helper methods..... public SyntheticRepository createRepos(File cpentry) { diff --git a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml index 2e165f3a8..84e1de484 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml +++ b/tests/src/org/aspectj/systemtest/ajc150/ajc150.xml @@ -125,7 +125,13 @@ - + + + + + + + diff --git a/weaver/src/org/aspectj/weaver/patterns/PatternParser.java b/weaver/src/org/aspectj/weaver/patterns/PatternParser.java index c9ca1ccf6..91f32baba 100644 --- a/weaver/src/org/aspectj/weaver/patterns/PatternParser.java +++ b/weaver/src/org/aspectj/weaver/patterns/PatternParser.java @@ -985,24 +985,26 @@ public class PatternParser { name = NamePattern.ANY; } else { kind = Member.METHOD; + IToken nameToken = tokenSource.peek(); declaringType = parseTypePattern(); if (maybeEat(".")) { + nameToken = tokenSource.peek(); name = parseNamePattern(); } else { name = tryToExtractName(declaringType); - if (name == null) { - throw new ParserException("name pattern", tokenSource.peek()); - } - String simpleName = name.maybeGetSimpleName(); - //XXX should add check for any Java keywords - if (simpleName != null && simpleName.equals("new")) { - throw new ParserException("constructor patterns have no return type", - tokenSource.peek()); - } if (declaringType.toString().equals("")) { declaringType = TypePattern.ANY; } - } + } + if (name == null) { + throw new ParserException("name pattern", tokenSource.peek()); + } + String simpleName = name.maybeGetSimpleName(); + //XXX should add check for any Java keywords + if (simpleName != null && simpleName.equals("new")) { + throw new ParserException("method name (not constructor)", + nameToken); + } } TypePatternList parameterTypes = parseArgumentsPattern(); -- 2.39.5