2013-05-23 2 views
2

Findbugs 플러그인으로 Eclipse Java EE juno SR2 win32를 실행하고 있습니다. codesample 다음FindBugs의 단일 발견을 무시합니다.

은 FindBugs가 발견 표시 할 수 있습니다 :

catch (OutOfMemoryError e) { 
    tryAgain = true; 
    log.error("try to recover", e); 
    System.gc(); // not so happy about this 
} 

을 그리고 여기에 검사에 beeing하지 않도록

Bug: [..] forces garbage collection; extremely dubious except in benchmarking code 

Code explicitly invokes garbage collection. Except for specific use in benchmarking, this is very dubious. 

In the past, situations where people have explicitly invoked the garbage collector in routines such as close or 
finalize methods has led to huge performance black holes. Garbage collection can be expensive. Any situation that forces 
hundreds or thousands of garbage collections will bring the machine to a crawl. 

Confidence: High, Rank: Of Concern (16) 
Pattern: DM_GC 
Type: Dm, Category: PERFORMANCE (Performance) 

그래서 내가 어떻게이 행에 주석을 달 수있는 discription은?

나는 시도했다 작동하지 않습니다 (source)

@edu.umd.cs.findbugs.annotations.SuppressWarnings("DM_GC") 
System.gc(); 

그래서 내가 말하는

@edu.umd.cs.findbugs.annotations.SuppressWarnings("DM_GC") 
private bla(){ 

이 방법으로 이동 : "에듀 유형에 해결 될 수 없다" 그래서 나는 시도했다 :

@SuppressWarnings("DM_GC") 
private bla(){ 

와 나는 "지원되지 않는 @SuppressWarnings있어 ("DM_GC") "

이것은 findbugs 버그, 특정 버그를 비활성화하는 방법에 대한 요청이 아닙니다.

감사합니다.

FYI : gc를 호출하는 것이 좋은 생각이 아닙니다.

답변

4

은 당신이 당신의 프로젝트에 FindBugs 항아리를 추가하지 않은 때문이다

"에듀는 유형에 해결 될 수 없습니다." 당신이 메이븐 당신이 종속성을 추가 사용하는 경우의 pom.xml : 당신은 메이븐을 사용하지 않는 경우

<dependency> 
    <groupId>com.google.code.findbugs</groupId> 
    <artifactId>annotations</artifactId> 
    <version>2.0.0</version> 
</dependency> 

클래스 패스에 jar manually를 추가합니다. 그러면 FindBugs 주석 SuppressWarnings이 발견되어 더 이상 문제를 보지 않아야합니다.

+0

대신 'SuppressFBWarnings'을 사용하면 상단에서 가져올 수 있습니다. –

+0

이 문제가 해결되어 "@ edu.umd.cs.findbugs.annotations.SuppressWarnings ("DM_GC ")"가 작동합니다. 고맙습니다! – MemLeak

관련 문제