[jboss-cvs] JBossAS SVN: r60394 - branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Feb 7 12:57:55 EST 2007


Author: kabir.khan at jboss.com
Date: 2007-02-07 12:57:54 -0500 (Wed, 07 Feb 2007)
New Revision: 60394

Modified:
   branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/JoinpointSimpleClassifier.java
Log:
[JBAOP-358] Handle NotFoundExceptions for unused members gracefully.

Modified: branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/JoinpointSimpleClassifier.java
===================================================================
--- branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/JoinpointSimpleClassifier.java	2007-02-07 17:43:30 UTC (rev 60393)
+++ branches/Branch_AOP_1_5/aop/src/main/org/jboss/aop/instrument/JoinpointSimpleClassifier.java	2007-02-07 17:57:54 UTC (rev 60394)
@@ -62,14 +62,21 @@
       {
          Pointcut pointcut = (Pointcut) it.next();
          
-         if (joinpointMatcher.matches(pointcut, advisor, member)) 
+         try
          {
-            if (AspectManager.verbose)
+            if (joinpointMatcher.matches(pointcut, advisor, member)) 
             {
-               System.out.println("[debug] " + member + " matches pointcut: " + pointcut.getExpr());
+               if (AspectManager.verbose)
+               {
+                  System.out.println("[debug] " + member + " matches pointcut: " + pointcut.getExpr());
+               }
+               return JoinpointClassification.WRAPPED; 
             }
-            return JoinpointClassification.WRAPPED; 
          }
+         catch (RuntimeException e)
+         {
+            return handleError(e, member);
+         }
       }
       if (AspectManager.verbose)
       {
@@ -77,4 +84,38 @@
       }
       return JoinpointClassification.NOT_INSTRUMENTED;
    }
+   
+   private JoinpointClassification handleError(RuntimeException e, CtMember member)
+   {
+      if (AspectManager.suppressTransformationErrors)
+      {
+         //An unused field may be of a type, or an unused method may have return-type/parameters that are not on the classpath
+         //If supress transformationerrors=true, we should simply log that this member cannot be woven and continue.
+         //Loadtime weaving with JRockit seems especially sensitive to this 
+         NotFoundException nfe = null;
+         Throwable cause = e.getCause();
+
+         while (cause != null)
+         {
+            if (cause instanceof NotFoundException)
+            {
+               nfe = (NotFoundException)cause;
+               break;
+            }
+            cause = cause.getCause();
+         }
+         
+         if (nfe != null)
+         {
+            System.err.println("The member " + member.getName() + " in " + member.getDeclaringClass().getName() + 
+                  " uses the type " + nfe.getMessage() + " which cannot be found on the classpath. Weaving is therefore skipped for this particular member");
+            if (AspectManager.verbose)
+            {
+               e.printStackTrace();
+            }
+            return JoinpointClassification.NOT_INSTRUMENTED;
+         }
+      }
+      throw e;
+   }
 }
\ No newline at end of file




More information about the jboss-cvs-commits mailing list