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

Compat: remove Numeric constructors (java >= 9) #414

Closed
jandam opened this issue Apr 15, 2019 · 3 comments · Fixed by #416
Closed

Compat: remove Numeric constructors (java >= 9) #414

jandam opened this issue Apr 15, 2019 · 3 comments · Fixed by #416

Comments

@jandam
Copy link

jandam commented Apr 15, 2019

Numeric constructors are deprecated since Java 9. They should be replaced with autoboxing or by appropriate parse method.

For example following line

return (new Integer(sigDigits)).compareTo(new Integer(otherSigDigits));

should be replaced with:
return Integer.compare(sigDigits, otherSigDigits));

Same for other types Float/Double/Long...

@mprins
Copy link
Contributor

mprins commented Apr 15, 2019

JTS currently is at Java 8:

jts/pom.xml

Lines 42 to 44 in a8b86cb

<!-- maven compiler target versions -->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>

@jandam
Copy link
Author

jandam commented Apr 15, 2019

Yes JTS is at Java 8. But it is used on newer versions by other projects. Using Integer::compare (since java 1.7) and Integer:parseInt (is even older) avoids creating new instances of Integer. Same for other types Double::compare, Double.parseDouble, ...
Using new Integer() was not good practice. Since java 1.5 should be replaced with static method Integer.valueOf()

@dr-jts
Copy link
Contributor

dr-jts commented Apr 15, 2019

Good point, and seems like a worthwhile fix. PR welcome, or I will fix when I can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants