Reflection: setting public fields of an object from another package

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mikhail Teterin

    Reflection: setting public fields of an object from another package

    Hello!

    I have a method, that is supposed to set fields in an object passed to it.
    Any object -- the names of the fields are determined at run-time, the only
    (obvious) requirement is, the fields must be "public".

    This worked perfectly fine, until I put that method's class into a package
    of its own.

    Now, when the method is given an object of a class /from another package/
    the field-setting fails:

    Field CDS_REPL is not accessible: java.lang.Illeg alAccessExcepti on: Class foo.bar.BarQueu e can not access a member of class foo.dang.Meow with modifiers "public"

    How can I overcome this? Is there something more permissive than "public",
    or, perhaps, I can, somehow, explicitly grant foo.bar.BarQueu e the right
    to modify public fields the callers?

    Thanks!

    -mi
Working...