-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
6
-
x86
-
linux
FULL PRODUCT VERSION :
% java -version
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Server VM (build 1.6.0_01-b06, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux olaf 2.6.20-1.2944.fc6 #1 SMP Tue Apr 10 18:46:45 EDT 2007 i686 i686 i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Using a splash screen on an application that installs a tray icon crashes the JVM.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile application into a jar using the ant build.xml. Execute the jar. Using the -splash java command line option with the file 'ind_sm.png' will prevent the crash. Or, change the build.xml to use ind_sm.png instead of DukeWithHelmet-64.png as the splash screen will also avoid the crash. Different splash images may work on Java 1.6.0 but not work on 1.6.0_01.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Splash screen display, icon installed in system tray.
ACTUAL -
Splash screen displays, then JVM crashes in call to SystemTray.add(TrayIcon)
ERROR MESSAGES/STACK TRACES THAT OCCUR :
see hs_err.log in attachment
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package com.ess.test;
import java.awt.AWTException;
import java.awt.Image;
import java.awt.MenuItem;
import java.awt.PopupMenu;
import java.awt.SystemTray;
import java.awt.TrayIcon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedList;
import javax.imageio.ImageIO;
public class Tray
{
public static void main(String [] args)
{
if (SystemTray.isSupported())
{
new Tray();
}
else
{
System.err.println("System Tray not available ;-(");
System.exit(1);
}
}
public Tray()
{
SystemTray tray = SystemTray.getSystemTray(); // get the SystemTray instance
PopupMenu popup = new PopupMenu(); // create a popup menu
MenuItem item = new MenuItem("Exit");
item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
});
popup.add(item);
trayIcon = new TrayIcon(loadImage("/DukeWithHelmet-32.png"), "Pretty cool tray icon, no?", popup);
try
{
System.err.println("Goodbye, my friend...");
tray.add(trayIcon);
System.err.println("It's alive!");
}
catch(AWTException e)
{
System.err.println("Failed adding tray image");
System.exit(1);
}
}
private Image loadImage(String name)
{
Image img = null; // image loaded from jar file
InputStream stream = null; // input stream
try
{
stream = Tray.class.getResourceAsStream(name);
if(stream != null)
{
img = ImageIO.read(stream);
}
}
catch(IOException e)
{
e.printStackTrace();
System.exit(1);
}
finally
{
if(stream != null)
{
try { stream.close(); } catch(IOException e) { e.printStackTrace(); System.exit(1); }
}
}
return img;
}
private TrayIcon trayIcon;
}
Ant build.xml:
<?xml version="1.0"?>
<project name="tray" default="tray-jar" basedir=".">
<target name="tray-jar" depends="tray-compile">
<jar jarfile="classes/Tray.jar" basedir="classes">
<include name="com/ess/test/Tray**.class"/>
<manifest>
<attribute name="Main-class" value="com.ess.test.Tray"/>
<!-- <attribute name="SplashScreen-Image" value="ind_sm.png"/> -->
<attribute name="SplashScreen-Image" value="DukeWithHelmet-64.png"/>
</manifest>
</jar>
<jar jarfile="classes/Tray.jar" basedir="." update="true">
<include name="*.png"/>
<include name="*.gif"/>
</jar>
</target>
<target name="tray-compile" depends="prepare">
<javac srcdir="." destdir="classes" debug="on">
<include name="tray/**.java"/>
</javac>
</target>
<target name="prepare" depends="clean">
<delete dir="classes"/>
<mkdir dir="classes"/>
</target>
<target name="clean">
<delete dir="classes"/>
</target>
</project>
---------- END SOURCE ----------
% java -version
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Server VM (build 1.6.0_01-b06, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux olaf 2.6.20-1.2944.fc6 #1 SMP Tue Apr 10 18:46:45 EDT 2007 i686 i686 i386 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Using a splash screen on an application that installs a tray icon crashes the JVM.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile application into a jar using the ant build.xml. Execute the jar. Using the -splash java command line option with the file 'ind_sm.png' will prevent the crash. Or, change the build.xml to use ind_sm.png instead of DukeWithHelmet-64.png as the splash screen will also avoid the crash. Different splash images may work on Java 1.6.0 but not work on 1.6.0_01.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Splash screen display, icon installed in system tray.
ACTUAL -
Splash screen displays, then JVM crashes in call to SystemTray.add(TrayIcon)
ERROR MESSAGES/STACK TRACES THAT OCCUR :
see hs_err.log in attachment
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package com.ess.test;
import java.awt.AWTException;
import java.awt.Image;
import java.awt.MenuItem;
import java.awt.PopupMenu;
import java.awt.SystemTray;
import java.awt.TrayIcon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.io.InputStream;
import java.util.LinkedList;
import javax.imageio.ImageIO;
public class Tray
{
public static void main(String [] args)
{
if (SystemTray.isSupported())
{
new Tray();
}
else
{
System.err.println("System Tray not available ;-(");
System.exit(1);
}
}
public Tray()
{
SystemTray tray = SystemTray.getSystemTray(); // get the SystemTray instance
PopupMenu popup = new PopupMenu(); // create a popup menu
MenuItem item = new MenuItem("Exit");
item.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
});
popup.add(item);
trayIcon = new TrayIcon(loadImage("/DukeWithHelmet-32.png"), "Pretty cool tray icon, no?", popup);
try
{
System.err.println("Goodbye, my friend...");
tray.add(trayIcon);
System.err.println("It's alive!");
}
catch(AWTException e)
{
System.err.println("Failed adding tray image");
System.exit(1);
}
}
private Image loadImage(String name)
{
Image img = null; // image loaded from jar file
InputStream stream = null; // input stream
try
{
stream = Tray.class.getResourceAsStream(name);
if(stream != null)
{
img = ImageIO.read(stream);
}
}
catch(IOException e)
{
e.printStackTrace();
System.exit(1);
}
finally
{
if(stream != null)
{
try { stream.close(); } catch(IOException e) { e.printStackTrace(); System.exit(1); }
}
}
return img;
}
private TrayIcon trayIcon;
}
Ant build.xml:
<?xml version="1.0"?>
<project name="tray" default="tray-jar" basedir=".">
<target name="tray-jar" depends="tray-compile">
<jar jarfile="classes/Tray.jar" basedir="classes">
<include name="com/ess/test/Tray**.class"/>
<manifest>
<attribute name="Main-class" value="com.ess.test.Tray"/>
<!-- <attribute name="SplashScreen-Image" value="ind_sm.png"/> -->
<attribute name="SplashScreen-Image" value="DukeWithHelmet-64.png"/>
</manifest>
</jar>
<jar jarfile="classes/Tray.jar" basedir="." update="true">
<include name="*.png"/>
<include name="*.gif"/>
</jar>
</target>
<target name="tray-compile" depends="prepare">
<javac srcdir="." destdir="classes" debug="on">
<include name="tray/**.java"/>
</javac>
</target>
<target name="prepare" depends="clean">
<delete dir="classes"/>
<mkdir dir="classes"/>
</target>
<target name="clean">
<delete dir="classes"/>
</target>
</project>
---------- END SOURCE ----------
- duplicates
-
JDK-6510620 java -jar SwingSet2.jar Backtrace:
- Closed