Add support for Java 11+
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:
- https://github.com/jacoco/jacoco/issues/896 (Some of the changes are based on the artifact
com.github.hazendaz.jmockit:jmockit:1.49.2which is mentioned in the thread though I could not find @hazendaz hosting the source currently) - #729
Other changes under the hood:
- Change bytecode handling to explicitly fail rather than assume a type in switch cases (Assisted in debugging, and failing makes the cause more clear than undefined behavior caused by ignoring the issue with fallback behavior)
- Use full names instead of shorthand for constants (minor legibility improvement)
- Use objenesis instead of direct sun reflection-factory for instance creation
- Remove junit platform exclusion in
pom.xml, resolving some failures with IntelliJ integration
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.
HI @rliesenfeld , @idstein , @gliptak
Need your help to review / merge this PR, thanks