Delphi 代码到 Java 的转换
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1496626/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Conversion of Delphi code to Java
提问by
Does a parser exist for Delphi which can be used to convert the Delphi code into Java code automatically?
Delphi 是否存在可用于将 Delphi 代码自动转换为 Java 代码的解析器?
回答by Brian Rasmussen
I am not aware of such a converter, but keep in mind that such conversions will only get you so far.
我不知道有这样的转换器,但请记住,这样的转换只能让您到此为止。
For instance there's a Java to C# convert that ships with Visual Studio. It does an excellent job, but for anything beyond the most trivial example you still have to do a lot of cleanup/refactoring yourself in my experience. Also, bad code in the original language will usually get converted to just as bad or possible worse code in the new language. So the code will be hard to maintain.
例如,Visual Studio 附带了一个 Java 到 C# 的转换。它做得非常好,但除了最琐碎的例子之外,根据我的经验,你仍然需要自己做很多清理/重构。此外,原始语言中的糟糕代码通常会被转换为新语言中同样糟糕或可能更糟的代码。所以代码将很难维护。
The point is there's no free lunch. Even with a converter you most likely will have to do a significant bit of porting yourself. If that is out of the question (due to time, money, whatever) you may have to rethink the project.
重点是天下没有免费的午餐。即使使用转换器,您很可能也必须自己进行大量移植。如果这是不可能的(由于时间、金钱等原因),您可能需要重新考虑该项目。
I am sorry I could not point you to a useful tool (hopefully others will) but I have seen these projects a couple of times and people are usually surprised by the cleanup work needed after a conversion.
很抱歉,我无法为您指出一个有用的工具(希望其他人会),但我已经看过这些项目几次,人们通常对转换后所需的清理工作感到惊讶。
回答by user181750
The best solution I can think of would be: grab a Java-Developer and do some extreme programming (you: reading the Delphi sourcecode and explaining to him what it should do - he: writing all down in Java)
我能想到的最佳解决方案是:找一个 Java 开发人员并进行一些极限编程(你:阅读 Delphi 源代码并向他解释它应该做什么 - 他:用 Java 写下所有内容)
Because even if you find a Delphi-to-Java Converter - it might produce bad sourcecode.
因为即使您找到了 Delphi-to-Java 转换器 - 它也可能会产生错误的源代码。
回答by mjn
Free Pascal supports compilation for the Java Virtual Machine (JVM):
Free Pascal 支持编译 Java 虚拟机 (JVM):
Java-bytecode target added to the Free Pascal compiler.
Java 字节码目标添加到 Free Pascal 编译器中。
A new target has been added to Free Pascal compiler. It is now possible to compile applications to Java bytecode. This means that these Free Pascal applications can run in a Java Virtual Machine (JVM), so that it can run on any platform that has Java support.
Free Pascal 编译器中添加了一个新目标。现在可以将应用程序编译为 Java 字节码。这意味着这些 Free Pascal 应用程序可以在 Java 虚拟机 (JVM) 中运行,因此它可以在任何支持 Java 的平台上运行。
However, this target does only support the basic Pascal language and some functionality of the system unit.
然而,这个目标只支持基本的 Pascal 语言和系统单元的一些功能。
回答by Wael Dalloul
Before there was a program called Delphi2Jto convert, but I couldn't find the link to download it.
之前有个叫Delphi2J的程序可以转换,但是找不到下载链接。
Another way:
其他方式:
- Try to Convert Delphi code to C# code using the Delphi2CS
- Then use VB & C# to Java Converterthere is demo, I didn't try it.
- 尝试使用Delphi2CS将 Delphi 代码转换为 C# 代码
- 然后使用VB & C# to Java Converter有demo,我没试过。

