java.lang.IllegalArgumentException, Groovy 2.4.7, _might_ be caused by Java 8

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
OC
Reply | Threaded
Open this post in threaded view
|

java.lang.IllegalArgumentException, Groovy 2.4.7, _might_ be caused by Java 8

OC
Hi there,

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
... ...
===

which works without a glitch on my old computer (Java 1.7.0_13 / Mac OS X 10.8.5). Alas, it reliably fails with my new one (Java 1.8.0_45 / Mac OS X 10.12.5) this way:

===
...
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)
===

Does it make any sense? Can anybody here see the culprit and suggest a fix?

Thanks a lot,
OC

OC
Reply | Threaded
Open this post in threaded view
|

Followup: java.lang.IllegalArgumentException, Groovy 2.4.7, _might_ be caused by Java 8

OC
Hi there again,

On 30. 7. 2017, at 21:16, [hidden email] 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.,

===
...
showClosedAuctions=(boolean)... some expression ...
...
===

did help and it does not throw anymore. Weird. Shouldn't it be superfluous in this case?

Anyway, for the moment it seems it is resolved, althougth I regret to admit I do not understand the mechanism which caused the problem nor the one which fixed it at all.

Thanks,
OC

> which works without a glitch on my old computer (Java 1.7.0_13 / Mac OS X 10.8.5). Alas, it reliably fails with my new one (Java 1.8.0_45 / Mac OS X 10.12.5) this way:
>
> ===
> ...
> 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)
> ===
>
> Does it make any sense? Can anybody here see the culprit and suggest a fix?
>
> Thanks a lot,
> OC
>

Reply | Threaded
Open this post in threaded view
|

Re: Followup: java.lang.IllegalArgumentException, Groovy 2.4.7, _might_ be caused by Java 8

Jochen Theodorou


On 30.07.2017 23:26, OC wrote:

> Hi there again,
>
> On 30. 7. 2017, at 21:16, [hidden email] 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