I like to reflect myself, but in the words: it can be a nightmare. Saving java reflection is very controllable (that is, stateless, without using global / external variables) and minimal scope.
What to look for?
To find private fields and methods that have become public, find Field#setAccessible() and Method#setAccessible() , for example, the following examples:
Field privateNameField = Person.class.getDeclaredField("name"); privateNameField.setAccessible(true); Method privatePersonMethod = Person.class.getDeclaredMethod("personMeth", null); privatePersonMethod.setAccessible(true);
So, setAccessible() will breathe for you, but getDeclaredField() and getDeclaredMethod() really where the fields are available (which really makes the fire).
Pay particular attention to the values ββused in them, especially if they are variables (they are likely to be), as they determine access to the field.
Search in plain text
It is also useful to use text search for the field / method name in the entire project folder. I would say if you are not sure, do not delete before performing a full text search .
If you have many other projects that depend on this, which you are trying to change; and if you werenβt (or didnβt know) the guy who planted these (bombs), I would let him go. If only it would have changed, if really really needed. The best action would be to get them one by one when you need to make changes to the code around it.
And, and if you have, running tests with code coverage can also help you spend a lot of time looking for unused code.
source share