Browse Source

fix and testcode update for: 151673: after advice sometimes woven incorrectly into strangely formed input bytecode

tags/PRE_PIPELINE
aclement 18 years ago
parent
commit
e4ab0ae576

+ 0
- 1
tests/features152/synchronization/transformed/expected/C.m.txt View File

L0: INVOKESTATIC Four.aspectOf ()LFour; L0: INVOKESTATIC Four.aspectOf ()LFour;
INVOKEVIRTUAL Four.ajc$afterReturning$Four$1$c2776aed ()V INVOKEVIRTUAL Four.ajc$afterReturning$Four$1$c2776aed ()V
RETURN RETURN
RETURN
end public void m() end public void m()

+ 0
- 1
tests/features152/synchronization/transformed/expected/C.m3.txt View File

L0: INVOKESTATIC Three.aspectOf ()LThree; L0: INVOKESTATIC Three.aspectOf ()LThree;
INVOKEVIRTUAL Three.ajc$afterReturning$Three$1$3f09355c ()V INVOKEVIRTUAL Three.ajc$afterReturning$Three$1$3f09355c ()V
RETURN RETURN
RETURN
end public void m3() end public void m3()

+ 0
- 1
tests/features152/synchronization/transformed/expected/C.m33.txt View File

INVOKESTATIC Three.aspectOf ()LThree; INVOKESTATIC Three.aspectOf ()LThree;
INVOKEVIRTUAL Three.ajc$afterReturning$Three$3$b48e4ae1 ()V INVOKEVIRTUAL Three.ajc$afterReturning$Three$3$b48e4ae1 ()V
RETURN RETURN
RETURN
end public void m33() end public void m33()

+ 21
- 3
weaver/src/org/aspectj/weaver/bcel/BcelShadow.java View File

import org.aspectj.apache.bcel.generic.NEW; import org.aspectj.apache.bcel.generic.NEW;
import org.aspectj.apache.bcel.generic.ObjectType; import org.aspectj.apache.bcel.generic.ObjectType;
import org.aspectj.apache.bcel.generic.PUSH; import org.aspectj.apache.bcel.generic.PUSH;
import org.aspectj.apache.bcel.generic.RETURN;
import org.aspectj.apache.bcel.generic.ReturnInstruction; import org.aspectj.apache.bcel.generic.ReturnInstruction;
import org.aspectj.apache.bcel.generic.SWAP; import org.aspectj.apache.bcel.generic.SWAP;
import org.aspectj.apache.bcel.generic.StoreInstruction; import org.aspectj.apache.bcel.generic.StoreInstruction;
* variable to hold the return value, and load the value from this var before * variable to hold the return value, and load the value from this var before
* returning (see pr148007 for why we do this - it works around a JRockit bug, * returning (see pr148007 for why we do this - it works around a JRockit bug,
* and is also closer to what javac generates) * and is also closer to what javac generates)
*
* Sometimes the 'last return' isnt the right one - some rogue code can
* include the real return from the body of a subroutine that exists at the end
* of the method. In this case the last return is RETURN but that may not be
* correct for a method with a non-void return type... pr151673
*
* @param returns list of all the return instructions in the shadow * @param returns list of all the return instructions in the shadow
* @param returnInstructions instruction list into which the return instructions should * @param returnInstructions instruction list into which the return instructions should
* be generated * be generated
*/ */
private BcelVar generateReturnInstructions(List returns, InstructionList returnInstructions) { private BcelVar generateReturnInstructions(List returns, InstructionList returnInstructions) {
BcelVar returnValueVar = null; BcelVar returnValueVar = null;
InstructionHandle lastReturnHandle = (InstructionHandle)returns.get(returns.size() - 1);
Instruction newReturnInstruction = Utility.copyInstruction(lastReturnHandle.getInstruction());
if (this.hasANonVoidReturnType()) { if (this.hasANonVoidReturnType()) {
// Find the last *correct* return - this is a method with a non-void return type
// so ignore RETURN
Instruction newReturnInstruction = null;
int i=returns.size()-1;
while (newReturnInstruction == null && i>=0) {
InstructionHandle ih = (InstructionHandle)returns.get(i);
if (!(ih.getInstruction() instanceof RETURN)) {
newReturnInstruction = Utility.copyInstruction(ih.getInstruction());
}
i--;
}
returnValueVar = genTempVar(this.getReturnType()); returnValueVar = genTempVar(this.getReturnType());
returnValueVar.appendLoad(returnInstructions,getFactory()); returnValueVar.appendLoad(returnInstructions,getFactory());
returnInstructions.append(newReturnInstruction);
} else { } else {
InstructionHandle lastReturnHandle = (InstructionHandle)returns.get(returns.size() - 1);
Instruction newReturnInstruction = Utility.copyInstruction(lastReturnHandle.getInstruction());
returnInstructions.append(newReturnInstruction); returnInstructions.append(newReturnInstruction);
} }
returnInstructions.append(newReturnInstruction);
return returnValueVar; return returnValueVar;
} }

