Skip to content

Commit

Permalink
Fix Class<?>.newInstance() deprecation warning
Browse files Browse the repository at this point in the history
  • Loading branch information
peace-maker committed Nov 4, 2024
1 parent 01371ec commit bf51204
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@
<version>3.13.0</version>
<configuration>
<release>16</release>
<compilerArgs>
<arg>-Xlint:deprecation</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.schunterkino.kinoapi.sockets;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;

import purejavacomm.CommPort;
import purejavacomm.CommPortIdentifier;
Expand All @@ -25,8 +26,8 @@ public BaseSerialPortClient(String portName, Class<T> typeArgumentClass) {
this.log_tag = typeArgumentClass.getSimpleName();
this.serial = null;
try {
this.commands = typeArgumentClass.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
this.commands = typeArgumentClass.getDeclaredConstructor().newInstance();
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
e.printStackTrace();
}
this.stop = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.schunterkino.kinoapi.sockets;

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
Expand All @@ -27,8 +28,8 @@ public BaseSocketClient(String ip, int port, Class<T> typeArgumentClass) {
this.socket = null;
try {
this.socketAddress = new InetSocketAddress(InetAddress.getByName(ip), port);
this.commands = typeArgumentClass.newInstance();
} catch (InstantiationException | IllegalAccessException | UnknownHostException e) {
this.commands = typeArgumentClass.getDeclaredConstructor().newInstance();
} catch (InstantiationException | IllegalAccessException | UnknownHostException | NoSuchMethodException | InvocationTargetException e) {
e.printStackTrace();
}
this.stop = false;
Expand Down

0 comments on commit bf51204

Please sign in to comment.