-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
1.4.0, 5.0
-
x86, sparc
-
solaris_8, windows_xp
Name: gm110360 Date: 09/10/2003
FULL PRODUCT VERSION :
java version "1.4.2-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-rc-b24)
Java HotSpot(TM) Client VM (build 1.4.2-rc-b24, mixed mode)
FULL OS VERSION :
SunOS xxxxx 5.8 Generic_108528-16 sun4u sparc SUNW,Ultra-80
A DESCRIPTION OF THE PROBLEM :
When running a simple program that uses XMLEncoder, a meaningless set of error messages are generated.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac MatchSet.java
java MatchSet
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should silently write file test.xml
ACTUAL -
Produces these error messages:
java.lang.IllegalArgumentException: object is not an instance of declaring class
Continuing ...
java.lang.Exception: discarding statement XMLEncoder0.writeObject(MatchSet0);
Continuing ...
ERROR MESSAGES/STACK TRACES THAT OCCUR :
As described in "actual result"
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
The file should be called MatchSet.java:
import java.lang.reflect.*;
import java.beans.*;
import java.io.*;
public class MatchSet {
public MatchSet newInstance() {
return new MatchSet();
}
public static void main(String[] args) throws Exception {
try {
MatchSet o = new MatchSet();
write(o, new FileOutputStream("test.xml"));
} catch (Exception e) {
e.printStackTrace();
}
}
public static void write(MatchSet o, OutputStream os) throws Exception {
BufferedOutputStream bos = new BufferedOutputStream(os);
XMLEncoder enc = new XMLEncoder(bos);
enc.writeObject(o);
enc.close();
bos.close();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Comment out the method "newInstance()" and the test case will work.
If you can't have a method called newInstance() then at the very least it should be documented somewhere in the XMLEncoder docs. Ideally of course, there shouldn't be any problem calling your methods whatever you like.
(Incident Review ID: 187303)
======================================================================
FULL PRODUCT VERSION :
java version "1.4.2-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-rc-b24)
Java HotSpot(TM) Client VM (build 1.4.2-rc-b24, mixed mode)
FULL OS VERSION :
SunOS xxxxx 5.8 Generic_108528-16 sun4u sparc SUNW,Ultra-80
A DESCRIPTION OF THE PROBLEM :
When running a simple program that uses XMLEncoder, a meaningless set of error messages are generated.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac MatchSet.java
java MatchSet
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Should silently write file test.xml
ACTUAL -
Produces these error messages:
java.lang.IllegalArgumentException: object is not an instance of declaring class
Continuing ...
java.lang.Exception: discarding statement XMLEncoder0.writeObject(MatchSet0);
Continuing ...
ERROR MESSAGES/STACK TRACES THAT OCCUR :
As described in "actual result"
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
The file should be called MatchSet.java:
import java.lang.reflect.*;
import java.beans.*;
import java.io.*;
public class MatchSet {
public MatchSet newInstance() {
return new MatchSet();
}
public static void main(String[] args) throws Exception {
try {
MatchSet o = new MatchSet();
write(o, new FileOutputStream("test.xml"));
} catch (Exception e) {
e.printStackTrace();
}
}
public static void write(MatchSet o, OutputStream os) throws Exception {
BufferedOutputStream bos = new BufferedOutputStream(os);
XMLEncoder enc = new XMLEncoder(bos);
enc.writeObject(o);
enc.close();
bos.close();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Comment out the method "newInstance()" and the test case will work.
If you can't have a method called newInstance() then at the very least it should be documented somewhere in the XMLEncoder docs. Ideally of course, there shouldn't be any problem calling your methods whatever you like.
(Incident Review ID: 187303)
======================================================================