logo       

Re: calling method with List in signature: msg#00092

lang.groovy.user

Subject: Re: calling method with List in signature

Did you try:

List blockList = new Vector();

?
(I don't know if this will work or not - just guessing here...)
Randy Thornton wrote:

I have a java class with a method that takes two arguments. One is a class I
define and the other is a List interface. The call to the method from groovy
works if the List is empty, but fails if the List has elements in it. I get an
error that the second argument is the wrong class and the class type is the
first element of the List. How do I tell it to pass the List to the method?

Vector blockList = new Vector(); blockList.add( salesRollupBlock );
yyy.populateCategoryRollupFromBlocks( catRollupBlock, (List)blockList );


groovy.lang.GroovyRuntimeException: failed to invoke method: groovy.lang.MetaMet
hod@14e5d57[name: populateCategoryRollupFromBlocks params: [class com.perfretail
.k2v1.trackers.sales.CategoryRollupBlock, interface java.util.List] returns: voi
d owner: class com.perfretail.k2v1.envoys.sales.SalesTotalEnvoy] on: com.perfret
ail.k2v1.envoys.sales.SalesTotalEnvoy@1ad9b0f with arguments: [com.perfretail.k2
v1.trackers.sales.CategoryRollupBlock@15d533d, [com.perfretail.k2v1.trackers.sal
es.SalesRollupBlock@178b0f9]] reason: java.lang.ClassCastException
at groovy.lang.MetaClass.doMethodInvoke(MetaClass.java:1383)
at groovy.lang.MetaClass.invokeMethod(MetaClass.java:316)
at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:143)
at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.
java:106)
at script1097528528832.run(script1097528528832.groovy:78)
at gjdk.script1097528528832_GroovyReflector.invoke(script1097528528832_G
roovyReflector.java)
at groovy.lang.MetaMethod.invoke(MetaMethod.java:110)
at groovy.lang.MetaClass.doMethodInvoke(MetaClass.java:1372)
at groovy.lang.MetaClass.invokeMethod(MetaClass.java:316)
at groovy.lang.MetaClass.invokeMethod(MetaClass.java:301)
at groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java
:73)

Randy





<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise