-
Notifications
You must be signed in to change notification settings - Fork 17
Description
We are trying to migrate from 4.4.1 to 4.5.0, which is supposed to be able to process some new java features, like records for example.
We are using gradle in our project, with clovers plugin:
dependencies { classpath "org.openclover:clover:4.4.1" // 4.5.0 }
Which works, but bumping to 4.5.0, clover stops working.
We have the standard gradle tasks, as is suggested at https://openclover.org/doc/manual/4.2.0/gradle--gradle-clover-plugin.html.
Running the clover instrumentation, we get an error:
ERROR: full/path/to/class/SomeClass.java:52:5:unexpected token: Optional
ERROR: Instrumentation error
full/path/to/class/SomeClass.java:52:5:unexpected token: Optional
Instrumentation error
The source code does indeed use an Optional in that line.
More info:
When running instrumentation, in clover 4.4.1, the source level was set to 1.9:
build 10-Oct-2023 09:11:12 Processing files at 1.9 source level.
However, using clover 4.5.0, we now get:
build 10-Oct-2023 09:15:39 > Task :cloverInstr
build 10-Oct-2023 09:15:39 OpenClover Version 4.5.0, built on 2023-10-04
build 10-Oct-2023 09:15:39 Creating new database at 'path\to\db\clover.db'.
build 10-Oct-2023 09:15:39 Processing files at JAVA_7 source level.
This seems strange to me, so I tried tricking clover to set the value back to 1.9, or at least JAVA_11 (max supported in 4.5.0).
task cloverInst(...) {
...
// also tried adding to argsList: [..."--source", "9"]
// right before calling CloverInstr.mainImpl !
com.atlassian.clover.cfg.instr.java.SourceLevel.JAVA_9.versionStrings.add("17")
// or: com.atlassian.clover.cfg.instr.java.SourceLevel.JAVA_11.versionStrings.add("17")
com.atlassian.clover.CloverInstr.mainImpl(args)
}
which then results in log when running clover:
build 10-Oct-2023 09:18:41 Processing files at JAVA_11 source level.
or
build 10-Oct-2023 09:18:41 Processing files at JAVA_9 source level.
Which is fine, however, the same error pops up; unexpected token: Optional.
We are using Java 17 Temurin 17.0.4.
And in clovers sourcecode, the class JavaEnvUtils does in fact correctly set to
javaVersion = JAVA_17
in it's static block.