--- /dev/null
+aspect ModelErrorConversion {
+
+
+ // convert exception types
+ after(Entity entity) throwing (HibernateException e): modelExec(entity) {
+ convertException(e, entity, thisJoinPoint);
+ }
+ after(Entity entity) throwing (ServiceException e): modelExec(entity) {
+ convertException(e, entity, thisJoinPoint);
+ }
+ after(Entity entity) throwing (SOAPException e): modelExec(entity) {
+ convertException(e, entity, thisJoinPoint);
+ }
+ after(Entity entity) throwing (SOAPFaultException e): modelExec(entity) {
+ convertException(e, entity, thisJoinPoint);
+ }
+
+ /** execution of any method in the model */
+ pointcut modelExecStatic() :
+ execution(* model..*(..));
+
+ pointcut modelExec(Entity entity) :
+ modelExecStatic() && this(entity);
+ // soften the checked exceptions
+ declare soft: ServiceException: modelExecStatic();
+ declare soft: SOAPException: modelExecStatic();
+
+
+ /** Converts exceptions to model exceptions, storing context */
+ private void convertException(Exception e, Entity entity,
+ JoinPoint jp) {
+ ModelException me = new ModelException(e);
+ me.setEntity(entity);
+ me.setArgs(jp.getArgs());
+ // ModelException extends RuntimeException, so this is unchecked
+ throw me;
+ }
+}
+
+class HibernateException extends RuntimeException {}
+class ServiceException extends Exception {}
+class SOAPException extends Exception {}
+class SOAPFaultException extends RuntimeException {}
+
+class Entity {}
+
+class ModelException extends RuntimeException {
+ public ModelException(Throwable t) { super(t); }
+ public void setEntity(Entity entity) {}
+ public void setArgs(Object[] argz) {}
+}
public void testIncorrectlyReferencingPointcuts_pr122452_2() { runTest("incorrectly referencing pointcuts - 2");}
public void testInlinevisitorNPE_pr123901() { runTest("inlinevisitor NPE");}
//public void testExposingWithintype_enh123423() { runTest("exposing withintype");}
+ //public void testMissingImport_pr127299() { runTest("missing import gives funny message");}
+ public void testUnusedInterfaceMessage_pr120527() { runTest("incorrect unused interface message");}
public void testMixingNumbersOfTypeParameters_pr125080() {
runTest("mixing numbers of type parameters");
<compile files="pr122458.aj" options="-1.5 -emacssym"/>
</ajc-test>
+ <ajc-test dir="bugs151/pr127299" title="missing import gives funny message">
+ <compile files="ModelErrorConversion.aj" options="-1.5"/>
+ </ajc-test>
+
+ <ajc-test dir="bugs151/pr120527" title="incorrect unused interface message">
+ <compile files="Bugs.aj" options="-warn:unusedPrivate"/>
+ </ajc-test>
+
<ajc-test dir="bugs151/pr123901" title="inlinevisitor NPE">
<compile files="A.java,B.java" options="-1.5">
<message kind="error" line="5" text="a.A cannot be resolved or is not a field"/>