summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhugunin <jhugunin>2003-03-13 19:16:53 +0000
committerjhugunin <jhugunin>2003-03-13 19:16:53 +0000
commit56cc4f27afaf591f8cebb2450513cc6eb7d51299 (patch)
tree0279a7e07f317888c2ddbee33a63ce4d5ff7c342
parent21f9d5a71fa19792e0268a97955efdb8bf5d7916 (diff)
downloadaspectj-1_1_0_RC1.tar.gz
aspectj-1_1_0_RC1.zip
test and fix for Bugzilla Bug 34925 v1_1_0_RC1
compiler crash on yesterday's rc1 build
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseShadow.java67
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java40
-rw-r--r--tests/ajcTests.xml6
-rw-r--r--tests/bugs/ConvertToUnchecked.java68
-rw-r--r--tests/jimTests.xml2
5 files changed, 133 insertions, 50 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseShadow.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseShadow.java
index 2e0630f6c..a8b5d3d40 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseShadow.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/lookup/EclipseShadow.java
@@ -13,25 +13,12 @@
package org.aspectj.ajdt.internal.compiler.lookup;
-import org.aspectj.ajdt.internal.compiler.ast.AdviceDeclaration;
-import org.aspectj.ajdt.internal.compiler.ast.InterTypeConstructorDeclaration;
-import org.aspectj.ajdt.internal.compiler.ast.InterTypeDeclaration;
-import org.aspectj.ajdt.internal.compiler.ast.InterTypeFieldDeclaration;
-import org.aspectj.ajdt.internal.compiler.ast.InterTypeMethodDeclaration;
+
+import org.aspectj.ajdt.internal.compiler.ast.*;
import org.aspectj.bridge.ISourceLocation;
-import org.aspectj.bridge.SourceLocation;
-import org.aspectj.weaver.Member;
-import org.aspectj.weaver.Shadow;
-import org.aspectj.weaver.TypeX;
-import org.aspectj.weaver.World;
+import org.aspectj.weaver.*;
import org.aspectj.weaver.ast.Var;
-import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.AllocationExpression;
-import org.eclipse.jdt.internal.compiler.ast.AstNode;
-import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
-import org.eclipse.jdt.internal.compiler.ast.ExplicitConstructorCall;
-import org.eclipse.jdt.internal.compiler.ast.MessageSend;
-import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.*;
import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
/**
@@ -44,8 +31,8 @@ import org.eclipse.jdt.internal.compiler.impl.ReferenceContext;
public class EclipseShadow extends Shadow {
EclipseFactory world;
AstNode astNode;
- //XXXReferenceContext context;
- AbstractMethodDeclaration enclosingMethod;
+ ReferenceContext context;
+ //AbstractMethodDeclaration enclosingMethod;
public EclipseShadow(EclipseFactory world, Kind kind, Member signature, AstNode astNode,
ReferenceContext context)
@@ -53,8 +40,7 @@ public class EclipseShadow extends Shadow {
super(kind, signature, null);
this.world = world;
this.astNode = astNode;
- //XXX can this fail in practice?
- this.enclosingMethod = (AbstractMethodDeclaration)context;
+ this.context = context;
}
public World getIWorld() {
@@ -63,7 +49,13 @@ public class EclipseShadow extends Shadow {
public TypeX getEnclosingType() {
- return world.fromBinding(enclosingMethod.binding.declaringClass);
+ if (context instanceof TypeDeclaration) {
+ return world.fromBinding(((TypeDeclaration)context).binding);
+ } else if (context instanceof AbstractMethodDeclaration) {
+ return world.fromBinding(((AbstractMethodDeclaration)context).binding.declaringClass);
+ } else {
+ return ResolvedTypeX.MISSING;
+ }
}
public ISourceLocation getSourceLocation() {
@@ -72,7 +64,14 @@ public class EclipseShadow extends Shadow {
}
public Member getEnclosingCodeSignature() {
- return world.makeResolvedMember(enclosingMethod.binding);
+ if (context instanceof TypeDeclaration) {
+ return new Member(Member.STATIC_INITIALIZATION, getEnclosingType(), 0,
+ ResolvedTypeX.VOID, "<clinit>", TypeX.NONE);
+ } else if (context instanceof AbstractMethodDeclaration) {
+ return world.makeResolvedMember(((AbstractMethodDeclaration)context).binding);
+ } else {
+ return null;
+ }
}
// -- all below here are only used for implementing, not in matching
@@ -114,14 +113,12 @@ public class EclipseShadow extends Shadow {
world.makeResolvedMember(e.binding), astNode, context);
} else if (astNode instanceof MessageSend) {
MessageSend e = (MessageSend)astNode;
+ if (e.isSuperAccess()) return null; // super calls don't have shadows
return new EclipseShadow(world, Shadow.MethodCall,
world.makeResolvedMember(e.binding), astNode, context);
} else if (astNode instanceof ExplicitConstructorCall) {
- //??? these need to be ignored, they don't have shadows
- return null;
-// ExplicitConstructorCall e = (ExplicitConstructorCall)astNode;
-// return new EclipseShadow(world, Shadow.MethodCall,
-// world.makeResolvedMember(e.binding), astNode, context);
+ //??? these should be ignored, they don't have shadows
+ return null;
} else if (astNode instanceof AbstractMethodDeclaration) {
AbstractMethodDeclaration e = (AbstractMethodDeclaration)astNode;
Shadow.Kind kind;
@@ -139,13 +136,23 @@ public class EclipseShadow extends Shadow {
kind = Shadow.MethodExecution;
} else if (e instanceof ConstructorDeclaration) {
kind = Shadow.ConstructorExecution;
+ } else if (e instanceof Clinit) {
+ kind = Shadow.StaticInitialization;
} else {
- throw new RuntimeException("unimplemented: " + e);
+ return null;
+ //throw new RuntimeException("unimplemented: " + e);
}
return new EclipseShadow(world, kind,
world.makeResolvedMember(e.binding), astNode, context);
+ } else if (astNode instanceof TypeDeclaration) {
+ return new EclipseShadow(world, Shadow.StaticInitialization,
+ new Member(Member.STATIC_INITIALIZATION,
+ world.fromBinding(((TypeDeclaration)astNode).binding), 0,
+ ResolvedTypeX.VOID, "<clinit>", TypeX.NONE),
+ astNode, context);
} else {
- throw new RuntimeException("unimplemented: " + astNode);
+ return null;
+ //throw new RuntimeException("unimplemented: " + astNode);
}
}
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java
index 16bb99b1a..3981de98b 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/problem/AjProblemReporter.java
@@ -65,31 +65,31 @@ public class AjProblemReporter extends ProblemReporter {
{
if (!world.getWorld().getDeclareSoft().isEmpty()) {
Shadow callSite = world.makeShadow(location, referenceContext);
- if (callSite == null) {
- super.unhandledException(exceptionType, location);
- return;
- }
Shadow enclosingExec = world.makeShadow(referenceContext);
- // System.err.println("about to show error for unhandled exception: " + exceptionType +
- // " at " + location + " in " + referenceContext);
-
+// System.err.println("about to show error for unhandled exception: " + new String(exceptionType.sourceName()) +
+// " at " + location + " in " + referenceContext);
for (Iterator i = world.getWorld().getDeclareSoft().iterator(); i.hasNext(); ) {
DeclareSoft d = (DeclareSoft)i.next();
- FuzzyBoolean match = d.getPointcut().match(callSite);
- if (match.alwaysTrue()) {
- //System.err.println("matched callSite: " + callSite + " with " + d);
- return;
- } else if (!match.alwaysFalse()) {
- throw new RuntimeException("unimplemented, shouldn't have fuzzy match here");
+ if (callSite != null) {
+ FuzzyBoolean match = d.getPointcut().match(callSite);
+ if (match.alwaysTrue()) {
+ //System.err.println("matched callSite: " + callSite + " with " + d);
+ return;
+ } else if (!match.alwaysFalse()) {
+ //!!! need this check to happen much sooner
+ //throw new RuntimeException("unimplemented, shouldn't have fuzzy match here");
+ }
}
-
- match = d.getPointcut().match(enclosingExec);
- if (match.alwaysTrue()) {
- //System.err.println("matched enclosingExec: " + enclosingExec + " with " + d);
- return;
- } else if (!match.alwaysFalse()) {
- throw new RuntimeException("unimplemented, shouldn't have fuzzy match here");
+ if (enclosingExec != null) {
+ FuzzyBoolean match = d.getPointcut().match(enclosingExec);
+ if (match.alwaysTrue()) {
+ //System.err.println("matched enclosingExec: " + enclosingExec + " with " + d);
+ return;
+ } else if (!match.alwaysFalse()) {
+ //!!! need this check to happen much sooner
+ //throw new RuntimeException("unimplemented, shouldn't have fuzzy match here");
+ }
}
}
}
diff --git a/tests/ajcTests.xml b/tests/ajcTests.xml
index c524c7191..2f591fff5 100644
--- a/tests/ajcTests.xml
+++ b/tests/ajcTests.xml
@@ -5762,4 +5762,10 @@
<run class="AspectInitError"/>
</ajc-test>
+ <ajc-test dir="bugs" pr="34925"
+ title="declare soft and throw statements">
+ <compile files="ConvertToUnchecked.java"/>
+ <run class="ConvertToUnchecked"/>
+ </ajc-test>
+
</suite>
diff --git a/tests/bugs/ConvertToUnchecked.java b/tests/bugs/ConvertToUnchecked.java
new file mode 100644
index 000000000..2c7eb6c42
--- /dev/null
+++ b/tests/bugs/ConvertToUnchecked.java
@@ -0,0 +1,68 @@
+
+import org.aspectj.testing.Tester;
+
+/** Bugzilla Bug 34925
+ compiler crash on yesterday's rc1 build
+ */
+import java.io.*;
+
+public aspect ConvertToUnchecked {
+
+ public static void main(String[] args) {
+ try {
+ Foo foo = new Foo("hello");
+ Tester.check(false, "shouldn't get here");
+ } catch (PersistenceException pe) {
+ }
+ }
+
+ // convert IOExceptions in Foo to PersistenceException
+ pointcut module() : within(Foo);
+
+ after() throwing (IOException e) : module() {
+ throw new PersistenceException(e);
+ }
+ declare soft: (IOException): module();
+}
+
+class PersistenceException extends RuntimeException
+{
+ public PersistenceException(Throwable cause) {
+ super(cause);
+ }
+}
+
+
+class Root {
+ Root(String s) throws IOException {
+ }
+}
+
+class Foo extends Root {
+ Foo(String s) {
+ super(s);
+ }
+
+ static {
+ if (false) {
+ getFile();
+ throw new IOException("bar");
+ }
+
+ }
+
+ {
+ if (false) throw new IOException("bar");
+ }
+
+ File f = getFile();
+
+ static File getFile() throws IOException {
+ throw new IOException("bad");
+ }
+
+
+ public void m() {
+ throw new IOException("hi");
+ }
+} \ No newline at end of file
diff --git a/tests/jimTests.xml b/tests/jimTests.xml
index 7c1c4af1f..a0ad71ec7 100644
--- a/tests/jimTests.xml
+++ b/tests/jimTests.xml
@@ -1,6 +1,8 @@
<!DOCTYPE suite SYSTEM "../tests/ajcTestSuite.dtd">
<suite>
+
+
<!--
<ajc-test dir="new" pr="885"