public static char[] toCharArray(String s){
  if (!charArrayBugTested) {
    charArrayBugTested=true;
    if (s.toCharArray() == s.toCharArray()) {
      charArrayBug=true;
    }
  }
  if (charArrayBug) {
    char[] c=new char[s.length()];
    System.arraycopy(s.toCharArray(),0,c,0,c.length);
    return c;
  }
  return s.toCharArray();
}

public static char [ ] toCharArray ( String s ) { if ( ! charArrayBugTested ) { charArrayBugTested = true ; if ( s . toCharArray ( ) == s . toCharArray ( ) ) { charArrayBug = true ; } } if ( charArrayBug ) { char [ ] c = new char [ s . length ( ) ] ; System . arraycopy ( s . toCharArray ( ) , 0 , c , 0 , c . length ) ; return c ; } return s . toCharArray ( ) ; }
tochararray should return a new array always , however some devices might suffer a bug that allows mutating a string ( serious security hole in the jvm ) hence this method simulates the proper behavior
