harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Zhang" <zhanghuang...@gmail.com>
Subject Re: [classlib] Enum ready to go
Date Wed, 07 Jun 2006 05:42:51 GMT
Exciting news! :)

And I also found some mocked enum classes (e.g. java.net.Proxy.Type
java.net.Authenticator.Request) had already been updated as real enum style!
:)

But things don't end. We should be aware of serialization issue of enum type
class, that means  readObject method may be overridden.

Following test case,which is  passeed on RI but failed on Harmony,
shows serialization problem.
    public void test_Type_serialize() throws IOException,
ClassNotFoundException {
        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        ObjectOutputStream out = new ObjectOutputStream(bout);

        Proxy.Type type = Proxy.Type.DIRECT;
        out.writeObject(type);
        out.flush();

        ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray
());
        ObjectInputStream in = new ObjectInputStream(bin);

        Proxy.Type deType = (Proxy.Type) in.readObject();
        assertSame(Proxy.Type.DIRECT, deType);
    }
Many enum type class serialization JIRAs are expected in the following days.
:)
On 6/7/06, Tim Ellison <t.p.ellison@gmail.com> wrote:
>
> Heads up that I completed the implementation of j.l.Enum today; so you
> can go mad and use enum types in classlib code for real now.
>
> I wrote a bunch of tests but if you could hammer on it and try to break
> it that would be good :-)
>
>
> If you take a look at the implementation [1] of valueOf(Class, String)
> it uses reflection to get the enum constant values.  I'm not sure how
> 'popular' the valueOf() method is, but since the values don't change
> they are a good candidate for being cached if it proves to be called
> frequently.  I'm happy to do that if people think it is worthwhile.
>
> Regards,
> Tim
>
>
> [1]
>
> http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/Enum.java?revision=412166&view=markup
>
> --
>
> Tim Ellison (t.p.ellison@gmail.com)
> IBM Java technology centre, UK.
>
> ---------------------------------------------------------------------
> Terms of use : http://incubator.apache.org/harmony/mailing.html
> To unsubscribe, e-mail: harmony-dev-unsubscribe@incubator.apache.org
> For additional commands, e-mail: harmony-dev-help@incubator.apache.org
>
>


-- 
Andrew Zhang
China Software Development Lab, IBM

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message