Skip to content

Fix NullPointerException in MethodsFunctionsChecker#150

Open
rcosta358 wants to merge 2 commits intomainfrom
fix-npe
Open

Fix NullPointerException in MethodsFunctionsChecker#150
rcosta358 wants to merge 2 commits intomainfrom
fix-npe

Conversation

@rcosta358
Copy link
Collaborator

This PR fixes an issue where when a class had multiple methods and one method would throw an error related to a parametric refinement (e.g., InvalidRefinementError), the exception would abort the visitation of sibling methods during the first pass. Then, in second pass, when trying to get the function that should have been added to the context in the first pass, it is not there, and would throw a NullPointerException. This was because there were missing try-catch blocks in the getMethodRefinements and getConstructorRefinements (in this case, the first one).

Example Reproduction

public class SimpleTest {

    void testParam(@Refinement("y + 1") int y) {}

    int test() {
        return -1;
    }
}
// Cannot invoke "liquidjava.processor.context.RefinedFunction.getArguments()" because "fi" is null

@rcosta358 rcosta358 self-assigned this Feb 14, 2026
@rcosta358 rcosta358 added the bug Something isn't working label Feb 14, 2026
Comment on lines +184 to +185
if (fi == null)
return;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just in case.

Comment on lines -414 to -417
} else {
assert false;
// Method should already be in context. Should not arrive this point in
// refinement checker.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot assume this anymore because a method that throws InvalidRefinementError on a parametric refinement will not be added to the context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant