java.lang.IllegalArgumentException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • *Original problem:* I have an abstract groovy class, and two (or more) concrete java subclasses extend it. The superclass has an abstract method, which each concrete subclass overrides (of course). When I use just one subclass, everything works fine: I call a superclass method that calls the abstract method, and I get the behavior I expect. But when the other subclass has already been loaded, things are different. Then, I get an IllegalArgumentException: object is not an instance of declaring class. This problem corresponds to testGenericSubclassWithBafflingSymptom() in the attached junit tests. See that test for additional details. *Simpler case that illustrates the likely underlying problem (and does not involve generics):* I have an abstract groovy class, and two concrete java subclasses extend it. If I have an instance of just one of the subclasses, then instance.metaClass.theClass returns exactly what I expect. But if I've already loaded the other subclass, then the metaClass on an instance of *either* subclass is for the class that was used first! {code:java} // snippet of the groovy version of testSubclass(), also attached OtherConcreteJavaSubclass unrelatedInstance = new OtherConcreteJavaSubclass(); ConcreteJavaSubclass instance = new ConcreteJavaSubclass(); assertEquals("this one works", OtherConcreteJavaSubclass, unrelatedInstance.metaClass.theClass) assertEquals("but this one is wrong", ConcreteJavaSubclass, instance.metaClass.theClass) {code} This mixture of groovy and java may sound a little odd, but we actually ran into it when converting an existing class from java to groovy, and it stumped us for quite a while.
    via by Laura Dean,
  • Spring+JPA+DAO+Tomcat
    via Stack Overflow by Ivan
    ,
    • java.lang.IllegalArgumentException: object is not an instance of declaring class 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 org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSite.invoke(PogoMetaMethodSite.java:226) at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.callCurrent(PogoMetaMethodSite.java:52) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:145)

    Users with the same issue

    Unknown visitor1 times, last one,
    Pilleo
    1 times, last one,
    kjhdofjosvs
    2 times, last one,
    tyson925
    2 times, last one,
    Unknown visitor1 times, last one,
    94 more bugmates