(String s)
| 1291 | /// |
| 1292 | /// the contents of the string as a char array guaranteed to be a copy of the current array |
| 1293 | public static char[] toCharArray(String s) { |
| 1294 | // toCharArray should return a new array always, however some devices might |
| 1295 | // suffer a bug that allows mutating a String (serious security hole in the JVM) |
| 1296 | // hence this method simulates the proper behavior |
| 1297 | if (!charArrayBugTested) { |
| 1298 | charArrayBugTested = true; |
| 1299 | if (s.toCharArray() == s.toCharArray()) { //NOPMD CompareObjectsWithEquals |
| 1300 | charArrayBug = true; |
| 1301 | } |
| 1302 | } |
| 1303 | if (charArrayBug) { |
| 1304 | char[] c = new char[s.length()]; |
| 1305 | System.arraycopy(s.toCharArray(), 0, c, 0, c.length); |
| 1306 | return c; |
| 1307 | } |
| 1308 | return s.toCharArray(); |
| 1309 | } |
| 1310 | |
| 1311 | private static String encode(String str, String spaceChar) { |
| 1312 | if (str == null) { |
no test coverage detected