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

Runtime Annotation lost in parent interface when the code is compiled by eclipse #2752

Closed
beanww opened this issue Jan 16, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@beanww
Copy link

beanww commented Jan 16, 2025

Let's make sure issue is not already fixed in latest builds first.

Steps to reproduce

From a fresh installation and clean workspace:

with eclipse-jee-2024-12-R-win32-x86_64.zip
and plugin: Lombok v1.18.36

I tried Test.java:

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Method;

public class Test {
	public static void main(String[] args) {
		Method[] methods = ChildInterface.class.getMethods();
		for(Method method: methods) {
			if(method.getName().contains("select")) {
				System.out.println(method.getAnnotations().length);
			}
		}
	}
}
interface ParentInterface<V extends ClassInf>{
	V selectById();
}

interface ChildInterface extends ParentInterface<ImplClass>{
	@anno
	default ImplClass selectById() {
		return null;
	}
}
interface ClassInf{}

class ImplClass implements ClassInf{}

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@interface anno{
	
}

Run Test.java

I expected: <what was the expected outcome?>

1
1
which means both 2 methods have annotation object

But got: <what is the actual undesired behavior?>

1
0

I encountered this issue when compiling Test.java with Eclipse: 'The method object with return type ClassInf has no annotation object.'

However, this issue does not occur when I compile Test.java using IntelliJ IDEA or javac.

Tested under this environment:

  • OS & version:
  • Win10
  • Eclipse IDE/Platform version (as shown in Help > About):
  • Version: 2024-12 (4.34.0)
  • Build id: 20241128-0757
    *JDK:
    jdk-21.0.5
@beanww beanww added the bug Something isn't working label Jan 16, 2025
@akurtakov
Copy link
Member

This looks like JDT bug . Unfortunately, Github doesn't allow moving issues between organizations so you would have to open a new one in the proper location https://github.com/eclipse-jdt/eclipse.jdt.core .
As there is nothing that can be done by the Eclipse Platform project I'm closing this one.

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

No branches or pull requests

2 participants