Community
Participate
Working Groups
The new dead code detection feature in Galileo warns about this bit of code: private static final boolean ALLOW_DOMAIN_LITERALS = false; private static final String domain = ALLOW_DOMAIN_LITERALS ? rfc2822Domain : rfc1035DomainName; Since the true branch of the ternary if can not be reached, this is correct, but somehow it should be classified as trivial and thus treated in the same manner as this code: private static final boolean ALLOW_DOMAIN_LITERALS = false; private static final String domain; static { if(ALLOW_DOMAIN_LITERALS) { domain = rfc2822Domain; } else { domain= rfc1035DomainName; } } This second version is ignored. Treating the ternary if different seems inconsistent and putting compile-time configuration into static final booleans seems a common enough case to justify special treatment.
If we support the trivial if as a special case, we should also support the conditional expression.
Created attachment 141659 [details] Proposed fix I'll add regression test for this.
Created attachment 141670 [details] Proposed fix + updated regression test I updated the test org.eclipse.jdt.core.tests.compiler.regression.CastTest#test036
Released for 3.6M1. Updated existing regression test.
Verified for 3.6M1 using build I20090802-2000