2016년 12월 15일 목요일

[jvm]00-Class File Format 클래스파일포맷

jvm 개요

  1. Class File Format

  2. 모든 JVM으로 컴파일된 코드는 class라는 파일포맷으로 변환된다.

  3. Data Types

  4. JVM은 두 가지의 타입을 운영한다. primitive typesreference types이다. 그에 부응하여, 이 두 타입은 서로 방식으로 값을 저장하고, 아규먼트로 다뤄지거나, 리턴값으로 사용되고 또 계산된다. JVM은 대부분의 타입체킹type checking을 런타임 이전에 한다. primitive type의 값들은 이름표가 붙여질 필요가 없어서 알기 힘들 수 있지만, run time에는 타입을 볼 수 있고, 레퍼런스타입의 값으로 구별할 수도 있다.

    JVM도 이런 식으로 알아낼까??? JVM은 명령어 집합이 operand(피연산자)타입을 구별한다. (특정 타입 값을 실행하기 위해서 명령어를 보고 확인한다) 예를들어, iadd, ladd, fadd, dadd 는 모두 JVM에서 수를 더하고 결과값을 생성하는 명령어다. 하지만 각각 특정한 operand type에서만 작동한다. 위의 명령어들은 순서대로 int, long, float, double이다.

    JVM은 오브젝트를 지원한다. (여기서 오브젝트는 동적할당 인스턴스 또는 배열 모두를 말한다.) 오브젝트 레퍼런스(a reference to an object)는 Java Virtual Machine type reference로 간주된다. (그냥 reference type이라 간주된다는 말...?) 레퍼런스타입의 값은 오브젝트의 포인터로 생각해도 좋다. 하나의 오브젝트에 여러개의 오브젝트레퍼런스가 존재할 수 있다. (More than one reference to an object may exist.) 오브젝트는 항상 type reference의 값을 통해서 실행되고, 넘겨지고 테스트된다.(Objects are always operated on, passed, and tested via values of type reference.)

  5. Primitive Types and Values

  6. Java Virtual Machine이 지원하는 primitive data type은 숫자 타입(numeric types), 불린 타입(boolean type), 그리고 리턴어드레스 타입이다.(returnAddress type)

    숫자타입(numberic types)는 정수타입(integral type)과 부동소수점 타입(floating-point type)으로 나뉜다.

    정수타입

    • byte, 8-bit 부호붙은 2의보수 정수(8-bit signed two's-complement integers), 디폴트 0
    • short, 16-bit 부호붙은 2의보수 정수, 디폴트 0
    • int, 32-bit 부호붙은 2의보수 정수, 디폴트 0
    • long, 16-bit 부호없는 정수(16-bit unsigned integers), 유니코드 코드포인트(문자의 바이트코드)를 나타내며, UTF-16으로 인코딩되어있다. 디폴트 null code point('\u0000')

    부동소수점 타입은 IEEE754의 표준을 따른다.

    • float, whose values are elements of the float value set or, where supported, the float-extended-exponent value set, and whose default value is positive zero
    • double, whose values are elements of the double value set or, where supported, the double-extended-exponent value set, and whose default value is positive zero
    • 위 내용을 그냥 적은 이유는 아래에 관련 내용이 제대로 설명될 것 같아. 용어를 남겨 놓는다. (적절한 용어도 뭔지 모르겠음, 그냥 float,double 값들이랑, double-extended-exponent는 지수로 표현되는 값들을 말한다. 디폴트는 양수0으로 같다)

    불린타입(boolean type)은 참 거짓을 true, false로 부호화한다. 디폴트 false.

    • The First Edition of The Java® Virtual Machine Specification did not consider boolean to be a Java Virtual Machine type. However, boolean values do have limited support in the Java Virtual Machine. The Second Edition of The Java® Virtual Machine Specification clarified the issue by treating boolean as a type.

    returnAddress타입은 JVM명령어의 연산부호의 포인터다. primitives type에서 유일하게 Java Programming language type과 직접적으로 연관되어 있지 않다.

댓글 없음:

댓글 쓰기