Normal view

There are new articles available, click to refresh the page.
Today — 3 January 2025Main stream

有静态分析工具可以分析出因为拆箱导致的空指针 NPE 吗?

By: inza9hi
3 January 2025 at 20:07
inza9hi:

我一直以为静态分析已经很强大了, 尝试了下 IDEA 自带的工具和 PMD 竟然都分析不出来。

PS: A 是 Pb 生成的,B 是手写的,所以导致有用 int ,有用 integer

@Data
    static class A{
        private int a;
    }
    @Data
    static class B  {
        private Integer b;
    }

    public static void main(String[] args) {
        A a = new A();
        B b = new B();
       a.setA(b.getB());
    }
❌
❌