When trying to get a FileAttributeView from a zip entry JDK 17+ throws an undeclared UnsupportedOperationException. The javadoc of Files.getFileAttributeView() says:
https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/nio/file/Files.html#getFileAttributeView(java.nio.file.Path,java.lang.Class,java.nio.file.LinkOption...)
"""
Returns:
a file attribute view of the specified type, or null if the attribute view type is not available
"""
Yet, an exception is thrown in some cases. That is a regression to JDK 11. See the attached reproducer.
JDK 11 run:
--------------------------
Debug: Creating test-zip-file.zip...
Debug: reading entry: /noperm_entry
Debug: os.name == Linux
Non-Windows Test PASSED! env=posix view=null, featureVersion: 11
Debug: reading entry: /noperm_entry
Debug: os.name == Linux
Non-Windows Test PASSED! env=empty view=null, featureVersion: 11
JDK 17+ runs:
--------------------------
Debug: Creating test-zip-file.zip...
Debug: reading entry: /noperm_entry
Debug: os.name == Linux
Non-Windows Test PASSED! env=posix view=jdk.nio.zipfs.ZipPosixFileAttributeView@2f2c9b19, featureVersion: 17
Debug: reading entry: /noperm_entry
Debug: Files.getFileAttributeView() threw exception: java.lang.UnsupportedOperationException: view <interface java.nio.file.attribute.PosixFileAttributeView> is not supported
Debug: os.name == Linux
Exception in thread "main" java.lang.RuntimeException: Test failed! view=null
at TestPosixAttributeView.runTest(TestPosixAttributeView.java:83)
at TestPosixAttributeView.main(TestPosixAttributeView.java:105)
This was originally reported here, where the issue is that on Windows, where Posix permissions are not supported, suddenly throws an exception when it didn't before JDK-8213031:
https://github.com/adoptium/adoptium-support/issues/363