Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinity/NaN not supported #5

Open
mrjameshamilton opened this issue May 17, 2021 · 1 comment
Open

Infinity/NaN not supported #5

mrjameshamilton opened this issue May 17, 2021 · 1 comment

Comments

@mrjameshamilton
Copy link
Contributor

mrjameshamilton commented May 17, 2021

If you compile the following:

public class Test  {
    public static final float POSITIVE_INFINITY = Float.POSITIVE_INFINITY;
    public static final float NEGATIVE_INFINITY = Float.NEGATIVE_INFINITY;
    public static final float NaN = Float.NaN;
}

the disassembler produces the following:

version 1.8;
public class TestInf extends java.lang.Object [
    SourceFile "TestInf.java";
] {
    public static final float POSITIVE_INFINITY = ∞float;
    public static final float NEGATIVE_INFINITY = -∞float;
    public static final float NAN = NaNfloat;

    public void <init>() {
        line 1
            aload_0
            invokespecial java.lang.Object#void <init>()
            return
    }

    public static void main(java.lang.String[]) {
        line 8
            getstatic java.lang.System#java.io.PrintStream out
            ldc ∞float
            invokevirtual java.io.PrintStream#void println(float)
        line 9
            getstatic java.lang.System#java.io.PrintStream out
            ldc -∞float
            invokevirtual java.io.PrintStream#void println(float)
        line 10
            getstatic java.lang.System#java.io.PrintStream out
            ldc NaNfloat
            invokevirtual java.io.PrintStream#void println(float)
        line 11
            return
    }

}

This is because the conversion from number to string uses DecimalFormat here.

The assembler also cannot read this back in, since it cannot parse these constants (they aren't numbers).

@shunf4
Copy link

shunf4 commented Mar 16, 2024

try my fork which fixed this https://github.com/shunf4/proguard-assembler

though DecimalFormat may still cause problems like not accurately expressing double/float (disassembing and then assembling back may get a different value, e.g. Double.MIN_VALUE and Double.MAX_VALUE), not a clever way to precisely serialize & print decimal numbers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants