简体   繁体   English

FindBugs - 完成错误

[英]FindBugs - finalize error

I have finalize method in my project(I know finalize should not be used, but can not change logic now.) FindBugs gives error that super.finalize() should be called, but if that is done and Throwable is catched (which should not be done either), FindBugs gives another error, stating Throwable should not be catched. 我在我的项目中有finalize方法(我知道不应该使用finalize ,但现在不能更改逻辑。)FindBugs给出了应该调用super.finalize()错误,但是如果这样做并且Throwable (不应该要么完成),FindBugs会给出另一个错误,说明Throwable不应该被捕获。

I can not throw Throwable either, application may suffer. 我也不能投掷Throwable ,应用可能会受到影响。

Is there anyway out? 反正了吗?

You have to throw Throwable in your finalize method. 你必须在你的finalize方法中抛出Throwable Here is the code of the method you need: 以下是您需要的方法代码:

@Override
protected void finalize() throws Throwable
    try {
        super.finalize();
    } finally {
        ...
    }
}

From your telling: 从你的讲述:

try {
    super.finalize();
} finally {
    ... // your code
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM