-
Bug
-
Resolution: Won't Fix
-
P4
-
None
-
1.2.2
-
x86
-
windows_nt
Name: krT82822 Date: 06/04/99
This report started life as a presumed javax.comm problem (or compatibility issue).
However, it appears that it's simply a problem with the JIT (probably due to handling of anonymous inner classes -- in this case, the
WindowListener). Am filing it for reference. Apparently, the problem does NOT show up with HotSpot, just with the existing
symcjit.
(This is the most RECENT info received from user, rcvd. 6/4/99:)
My program does not break without the JIT and I also tested the new HotSpot VM
(1.0fcs, mixed mode, build E) and it also works without any problem.
So the problem is probably in the JIT.
Thank you for your assistance,
Christian
> Subject: Re: (Review ID: 83750) jdk1.2.2 crashes in adding window listener while using javacomm 2.0
> Date: Fri, 4 Jun 1999 08:14:22 -0400 (EDT)
> From: Christian Stoeckl <###@###.###>
Dear Kevin !
Sorry for the confusion, it's my first bug report and I did not know what info
do you really need. Attached you'll find two selfconsistent files
CopperTest.works and CopperTest.breaks. I deleted as much as possible to keep
the code clear. In fact there ist almost nothing left of my code at all.
CopperTest.breaks crashes with the following output:
COM1
COM2
Exception in thread "main" java.lang.ClassCastException:
javax.comm.CommPortEnumerator
at java.awt.AWTEventMulticaster.add(AWTEventMulticaster.java:465)
at java.awt.Window.addWindowListener(Window.java:560)
at CopperTest.main(CopperTest.java, Compiled Code)
I'm using:
java version "1.2.2"
Classic VM (build JDK-1.2.2-U, native threads, symcjit)
and
javacomm 2.0
The properties file and dll for javacomm are unmodified from the SUN
distribution.
Thank you for the quick reply and sorry again for the confusion, I'll try to
be more specific in the future.
Christian
---------
Test cases -- "works" and "breaks" versions: (rcvd 6/4/99):
( 50 )% diff co*{eaks,works}
24c24,28
<
---
> WindowListener l = new WindowAdapter() {
> public void windowClosing(WindowEvent e) {
> System.exit(0);
> }
> };
37,41c41
< WindowListener l = new WindowAdapter() {
< public void windowClosing(WindowEvent e) {
< System.exit(0);
< }
< };
---
>
-----------------
// coppertest.breaks (.java):
import java.io.*;
import java.util.*;
import javax.comm.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class CopperTest implements Runnable , SerialPortEventListener, ActionListener {
static CommPortIdentifier portId;
static Enumeration portList;
InputStream inputStream;
static OutputStream outputStream;
SerialPort serialPort;
static CopperTest reader;
static JFrame frame;
public void actionPerformed(ActionEvent e) {
}
public static void main(String args[]) {
portList = CommPortIdentifier.getPortIdentifiers();
try {
UIManager.setLookAndFeel(
UIManager.getCrossPlatformLookAndFeelClassName());
} catch (Exception e) {
System.err.println("Couldn't use the cross-platform "
+ "look and feel: " + e);
}
WindowListener l = new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
};
while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
System.out.println(portId.getName());
if (portId.getName().equals("COM1")) {
reader = new CopperTest();
}
}
}
frame = new JFrame();
frame.addWindowListener(l);
frame.pack();
frame.setVisible(true);
}
public CopperTest() {}
public void run(){}
public void serialEvent(SerialPortEvent event) {}
}
// coppertest.works (.java):
import java.io.*;
import java.util.*;
import javax.comm.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class CopperTest implements Runnable , SerialPortEventListener, ActionListener {
static CommPortIdentifier portId;
static Enumeration portList;
InputStream inputStream;
static OutputStream outputStream;
SerialPort serialPort;
static CopperTest reader;
static JFrame frame;
public void actionPerformed(ActionEvent e) {
}
public static void main(String args[]) {
WindowListener l = new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
};
portList = CommPortIdentifier.getPortIdentifiers();
try {
UIManager.setLookAndFeel(
UIManager.getCrossPlatformLookAndFeelClassName());
} catch (Exception e) {
System.err.println("Couldn't use the cross-platform "
+ "look and feel: " + e);
}
while (portList.hasMoreElements()) {
portId = (CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
System.out.println(portId.getName());
if (portId.getName().equals("COM1")) {
reader = new CopperTest();
}
}
}
frame = new JFrame();
frame.addWindowListener(l);
frame.pack();
frame.setVisible(true);
}
public CopperTest() {}
public void run(){}
public void serialEvent(SerialPortEvent event) {}
}
-------------
------------------------------------
// test case in progress (altered from original user submission)
/*
Using:
java version "1.2.2"
Classic VM (build JDK-1.2.2-U, native threads, symcjit)
and
javacomm 2.0
the following code crashes:
*/
import javax.comm.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public class Test83750 {
public static void main(String args[]) {
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
try {
UIManager.setLookAndFeel(
UIManager.getCrossPlatformLookAndFeelClassName());
} catch (Exception e) {
System.err.println("Couldn't use the cross-platform "
+ "look and feel: " + e);
}
WindowListener l = new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
};
}
}
/*
with:
Exception in thread "main" java.lang.ClassCastException: javax.comm.CommPortEnum
erator
at java.awt.AWTEventMulticaster.add(Unknown Source)
at java.awt.Window.addWindowListener(Unknown Source)
at CopperControl.main(CopperControl.java, Compiled Code)
Compilation succeeds without any error in jdk1.2.2 and program
works with both jdk1.1.7 and swing and jdk1.2
*/
// original user submission follows: -----------------------------------
Using:
java version "1.2.2"
Classic VM (build JDK-1.2.2-U, native threads, symcjit)
and
javacomm 2.0
the following code crashes:
public static void main(String args[]) {
portList = CommPortIdentifier.getPortIdentifiers();
try {
UIManager.setLookAndFeel(
UIManager.getCrossPlatformLookAndFeelClassName());
} catch (Exception e) {
System.err.println("Couldn't use the cross-platform "
+ "look and feel: " + e);
}
WindowListener l = new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
};
with:
Exception in thread "main" java.lang.ClassCastException: javax.comm.CommPortEnum
erator
at java.awt.AWTEventMulticaster.add(Unknown Source)
at java.awt.Window.addWindowListener(Unknown Source)
at CopperControl.main(CopperControl.java, Compiled Code)
Compilation succeeds without any error in jdk1.2.2 and program
works with both jdk1.1.7 and swing and jdk1.2
(Review ID: 83750)
======================================================================