diff --git a/tool/test/org/antlr/v4/test/TestPerformance.java b/tool/test/org/antlr/v4/test/TestPerformance.java index 4efae4e94..25115b918 100644 --- a/tool/test/org/antlr/v4/test/TestPerformance.java +++ b/tool/test/org/antlr/v4/test/TestPerformance.java @@ -441,10 +441,8 @@ public class TestPerformance extends BaseTest { protected ParserFactory getParserFactory(String lexerName, String parserName, String listenerName, final String entryPoint) { try { ClassLoader loader = new URLClassLoader(new URL[] { new File(tmpdir).toURI().toURL() }, ClassLoader.getSystemClassLoader()); - @SuppressWarnings({"unchecked"}) - final Class lexerClass = (Class)loader.loadClass(lexerName); - @SuppressWarnings({"unchecked"}) - final Class parserClass = (Class)loader.loadClass(parserName); + final Class lexerClass = loader.loadClass(lexerName).asSubclass(Lexer.class); + final Class parserClass = loader.loadClass(parserName).asSubclass(Parser.class); @SuppressWarnings({"unchecked"}) final Class> listenerClass = (Class>)loader.loadClass(listenerName); TestPerformance.sharedListener = listenerClass.newInstance();