question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Carry annotations from interface into generated implementation

See original GitHub issue

Has this been considered? The following is an example use case:

class Foo @AssistedInject constructor(@Assisted val assisted: Bar) {
  @Reusable
  @AssistedInject.Factory 
  interface Factory {
    fun create(assisted: Bar): Foo
  }
}

to generate a factory implementation annotated with @Reusable:

@Reusable // This line is new
public final class Foo_AssistedFactory implements Foo.Factory {
  @Inject
  public Foo_AssistedFactory() {
  }

  @Override
  public Foo create(Bar assisted) {
    return new Foo(assisted);
  }
}

I understand it’s probably a bit questionable since something like this would also leave the interface annotated which may not be desirable, but considering interfaces have no implementation I see no major issue with it, and there may also be other mechanisms to achieve the same goal and don’t have this issue. Thoughts?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
JakeWhartoncommented, Nov 10, 2020

Ok! It’s not that urgent. There’s three whole days left this week, and Monday would be fine, too.

0reactions
stoyickercommented, Nov 10, 2020

I have a patch half-way through for annotations in dagger.* packages. Just need to add/update some tests but I’m afk right now, I’ll have it ready in a few hours

On Tue, 10 Nov 2020, 20:50 Jake Wharton, notifications@github.com wrote:

I would like to do a release this week. Let me know how you are progressing and if you want me to take over. We can start with just special casing that annotation.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/square/AssistedInject/issues/158#issuecomment-724928467, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANHCRYXQH2WIL6VFP7CLI3SPGKQZANCNFSM4TQOISOQ .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Carry annotations from interface into generated implementation
The following is an example use case: class Foo @AssistedInject ... Carry annotations from interface into generated implementation #158.
Read more >
Carry forward annotation from interface to generated java ...
I have created a custom method level annotation called @Primary (denoting which attribute is primary field) that I have used to annotate one...
Read more >
An Introduction to Annotations and Annotation Processing in ...
Annotations provide information to a program at compile time or at runtime based on which the program can take further action.
Read more >
Chapter 9. Interfaces - Oracle Help Center
An interface declaration introduces a new reference type whose members are classes, interfaces, constants, and methods. This type has no instance variables, ...
Read more >
Interface Driven Controllers in Spring - Baeldung
Learn how to create controllers using Spring MVC request annotation on Java interfaces.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found