Menu

IllegalAccessException on reflection import

Developers
2008-01-14
2012-10-08
  • Christian Köllner

    Hello there,

    when I try to import one of the JRE classes (in my case: java.lang.String) by reflection, I'll get the following RuntimeException:

    Caused by: java.lang.IllegalAccessException: Class recoder.bytecode.ReflectionImport can not access a member of class java.lang.String with modifiers "private static final"

    Looking in the source code yields that the exception is fired by a code snippet which is prefixed by the comment "this should never happen!" - obviously it does. ;-) It seems that getClassFile doesn't make the fields accessible by calling setAccessible(). Is this the way to solve the problem? It did I do something wrong?

    Best regards,
    Christian

     
    • Tobias Gutzmann

      Tobias Gutzmann - 2008-01-16

      Hi,

      Yes, that should do the trick. Will be fixed in the next release. However, note that reflection import has not been updated to support Java 5 language features, so you won't get the same information as from reading the bytecode classes.

      /Tobias

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.