forked from jasder/antlr
Use Class.asSubclass instead of unchecked cast
This commit is contained in:
parent
1970ac240e
commit
05930b04ce
|
@ -441,10 +441,8 @@ public class TestPerformance extends BaseTest {
|
||||||
protected ParserFactory getParserFactory(String lexerName, String parserName, String listenerName, final String entryPoint) {
|
protected ParserFactory getParserFactory(String lexerName, String parserName, String listenerName, final String entryPoint) {
|
||||||
try {
|
try {
|
||||||
ClassLoader loader = new URLClassLoader(new URL[] { new File(tmpdir).toURI().toURL() }, ClassLoader.getSystemClassLoader());
|
ClassLoader loader = new URLClassLoader(new URL[] { new File(tmpdir).toURI().toURL() }, ClassLoader.getSystemClassLoader());
|
||||||
@SuppressWarnings({"unchecked"})
|
final Class<? extends Lexer> lexerClass = loader.loadClass(lexerName).asSubclass(Lexer.class);
|
||||||
final Class<? extends Lexer> lexerClass = (Class<? extends Lexer>)loader.loadClass(lexerName);
|
final Class<? extends Parser> parserClass = loader.loadClass(parserName).asSubclass(Parser.class);
|
||||||
@SuppressWarnings({"unchecked"})
|
|
||||||
final Class<? extends Parser> parserClass = (Class<? extends Parser>)loader.loadClass(parserName);
|
|
||||||
@SuppressWarnings({"unchecked"})
|
@SuppressWarnings({"unchecked"})
|
||||||
final Class<? extends ParseTreeListener<Token>> listenerClass = (Class<? extends ParseTreeListener<Token>>)loader.loadClass(listenerName);
|
final Class<? extends ParseTreeListener<Token>> listenerClass = (Class<? extends ParseTreeListener<Token>>)loader.loadClass(listenerName);
|
||||||
TestPerformance.sharedListener = listenerClass.newInstance();
|
TestPerformance.sharedListener = listenerClass.newInstance();
|
||||||
|
|
Loading…
Reference in New Issue