On 30.07.2017 23:26, OC wrote:
Hi there again,

On 30. 7. 2017, at 21:16, o...@ocs.cz wrote:
I have got the following code (part of a big project):
===
class AuctionTable extends SecureComponent {
   public AuctionTable(WOContext context) {
       super(context)
       showClosedAuctions=... some expression ... // the fail line 8, see 
please below
... ...
   }
   boolean showClosedAuctions
... ...
===

it looks like an explicit type-cast, i.e.,

I am not really having enough information to be sure, but I can say what it looks like it me (though not why that should be different in 8 and 7)

Your method call was done using Reflection and an invoke method, which takes an Object[] for the arguments. Obviously the method we call will have typed parameters, so what happens if the argument runtime types and the parameter types do not fit together? You get the mentioned IllegalArgumentException.

[...]
...
Caused by: java.lang.IllegalArgumentException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:497)
        at 
org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
        at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2705)
        at groovy.lang.ExpandoMetaClass.setProperty(ExpandoMetaClass.java:1185)
        at groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3747)
        at components.sharedcode.OCSComponent.setProperty(OCSComponent.groovy)
        at 
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setGroovyObjectProperty(ScriptBytecodeAdapter.java:532)
        at components.sharedparts.AuctionTable.<init>(AuctionTable.groovy:8)

ExpandoMetaClass. setProperty is use§d to resolve the assignment you mentioned. This most likely calls an existing setter method or some other java method, that handles the call (CachedMethod.invoke) and it does at least the first such call using Reflection (Method.invoke and all the MethodAccessor things)

bye Jochen

Reply via email to