1818import static java .lang .String .format ;
1919import static java .util .function .Predicate .not ;
2020import static java .util .stream .Collectors .toList ;
21+ import static java .util .stream .IntStream .range ;
2122import static net .bytebuddy .matcher .ElementMatchers .is ;
2223import static net .bytebuddy .matcher .ElementMatchers .named ;
2324import static org .jmolecules .bytebuddy .PluginUtils .markGenerated ;
@@ -287,7 +288,7 @@ private Method checkMethod(ConfigEntry config, TypeDescription actual) {
287288 TypeDescription [] parameters = new TypeDescription [] { config .anno (), config .resolveSuperType (actual ) };
288289 return checkMethod (parameters ).map (m -> {
289290 var supportedType = m .getParameterTypes ()[1 ];
290- if (new TypeDescription . ForLoadedType (supportedType ). isAssignableFrom ( actual )) {
291+ if (actual . isAssignableTo (supportedType )) {
291292 return m ;
292293 }
293294 throw annotationOnTypeNotValid (parameters [0 ], actual , List .of (supportedType .getName ()));
@@ -299,19 +300,24 @@ private IllegalStateException unsupportedType(TypeDescription... parameters) {
299300 var supported = this .codeFragmentMethods .stream () //
300301 .filter (this ::isCheckMethod ) //
301302 .filter (m -> m .getParameterCount () > 1 ) //
302- .filter (m -> TypeDescription . ForLoadedType . of (m .getParameterTypes ()[0 ]) == parameters [ 0 ] ) //
303+ .filter (m -> parameters [ 0 ]. represents (m .getParameterTypes ()[0 ])) //
303304 .map (m -> m .getParameterTypes ()[1 ].getName ()) //
304305 .collect (toList ());
305306 return annotationOnTypeNotValid (parameters [0 ], parameters [1 ], supported );
306307 }
307308
308309 private Optional <Method > checkMethod (TypeDescription ... parameters ) {
309- return codeFragmentMethods
310- .stream (). filter (this ::isCheckMethod ). filter ( m -> Arrays . equals ( Stream . of ( m . getParameterTypes ())
311- . map ( TypeDescription . ForLoadedType :: of ). toArray ( TypeDescription []:: new ), parameters ))
310+ return codeFragmentMethods . stream () //
311+ .filter (this ::isCheckMethod ) //
312+ . filter ( m -> representsAll ( parameters , m . getParameterTypes ())) //
312313 .findFirst ();
313314 }
314315
316+ private static boolean representsAll (TypeDescription [] descriptions , Class <?>[] classes ) {
317+ return classes .length == descriptions .length && range (0 , classes .length ) //
318+ .allMatch (i -> descriptions [i ].represents (classes [i ]));
319+ }
320+
315321 private boolean isCheckMethod (Method method ) {
316322 return "check" .equals (method .getName ());
317323 }
0 commit comments