title: java.lang.ClassCastException: org.antlr.runtime.CommonToken cannot be cast to antlr.Token
body: <p>I am trying to check similarities between two codes, I need the id of Tokens from lexer,
  but I don't know why I get this error: </p>
  
  <pre><code>java.lang.ClassCastException: org.antlr.runtime.CommonToken cannot be cast to antlr.Token
  </code></pre>
  
  <p>Here is the code:</p>
  
  <pre><code>final CommonTokenStream tokens;
  tokens = new CommonTokenStream();
  
  tokens.setTokenSource(lexer);
  tokens.LT(10); // force load
  
  Antlr3JavaParser parser = new Antlr3JavaParser(tokens);
  List tokenList = tokens.getTokens();
  for (int i = 0; i &lt; tokenList.size(); i++) {
      Token t = (Token) tokenList.get(i);
  }
  </code></pre>