aboutsummaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
authorjhugunin <jhugunin>2004-01-14 15:24:06 +0000
committerjhugunin <jhugunin>2004-01-14 15:24:06 +0000
commit5834de97836ebcc056415736c17c46e8b1dfaf5a (patch)
treea7b87ccc35e25aafe73d24d17f08cc33f62b22c4 /weaver
parent7bbd1f419239dc9e8b46e7fd912b2bc007bbd76a (diff)
downloadaspectj-5834de97836ebcc056415736c17c46e8b1dfaf5a.tar.gz
aspectj-5834de97836ebcc056415736c17c46e8b1dfaf5a.zip
Fix for Bugzilla Bug 44587
Erroneous exception conversion and Bugzilla Bug 34206 before():execution(new(..)) does not throw NoAspectBoundException All exceptions that occur during the static intialization of a persingleton aspect will be swallowed. When using that aspect (via aspectOf()) a NoAspectBoundException will be thrown with the original exception from the staitc initializer as the cause.
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/org/aspectj/weaver/AjcMemberMaker.java30
-rw-r--r--weaver/src/org/aspectj/weaver/NameMangler.java4
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java18
3 files changed, 45 insertions, 7 deletions
diff --git a/weaver/src/org/aspectj/weaver/AjcMemberMaker.java b/weaver/src/org/aspectj/weaver/AjcMemberMaker.java
index d91d5f65c..52d6d6144 100644
--- a/weaver/src/org/aspectj/weaver/AjcMemberMaker.java
+++ b/weaver/src/org/aspectj/weaver/AjcMemberMaker.java
@@ -15,6 +15,8 @@ package org.aspectj.weaver;
import java.lang.reflect.Modifier;
+import org.aspectj.weaver.ResolvedTypeX.Name;
+
public class AjcMemberMaker {
private static final int PUBLIC_STATIC_FINAL =
@@ -60,14 +62,23 @@ public class AjcMemberMaker {
public static Member noAspectBoundExceptionInit() {
return new ResolvedMember(
- Member.METHOD,
- NO_ASPECT_BOUND_EXCEPTION,
- Modifier.PUBLIC,
- "<init>",
- "()V");
+ Member.METHOD,
+ NO_ASPECT_BOUND_EXCEPTION,
+ Modifier.PUBLIC,
+ "<init>",
+ "()V");
}
+ public static Member noAspectBoundExceptionInitWithCause() {
+ return new ResolvedMember(
+ Member.METHOD,
+ NO_ASPECT_BOUND_EXCEPTION,
+ Modifier.PUBLIC,
+ "<init>",
+ "(Ljava/lang/String;Ljava/lang/Throwable;)V");
+ }
+
public static ResolvedMember perCflowPush(TypeX declaringType) {
return new ResolvedMember(
Member.METHOD,
@@ -95,6 +106,15 @@ public class AjcMemberMaker {
declaringType.getSignature());
}
+
+ public static ResolvedMember initFailureCauseField(TypeX declaringType) {
+ return new ResolvedMember(
+ Member.FIELD,
+ declaringType,
+ PRIVATE_STATIC,
+ NameMangler.INITFAILURECAUSE_FIELD_NAME,
+ TypeX.THROWABLE.getSignature());
+ }
public static ResolvedMember perObjectField(TypeX declaringType, ResolvedTypeX aspectType) {
int modifiers = Modifier.PRIVATE;
diff --git a/weaver/src/org/aspectj/weaver/NameMangler.java b/weaver/src/org/aspectj/weaver/NameMangler.java
index d620ecad8..7db5107ce 100644
--- a/weaver/src/org/aspectj/weaver/NameMangler.java
+++ b/weaver/src/org/aspectj/weaver/NameMangler.java
@@ -40,8 +40,8 @@ public class NameMangler {
public static final String AJC_POST_CLINIT_NAME = PREFIX + "postClinit";
-
-
+ public static final String INITFAILURECAUSE_FIELD_NAME = PREFIX + "initFailureCause";
+
public static String perObjectInterfaceGet(TypeX aspectType) {
return makeName(aspectType.getNameAsIdentifier(), "perObjectGet");
}
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
index fde2d9d0e..8ef653f87 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java
@@ -904,6 +904,8 @@ class BcelClassWeaver implements IClassWeaver {
// assert t.getHandler() == ih
ExceptionRange er = (ExceptionRange) t;
if (er.getCatchType() == null) continue;
+ if (isInitFailureHandler(ih)) return;
+
match(
BcelShadow.makeExceptionHandler(
world,
@@ -915,6 +917,14 @@ class BcelClassWeaver implements IClassWeaver {
}
}
+ private boolean isInitFailureHandler(InstructionHandle ih) {
+ if (ih.getInstruction() instanceof PUTSTATIC) {
+ String name = ((PUTSTATIC)ih.getInstruction()).getFieldName(cpg);
+ if (name.equals(NameMangler.INITFAILURECAUSE_FIELD_NAME)) return true;
+ }
+ return false;
+ }
+
private void matchSetInstruction(
LazyMethodGen mg,
@@ -923,6 +933,10 @@ class BcelClassWeaver implements IClassWeaver {
List shadowAccumulator) {
FieldInstruction fi = (FieldInstruction) ih.getInstruction();
Member field = BcelWorld.makeFieldSignature(clazz, fi);
+
+ // synthetic fields are never join points
+ if (field.getName().startsWith(NameMangler.PREFIX)) return;
+
ResolvedMember resolvedField = field.resolve(world);
if (resolvedField == null) {
// we can't find the field, so it's not a join point.
@@ -946,6 +960,10 @@ class BcelClassWeaver implements IClassWeaver {
private void matchGetInstruction(LazyMethodGen mg, InstructionHandle ih, BcelShadow enclosingShadow, List shadowAccumulator) {
FieldInstruction fi = (FieldInstruction) ih.getInstruction();
Member field = BcelWorld.makeFieldSignature(clazz, fi);
+
+ // synthetic fields are never join points
+ if (field.getName().startsWith(NameMangler.PREFIX)) return;
+
ResolvedMember resolvedField = field.resolve(world);
if (resolvedField == null) {
// we can't find the field, so it's not a join point.