raphw / byte-buddy

Runtime code generation for the Java virtual machine.
https://bytebuddy.net
Apache License 2.0
6.23k stars 804 forks source link

BUG: instrumentation error #1587

Closed YongwuHe closed 6 days ago

YongwuHe commented 8 months ago

@raphw

lombok.NonNull

@Override
public Collection<?> fuzzyQueryCity(@NonNull String name) {
}

@Override
public Map<Long, CityBasicData> batchSearchCity(@NonNull List<Long> IdList, @NonNull String language) {
}

When I try to modify this method (batchSearchCity), the following exception is thrown. What is the reason?


 ERROR TransformListener - onError: loaded: false from classLoader ParallelWebappClassLoader
  context: ROOT
  delegate: false
----------> Parent Classloader:
, throwable: java.lang.IllegalStateException: Illegal type annotations on parameter java.lang.String arg0 for public java.util.Collection fuzzyQueryCity(java.lang.String)
raphw commented 8 months ago

I assume this is a Lombock issue. The exception states what the issue is. You can ignore this if you only want to decorate classes (apply Advice) by setting DECORATE as a type strategy.

YongwuHe commented 8 months ago

@raphw My question is why this type of method cannot be decorated.

raphw commented 8 months ago

Byte Buddy resolves the type to a type description. Doing so it discovers that fuzzyQueryCity(java.lang.String) has a type annotation on its first parameter that is not legally defined to be added on a parameter.