NeuronRobotics / nrjavaserial

A Java Serial Port system. This is a fork of the RXTX project that uses in jar loading of the native code.
Other
344 stars 142 forks source link

Add generic type to CommPortIdentifier.getPortIdentifiers() #205

Open MrDOS opened 3 years ago

MrDOS commented 3 years ago

Per the JCA, CommPortIdentifier.getPortIdentifiers() [is declared as](https://docs.oracle.com/cd/E17802_01/products/products/javacomm/reference/api/javax/comm/CommPortIdentifier.html#getPortIdentifiers()):

public static java.util.Enumeration getPortIdentifiers()

...which makes sense, because even JCA 3.0 predates the introduction of generics in Java 1.5. But generics were implemented in a backwards-compatible manner. There should be nothing stopping us from specifying the type of the returned enumeration:

public static java.util.Enumeration<CommPortIdentifier> getPortIdentifiers()

This would make the API considerably easier to consume at no binary compatibility cost.

madhephaestus commented 3 years ago

love it, great idea!