harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anton Luht (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-812) transient fields are serialized
Date Tue, 11 Jul 2006 08:58:42 GMT
    [ http://issues.apache.org/jira/browse/HARMONY-812?page=comments#action_12420249 ] 

Anton Luht commented on HARMONY-812:
------------------------------------

Alexey,

I couldn't find a place in spec where it is stated, but found some third-party articles that
seem to contain same info:

http://www.awprofessional.com/articles/article.asp?p=417997&seqNum=8&rl=1

--
Each transient field in the reconstituted object is set to the default value for its type
--

e.g. int is set to 0, Objct to null, etc.

Maybe I've read about this in Bloch's "Effective Java"  - unfortunately I don't have this
book by me now and can't check this.

> transient fields are serialized
> -------------------------------
>
>          Key: HARMONY-812
>          URL: http://issues.apache.org/jira/browse/HARMONY-812
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>  Environment: Windows XP professional
>     Reporter: Anton Luht
>     Priority: Minor

>
> Classlib + VM version 419914 
> build: win_ia32_msvc_debug
> Fields that are marked as 'transient' are serialized though they shouldn't
> Code to reproduce:
> import java.io.*;
> public class Test {
>  public static void main(String[] args) throws Throwable {
>     ByteArrayOutputStream baos = new ByteArrayOutputStream();
>     ObjectOutputStream oos = new ObjectOutputStream(baos);
>     oos.writeObject(new Transient());
>     oos.close();
>     ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
>     Transient t = (Transient) ois.readObject();
>     ois.close();
>     System.out.println(t.trs == null ? "PASSED" : "FAILED");
>  }
> }
> class Transient implements Serializable {
>     transient String trs = "aaa";
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message