Open GGGTTTTT opened 1 month ago
This likely related to the javac version that was used. There has been a row of bugs related to type annotations, and Byte Buddy fails to parse those as they do not match the specification.
Thank you very much for your response. If I do not need to enhance the Guava classes, would it be appropriate to ignore these error messages?
You can do this. If you exclude them by their package prefix, the class will not be resolved. You will need to include this matcher first.
I found that I can't avoid this error by excluding package names related to Guava, as the error is triggered by ignoreMatcher. Can I directly ignore this error message?
Yes, you would need to define a custom ignore matcher that ignores types of this name before attempting to resolve the type description for any other complex property.
@raphw Will there be any updates in the future versions to address this situation?
By updating, the error will disappear eventually. Incorrect class files will lead to errors. There is some robustness in Byte Buddy, but generally speaking, errors like that cannot be really picked up.
@raphw We have updated the byte buddy to the latest version (1.15.0) and the issue still persists. Can we expect a fix for this issue in the upcoming byte buddy releases ?
This is an error in Guava. If you update the library, does this error still occur?
@raphw
I've done some testing on this issue, and it seems more likely to be related to javac
.
On the Windows platform, Java versions 9, 10, and 11 result in bytecode that isn't compatible with Byte Buddy, while starting from Java 12, things return to normal. All versions tested were from Azul JDK.
The incompatible bytecode appears in the bar
method in the following example, where an extra RuntimeVisibleTypeAnnotations(@LTest1678$Foo;() : CLASS_EXTENDS 0, 0;)
is added. This CLASS_EXTENDS breaks Byte Buddy's runtime operations. Here's the corresponding example:
public class Test1678 {
public static void main(String[] args) throws IOException {
ClassFileLocator locator = ClassFileLocator.ForClassLoader.of(Test1678.class.getClassLoader());
TypePool pool = TypePool.Default.of(locator);
pool.describe(Test1678.class.getName()).resolve();
}
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER})
public @interface Foo {
}
public static Object bar() {
return new Iterable<@Foo Object>() {
@Override
public Iterator<Object> iterator() {
return null;
}
};
}
}
So far, I've only tested on the Windows platform. Java 9, 10, and 11 all failed, while Java 8, 12, 16, 17, 21, and 22 all worked successfully.
That should be consistent for all OSes. This also sounds intuitive since 9, 10 and 11 are unsupported versions with no bug fix backports.
Are you planning to make Byte Buddy compatible with this specific value? From reviewing previous issues #1509 , it looks like there's some precedent for handling such cases.
From the code alone, my first instinct is that the segment return new Iterable<@Foo Object>
is what's causing the javac error.
On one hand, being inside the method body, it doesn't seem like it should cause a type resolution error. On the other hand, the JVM doesn’t reject it at runtime, so it doesn’t appear to be a serious error from the JVM's perspective either.
I can certainly add it since it is an enduring compiler bug. Could you create a reproduction without dependencies for me to integrate in Byte Buddy?
Of course! I can provide the source code and the corresponding bytecode files. Is that what you need?
Built from JDK-11. It includes the source file and bytecode file for net.bytebuddy.test.precompiled.v11.ClassExtendsTypeReference
ClassExtendsTypeReference.zip
This is now handled and supported by a test. It will be released with the next version. Sorry for not taking care of this earlier.
guava: 33.2.1-jre, byte-buddy: 1.14.18
When using byte-buddy to define java agent, some classes in Guava, such as Joiner, can result in the following errors:
However, this problem does not arise when using Guava versions not exceeding 33.2.0-jre, despite the fact that the Joiner has remained unchanged. test-agent.zip test-project.zip