From 2b0e11d8633c84e8b0827e0eb77b4639fe0914e4 Mon Sep 17 00:00:00 2001 From: Andrew Clement Date: Tue, 15 Apr 2025 15:26:29 -0700 Subject: Fix more "Attempt to push null on operand stack" variants This change fixes more cases in the *Declaration classes that generate code. Both #336 and #337 are due to the same piece of code not correctly computing the resolved position because of copying it from a source method when it needs recomputing for the method being generated. In particular primitive types and/or double slot types (like long or double) cause the code to miscompute the resolved positions or set the wrong type of expected type on the stack. Fixes #336 Fixes #337 --- .../org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'org.aspectj.ajdt.core/src') diff --git a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java index c91e1a424..10dc68406 100644 --- a/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java +++ b/org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/AdviceDeclaration.java @@ -196,7 +196,6 @@ public class AdviceDeclaration extends AjMethodDeclaration { private void generateProceedMethod(ClassScope classScope, ClassFile classFile) { MethodBinding binding = proceedMethodBinding; - classFile.generateMethodInfoHeader(binding); int methodAttributeOffset = classFile.contentsOffset; int attributeNumber = classFile.generateMethodInfoAttributes(binding, AstUtil.getAjSyntheticAttribute()); @@ -214,16 +213,17 @@ public class AdviceDeclaration extends AjMethodDeclaration { Argument[] arguments = this.arguments; if (arguments != null) { + int rp = 0; for (Argument argument: arguments) { LocalVariableBinding lvb = argument.binding; LocalVariableBinding lvbCopy = new LocalVariableBinding(lvb.name, lvb.type, lvb.modifiers, true); lvbCopy.declaration = new LocalDeclaration(argument.name, 0, 0); codeStream.record(lvbCopy); lvbCopy.recordInitializationStartPC(0); - lvbCopy.resolvedPosition = lvb.resolvedPosition; + lvbCopy.resolvedPosition = rp; + rp += InterTypeMethodDeclaration.getSlotSize(lvb.type.id); } } - codeStream.aload(closureIndex); // build the Object[] @@ -242,7 +242,6 @@ public class AdviceDeclaration extends AjMethodDeclaration { if (type.isBaseType()) { codeStream.invoke(Opcodes.OPC_invokestatic, AjTypeConstants.getConversionMethodToObject(classScope, type), null); } - codeStream.aastore(); } -- cgit v1.2.3