Regarding this in regular setup, there are very few cases where this can happen.
Non-public methods will result in a NoSuchMethodException because getMethod specifically searches only public methods. getDeclaredMethod will find this method, but will allow the return of private / protected methods.
The only real way to do this is, as javadocs say, to have a separate package that is protected by a security manager, which, I assume, can only be executed with unsigned applets or similar permissions. (I never came across this myself, so I'm not quite sure)
Your best bet is to force an exception to be thrown for specific methods by overriding the security manager.
xthexder
source share