Skip to content

Commit

Permalink
enh: Build on JDK 22
Browse files Browse the repository at this point in the history
  • Loading branch information
lprimak committed Jun 12, 2024
1 parent 77c7c5f commit 6adc508
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
strategy:
matrix:
os: [ 'ubuntu-latest', 'windows-latest', 'macOS-latest' ]
jdk: [ 11, 17, 21 ]
jdk: [ 11, 17, 21, 22 ]
dist: [ 'temurin', 'adopt-openj9', 'zulu' ]
exclude:
# was already built
Expand All @@ -71,6 +71,9 @@ jobs:
# no OpenJ9 21
- dist: adopt-openj9
jdk: 21
# no OpenJ9 22
- dist: adopt-openj9
jdk: 22
fail-fast: false

runs-on: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion .jenkins.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pipeline {
axis {
// https://cwiki.apache.org/confluence/display/INFRA/JDK+Installation+Matrix
name 'MATRIX_JDK'
values 'jdk_11_latest', 'jdk_17_latest', 'jdk_21_latest'
values 'jdk_11_latest', 'jdk_17_latest', 'jdk_21_latest', 'jdk_22_latest'
}
// Additional axes, like OS and maven version can be configured here.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,8 @@ private static void printHelpAndExit(Options options, Exception e, boolean debug
private static char[] readPassword(boolean confirm) throws IOException {
java.io.Console console = System.console();
char[] first;
if (console != null) {
if (isTerminal(console)) {
first = console.readPassword("%s", "Password to hash: ");
//throw new IllegalStateException("java.io.Console is not available on the current JVM. Cannot read passwords.");
} else if (System.in != null) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String readLine = br.readLine();
Expand All @@ -494,7 +493,7 @@ private static char[] readPassword(boolean confirm) throws IOException {
if (first == null || first.length == 0) {
throw new IllegalArgumentException("No password specified.");
}
if (confirm) {
if (confirm && isTerminal(console)) {
char[] second = console.readPassword("%s", "Password to hash (confirm): ");
if (!Arrays.equals(first, second)) {
String msg = "Password entries do not match.";
Expand All @@ -504,6 +503,15 @@ private static char[] readPassword(boolean confirm) throws IOException {
return first;
}

private static boolean isTerminal(java.io.Console console) {
try {
// isTerminal() is only available in Java 22 or later
return console != null && (Boolean) console.getClass().getMethod("isTerminal").invoke(console);
} catch (ReflectiveOperationException e) {
return true;
}
}

private static File toFile(String path) {
String resolved = path;
if (path.startsWith("~/") || path.startsWith(("~\\"))) {
Expand Down

0 comments on commit 6adc508

Please sign in to comment.