Menu

#159 (static) final primitive variables

Some sunny day
closed
None
5
2015-01-10
2014-10-20
No

primitive variables, such as int, byte, short, etc. that are declared (static) final should have an option to be removed and their value be used to replace them.. Example..

public static final int i2k = 88;

public static void x()
{
  //Some Code
  exec(i2k);
}

public static void exec(int i)
{
  //Some Code
}

Would become

public static void x()
{
  //Some Code
  exec(88);
}

public static void exec(int i)
{
  //Some Code
}

I could be wrong in assuming that this is not implemented or that the compiler does not do this automatically, however - in my honest opinion - I believe that it should be something that is done at some stage.

Discussion

  • Eric Lafortune

    Eric Lafortune - 2014-12-28

    All java compilers already inline such constants where they are used. ProGuard then removes the definition. ProGuard also further propagates the constant argument in the second method and then removes the argument.

     
  • Eric Lafortune

    Eric Lafortune - 2014-12-28
    • status: open --> closed
    • assigned_to: Eric Lafortune
     

Log in to post a comment.