I know that the Java have these serval keywords to identify the variable scope during development, but I would like to know whether this is different when it is in a production environment or just for coder interest? Thanks.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Accessibility is enforced at runtime as well. If some code tries to access a member that it shouldn’t, then
IllegalAccessExceptionorIllegalAccessErroris thrown. Here’s a quick demonstration:With reflection:
As it is, the above program outputs:
Without reflection:
When I use a bytecode editor to change
in method
noReflection()to:the output is:
As Michael mentioned this behavior may be JVM dependent. I ran this on