Community
Participate
Working Groups
Build Identifier: 20100917-0705 This sample code is used to switch debug/release builds: public class BuildConfig { /** * Debug vs. production build */ public static final int BUILD_CONFIG_PRODUCTION = 1; public static final int BUILD_CONFIG_INTERNAL_DEBUG = 2; public static final int which = BUILD_CONFIG_INTERNAL_DEBUG; } And then: if (BuildConfig.which == BuildConfig.BUILD_CONFIG_INTERNAL_DEBUG) { // blah blah blah } This produces a Java compiler warning, "Comparing identical expressions". The only way to suppress it is to use @SuppressWarnings("all"), but that's too broad, it would be nice to have a specific pragma value. Reproducible: Always Steps to Reproduce: 1. Create a Java class like this: public class BuildConfig { /** * Debug vs. production build */ public static final int BUILD_CONFIG_PRODUCTION = 1; public static final int BUILD_CONFIG_INTERNAL_DEBUG = 2; public static final int which = BUILD_CONFIG_INTERNAL_DEBUG; } 2. Use it like this: if (BuildConfig.which == BuildConfig.BUILD_CONFIG_INTERNAL_DEBUG) { // blah blah blah } 3. You will get a Java compiler warning "Comparing identical expressions". The only way to suppress it is to use @SuppressWarnings("all"), but that's too broad, it would be nice to have a specific pragma value.
I'm not sure it's really worth adding a special token for that. Note that if you compile with ... public static final int which = BUILD_CONFIG_PRODUCTION; you'd two new warnings: - unused @SuppressWarnings("identical-expression") - the "// blah blah blah" block is dead code A better solution would be to just initialize the "which" like this: public static final int which; static { which= BUILD_CONFIG_INTERNAL_DEBUG; } That avoids all these problems. For the final production build, you can of course still initialize the constant directly.
Agreed. Closing as WONTFIX.
Verified for 3.7M6