Skip to content

Commit 5813dd5

Browse files
committed
Fixes #350 - java.lang.AssertionError: Attempt to push null on operand stack!
Similar to other fixes for related problems - make sure we record that a variable is in use so the code generation isnt surprised by a load instruction for one of them.
1 parent 80012ca commit 5813dd5

File tree

4 files changed

+35
-0
lines changed

4 files changed

+35
-0
lines changed

org.aspectj.ajdt.core/src/main/java/org/aspectj/ajdt/internal/compiler/ast/InterTypeFieldDeclaration.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,10 +412,29 @@ private void generateInterfaceReadBody(MethodBinding binding, MethodBinding read
412412
codeStream.invoke(Opcodes.OPC_invokeinterface,readMethod,null);
413413
}
414414

415+
/**
416+
* Example:
417+
*
418+
* For this ITD field on an interface type:
419+
* <pre>
420+
* {@code Set<String> I.changeListeners = new HashSet<String>(); }
421+
* </pre>
422+
* the binding (method we are currently writing) is:
423+
* <pre>
424+
* {@code public static void ajc$interFieldSetDispatch$Azpect$I$changeListeners(I, Set<java.lang.String>)}
425+
* </pre>
426+
* and the writeMethod to be invoked is:
427+
* <pre>
428+
* public abstract void ajc$interFieldSet$Azpect$I$changeListeners(Set<java.lang.String>)
429+
* </pre>
430+
*
431+
*/
415432
private void generateInterfaceWriteBody(MethodBinding binding, MethodBinding writeMethod, CodeStream codeStream) {
416433
codeStream.aload_0();
434+
LocalVariableBinding valueVar = createUsedVar(codeStream, "value", writeMethod.parameters[0], 1);
417435
codeStream.load(writeMethod.parameters[0], 1);
418436
codeStream.invoke(Opcodes.OPC_invokeinterface, writeMethod, null);
437+
valueVar.recordInitializationEndPC(codeStream.position);
419438
}
420439

421440
private void generateClassReadBody(MethodBinding binding, FieldBinding field, CodeStream codeStream) {

tests/bugs1925/350/Azpect.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import java.util.HashSet;
2+
import java.util.Set;
3+
4+
interface I {}
5+
6+
public aspect Azpect {
7+
private Set<String> I.changeListeners = new HashSet<String>();
8+
}

tests/src/test/java/org/aspectj/systemtest/ajc1925/Bugs1925Tests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ public void testGh336_ProceedCodeGenProblem() {
2626
public void testGh337_ProceedCodeGenProblem() {
2727
runTest("proceed code gen problem 2");
2828
}
29+
30+
public void testGh350_ITDCodeGenProblem() {
31+
runTest("itd code gen problem");
32+
}
2933

3034
@Override
3135
protected java.net.URL getSpecFile() {

tests/src/test/resources/org/aspectj/systemtest/ajc1925/ajc1925.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,9 @@ JDK 25 (https://openjdk.org/projects/jdk/25/):
104104
<compile files="X.aj" options="-17"/>
105105
<run class="X"/>
106106
</ajc-test>
107+
108+
<ajc-test dir="bugs1925/350" vm="24" title="itd code gen problem">
109+
<compile files="Azpect.java" options="-25"/>
110+
</ajc-test>
107111

108112
</suite>

0 commit comments

Comments
 (0)