Will be using a wiremock-jre-8 dependency within a java 11 project an issue?

Sorry in advance if this is a stupid question, but my research to clarify this was not as successful as i needed it to be. I am working on a project using jdk 11 and in order get decent testcoverage, i added something to mock calls/answers to/from external services. So i included wiremock. As suggested

Disclamer

Sorry in advance if this is a stupid question, but my research to clarify this was not as successful as i needed it to be.

Problem description

I am working on a project using jdk 11 and in order get decent testcoverage, i added something to mock calls/answers to/from external services. So i included wiremock. As suggested on their setup getting-started section, i included

testImplementation "com.github.tomakehurst:wiremock-jre8:2.34.0" 

Even though everything works on my machine (and tests run fine on the pipeline), i don't know if this will potentially cause issues on other machines. The architect involved in the project also stated his concern that we do only use jre 11.

Therefore i need some more insight to either change things up or argue why this is not an issue.

Attempts so far

I expected there to be an higher version of wiremock on mavencentral, but ther were only two projects:

To my surprise, wiremock-jre8 was the most recent version. I don't know what the older version was compiled with but i was using annotations that wouldn't work with the 2020 version either way. So it would be nice to not downgrade the current implementation to a less readable solution.

I should mention, that i only guess that wiremock-jre8 has been compiled with jdk8 from the naming. I did not find any evidence about what compiler did produce the bytecode for either of those dependencies or clues on how to interpret this.

When trying to figure out how back and forwards combability works with java, the compiler and the produced bytecode, i found this older post. In short it states:

Compatibility from the point of view of javac (as it is the part specific to the JDK), meaning that the bytecode generated can be run in future releases of the jvm (that is more related to the JRE, but also bundled in the JDK).

  • JDK's are (usually) forward compatible.
  • JRE's are (usually) backward compatible.

I do understand that in parts, but not fully concerning my issue. Especially the "usually" part. So are there some more insights someone has to spare to enlighten me? :)

2 Answers

The Download and Installation section of their documentation contains this sentence:

Additionally, versions of these JARs are distributed for both Java 7 and Java 8+.

So if you are still running Java 1.7 you must use the version for Java 7.

For all later versions of Java there is the version for Java 8+ (the version that you use.)

Since this is an actively supported project any problems related to Java versions later than Java 8 will be properly addressed and resolved (see for example Build on & fully support JDK 17 which was resolved in "com.github.tomakehurst:wiremock-jre8:2.32.0").

There is actually one issue you could run into if you use Java 9 modules.

wiremock-jre8-standalone has some classes in a javax.annnotations package which can cause a split package error when you also require the official javax.annotations.

I ran into the issue when using wiremock-spring-boot and resolved the issue by excluding the wiremock-jre8-standalone and adding the newer wiremock-standalone

 <!-- https://mvnrepository.com/artifact/com.github.tomakehurst/wiremock --> <dependency> <groupId>com.maciejwalkowiak.spring</groupId> <artifactId>wiremock-spring-boot</artifactId> <version>1.0.1</version> <exclusions> <exclusion> <groupId>com.github.tomakehurst</groupId> <artifactId>wiremock-jre8-standalone</artifactId> </exclusion> </exclusions> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/com.github.tomakehurst/wiremock-standalone --> <dependency> <groupId>com.github.tomakehurst</groupId> <artifactId>wiremock-standalone</artifactId> <version>3.0.1</version> <scope>test</scope> </dependency> 

ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobm1qZmWBdISOsKClpF2Xsm7B0qKloGWRYsSqvsSmppyjXZ%2B%2FpnmXZpueqJWjsaa6wrJksKGknbavecBmoZqukWJ%2BcnnPq6ajnZOpeqK6jKKqrK2V

 Share!