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

Some minor fixes/improvements you might want. #129

Open
vharron opened this issue Jan 19, 2020 · 0 comments
Open

Some minor fixes/improvements you might want. #129

vharron opened this issue Jan 19, 2020 · 0 comments

Comments

@vharron
Copy link

vharron commented Jan 19, 2020

We aren't allowed to use raw types, so I've added types to generics where needed. Also a couple other minor fixes.

diff -ur src/jtermios/freebsd/JTermiosImpl.java src/jtermios/freebsd/JTermiosImpl.java
--- src/jtermios/freebsd/JTermiosImpl.java	2020-01-19 09:29:42.277074663 -0800
+++ src/jtermios/freebsd/JTermiosImpl.java	2020-01-19 15:22:06.000000000 -0800
@@ -157,7 +157,7 @@
         public NativeLong tv_usec;
 
         @Override
-        protected List getFieldOrder() {
+        protected List<String> getFieldOrder() {
             return Arrays.asList(//
                     "tv_sec",//
                     "tv_usec"//
@@ -179,7 +179,7 @@
         public short revents;
 
         @Override
-        protected List getFieldOrder() {
+        protected List<String> getFieldOrder() {
             return Arrays.asList(//
                     "fd",//
                     "events",//
@@ -204,7 +204,7 @@
 		public int[] fd_array = new int[(fd_count + NFBBITS - 1) / NFBBITS];
 
 		@Override
-		protected List getFieldOrder() {
+		protected List<String> getFieldOrder() {
 			return Arrays.asList(//
 					"fd_array"//
 			);
@@ -239,7 +239,7 @@
         public int c_ospeed;
 
         @Override
-        protected List getFieldOrder() {
+        protected List<String> getFieldOrder() {
             return Arrays.asList(//
                     "c_iflag",//
                     "c_oflag",//
diff -ur src/jtermios/linux/JTermiosImpl.java src/jtermios/linux/JTermiosImpl.java
--- src/jtermios/linux/JTermiosImpl.java	2020-01-19 09:29:42.281074654 -0800
+++ src/jtermios/linux/JTermiosImpl.java	2020-01-19 15:22:06.000000000 -0800
@@ -197,7 +197,7 @@
         public NativeLong tv_usec;
 
         @Override
-        protected List getFieldOrder() {
+        protected List<String> getFieldOrder() {
             return Arrays.asList(//
                     "tv_sec",//
                     "tv_usec"//
@@ -219,7 +219,7 @@
         public short revents;
 
         @Override
-        protected List getFieldOrder() {
+        protected List<String> getFieldOrder() {
             return Arrays.asList(//
                     "fd",//
                     "events",//
@@ -250,7 +250,7 @@
         }
 
         @Override
-        protected List getFieldOrder() {
+        protected List<String> getFieldOrder() {
             return Arrays.asList(//
                     "fd_array"//
             );
@@ -299,7 +299,7 @@
         public NativeLong iomap_base;
 
         @Override
-        protected List getFieldOrder() {
+        protected List<String> getFieldOrder() {
             return Arrays.asList(//
                     "type",//
                     "line",//
@@ -336,7 +336,7 @@
         public int c_ospeed;
 
         @Override
-        protected List getFieldOrder() {
+        protected List<String> getFieldOrder() {
             return Arrays.asList(//
                     "c_iflag",//
                     "c_oflag",//
diff -ur src/jtermios/macosx/JTermiosImpl.java src/jtermios/macosx/JTermiosImpl.java
--- src/jtermios/macosx/JTermiosImpl.java	2020-01-19 09:29:42.281074654 -0800
+++ src/jtermios/macosx/JTermiosImpl.java	2020-01-19 15:22:06.000000000 -0800
@@ -159,7 +159,7 @@
 		public NativeLong tv_usec;
 
 		@Override
-		protected List getFieldOrder() {
+		protected List<String> getFieldOrder() {
 			return Arrays.asList(//
 					"tv_sec",//
 					"tv_usec"//
@@ -182,7 +182,7 @@
 		public short revents;
 
 		@Override
-		protected List getFieldOrder() {
+		protected List<String> getFieldOrder() {
 			return Arrays.asList(//
 					"fd",//
 					"events",//
@@ -207,7 +207,7 @@
 		public int[] fd_array = new int[(fd_count + NFBBITS - 1) / NFBBITS];
 
 		@Override
-		protected List getFieldOrder() {
+		protected List<String> getFieldOrder() {
 			return Arrays.asList(//
 					"fd_array"//
 			);
@@ -242,7 +242,7 @@
 		public NativeLong c_ospeed;
 
 		@Override
-		protected List getFieldOrder() {
+		protected List<String> getFieldOrder() {
 			return Arrays.asList(//
 					"c_iflag",//
 					"c_oflag",//
diff -ur src/jtermios/solaris/JTermiosImpl.java src/jtermios/solaris/JTermiosImpl.java
--- src/jtermios/solaris/JTermiosImpl.java	2020-01-19 09:29:42.281074654 -0800
+++ src/jtermios/solaris/JTermiosImpl.java	2020-01-19 15:22:06.000000000 -0800
@@ -150,7 +150,7 @@
         public NativeLong tv_usec;
 
         @Override
-        protected List getFieldOrder() {
+        protected List<String> getFieldOrder() {
             return Arrays.asList(//
                     "tv_sec",//
                     "tv_usec"//
@@ -172,7 +172,7 @@
         public short revents;
 
         @Override
-        protected List getFieldOrder() {
+        protected List<String> getFieldOrder() {
             return Arrays.asList(//
                     "fd",//
                     "events",//
@@ -203,7 +203,7 @@
         }
 
         @Override
-        protected List getFieldOrder() {
+        protected List<String> getFieldOrder() {
             return Arrays.asList(//
                     "fd_array"//
             );
@@ -238,7 +238,7 @@
         public byte[] c_cc = new byte[32];
 
         @Override
-        protected List getFieldOrder() {
+        protected List<String> getFieldOrder() {
             return Arrays.asList(//
                     "c_iflag",//
                     "c_oflag",//
diff -ur src/jtermios/windows/JTermiosImpl.java src/jtermios/windows/JTermiosImpl.java
--- src/jtermios/windows/JTermiosImpl.java	2020-01-19 09:29:42.281074654 -0800
+++ src/jtermios/windows/JTermiosImpl.java	2020-01-19 15:22:06.000000000 -0800
@@ -510,8 +510,9 @@
 						}
 						if (!GetOverlappedResult(port.m_Comm, port.m_WrOVL, port.m_WrN, false))
 							port.fail();
-						if (port.m_WrN[0] != port.m_WritePending) // I exptect this is never going to happen, if it does
-							new RuntimeException("Windows OVERLAPPED WriteFile failed to write all, tried to write " + port.m_WritePending + " but got " + port.m_WrN[0]);
+						if (port.m_WrN[0] != port.m_WritePending) { // I exptect this is never going to happen, if it does
+							throw new RuntimeException("Windows OVERLAPPED WriteFile failed to write all, tried to write " + port.m_WritePending + " but got " + port.m_WrN[0]);
+            }
 						break;
 					}
 					port.m_WritePending = 0;
@@ -1047,7 +1048,7 @@
 		java.util.Arrays.fill(p.bits, 0);
 	}
 
-	public int ioctl(int fd, int cmd, int[] arg) {
+	public int ioctl(int fd, int cmd, int... arg) {
 		Port port = getPort(fd);
 		if (port == null)
 			return -1;
@@ -1272,4 +1273,4 @@
 		return -1;
 	}
 
-}
\ No newline at end of file
+}
diff -ur src/jtermios/windows/WinAPI.java src/jtermios/windows/WinAPI.java
--- src/jtermios/windows/WinAPI.java	2020-01-19 09:29:42.281074654 -0800
+++ src/jtermios/windows/WinAPI.java	2020-01-19 15:22:06.000000000 -0800
@@ -447,7 +447,7 @@
 		public HANDLE hEvent;
 
 		@Override
-		protected List getFieldOrder() {
+		protected List<String> getFieldOrder() {
 			return Arrays.asList("Internal",//
 					"InternalHigh",//
 					"Offset",//
@@ -473,7 +473,7 @@
 		public boolean bInheritHandle;
 
 		@Override
-		protected List getFieldOrder() {
+		protected List<String> getFieldOrder() {
 			return Arrays.asList("nLength",//
 					"lpSecurityDescriptor",//
 					"bInheritHandle"//
@@ -513,7 +513,7 @@
 		public short wReserved1;
 
 		@Override
-		protected List getFieldOrder() {
+		protected List<String> getFieldOrder() {
 			return Arrays.asList("DCBlength",//
 					"BaudRate",//
 					"fFlags",//
@@ -548,7 +548,7 @@
 		public int WriteTotalTimeoutConstant;
 
 		@Override
-		protected List getFieldOrder() {
+		protected List<String> getFieldOrder() {
 			return Arrays.asList("ReadIntervalTimeout",//
 					"ReadTotalTimeoutMultiplier",//
 					"ReadTotalTimeoutConstant",//
@@ -579,7 +579,7 @@
 		public int cbOutQue;
 
 		@Override
-		protected List getFieldOrder() {
+		protected List<String> getFieldOrder() {
 			return Arrays.asList("fFlags",//
 					"cbInQue",//
 					"cbOutQue"//
diff -ur src/purejavacomm/CommPortIdentifier.java src/purejavacomm/CommPortIdentifier.java
--- src/purejavacomm/CommPortIdentifier.java	2020-01-19 09:29:42.281074654 -0800
+++ src/purejavacomm/CommPortIdentifier.java	2020-01-19 15:22:06.000000000 -0800
@@ -86,7 +86,7 @@
 				if (portid.getName().equals(portName))
 					return portid;
 			if (ENUMERATE) { // enumerating ports takes time, lets see if we can avoid it
-				Enumeration e = getPortIdentifiers();
+				Enumeration<CommPortIdentifier> e = getPortIdentifiers();
 				while (e.hasMoreElements()) {
 					CommPortIdentifier portid = (CommPortIdentifier) e.nextElement();
 					if (portid.getName().equals(portName))
@@ -190,7 +190,7 @@
 	public static Enumeration<CommPortIdentifier> getPortIdentifiers() {
 		synchronized (m_Mutex) {
 
-			return new Enumeration() {
+			return new Enumeration<CommPortIdentifier>() {
 				List<CommPortIdentifier> m_PortIDs;
 				{ // insert the  'addPortName' ports to the dynamic port list
 					m_PortIDs = new LinkedList<CommPortIdentifier>();
@@ -208,7 +208,7 @@
 					return m_Iterator != null ? m_Iterator.hasNext() : false;
 				}
 
-				public Object nextElement() {
+				public CommPortIdentifier nextElement() {
 					return m_Iterator.next();
 				};
 			};
diff -ur src/purejavacomm/testsuite/PureJavaCommDemo.java src/purejavacomm/testsuite/PureJavaCommDemo.java
--- src/purejavacomm/testsuite/PureJavaCommDemo.java	2020-01-19 09:29:42.281074654 -0800
+++ src/purejavacomm/testsuite/PureJavaCommDemo.java	2020-01-19 15:22:24.000000000 -0800
@@ -43,7 +43,7 @@
 		try {
 			System.out.println("PureJavaCommDemo");
 			CommPortIdentifier portid = null;
-			Enumeration e = CommPortIdentifier.getPortIdentifiers();
+			Enumeration<CommPortIdentifier> e = CommPortIdentifier.getPortIdentifiers();
 			while (e.hasMoreElements()) {
 				portid = (CommPortIdentifier) e.nextElement();
 				System.out.println("found " + portid.getName());
--- README.md   2020-01-19 09:29:42.233074768 -0800
+++ README.md   2020-01-19 15:58:47.000000000 -0800
@@ -2,7 +2,7 @@
 [![Javadocs](https://www.javadoc.io/badge/com.github.purejavacomm/purejavacomm.svg)](https://www.javadoc.io/doc/com.github.purejavacomm/purejavacomm)


-PureJavaComm is an Application Programmin Interface (API) for accessing serial ports from Java, so this is a library aimed at programmers, not end users.
+PureJavaComm is an Application Programming Interface (API) for accessing serial ports from Java, so this is a library aimed at programmers, not end users.

 PureJavaComm aims to be a drop-in replacement for Sun's (now Oracle) abandoned JavaComm and an easier to deploy alternative to RXTX.

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

No branches or pull requests

1 participant