Hello. I create little example with my problem. I use Assisted Inject with
Mulibinder. But my Assisted Factory contain Generic Type in Parameter List.
My Sources in Attachment
In GuiceAssitedWithMultibindingDontWork

I got

    public static interface PersistentDifferToLocaleStringFactory<Type>
    {
        PersistentDiffer<Type, String> create(Locale locale, Type
initialValue);
    }
It's pretty and simple. BUT doesn;t work.
I catch Exception:
Exception in thread "main" com.google.inject.CreationException: Guice
creation errors:

1) ru.faulab.guice.PersistentDiffer<Type, java.lang.String> cannot be used
as a key; It is not fully specified.

2) No implementation for
ru.faulab.guice.GuiceAssitedWithMultibindingDontWork$PersistentDifferToLocaleStringFactory
annotated with @com.google.inject.multibindings.Element(setName=,uniqueId=1)
was bound.
  at
ru.faulab.guice.GuiceAssitedWithMultibindingDontWork$1.configure(GuiceAssitedWithMultibindingDontWork.java:114)

2 errors
at
com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist(Errors.java:315)
 at
com.google.inject.InjectorBuilder.initializeStatically(InjectorBuilder.java:149)
at com.google.inject.InjectorBuilder.build(InjectorBuilder.java:105)
 at com.google.inject.Guice.createInjector(Guice.java:92)
at com.google.inject.Guice.createInjector(Guice.java:69)
 at com.google.inject.Guice.createInjector(Guice.java:59)
at
ru.faulab.guice.GuiceAssitedWithMultibindingDontWork.main(GuiceAssitedWithMultibindingDontWork.java:108)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
 at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)

I view sources, and create Hack Worked
Example: GuiceAssitedWithMultibindingHack

Here i got
public static class GenericWrap<Value>
    {
        public final Value value;

        private GenericWrap(Value value)
        {
            this.value = value;
        }

        public static <Value> GenericWrap<Value> cgw(Value value)
        {
            return new GenericWrap<Value>(value);
        }
    }

public static interface PersistentDifferToLocaleStringFactory<Type>
    {
        PersistentDiffer<Type, String> create(Locale locale, GenericWrap<Type>
initialValue);
    }

This Example work. but ugly. GenericWrap need to remove Java syntetic
method, but it to hight cost. Have you any idia how to create worked example
without hacks?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---

Attachment: GuiceAssitedWithMultibindingDontWork.java
Description: Binary data

Attachment: GuiceAssitedWithMultibindingHack.java
Description: Binary data

Attachment: InStringPersistentDifferFactory.java
Description: Binary data

Attachment: PersistentDiffer.java
Description: Binary data

Reply via email to