원시 타입의 값과 래퍼 클래스의 객체간 자동차 변환를 지원하기 위한 Java의 확장

Java Extension for supporting Automatic Transformation between Values of Primitive Types and Objects of Wrapper Classes

  • 김성기 (한산대학교 컴퓨터학과) ;
  • 김상철 (한국외국어대학교 컴퓨터공학과) ;
  • 정병수 (경희대학교 전자정보학부)
  • 발행 : 2001.10.01

초록

Java 에서 원시 타입과 클래스 타입간에 호환성이 제공되지 않으므로 원시값이 클래스 타입의 변수에 저장되지 못하며, 클래스 타입의 값이 원시 타입 변수에 저장되지 못한다. 객체가 필요한 곳에서 원시값을 사용하기 위해서는 원시 값을 저장하는 래퍼 클래스의 객체 생성이 필요하며, 패러 클래스의 객체에서 저장된 원시 값을 꺼내기 위해서는 특정 메소드를 호출하여야 한다.이러한 불편함과 변환시의 오류를 줄이기 위하여 본 논문에서는 Java의 원시타입과 래퍼 클래스 타입의 호환성 제공을 위한 변환방법을 제안하였다. 원시 타입과 래퍼 클래스 타입간의 호환성 뿐 아니라 원시 타입간의 호환성에 상응하는 래퍼 클래스간의 호환성도 제공하기 위해 래퍼 클래스 계층방법, java.lang.Number 클래스 이용방법, 래퍼 인터페이스 계층방법 등 3가지 변환방법을 제시하였다. 이들 방법의 비교분석과 성능측정을 통하여 래퍼 인터페이스 계층방법이 가장 우수한 방법임을 확인하였다.

Since there is no compatability between primitive types and class types in Java, values of primitive types cannot be assigned to variables of class types cannot be assigned to variables of primitive types. Primitive values must be converted to objects of wrapper classes and special methods must be called in order to extract the primitive values from those objects. In this paper we propose there methods which provide automatic transformation between primitive types and class types for their compatability. Those methods support compatability not only between primitive types but also between wapper classes. The first method utilizes the hierarchy of wrapper classes, the second utilizer java.lang.Number class, and the third utilizes the hierarchy of wrapper interfaces. Through comparison and performance measurement. we confirm that the third method works better than the others.

키워드

참고문헌

  1. K. Arnold and J. Gosling, The java Programming Language, Addison - Wesley, 1996
  2. J. H. Solorzano, S. Alagic, Parametric Polymorphism for Java: A Reflective Solution, Proceedings of OOPSLA '98, pp 216-225, 1998 https://doi.org/10.1145/286936.286959
  3. B. Strostrup, The C++ programming Language, Addison-Wesley, 1993
  4. B. Meyer, Eiffel: The Language, Prentice-Hall, 1992
  5. O. Agesen, S. N. Freund and J. C. Michell, Adding Type Parameterization to the Java Language, Proceedings of OOPSLA '97, pp. 49-65, 1997 https://doi.org/10.1145/263698.263720
  6. M. Odersky and P. Walder, Pizza into Java with virtual type, ACM Symposium on Principles of Programming Languages, pp. 149-159, 1997 https://doi.org/10.1145/263699.263715
  7. M. Grand, Java Language Reference, O'REILLY, 1997
  8. L. Cardelli and P. Wegner, On Understanding Types, Data Abstraction, and Polymorphism, ACM Computing Surveys, Vol. 17, No. 4, Dec. 1985 https://doi.org/10.1145/6041.6042
  9. T. Bennet. 'A Pragmatic Set Operation and its Implementation in C,' Proc, of the ACM/SIGAPP Symposium on Applied Computing. 1992 https://doi.org/10.1145/143559.143636
  10. J. Bergin, 'Run-time Design for Object-Oriented Extensions to Pascal,' Proc, of the ACM Conference on Computer Science, 1995 https://doi.org/10.1145/259526.259543