locationtech / jts

The JTS Topology Suite is a Java library for creating and manipulating vector geometry.
Other
1.94k stars 441 forks source link

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

Closed jandam closed 5 years ago

jandam commented 5 years ago

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

For example following line https://github.com/locationtech/jts/blob/a8b86cbaafcc4ccd6701116339caf0ad9c13af9c/modules/core/src/main/java/org/locationtech/jts/geom/PrecisionModel.java#L449 should be replaced with: return Integer.compare(sigDigits, otherSigDigits));

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

mprins commented 5 years ago

JTS currently is at Java 8: https://github.com/locationtech/jts/blob/a8b86cbaafcc4ccd6701116339caf0ad9c13af9c/pom.xml#L42-L44

jandam commented 5 years ago

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 commented 5 years ago

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