diff options
author | jhugunin <jhugunin> | 2004-01-14 15:24:06 +0000 |
---|---|---|
committer | jhugunin <jhugunin> | 2004-01-14 15:24:06 +0000 |
commit | 5834de97836ebcc056415736c17c46e8b1dfaf5a (patch) | |
tree | a7b87ccc35e25aafe73d24d17f08cc33f62b22c4 /org.aspectj.ajdt.core | |
parent | 7bbd1f419239dc9e8b46e7fd912b2bc007bbd76a (diff) | |
download | aspectj-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 'org.aspectj.ajdt.core')
-rw-r--r-- | org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectClinit.java | 23 | ||||
-rw-r--r-- | org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java | 15 |
2 files changed, 33 insertions, 5 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectClinit.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectClinit.java index 653f3d537..ebead22eb 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectClinit.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectClinit.java @@ -18,12 +18,16 @@ import org.aspectj.weaver.AjcMemberMaker; import org.eclipse.jdt.internal.compiler.CompilationResult; import org.eclipse.jdt.internal.compiler.ast.Clinit; import org.eclipse.jdt.internal.compiler.codegen.CodeStream; +import org.eclipse.jdt.internal.compiler.codegen.ExceptionLabel; +import org.eclipse.jdt.internal.compiler.codegen.Label; import org.eclipse.jdt.internal.compiler.lookup.ClassScope; +import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; public class AspectClinit extends Clinit { private boolean hasPre, hasPost; + private FieldBinding initFailureField; - public AspectClinit(Clinit old, CompilationResult compilationResult, boolean hasPre, boolean hasPost) { + public AspectClinit(Clinit old, CompilationResult compilationResult, boolean hasPre, boolean hasPost, FieldBinding initFailureField) { super(compilationResult); this.needFreeReturn = old.needFreeReturn; this.sourceEnd = old.sourceEnd; @@ -33,12 +37,19 @@ public class AspectClinit extends Clinit { this.hasPre = hasPre; this.hasPost = hasPost; + this.initFailureField = initFailureField; } + + private ExceptionLabel handlerLabel; protected void generateSyntheticCode( ClassScope classScope, CodeStream codeStream) { + if (initFailureField != null) { + handlerLabel = new ExceptionLabel(codeStream, classScope.getJavaLangThrowable()); + } + if (hasPre) { final EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(classScope); @@ -64,6 +75,16 @@ public class AspectClinit extends Clinit { ))); } + if (initFailureField != null) { + handlerLabel.placeEnd(); + Label endLabel = new Label(codeStream); + codeStream.goto_(endLabel); + + handlerLabel.place(); + codeStream.putstatic(initFailureField); + endLabel.place(); + } + } } diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java index 6fd3dd5f3..a823f10b0 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/AspectDeclaration.java @@ -151,7 +151,7 @@ public class AspectDeclaration extends TypeDeclaration { } } - + private FieldBinding initFailureField= null; public void generateCode(ClassFile enclosingClassFile) { if (ignoreFurtherInvestigation) { @@ -170,18 +170,22 @@ public class AspectDeclaration extends TypeDeclaration { if (!isAbstract()) { + initFailureField = factory.makeFieldBinding(AjcMemberMaker.initFailureCauseField(typeX)); + binding.addField(initFailureField); + if (perClause == null) { // we've already produced an error for this } else if (perClause.getKind() == PerClause.SINGLETON) { binding.addField(factory.makeFieldBinding(AjcMemberMaker.perSingletonField( typeX))); - methods[0] = new AspectClinit((Clinit)methods[0], compilationResult, false, true); + + methods[0] = new AspectClinit((Clinit)methods[0], compilationResult, false, true, initFailureField); } else if (perClause.getKind() == PerClause.PERCFLOW) { binding.addField( factory.makeFieldBinding( AjcMemberMaker.perCflowField( typeX))); - methods[0] = new AspectClinit((Clinit)methods[0], compilationResult, true, false); + methods[0] = new AspectClinit((Clinit)methods[0], compilationResult, true, false, null); } else if (perClause.getKind() == PerClause.PEROBJECT) { // binding.addField( // world.makeFieldBinding( @@ -522,10 +526,13 @@ public class AspectDeclaration extends TypeDeclaration { codeStream.ifnull(isNull); codeStream.areturn(); isNull.place(); + codeStream.new_(world.makeTypeBinding(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION)); codeStream.dup(); + codeStream.ldc(typeX.getNameAsIdentifier()); + codeStream.getstatic(initFailureField); codeStream.invokespecial(world.makeMethodBindingForCall( - AjcMemberMaker.noAspectBoundExceptionInit() + AjcMemberMaker.noAspectBoundExceptionInitWithCause() )); codeStream.athrow(); // body ends here |