It was my understanding that and static final constants are inlined at compile time when using Java.
Looking at Using the Version-Aware Component – Add the Switching Logic and the use of Build.VERSION.SDK_INT and Build.VERSION_CODES confuses me, as if both these constants values are inlined at compile time this approach would be useless. What am I missing here?
Thanks 🙂
EDIT: does the fact they are in a static method in an abstract class change this compile-time inlining?
What is inlined is constants that can be determined at compile time, such as:
If you check the source code (it’s an old version but I suppose it has not changed much), the constants look like this:
And this is the
getStringmethod:So the constant can’t be determined at compile time.