简体   繁体   English

强制执行异常处理之前的功能(JAVA)

[英]Force the execution of a function before exception handling (JAVA)

I am currently working on a big project (multiples sources files). 我目前正在做一个大项目(多个源文件)。 I would like to fix an abnormal behavior by adding a function execution before the program's stop with exception (I mean I have to add this fonctionnality into a lots of existing functions). 我想通过在程序异常停止之前添加函数执行来修复异常行为(我的意思是我必须将此功能添加到许多现有函数中)。 Is-it a simple solution (avoiding adding a line for each function) to force the execution ? 是一种强制执行的简单解决方案(避免为每个函数添加一行)吗?

thanks a lot 非常感谢

Tis是面向方面编程的完美用例https://en.wikipedia.org/wiki/Aspect-oriented_programming

before the program's stop with exception 在程序异常停止之前

You can use addShutdownHook method. 您可以使用addShutdownHook方法。

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

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