开发者

How to disable eclipse annotation error

开发者 https://www.devze.com 2022-12-20 04:36 出处:网络
In eclipse, I get the following errors in my project: The annotation @SuppressWarnings is disallowed for this location

In eclipse, I get the following errors in my project:

The annotation @SuppressWarnings is disallowed for this location

Can you please tell me how can I turn those errors into warnings?

Thank you.


Look like it is a bug in eclipse3.6M5. This is the code which gives me error. But it works fine in eclipse3.6M4.

package java.lang.annotation;

/**
 * Defines a meta-annotation for indicating that an annotation is automatically
 * inherited.
 *
 * @since 1.5
 */
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Tar开发者_如何学Cget(ElementType.ANNOTATION_TYPE)
public @interface Inherited {
}


If it's really a wrong location of the @SuppressWarnings then there is not much you can do. But why should you turn that off?

As any annotation you can use @SuppressWarnings only in front of a class, a variable declaration, a parameter or a method declaration. All other locations will give you a compile error.


Project -> Properties -> Java Compiler -> Errors/Warnings.

  • Choose Annotations.
  • Change "Unhandled token in '@SuppressWarnings':" to Ignore.

Rebuild your project and this irritant will go away. Dirty - but given that this masks other issues in the project and waists time probably worth the time saved.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号