While adding Spotless to the build for one of the repositories I work with, I stumbled upon a problem which suggests that the bytecode has ties to API available only in Java 9+. The trigger was a properties file in the repository that had ISO-8859-1 characters in it instead of Unicode escape sequences. Since Spotless uses UTF-8 by default, I would have expected Spotless to report an encoding error (e.g. Encoding error! Spotless uses UTF-8 by default. At line 14 col 176:). Instead, what I get is java.nio.ByteBuffer.clear()Ljava/nio/ByteBuffer;. I am using Java SE 8. If I switch the build to Java 11, I get the expected error message.
Also, Spotless does not tell me the name of the guilty file. Adding --debug helps me figure that out. I see that #868 is already open for this.
Summary of the problem
While adding Spotless to the build for one of the repositories I work with, I stumbled upon a problem which suggests that the bytecode has ties to API available only in Java 9+. The trigger was a properties file in the repository that had ISO-8859-1 characters in it instead of Unicode escape sequences. Since Spotless uses UTF-8 by default, I would have expected Spotless to report an encoding error (e.g.
Encoding error! Spotless uses UTF-8 by default. At line 14 col 176:
). Instead, what I get isjava.nio.ByteBuffer.clear()Ljava/nio/ByteBuffer;
. I am using Java SE 8. If I switch the build to Java 11, I get the expected error message.Also, Spotless does not tell me the name of the guilty file. Adding
--debug
helps me figure that out. I see that #868 is already open for this.https://jira.mongodb.org/browse/JAVA-2559 appears to be related and has a good explanation of the cause and a possible solution.
Gradle version
7.3.3
Spotless version
5.7.0 appears to be the earliest version where this problem occurs.
Operating system and version
Windows 10/RHEL 7.3
public repository to demonstrate the problem
https://github.com/smoothreggae/spotless-ties-to-java9