I have implemented a function to process a large array of strings (user names), checking for single quotes and pushing them into a new array before returning it.
However, I recently encountered an issue as the number of users in the list has grown substantially (currently 7418), causing this function to generate an error:
Caused by: java.lang.ClassFormatError: Invalid method Code length 105684 in class file org/mozilla/javascript/gen/c135516
Given that the version of javascript used is embedded in the application, upgrading it is currently not an option.
Is there a more efficient approach to achieve the same outcome? Are there alternative methods that could help prevent this error?
function listExcludedUsers(rInactive) {
var result = new Array('user1', 'user2', 'user3', 'user4');
for (var i = 0; i < rInactive.length; i++) {
//replace single quote with two single quotes for DQL
if (rInactive[i].indexOf("'") > 0) {
rInactive[i] = rInactive[i].replace(/'/g, "''");
}
result.push(rInactive[i]);
}
return result;
}