Hi I’m getting the violation as below:
Malicious code vulnerability – May expose internal representation by
returning reference to mutable object
in my code i wrote like this
public String[] chkBox() {
return chkBox;
}
How we can solve it.
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.
As the error message states, you’re returning internal state (chkBox is – most likely – part of the internal state of an object even though you’re not showing its definition)
This can cause problems if you – for example – do
Since an array object, as all Java objects, is passed by reference, this will change the original array stored inside your object as well.
What you most likely want to do to fix this is a simple
which returns a copy of the array instead of the actual array.