Arun Thirupathi
2017-03-16 18:33:47 UTC
I am using Guice injection (version 4.0) for a personal project.
On one of my private methods (this method has nothing to do with Guice
Injection, but consructor of this class uses Guice Injection) ,takes an
argument of type com.amazonaws.AmazonWebServiceResult
<http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/AmazonWebServiceResult.html>
<ResponseMetadata
<http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/ResponseMetadata.html>>
. The Caller passes in the object of type http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/dynamodbv2/model/QueryResult.html.
It compiles fine, but during unit testing, it fails with an error
java.lang.VerifyError: (class: <className> , method: <methodName> signature: (L<Param1Class>;L<Param2Class>;Lcom/amazonaws/services/dynamodbv2/model/QueryResult;)Z) Incompatible argument to function
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2585)
at java.lang.Class.getDeclaredConstructors(Class.java:1906)
at com.google.inject.spi.InjectionPoint.forConstructorOf(InjectionPoint.java:245)
at com.google.inject.internal.ConstructorBindingImpl.create(ConstructorBindingImpl.java:99)
at com.google.inject.internal.InjectorImpl.createUninitializedBinding(InjectorImpl.java:658)
at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:882)
at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:805)
at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:282)
at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:214)
at com.google.inject.internal.InjectorImpl.getInternalFactory(InjectorImpl.java:890)
at com.google.inject.internal.FactoryProxy.notify(FactoryProxy.java:46)
at com.google.inject.internal.ProcessedBindingData.runCreationListeners(ProcessedBindingData.java:50)
at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:134)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:107)
at com.google.inject.Guice.createInjector(Guice.java:96)
at com.google.inject.Guice.createInjector(Guice.java:73)
at com.google.inject.Guice.createInjector(Guice.java:62)
Is this a known Guice issue ?
I tried moving this method to a new class (the new class does not have
Guice Injection), tried adding one more intermediate method as pass
through, but the error is still the same. But if the method parameter
remains Result, if I extract the fields from the result and pass it down to
another method it does not complain.
I was writing some generic code which could take in any result type and
prints out the information like request id. I have added lots of
duplication of code by defining one method per result type. Can someone
please help me here ?
Thanks,
Arun.
On one of my private methods (this method has nothing to do with Guice
Injection, but consructor of this class uses Guice Injection) ,takes an
argument of type com.amazonaws.AmazonWebServiceResult
<http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/AmazonWebServiceResult.html>
<ResponseMetadata
<http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/ResponseMetadata.html>>
. The Caller passes in the object of type http://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/com/amazonaws/services/dynamodbv2/model/QueryResult.html.
It compiles fine, but during unit testing, it fails with an error
java.lang.VerifyError: (class: <className> , method: <methodName> signature: (L<Param1Class>;L<Param2Class>;Lcom/amazonaws/services/dynamodbv2/model/QueryResult;)Z) Incompatible argument to function
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2585)
at java.lang.Class.getDeclaredConstructors(Class.java:1906)
at com.google.inject.spi.InjectionPoint.forConstructorOf(InjectionPoint.java:245)
at com.google.inject.internal.ConstructorBindingImpl.create(ConstructorBindingImpl.java:99)
at com.google.inject.internal.InjectorImpl.createUninitializedBinding(InjectorImpl.java:658)
at com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:882)
at com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:805)
at com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:282)
at com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:214)
at com.google.inject.internal.InjectorImpl.getInternalFactory(InjectorImpl.java:890)
at com.google.inject.internal.FactoryProxy.notify(FactoryProxy.java:46)
at com.google.inject.internal.ProcessedBindingData.runCreationListeners(ProcessedBindingData.java:50)
at com.google.inject.internal.InternalInjectorCreator.initializeStatically(InternalInjectorCreator.java:134)
at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:107)
at com.google.inject.Guice.createInjector(Guice.java:96)
at com.google.inject.Guice.createInjector(Guice.java:73)
at com.google.inject.Guice.createInjector(Guice.java:62)
Is this a known Guice issue ?
I tried moving this method to a new class (the new class does not have
Guice Injection), tried adding one more intermediate method as pass
through, but the error is still the same. But if the method parameter
remains Result, if I extract the fields from the result and pass it down to
another method it does not complain.
I was writing some generic code which could take in any result type and
prints out the information like request id. I have added lots of
duplication of code by defining one method per result type. Can someone
please help me here ?
Thanks,
Arun.
--
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+***@googlegroups.com.
To post to this group, send email to google-***@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/47241614-1812-4e4b-a9a3-058a4cca7a9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
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+***@googlegroups.com.
To post to this group, send email to google-***@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/47241614-1812-4e4b-a9a3-058a4cca7a9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.