Community
Participate
Working Groups
Build Identifier: I20101216-1305 This seems to be related to a JDK bug in Constructor.getGenericParameterTypes: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5087240 Is there a possible workaround? Reproducible: Always Steps to Reproduce: 1. Create nested class with @Inject annotated constructor 2. Within outer class in @PostConstruct annotated method, call ContextInjectionFactory.make(NestedClass.class, context)
Created attachment 186923 [details] Is this the problem? Can you attach sample code that causes endless recursion? I tried to follow your description but what I am getting is an InjectionException which is more-or-less what is expected, see the attached code.
Ah, I found the reason your test case does not reproduce the bug: in org.eclipse.e4.core.internal.di.InjectorImpl.internalMake:298 // unless this is the default constructor, it has to be tagged if (!constructor.isAnnotationPresent(Inject.class) && constructor.getParameterTypes().length != 0) continue; Adding @Inject to the constructor of the nested class does the trick for me. The reason for the endless recursion is the following: In org.eclipse.e4.core.internal.di.InjectorImpl.resolveArgs:391, the argument descriptors returned by org.eclipse.e4.core.internal.di.ConstructorRequestor.getDependentObjects() include the outer class as first argument, which is then later created, thereby triggering the @PostConstruct and subsequent endless recursion.
On a related note, the necessity of the @Inject annotation on the default constructor is also a bug, I think. Since the default constructor of a nested class has the outer class as first parameter, it is not recognized as default constructor by the code-snippet above.
Created attachment 187005 [details] Trying to duplicate Hmm... I've added @Inject to constructor and still getting an injection exception, not an endless loop.
Oh my, found some egg on my face. I never actually ran this bug in "Run" mode, which pops up an InjectionException after a few seconds (still outrageous for something so simple). In debug mode, this takes long enough that I never actually waited it out, so I did not realize the unspectacular ending. Could you place a breakpoint in the @PostConstruct method and observe if you hit it more than the one time that is expected?
Created attachment 198265 [details] Patch
Patch applied to CVS Head.
Thanks Paul for taking time to figure this out!