I currently do not have a test class to provide, I first want to know if 
this is a problem with Assisted Factories you are aware of... If it's not, 
I'll try to create a test class for you to check! I use Guice 4.1.0.

The pseudo-code triggering the problem is something like this :

- Object A uses the method "create()" of an assisted factory to create 
object B, which is of class "Widget".
- There is an @Inject annotated method (called "init()") on class Widget.
- In this "init()" method, B uses the same "create()" method from the same 
assisted factory to create a Object C. And this is where the problem 
occures : the created "C" is not valid! Note that C is of the same class 
than B (Widget), but C doesn't create any new object in its own "init()" 
method.

I've tried to debug Guice's code a little bit, and found that this problem 
is caused in *com.google.inject.assistedinject.FactoryProvider2#invoke(...)* 
when *data.cachedBinding* is not null. I also saw that *data.cachedBinding* 
is not null when the "*optimized*" property is true. I searched to see how 
I could disable this optimization and saw that injecting the Guice Injector 
itself in my objects was a way to do it. I tried it and it did work!!  That 
produced a valid "C" object...

Of course I do not want to stick with such very slow workaround.

Are you aware of this problem?

Thanks!

Julien


-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-guice+unsubscr...@googlegroups.com.
To post to this group, send email to google-guice@googlegroups.com.
Visit this group at https://groups.google.com/group/google-guice.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-guice/aec3a4cc-0568-4700-8155-309cbc0249be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to