digitalgust / miniJVM

Develop iOS Android app in java, Cross platform java virtual machine , the minimal jvm .
MIT License
315 stars 89 forks source link

Getter/setter optimizer doesn't check method arity #29

Open I-asked opened 5 months ago

I-asked commented 5 months ago

Hi everyone and Hi Gust, first of all, I wanted to thank you and everyone involved a lot for this awesome project!

To the point:

Say you have a method like this:

int discardAndGetX(int x) {
    return this.x;
}

The getter optimization doesn't check the arity of the method and pops the integer instead of this from the stack, resulting in say an NPE.

I am not sure how to fix this without compromising the performance, but it's a real problem with legacy libraries that expose such API's for compatibility…

digitalgust commented 5 months ago

Yes ,thank you , this issue fixed. the issue that missed the parameter of getter method. setter has the same issue.