Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Varwizard replace Nullable annotation by NotNull annotation #2

Open
thanhlecongg opened this issue Jun 28, 2023 · 1 comment
Open

Comments

@thanhlecongg
Copy link

thanhlecongg commented Jun 28, 2023

Hi,

I found that VarWizard created a new code which is not semantic-equivalent to the original code for Nullable annotation in Java. For reproducing the bug, please use the following example

"""
import javax.annotation.Nullable;

public class NullableSample {
    
    public static void main(String[] args) {
        String nullableString = getNullableString(null);
        
        if (nullableString != null) {
            System.out.println(nullableString.toUpperCase());
        } else {
            System.out.println("Nullable string is null.");
        }
    }
    
    private static String getNullableString(@Nullable String nullableString) {
        boolean condition = true; // Simulating some condition
        
        if (condition) {
            return "Hello, World!";
        } else {
            return null;
        }
    }
}
"""

In the new code provided by VarWizard, Nullable annotation is replaced by NotNull annotations. This replacement not only changes the semantics of the code but also creates a critical bug in the new code.

I think the bug may come from your parser which wrongly identified @nullable as a variable name.

@minhngh
Copy link
Collaborator

minhngh commented Jul 6, 2023

Thanks for your finding. It correctly arises from my parser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants