Jump to content

Recommended Posts

For a first version it is ok though still a long way to go.

I've produced already many CTDs (the game does not like Java Threads :D and of course there is no easy way currently to stop such a thread, it continues when preview has ended).

Performance is fine but I absolutely don't like that jcall blocks the game.

Creating singleton classes is fine (ofc).

Xeno

Share this post


Link to post
Share on other sites

I like! Can't wait for this to be fully implemented!

PS: I'm making some coffee, anyone else want some??

Edited by bobtom

Share this post


Link to post
Share on other sites

New SQF commands for JVM interaction: CMB repository diff (Updated: ToH SQF list to 89707.)

---------- Post added at 09:54 PM ---------- Previous post was at 09:45 PM ----------

Some might find this useful:

You can check the RVI classes in the jniscripting.jar (located in .\TKOH\beta\jre\lib\ext)

1. Rename jar to zip

2. Extract zip file

3. Load bytecode class decompiler like http://java.decompiler.free.fr/?q=jdgui

4. Check source and have fun :bounce3:

Share this post


Link to post
Share on other sites
Sadly as far as i can tell the current state of affairs is not permissive of jython, however i only just spent 3 hours trying to learn how its held together. Since I'm not a fan of the java philosophy of if its to verbose it ain't verbose enough this makes me sad. Well i guess I'll have to learn java then. And i dont understand what im missing in the Initial Java documentation since for some it just seems to work.

What did you try for jython? I can't get the ScriptEngineManager to work because of a SecurityException upon its instantiation (I'm aiming for Jruby but because of this error it doesn't matter yet).

Share this post


Link to post
Share on other sites

The Java implementation currently lacks lots of things:

- You can only call static methods inside a class

- jLoad does not create an instance of the class (only possible via a static method, singleton for example, but that still doesn't mean that you can call a method class with jCall)

- The static method for jCall needs Object[] args as parameter and needs to return Object otherwise nothing happens

- Returning something in such a static method does nothing at all, the result is always null in sqf land

- Calling RVEngine scripting commands is not easy as the parameters sometimes do not fit or are simply wrong (try a missionNamespace setVariable in Java)

What is completely missing is encapsulation of game objects with Java classes like you find in scripting engines of other games (and I guess it won't happen).

Giving up on TOH Java for now, enough crashes and you are simply to limited in what you can do with it currently.

Maybe in a few months the situation will improve.

Xeno

Edited by Xeno

Share this post


Link to post
Share on other sites

Agree with Xeno what we currently have is far from what we may expect from Java. There is no need for Java if it to be stick to static procedure call.

What did you try for jython? I can't get the ScriptEngineManager to work because of a SecurityException upon its instantiation (I'm aiming for Jruby but because of this error it doesn't matter yet).

delete every files into jre/lib/security ...

Share this post


Link to post
Share on other sites
Agree with Xeno what we currently have is far from what we may expect from Java. There is no need for Java if it to be stick to static procedure call.

The problem imo is also that no BIS programmer can change or adjust things in the Oracle Java JRE like you can do with other scripting engines if you include them into a C/C++ app. You are limited to JNI which is not known for good performance when it comes to calls into native land and vice versa (tight long running loops with RVEngine scripting command calls into game land resulted mostly in either a stalled game, kill process ftw, or CTDs).

There must be a reason why no other game developer uses Java :)

But let's see how it develops.

Xeno

Share this post


Link to post
Share on other sites

There must be a reason why no other game developer uses Java :)

Xeno

Probably not supported by Xbox or PS3. :P

Share this post


Link to post
Share on other sites

IL-2 used Java, not sure if the sequel Cliff of Dover does.

Share this post


Link to post
Share on other sites
IL-2 used Java, not sure if the sequel Cliff of Dover does.

Ok, didn't know that. Then there must be a reason why they switched to C#/.NET in the successor Cliffs of Dover :p

Xeno

Share this post


Link to post
Share on other sites

Minecraft uses java too.

I couldn't think of any reason to use C# over java. Except for better MS product compatibility (DirectX ?).

Share this post


Link to post
Share on other sites
Minecraft uses java too.

Yeah, because it's completely written in Java...

I couldn't think of any reason to use C# over java. Except for better MS product compatibility (DirectX ?).

It's not a question about Java or .NET/C# it is a question of what you can do with a scripting engine or better, what limitations you have to face.

And with the current limitations it does not make much sense to use it (and I doubt that it will change massively in the future).

There's also LUA which can be embedded quite nicely into games or C/C++ apps (widely used), source code available. Mono the same (also widely used, even Microsoft uses it in a Kinetic product via the Unity engine).

Anyways, I've removed everything related to Java and bail out here.

Xeno

Share this post


Link to post
Share on other sites

People should remember not all babies are born beautiful but can become so with Nuture and direction :)

I think there should be better explanation than , hmm java wont do for what i want so its not good ?

