Jump to content
Sign in to follow this  
Slapstick

[Java] Solve most of your CTD probelms (maybe).

Recommended Posts

I just stumbled across this bug and since it seems that it likely affects a huge part of the Java API I thought I would post it in a separate thread to get more attention.

Short story

I've been attempting to attach a flashing light to a police car and the following code will cause a CTD.

// Assume we have a GameObject named "light"
RVEngine.setLightColor(light, Array.asList(0.3, 0.0, 0.0));

But the following code works perfectly

RVEngine.setLightColor(light, Array.asList(0.3f, 0.0f, 0.0f));

Long Story

The setLightColor function expects a GameObject and a list of "floats" as parameters. However, the Java default is to represent floating point numbers as "doubles". So the first example attempts to call RVEngine.setLightColor with a list of doubles, which causes a CTD.

In the second example I explicitly tell the compiler that the numbers are floats and the code works perfectly. I am just using setLightColor as an example here, but this bug seems to be pervasive.

Moral of the story

The TOH Java API is littered with List objects that don't specify what they are lists of. If you don't get the list element right it's back to the desktop for you.

Share this post


Link to post
Share on other sites

Good job Slapstick and thanks for sharing.

Would you mind to create a ticket here please:

https://dev-heaven.net/projects/jvm/issues

The CIT philosophy with observed vs expected, short bullet point repro steps + simple self contained demo mission would be best. Cheers!

(see https://dev-heaven.net/projects/cis/wiki/CIT#How-to-report-a-bug)

Share this post


Link to post
Share on other sites

Done. I've tried to follow the CIT philosophy as much as possible, but I didn't notice the ticket_template until just now... Is there any way to edit a bug report once I've submitted it? I can add an "update", but I don't see a way to go in a change my original report.

Share this post


Link to post
Share on other sites

Thanks Slapstick :)

Yes its somewhat hidden in the redmine interface.

After you click update, in the very top left of the edit area, there is a MORE button.

Once you click it, you are able to edit the ticket header and description.

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  

×