diff --git a/easymock.spec b/easymock.spec
index e191890..27a2949 100644
--- a/easymock.spec
+++ b/easymock.spec
@@ -2,7 +2,7 @@
Name: easymock
Version: 4.2
-Release: 4%{?dist}
+Release: 5%{?dist}
Summary: Easy mock objects
License: ASL 2.0
URL: http://www.easymock.org
@@ -103,6 +103,17 @@ rm core/src/test/java/org/easymock/tests2/ClassExtensionHelperTest.java
%pom_xpath_inject "pom:plugin[pom:artifactId='maven-surefire-plugin']" \
"none:none" core
+# Workaround Java 17 compatibility issue that should be fixed in
+# easymock 4.4: https://github.com/easymock/easymock/issues/274
+%pom_xpath_inject "pom:plugin[pom:artifactId='maven-surefire-plugin']/pom:configuration" \
+ "--add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED" core
+%pom_xpath_inject "pom:plugin[pom:artifactId='maven-surefire-plugin']/pom:configuration" \
+ "--add-opens=java.base/java.lang=ALL-UNNAMED" test-testng
+%pom_add_plugin :maven-surefire-plugin test-java8 "
+ --add-opens=java.base/java.lang=ALL-UNNAMED"
+%pom_add_plugin :maven-surefire-plugin test-junit5 "
+ --add-opens=java.base/java.lang=ALL-UNNAMED"
+
%build
%mvn_build
@@ -116,6 +127,9 @@ rm core/src/test/java/org/easymock/tests2/ClassExtensionHelperTest.java
%license core/LICENSE.txt
%changelog
+* Tue Nov 02 2021 Mikolaj Izdebski - 4.2-5
+- Workaround build issue with OpenJDK 17
+
* Wed Jul 21 2021 Fedora Release Engineering - 4.2-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild