diff --git a/builtins/src/main/java/org/jline/builtins/SyntaxHighlighter.java b/builtins/src/main/java/org/jline/builtins/SyntaxHighlighter.java
index 978c53bc9..968040d46 100644
--- a/builtins/src/main/java/org/jline/builtins/SyntaxHighlighter.java
+++ b/builtins/src/main/java/org/jline/builtins/SyntaxHighlighter.java
@@ -10,7 +10,8 @@
import java.io.*;
import java.io.InputStreamReader;
-import java.net.URL;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.nio.file.*;
import java.util.*;
@@ -187,12 +188,12 @@ public static SyntaxHighlighter build(String nanorcUrl) {
if (nanorcUrl.startsWith("classpath:")) {
inputStream = new Source.ResourceSource(nanorcUrl.substring(10), null).read();
} else {
- inputStream = new Source.URLSource(new URL(nanorcUrl), null).read();
+ inputStream = new Source.URLSource(new URI(nanorcUrl).toURL(), null).read();
}
NanorcParser parser = new NanorcParser(inputStream, null, null);
parser.parse();
out.addRules(parser.getHighlightRules());
- } catch (IOException e) {
+ } catch (IOException | URISyntaxException e) {
// ignore
}
return out;
diff --git a/console/src/main/java/org/jline/console/SystemRegistry.java b/console/src/main/java/org/jline/console/SystemRegistry.java
index 63b7f32e6..5abfcf244 100644
--- a/console/src/main/java/org/jline/console/SystemRegistry.java
+++ b/console/src/main/java/org/jline/console/SystemRegistry.java
@@ -187,15 +187,21 @@ protected static Registeries getInstance() {
}
protected void addRegistry(SystemRegistry systemRegistry) {
- systemRegisteries.put(Thread.currentThread().getId(), systemRegistry);
+ systemRegisteries.put(getThreadId(), systemRegistry);
}
protected SystemRegistry getSystemRegistry() {
- return systemRegisteries.getOrDefault(Thread.currentThread().getId(), null);
+ return systemRegisteries.getOrDefault(getThreadId(), null);
}
protected void removeRegistry() {
- systemRegisteries.remove(Thread.currentThread().getId());
+ systemRegisteries.remove(getThreadId());
+ }
+
+ // TODO: Thread.getId() should be replaced with Thread.threadId() when minimum is JDK >= 19
+ @SuppressWarnings("deprecation")
+ private static long getThreadId() {
+ return Thread.currentThread().getId();
}
}
}
diff --git a/console/src/main/java/org/jline/console/impl/ConsoleEngineImpl.java b/console/src/main/java/org/jline/console/impl/ConsoleEngineImpl.java
index f3f8d2682..4293de900 100644
--- a/console/src/main/java/org/jline/console/impl/ConsoleEngineImpl.java
+++ b/console/src/main/java/org/jline/console/impl/ConsoleEngineImpl.java
@@ -1173,7 +1173,7 @@ private Object doc(CommandInput input) {
private boolean urlExists(String weburl) {
try {
- URL url = new URL(weburl);
+ URL url = URI.create(weburl).toURL();
HttpURLConnection huc = (HttpURLConnection) url.openConnection();
huc.setRequestMethod("HEAD");
return huc.getResponseCode() == HttpURLConnection.HTTP_OK;
diff --git a/demo/jline-gogo.bat b/demo/jline-gogo.bat
index d53b8e14b..3acd60ec7 100755
--- a/demo/jline-gogo.bat
+++ b/demo/jline-gogo.bat
@@ -1,87 +1,87 @@
-@echo off
-
-set DIRNAME=%~dp0%
-set ROOTDIR=%DIRNAME%\..
-set TARGETDIR=%DIRNAME%target
-
-rem initialization
-if not exist %TARGETDIR%\lib (
- echo Build jline with maven before running the demo
- goto END
-)
-
-goto :SETUP_CLASSPATH
-
-:APPEND_TO_CLASSPATH
-set filename=%~1
-set cp=%cp%;%TARGETDIR%\lib\%filename%
-goto :EOF
-
-:SETUP_CLASSPATH
-set cp=%TARGETDIR%\classes
-rem JLINE
-pushd %TARGETDIR%\lib
-for %%G in (jline-*.jar) do call:APPEND_TO_CLASSPATH %%G
-rem Gogo Runtime
-for %%G in (org.apache.felix.gogo.runtime-*.jar) do call:APPEND_TO_CLASSPATH %%G
-rem Gogo JLine
-for %%G in (org.apache.felix.gogo.jline-*.jar) do call:APPEND_TO_CLASSPATH %%G
-
-set "opts=%JLINE_OPTS%"
-set "logconf=%DIRNAME%etc\logging.properties"
-:RUN_LOOP
- if "%1" == "jansi" goto :EXECUTE_JANSI
- if "%1" == "jna" goto :EXECUTE_JNA
- if "%1" == "ssh" goto :EXECUTE_SSH
- if "%1" == "debug" goto :EXECUTE_DEBUG
- if "%1" == "debugs" goto :EXECUTE_DEBUGS
- if "%1" == "verbose" goto :EXECUTE_VERBOSE
- if "%1" == "" goto :EXECUTE_MAIN
- set "opts=%opts% %~1"
- shift
- goto :RUN_LOOP
-
-:EXECUTE_JANSI
- for %%G in (jansi-*.jar) do call:APPEND_TO_CLASSPATH %%G
- shift
- goto :RUN_LOOP
-
-:EXECUTE_JNA
- for %%G in (jna-*.jar) do call:APPEND_TO_CLASSPATH %%G
- shift
- goto :RUN_LOOP
-
-:EXECUTE_SSH
- for %%G in (sshd-common-*.jar) do call:APPEND_TO_CLASSPATH %%G
- for %%G in (sshd-core-*.jar) do call:APPEND_TO_CLASSPATH %%G
- for %%G in (sshd-scp-*.jar) do call:APPEND_TO_CLASSPATH %%G
- for %%G in (sshd-sftp-*.jar) do call:APPEND_TO_CLASSPATH %%G
- for %%G in (slf4j-api-*.jar) do call:APPEND_TO_CLASSPATH %%G
- for %%G in (slf4j-jdk14-*.jar) do call:APPEND_TO_CLASSPATH %%G
- shift
- goto :RUN_LOOP
-
-:EXECUTE_DEBUG
- set "opts=%opts% -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005"
- shift
- goto :RUN_LOOP
-
-:EXECUTE_DEBUGS
- set "opts=%opts% -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005"
- shift
- goto :RUN_LOOP
-
-:EXECUTE_VERBOSE
- set "logconf=%DIRNAME%etc\logging-verbose.properties"
- shift
- goto :RUN_LOOP
-
-:EXECUTE_MAIN
-popd
-
-rem Launch gogo shell
-echo Launching Gogo JLine...
-echo Classpath: %cp%
-java -cp %cp% %opts% -Dgosh.home=%DIRNAME% -Djava.util.logging.config.file=%logconf% org.apache.felix.gogo.jline.Main
-
+@echo off
+
+set DIRNAME=%~dp0%
+set ROOTDIR=%DIRNAME%\..
+set TARGETDIR=%DIRNAME%target
+
+rem initialization
+if not exist %TARGETDIR%\lib (
+ echo Build jline with maven before running the demo
+ goto END
+)
+
+goto :SETUP_CLASSPATH
+
+:APPEND_TO_CLASSPATH
+set filename=%~1
+set cp=%cp%;%TARGETDIR%\lib\%filename%
+goto :EOF
+
+:SETUP_CLASSPATH
+set cp=%TARGETDIR%\classes
+rem JLINE
+pushd %TARGETDIR%\lib
+for %%G in (jline-*.jar) do call:APPEND_TO_CLASSPATH %%G
+rem Gogo Runtime
+for %%G in (org.apache.felix.gogo.runtime-*.jar) do call:APPEND_TO_CLASSPATH %%G
+rem Gogo JLine
+for %%G in (org.apache.felix.gogo.jline-*.jar) do call:APPEND_TO_CLASSPATH %%G
+
+set "opts=%JLINE_OPTS%"
+set "logconf=%DIRNAME%etc\logging.properties"
+:RUN_LOOP
+ if "%1" == "jansi" goto :EXECUTE_JANSI
+ if "%1" == "jna" goto :EXECUTE_JNA
+ if "%1" == "ssh" goto :EXECUTE_SSH
+ if "%1" == "debug" goto :EXECUTE_DEBUG
+ if "%1" == "debugs" goto :EXECUTE_DEBUGS
+ if "%1" == "verbose" goto :EXECUTE_VERBOSE
+ if "%1" == "" goto :EXECUTE_MAIN
+ set "opts=%opts% %~1"
+ shift
+ goto :RUN_LOOP
+
+:EXECUTE_JANSI
+ for %%G in (jansi-*.jar) do call:APPEND_TO_CLASSPATH %%G
+ shift
+ goto :RUN_LOOP
+
+:EXECUTE_JNA
+ for %%G in (jna-*.jar) do call:APPEND_TO_CLASSPATH %%G
+ shift
+ goto :RUN_LOOP
+
+:EXECUTE_SSH
+ for %%G in (sshd-common-*.jar) do call:APPEND_TO_CLASSPATH %%G
+ for %%G in (sshd-core-*.jar) do call:APPEND_TO_CLASSPATH %%G
+ for %%G in (sshd-scp-*.jar) do call:APPEND_TO_CLASSPATH %%G
+ for %%G in (sshd-sftp-*.jar) do call:APPEND_TO_CLASSPATH %%G
+ for %%G in (slf4j-api-*.jar) do call:APPEND_TO_CLASSPATH %%G
+ for %%G in (slf4j-jdk14-*.jar) do call:APPEND_TO_CLASSPATH %%G
+ shift
+ goto :RUN_LOOP
+
+:EXECUTE_DEBUG
+ set "opts=%opts% -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005"
+ shift
+ goto :RUN_LOOP
+
+:EXECUTE_DEBUGS
+ set "opts=%opts% -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005"
+ shift
+ goto :RUN_LOOP
+
+:EXECUTE_VERBOSE
+ set "logconf=%DIRNAME%etc\logging-verbose.properties"
+ shift
+ goto :RUN_LOOP
+
+:EXECUTE_MAIN
+popd
+
+rem Launch gogo shell
+echo Launching Gogo JLine...
+echo Classpath: %cp%
+java -cp %cp% %opts% -Dgosh.home=%DIRNAME% -Djava.util.logging.config.file=%logconf% org.apache.felix.gogo.jline.Main
+
:END
\ No newline at end of file
diff --git a/demo/src/main/java/org/apache/felix/gogo/jline/Posix.java b/demo/src/main/java/org/apache/felix/gogo/jline/Posix.java
index 964269c10..7142db2ce 100644
--- a/demo/src/main/java/org/apache/felix/gogo/jline/Posix.java
+++ b/demo/src/main/java/org/apache/felix/gogo/jline/Posix.java
@@ -1907,7 +1907,7 @@ public int compare(String o1, String o2) {
protected Double getDouble(String s, int start, int end) {
Matcher m = fpPattern.matcher(s.substring(start, end));
m.find();
- return new Double(s.substring(0, m.end(1)));
+ return Double.valueOf(s.substring(0, m.end(1)));
}
protected int compareRegion(
diff --git a/native/src/main/java/org/jline/nativ/OSInfo.java b/native/src/main/java/org/jline/nativ/OSInfo.java
index 51e8b8c79..689f5b385 100644
--- a/native/src/main/java/org/jline/nativ/OSInfo.java
+++ b/native/src/main/java/org/jline/nativ/OSInfo.java
@@ -118,14 +118,11 @@ public static boolean isAndroid() {
public static boolean isAlpine() {
try {
- Process p = Runtime.getRuntime().exec("cat /etc/os-release | grep ^ID");
+ Process p = Runtime.getRuntime().exec(new String[] {"cat", "/etc/os-release", "|", "grep", "^ID"});
p.waitFor();
- InputStream in = p.getInputStream();
- try {
+ try (InputStream in = p.getInputStream()) {
return readFully(in).toLowerCase().contains("alpine");
- } finally {
- in.close();
}
} catch (Throwable e) {
@@ -135,14 +132,11 @@ public static boolean isAlpine() {
static String getHardwareName() {
try {
- Process p = Runtime.getRuntime().exec("uname -m");
+ Process p = Runtime.getRuntime().exec(new String[] {"uname", "-m"});
p.waitFor();
- InputStream in = p.getInputStream();
- try {
+ try (InputStream in = p.getInputStream()) {
return readFully(in);
- } finally {
- in.close();
}
} catch (Throwable e) {
System.err.println("Error while running uname -m: " + e.getMessage());
diff --git a/pom.xml b/pom.xml
index 940f40fcc..53cf27d7e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -92,9 +92,9 @@
UTF-8
2023-03-08T19:46:51Z
+ 11
+ 1.8
3.5.0
- 1.8
- 1.8
true
@@ -114,7 +114,7 @@
22.3.0
21.2.0
-
+ --add-opens java.base/java.io=ALL-UNNAMED
@@ -329,17 +329,17 @@
org.apache.maven.plugins
maven-clean-plugin
- 3.2.0
+ 3.3.1
org.apache.maven.plugins
maven-dependency-plugin
- 3.5.0
+ 3.6.0
org.apache.maven.plugins
maven-install-plugin
- 3.1.0
+ 3.1.1
org.apache.maven.plugins
@@ -349,37 +349,37 @@
org.apache.maven.plugins
maven-release-plugin
- 3.0.0-M7
+ 3.0.1
org.apache.maven.plugins
maven-source-plugin
- 3.2.1
+ 3.3.0
org.apache.maven.plugins
maven-resources-plugin
- 3.3.0
+ 3.3.1
org.apache.maven.plugins
maven-site-plugin
- 3.9.1
+ 3.12.1
org.apache.maven.plugins
maven-surefire-plugin
- 3.0.0-M8
+ 3.1.2
org.apache.felix
maven-bundle-plugin
- 5.1.8
+ 5.1.9
org.codehaus.mojo
build-helper-maven-plugin
- 3.3.0
+ 3.4.0
org.graalvm.nativeimage
@@ -389,14 +389,15 @@
org.apache.maven.plugins
maven-enforcer-plugin
- 3.1.0
+ 3.4.1
org.apache.maven.plugins
maven-compiler-plugin
- 3.10.1
+ 3.11.0
true
+ ${java.target.version}
-Xlint:all,-options,-processing
-Werror
@@ -410,7 +411,7 @@
org.apache.maven.plugins
maven-deploy-plugin
- 3.0.0
+ 3.1.1
true
@@ -419,7 +420,7 @@
com.mycila
license-maven-plugin
- 4.2.rc3
+ 4.2
UTF-8
true
@@ -480,7 +481,7 @@
org.apache.maven.plugins
maven-gpg-plugin
- 3.0.1
+ 3.1.0
sign-artifacts
@@ -510,24 +511,24 @@
org.apache.maven.plugins
maven-javadoc-plugin
- 3.4.1
+ 3.5.0
org.apache.maven.plugins
maven-wrapper-plugin
- 3.1.1
+ 3.2.0
com.diffplug.spotless
spotless-maven-plugin
- 2.38.0
+ 2.39.0
- 2.35.0
+ 2.38.0
java|javax,org,,\#
@@ -580,7 +581,7 @@
org.apache.maven.plugins
maven-enforcer-plugin
- 3.1.0
+ 3.4.1
enforce-maven
@@ -592,6 +593,9 @@
${maven.version}
+
+ ${java.build.version}
+
@@ -686,6 +690,11 @@
org.graalvm.nativeimage
native-image-maven-plugin
+
+
+ com.diffplug.spotless
+ spotless-maven-plugin
+
@@ -740,42 +749,6 @@
-
- java9
-
- [9,)
-
-
- --add-opens java.base/java.io=ALL-UNNAMED
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
- 8
-
-
-
-
-
-
-
- java11
-
- [11,)
-
-
-
-
- com.diffplug.spotless
- spotless-maven-plugin
-
-
-
-
-
license-check
diff --git a/remote-telnet/src/main/java/org/jline/builtins/telnet/ConnectionData.java b/remote-telnet/src/main/java/org/jline/builtins/telnet/ConnectionData.java
index 629a62605..96855c355 100644
--- a/remote-telnet/src/main/java/org/jline/builtins/telnet/ConnectionData.java
+++ b/remote-telnet/src/main/java/org/jline/builtins/telnet/ConnectionData.java
@@ -399,19 +399,19 @@ private void setLocale() {
try {
country = country.substring(country.lastIndexOf(".") + 1);
if (country.equals("at")) {
- locale = new Locale("de", "AT");
+ locale = localeOf("de", "AT");
} else if (country.equals("de")) {
- locale = new Locale("de", "DE");
+ locale = localeOf("de", "DE");
} else if (country.equals("mx")) {
- locale = new Locale("es", "MX");
+ locale = localeOf("es", "MX");
} else if (country.equals("es")) {
- locale = new Locale("es", "ES");
+ locale = localeOf("es", "ES");
} else if (country.equals("it")) {
locale = Locale.ITALY;
} else if (country.equals("fr")) {
locale = Locale.FRANCE;
} else if (country.equals("uk")) {
- locale = new Locale("en", "GB");
+ locale = Locale.UK;
} else if (country.equals("arpa")) {
locale = Locale.US;
} else if (country.equals("com")) {
@@ -433,4 +433,11 @@ private void setLocale() {
locale = Locale.ENGLISH;
}
} // setLocale
+
+ // TODO: {@code new Locale(String, String)} should be replaced with {@code Locale.of(String, String)}
+ // TODO: when minimum JDK >= 19
+ @SuppressWarnings("deprecation")
+ private static Locale localeOf(String language, String country) {
+ return new Locale(language, country);
+ }
} // class ConnectionData