背景
了解java的基本类型,基本类型的大小和取值范围
platform:amd64
源码分析
在c++ standard 里面
类型 | 是否有符号 | 最小范围字节数 | type |
---|---|---|---|
char | implement defined [Type char is a distinct type that has an implementation-defined choice of “signed char” or “unsigned char” as its underlying type] | — | |
signed char | signed | — | signed type |
short int | signed | — | signed type |
int | signed | — | signed type |
long int | signed | — | signed type |
long long int | signed | — | signed type |
在linux 64位下面
java基本类型 | c/c++宏 |
---|---|
jint | int |
jlong | long |
jbyte | signed char |
jboolean | unsigned char |
jchar | unsigned short |
jfloat | float |
jdouble | double |
jsize | jint 也就是int |
// jdk/src/java.base/unix/native/include/jni_md.h
typedef int jint;
#ifdef _LP64
typedef long jlong;
#else
typedef long long jlong;
#endif
typedef signed char jbyte;
// jdk/src/java.base/share/native/include/jni.h
#ifndef JNI_TYPES_ALREADY_DEFINED_IN_JNI_MD_H
typedef unsigned char jboolean;
typedef unsigned short jchar;
typedef short jshort;
typedef float jfloat;
typedef double jdouble;
typedef jint jsize;