]> source.dussan.org Git - aspectj.git/commitdiff
Fix for Bugzilla Bug 72699
authoraclement <aclement>
Fri, 27 Aug 2004 11:18:01 +0000 (11:18 +0000)
committeraclement <aclement>
Fri, 27 Aug 2004 11:18:01 +0000 (11:18 +0000)
   Bogus error message: The abstract method ajc$pointcut$$tracingScope$a2 in type Tracing can only be defined by an abstract class

org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/PointcutDeclaration.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java
tests/bugs/BogusMessage.java [new file with mode: 0644]
tests/bugs/BogusMessage2.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc121/Ajc121Tests.java
tests/src/org/aspectj/systemtest/ajc121/ajc121-tests.xml

index e1c6673b76330dfc736f218f8aedf5d8fe7f158f..1993e68360f79c96d71d76d2dc9e0a8654bc0d2c 100644 (file)
@@ -76,14 +76,21 @@ public class PointcutDeclaration extends AjMethodDeclaration {
                selector = CharOperation.concat(mangledPrefix, '$', selector, '$',
                                Integer.toHexString(sourceStart).toCharArray());
                                
-               if (Modifier.isAbstract(this.declaredModifiers) && 
-                       !(typeDec instanceof AspectDeclaration))
-               {
-                       typeDec.scope.problemReporter().signalError(sourceStart, sourceEnd, 
-                               "The abstract pointcut " + new String(declaredName) +
-                               " can only be defined in an aspect");
-                       ignoreFurtherInvestigation = true;
-                       return;
+               if (Modifier.isAbstract(this.declaredModifiers)) {
+                       if (!(typeDec instanceof AspectDeclaration)) {
+                               typeDec.scope.problemReporter().signalError(sourceStart, sourceEnd, 
+                                               "The abstract pointcut " + new String(declaredName) +
+                                               " can only be defined in an aspect");
+                               ignoreFurtherInvestigation = true;
+                               return;
+                       } else if (!Modifier.isAbstract(typeDec.modifiers)) {
+                               typeDec.scope.problemReporter().signalError(sourceStart, sourceEnd, 
+                                               "The abstract pointcut " + new String(declaredName) +
+                                               " can only be defined in an abstract aspect");
+
+                               ignoreFurtherInvestigation = true;
+                               return;
+                       }
                }
                
                if (pointcutDesignator != null) {
index 77457f879f27ceb560a2a1a008078611aec1171a..5ac77b4ad9e073279261728104eba29cee87e20b 100644 (file)
@@ -31,6 +31,7 @@ import org.eclipse.jdt.internal.compiler.CompilationResult;
 import org.eclipse.jdt.internal.compiler.IErrorHandlingPolicy;
 import org.eclipse.jdt.internal.compiler.IProblemFactory;
 import org.eclipse.jdt.internal.compiler.ast.ASTNode;
+import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
 import org.eclipse.jdt.internal.compiler.ast.Argument;
 import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
 import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
@@ -41,6 +42,7 @@ import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
 import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
 import org.eclipse.jdt.internal.compiler.problem.ProblemReporter;
 import org.eclipse.jdt.core.compiler.CharOperation;
+import org.eclipse.jdt.core.compiler.IProblem;
 
 /**
  * Extends problem reporter to support compiler-side implementation of declare soft. 
@@ -221,5 +223,22 @@ public class AjProblemReporter extends ProblemReporter {
         if (reportIt) 
                super.javadocMissingParamTag(arg, modifiers);
     }
+    
+    public void abstractMethodInAbstractClass(SourceTypeBinding type, AbstractMethodDeclaration methodDecl) {
+
+       String abstractMethodName = new String(methodDecl.selector);
+       if (abstractMethodName.startsWith("ajc$pointcut")) {
+               // This will already have been reported, see: PointcutDeclaration.postParse()
+               return;
+       }
+       String[] arguments = new String[] {new String(type.sourceName()), abstractMethodName};
+       super.handle(
+               IProblem.AbstractMethodInAbstractClass,
+               arguments,
+               arguments,
+               methodDecl.sourceStart,
+               methodDecl.sourceEnd,this.referenceContext, 
+                       this.referenceContext == null ? null : this.referenceContext.compilationResult());
+    }
 
 }
diff --git a/tests/bugs/BogusMessage.java b/tests/bugs/BogusMessage.java
new file mode 100644 (file)
index 0000000..d11dd6d
--- /dev/null
@@ -0,0 +1,4 @@
+public aspect BogusMessage {
+       public abstract pointcut tracingScope();
+
+}
\ No newline at end of file
diff --git a/tests/bugs/BogusMessage2.java b/tests/bugs/BogusMessage2.java
new file mode 100644 (file)
index 0000000..26ccc36
--- /dev/null
@@ -0,0 +1,3 @@
+public class BogusMessage2 {
+       public abstract pointcut tracingScope();
+}
\ No newline at end of file
index 7c3e3a26198d9d093424644d48a5738edb221c67..0ecb6e6dc98dea01ebe14f4c74aeb68b1ef11212 100644 (file)
@@ -271,5 +271,13 @@ public class Ajc121Tests extends org.aspectj.testing.XMLBasedAjcTestCase {
   public void test051_arrayCloningInJava5() {
     runTest("AJC possible bug with static nested classes");
   }
+  
+  public void test052_bogusMessage1() {
+    runTest("Bogus error message: The abstract method ajc$pointcut$$tracingScope$a2 in type Tracing can only be defined by an abstract class (1)");
+  }
+  
+  public void test053_bogusMessage2() {
+    runTest("Bogus error message: The abstract method ajc$pointcut$$tracingScope$a2 in type Tracing can only be defined by an abstract class (2)");
+  }
 }
 
index dd966429518544554493fb8f299e63811a833a96..e4b3a793c94ab8883b98ea3388f4c95b6fcfcbaa 100644 (file)
           <compile files="A.java" inpath="OneFiveCode.jar"/>
           <!--run class="C"/-->
     </ajc-test>
+
+    <ajc-test dir="bugs" pr="72699"
+          title="Bogus error message: The abstract method ajc$pointcut$$tracingScope$a2 in type Tracing can only be defined by an abstract class (1)">
+          <compile files="BogusMessage.java">
+            <message kind="error" line="2" text="The abstract pointcut tracingScope can only be defined in an abstract aspect"/>
+          </compile>
+    </ajc-test>
+    
+    <ajc-test dir="bugs" pr="72699"
+          title="Bogus error message: The abstract method ajc$pointcut$$tracingScope$a2 in type Tracing can only be defined by an abstract class (2)">
+          <compile files="BogusMessage2.java">
+            <message kind="error" line="2" text="The abstract pointcut tracingScope can only be defined in an aspect"/>
+          </compile>
+    </ajc-test>
+    
        
\ No newline at end of file