things like this cannot be good for anybody especially people who are developing it .

so far i see that the developers envisage this new tool to be helpful in things like Armex , is this what people are trying to replicate when they are reporting back it wont work ? or are they simply trying to see if there own ideas will work ?

I think for clarity people should write a paragraph on what they want to achieve and paste there code for how they have achieved it , or simply it will be Baah shit uninstalling and nobody get anywehre :(.

Share this post


Link to post
Share on other sites
The problem imo is also that no BIS programmer can change or adjust things in the Oracle Java JRE like you can do with other scripting engines if you include them into a C/C++ app. You are limited to JNI which is not known for good performance when it comes to calls into native land and vice versa (tight long running loops with RVEngine scripting command calls into game land resulted mostly in either a stalled game, kill process ftw, or CTDs).

There must be a reason why no other game developer uses Java :)

But let's see how it develops.

Xeno

Well I basically can't see the usefulness of this SQF JCall command into the SQF API. It is possible in JNI to create a JVM inside a C native process that will load a Java thread let say main.Java class. This main.Java would be the equivalent to the init.sqf. See this as an example: http://www.inonit.com/cygwin/jni/invocationApi/intro.html

Share this post


Link to post
Share on other sites
I think for clarity people should write a paragraph on what they want to achieve and paste there code for how they have achieved it , or simply it will be Baah shit uninstalling and nobody get anywehre :(.

I'd want to instantiate a ScriptEngineManager to run my ruby script from (the same?) directory where java files are; my ruby script would interface with java this have, so I'd call ruby->java->jni->Real Virtuality .Sounds bollocks?

Maybe, but I wouldn't want to recompile my code every time I make a change (Java) and would prefer less verbose Ruby sources.

Obviously this way doesn't work with SQF calling JNI into my Java-Code, and then round tripping from Ruby back; at least no sane people would do that.

It seem I'd rather want to register some "events" to be called/notified when certain things happen in the world/scene and interact them. Much like Minecraft/Bukket with their Plugin-Model (which of course is complete hack anyway because there's still no official but upcoming modding API for MC).

And I'd want to have run parts of my code in its own thread to do background stuff and such. All outside SQF and the editor.

Share this post


Link to post
Share on other sites

How did ruby get included in this? :) I thought Java was being added as an alternative to SQF, not a gateway to Ruby or whatever someone's favorite language is. Does Java do what it's supposed to do so far SQF wise? All the juggling of IDEs and libraries and sources and classes and needing to compile things has just aggravated me so far.

I've not had much luck with Java so far but I think it's mostly since I'm not familiar with how Java is supposed to work. Unfortunately those that are have either bailed, are doing different things or trying things waaay beyond what I understand. :)

Share this post


Link to post
Share on other sites

Initially I was a bit sceptical by your decision to go down the JVM path but after mulling it over for a little while and doing a bit of research I'm pretty much ambivalent about which VM you use. I'm just happy that you've finally decided to move away from a proprietry implementation and thus (hopefully) reduce your cost of ownership of the subsytem so as to redirect resource and architectural thoughts and efforts into other subsystems. Good-on-ya though for biting the bullet had to be done sometime.

I am still curious though as to why you chose a JVM route over CLR/CLI?

Cheers, Sy.

Share this post


Link to post
Share on other sites

Xeno is always very critical and his preference is in C# / . NET. :)

The crashes will be fixed surely, stability improved.

I very much doubt BI would accept it to be slower than SQF.

So even if it were at this point, it should get improved.

Will it allow everything, make everything better or easier - no.

As said before I believe at least for the start the main benefits are

1) external tools like IDE

2) easier to get into for real programmers compared to SQF

At the same time for self learner SQF people without programmers education or training,

the transition to Java/JVM will be steep too.

Share this post


Link to post
Share on other sites

Yeah I noticed the difficulty of going from C/C++/LSL to Java, but luckily there are some good books out there to help you (found one in my uni library, and have ordered a copy for myself). Also been doing the tutorials from netbeans which also help a lot, although some of them are slightly wrong (like the database one, it worked when i changed a little code but I couldn't get the embeded database tutorial to work at all).

You just need to get used to it, it becomes quite useful and easier to use once you have done some practicing (cant wait to the full update is out because i will try the Java then when it is a bit more ready)

Share this post


Link to post
Share on other sites
How did ruby get included in this? :)

:-)

Substitute it with anything which is not Java. For me, the important factor is the "VM" of "JVM" and not the "J". I use Java for business in my company. It's just not "fun". Replace it with any scripting language and it's fun to work with them, be it Python, Ruby, etc. Little offtopic: since Stackoverflow makes their whole data accessible, someone analysed on what particular days what kind of question where asked. Some not too scientific result was that during work days, more Java question get asked then on weekends, where python was leading (in this very comparison, at least). Can't find the link now, unfortunately. But: go figure :-)

