I'm encountering an issue in VSCode with Lombok's @Delegate annotation. My project has a class (InfraFacade
) that delegates methods from two fields: classExample1
and classExample2
. Both of these delegate objects provide an implementation for the same method sayHello()
. Although the code runs correctly—Java uses the first delegate (classExample1
) which outputs "Hello! 1"—VSCode displays the following error:
"Duplicate method sayHello() in type InfraFacade Java(67109219)"
Here are my environment details:
- VSCode Extension: Extension Pack for Java 0.29.0
- Java Version: 1.8.0_412-412
- Lombok Version: 1.18.30
import lombok.experimental.Delegate;
public class Main {
public static void main(String[] args) {
InfraFacade infraFacade = new InfraFacade();
infraFacade.sayHello();
}
}
class InfraFacade implements IInfraFacade {
@Delegate
private Class1 classExample1 = new Class1();
@Delegate
private Class2 classExample2 = new Class2();
}
interface IInfraFacade extends IClass2, IClass1 {
}
interface IClass1 {
void sayHello();
}
interface IClass2 {
void sayHello();
}
class Class1 implements IClass1 {
public void sayHello() {
System.out.println("Hello! 1");
}
}
class Class2 implements IClass2 {
public void sayHello() {
System.out.println("Hello! 2");
}
}
Based on online research, I learned that for methods generated via the @Delegate annotation with identical signatures, the method explicitly defined in the class takes precedence. Furthermore, among the @delegate-generated methods, the one declared first is adopted. This is why the program compiles and runs correctly.
I have two questions:
- Is there a way to disable or suppress this duplicate method warning in VSCode without modifying my existing code?
- If this issue is due to a bug in one of the VSCode plugins, which specific plugin within the Extension Pack for Java should I report the problem to? Log hasn't been clear on pinpointing which plugin is causing this error.
Any guidance to resolve or work around this issue would be greatly appreciated!
I'm encountering an issue in VSCode with Lombok's @Delegate annotation. My project has a class (InfraFacade
) that delegates methods from two fields: classExample1
and classExample2
. Both of these delegate objects provide an implementation for the same method sayHello()
. Although the code runs correctly—Java uses the first delegate (classExample1
) which outputs "Hello! 1"—VSCode displays the following error:
"Duplicate method sayHello() in type InfraFacade Java(67109219)"
Here are my environment details:
- VSCode Extension: Extension Pack for Java 0.29.0
- Java Version: 1.8.0_412-412
- Lombok Version: 1.18.30
import lombok.experimental.Delegate;
public class Main {
public static void main(String[] args) {
InfraFacade infraFacade = new InfraFacade();
infraFacade.sayHello();
}
}
class InfraFacade implements IInfraFacade {
@Delegate
private Class1 classExample1 = new Class1();
@Delegate
private Class2 classExample2 = new Class2();
}
interface IInfraFacade extends IClass2, IClass1 {
}
interface IClass1 {
void sayHello();
}
interface IClass2 {
void sayHello();
}
class Class1 implements IClass1 {
public void sayHello() {
System.out.println("Hello! 1");
}
}
class Class2 implements IClass2 {
public void sayHello() {
System.out.println("Hello! 2");
}
}
Based on online research, I learned that for methods generated via the @Delegate annotation with identical signatures, the method explicitly defined in the class takes precedence. Furthermore, among the @delegate-generated methods, the one declared first is adopted. This is why the program compiles and runs correctly.
I have two questions:
- Is there a way to disable or suppress this duplicate method warning in VSCode without modifying my existing code?
- If this issue is due to a bug in one of the VSCode plugins, which specific plugin within the Extension Pack for Java should I report the problem to? Log hasn't been clear on pinpointing which plugin is causing this error.
Any guidance to resolve or work around this issue would be greatly appreciated!
Share Improve this question edited Feb 8 at 7:03 rioV8 28.7k4 gold badges42 silver badges60 bronze badges asked Feb 7 at 15:44 kaki-jiukaki-jiu 11 bronze badge New contributor kaki-jiu is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.1 Answer
Reset to default 0Enable Javac support in Visual Studio Code Java
https://devblogs.microsoft.com/java/annoucing-javac-support-in-visual-studio-code-java/
Install the latest pre-release version of the “Language Support for Java by Red Hat” or “Extension Pack for Java”.
Set “java.jdt.ls.javac.enabled“: “on” in your VS Code settings. Point “java.jdt.ls.java.home” to your Java 23 installation.