What is the best way to convert an existing php class into Java?

前端 未结 15 1258
梦毁少年i
梦毁少年i 2021-02-09 14:07

I have been tasked with converting several php classes into java classes, which is quickly becoming a nightmare for me. I understand the basic language structure, it being simil

相关标签:
15条回答
  • 2021-02-09 14:50

    Caucho/Resin server converts PHP Code into Java servlets in run-time!

    0 讨论(0)
  • 2021-02-09 14:53

    You could probably write something with the Reflection API to do some of this, but you really couldn't do anything with function bodies - you'd end up with stub classes that have no implementation.

    0 讨论(0)
  • 2021-02-09 14:53

    It sounds like you're trying to convert PHP code that is procedural into an OO code base.

    This is not so much a question of PHP to Java, but rather a paradigm shift. There's no automated way to do it, it's going to be rough. Especially if one code base is badly written.

    Btw, I would also why are you converting? Is it just performance? And if so, is there nothing you can do to fix the performance issues. I don't think just converting from one language to another will fix it, you'll still have to find the bottleneck.

    0 讨论(0)
  • 2021-02-09 15:00

    Someone implied that Java is not as flexible as PHP : it is, by default, far more flexible actually (in that the core API contains thousands of classes and built-in functionality). You just have to learn the core concepts of both languages, such as autoboxing for Java, for example, to make room for dynamic types. Check out http://www.javaworld.com and I am currently working on porting a big API from PHP to Java, should take me a few days. Two classes, libcurl, json parsing, and maybe a hundred methods / functions.

    0 讨论(0)
  • 2021-02-09 15:01

    Check out http://www.numiton.com

    0 讨论(0)
  • 2021-02-09 15:04

    I've been looking into Groovy as a transition language from PHP to Java. They (the Groovy developers) claim that it compiles to java byte code the same as Java code would.
    It's also less strict, they have several examples of translation on their website.

    0 讨论(0)
提交回复
热议问题