intoolswetrust / jd-cli

Command line Java Decompiler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Throwing Exception while trying to decompile a jar

debraj-manna opened this issue · comments

I am trying to decompile a jar with the below content

dmanna-m01:target dmanna$ jar -tf hbase-coproc-0.001-SNAPSHOT-jar-with-dependencies.jar
META-INF/MANIFEST.MF
META-INF/
com/
com/vnera/
com/vnera/storage/
com/vnera/storage/hbase/
com/vnera/storage/hbase/coprocessor/
com/vnera/storage/hbase/coprocessor/ArkinDataRetentionCoproc$1.class
com/vnera/storage/hbase/coprocessor/ArkinDataRetentionCoproc$HBaseRetentionInfo.class
com/vnera/storage/hbase/coprocessor/ArkinDataRetentionCoproc$HBaseRetentionInfoList.class
com/vnera/storage/hbase/coprocessor/ArkinDataRetentionCoproc$RetentionData.class
com/vnera/storage/hbase/coprocessor/ArkinDataRetentionCoproc$RetentionInfo.class
com/vnera/storage/hbase/coprocessor/ArkinDataRetentionCoproc$RetentionPolicy.class
com/vnera/storage/hbase/coprocessor/ArkinDataRetentionCoproc$RetentionResolutionData.class
com/vnera/storage/hbase/coprocessor/ArkinDataRetentionCoproc.class
META-INF/maven/com.vnera/hbase-coproc/pom.xml
META-INF/maven/com.vnera/hbase-coproc/pom.properties
META-INF/maven
META-INF/maven/com.vnera
META-INF/maven/com.vnera/hbase-coproc

But it is throwing the below errors

dmanna-m01:jd-cli-0.9.1.Final-dist dmanna$ java -jar jd-cli.jar ~/code/github/vnera/main/storage/hbase-coproc/target/hbase-coproc-0.001-SNAPSHOT-jar-with-dependencies.jar -od /tmp/decom/
14:42:10.430 INFO  jd.cli.Main - Decompiling /Users/dmanna/code/github/vnera/main/storage/hbase-coproc/target/hbase-coproc-0.001-SNAPSHOT-jar-with-dependencies.jar
14:42:10.434 INFO  jd.core.output.DirOutput - Directory output will be initialized for path /tmp/decom
14:42:10.585 WARN  jd.core.output.DirOutput - Class name or java source is null
14:42:10.589 ERROR jd.core.output.DirOutput - Writing resource to file /tmp/decom/META-INF/maven failed.
java.io.FileNotFoundException: /tmp/decom/META-INF/maven (Is a directory)
	at java.io.FileOutputStream.open0(Native Method) ~[na:1.8.0_131]
	at java.io.FileOutputStream.open(FileOutputStream.java:270) ~[na:1.8.0_131]
	at java.io.FileOutputStream.<init>(FileOutputStream.java:213) ~[na:1.8.0_131]
	at java.io.FileOutputStream.<init>(FileOutputStream.java:162) ~[na:1.8.0_131]
	at jd.core.output.DirOutput.processResource(DirOutput.java:114) ~[jd-cli.jar:na]
	at jd.core.output.MultiOutput.processResource(MultiOutput.java:163) [jd-cli.jar:na]
	at jd.core.input.ZipFileInput.decompile(ZipFileInput.java:90) [jd-cli.jar:na]
	at jd.cli.Main.main(Main.java:118) [jd-cli.jar:na]
14:42:10.590 ERROR jd.core.output.DirOutput - Writing resource to file /tmp/decom/META-INF/maven/com.vnera failed.
java.io.FileNotFoundException: /tmp/decom/META-INF/maven/com.vnera (Is a directory)
	at java.io.FileOutputStream.open0(Native Method) ~[na:1.8.0_131]
	at java.io.FileOutputStream.open(FileOutputStream.java:270) ~[na:1.8.0_131]
	at java.io.FileOutputStream.<init>(FileOutputStream.java:213) ~[na:1.8.0_131]
	at java.io.FileOutputStream.<init>(FileOutputStream.java:162) ~[na:1.8.0_131]
	at jd.core.output.DirOutput.processResource(DirOutput.java:114) ~[jd-cli.jar:na]
	at jd.core.output.MultiOutput.processResource(MultiOutput.java:163) [jd-cli.jar:na]
	at jd.core.input.ZipFileInput.decompile(ZipFileInput.java:90) [jd-cli.jar:na]
	at jd.cli.Main.main(Main.java:118) [jd-cli.jar:na]
14:42:10.590 ERROR jd.core.output.DirOutput - Writing resource to file /tmp/decom/META-INF/maven/com.vnera/hbase-coproc failed.
java.io.FileNotFoundException: /tmp/decom/META-INF/maven/com.vnera/hbase-coproc (Is a directory)
	at java.io.FileOutputStream.open0(Native Method) ~[na:1.8.0_131]
	at java.io.FileOutputStream.open(FileOutputStream.java:270) ~[na:1.8.0_131]
	at java.io.FileOutputStream.<init>(FileOutputStream.java:213) ~[na:1.8.0_131]
	at java.io.FileOutputStream.<init>(FileOutputStream.java:162) ~[na:1.8.0_131]
	at jd.core.output.DirOutput.processResource(DirOutput.java:114) ~[jd-cli.jar:na]
	at jd.core.output.MultiOutput.processResource(MultiOutput.java:163) [jd-cli.jar:na]
	at jd.core.input.ZipFileInput.decompile(ZipFileInput.java:90) [jd-cli.jar:na]
	at jd.cli.Main.main(Main.java:118) [jd-cli.jar:na]
14:42:10.590 INFO  jd.core.output.DirOutput - Finished with 7 class file(s) and 3 resource file(s) written.
dmanna-m01:jd-cli-0.9.1.Final-dist dmanna$ jar -tf /code/github/vnera/main/storage/hbase-coproc/target/hbase-coproc-0.001-SNAPSHOT-jar-with-dependencies.jar
java.io.FileNotFoundException: /code/github/vnera/main/storage/hbase-coproc/target/hbase-coproc-0.001-SNAPSHOT-jar-with-dependencies.jar (No such file or directory)
	at java.util.zip.ZipFile.open(Native Method)
	at java.util.zip.ZipFile.<init>(ZipFile.java:219)
	at java.util.zip.ZipFile.<init>(ZipFile.java:149)
	at java.util.zip.ZipFile.<init>(ZipFile.java:120)
	at sun.tools.jar.Main.list(Main.java:1115)
	at sun.tools.jar.Main.run(Main.java:293)
	at sun.tools.jar.Main.main(Main.java:1288)
dmanna-m01:jd-cli-0.9.1.Final-dist dmanna$ ls /tmp/decom/
META-INF com

Environment

  • Mac OS X - 10.12.6
  • Java 8

It seems, the META-INF/maven is used twice in your JAR file. Once as a directory and the second is a file.

Can't it be a result of shading?

If you have in mind a way how to handle these cases, pull request with fix is welcome.

The related code is in
https://github.com/kwart/jd-cmd/blob/master/jd-lib/src/main/java/jd/core/output/DirOutput.java