From 8b87db5ac266514d35e1632546d6888e7ca2f6d0 Mon Sep 17 00:00:00 2001 From: aclement Date: Thu, 8 Dec 2005 15:35:45 +0000 Subject: [PATCH] fixes for 119210 - allows for autoboxing with around advice. --- .../org/aspectj/weaver/bcel/BcelShadow.java | 4 +-- .../src/org/aspectj/weaver/bcel/Utility.java | 35 ++++++++++++++++++- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java index d9ab3af72..9163bc019 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelShadow.java @@ -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())); diff --git a/weaver/src/org/aspectj/weaver/bcel/Utility.java b/weaver/src/org/aspectj/weaver/bcel/Utility.java index ef7324a8e..7eec5ef41 100644 --- a/weaver/src/org/aspectj/weaver/bcel/Utility.java +++ b/weaver/src/org/aspectj/weaver/bcel/Utility.java @@ -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; -- 2.39.5