Friday, February 27th, 2009

Ghosts in the machine – avoid using window.sun in Firefox as it starts the Java engine!

Category: Java, JavaScript, Mozilla

<p>Sometimes you find leftovers of old technology in browsers that blow your mind. One of these “ghost in the machine” problems exists in Firefox: if you use window.sun or function sun() in JavaScript you effectively start the Java VM.

There are a few “magic” properties on Mozilla’s DOMWindow interface for supporting LiveConnect that will initialize the Java plugin and all the baggage that comes with it (which, with modern Java plugins, means launching java.exe as a subprocess). Looking up these properties on the window object is all it takes.

There are a few more of these still in the Mozilla source code and they are part of the old Netscape LiveConnect engine. They are:

  • java
  • Packages
  • netscape
  • sun
  • JavaClass
  • JavaArray
  • JavaMember

Avoid these at all cost lest you want the performance of your JavaScript to be like a Java Applet.

Related Content:

  • Melissa, the ghost in the machine
    Three years ago today, IT departments around the world were battling with the Melissa...
  • Ghost town?
    A year after E-Business Review first looked at the ASP market, Nick Booth asks if it has lived up to the wild...
  • Shadow processes, the ghost in the BPM machine
    When employees fail to follow business process, it can kill efficiency and hurt the bottom line. Don't assume your BPM solution is a...
  • A computer ghost story
    The attacks only happened when there was no-one around. How come? Sten Kalenda...
  • Firefox security
    What if Firefox was as big a target as Internet Explorer? Would it still be the more secure option? Confessed Microsoft enthusiast Brien Posey...

Posted by Chris Heilmann at 2:18 am
5 Comments

+++--
3.8 rating from 17 votes

5 Comments »

Comments feed TrackBack URI

about:mozilla anyone? :)

Comment by sixtyseconds — February 27, 2009

I believe, the performance of Java Applet hundends times faster than Javascript.

The only performance problem with Java Applet- it’s startup time.

Comment by kazukin — February 27, 2009

I have to agree with kazukin. Too bad the JVM has to be started at each plugin object once, otherwise we’d had Ajax with Java instead of Javascript.

Comment by Snyke — February 27, 2009

“…means launching java.exe as a subprocess.”

Oddly, my Mac doesn’t seem to do this. Nor does my Linux VM. Hmm…I must be doing something wrong. :)

Comment by MichaelThompson — February 27, 2009

I would call that a smaller truth since it’s a microbenchmark.

Comment by ilazarte — March 2, 2009

Leave a comment

You must be logged in to post a comment.