简体   繁体   中英

Byte Buddy class is loaded but cannot be accessed using ClassLoader.load

I have created a new class with the following code:

//...name and fields etc
.make()
.load(NetworkClassManager.class.getClassLoader())
.getLoaded();

Which has created my class called TestNetwork_ND , but when I try access it using:

NetworkClassManager.class.getClassLoader().loadClass("TestNetwork_ND")

I get the following error:

java.lang.ClassNotFoundException: TestNetwork_ND

How can I load it onto the classpath properly so that I can access it in the above way?

I had to inject the class.

.make()
.load(NetworkClassManager.class.getClassLoader(), ClassLoadingStrategy.Default.INJECTION)
            .getLoaded();

Using the ClassLoadingStrategy.Default.INJECTION , loading strategy fixed it for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM