Closed GoogleCodeExporter closed 9 years ago
This seems like a good improvement. I will get to it eventually, thanks!
Original comment by nathan.s...@gmail.com
on 10 Oct 2010 at 2:49
Original comment by nathan.s...@gmail.com
on 10 Oct 2010 at 2:50
For your idea to work, the class which accesses protected or default access
members must be defined by the same classloader as the class it is accessing.
Spec excerpt:
5.3 Creation and Loading
...
At run time, a class or interface is determined not by its name alone, but by a
pair: its fully qualified name and its defining class loader. Each such class
or interface belongs to a single runtime package. The runtime package of a
class or interface is determined by the package name and defining class loader
of the class or interface.
5.4.4 Access Control
...
A field or method R is accessible to a class or interface D if and only if any
of the following conditions is true:
* ...
* R is either protected or package private (that is, neither public nor
protected nor private), and is declared by a class in the same runtime package
as D.
I implemented a workaround in ReflectASM:
http://code.google.com/p/reflectasm/source/detail?r=14
I attempt reflection and setAccessible to call the protected defineClass in the
correct classloader. If this fails, ReflectASM's classloader is used. If it
succeeds, then protected and default access methods and fields are accessible.
Original comment by nathan.s...@gmail.com
on 9 Feb 2011 at 8:48
Original issue reported on code.google.com by
g.zarn...@googlemail.com
on 2 Sep 2010 at 2:55