Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7684635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:04:24+00:00 2026-05-31T19:04:24+00:00

I am trying Google GIN for our project and I came across a case

  • 0

I am trying Google GIN for our project and I came across a case where I have a generic interface and a generic implementation of that interface:

public interface IFace<T> {
    void setEntry(T t);
}

public class Face<T> implements IFace<T> {
    public void setEntry(T t) {
    }
}

Now I have a user of the interface that needs an IFace injected in the constructor:

public class IFaceUser {
    private IFace<String> face;

    @Inject
    public IFaceUser(IFace<String> face) {
        this.face = face;
    }
}

If I try to bind the interface to the implementation with bind(IFace.class).to(Face.class);, the injection fails with

Deferred binding result type 'IFace' should not be abstract

So GIN doesn’t find a binding for IFace<String> and falls back to IFace use the binding and tries GWT.create(IFace.class).

I also tried bind(new TypeLiteral<IFace>(){}).to(new TypeLiteral<Face>(){}); and bind(new TypeLiteral<IFace<?>>(){}).to(new TypeLiteral<Face<?>>(){}); with no success.

I know I could bind IFace<String> to Face<String>, but that could lead to a huge Module with lots of repeating code in it. It is also possible to use @ImplementedBy(Face.class), but that is not an option.

Is there a magic bind(...).to(...) combination I need to use? Is this even possible with GIN?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T19:04:25+00:00Added an answer on May 31, 2026 at 7:04 pm

    It seems this is not possible with GIN.

    There are several workarounds:

    • Let GIN inject an IFace or IFace and then cast to the desired type
    • Write a factory for IFace with a Provider injected that performs the cast in a generic factory method. Inject that factory and get a typesafe instance of IFace from the factory.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use Google Protocol Buffers in my project and I'd like to
I have scoured the forums and Google trying to figure out what I am
I have been looking all around Bing and Google trying to find this, does
I've been trying to google this but have been unable to find a solution
I'm trying use Google iosched as a reference project to learn the best practices
Been trying to google an answer but cant seem to find anything, I have
While trying the google plus API example from the project site I'm completely stuck
While trying out Google's Javascript API with Google+, I ran across a snag. var
I have been trying with google chrome and inspecting elements, but I cant get
I am trying to Google for what I've mentioned in the title, but somehow

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.