Skip to content

Commit

Permalink
Merge branch 'master' into issue_2176
Browse files Browse the repository at this point in the history
  • Loading branch information
dashorst authored Mar 27, 2024
2 parents 058051c + 2206fc5 commit 4d8d0c7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,9 @@ private void internalGenerateCode(ClassScope classScope, ClassFile classFile) {
// generate statements
if (this.statements != null) {
for (Statement statement : this.statements) {
codeStream.stmtInPreConContext = statement.inPreConstructorContext;
statement.generateCode(this.scope, codeStream);
codeStream.stmtInPreConContext = false;
if (!this.compilationResult.hasErrors() && codeStream.stackDepth != 0) {
this.scope.problemReporter().operandStackSizeInappropriate(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public class CodeStream {

public Map<BlockScope, List<ExceptionLabel>> patternAccessorMap = new HashMap<>();
public Stack<BlockScope> accessorExceptionTrapScopes = new Stack<>();
public boolean stmtInPreConContext = false;

public CodeStream(ClassFile givenClassFile) {
this.targetLevel = givenClassFile.targetJDK;
Expand Down Expand Up @@ -224,6 +225,7 @@ private static final void swap(int a[], int i, int j, int result[]) {
public void aaload() {
this.countLabels = 0;
this.stackDepth--;
popTypeBinding();
if (this.classFileOffset >= this.bCodeStream.length) {
resizeByteArray();
}
Expand Down Expand Up @@ -4777,7 +4779,7 @@ public void invoke(byte opcode, MethodBinding methodBinding, TypeBinding declari
case Opcodes.OPC_invokespecial :
receiverAndArgsSize = 1; // receiver
if (methodBinding.isConstructor()) {
if (declaringClass.isNestedType()) {
if (declaringClass.isNestedType() && !this.stmtInPreConContext) {
ReferenceBinding nestedType = (ReferenceBinding) declaringClass;
// enclosing instances
receiverAndArgsSize += nestedType.getEnclosingInstancesSlotSize();
Expand Down Expand Up @@ -7776,6 +7778,7 @@ private void pushTypeBinding(int nPop, TypeBinding typeBinding) {
pushTypeBinding(typeBinding);
}
private TypeBinding popTypeBinding() {
// debugStackDepth(this.stackDepth);
return isSwitchStackTrackingActive() ? this.switchSaveTypeBindings.pop() : null;
}
private void popTypeBinding(int nPop) {
Expand Down Expand Up @@ -7832,4 +7835,8 @@ public void handleRecordAccessorExceptions(BlockScope scope) {
invokeJavaLangMatchExceptionConstructor(); // [MatchException]
athrow();
}
void debugStackDepth(int stackDepth1) throws IllegalArgumentException{
if (stackDepth1 < 0)
throw new IllegalArgumentException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public static void main(String[] args) {

}

public void _test004() throws JavaModelException {
public void test004() throws JavaModelException {
if (!isJRE22) {
printJREError();
return;
Expand Down

0 comments on commit 4d8d0c7

Please sign in to comment.