GraxCode / threadtear

Multifunctional java deobfuscation tool suite
GNU General Public License v3.0
885 stars 123 forks source link

Boolean value is inverted when casting #70

Open foaw opened 2 years ago

foaw commented 2 years ago

In Casts#castWithPrimitives(...) there seems to be a typo. When converting Number values with boolean.class as the type, it returns true when the given value is 0, and false when the value is 1.

https://github.com/GraxCode/threadtear/blob/f0a13d5d515f769db33cd408cb65944b027d9ef0/core/src/main/java/me/nov/threadtear/util/reflection/Casts.java#L17-L25

As of Java 16, Java Virtual Machine Specification says:

The Java Virtual Machine encodes boolean array components using 1 to represent true and 0 to represent false. Where Java programming language boolean values are mapped by compilers to values of Java Virtual Machine type int, the compilers must use the same encoding.

Below I am attaching a list of all calls to this method:

Not much to fix, but I could send a PR if you want.