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.

Qualifier Named injection broken

See original GitHub issue
@Qualifier
annotation class Bar

class Foo

class A {
    @Inject
    @Bar
    lateinit var foo: Foo
}

val s0 = Toothpick.openScope("S0")
s0.installModules( object : Module() {
      init {
          bind(Foo::class.java).withName(Bar::class.java).toInstance(Foo())
      }
})
Toothpick.inject(A(), s0)

I’m getting error for the code above:

toothpick.locators.NoFactoryFoundException: No factory could be found for class com.shakuro.template.Foo. Check that the class has either a @Inject annotated constructor or contains @Inject annotated members.

There is no error when withName(Bar::class.java) removed.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
stephanenicolascommented, Apr 15, 2019

We definitely have a bug with the qualifiers… I am gonna open a ticket. Thanks for reporting it.

With @Named though, there must be something wrong on your side, we use this feature all the time. Do you mind creating a gist or a small sample project to reproduce it?

Le lun. 15 avr. 2019 à 01:13, Ruslan Krohalev notifications@github.com a écrit :

public final class A__MemberInjector implements MemberInjector { @Override public void inject(A target, Scope scope) { target.foo = scope.getInstance(Foo.class); } }

With @Named(“Bar”) and withName(“Bar”) i’m getting the same error.

Unfortunately i can’t provide the decompiled java code for A - i have some issues with decompiling apk file.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/stephanenicolas/toothpick/issues/328#issuecomment-483152443, or mute the thread https://github.com/notifications/unsubscribe-auth/ABv33SDdDKnlJwSMcQFiCom-tzOs5QFQks5vhDSjgaJpZM4csPNm .

0reactions
dectorcommented, Jun 20, 2019

Thanks you @stephanenicolas . Applying qualifier to field works well!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring @Qualifier isn't working without @Primary [duplicate]
@Qualifier is an annotation to specify the bean that you need to inject, it works together with @Autowired . ff you need to...
Read more >
Contexts and Dependency Injection - Quarkus
In Quarkus, you can skip the @Inject annotation completely if the injected field declares at least one qualifier. @ConfigProperty(name = "cool") String ...
Read more >
Dagger Core Semantics
Dagger is a fully static, compile-time dependency injection framework for both Java and Android. It is developed by the Java Core Libraries Team...
Read more >
Spring vs. Jakarta EE: Injecting Dependencies | Enji's Blog
Comparing the Dependency Injection mechanisms of Spring and Jakarta EE (part two).
Read more >
Contexts and Dependency Injection for the Java EE platform
To specify the name of a bean, the qualifier @javax.inject.Named is applied to the bean class or producer method or field. This bean...
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