Spring Security로 개발하는 동안 최근에 문제가 발생했습니다. 안전하지 않은 Java 인터페이스 구현
public interface GrantedAuthority extends Serializable, Comparable
그리고 자바 1.5 이후로
는, 인터페이스Comparable
이 (JVM 1.4의 호환성을 위해, 명백하게) 봄 보안 라이브러리에서 생략 된 형식 매개 변수
T
을한다 : 그것은 다음과 같은 서명이 인터페이스
GrantedAuthority
있습니다.
그래서 스칼라에서 GrantedAuthority
을 구현하려고합니다.
class Role extends GrantedAuthority {
. . .
def compareTo(obj: Any): Int = obj match {
case (r: Role) => r.toString.compareTo(this.toString)
case _ => -1
}
}
이 컴파일되지 않습니다 :
error: class Role needs to be abstract, since method compareTo in trait Comparable of type (T)Int is not defined
어떻게 스칼라 이러한 인터페이스를 구현 할 수 있습니까? 자바 제네릭과
원시 형식과 관련된 소리는 다음과 같습니다. https://lampsvn.epfl.ch/trac/scala/ticket/2970#comment:3 – retronym
고마워요, retronym. 그래서 최종 답은 사실 "wontfix"입니까? – incarnate