Skip to content

Commit

Permalink
Remove the unimplemented support for reflection-based errorOccurred m…
Browse files Browse the repository at this point in the history
…ethod in SerialPortEventListener
  • Loading branch information
pietrygamat committed Sep 22, 2021
1 parent dd58baa commit 83237ab
Showing 1 changed file with 0 additions and 28 deletions.
28 changes: 0 additions & 28 deletions src/main/java/jssc/SerialPort.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
package jssc;

import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;

/**
*
Expand All @@ -42,10 +41,6 @@ public class SerialPort {
private boolean maskAssigned = false;
private boolean eventListenerAdded = false;

//since 2.2.0 ->
private volatile Method methodErrorOccurred = null;
//<- since 2.2.0

/** Baud rate 110 symbols/second **/
public static final int BAUDRATE_110 = 110;
/** Baud rate 300 symbols/second **/
Expand Down Expand Up @@ -1094,19 +1089,6 @@ private synchronized void addEventListener(SerialPortEventListener listener, int
eventListener = listener;
eventThread = getNewEventThread();
eventThread.setName("EventThread " + portName);
//since 2.2.0 ->
try {
Method method = eventListener.getClass().getMethod("errorOccurred", new Class<?>[]{SerialPortException.class});
method.setAccessible(true);
methodErrorOccurred = method;
}
catch (SecurityException ex) {
//Do nothing
}
catch (NoSuchMethodException ex) {
//Do nothing
}
//<- since 2.2.0
eventThread.start();
eventListenerAdded = true;
}
Expand Down Expand Up @@ -1154,7 +1136,6 @@ public synchronized boolean removeEventListener() throws SerialPortException {
}
}
}
methodErrorOccurred = null;
eventListenerAdded = false;
return true;
}
Expand Down Expand Up @@ -1192,15 +1173,6 @@ public void run() {
for(int[] event : eventArray){
if(event[0] > 0 && !threadTerminated){
eventListener.serialEvent(new SerialPortEvent(SerialPort.this, event[0], event[1]));
//FIXME
/*if(methodErrorOccurred != null){
try {
methodErrorOccurred.invoke(eventListener, new Object[]{new SerialPortException(SerialPort.this, "method", "exception")});
}
catch (Exception ex) {
System.out.println(ex);
}
}*/
}
}
}
Expand Down

0 comments on commit 83237ab

Please sign in to comment.