Community
Participate
Working Groups
3.1 RC1 In the following case, we issue a 'Non-externalized string literal' warning for "deprecation": @SuppressWarnings("deprecation") public class X { } However this is always a constant (and will never be externalized). We should not issue a 'Non-externalized string literal' warning here (and for any annotation in general).
Olivier - how much changes would this take ? depending on it, we could consider this for RC2.
This doesn't look trivial as the non externalized string checking is done without any context. In order to fix this, we would need to disable in within the SuppressWarnings annotation. So this would require to move that check later (after type resolution).
Will reconsider post 3.1.
*** Bug 98217 has been marked as a duplicate of this bug. ***
*** Bug 102130 has been marked as a duplicate of this bug. ***
reopen
Fixed and released in 3.1 maintenance. Regression tests added in org.eclipse.jdt.core.tests.compiler.regression.AnnotationTest.test169-173.
The support has been added only for the SuppressWarnings annotation. For others, the compiler cannot make assumptions on the fact that a string should be externalized or not. We can imagine for example a Copyright annotation. You might want to provide a translated version of the copyright. @interface Copyright { String message(); } Copyright(message="Copyright in English") ..... The user might want to translate this one. If I add the support for all annotations, then this won't need to be tagged as a non-nls string by the user.
Update title accordingly.
Only constant values can be specified on annotation attributes, so it should not be restricted to @SuppressWarnings.
Fixed and released in HEAD. All annotations are supported. Regression tests added in org.eclipse.jdt.core.tests.compiler.regression.AnnotationTest.test169-176
Verified with 3.2 M1
I think the fix is incomplete. Although literal strings in the uses of annotations need no longer be marked with a non-nls comment, the uses of strings in default clauses in the declaration of annotations still generate NLS warnings. For example, consider this case: import java.lang.annotation.*; @Target({ElementType.TYPE, ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER, ElementType.CONSTRUCTOR, ElementType.LOCAL_VARIABLE, ElementType.PACKAGE}) @Retention(RetentionPolicy.CLASS) public @interface MySuppressWarnings { String[] value() default {}; String justification() default ""; } The declaration of 'justification' gives an NLS warning in 3.2M1. Since default strings must be constant expressions, the warning is not appropriate.
I opened bug 110613 for this last issue. It resides in annotation type declaration and not within the usage of annotation.
I believe that comment#13 should be the subject of a specific bug, since it applies to a use case that is quite a bit different (the focus being on the annotation declaration instead of the annotation use site). As far as the initial bug is concerned: Verified for 3.1.1 using build M20050923-1430.
(Collision -- agree with Olivier and IMHO this one is verified for 3.1.1.)
Verified for 3.1.1 using M20050923-1430.
*** Bug 119269 has been marked as a duplicate of this bug. ***