-
Notifications
You must be signed in to change notification settings - Fork 369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix deprecated uses of newInstance() #1887
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment to address, otherwise looks good
final CommandLineProgram program; | ||
try { | ||
program = (CommandLineProgram) Class.forName(programClassname).getDeclaredConstructor().newInstance(); | ||
} catch (InvocationTargetException | NoSuchMethodException e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I replaced that with catch (ReflectiveOperationException e)
and removed a bunch of boilerplate.
@@ -267,7 +274,7 @@ static void assertCRAM(final File outputFile) { | |||
try (InputStream in = new FileInputStream(outputFile)) { | |||
Assert.assertTrue(SamStreams.isCRAMFile(new BufferedInputStream(in)), "File " + outputFile.getAbsolutePath() + " is not a CRAM."); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
throw new RuntimeIOException(e); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also changed this from a silent success to an exception since it seems like it could easily hide errors.
Replace instances of
newInstance()
which is deprecated withgetDeclaredConstructor().newInstance()
which is the drop in replacement.