Skip to content
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 Java 11 deprecation warnings #6145

Merged
merged 3 commits into from
Sep 17, 2019
Merged

Conversation

tomwhite
Copy link
Contributor

@tomwhite tomwhite commented Sep 9, 2019

Pre-req to testing on Java 11

@tomwhite
Copy link
Contributor Author

#6119 has these changes (and more), but this PR has a set of simple changes that should be easy to merge.

Copy link
Member

@lbergelson lbergelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomwhite I think we can avoid most of the suppressions because they're mostly Class.newInstance which has a replacement in java 8. I thought some of the new Integer calls might be deliberate, but none of them look meaningful on further inspection. Most of them can be just removed entirely though since the compiler will box them if necessary.

@@ -298,6 +298,7 @@ private static boolean printStackTraceOnUserExceptions() {
/**
* Returns the command line program specified, or prints the usage and exits with exit code 1 *
*/
@SuppressWarnings("deprecation")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think most of the deprecation sites can be fixed by replace class.newInstance() with class.getDeclaredConstructor().newInstance() which seems to exist in 8. It means adding additional exceptions to the list of exceptions caught or thrown but I think that's preferable to keeping the deprecated method and suppressing it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In intellij you can use find -> search structurally to find all these sites easily.

Screen Shot 2019-09-13 at 3 25 40 PM

{"-27", new Integer(-27)},
{"0", new Integer(0)},
{"-27014", new Integer(-27014)},
{"27", Integer.valueOf(27)},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking this might have been a deliberate choice, but looking at it closely I don't think so. This seems fine.

}
else if ( annotationsToCheckMaf.get(i).equals(MafOutputRendererConstants.FieldName_End_Position) ) {
mafFieldValues = maf.getRecords().stream().map(AnnotatedInterval::getEnd).map(x -> new Integer(x)).map(Object::toString).collect(Collectors.toList());
mafFieldValues = maf.getRecords().stream().map(AnnotatedInterval::getEnd).map(x -> Integer.valueOf(x)).map(Object::toString).collect(Collectors.toList());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these are unnecessary boxing and could just be removed.

score.addTotalReads(new Integer(tok[7]));
score.addUnambiguousReads(new Integer(tok[8]));
score.setReferenceLength(new Long(tok[9]));
score.addSelfScore(Double.valueOf(tok[5]));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should really be Double.parseDouble instead but it's just a test so it doesn't really matter

@@ -104,7 +104,7 @@ public void testRandomMaskedKmers() {
//Generate random indices to mask
List<Byte> maskIndices = new ArrayList<>(K);
for (int j = 0; j < K; j++) {
maskIndices.add(new Byte((byte) j));
maskIndices.add(Byte.valueOf((byte) j));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can just be autoboxed

@@ -132,7 +132,7 @@ void resizeTest() {
Assert.assertTrue(hopscotchSet.size() == hashSet.size());
LongIterator itrL = hopscotchSet.iterator();
while (itrL.hasNext()) {
Assert.assertTrue(hashSet.contains(new Long(itrL.next())));
Assert.assertTrue(hashSet.contains(Long.valueOf(itrL.next())));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likewise

@lbergelson lbergelson assigned tomwhite and unassigned lbergelson Sep 13, 2019
@tomwhite tomwhite force-pushed the tw_fix_java11_deprecation_warnings branch from 1f5db31 to 3e30784 Compare September 17, 2019 14:04
Copy link
Member

@lbergelson lbergelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Looks good. Merge when tests pass.

@tomwhite tomwhite force-pushed the tw_fix_java11_deprecation_warnings branch from 3e30784 to 2e74072 Compare September 17, 2019 16:36
@tomwhite tomwhite merged commit f499656 into master Sep 17, 2019
@tomwhite tomwhite deleted the tw_fix_java11_deprecation_warnings branch September 17, 2019 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants