Playing with Pivot reveals AWT dependence on Swing

Pivot is an open-source Java framework for building Web and desktop applications, originated as an R&D effort at VMware. Its recent introduction has ignited some discussions (see here or here.) Pivot builds on top of AWT and, as its authors Greg Brown and Todd Volkert say “takes a number of design cues from Swing”, but does not rely on Swing in any way.

This latter fact has made me eager to try optimizing and packaging a Pivot application with Excelsior JET to see to what extent its download size and disk footprint may be reduced using our Java Runtime Slim-Down model. I have compiled PivotDemo, but, to my big surprise, Swing was not marked as “safe to remove”. So I run PivotDemo on HotSpot in verbose mode:


E:\TEMP\pivot>java -verbose -cp pivot-core.jar;pivot-wtk.jar;pivot-wtkx.jar;pivot-tutorials.jar pivot.wtk.DesktopApplicationContext pivot.tutorials.Demo | grep swing
[Loaded javax.swing.TransferHandler$HasGetTransferHandler from C:\Program Files\Java\jre1.6.0_03\lib\rt.jar]
[Loaded javax.swing.JComponent from C:\Program Files\Java\jre1.6.0_03\lib\rt.jar]
[Loaded javax.swing.JPanel from C:\Program Files\Java\jre1.6.0_03\lib\rt.jar]

After some discussion with Greg that took place in comments to his blog post Introducing Pivot, he has kindly pointed out that there is a dependence on Swing in AWT code!

Dmitry,

A grep for ‘javax.swing’ in the source of java/awt/* yields that Sun has built a dependency on Swing within AWT:


EventDispatchThread#checkMouseEventForModalJInternalFrame(...):
> if (modalComp instanceof javax.swing.JInternalFrame) { ...
Container#startLWModal(...)
> Component predictedFocusOwner = (this instanceof javax.swing.JInternalFrame) ? ((javax.swing.JInternalFrame)(this)).getMostRecentFocusOwner() : null;

I have also run grep on AWT sources and found some more Swing dependencies. For instance, javax.swing.JFrame is used in the definition of the interface java.awt.im.spi.InputMethodContext, java.awt.dnd.DropTarget uses javax.swing.Timer, and so on. :(

Putting aside the discussion of whether these dependencies are evil, I was able to get the download size of PivotDemo down to 9.3MB, and the disk footprint to 34.6 MB even with some Swing classes compiled. The natively compiled demo also seems to use a bit less memory than when run on Sun JRE 1.6.0_03, which is, by the way, a 13.9 MB download and occupies 79 MB on the disk.

I invite you to download the natively compiled PivotDemo and see for yourself. Comments and questions are most welcome.

Excelsior JET 6.4 Released, Introduces Encryption Of Program Data And Resources

I am glad to write that we have released Excelsior JET 6.4 today. This new version enhances protection of your optimized applications against reverse engineering and tampering by scrambling program data and resources. This includes string literals, reflection information, and any media and property files packed into the executable. On-demand decryption ensures that reflection and JNI remain fully functional, as opposed to name obfuscation, commonly used for protection of Java applications.

More new features and improvements:

  • Startup Optimizer improves the cold startup time of your applications;
  • Not-So-Dumb Compilation: now a settings change that has no impact on generated code results in a re-link instead of a full build;
  • At last, the Installation Toolkit supports inclusion of newer JET Runtime versions into update packages;
  • Faster AOT and JIT compilation;
  • Application performance improvements.

Excelsior JET 6.4 Beta 3 Available

I am pleased to announce the availability of Excelsior JET 6.4 beta 3. The final release is expected before the end of June. Please note that beta 3 is set to expire on July 2nd 2008.

What’s New in 6.4 (in brief):

  • Support for Java SE 6 Update 7 and J2SE 1.5 Update 15
  • Encryption of program data: string literals, reflection info, etc.
  • Encryption of resource files
  • Startup Optimizer
  • Not-so-dumb compilation aka Smart Compilation Level 0
  • JET Runtime updates support in JetPackII

Plus the usual:

  • Improved application performance
  • Faster JIT compilation
  • Faster AOT compilation

Your feedback is most welcome.