From 83237ab1a3d71ce5a66b5de3caae8c110f01b794 Mon Sep 17 00:00:00 2001 From: Mateusz Pietryga Date: Thu, 23 Sep 2021 00:22:31 +0200 Subject: [PATCH] Remove the unimplemented support for reflection-based errorOccurred method in SerialPortEventListener --- src/main/java/jssc/SerialPort.java | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/src/main/java/jssc/SerialPort.java b/src/main/java/jssc/SerialPort.java index 14f9acc9e..86b92c806 100644 --- a/src/main/java/jssc/SerialPort.java +++ b/src/main/java/jssc/SerialPort.java @@ -25,7 +25,6 @@ package jssc; import java.io.UnsupportedEncodingException; -import java.lang.reflect.Method; /** * @@ -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 **/ @@ -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; } @@ -1154,7 +1136,6 @@ public synchronized boolean removeEventListener() throws SerialPortException { } } } - methodErrorOccurred = null; eventListenerAdded = false; return true; } @@ -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); - } - }*/ } } }