Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
4.0.4, 3.0.20, 4.0.16, 4.0.18
-
None
-
None
Description
When I compile and run this Spock 2.3-groovy-4.0 test on JDK 17 (build target 8), it works fine:
import com.github.marschall.memoryfilesystem.MemoryFileSystemBuilder import com.google.common.jimfs.Configuration import com.google.common.jimfs.Jimfs import spock.lang.Specification import spock.lang.Unroll import java.nio.file.FileSystems import java.nio.file.Files @Grab('com.google.jimfs:jimfs:1.3.0') @Grab('com.github.marschall:memoryfilesystem:2.8.0') class NestedZipTest extends Specification { @Unroll('#scenario') def 'create nested zip file'() { given: 'a text file on the default FS' def sourceFS = MemoryFileSystemBuilder.newEmpty().build() def rootTxtPath = sourceFS.getPath('root.txt') Files.write(rootTxtPath, 'Hello root!'.bytes) when: 'creating a zip FS on the target FS, adding two text files' def outerZipPath = targetFS.getPath('outer.zip') if (Files.exists(outerZipPath)) Files.delete(outerZipPath) def outerZipFS = FileSystems.newFileSystem(outerZipPath, [create: 'true']) Files.write(outerZipFS.getPath('outer.txt'), 'Hello outer!'.bytes) Files.copy(rootTxtPath, outerZipFS.getPath('from-root.txt')) and: 'creating a zip FS inside the outer zip file, adding two text files' def innerZipPath = outerZipFS.getPath('inner.zip') def innerZipFS = FileSystems.newFileSystem(innerZipPath, [create: 'true']) Files.write(innerZipFS.getPath('inner.txt'), 'Hello inner!'.bytes) Files.copy(rootTxtPath, innerZipFS.getPath('from-root.txt')) and: 'creating a zip FS inside the inner zip file, adding two text files' def inner2ZipPath = innerZipFS.getPath('inner2.zip') def inner2ZipFS = FileSystems.newFileSystem(inner2ZipPath, [create: 'true']) Files.write(inner2ZipFS.getPath('inner2.txt'), 'Hello inner2!'.bytes) Files.copy(rootTxtPath, inner2ZipFS.getPath('from-root.txt')) then: 'no errors occur' noExceptionThrown() cleanup: inner2ZipFS?.close() innerZipFS?.close() outerZipFS?.close() where: scenario | targetFS 'on disk' | FileSystems.default 'JimFS' | Jimfs.newFileSystem(Configuration.unix().toBuilder().setWorkingDirectory('/').build()) 'MemoryFileSystem' | MemoryFileSystemBuilder.newEmpty().build() } }
Try it in the Groovy Web Console.
You can also comment out the test iterations for JimFS and MemoryFileSystem in the where blocks, if you want to test without external dependencies.
When running the same code on JDK 8, there is a MissingMethodException, which is fine, because some JDK API I am calling only exists since JDK 13. I.e., I expect the MissingMethodException on JDKs 8-12 and a working test on 13+.
What happens instead is that on JDKs 9-16, I see: "BUG! At this point argument array length and parameter array length should be the same"
Because of this message coming from Groovy directly, I am opening a bug here first, not in the Spock project.