Community
Participate
Working Groups
These test files crash the compiler (in fact if you just compile ConvertToUnchecked it crashes it): ConvertToUnchecked.java: import java.io.IOException; // example 3 aspect ConvertToUnchecked { // make all exceptions in an application unchecked; "soft" //declare soft: (Exception && !RuntimeException): within(com.foo.app..*); // convert IOExceptions in a package to PersistenceException pointcut module() : within(test.*); // within (com.foo.framework.persistence.*); // convert exceptions // within(test.*) would work to allow an immediate catch, except for // the last statement in a try block // however, I suspect that would also generate inefficient code // even this might be inefficient: it needs to wrap every method body in a // try ... catch block after() throwing (IOException e) : within(test.*) { throw new PersistenceException(e); } declare soft: (IOException): module(); } // tested by: test.ConvertToUnchecked ---- PersistenceException.java public class PersistenceException extends Exception { public PersistenceException(Throwable cause) { super(cause); } } --- sample run: C:\ron\devel\articles\errorHandling>ajc -1.4 ConvertToUnchecked.java Persistence Exception.java java.lang.RuntimeException: unimplemented: throw new PersistenceException(e) at org.aspectj.ajdt.internal.compiler.lookup.EclipseShadow.makeShadow (Ec lipseShadow.java:148) at org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory.makeShadow (E clipseFactory.java:292) at org.aspectj.ajdt.internal.compiler.problem.AjProblemReporter.unhandle dException(AjProblemReporter.java:67) at org.eclipse.jdt.internal.compiler.flow.FlowContext.checkExceptionHand lers(FlowContext.java:249) at org.eclipse.jdt.internal.compiler.ast.ThrowStatement.analyseCode (Thro wStatement.java:35) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.analy seCode(AbstractMethodDeclaration.java:106) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.analyseCode (Typ eDeclaration.java:445) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.anal yseCode(CompilationUnitDeclaration.java:76) at org.eclipse.jdt.internal.compiler.Compiler.process (Compiler.java:539) at org.aspectj.ajdt.internal.compiler.AjCompiler.process (AjCompiler.java :65) at org.eclipse.jdt.internal.compiler.Compiler.compile (Compiler.java:340) at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile (Ab stractImageBuilder.java:232) at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile (Ab stractImageBuilder.java:171) at org.aspectj.ajdt.internal.core.builder.AjBuildManager$BatchBuilder.ru n(AjBuildManager.java:656) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild (AjBu ildManager.java:139) at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:55) at org.aspectj.tools.ajc.Main.run(Main.java:216) at org.aspectj.tools.ajc.Main.runMain(Main.java:155) at org.aspectj.tools.ajc.Main.main(Main.java:72) C:\ron\devel\articles\errorHandling\ConvertToUnchecked.java:0 Internal compiler error java.lang.RuntimeException: unimplemented: throw new PersistenceException(e) at org.aspectj.ajdt.internal.compiler.lookup.EclipseShadow.makeShadow (Ec lipseShadow.java:148) at org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory.makeShadow (E clipseFactory.java:292) at org.aspectj.ajdt.internal.compiler.problem.AjProblemReporter.unhandle dException(AjProblemReporter.java:67) at org.eclipse.jdt.internal.compiler.flow.FlowContext.checkExceptionHand lers(FlowContext.java:249) at org.eclipse.jdt.internal.compiler.ast.ThrowStatement.analyseCode (Thro wStatement.java:35) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.analy seCode(AbstractMethodDeclaration.java:106) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.analyseCode (Typ eDeclaration.java:445) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.anal yseCode(CompilationUnitDeclaration.java:76) at org.eclipse.jdt.internal.compiler.Compiler.process (Compiler.java:539) at org.aspectj.ajdt.internal.compiler.AjCompiler.process (AjCompiler.java :65) at org.eclipse.jdt.internal.compiler.Compiler.compile (Compiler.java:340) at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile (Ab stractImageBuilder.java:232) at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile (Ab stractImageBuilder.java:171) at org.aspectj.ajdt.internal.core.builder.AjBuildManager$BatchBuilder.ru n(AjBuildManager.java:656) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild (AjBu ildManager.java:139) at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:55) at org.aspectj.tools.ajc.Main.run(Main.java:216) at org.aspectj.tools.ajc.Main.runMain(Main.java:155) at org.aspectj.tools.ajc.Main.main(Main.java:72) !! no source information available !! ABORT Exception thrown from AspectJ 1.1rc1 This might be logged as a bug already -- find current bugs at http://bugs.eclipse.org/bugs/buglist.cgi?product=AspectJ&component=Compiler Bugs for exceptions thrown have titles File:line from the top stack, e.g., "SomeFile.java:243" If you don't find the exception below in a bug, please add a new bug at http://bugs.eclipse.org/bugs/enter_bug.cgi?product=AspectJ To make the bug a priority, please include a test program that can reproduce this exception. unimplemented: throw new PersistenceException(e) unimplemented: throw new PersistenceException(e) java.lang.RuntimeException: unimplemented: throw new PersistenceException(e) at org.aspectj.ajdt.internal.compiler.lookup.EclipseShadow.makeShadow (Ec lipseShadow.java:148) at org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory.makeShadow (E clipseFactory.java:292) at org.aspectj.ajdt.internal.compiler.problem.AjProblemReporter.unhandle dException(AjProblemReporter.java:67) at org.eclipse.jdt.internal.compiler.flow.FlowContext.checkExceptionHand lers(FlowContext.java:249) at org.eclipse.jdt.internal.compiler.ast.ThrowStatement.analyseCode (Thro wStatement.java:35) at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.analy seCode(AbstractMethodDeclaration.java:106) at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.analyseCode (Typ eDeclaration.java:445) at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.anal yseCode(CompilationUnitDeclaration.java:76) at org.eclipse.jdt.internal.compiler.Compiler.process (Compiler.java:539) at org.aspectj.ajdt.internal.compiler.AjCompiler.process (AjCompiler.java :65) at org.eclipse.jdt.internal.compiler.Compiler.compile (Compiler.java:340) at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile (Ab stractImageBuilder.java:232) at org.eclipse.jdt.internal.core.builder.AbstractImageBuilder.compile (Ab stractImageBuilder.java:171) at org.aspectj.ajdt.internal.core.builder.AjBuildManager$BatchBuilder.ru n(AjBuildManager.java:656) at org.aspectj.ajdt.internal.core.builder.AjBuildManager.batchBuild (AjBu ildManager.java:139) at org.aspectj.ajdt.ajc.AjdtCommand.runCommand(AjdtCommand.java:55) at org.aspectj.tools.ajc.Main.run(Main.java:216) at org.aspectj.tools.ajc.Main.runMain(Main.java:155) at org.aspectj.tools.ajc.Main.main(Main.java:72) 1 fail|abort, 1 error
I actually ran this test against the latest rc1 build (I pulled it from cvs on my home machine and didn't realize there was a new build til I read my email)...
This bug is easily reproduced. The bug means that declare soft can not be used in a system that has explicit throw statements which throw checked exceptions that are not permitted except through the declare soft. This particular example could be worked-around by making PersistenceException a RuntimeException. This clearly seems to be the right choice in this minimal test case. However, the bug would still be revealed if the rest of the code contains an explicit 'throw IOException' that was not declared by the enclosing method. This bug is right on the border-line for delaying the RC1 release and we are currently evaluating that. It will be fixed shortly in the active cvs tree.
resolved in tree and for 1.1rc1 release