Share this post


Link to post
Share on other sites

Will it allow everything, make everything better or easier - no.

As said before I believe at least for the start the main benefits are

1) external tools like IDE

2) easier to get into for real programmers compared to SQF

Additionally, while skimming through the methods available to the RV lib I discovered some commands that were not available over SQF/SQS. Just didn't have time to test if they are functional.

@rfc: I know what you mean. But what makes java not "fun" in the work environment is mostly the corporate stuff that comes with it. Stuff like "I don't comment because the code says it all", overdone structure for small projects, mostly rigid (and bogged down) procedures and last but not least the ages it takes to upgrade versions or switch frameworks. I have fun coding java the way I want. Though I think I'd enjoy python a lot more with type safety. As a java breather I'm in agony without variable initialization. xD

Share this post


Link to post
Share on other sites
:-)

Substitute it with anything which is not Java. For me, the important factor is the "VM" of "JVM" and not the "J". I use Java for business in my company. It's just not "fun". Replace it with any scripting language and it's fun to work with them, be it Python, Ruby, etc. Little offtopic: since Stackoverflow makes their whole data accessible, someone analysed on what particular days what kind of question where asked. Some not too scientific result was that during work days, more Java question get asked then on weekends, where python was leading (in this very comparison, at least). Can't find the link now, unfortunately. But: go figure :-)

Experience from the past 30 years in the software industry has shown that typed/constrained language make much robust program. Why ? Because even the best programmer in the world will mistaken sometimes. In firms like aeronautic or transportation where program reliability is critical they use language like Ada which is much more constrained than Java.

Share this post


Link to post
Share on other sites

All I really want out of this is a self contained (as much as possible when controlling an external App) environment which allows me to ultilise one IDE and gives me the ability to properly test addons and mods with code breaks, stepping and variable watching. Testing and bug fixing in native SQF can be a pain in arse as mostly these tools do not exist. At least by moving a lot of the control structures out to Java (or whatever) will allow for a more traditional development approach using IDE's like Eclipse.

What worries me about all this is that the community would become fragmented with people preferring different flavours of Java. At the moment people mostly provide code snippets in SQF with the occaisional and less frequent SQS. I can see that the knowledge base here in these forums will become more diluted as the amount of source languages used increases.

Also, in the new world, if I break open a PBO, what will I see? Will it be compiled code, Java source or some derivative language source? Although a lot of my SQF knowledge has come from these forums, I would say that most of it was gained by breaking open PBOs and seeing how it was done. Perhaps this is going to become more difficult to do? Ity would worry me greatly if the code in the resultant pbo was compiled as I would fear for the future of the community! I haven't looked into it enough to know if my fears are realistic or not though, so judgement will be reserved until people really start to use this.

Share this post


Link to post
Share on other sites

Also, in the new world, if I break open a PBO, what will I see? Will it be compiled code, Java source or some derivative language source? Although a lot of my SQF knowledge has come from these forums, I would say that most of it was gained by breaking open PBOs and seeing how it was done. Perhaps this is going to become more difficult to do? Ity would worry me greatly if the code in the resultant pbo was compiled as I would fear for the future of the community! I haven't looked into it enough to know if my fears are realistic or not though, so judgement will be reserved until people really start to use this.

You will see in PBO or rather JAR archive containing Java compiled code (i.e .class). Author could add source code (Java/JPython etc) or not because the game just seek for .class to load. That how current Java implementation works in TOH. But there is an other way possible technically speaking : missions/scripts/addons are made of Java source files (i.e .Java). These files are compilated to .class thanks to embeded javac compiler into the game and then the .class are loaded. The disadvantages of this is are:

-> only Java source files are accepted

-> longer time to load a missions/addons etc since the game need to compile the Java source files.

Share this post


Link to post
Share on other sites
You will see in PBO or rather JAR archive containing Java compiled code (i.e .class). Author could add source code (Java/JPython etc) or not because the game just seek for .class to load. That how current Java implementation works in TOH. But there is an other way possible technically speaking : missions/scripts/addons are made of Java source files (i.e .Java). These files are compilated to .class thanks to embeded javac compiler into the game and then the .class are loaded. The disadvantages of this is are:

-> only Java source files are accepted

-> longer time to load a missions/addons etc since the game need to compile the Java source files.

If community addons are going to contain compiled files only, I find that kind of sad really. I am not an advocate of stealing people's code wholesale (I'll always ask permission if I am going to do that), but it is certainly useful to see how other people have coded their solutions and I would say that most of us have taken a snippet of code here and there. My last addon contained a Dialog and if I hadn't been able to see how other people had done it (and just used the Wiki alone), I would probably had given up.

I guess it will be down to individuals whether they will include their source or not. Any addons I make with Java (and I will get involved) will have the source as I think it's important to keep things open.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×