depclean: Does not work with JDK 8 bsed project
The plugin is built on Java 11, so not possible to use with a project using jdk 8.
Throws exception,
[ERROR] Failed to execute goal se.kth.castor:depclean-maven-plugin:1.1.0:depclean (default) on project idsk-commons-media: Execution default of goal se.kth.castor:depclean-maven-plugin:1.1.0:depclean failed: An API incompatibility was encountered while executing se.kth.castor:depclean-maven-plugin:1.1.0:depclean: java.lang.NoSuchMethodError: java.nio.ByteBuffer.limit(I)Ljava/nio/ByteBuffer;
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 18 (7 by maintainers)
Commits related to this issue
- Specify maven.compiler.release version Use `maven.compiler.release` to avoid runtime issue (see #25). As `maven.compiler.release` lead to the usage of `-release` `javac` option. Removed `maven.compil... — committed to amottier/depclean by amottier 3 years ago
- Fix Java 8 compatibility issue when building on Java9+ (https://github.com/castor-software/depclean/issues/25) — committed to ASSERT-KTH/depclean by deleted user 3 years ago
- Fix compilation issue for JDK 8 (OpenJdk8) #25 — committed to rvsoni/depclean by deleted user 3 years ago
Minor release is coming soon…
I get the same issue with version
1.1.1
so I tried to investigate a little bit more.Error is related probably to usage of
java.nio.ByteBuffer
in: https://github.com/castor-software/depclean/blob/master/depclean-core/src/main/java/se/kth/depclean/core/analysis/asm/ConstantPoolParser.javaA comment mention a workaround to this issue but is not implemented.
I run
javap -verbose ConstantPoolParser
onConstantPoolParser.class
packaged indepclean-core-1.1.1.jar
and get the following output:According to https://en.wikipedia.org/wiki/Java_class_file#General_layout this confirm that this is some byte code targeting Java 8 even if
META-INF/MANIFEST.MF
packaged indepclean-core-1.1.1.jar
mentionBuild-Jdk: 15.0.1
: JDK 15 can generate byte code for Java 8.An explanation about this behavior can be found in https://github.com/eclipse/jetty.project/issues/3244#issuecomment-495322586
Actually current pom.xml specify source and target (https://github.com/castor-software/depclean/blob/master/pom.xml#L19) but if Java 9 or higher is used to build the project it should specify the release option (
maven.compiler.release
) see https://stackoverflow.com/a/43103038/2440340I will shortly create a pull request that fix the issue and allow successful build on Java 9 or higher (but note that build will failed with Java 8) with error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project depclean-core: Fatal error compiling: invalid flag: --release -> [Help 1]
)I’m not sure if there is an easy solution to allow build of the project with both Java 8 and Java 9+ versions. I guess that requiring Java 9+ version for building is not a big issue and that compatibility with Java 8+ version is what is important here.
Hi @rvsoni, DepClean is available for JDK 8 in Maven Central. See it at https://search.maven.org/artifact/se.kth.castor/depclean-parent-pom/1.1.0/pom
Please close this issue if it works for you. Also, consider giving this project a ⭐, it helps us to grow. Thanks.