Team-CC-Corp / JVML-JIT

A continuation of JVML which JITs Java bytecode to Lua bytecode rather than interpreting.
MIT License
30 stars 4 forks source link

Closely Implement Java Standard Library #25

Open Yevano opened 10 years ago

Yevano commented 10 years ago

This is one of those issues which is gonna stay an issue for a really, really long time.

I think one of our goals should be to be able to run actual already created Java programs and libraries with little to no porting involved. Namely, the Java compiler would be extremely useful to be able to run within ComputerCraft, as it would mean we can actually write Java programs on servers and such where we don't have access to the external Java compiler.

Right now, most of the included classes have parts pruned as a matter of simplification. I think the approach we should take should be fairly relaxed. If we add new features which allows certain parts of classes to be implemented, we should try our best to implement those classes completely until we can do a direct copy-paste from the Java source and it just works.

We don't really need to worry about this too much until the actual VM is completely implemented. (Which is not too far down the road I think.) After that, the only obstacle is implementing the native methods which the library will depend on. Just looking at the Java source, the native runtime stuff is pretty intricate, so this will be somewhat difficult. I think that it might not be too bad to simplify the native backbone where we can in favor of getting all the rest of the actual Java stuff working, and then go back later and fill it out just for consistency.

tl;dr we should implement the standard library but vm and natives are the main obstacles so we should take it one step at a time.

Yevano commented 10 years ago

This is almost more like a milestone so I don't know if this should really be here, but I was just thinking about this so I wanted to write it quickly so I wouldn't forget. :P

glegris commented 10 years ago

Hi guys ! I could help to complete the standard library. But would you be ok if I use some code from other projects under a BSD license (I know JVML-JIT is licensed under MIT) ?

Yevano commented 10 years ago

I don't see why it would be a problem, but I'm also not very familiar with licensing. What projects were you thinking of using code from?

glegris commented 10 years ago

I think Avian (BSD license) is a good start. Harmony (Apache license), now included and improved in the Android core library, could be interesting too.

ElvishJerricco commented 10 years ago

As long as the code in the repo is legal for us to use and distribute, pull requests are always welcome.

glegris commented 10 years ago

Ok I'll start ASAP. Out of topic: I'm new to the project. Is there a way to develop/test without a ComputerCraft emulator (I planned to use CCEmuRedux) ? i.e. using vanilla Lua with a thin library which emulates CraftOS API ?

Yevano commented 10 years ago

It's probably not difficult. The jvml program handles creating the sandbox for the VM, so you could create any necessary proxy functions there.

Though tbh I've found it's not too difficult to just do tests in-game as long as you put a symbolic link to the repo inside a computer save.

ElvishJerricco commented 10 years ago

Yea I just use the regular game on a launcher profile that only has CC installed. It's pretty easy that way. I've been thinking about trying it with an emulator.

But in the regular lua VM, you're missing several APIs. It's probably not worth it to do it that way

glegris commented 10 years ago

I wrote a thin layer which emulates CC on Linux. The JVM works fine with vanilla Lua 5.1 now. Nevertheless I had to fix some visibility issues (e.g the natives table) in the JVM core.

Turakar commented 9 years ago

What do you think about creating a RT library as a seperate project and put it under the GPL v2/3, so we can use the openjdk7 source code (or wait for a openjdk8 version)? It would also make sense, as the JVML doesn't depend on the RT library.