]> source.dussan.org Git - aspectj.git/commitdiff
fixes for 119210 - allows for autoboxing with around advice.
authoraclement <aclement>
Thu, 8 Dec 2005 15:35:45 +0000 (15:35 +0000)
committeraclement <aclement>
Thu, 8 Dec 2005 15:35:45 +0000 (15:35 +0000)
weaver/src/org/aspectj/weaver/bcel/BcelShadow.java
weaver/src/org/aspectj/weaver/bcel/Utility.java

index d9ab3af72679fd3e4e996380652ae4dc1dfa08e6..9163bc0194d4ca566550adefe014d6110c49f6c6 100644 (file)
@@ -2231,7 +2231,7 @@ public class BcelShadow extends Shadow {
                        Utility.createConversion(
                            getFactory(), 
                            BcelWorld.makeBcelType(mungerSig.getReturnType()), 
-                           extractedMethod.getReturnType()));
+                           extractedMethod.getReturnType(),world.isInJava5Mode()));
                    if (! isFallsThrough()) {
                        advice.append(InstructionFactory.createReturn(extractedMethod.getReturnType()));
                    }
@@ -2659,7 +2659,7 @@ public class BcelShadow extends Shadow {
                    Utility.createConversion(
                        getFactory(), 
                        BcelWorld.makeBcelType(munger.getSignature().getReturnType()), 
-                       callbackMethod.getReturnType());
+                       callbackMethod.getReturnType(),world.isInJava5Mode());
                        if (!isFallsThrough()) {
                                returnConversionCode.append(
                                        InstructionFactory.createReturn(callbackMethod.getReturnType()));
index ef7324a8e09ce05e53554e0901f8fbb851fbb8d6..7eec5ef41e263d0ba35ab2d964454e3c0218c120 100644 (file)
@@ -394,11 +394,15 @@ public class Utility {
         }
     }
 
+    public static InstructionList createConversion(InstructionFactory factory,Type fromType,Type toType) {
+       return createConversion(factory,fromType,toType,false);
+    }
     
     public static InstructionList createConversion(
             InstructionFactory fact,
             Type fromType,
-            Type toType) {
+            Type toType,
+            boolean allowAutoboxing) {
         //System.out.println("cast to: " + toType);
 
         InstructionList il = new InstructionList();
@@ -459,6 +463,35 @@ public class Utility {
                 && ((ReferenceType)fromType).isAssignmentCompatibleWith(toType)) {
             return il;
         }
+        
+        if (allowAutoboxing) {
+               if (toType instanceof BasicType && fromType instanceof ReferenceType) {
+                       // unboxing
+                       String name = toType.toString() + "Value";
+                   il.append(
+                       fact.createInvoke(
+                           "org.aspectj.runtime.internal.Conversions",
+                           name,
+                           toType,
+                           new Type[] { Type.OBJECT },
+                           Constants.INVOKESTATIC));
+                   return il;
+               }
+               
+               if (fromType instanceof BasicType && toType instanceof ReferenceType) {
+                       // boxing
+                       String name = fromType.toString() + "Object";
+                   il.append(
+                       fact.createInvoke(
+                           "org.aspectj.runtime.internal.Conversions",
+                           name,
+                           Type.OBJECT,
+                           new Type[] { fromType },
+                           Constants.INVOKESTATIC));
+                   il.append(fact.createCast(Type.OBJECT, toType));
+                   return il;
+               }
+        }
 
         il.append(fact.createCast(fromType, toType));
         return il;