java. Lang.illegalaccesserror: attempt to access field concreteentity. From class entity instance

OK, so here's the deal I'm trying to access concreteentity Instance, which is the default field of the access type existing in the default classloader, while entity GetInstance is a method that exists in a child classloader

Remember, they are all in the same package, but an illegalaccesserror will be thrown Has this problem been solved without actually loading the entity class into the same classloader as concreteentity?

0 new #14 <Entity>
 3 dup
 4 aload_0
 5 invokevirtual #18 <Adapter.getInstance>
 8 checkcast #20 <sl>
11 getfield #24 <sl.d>
14 invokespecial #25 <Entity.<init>>
17 areturn

The bytecode retrieved through jclasslib is the exception generation "after compilation"

Thank you, gamb, for cleaning up the post

Solution

See my answer to a similar question. Except for your case, it is obvious that you are dealing with multiple class loaders:

The JVM believes that classes loaded from different class loaders can be in different "runtime packages", even if they have the same package name From the JVM spceification, section 5.3:

In section 5.4 In Section 4:

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>