简体   繁体   English

用Java和汇编语言构建在“裸机”上运行的系统

[英]building a system in Java and assembly language that runs on “bare metal”

Alright everyone, Let's say i wanted to make a system that used only assembly and java, my question would be, as long as i included all of the jvm folders, classes, jars, etc.. java should still function effectively? 好的,大家好,假设我想创建一个仅使用汇编语言和java的系统,我的问题是,只要我包括所有jvm文件夹,类,jar等。java仍应有效运行吗? i understand there are those things that are compiled platform specifically but this is why i am asking, is it possible, using assembly to replicate all of the .exe, or other executable files that java has included into a pure assembly/java system? 我知道有些东西是经过专门编译的平台,但是这就是为什么我要问的问题,有可能使用汇编将所有.exe或Java包含的其他可执行文件复制到纯汇编/ java系统中吗?

If you are asking whether it is possible to build a system in Java and assembly language that runs on "bare metal", the answer is yes. 如果您问是否可以用Java和汇编语言构建在“裸机”上运行的系统,答案是肯定的。 There are a couple of current examples: 当前有两个示例:

  • JavaOS is targeted primarily at the embedded systems domain. JavaOS主要针对嵌入式系统领域。 (Sun consider SunOS to be a "legacy" product line these days.) (最近,Sun认为SunOS是“传统”产品线。)
  • JNode aims are broader, and encompass embedded systems, desktop systems, servers and cloud computing. JNode的目标更广泛,涵盖嵌入式系统,台式机系统,服务器和云计算。

Be aware that building a system of this kind is a multi-year, multi-person project requiring deep understanding of virtual machine internals, compilers, garbage collectors, hardware architectures, device driver writing and so on. 请注意,构建这种系统是一个多年的,多人的项目,需要深入了解虚拟机内部,编译器,垃圾收集器,硬件体系结构,设备驱动程序编写等。

If you are asking about something else, please be more explicit. 如果您有其他疑问,请更加明确。

EDIT: responding to the OP's followup question: 编辑:回应OP的后续问题:

  1. It is not practical to use the Java and other "exe" files per se. 本身使用Java和其他“ exe”文件是不切实际的。 They require a fully fledged operating system underneath them; 它们要求在其下面有完整的操作系统。 eg Windows, Linux, whatever. 例如Windows,Linux等。 If you had access to the source code, you could conceivably rewrite as required to make them run on "bare metal", but that would entail significant architectural changes, especially if you want to write device drivers, etc in Java. 如果可以访问源代码,可以想象可以根据需要进行重写以使它们在“裸机”上运行,但是这将需要进行重大的体系结构更改,尤其是如果您想用Java编写设备驱动程序等。 (Besides, the core of Sun's JRE is implemented in C++ ... ). (此外,Sun的JRE的核心是用C ++实现的。)。
  2. You cannot directly use the existing Java class library JAR files, because they include a significant amount of platform specific code. 您不能直接使用现有的Java类库JAR文件,因为它们包含大量的平台特定代码。 However, you can build your own Java class library JARs from an existing open-source version of the Java class libraries (eg the OpenJDK 6.0 J2SE libraries). 但是,您可以从Java类库的现有开放源代码版本(例如OpenJDK 6.0 J2SE库)构建自己的Java类库JAR。 You deal with the platform specific code by providing your own versions as native libraries or (as JNode does) as Java classes. 通过提供自己的版本作为本机库或(如JNode一样)作为Java类来处理特定于平台的代码。

If I understand your question correctly, you mean something like JavaOS . 如果我正确理解您的问题,则表示类似JavaOS的意思。 Sure, its possible to implement the JVM raw on the hardware, not sure why you would, though. 当然,可以在硬件上实现JVM raw,但是不确定为什么要这样做。 And if you did, why you wouldn't use C instead of Assembly for most of the work. 而且,如果这样做了,为什么在大多数工作中不使用C而不是Assembly。

Its theoretically possible to implement the jvm in a whole other language. 从理论上说,可以用另一种语言实现jvm。 The best example I can think of is Python/Jpython where there is the original C implementation and a pure Java implementation of the language. 我能想到的最好的例子是Python / Jpython,其中有该语言的原始C实现和纯Java实现。

The main argumant against this is -- its a ton of work for not much benefit. 反对这一点的主要方法是-花费大量精力而不是很多工作。

The official Sun jvm and supporting jni libraries are written mostly in C, you would need to provide native assembler implementations for most of the C POSIX APIs at the very least. 官方的Sun jvm和支持的jni库主要是用C编写的,您至少需要为大多数C POSIX API提供本机汇编程序实现。

Also the original design goal of C was 'a portable assembly language' and to a large extent it still meets these goals. 同样,C的最初设计目标是“一种便携式汇编语言”,并且在很大程度上仍能满足这些目标。 C produces efficient machine code and most C compilers will let code machine instructions inline with the C code. C生成高效的机器代码,大多数C编译器将使代码机器指令与C代码内联。

Another benefit of C is the number of cross compilers available, you dont need to run the development environment on tHe target architecture, you can deveop and unit test on your favourite paltform/IDE, when you are ready you can then export your executables to the target platform. C的另一个好处是可以使用交叉编译器的数量,您不需要在目标体系结构上运行开发环境,就可以在自己喜欢的paltform / IDE上进行开发和单元测试,当您准备好之后可以将可执行文件导出到目标平台。

Jikes RVM and Sun's Maxine provide a JVM implementation with little (of the order of 1 kloc) native code. Jikes RVM和Sun的Maxine提供了很少的(大约1 kloc)本机代码的JVM实现。 However, both VMs require an OS and are only research implementations. 但是,两个VM都需要一个OS,并且仅是研究实现。 The process of creating a stream of octets that form machine code, is obviously achievable in Java. 在Java中显然可以实现创建形成机器代码的八位字节流的过程。

Have a look at JNode. 看看JNode。 They have been working on this for years. 他们已经为此工作了多年。

http://www.jnode.org/ http://www.jnode.org/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 裸机Java - Bare Metal Java Softlayer JAVA API示例获得“每小时/预设配置裸机服务器”的所有配置 - Softlayer JAVA API sample to get all the configurations for “Hourly/Pre-set Configuration Bare Metal Servers” 构建 java 语言的扩展 - 步骤? - Building an extension to the java language - Steps? 裸机wicket / tomcat HelloWorld示例 - bare metal wicket/tomcat HelloWorld example java - system.nanoTime() 运行速度太慢 - java - system.nanoTime() runs too slow 如何在 Java 中创建一个在后台运行另一种语言的 GUI? - How to create a GUI in Java that runs another language in the background? 在Java编程中更改系统语言。 - Change system language in java programming. 如何从Java调用用汇编语言代码编写的函数? - How to call a function written in assembly language code from java? IntelliJ IDEA 2019 运行 Java 11(在构建 Gradle 项目时)即使每个选项都设置为 Java 8? - IntelliJ IDEA 2019 runs Java 11 (when building Gradle project) even though every option set to Java 8? 与Java以外的其他语言在winxp上System.currentTimeMillis的准确性如何? - How accurate of System.currentTimeMillis on winxp with other language than Java?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM