任何Java字节码生成指南? [英] Any Java Bytecode Generation Guide?

查看:208
本文介绍了任何Java字节码生成指南?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在从 Pascal JVM字节码编写某种编译器。我们已经实现了一个表达式树生成,所以下一步应该是创建 .class 文件。你能建议任何指南/教程如何至少从一些静态数据生成任何 .class 文件?因为我已经googled了2个小时已经读了JVM规范,但我真的需要一些最简单的例子来开始开发整个东西。

we're writing some sort of compiler from Pascal to JVM Bytecode. And we've already implemented an expression tree generation, so the next step should be the creation of .class file. Can you suggest any guide/tutorial of how to generate any .class file at least from some static data? Because I've googled for 2 hours already and read JVM specification, but I really need some even simplest example to start developing the whole stuff.

推荐答案

实际上,您下载的 ASM 文件夹中有一个示例文件。它称为 Helloworld ,位于 examples 子文件夹中。它显示如何编译(从头开始生成) .class 文件对应于简单的hello world应用程序。它还显示如何从 .class 文件获取日期,但这是另一个故事。

Actually there is an example file inside ASM folder that you download. It's called Helloworld and it's located in examples subfolder. It shows how to compile (generate from scratch) .class file that corresponds to simple hello world app. It also shows how to get date from .class files but it's another story.

也许这是最好的方式,但是当你需要从java字节码生成开始,你需要一些基本的例子,这是一个好主意,看看

Maybe this is'n the best way, but when you need to start with java byte code generation and you need some basic examples it's a good idea to have a look at ASM and the examples that are bundled within standard package.

此外,Groovy使用ASM生成其代码:)

Moreover Groovy uses ASM to generate its code :)

这篇关于任何Java字节码生成指南?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