ProbeJS icon indicating copy to clipboard operation
ProbeJS copied to clipboard

method filtering for parameterized interfaces seems not working at all

Open ZZZank opened this issue 11 months ago • 2 comments

This issue is about hasIdenticalParentMethod method in ClassInfo.java , it sems not working at all for parameterized interfaces.

E.g. Internal.RecipeFilter, which is a subclass of Internal.Predicate<Internal.RecipeKJS>, and here is what looks like in an actual dump (using ProbeJS 5.3.4 for MC1.19):

    interface RecipeFilter extends Internal.Predicate<Internal.RecipeKJS> {
        test(arg0: any): boolean;
        negate(): Internal.Predicate<Internal.RecipeKJS>;
        not<T>(arg0: Internal.Predicate_<T>): Internal.Predicate<T>;
        or(arg0: Internal.Predicate_<Internal.RecipeKJS>): Internal.Predicate<Internal.RecipeKJS>;
        and(arg0: Internal.Predicate_<Internal.RecipeKJS>): Internal.Predicate<Internal.RecipeKJS>;
        test(arg0: Internal.RecipeKJS_): boolean;
        of(cx: Internal.Context_, o: any): this;
        isEqual<T>(arg0: any): Internal.Predicate<T>;
        readonly PARSE: dev.architectury.event.Event<Internal.RecipeFilterParseEvent>;
    }

and Internal.Predicate

    interface Predicate <T> {
        negate(): this;
        not<T>(arg0: Internal.Predicate_<T>): this;
        or(arg0: Internal.Predicate_<T>): this;
        test(arg0: T): boolean;
        and(arg0: Internal.Predicate_<T>): this;
        isEqual<T>(arg0: any): this;
        (arg0: T): boolean;
    }

It's clear that inherited methods are not being filtered out.

ZZZank avatar Mar 27 '24 06:03 ZZZank

I made some tests days ago, and found that hasIdenticalParentMethod goes wrong when checking generic types. For RecipeFilter, getGenericReturnType() will return proper return type, but for Predicate, it's returning Object when generic T is involved.

But that was days ago, I'm not quite sure if it's returnType or parameterTypes that's going wrong.

ZZZank avatar Mar 27 '24 06:03 ZZZank

This was a very hard thing to be debugged, might be a low priority since I'm currently working on other things.

Prunoideae avatar Mar 27 '24 09:03 Prunoideae

https://github.com/Prunoideae/ProbeJS/blob/a9fe3bfab6bed5da7ed9ca19914fcc3469284588/common/src/main/java/moe/wolfgirl/next/java/clazz/Clazz.java#L119-L133 https://github.com/Prunoideae/ProbeJS/blob/a9fe3bfab6bed5da7ed9ca19914fcc3469284588/common/src/main/java/moe/wolfgirl/next/java/clazz/Clazz.java#L150-L159

👁👁

n0099 avatar May 24 '24 16:05 n0099