Skip to content

Commit

Permalink
Update to JDK21 - both JDK and language level (#10528)
Browse files Browse the repository at this point in the history
* Update to JDK21 - both JDK and language level

* Fix dependency for "Task :generateJournalListMV"

* Update modernizer

* Replace mssing env.JDK21

* Replace Stack by Deque

* One more replacement

* Introduce unique variables

* compare with stack

* reverse order

* fix bug from olly

* improve javadoc

* remove leftover

* Fix comment

* Add line break

* Rename variable

---------

Co-authored-by: Siedlerchr <[email protected]>
  • Loading branch information
koppor and Siedlerchr authored Oct 20, 2023
1 parent 3670ef6 commit cbf99ec
Show file tree
Hide file tree
Showing 22 changed files with 89 additions and 139 deletions.
4 changes: 2 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
// Install java.
// See https://github.com/devcontainers/features/tree/main/src/java#options for details.
"ghcr.io/devcontainers/features/java:1": {
"version": "20.0.2-tem",
"version": "21.0.1-librca",
"installGradle": false,
"jdkDistro": "tem"
"jdkDistro": "librca"
}
}
}
26 changes: 6 additions & 20 deletions .github/workflows/deployment-arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,9 @@ jobs:
- name: Setup JDK
uses: actions/setup-java@v3
with:
java-version: 20
distribution: 'temurin'
java-version: 21.0.1
distribution: 'liberica'
cache: 'gradle'
- name: Setup JDK jabref-fix macOS
shell: bash
run: |
mkdir ${{runner.temp}}/jdk
wget -qO- https://files.jabref.org/jdks/jdk-macos-aarch64.tar.gz | tar xz -C ${{runner.temp}}/jdk
mv ${{runner.temp}}/jdk/jdk-21.jdk ${{runner.temp}}/jdk/jdk-21
echo "JDK21=${{runner.temp}}/jdk/jdk-21" >> "$GITHUB_ENV"
ls ${{runner.temp}}/jdk
echo "org.gradle.java.installations.paths=${{runner.temp}}/jdk/jdk-21" >> gradle.properties
echo "org.gradle.java.installations.auto-detect=false" >> gradle.properties
cat gradle.properties
sed -i'.bak' -e "s/JavaLanguageVersion.of(20)/JavaLanguageVersion.of(21)/" build.gradle
- name: Clean up keychain
run: |
security delete-keychain signing_temp.keychain ${{runner.temp}}/keychain/notarization.keychain || true
Expand All @@ -104,9 +90,9 @@ jobs:
- name: Build dmg (macOS)
shell: bash
run: |
${{env.JDK21}}/Contents/Home/bin/jpackage \
jpackage \
--module org.jabref/org.jabref.cli.Launcher \
--module-path ${{env.JDK21}}/Contents/Home/jmods/:build/jlinkbase/jlinkjars \
--module-path ${{env.JAVA_HOME}}/jmods/:build/jlinkbase/jlinkjars \
--add-modules org.jabref,org.jabref.merged.module \
--dest build/distribution \
--app-content buildres/mac/jabrefHost.py \
Expand All @@ -128,9 +114,9 @@ jobs:
- name: Build pkg (macOS)
shell: bash
run: |
${{env.JDK21}}/Contents/Home/bin/jpackage \
jpackage \
--module org.jabref/org.jabref.cli.Launcher \
--module-path ${{env.JDK21}}/Contents/Home/jmods/:build/jlinkbase/jlinkjars \
--module-path ${{env.JAVA_HOME}}/jmods/:build/jlinkbase/jlinkjars \
--add-modules org.jabref,org.jabref.merged.module \
--dest build/distribution \
--app-content buildres/mac/jabrefHost.py \
Expand Down
55 changes: 6 additions & 49 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,52 +92,9 @@ jobs:
- name: Setup JDK
uses: actions/setup-java@v3
with:
java-version: 20
distribution: 'temurin'
java-version: 21.0.1
distribution: 'liberica'
cache: 'gradle'
- name: Setup JDK jabref-fix (Windows)
if: (matrix.os == 'windows-latest')
shell: bash
run: |
mkdir ${{runner.temp}}\jdk
curl -kLsS ${{matrix.eaJDK}} -o temp.zip && 7z x temp.zip -o"$(cygpath -u "$RUNNER_TEMP\jdk")"
echo "JDK21=${{runner.temp}}\jdk\jdk-21" >> "$GITHUB_ENV"
ls "$(cygpath -u "$RUNNER_TEMP\jdk\jdk-21")"
echo "org.gradle.java.installations.paths=${{runner.temp}}\jdk\jdk-21" | sed "s/\\\\/\\\\\\\\/g" >> gradle.properties
echo "org.gradle.java.installations.auto-detect=false" >> gradle.properties
cat gradle.properties
sed -i "s/JavaLanguageVersion.of(20)/JavaLanguageVersion.of(21)/" build.gradle
- name: Setup JDK jabref-fix (linux)
if: (matrix.os == 'ubuntu-latest')
shell: bash
run: |
mkdir ${{runner.temp}}/jdk
wget -qO- ${{matrix.eaJDK}} | tar xz -C ${{runner.temp}}/jdk
echo "JDK21=${{runner.temp}}/jdk/jdk-21" >> "$GITHUB_ENV"
ls ${{runner.temp}}/jdk
echo "org.gradle.java.installations.paths=${{runner.temp}}/jdk/jdk-21" >> gradle.properties
echo "org.gradle.java.installations.auto-detect=false" >> gradle.properties
cat gradle.properties
sed -i "s/JavaLanguageVersion.of(20)/JavaLanguageVersion.of(21)/" build.gradle
- name: Setup JDK jabref-fix (macOS)
if: (matrix.os == 'macos-latest')
shell: bash
run: |
mkdir ${{runner.temp}}/jdk
wget -qO- ${{matrix.eaJDK}} | tar xz -C ${{runner.temp}}/jdk
mv ${{runner.temp}}/jdk/jdk-21.jdk ${{runner.temp}}/jdk/jdk-21
echo "JDK21=${{runner.temp}}/jdk/jdk-21" >> "$GITHUB_ENV"
ls ${{runner.temp}}/jdk
echo "org.gradle.java.installations.paths=${{runner.temp}}/jdk/jdk-21" >> gradle.properties
echo "org.gradle.java.installations.auto-detect=false" >> gradle.properties
cat gradle.properties
sed -i'.bak' -e "s/JavaLanguageVersion.of(20)/JavaLanguageVersion.of(21)/" build.gradle
- name: Prepare merged jars and modules dir (macOS)
if: (matrix.os == 'macos-latest') || (steps.checksecrets.outputs.secretspresent == 'NO')
run: ./gradlew -i -PprojVersion="${{ steps.gitversion.outputs.AssemblySemVer }}" -PprojVersionInfo="${{ steps.gitversion.outputs.InformationalVersion }}" prepareModulesDir
Expand All @@ -160,9 +117,9 @@ jobs:
if: (matrix.os == 'macos-latest') && (steps.checksecrets.outputs.secretspresent == 'YES')
shell: bash
run: |
${{env.JDK21}}/Contents/Home/bin/jpackage \
jpackage \
--module org.jabref/org.jabref.cli.Launcher \
--module-path ${{env.JDK21}}/Contents/Home/jmods/:build/jlinkbase/jlinkjars \
--module-path ${{env.JAVA_HOME}}/jmods/:build/jlinkbase/jlinkjars \
--add-modules org.jabref,org.jabref.merged.module \
--dest build/distribution \
--app-content buildres/mac/jabrefHost.py \
Expand All @@ -185,9 +142,9 @@ jobs:
if: (matrix.os == 'macos-latest') && (steps.checksecrets.outputs.secretspresent == 'YES')
shell: bash
run: |
${{env.JDK21}}/Contents/Home/bin/jpackage \
jpackage \
--module org.jabref/org.jabref.cli.Launcher \
--module-path ${{env.JDK21}}/Contents/Home/jmods/:build/jlinkbase/jlinkjars \
--module-path ${{env.JAVA_HOME}}/jmods/:build/jlinkbase/jlinkjars \
--add-modules org.jabref,org.jabref.merged.module \
--dest build/distribution \
--app-content buildres/mac/jabrefHost.py \
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/refresh-journal-lists.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 20
distribution: 'temurin'
java-version: 21.0.1
distribution: 'liberica'
cache: 'gradle'
- name: Check whether journal-list.mv can be generated (the "real" generation is done inside JabRef's build process)
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests-fetchers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 20
distribution: 'temurin'
java-version: 21.0.1
distribution: 'liberica'
cache: 'gradle'
- name: Run fetcher tests
run: ./gradlew fetcherTest
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ jobs:
- name: Checkout source
uses: actions/checkout@v4
with:
submodules: 'false'
submodules: 'true'
show-progress: 'false'
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 20
distribution: 'temurin'
java-version: 21.0.1
distribution: 'liberica'
cache: 'gradle'
- name: Run checkstyle reporter
uses: nikitasavinov/checkstyle-action@master
Expand Down Expand Up @@ -103,8 +103,8 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 20
distribution: 'temurin'
java-version: 21.0.1
distribution: 'liberica'
cache: 'gradle'
- name: Run tests
run: xvfb-run --auto-servernum ./gradlew check -x checkstyleJmh -x checkstyleMain -x checkstyleTest -x modernizer
Expand Down Expand Up @@ -138,8 +138,8 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 20
distribution: 'temurin'
java-version: 21.0.1
distribution: 'liberica'
cache: 'gradle'
- name: Run tests on PostgreSQL
run: ./gradlew databaseTest --rerun-tasks
Expand Down Expand Up @@ -175,8 +175,8 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 20
distribution: 'temurin'
java-version: 21.0.1
distribution: 'liberica'
cache: 'gradle'
- name: Run GUI tests
run: xvfb-run --auto-servernum ./gradlew guiTest
Expand Down Expand Up @@ -216,8 +216,8 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 20
distribution: 'temurin'
java-version: 21.0.1
distribution: 'liberica'
cache: 'gradle'
- name: Update test coverage metrics
if: steps.checksecrets.outputs.secretspresent == 'YES'
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import org.jabref.build.xjc.XjcTask
plugins {
id 'application'

id 'com.github.andygoossens.modernizer' version '1.8.0'
id 'com.github.andygoossens.modernizer' version '1.9.0'

id 'me.champeau.jmh' version '0.7.1'

Expand Down Expand Up @@ -41,15 +41,15 @@ group = "org.jabref"
version = project.findProperty('projVersion') ?: '100.0.0'

java {
sourceCompatibility = JavaVersion.VERSION_19
targetCompatibility = JavaVersion.VERSION_19
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
// Workaround needed for Eclipse, probably because of https://github.com/gradle/gradle/issues/16922
// Should be removed as soon as Gradle 7.0.1 is released ( https://github.com/gradle/gradle/issues/16922#issuecomment-828217060 )
modularity.inferModulePath.set(false)

toolchain {
// If this is updated, also update .devcontainer/devcontainer.json#L34
languageVersion = JavaLanguageVersion.of(20)
languageVersion = JavaLanguageVersion.of(21)
}
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ nav_order: 12

# Step 2: Setup the build system: JDK and Gradle

## Ensure that JDK 20 is available to IntelliJ
## Ensure that JDK 21 is available to IntelliJ

Ensure you have a Java 20 SDK configured by navigating to **File > Project Structure... > Platform Settings > SDKs**.
Ensure you have a Java 21 SDK configured by navigating to **File > Project Structure... > Platform Settings > SDKs**.

{% figure caption:"JDKs 11, 14, and 15 shown in available SDKs. JDK 20 is missing." %}
{% figure caption:"JDKs 11, 14, and 15 shown in available SDKs. JDK 21 is missing." %}
![Plattform Settings - SDKs](intellij-choose-jdk-adoptopenjdk-on-windows-project-settings.png)
{% endfigure %}

If there is another JDK than JDK 20 selected, click on the plus button and choose "Download JDK..."
If there is another JDK than JDK 21 selected, click on the plus button and choose "Download JDK..."

{% figure caption:"Download JDK..." %}
![Plattform Settings - SDKs - plus button - Download JDK...](guidelines-select-download-jdk.png)
{% endfigure %}

Select JDK version 20 and then Eclipse Temurin (showing JDK 18 as example).
Select JDK version 21 and then Eclipse Temurin.

{% figure caption:"Example for JDK 18 - Choose Eclipse Temurin" %}
![Download Eclipse Temurin](guidelines-select-jdk-18-eclipse-temurin.png)
{% figure caption:"Example for JDK 21 - Choose Eclipse Temurin" %}
![Download Eclipse Temurin](guidelines-intellij-select-jdk-eclipse-temurin.png)
{% endfigure %}

After clicking "Download", IntelliJ installs Eclipse Temurin:
Expand All @@ -32,20 +32,26 @@ After clicking "Download", IntelliJ installs Eclipse Temurin:
![IntelliJ installs Eclipse Temurin](guidelines-intellij-installs-temurin.png)
{% endfigure %}

Navigate to **Project Settings > Project** and ensure that the projects' SDK is Java 20
Open the module settings: Right click on "JabRef" and select "Open Module Settings":

{% figure caption:"Project SDK is pinned to the downloaded SDK (showing JDK 18 as example)" %}
![Project SDK is JDK 18](guidelines-intellij-project-settings-jdk18.png)
{% figure caption:"Open IntelliJ Module Settings" %}
![IntelliJ Module Settings](guidelines-intellij-open-module-settings.png)
{% endfigure %}

Navigate to **Project Settings > Project** and ensure that the projects' SDK is Java 21.

{% figure caption:"Project SDK is pinned to the downloaded SDK (showing JDK 21 as example)" %}
![Project SDK is JDK 21](guidelines-intellij-project-settings-jdk.png)
{% endfigure %}

Click "OK" to store the changes.

## Configure the Build System

Navigate to **File > Settings... > Build, Execution, Deployment > Build Tools > Gradle** and select the "Project SDK" as the Gradle JVM at the bottom. If that does not exist, just select a JDK 20.
Navigate to **File > Settings... > Build, Execution, Deployment > Build Tools > Gradle** and select the "Project SDK" as the Gradle JVM at the bottom. If that does not exist, just select a JDK 21.

{% figure caption:"Gradle JVM is project SDK (showing JDK 18 as example)" %}
![Gradle JVM is project SDK](guidelines-settings-gradle-gradlejvm-is-projectjvm.png)
{% figure caption:"Gradle JVM is project SDK (showing JDK 21 as example)" %}
![Gradle JVM is project SDK](guidelines-intellij-settings-gradle-gradlejvm-is-projectjvm.png)
{% endfigure %}

To prepare IntelliJ's build system additional steps are required:
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/jabref/logic/bst/BstFunctions.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.jabref.logic.bst;

import java.util.Deque;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand All @@ -30,7 +30,7 @@ public class BstFunctions {
private final Map<String, BstFunction> functions;
private final String preamble;

private final Stack<Object> stack;
private final Deque<Object> stack;
private final StringBuilder bbl;

private int bstWarning = 0;
Expand Down Expand Up @@ -670,7 +670,7 @@ private void bstSkip(BstVMVisitor visitor, ParserRuleContext ctx) {
* designers while debugging.
*/
private void bstStack(BstVMVisitor visitor, ParserRuleContext ctx) {
while (!stack.empty()) {
while (!stack.isEmpty()) {
LOGGER.debug("Stack entry {}", stack.pop());
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/jabref/logic/bst/BstVM.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Deque;
import java.util.List;
import java.util.Objects;
import java.util.Stack;

import org.jabref.model.database.BibDatabase;
import org.jabref.model.entry.BibEntry;
Expand Down Expand Up @@ -93,7 +93,7 @@ public String render(Collection<BibEntry> bibEntries) {
return render(bibEntries, null);
}

protected Stack<Object> getStack() {
protected Deque<Object> getStack() {
if (latestContext != null) {
return latestContext.stack();
} else {
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/org/jabref/logic/bst/BstVMContext.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
package org.jabref.logic.bst;

import java.nio.file.Path;
import java.util.Deque;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Stack;

import org.jabref.model.database.BibDatabase;

public record BstVMContext(List<BstEntry> entries,
Map<String, String> strings,
Map<String, Integer> integers,
Map<String, BstFunctions.BstFunction> functions,
Stack<Object> stack,
Deque<Object> stack,
BibDatabase bibDatabase,
Optional<Path> path) {
public BstVMContext(List<BstEntry> entries, BibDatabase bibDatabase, Path path) {
this(entries, new HashMap<>(), new HashMap<>(), new HashMap<>(), new Stack<>(), bibDatabase, Optional.ofNullable(path));
// LinkedList instead of ArrayDeque, because we (currently) need null support
this(entries, new HashMap<>(), new HashMap<>(), new HashMap<>(), new LinkedList<>(), bibDatabase, Optional.ofNullable(path));
}
}
Loading

0 comments on commit cbf99ec

Please sign in to comment.