How to detect if a Java System property has changed?

陌路散爱 提交于 2019-12-05 06:40:15

You can replace the system Properties with your own custom subclass.

MyProperties newProps = new MyProperties(System.getProperties());
System.setProperties(newProps);

Then, just write a subclass of Properties which hooks the relevant methods.

If you primarily want to find the issue, I would look at using the SecurityManager for this. It has a couple methods available checkPropertiesAccess() and checkPropertyAccess() which look like they will help you to find the issue, but not necessarily be able to 'notify you when a system property has changed.'

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!