I remove this throwTypeMismatch method because using it can sometimes triggers a weird warning in java compiler. 

For example, in this dummy method:

public int dummy(int i) {
  if (i > 0) {
    return 1;
  } else {
    throwSomeException();
  }
}

The java would report a warning saying that the method must return something in the else branch. We need to insert a return statement after the throwException method to make it work. I think it is pretty weird and I remove the method completely.