byte-buddy icon indicating copy to clipboard operation
byte-buddy copied to clipboard

NoSuchTypeException: Cannot resolve type description for… after moving a type in VS Code

Open odrotbohm opened this issue 2 years ago • 1 comments

I use Bytebuddy 1.14.5 in a Maven project with VSCode. Let's say I have my code compiled and it works file. If I move a type (SomeInternal in the trace below) between packages, I see the following error in the console. I assume the exception is caused by a mismatch between the classpath and the cache that Bytebuddy uses. I am wildly guessing that VSC reuses the plugin instance which is still referring to the old classpath and not finding the type in the new location.

Do you think a scenario like this would cause the exception shown below?

…
Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to transform class files in /Users/odrotbohm/Documents/workspace/arch-evident-spring/target/classes
	at net.bytebuddy.build.maven.ByteBuddyMojo.apply(ByteBuddyMojo.java:470)
	at net.bytebuddy.build.maven.ByteBuddyMojo.execute(ByteBuddyMojo.java:340)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:126)
	at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeMojo(MavenExecutionContext.java:338)
	... 41 more
Caused by: net.bytebuddy.pool.TypePool$Resolution$NoSuchTypeException: Cannot resolve type description for SomeInternal
	at net.bytebuddy.pool.TypePool$Resolution$Illegal.resolve(TypePool.java:190)
	at net.bytebuddy.pool.TypePool$Default$WithLazyResolution$LazyTypeDescription.delegate(TypePool.java:1111)
	at net.bytebuddy.description.type.TypeDescription$AbstractBase$OfSimpleType$WithDelegation.getModifiers(TypeDescription.java:8535)
	at net.bytebuddy.description.ModifierReviewable$AbstractBase.matchesMask(ModifierReviewable.java:618)
	at net.bytebuddy.description.ModifierReviewable$AbstractBase.isStatic(ModifierReviewable.java:329)
	at net.bytebuddy.description.type.TypeDescription$AbstractBase.getInnerClassCount(TypeDescription.java:8154)
	at net.bytebuddy.pool.TypePool$Default$LazyTypeDescription$GenericTypeToken$Resolution$Raw$RawAnnotatedType.getDeclaredAnnotations(TypePool.java:3817)
	at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Validator$ForTypeAnnotations.isValid(TypeDescription.java:1671)
	at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Validator$ForTypeAnnotations.onNonGenericType(TypeDescription.java:1660)
	at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Validator$ForTypeAnnotations.onNonGenericType(TypeDescription.java:1575)
	at net.bytebuddy.description.type.TypeDescription$Generic$OfNonGenericType.accept(TypeDescription.java:3744)
	at net.bytebuddy.dynamic.scaffold.InstrumentedType$Default.validated(InstrumentedType.java:1682)
	at net.bytebuddy.dynamic.scaffold.MethodRegistry$Default.prepare(MethodRegistry.java:519)
	at net.bytebuddy.dynamic.scaffold.inline.RebaseDynamicTypeBuilder.toTypeWriter(RebaseDynamicTypeBuilder.java:220)
	at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase$UsingTypeWriter.make(DynamicType.java:4057)
	at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase$Delegator.make(DynamicType.java:4007)
	at net.bytebuddy.build.Plugin$Engine$Default$Preprocessor$Resolved.call(Plugin.java:4893)
	at net.bytebuddy.build.Plugin$Engine$Default$Preprocessor$Resolved.call(Plugin.java:4850)
	at net.bytebuddy.build.Plugin$Engine$Dispatcher$ForSerialTransformation.complete(Plugin.java:3927)
	at net.bytebuddy.build.Plugin$Engine$Default.apply(Plugin.java:4709)
	at net.bytebuddy.build.maven.ByteBuddyMojo.apply(ByteBuddyMojo.java:468)
	... 44 more

odrotbohm avatar Jul 27 '23 16:07 odrotbohm

Yes, it certainly would. A ClassFileLocator is querying a class loader or file system location which resolves a .class file. If the file cannot be resolved, this exception is thrown.

raphw avatar Aug 06 '23 21:08 raphw