Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[类工具] ClassUtil.getTypeArgument() 获取泛型存在null情况 #3516

Closed
iamxiaojianzheng opened this issue Mar 15, 2024 · 2 comments
Closed
Labels

Comments

@iamxiaojianzheng
Copy link

iamxiaojianzheng commented Mar 15, 2024

版本情况

JDK版本: openjdk_8_341
hutool版本: 5.8.26(请确保最新尝试是否还有问题)

问题描述(包括截图)

  1. 复现代码
public class Demo implements A2B {
    public static void main(String[] args) {
        // 5.8.20版本之前结果正常为B类,5.8.21开始之后的版本结果为null。
        System.out.println(ClassUtil.getTypeArgument(Demo.class, 0));
    }
    @Override
    public A apply(B arg0) {
        A a = new A();
        return a;
    }
}

class A {
    private String name;
}

class B {
    private String name;
}

interface A2B extends Function<B, A> {
}
  1. 堆栈信息

  2. 测试涉及到的文件(注意脱密)

比如报错的Excel文件,有问题的图片等。

@iamxiaojianzheng
Copy link
Author

从5.8.21发布的日志看,是gitee#I7CRIW 这个issue对应的 commit 改动导致的

@iamxiaojianzheng iamxiaojianzheng changed the title ClassUtil.getTypeArgument 有问题 [类工具] ClassUtil.getTypeArgument() 获取泛型存在null情况 Mar 15, 2024
@looly looly added the bug label Mar 18, 2024
@looly
Copy link
Member

looly commented Mar 18, 2024

5.8.27修复此问题。

原因是修改后没有递归获取父类的父类的类型导致的。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants