Community
Participate
Working Groups
While trying to reduce our string footprint, we saw a case where the code: value = ":" + 9443 + "/service"; was replaced with: value = ':' + 9443 + "/service"; //$NON-NLS-1$ The result of these expressions are quite different. The first sets value to ":9443/service", while the second sets value to "9501/service". This happens because the colon character's integer value is added to 9443, before being concatenated with "/service". It would be helpful to have a JDT compiler warning for the case where a character is being added to another character, or a number. Ideally the compiler warning would detect only the case where a character is involved in integer addition, followed by concatenation with a string, but I understand if that is not feasible. A common work around for such as problem is to do the following: value = "" + ':' + 9443 + "/service"; //$NON-NLS-1$ //$NON-NLS-2$ But this is not ideal, since it introduces yet another string, which also needs to be NON-NLS'd.
We have one warning for use of char[] in String concatenation... this new one goes in the same direction... time permitting