RFR(M): 8199940: Print more information about class loaders in IllegalAccessErrors.
mandy chung
mandy.chung at oracle.com
Thu May 24 22:15:06 UTC 2018
On 5/24/18 2:12 PM, Lindenmaier, Goetz wrote:
> Hi Lois,
>
> I changed the code as agreed:
> http://cr.openjdk.java.net/~goetz/wr18/8199940-exMsg-IllegalAccess/02/
>
> I'm not really sure this is good:
>
> interface IAE1_A {
> public IAE1_D gen();
> }
> class IAE1_B implements IAE1_A {
> public IAE1_D gen() {
> return null;
> }
> }
> A is loaded by "app", B by the custom loader.
>
> The message is now:
> "class test.IAE1_B cannot access its superinterface test.IAE1_A"
> if there are no names in the loaders.
For this IAE, it should include the module in the message as:
class test.IAE1_B (in unnamed module @0x3d04a311) cannot access its
superinterface test.IAE1_A (in module m1)
> How should anybody know from the message that the classes were
> loaded by different loaders? It gives no hint at all to the cause of
> the problem.
The above is one example that does not have the loader name.
Each module is defined to one loader so it can derive from
the module info.
>> java.lang.IllegalAccessError: tried to access private method
>> MySameClassLoader/m2x/p2.c2.method2()V from class
>> MySameClassLoader/m1x/p1.c1
What about other formats:
tried to access private method p2.c2.method2()V (in module m2x) from
class p1.c1 (in module m1x)
if the loader name is highly desirable (I'm unsure yet):
tried to access private method p2.c2.method2()V (in module m2x defined
to MySameClassLoader) from class p1.c1 (in module m1x defined to
MySameClassLoader)
Mandy
More information about the hotspot-runtime-dev
mailing list