Injecting private fields

24 views
Skip to first unread message

anton.b...@gmail.com

unread,
Mar 27, 2015, 12:43:47 AM3/27/15
to js...@googlegroups.com
Greetings,

I'd like to inject a plugin into a private field of another plugin. Source code seems supposed to allow it according to following lines in init method of InjectHandler:

// Try to get inject annotation. New: also turn on extended accessibility, so
// elements don't have to be public anymore.
field.setAccessible(true);

The only problem with those lines are the fact that "field" is part of "public only" collection of class fields:

final Field[] fields = plugin.getClass().getFields();
...
// Process every field
for (final Field field : fields) {

The fix would be to change getFields() to getDeclaredFields()

Am I right on it and can it be done?


Thanks,
Anton
Reply all
Reply to author
Forward
0 new messages