intoolswetrust / jd-cli

Command line Java Decompiler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Throwing StringIndexOutOfBoundsException when passing /dev/stdin as class file

onesunvan opened this issue · comments

commented

I'm trying to decompile only certain class file from full jar.

For these purposes I'm using linux pipe:

$ unzip -p myjar.jar com/example/App.class | jd-cli /dev/stdin

But unfortunately, jd-cli throws an exception
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(String.java:1967) ~[na:1.8.0_151]
at jd.core.input.AbstractFileJDInput.cutClassSuffix(AbstractFileJDInput.java:79) ~[jd-cli.jar:na]
at jd.core.input.ClassFileInput.decompile(ClassFileInput.java:54) ~[jd-cli.jar:na]
at jd.cli.Main.main(Main.java:118) ~[jd-cli.jar:na]

(I suppose, the root cause is that jd-cli wants to discover java class name, simply cutting ".class" suffix, but in case of /dev/stdin it leads to exception)

Also, it would be grateful if jd-cli will support class ingesting from standard input out-of-the-box.

P.S. Thanks for this great tool.

Should be fixed now by 2fea440.
Use simple - if you want to read from the STD_IN:

unzip -p myjar.jar com/example/App.class | jd-cli -

The /dev/stdin won't work as the file is read more times (first is file-type guessing).