posted in this-SO-post :
I’m running proguard
on a single class file but the output.jar
file is not created .
$ javap -c java-8-classes/BinaryNode.class | sed -n "139,150p;151q"
public int hashCode();
Code:
0: aload_0
1: getfield #2 // Field _data:[B
4: ifnonnull 11
7: iconst_m1
8: goto 16
11: aload_0
12: getfield #2 // Field _data:[B
15: arraylength
16: ireturn
So unless I’m mistaken(?) it seems that BinaryNode::hashCode
only needs _data
field.
$ javap -c java-8-classes/BinaryNode.class | sed -n "5,6p;7q"
protected final byte[] _data;
So I edited my config.pro
accordingly:
$ cat config.pro
-injars java-8-classes/BinaryNode.class
-outjars output.jar
-verbose
-keep class com.fasterxml.jackson.databind.node.BinaryNode
{
protected final byte[] _data;
public int hashCode();
}
-allowaccessmodification
When I run proguard, output jar does not get created:
$ java -jar ../proguard/lib/proguard.jar -dontwarn @config.pro
ProGuard, version 7.1.0-beta2
Reading input...
Reading program directory [/home/oren/Documents/java-8-classes/BinaryNode.class] (filtered) # <---- OK??
Initializing...
<...>
Preparing output jar [/home/oren/Documents/output.jar] (filtered) # <---- WHY ???
james
April 5, 2021, 10:06am
2
Hi @AliveBeef !
I’ve tried reproducing this: the problem is probably the package.
What package is BinaryNode
class in? Is it still in the jackson package or is it in the root package?
Is there any warning on stderr like:
Warning: class [BinaryNode.class] unexpectedly contains class [com.fasterxml.jackson.databind.node.BinaryNode]
Warning: there were 1 classes in incorrectly named files.
...
Warning: the output jar is empty. Did you specify the proper '-keep' options?
...
If you instead, pass the jackson databind jar as input it works fine:
~/Downloads $ cat config.pro
#-injars /home/james/Downloads/BinaryNode.class
-injars jackson-databind-2.12.2.jar
-outjars output.jar
-verbose
-keep class com.fasterxml.jackson.databind.node.BinaryNode
{
protected final byte[] _data;
public int hashCode();
}
-allowaccessmodification
~/Downloads $ unzip -l output.jar
Archive: output.jar
Length Date Time Name
--------- ---------- ----- ----
11614 2021-04-05 12:05 META-INF/MANIFEST.MF
11358 2021-04-05 12:05 META-INF/LICENSE
667 2021-04-05 12:05 META-INF/NOTICE
78 2021-04-05 12:05 META-INF/maven/com.fasterxml.jackson.core/jackson-databind/pom.properties
14785 2021-04-05 12:05 META-INF/maven/com.fasterxml.jackson.core/jackson-databind/pom.xml
44 2021-04-05 12:05 META-INF/services/com.fasterxml.jackson.core.ObjectCodec
163 2021-04-05 12:05 com/fasterxml/jackson/databind/a.class
187 2021-04-05 12:05 com/fasterxml/jackson/databind/c.class
84 2021-04-05 12:05 com/fasterxml/jackson/databind/b.class
193 2021-04-05 12:05 com/fasterxml/jackson/databind/node/a.class
366 2021-04-05 12:05 com/fasterxml/jackson/databind/node/BinaryNode.class
173 2021-04-05 12:05 com/fasterxml/jackson/databind/node/b.class
Thanks for the answer James !
I reproduced the creation when using the whole jackson-databind jar.
I think I understand why my isolated class attempt failed
Proguard seems to need BinaryNode
class’ super classes (?)
The one-letter minified classes are its ancestors in the inheritance tree:
BinaryNode → node/b → node/a → a → c → b (interface)
Is my understanding correct ?