Java: Is it possible to always execute a certain function before other functions are called? (Like @Before in JUnit)

前端 未结 7 1576
情歌与酒
情歌与酒 2021-01-02 23:59

Is there a way to always execute a function before any other function of a class is called?

I have a class where I need to refresh some fields always before any func

相关标签:
7条回答
  • 2021-01-03 00:46

    Not in Java SE, but if you are using Java EE, you could use interceptors.

    For standalone applications, you could consider using a bytecode manipulation framework, like javassist.

    0 讨论(0)
提交回复
热议问题