본문 바로가기
Programming/Spring

uses unchecked or unsafe operations. 에러

by peter paak 2019. 11. 28.
728x90
Task :폴더이름:compileJava
Note: C:\경로\UserQueryDSLImpl.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

stackoverflow 참조

  • Java5 버전 부터 생김
  • Collection 사용시 type을 지정하지 않으면 (ArrayList<User>와 같이 타입을 지정 안하면) 발생한다.
  • 한마디로 코드가 raw type으로 컴파일 되었다는 뜻이다.

raw type

public class Box<T> {
    public void set(T t) { /* ... */ }
    // ...
}
  • compiler는 사용자가 type safe한 방법으로 Collection을 사용하는지 generic으로 체크 할 수 없다.
  • -Xlint:unchecked로 변환해서 recompile하는 방법이 있다.
javac YourFile.java -Xlint:unchecked

참조

gradle로 build 할 때 --stacktrace 옵션으로 빌드하였다. stack trace의 log는 에러시 이벤트 블록만 표시해주는 것 같은데 정확한 의미를 알기 위해 stackoverflow를 참조하였다.

stack trace is a list of the method calls that the application was in the middle of when an Exception was thrown.

한마디로 에러가 발생할 때의 불려진 메소드의 리스트들이다. 무한정으로 늘어나는 일반 로그 메세지보다 훨씬 더 많은 정보를 담고 있기 때문에 자주 사용해야 할 듯 하다.

./gradlew --stacktrace clean 
728x90