JVM 명세는 추상적인 개념을 제시하며 디테일한 부분은 구현체 개발자의 창의성을 해칠 수 있기 때문에 재량으로 남겨두었습니다.
Implementation details that are not part of the Java Virtual Machine's specification
would unnecessarily constrain the creativity of implementors.
예를 들어 런타임 데이터 영역의 메모리 레이아웃, 사용되는 가비지 컬렉션 알고리즘, JVM 명령어의 내부 최적화는 구현자의 재량에 맡겼습니다.
For example, the memory layout of run-time data areas, the garbage-collection algorithm used, and any internal optimization of the Java Virtual Machine instructions (for example, translating them into machine code) are left to the discretion of the implementor.
강제성이 없는 표현이라면 꼼꼼히 생각해보아야합니다.
단수표현, 복수 표현 역시 눈여겨 보아야 합니다.
- ex) A reference to an object is considered to have Java Virtual Machine type reference.
- 하나의 참조가 하나의 객체를 가리킬 수 있다는 문장입니다.
- 해당 문장은 하나의 참조가 반드시 하나의 객체만 가리켜야 한다는 강제성이 없습니다.
- 이것은 여러 참조가 하나의 객체를 가리켜도 문제가 없다는 뜻입니다.
JVM을 올바르게 구현하려면, 클래스 파일 형식을 읽을 수 있고, 그 안에 지정된 연산을 정확하게 수행할 수 있기만 하면 됩니다.
To implement the Java Virtual Machine correctly, you need only be able to read the class file format and correctly perform the operations specified therein.
| 구분 | JVM 종류 |
|---|---|
| Sun, Oracle | GraalVM, HotSpot, Maxine |
| 주요 구현 | IKVM, JamVM, Jikes RVM, OpenJ9 |
| 임베디드 | Android Runtime, JamaicaVM, Mika VM |
| 기타 | IcedTea, more… |
| 단종 | Apache Harmony, Dalvik, GCJ, JRockit, JX, Kaffe, KVM, Microsoft JVM, SableVM, Squawk, Jupiter, Excelsior JET, more… |
JVM에서 실행되는 컴파일된 코드는 하드웨어 및 운영 체제에 독립적인 바이너리 포맷(byte code)으로 표현되며 관용적으로 클래스 파일 포맷이라는 파일에 저장됩니다. 다만 이 역시 구현자 재량에 따라 달라질 수 있습니다.
Compiled code to be executed by the Java Virtual Machine is represented using a hardware- and operating system-independent binary format, typically (but not necessarily) stored in a file, known as the class file format.
클래스 파일 포맷은 플랫폼 종속적 객체 파일 형식에서 당연하게 여겨지는 바이트 순서와 같은 세부 사항도 명확히 규정되어 있습니다.
The class file format precisely defines the representation of a class or interface, including details such as byte ordering that might be taken for granted in a platform-specific object file format.
JVM은 Java와 마찬가지로 기본 타입 (Primitive Types)과 참조 타입 (Reference Types) 이 두가지 타입을 다룹니다.
Like the Java programming language, the Java Virtual Machine operates on two kinds of types: primitive types and reference types.
이에 따라, 변수에 저장되거나 인자로 전달되거나 메서드로부터 반환되거나 연산에 사용되는 값도 기본 값(primitive values)과 참조 값(reference values)으로 나뉩니다.
There are, correspondingly, two kinds of values that can be stored in variables, passed as arguments, returned by methods, and operated upon: primitive values and reference values.
JVM은 대부분의 타입 검사를 런타임 이전에 수행하는 것을 가정합니다.
일반적으로 컴파일러가 타입 검사를 수행하며, 이 경우 JVM 자체에서는 타입 검사를 할 필요가 없습니다
The Java Virtual Machine expects that nearly all type checking is done prior to run time, typically by a compiler, and does not have to be done by the Java Virtual Machine itself.
기본 타입의 값은 런타임 중에 태그를 붙이거나 검사할 필요가 없지만 JVM 명령어 집합은 피연산자 타입에 따라 명령어를 구분합니다.
// byte code iadd: int ladd: long fadd: float dadd: double
Values of primitive types need not be tagged or otherwise be inspectable to determine their types at run time, or to be distinguished from values of reference types.
JVM에서 참조형 변수는 참조 타입이라는 특별한 타입으로 인식합니다.
객체는 동적으로 할당된 클래스 인스턴스 또는 배열을 의미하며 JVM은 객체에 대한 명시적 지원을 포함합니다.
The Java Virtual Machine contains explicit support for objects.
An object is either a dynamically allocated class instance or an array.
A reference to an object is considered to have Java Virtual Machine type reference.
JVM 명세와 구현체는 구분되어 있으며, JVM 명세는 추상적 개념을 정의하고 세부 구현은 개발자에게 재량을 부여합니다.
JVM의 올바른 구현을 위해서는 클래스 파일 형식을 읽고 연산을 수행할 수 있어야 하며, 구현체와 명세를 모두 이해해야 합니다.
| 구분 | 내용 | 출처 |
|---|---|---|
| JVM 명세의 특성 | JVM 명세는 추상적 개념을 제시하며, 명령 실행 관련 부분은 구현체 개발자의 재량으로 남겨둠. | Oracle docs |
| 구현 세부사항 | 런타임 데이터 영역의 메모리 레이아웃, GC 알고리즘, JVM 명령어의 내부 최적화는 개발자 재량 | Oracle docs |
| JVM 올바른 구현 조건 | 클래스 파일 형식을 읽고, 그 안에 지정된 연산을 정확하게 수행할 수 있어야 함 | Oracle docs |
| JVM 구현체 종류 | GraalVM, HotSpot, Maxine, IKVM, OpenJ9, JamVM, Android Runtime 등 | Java VM Wikipedia |
| 단종된 JVM 구현체 | Apache Harmony, Dalvik, JRockit, GCJ, Kaffe 등 | Java VM Wikipedia |
| 클래스 파일 형식 | 하드웨어 및 OS 독립적인 바이너리 포맷(byte code)으로 표현되며, 클래스 파일 포맷으로 저장됨 | Oracle docs |
| 데이터 타입 | 기본 타입(Primitive Types)과 참조 타입(Reference Types)을 사용 | Oracle docs |
| 타입 검사와 명령어 집합 | 대부분의 타입 검사는 런타임 이전에 수행, JVM 명령어는 피연산자 타입에 따라 구분됨 | Oracle docs |
| 객체 처리 | 동적으로 할당된 클래스 인스턴스 또는 배열로서, JVM 참조 타입(reference)으로 조작됨 | Oracle docs |