public static String makeValidConstantName(String candidateName) {
    String answer = candidateName;
    for (int i = 0; i < answer.length(); i++) {
      char c = answer.charAt(i);
      if (Character.isLetterOrDigit(c) || c == '-' || c == '_' || c == '?')
        continue;
      StringBuffer answerBuf = new StringBuffer(answer);
      answerBuf.setCharAt(i, '_');
      answer = answerBuf.toString();
    }
    return answer;
  }