ByteBuddy:java.lang.IllegalArgumentException:无法附加未定义的变量:V
ByteBuddy: java.lang.IllegalArgumentException: Cannot attach undefined variable: V
从 Google Guava 变基 class com.google.common.collect.ImmutableMultimap$Values
时,我从 ByteBuddy 收到 IllegalArgumentException。
内部 class 是 com.google.common.collect.ImmutableCollection
的子 class,其方法 ImmutableList<E> createAsList()
导致了问题。
堆栈跟踪:
Exception in thread "main" java.lang.IllegalArgumentException: Cannot attach undefined variable: V
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:1973)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:1896)
at net.bytebuddy.description.type.TypeDescription$Generic$OfTypeVariable$Symbolic.accept(TypeDescription.java:5551)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor.onParameterizedType(TypeDescription.java:1857)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onParameterizedType(TypeDescription.java:1896)
at net.bytebuddy.description.type.TypeDescription$Generic$OfParameterizedType.accept(TypeDescription.java:5017)
at net.bytebuddy.dynamic.Transformer$ForMethod$TransformedMethod.getReturnType(Transformer.java:377)
at net.bytebuddy.description.method.MethodDescription$AbstractBase.asTypeToken(MethodDescription.java:685)
at net.bytebuddy.dynamic.scaffold.MethodRegistry$Default$Prepared$Entry.resolveBridgeTypes(MethodRegistry.java:916)
at net.bytebuddy.dynamic.scaffold.MethodRegistry$Default$Prepared.compile(MethodRegistry.java:778)
at net.bytebuddy.dynamic.scaffold.TypeWriter$Default$ForInlining$RedefinitionClassVisitor.visit(TypeWriter.java:3281)
at net.bytebuddy.jar.asm.ClassReader.accept(Unknown Source)
at net.bytebuddy.jar.asm.ClassReader.accept(Unknown Source)
at net.bytebuddy.dynamic.scaffold.TypeWriter$Default$ForInlining.create(TypeWriter.java:3018)
at net.bytebuddy.dynamic.scaffold.TypeWriter$Default.make(TypeWriter.java:1617)
at net.bytebuddy.dynamic.scaffold.inline.RebaseDynamicTypeBuilder.make(RebaseDynamicTypeBuilder.java:198)
at net.bytebuddy.dynamic.scaffold.inline.AbstractInliningDynamicTypeBuilder.make(AbstractInliningDynamicTypeBuilder.java:90)
at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase.make(DynamicType.java:2566)
at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase$Delegator.make(DynamicType.java:2668)
at cl.InnerClassLoader.loadClass(InnerClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at test.Stuff.<init>(Stuff.java:15)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at java.lang.Class.newInstance(Class.java:438)
at test.Main.main(Main.java:15)
我在这里创建了一个触发问题的示例:https://github.com/erikhakansson/bytebuddytest
该测试是根据我之前的测试修改的,因此其中可能有一些垃圾。
要进行测试,只需 运行 mvn clean install 然后 运行 生成的 jar。
很可能,我做错了什么,但我不知道是什么,所以请帮忙! :)
您在字节好友中发现了一个错误。我已经在 Byte Buddy 1.4.17 中解决了这个问题(以前在 1.6.14 版本中不正确)。
从 Google Guava 变基 class com.google.common.collect.ImmutableMultimap$Values
时,我从 ByteBuddy 收到 IllegalArgumentException。
内部 class 是 com.google.common.collect.ImmutableCollection
的子 class,其方法 ImmutableList<E> createAsList()
导致了问题。
堆栈跟踪:
Exception in thread "main" java.lang.IllegalArgumentException: Cannot attach undefined variable: V
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:1973)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onTypeVariable(TypeDescription.java:1896)
at net.bytebuddy.description.type.TypeDescription$Generic$OfTypeVariable$Symbolic.accept(TypeDescription.java:5551)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor.onParameterizedType(TypeDescription.java:1857)
at net.bytebuddy.description.type.TypeDescription$Generic$Visitor$Substitutor$ForAttachment.onParameterizedType(TypeDescription.java:1896)
at net.bytebuddy.description.type.TypeDescription$Generic$OfParameterizedType.accept(TypeDescription.java:5017)
at net.bytebuddy.dynamic.Transformer$ForMethod$TransformedMethod.getReturnType(Transformer.java:377)
at net.bytebuddy.description.method.MethodDescription$AbstractBase.asTypeToken(MethodDescription.java:685)
at net.bytebuddy.dynamic.scaffold.MethodRegistry$Default$Prepared$Entry.resolveBridgeTypes(MethodRegistry.java:916)
at net.bytebuddy.dynamic.scaffold.MethodRegistry$Default$Prepared.compile(MethodRegistry.java:778)
at net.bytebuddy.dynamic.scaffold.TypeWriter$Default$ForInlining$RedefinitionClassVisitor.visit(TypeWriter.java:3281)
at net.bytebuddy.jar.asm.ClassReader.accept(Unknown Source)
at net.bytebuddy.jar.asm.ClassReader.accept(Unknown Source)
at net.bytebuddy.dynamic.scaffold.TypeWriter$Default$ForInlining.create(TypeWriter.java:3018)
at net.bytebuddy.dynamic.scaffold.TypeWriter$Default.make(TypeWriter.java:1617)
at net.bytebuddy.dynamic.scaffold.inline.RebaseDynamicTypeBuilder.make(RebaseDynamicTypeBuilder.java:198)
at net.bytebuddy.dynamic.scaffold.inline.AbstractInliningDynamicTypeBuilder.make(AbstractInliningDynamicTypeBuilder.java:90)
at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase.make(DynamicType.java:2566)
at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase$Delegator.make(DynamicType.java:2668)
at cl.InnerClassLoader.loadClass(InnerClassLoader.java:187)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at test.Stuff.<init>(Stuff.java:15)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
at java.lang.Class.newInstance(Class.java:438)
at test.Main.main(Main.java:15)
我在这里创建了一个触发问题的示例:https://github.com/erikhakansson/bytebuddytest 该测试是根据我之前的测试修改的,因此其中可能有一些垃圾。
要进行测试,只需 运行 mvn clean install 然后 运行 生成的 jar。
很可能,我做错了什么,但我不知道是什么,所以请帮忙! :)
您在字节好友中发现了一个错误。我已经在 Byte Buddy 1.4.17 中解决了这个问题(以前在 1.6.14 版本中不正确)。