继承与构成的区别(Difference between Inheritance and Composition)
组合和继承是一样的吗? 如果我想实现组合模式,那我该如何用Java呢?
Are Composition and Inheritance the same? If I want to implement the composition pattern, how can I do that in Java?
原文:https://stackoverflow.com/questions/2399544
最满意答案
更新:正如我昨天答应的,我添加了更多链接到列表。
UFFF。 没有多少文档! 最好的建议? 反编译,阅读和调整,看看它是如何做到的,并重新开始循环。 但是你没有要求这个建议,对吧? ;)
现在,还有几个地方会有一点点:
http://androidcracking.blogspot.com/search/label/smali这是最好的一个。 我甚至问这个人一个问题,他回答很快,所以去看看。
http://pallergabor.uw.hu/androidblog/dalvik_opcodes.html非常全面的表 - 很好的参考!
http://webchat.freenode.net/?channels=smali我从来没有尝试过,但它是在baksmali作者的谷歌代码页( http://code.google.com/p/smali/ )
http://forum.xda-developers.com/showthread.php?t=777707最后,这是一段我之前描述的一些关于Captivate相机的黑客的帖子。 你可以在这里跟踪diff,因为我对每个.diff文件做了一些评论。 好的东西从20号的帖子开始。
http://www.slideshare.net/paller/understanding-the-dalvik-bytecode-with-the-dedexer-tool有趣的幻灯片放映有一些基本概念。 好的开始的方式
http://sites.google.com/site/haynesmathew/home/projects/dalvik-notes甚至比典型的.smali更低的水平。 以后参考,但阅读不错。
http://jasmin.sourceforge.net/guide.html Smali语法基于Jasmin,所以这给出了很好的概念。
http://groups.google.com/group/apktool?pli=1有些讨论值得一读。 当你陷入困境的时候,也是一个很好的地方。
最后,但并非最不重要的是我使用的最有用的技巧:在java中开始编写非常基本的类和方法,然后编译它们然后baksmali你自己的代码。 你知道它是做什么的,所以这将会更容易遵循。
祝你好运!
UPDATE: As I promised yesterday, I added some more links to the list.
Ufff. Not much documentation around! Best advice? Decompile, and read, and tweak, and see how it did, and start the cycle again and again. But you did not ask for that advice, right? ;)
Now, there are a few places out there that wil lhelp a little bit:
http://androidcracking.blogspot.com/search/label/smali This is the best one. I even asked the guy a question and he answered very quickly, so go and take a look.
http://pallergabor.uw.hu/androidblog/dalvik_opcodes.html Very comprehensive table - good reference!
http://webchat.freenode.net/?channels=smali I never tried it, but it's on the google code page of the baksmali author ( http://code.google.com/p/smali/ )
http://forum.xda-developers.com/showthread.php?t=777707 Lastly, this is a post I made some time ago describing some hacks to the Captivate camera. You can follow the diffs in there as I comment a little bit on what each .diff file is doing. The good stuff starts at the post #20.
http://www.slideshare.net/paller/understanding-the-dalvik-bytecode-with-the-dedexer-tool Interesting slide show with some basic concepts. Good way to start.
http://sites.google.com/site/haynesmathew/home/projects/dalvik-notes Even more low level than the typical .smali. A reference for later, but a good read.
http://jasmin.sourceforge.net/guide.html Smali syntax is based on Jasmin, so this gives good concepts.
http://groups.google.com/group/apktool?pli=1 Some discussions there are worth reading through. Also a good place to search for when you're stuck in something.
And last, but not least, the most helpful trick I used: start coding very basic classes and methods in java, compile them and then baksmali your own code. You know exactly what it does, so it will be a lot easier to follow.
Good luck!
相关问答
更多-
当您创建应用程序代码时,apk文件包含一个.dex文件,其中包含二进制Dalvik字节码。 这是平台实际理解的格式。 但是,读取或修改二进制代码并不容易,所以有工具可以将其转换为人类可读的表示。 最常见的人类可读格式被称为Smali。 这与你提到的拆装工基本相同。 例如,假设你有类似的Java代码 int x = 42 假设这是第一个变量,那么该方法的dex代码很可能包含十六进制序列 13 00 2A 00 如果你运行baksmali,你会得到一个包含该行的文本文件 const/16 v0, 42 这 ...
-
Dalvik将不会处理一些事情,也不会处理与标准Java字节码完全相同的方法,尽管它们大部分都是非常先进的。 最严重的例子是运行时字节码生成和自定义类加载。 假设你想创建一些字节码,然后使用classloader来加载它,如果这个技巧可以在你的普通机器上工作,那么保证在Dalvik上不起作用,除非你改变你的字节码生成。 这阻止你使用某些依赖注入框架,大多数已知的例子是Google Guice(尽管我相信有些人可以这样做)。 另一方面,AspectJ应该使用字节码检测作为编译步骤(尽管我不知道如果有人尝试过) ...
-
更新:正如我昨天答应的,我添加了更多链接到列表。 UFFF。 没有多少文档! 最好的建议? 反编译,阅读和调整,看看它是如何做到的,并重新开始循环。 但是你没有要求这个建议,对吧? ;) 现在,还有几个地方会有一点点: http://androidcracking.blogspot.com/search/label/smali这是最好的一个。 我甚至问这个人一个问题,他回答很快,所以去看看。 http://pallergabor.uw.hu/androidblog/dalvik_opcodes.html非常 ...
-
为什么基于JVM堆栈和基于Dalvik VM的注册?(Why is the JVM stack-based and the Dalvik VM register-based?)[2022-05-24]
基于堆栈的虚拟机有一些属性与Java的设计目标非常契合: 基于堆栈的设计对目标硬件(寄存器,CPU特性)进行了很少的假设,因此可以在各种硬件上实现虚拟机。 由于指令的操作数很大程度上是隐含的,所以目标代码往往会更小。 如果您要通过缓慢的网络链接下载代码,这很重要。 使用基于注册的方案可能意味着Dalvik的代码生成器不必像制作性能代码一样努力。 运行在非常注册丰富的或注册表不佳的架构可能会妨碍达尔维克,但这不是通常的目标 - ARM是一个非常中等的架构。 我也忘记了Dalvik的初始版本根本不包括JIT。 ... -
这是不可能的。 有关详细信息,请参阅YouTube上关于Dalvik内部的Google IO 2008演示文稿。 包括Java和MS .NET的移动虚拟机不是完整的虚拟机,并且由于内存和性能限制,因此省去了允许完成所描述的部分。 its not possible. See the Google IO 2008 presentation on youtube about Dalvik internals for details. Mobile VMs including both Java and MS .N ...
-
是的,您甚至可以在理论上添加对C#的支持,这意味着您可以添加CLR / CLI支持,或者您喜欢的任何语言或VM。 所有的Android组件都是模块化的,整个操作系统都是可定制的,问题是这需要大量的资金,时间,技术诀窍以及最有可能的专利控制。 点击我的YouTube回复 这是关于Android的官方谈话。 Yes, you can even add a support for C# in theory, meaning that you can add a CLR/CLI support, or whatev ...
-
你在看什么是davlik字节码。 Java代码由dx工具转换为Dalvik字节码。 清单是一个单独的问题,我将在一分钟内解决。 实际上,当您编译Android应用程序时,dx工具会使用256个dalvik操作码将Java代码转换为字节码(与javac将标准JVM应用程序的Java字节码转换为Java字节码的方式相同)。 例如, invoke-super是一个操作码,它指示dvm(dalvik虚拟机)调用超类的方法。 同样, invoke-interface指示dvm调用接口方法。 所以你可以看到 super ...
-
如果我已正确理解你的问题:我正在考虑将问题提到的问题为apk(如果是这样,那么以下回答可能有助于ypu) 如果您的目标已连接到主机,则可以使用两种最常用的命令工具: activity manager (am) package manager (pm) 首先通过命令行adb install
例如: adb shell am start -a android.intent.action.MAIN -n com.android.settings/.Settings将启动设 ... -
这给出了dalvik vm中存在的每个操作码的所有细节,并给出了链接1中表中使用的所有指令格式 This gives all the details of each opcode present in the dalvik vm and this gives all the instruction formats used in the table in link 1
-
我发现问题出在哪里:当打印一个int数字(不是Integer对象)时,参数类型应该是'I'而不是'Java / lang / Integer'。 I found where the problem is : When print an int number (not an Integer object), the parameter type should be 'I' instead of 'Java/lang/Integer'.