18. What is the Marker interface in Java ?

toutbon·2024년 3월 25일
0

Marker interface 란 ?

  • 상수, 메서드가 없이 완전히 비어있는 인터페이스
  • 인터페이스는 일반적으로 자바에서 약속을 의미한다
  • 특별한 행동을 compiler에게 알려주고, jvm은 이것이 되도록 기능을 support 한다.
  • tag interface 라고 부르기도 한다.

Marker Interface Example

  • serializable
    - 나중에 객체직렬화를 통해 통신을 할 수도 있음
  • Clonnable
    - 이 인터페이스를 구현한 객체만 객체 복제가 가능함
  • SingleThreadModel
    - 서블릿이 싱글스레드로 구현하면, default 인 멀티가 아닌 싱글로 처리하게 됨
  • Remote
    - 해당 객체를 구현했어야만 jvm이 원격 호출을 support 한다.

Keyword

  • No Constant or methods, empty body, called as a tag interface
  • Indicate special function to compiler or JVM
  • Can be replaced with annotation from Java 5 (ex> Junit class @Test)
profile
뚜봉

0개의 댓글