This discussion is archived
5 Replies Latest reply: May 3, 2010 7:49 PM by 843798 RSS

Reflaction problem

843798 Newbie
Currently Being Moderated
Hello,

I am using reflection to invoke particular methods in runtime. Code looks like:

method = workClass.getMethod(methodName, parameterTypes);
retrivedValue = method.invoke(retrivedValue, parameterValues);


Most of the time 99% cases, it works properly. But, sometimes the following error is happened:

Throwable:
java.lang.VerifyError: COM/net/java/ppl/PPLFacade.getInstance()LCOM/net/java/ppl/PPLFacade;
at sun.reflect.GeneratedMethodAccessor96.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:615)

It is strange because the some method will be invoked many times correctly and suddenly for the some method previous error will be thrown.
Does anyone know what problem could be?

Thank you in advance.
K
  • 1. Re: Reflaction problem
    jschellSomeoneStoleMyAlias Expert
    Currently Being Moderated
    Presumably you know what the error means.

    Could be that most of the time you go down code path A in the call tree (in the reflected code).
    Sometimes you go down code path B and that path is attempting to load a bad class.
  • 2. Re: Reflaction problem
    843798 Newbie
    Currently Being Moderated
    Thanks for thoughts.

    I do not have idea what the error means.

    I put break point and I saw that:
         methodName is: getInstance
         parameterTypes: null
         retrievedValue: COM.net.java.ppl.PPLFacade
         parameterValues: null


    Can you please tell me do you see some solution for this problem?

    Thanks.
    K
  • 3. Re: Reflaction problem
    jschellSomeoneStoleMyAlias Expert
    Currently Being Moderated
    Katarina9 wrote:
    I do not have idea what the error means.
    That specific exception occurs for a specific reason in java. You should look at the java docs.
    It occurs due to a type of failure in loading a class.
  • 4. Re: Reflaction problem
    843798 Newbie
    Currently Being Moderated
    A couple things to think about:

    Are you always executing the method from the same threads? The javadocs refer to the fact it can be a security issue. If you're running in some type of sandbox, or if a given thread has restricted access, it could cause this exception.

    Another possibility is you're running out of memory in some strange way. Usually you'll get an 'OutOfMemoryError' thrown, but that is if the JVM runs out of memory. It could be something strange happening with lack of memory (or temporary space etc) on the system. Have you tried executing the code on different machines? The fact that you said it happens many times, then has a problem makes me believe there is a memory leak somewhere (or a space issue).
  • 5. Re: Reflaction problem
    843798 Newbie
    Currently Being Moderated
    I have list of items. With every item selection, I have to create panel with different components on it dynamically.
    I am creating thread to build GUI on the fly. So, in the thread:
         - I am repeating the following process:
              1.I instantiate corresponding component(I don't know in advance which it will be - JList, JTable,...),
              2.place it on the panel,
              3.using reflection I get data value, and
              4.populate component with retrieved value.
         - In event dispatch thread, I am placing panel on corresponding tab.

    I have not tried executing the code on different machines but this project went in production, so many people use it
    and so far nobody complained.

    Thank you.
    K