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

@Inherited annotations written in a stub file #3594

Closed
Nargeshdb opened this issue Aug 14, 2020 · 3 comments · Fixed by #3600
Closed

@Inherited annotations written in a stub file #3594

Nargeshdb opened this issue Aug 14, 2020 · 3 comments · Fixed by #3600
Assignees

Comments

@Nargeshdb
Copy link
Contributor

If we have an @inherited annotation written in a stub file, subclasses in source code will not inherit the annotation!
e.g. Consider InheritedAnnotationType:

@Inherited
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface InheritedAnnotationType {
 ...   
}

Add @InheritedAnnotationType to Socket in a stub file:

@InheritedAnnotationType
class Socket implements Closeable {...}

Then, SubSocket doesn't inherit @InheritedAnnotationType!
class SubSocket extends Socket {}

@msridhar
Copy link
Contributor

I think the question here is, is there any way to annotate a JDK library class declaration, via stub files, modifying the annotated JDK, or some other trick, such that the annotation will be inherited? As @Nargeshdb notes above just using @Inherited does not seem to work.

@smillst
Copy link
Member

smillst commented Aug 18, 2020

is there any way to annotate a JDK library class declaration, via stub files, modifying the annotated JDK, or some other trick, such that the annotation will be inherited?

Not currently, but I made a PR #3600 that reads inherited annotations from stub files and applies them to subclasses.

@msridhar
Copy link
Contributor

Thanks, @smillst! @Nargeshdb is working on testing out #3600

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

Successfully merging a pull request may close this issue.

3 participants