+ 0
- 2
weaver/testdata/AfterFancyHelloWorld.txt View File

| ATHROW | ATHROW
| L0: INVOKESTATIC Aspect.ajc_after_constructor_execution ()V | L0: INVOKESTATIC Aspect.ajc_after_constructor_execution ()V
| RETURN | RETURN
| RETURN
constructor-execution(void FancyHelloWorld.<init>()) constructor-execution(void FancyHelloWorld.<init>())
end public void <init>() end public void <init>()


| ATHROW | ATHROW
| L7: INVOKESTATIC Aspect.ajc_after_method_execution ()V | L7: INVOKESTATIC Aspect.ajc_after_method_execution ()V
| RETURN | RETURN
| RETURN
method-execution(void FancyHelloWorld.main(java.lang.String[])) method-execution(void FancyHelloWorld.main(java.lang.String[]))
end public static void main(String[]) end public static void main(String[])



+ 0
- 2
weaver/testdata/AfterHelloWorld.txt View File

| ATHROW | ATHROW
| L0: INVOKESTATIC Aspect.ajc_after_constructor_execution ()V | L0: INVOKESTATIC Aspect.ajc_after_constructor_execution ()V
| RETURN | RETURN
| RETURN
constructor-execution(void HelloWorld.<init>()) constructor-execution(void HelloWorld.<init>())
end public void <init>() end public void <init>()


| ATHROW | ATHROW
| L2: INVOKESTATIC Aspect.ajc_after_method_execution ()V | L2: INVOKESTATIC Aspect.ajc_after_method_execution ()V
| RETURN | RETURN
| RETURN
method-execution(void HelloWorld.main(java.lang.String[])) method-execution(void HelloWorld.main(java.lang.String[]))
end public static void main(String[]) end public static void main(String[])



+ 0
- 2
weaver/testdata/AfterReturningFancyHelloWorld.txt View File

| NOP | NOP
| INVOKESTATIC Aspect.ajc_afterReturning_constructor_execution ()V | INVOKESTATIC Aspect.ajc_afterReturning_constructor_execution ()V
| RETURN | RETURN
| RETURN
constructor-execution(void FancyHelloWorld.<init>()) constructor-execution(void FancyHelloWorld.<init>())
end public void <init>() end public void <init>()


| L2: NOP (line 17) | L2: NOP (line 17)
| INVOKESTATIC Aspect.ajc_afterReturning_method_execution ()V | INVOKESTATIC Aspect.ajc_afterReturning_method_execution ()V
| RETURN | RETURN
| RETURN
method-execution(void FancyHelloWorld.main(java.lang.String[])) method-execution(void FancyHelloWorld.main(java.lang.String[]))
end public static void main(String[]) end public static void main(String[])



+ 0
- 2
weaver/testdata/AfterReturningHelloWorld.txt View File

