Status: New
Owner: ----
New issue 281 by dh.evolutionnext: Attempt to call methodInvocation.getThis
results in StackOverflowError
http://code.google.com/p/google-guice/issues/detail?id=281
(Sample Application is attached)
I was attempting to create an AOP Interceptor in a prototype app that would
mimic a Lifecycle Process. Unfortunately a call to
methodInvocation.getThis(); caused a StackOverflowException. Here is the
interceptor.
public class LifecycleInterceptor implements MethodInterceptor {
private Set<Object> cache;
public LifecycleInterceptor() {
this.cache = new HashSet<Object>();
}
public Object invoke(MethodInvocation methodInvocation) throws
Throwable {
Object parentObject = methodInvocation.getThis(); //<--Stack
Overflow Occurs here
if (cache.contains(parentObject)) {
return methodInvocation.proceed();
}
cache.add(parentObject);
return methodInvocation.proceed();
}
protected Set<Object> getCache() {
return cache;
}
}
Here is a snippet of the stack trace.
Exception in thread "main" java.lang.RuntimeException:
java.lang.reflect.InvocationTargetException
at
com.google.inject.ConstructorInjector.construct(ConstructorInjector.java:161)
at
com.google.inject.InjectorImpl$ImplicitBinding.get(InjectorImpl.java:1006)
at
com.google.inject.BindingBuilderImpl$FactoryProxy.get(BindingBuilderImpl.java:299)
at com.google.inject.InjectorImpl$9$1.call(InjectorImpl.java:708)
at com.google.inject.InjectorImpl.callInContext(InjectorImpl.java:747)
at com.google.inject.InjectorImpl$9.get(InjectorImpl.java:702)
at com.google.inject.InjectorImpl.getInstance(InjectorImpl.java:728)
at com.evolutionnext.Application.main(Application.java:18)
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)
Caused by: java.lang.reflect.InvocationTargetException
at
com.evolutionnext.EnterQuestionFrame$$EnhancerByGuice$$70c97c37$$FastClassByGuice$$b9fbb725.newInstance(<generated>)
at
com.google.inject.cglib.reflect.FastConstructor.newInstance(FastConstructor.java:40)
at com.google.inject.ProxyFactory$4.newInstance(ProxyFactory.java:176)
at
com.google.inject.ConstructorInjector.construct(ConstructorInjector.java:142)
... 12 more
Caused by: java.lang.StackOverflowError
at
com.google.inject.InterceptorStackCallback.intercept(InterceptorStackCallback.java:45)
at
com.evolutionnext.EnterQuestionFrame$$EnhancerByGuice$$70c97c37.toString(<generated>)
at java.lang.String.valueOf(String.java:2827)
at java.io.PrintStream.println(PrintStream.java:771)
at
com.evolutionnext.LifecycleInterceptor.invoke(LifecycleInterceptor.java:24)
at
com.google.inject.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:66)
at
com.google.inject.InterceptorStackCallback.intercept(InterceptorStackCallback.java:45)
at
com.evolutionnext.EnterQuestionFrame$$EnhancerByGuice$$70c97c37.toString(<generated>)
at java.lang.String.valueOf(String.java:2827)
at java.io.PrintStream.println(PrintStream.java:771)
at
com.evolutionnext.LifecycleInterceptor.invoke(LifecycleInterceptor.java:24)
at
com.google.inject.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:66)
Attachments:
sampleguiceswingapp.zip 28.8 KB
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"google-guice-dev" 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-dev?hl=en
-~----------~----~----~----~------~----~------~--~---