2

See, in master:

https://github.com/android/platform_frameworks_base/blob/master/core/java/android/os/Environment.java#L419

Why are these mutable? What does it mean? What's the use case?

Michal Rus
  • 1,796
  • 2
  • 18
  • 27
  • 1
    They failed to add `final` or in case it is on purpose it is to allow that those values can be different on other devices. Actual constants are compiled into your app and would not allow that. – zapl Jan 15 '14 at 10:31

1 Answers1

2

If they were final, they could be inlined at compile time, based on the definitions in the stub android.jar in the SDK.

Now, device manufacturers are free to change the paths to whatever they want. By making the definitions non-final it is ensured that the definition in the runtime platform is used instead.

There are also other methods to prevent inlining.

Community
  • 1
  • 1
laalto
  • 150,114
  • 66
  • 286
  • 303