| NOP | NOP
| INVOKESTATIC Aspect.ajc_afterReturning_constructor_execution ()V | INVOKESTATIC Aspect.ajc_afterReturning_constructor_execution ()V
| RETURN | RETURN
| RETURN
constructor-execution(void HelloWorld.<init>()) constructor-execution(void HelloWorld.<init>())
end public void <init>() end public void <init>()


| NOP (line 11) | NOP (line 11)
| INVOKESTATIC Aspect.ajc_afterReturning_method_execution ()V | INVOKESTATIC Aspect.ajc_afterReturning_method_execution ()V
| RETURN | RETURN
| RETURN
method-execution(void HelloWorld.main(java.lang.String[])) method-execution(void HelloWorld.main(java.lang.String[]))
end public static void main(String[]) end public static void main(String[])



+ 0
- 1
weaver/testdata/ArgsAfterReturningFancyHelloWorld.txt View File

| ALOAD 8 | ALOAD 8
| INVOKESTATIC Aspect.ajc_afterReturning_method_execution (Ljava/lang/Object;)V | INVOKESTATIC Aspect.ajc_afterReturning_method_execution (Ljava/lang/Object;)V
| RETURN | RETURN
| RETURN
method-execution(void FancyHelloWorld.main(java.lang.String[])) method-execution(void FancyHelloWorld.main(java.lang.String[]))
end public static void main(String[]) end public static void main(String[])



+ 0
- 1
weaver/testdata/ArgsAfterReturningHelloWorld.txt View File

| ALOAD_2 | ALOAD_2
| INVOKESTATIC Aspect.ajc_afterReturning_method_execution (Ljava/lang/Object;)V | INVOKESTATIC Aspect.ajc_afterReturning_method_execution (Ljava/lang/Object;)V
| RETURN | RETURN
| RETURN
method-execution(void HelloWorld.main(java.lang.String[])) method-execution(void HelloWorld.main(java.lang.String[]))
end public static void main(String[]) end public static void main(String[])



+ 0
- 1
weaver/testdata/ArgsBeforeAfterHelloWorld.txt View File

| L1: ALOAD_3 | L1: ALOAD_3
| INVOKESTATIC Aspect.ajc_afterReturning_method_execution (Ljava/lang/Object;)V | INVOKESTATIC Aspect.ajc_afterReturning_method_execution (Ljava/lang/Object;)V
| RETURN | RETURN
| RETURN
method-execution(void HelloWorld.main(java.lang.String[])) method-execution(void HelloWorld.main(java.lang.String[]))
end public static void main(String[]) end public static void main(String[])



+ 0
- 1
weaver/testdata/CflowNonStaticBeforeFancyHelloWorld.txt View File

| L4: GETSTATIC Aspect.ajc$perCflowStack Lorg/aspectj/runtime/internal/CFlowStack; | L4: GETSTATIC Aspect.ajc$perCflowStack Lorg/aspectj/runtime/internal/CFlowStack;
| INVOKEVIRTUAL org.aspectj.runtime.internal.CFlowStack.pop ()V | INVOKEVIRTUAL org.aspectj.runtime.internal.CFlowStack.pop ()V
| RETURN | RETURN
| RETURN
method-execution(void FancyHelloWorld.main(java.lang.String[])) method-execution(void FancyHelloWorld.main(java.lang.String[]))
end public static void main(String[]) end public static void main(String[])



+ 0
- 1
weaver/testdata/CflowNonStaticBeforeHelloWorld.txt View File

| L1: GETSTATIC Aspect.ajc$perCflowStack Lorg/aspectj/runtime/internal/CFlowStack; | L1: GETSTATIC Aspect.ajc$perCflowStack Lorg/aspectj/runtime/internal/CFlowStack;
| INVOKEVIRTUAL org.aspectj.runtime.internal.CFlowStack.pop ()V | INVOKEVIRTUAL org.aspectj.runtime.internal.CFlowStack.pop ()V
| RETURN | RETURN
| RETURN
method-execution(void HelloWorld.main(java.lang.String[])) method-execution(void HelloWorld.main(java.lang.String[]))
end public static void main(String[]) end public static void main(String[])



Loading…
Cancel
Save