Skip to content

Automatic program repair in plugin #189

@aosen-xiong

Description

@aosen-xiong

For a buggy code snippet like below,

public class Greeting {
    
    public static void greet(String name) {
        System.out.println("Hello, " + name.trim());
    }

    public static void main(String[] args) {
        greet(null);  // This will throw a NullPointerException
    }
}

can we have some features to automatic generate code patch like

public class Greeting {
    
    public static void greet(@NonNull String name) {
        System.out.println("Hello, " + name.trim());
    }

    public static void main(String[] args) {
        String name = null;
        
        if (name != null) {
            greet(name);  // Safe now!
        } else {
            System.out.println("Name is not provided.");
        }
    }
}

I think this will be helpful for developers are using the plugin.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions