Skip to content

Update to Java 17 #560

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 8, 2025
6 changes: 3 additions & 3 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: 11
distribution: 'adopt'
java-version: 17
distribution: 'temurin'
- name: Install Protoc
run: sudo apt install -y protobuf-compiler
- uses: actions/cache@v4
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ jobs:
uses: actions/checkout@v2
with:
submodules: true
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: 11
distribution: 'adopt'
java-version: 17
distribution: 'temurin'
- name: Install Protoc
run: sudo apt install -y protobuf-compiler
- uses: actions/cache@v4
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ jobs:
API_KEY: $HOME/gems
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: 8
distribution: 'adopt'
java-version: 17
distribution: 'temurin'
- name: Install ruby
run: |
sudo apt install -y ruby-full build-essential zlib1g-dev
Expand Down
59 changes: 48 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,13 @@ source ~/.zshrc

### Requirements at Runtime

Since Apache Wayang (incubating) is not an execution engine itself but rather manages the execution engines for you, it is important to have the necessary requirements installed.
Apache Wayang (incubating) relies on external execution engines and Java to function correctly. Below are the updated runtime requirements:

- Apache Wayang supports Java versions 8 and above. However, the Wayang team recommends using Java version 11. Don’t forget to set the `JAVA_HOME` environment variable.
- You need to install Apache Spark version 3 or higher. Don’t forget to set the `SPARK_HOME` environment variable.
- You need to install Apache Hadoop version 3 or higher. Don’t forget to set the `HADOOP_HOME` environment variable.
- **Java 17**: Make sure `JAVA_HOME` is correctly set to your Java 17 installation.
- **Apache Spark 3.4.4**: Compatible with Scala 2.12. Set the `SPARK_HOME` environment variable.
- **Apache Hadoop 3+**: Set the `HADOOP_HOME` environment variable.

> 🛠️ **Note:** When using Java 17, you _must_ add JVM flags to allow Wayang and Spark to access internal Java APIs, or you will encounter `IllegalAccessError`. See below.

### Validating the installation

Expand All @@ -95,6 +97,26 @@ To execute your first application with Apache Wayang, you need to execute your p
bin/wayang-submit org.apache.wayang.apps.wordcount.Main java file://$(pwd)/README.md
```

### ⚙️ Java 17 Compatibility

When running Wayang applications using Java 17 (especially with Spark), you must add JVM flags to open specific internal Java modules. These flags resolve access issues with `sun.nio.ch.DirectBuffer` and others.

Update your `wayang-submit` (wayang-assembly/target/wayang-1.0.1-SNAPSHOT/bin/wayang-submit) script (or command) with:

```bash
eval "$RUNNER \
--add-exports=java.base/sun.nio.ch=ALL-UNNAMED \
--add-opens=java.base/java.nio=ALL-UNNAMED \
--add-opens=java.base/java.lang=ALL-UNNAMED \
--add-opens=java.base/java.util=ALL-UNNAMED \
--add-opens=java.base/java.io=ALL-UNNAMED \
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED \
--add-opens=java.base/java.util.concurrent=ALL-UNNAMED \
--add-opens=java.base/java.net=ALL-UNNAMED \
--add-opens=java.base/java.lang.invoke=ALL-UNNAMED \
$FLAGS -cp \"${WAYANG_CLASSPATH}\" $CLASS ${ARGS}"
```

## Getting Started

Wayang is available via Maven Central. To use it with Maven, include the following code snippet into your POM file:
Expand Down Expand Up @@ -128,15 +150,17 @@ In addition, you can obtain the most recent snapshot version of Wayang via Sonat
```

### Prerequisites
Apache Wayang (incubating) is built with Java 11 and Scala 2.12. However, to run Apache Wayang it is sufficient to have just Java 11 installed. Please also consider that processing platforms employed by Wayang might have further requirements.
Apache Wayang (incubating) is built with Java 17 and Scala 2.12. However, to run Apache Wayang it is sufficient to have just Java 17 installed. Please also consider that processing platforms employed by Wayang might have further requirements.
```
Java 11
[Scala 2.12]
Java 17
Scala 2.12.17
Spark 3.4.4, Compatible with Scala 2.12.
Maven
```

> **NOTE:** In windows, you need to define the variable `HADOOP_HOME` with the winutils.exe, an not official option to obtain [this repository](https://github.com/steveloughran/winutils), or you can generate your winutils.exe following the instructions in the repository. Also, you may need to install [msvcr100.dll](https://www.microsoft.com/en-us/download/details.aspx?id=26999)

> **NOTE:** Make sure that the JAVA_HOME environment variable is set correctly to Java 11 as the prerequisite checker script currently supports up to Java 11 and checks the latest version of Java if you have higher version installed. In Linux, it is preferably to use the export JAVA_HOME method inside the project folder. It is also recommended running './mvnw clean install' before opening the project using IntelliJ.
> **NOTE:** Make sure that the JAVA_HOME environment variable is set correctly to Java 17 as the prerequisite checker script currently supports up to Java 17 and checks the latest version of Java if you have higher version installed. In Linux, it is preferably to use the export JAVA_HOME method inside the project folder. It is also recommended running './mvnw clean install' before opening the project using IntelliJ.


### Building
Expand All @@ -152,11 +176,24 @@ If you need to rebuild Wayang, e.g., to use a different Scala version, you can s
```
> **NOTE:** If you receive an error about not finding `MathExBaseVisitor`, then the problem might be that you are trying to build from IntelliJ, without Maven. MathExBaseVisitor is generated code, and a Maven build should generate it automatically.

> **NOTE:** In the current Maven setup, the version of scala is tied to the Java version, you can compile the profile `scala-11` with Java 8 and profile `scala-12` with Java 11.
> **NOTE:**: In the current Maven setup, Wayang supports Java 17. The default Scala version is 2.12.17, which is compatible with Java 17. Ensure that your Spark distribution is also built with Scala 2.12 (e.g., `spark-3.4.4-bin-hadoop3-scala2.12`).

> **NOTE:** For compiling and testing the code it is required to have Hadoop installed on your machine.

> **NOTE:** the `standalone` profile to fix Hadoop and Spark versions, so that Wayang apps do not explicitly need to declare the corresponding dependencies.

> **NOTE**: When running applications (e.g., WordCount) with Java 17, you must pass additional flags to allow internal module access:

>--add-exports=java.base/sun.nio.ch=ALL-UNNAMED \
--add-opens=java.base/java.nio=ALL-UNNAMED \
--add-opens=java.base/java.lang=ALL-UNNAMED \
--add-opens=java.base/java.util=ALL-UNNAMED \
--add-opens=java.base/java.io=ALL-UNNAMED \
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED \
--add-opens=java.base/java.util.concurrent=ALL-UNNAMED \
--add-opens=java.base/java.net=ALL-UNNAMED \
--add-opens=java.base/java.lang.invoke=ALL-UNNAMED \

>
> Also, note the `distro` profile, which assembles a binary Wayang distribution.
To activate these profiles, you need to specify them when running maven, i.e.,
Expand All @@ -176,8 +213,8 @@ You can see examples on how to start using Wayang [here](guides/wayang-examples.

## Built With

* [Java 11](https://www.oracle.com/de/java/technologies/javase/jdk11-archive-downloads.html)
* [Scala 2.12](https://www.scala-lang.org/download/2.12.0.html)
* [Java 17](https://www.oracle.com/java/technologies/javase/17-0-14-relnotes.html)
* [Scala 2.12.17](https://www.scala-lang.org/download/2.12.17.html)
* [Maven](https://maven.apache.org/)

## Contributing
Expand Down
17 changes: 17 additions & 0 deletions guides/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,23 @@ To execute the WordCount example with Apache Wayang, you need to execute your pr
cd wayang-1.0.1-SNAPSHOT
./bin/wayang-submit org.apache.wayang.apps.wordcount.Main java file://$(pwd)/README.md
```
## If you're using Java 17, add the following JVM flags:
Update your `wayang-submit` (wayang-assembly/target/wayang-1.0.1-SNAPSHOT/bin/wayang-submit) script (or command) with:

```shell
eval "$RUNNER \
--add-exports=java.base/sun.nio.ch=ALL-UNNAMED \
--add-opens=java.base/java.nio=ALL-UNNAMED \
--add-opens=java.base/java.lang=ALL-UNNAMED \
--add-opens=java.base/java.util=ALL-UNNAMED \
--add-opens=java.base/java.io=ALL-UNNAMED \
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED \
--add-opens=java.base/java.util.concurrent=ALL-UNNAMED \
--add-opens=java.base/java.net=ALL-UNNAMED \
--add-opens=java.base/java.lang.invoke=ALL-UNNAMED \
$FLAGS -cp \"${WAYANG_CLASSPATH}\" $CLASS ${ARGS}"
```

Then you should be able to see outputs like this:

![img.png](../images/wordcount_result.png)
80 changes: 47 additions & 33 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,33 +102,33 @@
<!-- Timestamp for the reproducible builds -->
<project.build.outputTimestamp>2025-02-04T20:09:34Z</project.build.outputTimestamp>

<scala.version>2.12.12</scala.version>
<scala.version>2.12.17</scala.version>
<scala.mayor.version>2.12</scala.mayor.version>
<spark.version>3.1.2</spark.version>
<spark.version>3.4.4</spark.version>
<flink.version>1.20.0</flink.version>

<java.version>11</java.version>
<source.level>11</source.level>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>
<java.version>17</java.version>
<source.level>17</source.level>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.release>17</maven.compiler.release>
<jaxb.version>2.2.11</jaxb.version>
<java-activation.version>1.1.1</java-activation.version>
<javax-annotation-api>1.3.2</javax-annotation-api>

<assertj.version>3.17.2</assertj.version>
<commons-io.version>2.5</commons-io.version>
<guava.version>19.0</guava.version>
<hamcrest.version>1.3</hamcrest.version>
<jackson.version>2.10.2</jackson.version>
<jacoco.version>0.8.5</jacoco.version>
<assertj.version>3.25.3</assertj.version>
<commons-io.version>2.15.1</commons-io.version>
<guava.version>32.1.3-jre</guava.version>
<hamcrest.version>2.2</hamcrest.version>
<jackson.version>2.15.4</jackson.version>
<jacoco.version>0.8.9</jacoco.version>
<jodatime.version>2.10.6</jodatime.version>
<jsonpath.version>2.4.0</jsonpath.version>
<junit5.version>5.6.1</junit5.version>
<mockito.version>3.5.10</mockito.version>
<junit5.version>5.10.2</junit5.version>
<mockito.version>5.11.0</mockito.version>
<mockk.version>1.10.0</mockk.version>
<external.platforms.scope>provided</external.platforms.scope>
<hadoop.version>3.1.2</hadoop.version>
<hadoop.version>3.3.6</hadoop.version>
<!-- To be overridden by individual modules -->
<java-module-name>org.apache.wayang.default</java-module-name>
<code.coverage.project.folder>${basedir}/</code.coverage.project.folder>
Expand Down Expand Up @@ -286,16 +286,16 @@

<!-- Used to build Java 11+ -->
<profile>
<id>java11</id>
<id>java17</id>
<activation>
<jdk>11</jdk>
<jdk>17</jdk>
</activation>
<properties>
<java.version>11</java.version>
<source.level>11</source.level>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>
<java.version>17</java.version>
<source.level>17</source.level>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.release>17</maven.compiler.release>
<jaxb.version>2.2.11</jaxb.version>
<java-activation.version>1.1.1</java-activation.version>
<javax-annotation-api>1.3.2</javax-annotation-api>
Expand All @@ -314,7 +314,7 @@
<configuration>
<rules>
<requireJavaVersion>
<version>11</version>
<version>17</version>
</requireJavaVersion>
</rules>
</configuration>
Expand All @@ -325,7 +325,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<source>11</source>
<source>17</source>
<detectJavaApiLink>false</detectJavaApiLink>
</configuration>
</plugin>
Expand Down Expand Up @@ -393,7 +393,7 @@
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>4.8.1</version>
<version>4.9.5</version>
<executions>
<execution>
<id>compile-scala</id>
Expand Down Expand Up @@ -447,9 +447,9 @@
</file>
</activation>
<properties>
<scala.version>2.12.12</scala.version>
<scala.version>2.12.17</scala.version>
<scala.mayor.version>2.12</scala.mayor.version>
<spark.version>3.1.2</spark.version>
<spark.version>3.4.4</spark.version>
</properties>
<build>
<plugins>
Expand Down Expand Up @@ -555,7 +555,7 @@
</file>
</activation>
<properties>
<antlr.version>4.9.1</antlr.version>
<antlr.version>4.13.1</antlr.version>
</properties>
<build>
<pluginManagement>
Expand Down Expand Up @@ -775,7 +775,7 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-bom</artifactId>
<version>2.17.0</version>
<version>2.20.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
Expand Down Expand Up @@ -959,8 +959,22 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
<version>3.0.0</version>
<configuration>
<argLine>
--add-exports=java.base/sun.nio.ch=ALL-UNNAMED
--add-exports=java.base/jdk.internal.misc=ALL-UNNAMED
--add-opens=java.base/java.nio=ALL-UNNAMED
--add-opens=java.base/sun.nio.ch=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.util=ALL-UNNAMED
--add-opens=java.base/java.io=ALL-UNNAMED
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
--add-opens=java.base/sun.reflect.annotation=ALL-UNNAMED
--add-opens=java.base/java.util.concurrent=ALL-UNNAMED
--add-opens=java.base/java.net=ALL-UNNAMED
--add-opens=java.base/java.lang.invoke=ALL-UNNAMED
</argLine>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
Expand Down Expand Up @@ -1242,7 +1256,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0</version>
<version>3.0.0-M3</version>
<executions>
<execution>
<id>enforce-maven-version</id>
Expand All @@ -1263,7 +1277,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.3</version>
<version>0.8.9</version>
<executions>
<execution>
<id>coverage-initialize</id>
Expand Down
2 changes: 1 addition & 1 deletion src/main/script/prerequisiteCheck.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ if (os == "windows") {
// profiles.
/////////////////////////////////////////////////////

checkJavaVersion("1.8", "11")
checkJavaVersion("1.8", "17")

// Check if hadoop is available
// It seems that this is only required on Windows systems.
Expand Down
8 changes: 4 additions & 4 deletions wayang-api/wayang-api-json/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@

<properties>
<java-module-name>org.apache.wayang.api.json</java-module-name>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<encoding>UTF-8</encoding>
<scala.version>2.12.10</scala.version>
<scala.version>2.12.17</scala.version>
<scala.compat.version>2.12</scala.compat.version>
<spec2.version>4.2.0</spec2.version>
</properties>
Expand Down Expand Up @@ -125,7 +125,7 @@
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-scala_2.12</artifactId>
<version>2.13.1</version>
<version>2.15.4</version>
</dependency>


Expand Down
Loading
Loading