Follow by Email

Friday, December 22, 2006

Java :(

In our Java project, I had some frustrating errors that I can't figure out till now.
The project is video streaming and I am using JMF.

I tried to send frame by frame at first. The client only displayed the first frame and stopped althought the server is showing the video correctly. I discovered after five days of tracing and testing the BufferedImage and ObjectStream and BufferToImage, that the problem was solved when I reallocated the byte array every time instead of reusing it!

Another one, using the RTPManager of JMF, both the server and the client was on the same machine, the program never worked when using 127.0.0.1, I had to use the actual IP of my machine (I wonder what if I was disconnect and don't have an IP ?)

Today I had a strange error too, I still didn't trace it. I initialize ActionEvent(this,0,"GotPlayer"), I get an exception telling me the the source (this) is null. I tried to ActionEvent(new Object(),0,"GotPlayer"), I got the same error too!

Please somebody have an answer tell me, I really got tired of that.

Ah, by the way, sometime we got an error in our MFC project, a line that assigns a function to a function pointer, we traced it, the funtion pointer is still = null after the assignment although the watch of the function itself (the right hand side of the assignment) was not null.

Either, the evil forces of darkness has conspired upon us, or this is really some programming myths that should be reserved for history cuz maybe after 1000 years the sercret will be unvield!

2 comments:

Badr said...

java is mysterious that way, it doesnt' always behave in a predictable way...still i'd go for it over the extremely easy, exremely stable C# anyday.

I guess this comes with the fact that its open source, allowing lots of people to develop libraries which might not be completely stable upon release.

i suggest that you seperate your project to modules and develop each seperatly then put them all together in the end, this limits the errors and stops complex errors to happen. also it makes it way easier to divide the work on team members.

Mohammad Nabil said...

I've always been afraid of the day that I don't understand why a program behaves in a certain way. That what made me very interested in low-level details in my very first begining. Like assembly language.
When it comes to Java, to be the same way sure about what caused an error like that, I need to know details about byte code and JVM, which I don't have time or didn't have time to dive into. This is actually a nightmare to me. Seeing myself wining like that on some errors makes me feel pathetic.

About open source thing, I'd assume the problem shall emerge from issues with integration. But that byte array issue seems really strange, it's a basic and primitive thing, how can such a bug emerge, regardless of open or closed source.

Sure dividing into modules is an essential thing. Anyway the project is super-tiny using the Java Media Framework(JMF). Although the most stupid package I've ever seen (stupid design and poor documentation and implementation), but it saved a lot of code, on the trade-off of wasting time trying to use it. Anyway thanks for the advice.