add THIS parameter to lambda methods

This commit is contained in:
Volker Berlin 2021-01-24 13:49:23 +01:00
parent a6a038aad0
commit c1869baee5
2 changed files with 13 additions and 2 deletions

View File

@ -1,5 +1,5 @@
/*
Copyright 2011 - 2020 Volker Berlin (i-net software)
Copyright 2011 - 2021 Volker Berlin (i-net software)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -110,6 +110,15 @@ public class MethodInfo implements Member {
return (accessFlags & 0x0400) > 0;
}
/**
* If the method is synthetic
*
* @return true, if synthetic
*/
public boolean isSynthetic() {
return (accessFlags & 0x1000) > 0;
}
/**
* @return the name
*/

View File

@ -222,7 +222,9 @@ public class ModuleGenerator {
}
if( method != null ) {
createInstructions( functions.replace( next, method ) );
boolean needThisParameter = !method.isStatic() || "<init>".equals( method.getName() );
boolean needThisParameter = !method.isStatic() // if not static there is a not declared THIS parameter
|| "<init>".equals( method.getName() ) // constructor method need also the THIS parameter also if marked as static
|| (method.isSynthetic() && method.getName().startsWith( "lambda$" )); // lambda functions are static but will call with a THIS parameter which need be removed from stack
functions.markAsScanned( next, needThisParameter );
if( needThisParameter ) {
types.valueOf( next.className ); // for the case that the type unknown yet