jmockit / jmockit1

Advanced Java library for integration testing, mocking, faking, and code coverage
Other
458 stars 238 forks source link

Add support for Java 11+ #736

Open Col-E opened 1 year ago

Col-E commented 1 year ago

NOTE: The work on this PR and a few others is mirrored on https://github.com/hazendaz/jmockit1/ since it seems like the maintainers of this project are MIA


Encountered some compatibility issues with a project due to outdated bytecode handling. This PR addresses the cases I've encountered personally but should also address the following issues:

Other changes under the hood:

Testing

You can test the validity of the changes within this project by forcing maven to execute the project in a Java 11+ context. I suggest the maven toolchain plugin for this:

Index: main/pom.xml
<+>UTF-8
===================================================================
diff --git a/main/pom.xml b/main/pom.xml
--- a/main/pom.xml  (revision 5c6a2dfc6042ebf8d99770a7e9167bf3c26149e8)
+++ b/main/pom.xml  (date 1665027301503)
@@ -66,10 +66,29 @@
       </resources>
       <plugins>
          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-toolchains-plugin</artifactId>
+            <version>3.1.0</version>
+            <configuration>
+               <toolchains>
+                  <jdk>
+                     <version>11</version>
+                  </jdk>
+               </toolchains>
+            </configuration>
+            <executions>
+               <execution>
+                  <goals>
+                     <goal>toolchain</goal>
+                  </goals>
+               </execution>
+            </executions>
+         </plugin>
+         <plugin>
             <artifactId>maven-compiler-plugin</artifactId><version>3.8.0</version>
             <configuration>
                <encoding>UTF-8</encoding>
-               <source>1.7</source><target>1.7</target>
+               <release>11</release>
                <compilerArgs><arg>-Xlint:none</arg></compilerArgs>
                <useIncrementalCompilation>false</useIncrementalCompilation>
             </configuration>

I tested up to Java 17 with all tests passing.

amosshi commented 1 year ago

HI @rliesenfeld , @idstein , @gliptak

Need your help to review / merge this PR, thanks