You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Spark Shen <sm...@gmail.com> on 2007/08/15 09:16:59 UTC

[classlib][beans] Another non-bug difference? (was [JIRA 1568] [classlib][beans] XMLDecoder(3 params).getExceptionListener() returns object on RI and 'null' on Harmony)

Hi, all
Seems JIRA 1568 needs further attention.

Even fixed 1568, harmony still prints some shocking stack trace. The test
case[1] given by 1568 will reveal this. Although this can be viewed as a
non-bug difference, print such shocking error message when constructing a
XMLDecoder may not be so elegant.
I have two alternatives to amend this behavior:

1. simplify the error message printed out by DefaultExceptionListener, as
the patch given below:
Index: beans/src/main/java/java/beans/XMLDecoder.java
===================================================================
--- beans/src/main/java/java/beans/XMLDecoder.java    (revision 566039)
+++ beans/src/main/java/java/beans/XMLDecoder.java    (working copy)
@@ -45,9 +45,10 @@

     private static class DefaultExceptionListener implements
ExceptionListener {

+        @SuppressWarnings("nls")
         public void exceptionThrown(Exception e) {
-            e.printStackTrace();
-            System.err.println("Continue..."); //$NON-NLS-1$
+            System.err.println(e.getClass().getCanonicalName() + ": "
+e.getMessage());
+            System.err.println("Continue...");
         }
     }



2. Delay inputStream parsing, moving it from constructor to other place like
readObject.

Or any other suggestions?

[1] test case given by https://issues.apache.org/jira/browse/HARMONY-1568
import java.beans.*;
import java.io.ByteArrayInputStream;

public class test {
   public static void main(String[] args) {
       System.out.println("res = " + new XMLDecoder(new
ByteArrayInputStream(new byte[] {1, 2}), new Double(1),
null).getExceptionListener());
    }
}

-- 
Spark Shen
China Software Development Lab, IBM

Re: [classlib][beans] Another non-bug difference? (was [JIRA 1568] [classlib][beans] XMLDecoder(3 params).getExceptionListener() returns object on RI and 'null' on Harmony)

Posted by Spark Shen <sm...@gmail.com>.
If delaying inputStream parsing to readObject method. Then a boolean
variable is needed to guarantee that parsing is done only once.  The
potential drawback is that, original implementation is instinctive thread
safe regarding to inputStream parsing, while using boolean we may need extra
efforts to guarantee thread safety or just give it up.2007/8/15, Yang Paulex
<pa...@gmail.com>:
>
> 2007/8/15, Spark Shen <sm...@gmail.com>:
> >
> > RI will print out 'res = class java.beans.Statement$1', with on
> exception
> > information.
> >
> > 2007/8/15, Yang Paulex <pa...@gmail.com>:
> > >
> > > 2007/8/15, Spark Shen <sm...@gmail.com>:
> > > >
> > > > Hi, all
> > > > Seems JIRA 1568 needs further attention.
> > > >
> > > > Even fixed 1568, harmony still prints some shocking stack trace. The
> > > test
> > > > case[1] given by 1568 will reveal this. Although this can be viewed
> as
> > a
> > > > non-bug difference, print such shocking error message when
> > constructing
> > > a
> > > > XMLDecoder may not be so elegant.
> > > > I have two alternatives to amend this behavior:
> > > >
> > > > 1. simplify the error message printed out by
> DefaultExceptionListener,
> > > as
> > > > the patch given below:
> > > > Index: beans/src/main/java/java/beans/XMLDecoder.java
> > > > ===================================================================
> > > > --- beans/src/main/java/java/beans/XMLDecoder.java    (revision
> > 566039)
> > > > +++ beans/src/main/java/java/beans/XMLDecoder.java    (working copy)
> > > > @@ -45,9 +45,10 @@
> > > >
> > > >      private static class DefaultExceptionListener implements
> > > > ExceptionListener {
> > > >
> > > > +        @SuppressWarnings("nls")
> > > >          public void exceptionThrown(Exception e) {
> > > > -            e.printStackTrace();
> > > > -            System.err.println("Continue..."); //$NON-NLS-1$
> > > > +            System.err.println(e.getClass().getCanonicalName() + ":
> "
> > > > +e.getMessage());
> > > > +            System.err.println("Continue...");
> > > >          }
> > > >      }
> > > >
> > > >
> > > >
> > > > 2. Delay inputStream parsing, moving it from constructor to other
> > place
> > > > like
> > > > readObject.
> > > >
> > > > Or any other suggestions?
> > >
> > >
> > > What's RI's behavior here?
> > >
> > > [1] test case given by
> > https://issues.apache.org/jira/browse/HARMONY-1568
> > > > import java.beans.*;
> > > > import java.io.ByteArrayInputStream;
>
>
> I think we can just follow RI here. Any drawbacks?
>
> > >
> > > > public class test {
> > > >    public static void main(String[] args) {
> > > >        System.out.println("res = " + new XMLDecoder(new
> > > > ByteArrayInputStream(new byte[] {1, 2}), new Double(1),
> > > > null).getExceptionListener());
> > > >     }
> > > > }
> > > >
> > > > --
> > > > Spark Shen
> > > > China Software Development Lab, IBM
> > > >
> > >
> > >
> > >
> > > --
> > > Paulex Yang
> > > China Software Development laboratory
> > > IBM
> > >
> >
> >
> >
> > --
> > Spark Shen
> > China Software Development Lab, IBM
> >
>
>
>
> --
> Paulex Yang
> China Software Development laboratory
> IBM
>



-- 
Spark Shen
China Software Development Lab, IBM

Re: [classlib][beans] Another non-bug difference? (was [JIRA 1568] [classlib][beans] XMLDecoder(3 params).getExceptionListener() returns object on RI and 'null' on Harmony)

Posted by Yang Paulex <pa...@gmail.com>.
2007/8/15, Spark Shen <sm...@gmail.com>:
>
> RI will print out 'res = class java.beans.Statement$1', with on exception
> information.
>
> 2007/8/15, Yang Paulex <pa...@gmail.com>:
> >
> > 2007/8/15, Spark Shen <sm...@gmail.com>:
> > >
> > > Hi, all
> > > Seems JIRA 1568 needs further attention.
> > >
> > > Even fixed 1568, harmony still prints some shocking stack trace. The
> > test
> > > case[1] given by 1568 will reveal this. Although this can be viewed as
> a
> > > non-bug difference, print such shocking error message when
> constructing
> > a
> > > XMLDecoder may not be so elegant.
> > > I have two alternatives to amend this behavior:
> > >
> > > 1. simplify the error message printed out by DefaultExceptionListener,
> > as
> > > the patch given below:
> > > Index: beans/src/main/java/java/beans/XMLDecoder.java
> > > ===================================================================
> > > --- beans/src/main/java/java/beans/XMLDecoder.java    (revision
> 566039)
> > > +++ beans/src/main/java/java/beans/XMLDecoder.java    (working copy)
> > > @@ -45,9 +45,10 @@
> > >
> > >      private static class DefaultExceptionListener implements
> > > ExceptionListener {
> > >
> > > +        @SuppressWarnings("nls")
> > >          public void exceptionThrown(Exception e) {
> > > -            e.printStackTrace();
> > > -            System.err.println("Continue..."); //$NON-NLS-1$
> > > +            System.err.println(e.getClass().getCanonicalName() + ": "
> > > +e.getMessage());
> > > +            System.err.println("Continue...");
> > >          }
> > >      }
> > >
> > >
> > >
> > > 2. Delay inputStream parsing, moving it from constructor to other
> place
> > > like
> > > readObject.
> > >
> > > Or any other suggestions?
> >
> >
> > What's RI's behavior here?
> >
> > [1] test case given by
> https://issues.apache.org/jira/browse/HARMONY-1568
> > > import java.beans.*;
> > > import java.io.ByteArrayInputStream;


I think we can just follow RI here. Any drawbacks?

> >
> > > public class test {
> > >    public static void main(String[] args) {
> > >        System.out.println("res = " + new XMLDecoder(new
> > > ByteArrayInputStream(new byte[] {1, 2}), new Double(1),
> > > null).getExceptionListener());
> > >     }
> > > }
> > >
> > > --
> > > Spark Shen
> > > China Software Development Lab, IBM
> > >
> >
> >
> >
> > --
> > Paulex Yang
> > China Software Development laboratory
> > IBM
> >
>
>
>
> --
> Spark Shen
> China Software Development Lab, IBM
>



-- 
Paulex Yang
China Software Development laboratory
IBM

Re: [classlib][beans] Another non-bug difference? (was [JIRA 1568] [classlib][beans] XMLDecoder(3 params).getExceptionListener() returns object on RI and 'null' on Harmony)

Posted by Spark Shen <sm...@gmail.com>.
RI will print out 'res = class java.beans.Statement$1', with on exception
information.

2007/8/15, Yang Paulex <pa...@gmail.com>:
>
> 2007/8/15, Spark Shen <sm...@gmail.com>:
> >
> > Hi, all
> > Seems JIRA 1568 needs further attention.
> >
> > Even fixed 1568, harmony still prints some shocking stack trace. The
> test
> > case[1] given by 1568 will reveal this. Although this can be viewed as a
> > non-bug difference, print such shocking error message when constructing
> a
> > XMLDecoder may not be so elegant.
> > I have two alternatives to amend this behavior:
> >
> > 1. simplify the error message printed out by DefaultExceptionListener,
> as
> > the patch given below:
> > Index: beans/src/main/java/java/beans/XMLDecoder.java
> > ===================================================================
> > --- beans/src/main/java/java/beans/XMLDecoder.java    (revision 566039)
> > +++ beans/src/main/java/java/beans/XMLDecoder.java    (working copy)
> > @@ -45,9 +45,10 @@
> >
> >      private static class DefaultExceptionListener implements
> > ExceptionListener {
> >
> > +        @SuppressWarnings("nls")
> >          public void exceptionThrown(Exception e) {
> > -            e.printStackTrace();
> > -            System.err.println("Continue..."); //$NON-NLS-1$
> > +            System.err.println(e.getClass().getCanonicalName() + ": "
> > +e.getMessage());
> > +            System.err.println("Continue...");
> >          }
> >      }
> >
> >
> >
> > 2. Delay inputStream parsing, moving it from constructor to other place
> > like
> > readObject.
> >
> > Or any other suggestions?
>
>
> What's RI's behavior here?
>
> [1] test case given by https://issues.apache.org/jira/browse/HARMONY-1568
> > import java.beans.*;
> > import java.io.ByteArrayInputStream;
> >
> > public class test {
> >    public static void main(String[] args) {
> >        System.out.println("res = " + new XMLDecoder(new
> > ByteArrayInputStream(new byte[] {1, 2}), new Double(1),
> > null).getExceptionListener());
> >     }
> > }
> >
> > --
> > Spark Shen
> > China Software Development Lab, IBM
> >
>
>
>
> --
> Paulex Yang
> China Software Development laboratory
> IBM
>



-- 
Spark Shen
China Software Development Lab, IBM

Re: [classlib][beans] Another non-bug difference? (was [JIRA 1568] [classlib][beans] XMLDecoder(3 params).getExceptionListener() returns object on RI and 'null' on Harmony)

Posted by Yang Paulex <pa...@gmail.com>.
2007/8/15, Spark Shen <sm...@gmail.com>:
>
> Hi, all
> Seems JIRA 1568 needs further attention.
>
> Even fixed 1568, harmony still prints some shocking stack trace. The test
> case[1] given by 1568 will reveal this. Although this can be viewed as a
> non-bug difference, print such shocking error message when constructing a
> XMLDecoder may not be so elegant.
> I have two alternatives to amend this behavior:
>
> 1. simplify the error message printed out by DefaultExceptionListener, as
> the patch given below:
> Index: beans/src/main/java/java/beans/XMLDecoder.java
> ===================================================================
> --- beans/src/main/java/java/beans/XMLDecoder.java    (revision 566039)
> +++ beans/src/main/java/java/beans/XMLDecoder.java    (working copy)
> @@ -45,9 +45,10 @@
>
>      private static class DefaultExceptionListener implements
> ExceptionListener {
>
> +        @SuppressWarnings("nls")
>          public void exceptionThrown(Exception e) {
> -            e.printStackTrace();
> -            System.err.println("Continue..."); //$NON-NLS-1$
> +            System.err.println(e.getClass().getCanonicalName() + ": "
> +e.getMessage());
> +            System.err.println("Continue...");
>          }
>      }
>
>
>
> 2. Delay inputStream parsing, moving it from constructor to other place
> like
> readObject.
>
> Or any other suggestions?


What's RI's behavior here?

[1] test case given by https://issues.apache.org/jira/browse/HARMONY-1568
> import java.beans.*;
> import java.io.ByteArrayInputStream;
>
> public class test {
>    public static void main(String[] args) {
>        System.out.println("res = " + new XMLDecoder(new
> ByteArrayInputStream(new byte[] {1, 2}), new Double(1),
> null).getExceptionListener());
>     }
> }
>
> --
> Spark Shen
> China Software Development Lab, IBM
>



-- 
Paulex Yang
China Software Development laboratory
IBM