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

Change default generated method stub to throw exception #2366

Merged
merged 1 commit into from
Feb 6, 2023

Conversation

JessicaJHee
Copy link
Contributor

Peek 2022-12-07 15-18

Fixes redhat-developer/vscode-java#1792

Signed-off-by: Jessica He jhe@redhat.com

@JessicaJHee JessicaJHee marked this pull request as draft December 7, 2022 20:33
@JessicaJHee JessicaJHee marked this pull request as ready for review December 7, 2022 21:49
@rgrunber rgrunber self-requested a review December 8, 2022 21:50
Signed-off-by: Jessica He <jhe@redhat.com>
@JessicaJHee JessicaJHee marked this pull request as ready for review February 2, 2023 21:21
Copy link
Contributor

@rgrunber rgrunber left a comment

Choose a reason for hiding this comment

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

Works well form me. I just have an example that misbehaves and am wondering if there's anything we can do :

IEmployee.java

package org.example;

import java.util.List;

public interface IEmployee {
    public String getFirstName();
    public String getLastName();
    public long getEmployeeId();
    public boolean isContractor();
    public List<String> getSubscribedLists();
    public IEmployee getSupervisor();
}

Researcher.java
Note : (has a compilation error, doesn't implement any of the IEmployee methods)

package org.example;

import java.util.List;

public class Researcher implements IEmployee {
}

GradStudent.java

package org.example;

public class GradStudent extends Researcher {

}

Now go to GradStudent, and on the type declaration, activate code actions, and select "Override/Implement methods". You can select any of the ones from IEmployee and when they're created you'll see they return the default value in the body. I'm guessing this is because they aren't recognized as belonging to the super-class (they aren't) ?

I wonder if there's anything we can do, or if it's just a consequence of the valid error.

@JessicaJHee
Copy link
Contributor Author

I wonder if there's anything we can do, or if it's just a consequence of the valid error.

I played around with your example and I think it makes sense the way it behaves right now. If I implement the methods in Researcher and resolve the unimplemented methods error, GradStudent will correctly call the base class. But if you think it is important to support this case, I can definitely take some time to look into it!

@rgrunber rgrunber added this to the Mid February 2023 milestone Feb 6, 2023
@rgrunber rgrunber added the bug label Feb 6, 2023
@rgrunber rgrunber merged commit b8d53af into eclipse-jdtls:master Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support of customizing generated method stub
2 participants