从Google Guava重新定位课程com.google.common.collect.ImmutableMultimap$Values
时,我会从ByteBuddy获得IllegalArgumentException。
内部类是com.google.common.collect.ImmutableCollection
的子类,其方法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。
最有可能的是,我做错了什么,但我无法弄清楚是什么,所以请帮忙! :)
答案 0 :(得分:2)
您在Byte Buddy中发现了一个错误。我在Byte Buddy 1.4.17中解决了这个问题(以前在版本1.6.14中不正确)。