refactor: prevent casting by setting proper types

This commit is contained in:
Connor Tumbleson 2020-09-13 08:45:30 -04:00
parent 943b424172
commit 6427a28beb
No known key found for this signature in database
GPG Key ID: C3CC0A201EC7DA75

View File

@ -17,6 +17,8 @@
package brut.androlib.mod;
import java.io.*;
import java.nio.charset.StandardCharsets;
import org.antlr.runtime.*;
import org.antlr.runtime.tree.CommonTree;
import org.antlr.runtime.tree.CommonTreeNodeStream;
@ -54,14 +56,14 @@ public class SmaliMod {
boolean printTokens) throws IOException, RecognitionException {
CommonTokenStream tokens;
LexerErrorInterface lexer;
smaliFlexLexer lexer;
InputStream is = new FileInputStream(smaliFile);
InputStreamReader reader = new InputStreamReader(is, "UTF-8");
InputStreamReader reader = new InputStreamReader(is, StandardCharsets.UTF_8);
lexer = new smaliFlexLexer(reader, apiLevel);
((smaliFlexLexer)lexer).setSourceFile(smaliFile);
tokens = new CommonTokenStream((TokenSource) lexer);
(lexer).setSourceFile(smaliFile);
tokens = new CommonTokenStream(lexer);
if (printTokens) {
tokens.getTokens();
@ -88,7 +90,7 @@ public class SmaliMod {
return false;
}
CommonTree t = (CommonTree) result.getTree();
CommonTree t = result.getTree();
CommonTreeNodeStream treeStream = new CommonTreeNodeStream(t);
treeStream.setTokenStream(tokens);