Skip to content

Commit be36136

Browse files
Copilotdkayiwa
andauthored
Fix deprecated API usage and update Java source/target to 17 (#99)
* Initial plan * Initial plan Co-authored-by: dkayiwa <1390773+dkayiwa@users.noreply.github.com> * Fix deprecated API usage and update Java source/target to 17 Co-authored-by: dkayiwa <1390773+dkayiwa@users.noreply.github.com> * Rename variable 'Application' to 'applicationClass' for Java naming conventions Co-authored-by: dkayiwa <1390773+dkayiwa@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: dkayiwa <1390773+dkayiwa@users.noreply.github.com>
1 parent 61a5fdf commit be36136

File tree

6 files changed

+19
-16
lines changed

6 files changed

+19
-16
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# maven ignores
22
target/
3+
4+
# Compiled class files
5+
*.class
36
# IntelliJ ignores
47
*.iml
58
*.ipr

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
<properties>
2323

24-
<maven.compiler.source>1.8</maven.compiler.source>
25-
<maven.compiler.target>1.8</maven.compiler.target>
24+
<maven.compiler.source>17</maven.compiler.source>
25+
<maven.compiler.target>17</maven.compiler.target>
2626

2727

2828
<ciel.dictionary.openmrs.version>2.5.5</ciel.dictionary.openmrs.version>
@@ -153,8 +153,8 @@
153153
<artifactId>maven-compiler-plugin</artifactId>
154154
<configuration>
155155
<fork>true</fork>
156-
<source>1.8</source>
157-
<target>1.8</target>
156+
<source>17</source>
157+
<target>17</target>
158158
</configuration>
159159
</plugin>
160160
</plugins>

src/main/java/org/openmrs/standalone/DbInitializer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
public class DbInitializer {
2121
// This is to be called via pom-step-04 with id 'import-demo-sql'
2222
public static void main(String[] args) throws Exception {
23-
Class.forName("org.mariadb.jdbc.Driver").newInstance();
23+
Class.forName("org.mariadb.jdbc.Driver").getDeclaredConstructor().newInstance();
2424

2525
String sqlFilePath = args[0];
2626
String jdbcUrl = args[1];

src/main/java/org/openmrs/standalone/MainFrame.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@
6767
*/
6868
public class MainFrame extends javax.swing.JFrame implements ActionListener, UserInterface {
6969

70+
private static final long serialVersionUID = 1L;
71+
7072
private ApplicationController appController;
7173

7274
private int tomcatPort = UserInterface.DEFAULT_TOMCAT_PORT;
@@ -118,7 +120,7 @@ public void windowClosing(java.awt.event.WindowEvent evt) {
118120

119121
setStatus(UserInterface.STATUS_MESSAGE_STARTING);
120122

121-
int preferredMetaKey = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask();
123+
int preferredMetaKey = Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx();
122124

123125
fileMenu.setText("File");
124126
browserMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, preferredMetaKey));
@@ -298,14 +300,13 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
298300

299301
try{
300302
if (System.getProperty("os.name").startsWith("Mac OS X")) {
301-
Class noparams[] = {}; //no paramater
302-
Class[] paramImage = new Class[1]; //Image parameter
303+
Class<?>[] noparams = {};
304+
Class<?>[] paramImage = new Class<?>[1];
303305
paramImage[0] = Image.class;
304-
Class Application = Class.forName("com.apple.eawt.Application");
305-
Object application = Application.newInstance();
306-
Method getApplication = Application.getDeclaredMethod("getApplication", noparams);
307-
application = getApplication.invoke(null, null);
308-
Method setDockIconImage = Application.getDeclaredMethod("setDockIconImage", paramImage);
306+
Class<?> applicationClass = Class.forName("com.apple.eawt.Application");
307+
Method getApplication = applicationClass.getDeclaredMethod("getApplication", noparams);
308+
Object application = getApplication.invoke(null, (Object[]) null);
309+
Method setDockIconImage = applicationClass.getDeclaredMethod("setDockIconImage", paramImage);
309310
ImageIcon image = new ImageIcon(getClass().getResource("openmrs_logo_white.gif"));
310311
setDockIconImage.invoke(application, image.getImage());
311312
}

src/main/java/org/openmrs/standalone/StandaloneUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ public static String getContextName() {
316316

317317
private static boolean setMysqlPassword(String url, String mysqlPort, String username, String newPassword) throws Exception {
318318
try {
319-
Class.forName("org.mariadb.jdbc.Driver").newInstance();
319+
Class.forName("org.mariadb.jdbc.Driver").getDeclaredConstructor().newInstance();
320320

321321
MariaDbController.startMariaDB(mysqlPort, properties.getProperty("connection.password", ""));
322322

src/main/java/org/openmrs/standalone/TomcatManager.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.net.MalformedURLException;
2121
import java.net.ServerSocket;
2222
import java.net.Socket;
23-
import java.security.AccessControlException;
2423
import java.util.Random;
2524

2625
import ch.vorburger.exec.ManagedProcessException;
@@ -153,7 +152,7 @@ public void await() {
153152
socket.setSoTimeout(10 * 1000); // Ten seconds
154153
stream = socket.getInputStream();
155154
}
156-
catch (AccessControlException ace) {
155+
catch (SecurityException ace) {
157156
System.out.println("TomcatManager.accept security exception: " + ace.getMessage());
158157
continue;
159158
}

0 commit comments

Comments
 (0)