本文只为提供更多信息之目的. 本文中提到的Google, Android, Delvik, Oracle, OpenJDK, JVM, Java 等均属于各自公司的商标或者专利产品.

本文转载请注明作者为 wlsmon@qq.com, 来自于 http://www.beansoft.biz/ .

 

首先, 虚拟机都是C/C++开发的.

Dalvik 的源码可以在这里下: http://android.git.kernel.org/?p=platform/dalvik.git;a=summary 然后点下面链接中的最后一个 snapshot 即可下载:

2010-07-01 Bruce Beare Don’t prelink dalvik for x86 64/15564/2 master commit commitdiff tree snapshot

Open JDK 6 的源码可以这里下: http://download.java.net/openjdk/jdk6/ 点击下面链接下载:

OpenJDK 6 source

 

下载完毕分别解压缩, 然后可以发现都有一个jni.h的文件, 打开来进行比较的结果, 令人惊讶, 大部分代码都几乎是一样的, 只是顶部的版权信息变了… 呵呵, 难怪会起纠纷. 其源代码的前100行分别如下所示:

OpenJDK Dalvik
   1: /*

   2:  * @(#)jni.h    1.62 06/02/02

   3:  *

   4:  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.

   5:  * SUN PROPRIETARY/CONFIDENTIAL.  Use is subject to license terms.

   6:  */

   7:  

   8: /*

   9:  * We used part of Netscape's Java Runtime Interface (JRI) as the starting

  10:  * point of our design and implementation.

  11:  */

  12:  

  13: /******************************************************************************

  14:  * Java Runtime Interface

  15:  * Copyright (c) 1996 Netscape Communications Corporation. All rights reserved.

  16:  *****************************************************************************/

  17:  

  18: #ifndef _JAVASOFT_JNI_H_

  19: #define _JAVASOFT_JNI_H_

  20:  

  21: #include <stdio.h>

  22: #include <stdarg.h>

  23:  

  24: /* jni_md.h contains the machine-dependent typedefs for jbyte, jint

  25:    and jlong */

  26:  

  27: #include "jni_md.h"

  28:  

  29: #ifdef __cplusplus

  30: extern "C" {

  31: #endif

  32:  

  33: /*

  34:  * JNI Types

  35:  */

  36:  

  37: #ifndef JNI_TYPES_ALREADY_DEFINED_IN_JNI_MD_H

  38:  

  39: typedef unsigned char    jboolean;

  40: typedef unsigned short    jchar;

  41: typedef short        jshort;

  42: typedef float        jfloat;

  43: typedef double        jdouble;

  44:  

  45: typedef jint            jsize;

  46:  

  47: #ifdef __cplusplus

  48:  

  49: class _jobject {};

  50: class _jclass : public _jobject {};

  51: class _jthrowable : public _jobject {};

  52: class _jstring : public _jobject {};

  53: class _jarray : public _jobject {};

  54: class _jbooleanArray : public _jarray {};

  55: class _jbyteArray : public _jarray {};

  56: class _jcharArray : public _jarray {};

  57: class _jshortArray : public _jarray {};

  58: class _jintArray : public _jarray {};

  59: class _jlongArray : public _jarray {};

  60: class _jfloatArray : public _jarray {};

  61: class _jdoubleArray : public _jarray {};

  62: class _jobjectArray : public _jarray {};

  63:  

  64: typedef _jobject *jobject;

  65: typedef _jclass *jclass;

  66: typedef _jthrowable *jthrowable;

  67: typedef _jstring *jstring;

  68: typedef _jarray *jarray;

  69: typedef _jbooleanArray *jbooleanArray;

  70: typedef _jbyteArray *jbyteArray;

  71: typedef _jcharArray *jcharArray;

  72: typedef _jshortArray *jshortArray;

  73: typedef _jintArray *jintArray;

  74: typedef _jlongArray *jlongArray;

  75: typedef _jfloatArray *jfloatArray;

  76: typedef _jdoubleArray *jdoubleArray;

  77: typedef _jobjectArray *jobjectArray;

  78:  

  79: #else

  80:  

  81: struct _jobject;

  82:  

  83: typedef struct _jobject *jobject;

  84: typedef jobject jclass;

  85: typedef jobject jthrowable;

  86: typedef jobject jstring;

  87: typedef jobject jarray;

  88: typedef jarray jbooleanArray;

  89: typedef jarray jbyteArray;

  90: typedef jarray jcharArray;

  91: typedef jarray jshortArray;

  92: typedef jarray jintArray;

  93: typedef jarray jlongArray;

  94: typedef jarray jfloatArray;

  95: typedef jarray jdoubleArray;

  96: typedef jarray jobjectArray;

  97:  

  98: #endif

  99:  

 100: typedef jobject jweak;

</p>
</p>
   1: /*

   2:  * Copyright 2006 The Android Open Source Project

   3:  *

   4:  * JNI specification, as defined by Sun:

   5:  * http://java.sun.com/javase/6/docs/technotes/guides/jni/spec/jniTOC.html

   6:  *

   7:  * Everything here is expected to be VM-neutral.

   8:  */

   9: #ifndef _JNI_H

  10: #define _JNI_H

  11:  

  12: #include <stdarg.h>

  13:  

  14: /*

  15:  * Primitive types that match up with Java equivalents.

  16:  */

  17: #ifdef HAVE_INTTYPES_H

  18: # include <inttypes.h>      /* C99 */

  19: typedef uint8_t         jboolean;       /* unsigned 8 bits */

  20: typedef int8_t          jbyte;          /* signed 8 bits */

  21: typedef uint16_t        jchar;          /* unsigned 16 bits */

  22: typedef int16_t         jshort;         /* signed 16 bits */

  23: typedef int32_t         jint;           /* signed 32 bits */

  24: typedef int64_t         jlong;          /* signed 64 bits */

  25: typedef float           jfloat;         /* 32-bit IEEE 754 */

  26: typedef double          jdouble;        /* 64-bit IEEE 754 */

  27: #else

  28: typedef unsigned char   jboolean;       /* unsigned 8 bits */

  29: typedef signed char     jbyte;          /* signed 8 bits */

  30: typedef unsigned short  jchar;          /* unsigned 16 bits */

  31: typedef short           jshort;         /* signed 16 bits */

  32: typedef int             jint;           /* signed 32 bits */

  33: typedef long long       jlong;          /* signed 64 bits */

  34: typedef float           jfloat;         /* 32-bit IEEE 754 */

  35: typedef double          jdouble;        /* 64-bit IEEE 754 */

  36: #endif

  37:  

  38: /* "cardinal indices and sizes" */

  39: typedef jint            jsize;

  40:  

  41: #ifdef __cplusplus

  42: /*

  43:  * Reference types, in C++

  44:  */

  45: class _jobject {};

  46: class _jclass : public _jobject {};

  47: class _jstring : public _jobject {};

  48: class _jarray : public _jobject {};

  49: class _jobjectArray : public _jarray {};

  50: class _jbooleanArray : public _jarray {};

  51: class _jbyteArray : public _jarray {};

  52: class _jcharArray : public _jarray {};

  53: class _jshortArray : public _jarray {};

  54: class _jintArray : public _jarray {};

  55: class _jlongArray : public _jarray {};

  56: class _jfloatArray : public _jarray {};

  57: class _jdoubleArray : public _jarray {};

  58: class _jthrowable : public _jobject {};

  59:  

  60: typedef _jobject*       jobject;

  61: typedef _jclass*        jclass;

  62: typedef _jstring*       jstring;

  63: typedef _jarray*        jarray;

  64: typedef _jobjectArray*  jobjectArray;

  65: typedef _jbooleanArray* jbooleanArray;

  66: typedef _jbyteArray*    jbyteArray;

  67: typedef _jcharArray*    jcharArray;

  68: typedef _jshortArray*   jshortArray;

  69: typedef _jintArray*     jintArray;

  70: typedef _jlongArray*    jlongArray;

  71: typedef _jfloatArray*   jfloatArray;

  72: typedef _jdoubleArray*  jdoubleArray;

  73: typedef _jthrowable*    jthrowable;

  74: typedef _jobject*       jweak;

  75:  

  76:  

  77: #else /* not __cplusplus */

  78:  

  79: /*

  80:  * Reference types, in C.

  81:  */

  82: typedef void*           jobject;

  83: typedef jobject         jclass;

  84: typedef jobject         jstring;

  85: typedef jobject         jarray;

  86: typedef jarray          jobjectArray;

  87: typedef jarray          jbooleanArray;

  88: typedef jarray          jbyteArray;

  89: typedef jarray          jcharArray;

  90: typedef jarray          jshortArray;

  91: typedef jarray          jintArray;

  92: typedef jarray          jlongArray;

  93: typedef jarray          jfloatArray;

  94: typedef jarray          jdoubleArray;

  95: typedef jobject         jthrowable;

  96: typedef jobject         jweak;

  97:  

  98: #endif /* not __cplusplus */

  99:  

 100: struct _jfieldID;                       /* opaque structure */

</p>
</p>

转载请注明:WebLogic Android 博客 » Google Android Dalvik VM 源码涉嫌抄袭 Oracle OpenJDK JVM 源码?