Skip to content

Class already loaded #1838

@dorohovGeorge

Description

@dorohovGeorge

Hi! I have such a problem and a question.
I am starting the creation of classes via ByteBuddy at the time of the Spring application launch
And everything was fine until I had tests for this Spring application. I run the tests through JUnit and Maven.
When the tests are run individually, this class generation method works without problems. But if the methods are run together in the same module, then the problem arises that such a class has already been loaded.
java.lang.IllegalStateException: Cannot inject already loaded type: class PolynomialAud at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection.injectRaw(ClassInjector.java:333) at net.bytebuddy.dynamic.loading.ClassInjector$AbstractBase.injectRaw(ClassInjector.java:166) at net.bytebuddy.dynamic.loading.ClassInjector$AbstractBase.inject(ClassInjector.java:154) at net.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default$InjectionDispatcher.load(ClassLoadingStrategy.java:241) at net.bytebuddy.dynamic.loading.ClassLoadingStrategy$Default.load(ClassLoadingStrategy.java:148) at net.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrategy.java:101) at net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:6424)
And I want to know if this issue has already been raised. And the question is whether it is possible to unload the classes uploaded via ByteBuddy? Or track them? Loading classes use ClassLoadingStrategy.Default.INJECTION and can't change it

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions