|
Quick Lists
|
|
Bug ID:
|
6594219
|
|
Votes
|
0
|
|
Synopsis
|
Plugin loads Swing classes
|
|
Category
|
java_plugin:plugin
|
|
Reported Against
|
|
|
Release Fixed
|
,
6u10(b10) (Bug ID:2157252)
|
|
State
|
3-Accepted,
bug
|
|
Priority:
|
3-Medium
|
|
Related Bugs
|
6461817
,
6641440
,
6641564
,
6649414
|
|
Submit Date
|
17-AUG-2007
|
|
Description
|
Java plugin loads many Swing classes even if the applet does not use Swing, and Java console is off.
I configured plugin to run hprof (-Xrunhprof:heap=dump), and set 'Do not start console' in Advanced/Java console. Though my applet was AWT-only, 66 Swing classes were loaded - see attached hprof.txt.
I used Firefox2 and JDK 7 b17 on Linux, and the following applet:
import java.applet.Applet;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
public class T extends Applet {
public void start() {
final Frame f = new Frame("100% AWT");
f.add(new Button("Hit me if you can!"));
f.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent ev) {
System.out.println("Exiting!");
f.setVisible(false);
f.dispose();
}
});
f.pack();
f.setVisible(true);
}
}
Posted Date : 2007-08-17 12:57:29.0
|
|
Work Around
|
N/A
|
|
Evaluation
|
This is the thread that most likely triggers loading Swing classes (JDK7 b17):
com.sun.deploy.util.DeployUIManager.setLookAndFeel(DeployUIManager.java:84)
sun.plugin.util.PluginSysUtil$1.run(PluginSysUtil.java:66)
java.lang.Thread.run(Thread.java:644)
Posted Date : 2007-08-29 13:19:48.0
There's a way to specify the default LAF Swing will use, without having to load Swing classes. It is, to set the "swing.defaultlaf" property:
System.setProperty("swing.defaultlaf", "com.sun.java.swing.plaf.motif.MotifLookAndFeel");
Unfortunately getting system LAF name from Swing would need UIManager to be loaded :( You may want to borrow some logic from UIManager.getSystemLookAndFeelClassName().
Posted Date : 2007-09-19 17:05:24.0
There are several places where Swing classes are loaded. They were identified by running ArcTest applet - pure AWT - inside plugin on Windows.
The first problem is described above: DeployUIManager.setLookAndFeel(). This method can be rewritten to set system property "swing.defaultlaf" instead of setting LAF directly. Code that guesses system LAF should be copied from UIManager.
This method also puts current Metal theme name into themeMap. This map now seems unused. It was previously accessed from the restoreLookAndFeel() method, which was removed by Rita in version 1.21. I believe this code is now dead, so i suggest removing it.
The second problem is SwingUtilities.invokeLater() in sun.plugin.util.PluginSysUtil - needs to be replaced with EventQueue.
The third one is sun.plugin.AppletViewer which explicitly loads javax.swing.ImageIcon to work around a memory leak in Swing. The memory leak is hopefully fixed on the Swing side - see bug 6482575, fixed in 6u10b05. So hopefully the workaround can now be safely removed, but this needs to be verified.
Posted Date : 2007-12-13 14:42:34.0
|
|
Comments
|
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |