Android面试之---Android的虚拟机Dalvik 介绍

Dalvik是Android的虚拟机,与基于栈的JVM不同,它基于寄存器,适合有限资源的设备。每个Android应用作为独立的Linux进程在Dalvik上运行,优化了内存使用。此外,Dalvik支持多种编程语言,如Scala,还有对Java兼容性的担忧,但Google强调其是为了解决Java ME平台的分裂和提供更灵活的许可证。Dalvik的开放源码和许可证使其在移动电话市场具有竞争力,但也引发了与Sun(现Oracle)的潜在法律纠纷。
摘要由CSDN通过智能技术生成

Dalvik和标准Java虚拟机(JVM)之间的首要差别之一,就是Dalvik基于寄存器,而JVM基于栈。一直以来都有人在猜测,选择基于寄存器的方式是因为它对提前优化(ahead-of-time optimization)提供了更好的支持,而这对类似于移动电话这样的受限环境是颇有裨益的。另一份针对基于寄存器虚拟机和基于栈虚拟机更深入的比较分析指出,基于寄存器的虚拟机对于更大的程序来说,在它们编译的时候,花费的时间更短。

  Dalvik和Java之间的另外一大区别就是运行环境——Dalvik经过优化,允许在有限的内存中同时运行多个虚拟机的实例,并且每一个 Dalvik应用作为一个独立的Linux进程执行。Neil Bartlett指出,给每一个应用赋予独立的进程可以允许动态安装、激活和去激活,但是他对Dalvik为什么要选择这种方式而没有使用OSGi在单一进程中实现表示疑问——Radoslav Gerganov回复说,独立的进程可以防止在虚拟机崩溃的时候所有程序都被关闭。Carl Rosenberger也指出OSGi也可以被移植到Android平台,而Jilles van Gurp对Google为何选择重新实现若干组件,如跨进程通信,表示疑问。

  此外,Java也已经不再是人们在Dalvik上开发所选择的唯一语言了——已经有人在Dalvik上运行Scala取得了成功,并且Hecl也已经被成功移植了。另外更有人对运行Groovy做了一次尝试,不过目前为止还不怎么成功。Mono项目的创始人Miguel de Icaza也对在Dalvik源码公开之后将Mono整合到Dalvik上表示了兴趣,而且也已经有人猜测如何用多种方式来实现整合了,包括与随Android SDK提供的Java到Dalvik重编译器类似的CIL(Common Intermediate Language,通用

Android虚拟机Dalvik完整源码,宝贵资源,欢迎下载! This directory contains the Dalvik virtual machine and core class library, as well as related tools, libraries, and tests. A note about the licenses and header comments --------------------------------------------- Much of the code under this directory originally came from the Apache Harmony project, and as such contains the standard Apache header comment. Some of the code was written originally for the Android project, and as such contains the standard Android header comment. Some files contain code from both projects. In these cases, the header comment is a combination of the other two, and the portions of the code from Harmony are identified as indicated in the comment. Here is the combined header comment: /* * Copyright (C) The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * ---------- * * Portions of the code surrounded by "// BEGIN Harmony code" and * "// END Harmony code" are copyrighted and licensed separately, as * follows: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ Native SH call bridge --------------------- Native SH call bridge is written by Shin-ichiro KAWASAKI and Contributed to Android by Hitachi, Ltd. and Renesas Solutions Corp.
评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值