Bug 163488 - Objects created by ObjectInputStream.readObject() are not registered
Objects created by ObjectInputStream.readObject() are not registered
Status: VERIFIED FIXED
Product: profiler
Classification: Unclassified
Component: Base
5.x
All All
: P2 (vote)
: 6.x
Assigned To: Tomas Hurka
issues@profiler
: VISUALVM
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-04-23 14:13 UTC by Tomas Hurka
Modified: 2009-06-05 08:48 UTC (History)
0 users

See Also:
Issue Type: DEFECT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Hurka 2009-04-23 14:13:25 UTC
Objects created by ObjectInputStream.readObject() are not registered by profiler and there such objects are not visible in memory life results or memory 
snapshot.
Comment 1 Tomas Hurka 2009-04-23 15:17:42 UTC
This is day one bug. Below is the test-case:

package javaapplication1;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;


public class Main {


    public static void main(String[] args) throws IOException, ClassNotFoundException {
        int size = 100000;
        int b = 0;
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(stream);
        for (int i = 0; i<size;i++) {
            A a = new A(i);
            oos.writeObject(a);
        }
        ByteArrayInputStream inStrem = new ByteArrayInputStream(stream.toByteArray());
        ObjectInputStream ois = new ObjectInputStream(inStrem);
        for (int i = 0; i<size;i++) {
            A a = (A) ois.readObject();
            if (a != null) {
                b++;
            }
        }
        System.out.println("done "+b);
    }

}

class A implements Serializable {
    int val;

    A(int v) {
        val = v;
    }
}

Profiler should see 200000 allocations of A, but only 100000 is reported.
  
Comment 2 Tomas Hurka 2009-04-23 20:07:52 UTC
Fixed in profiler-main
changeset:   128275:f3b2d11bfa7e
user:        Tomas Hurka <thurka@netbeans.org>
date:        Thu Apr 23 21:06:23 2009 +0200
summary:     bugfix #163488, constructor does not need to be invoked on 'newOpClassName' class; in case of de-serialization the constructor of the first 
non-serializable superclass is invoked instead

Comment 3 Quality Engineering 2009-04-25 07:24:53 UTC
Integrated into 'main-golden', will be available in build *200904250201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/f3b2d11bfa7e
User: Tomas Hurka <thurka@netbeans.org>
Log: bugfix #163488, constructor does not need to be invoked on 'newOpClassName' class; in case of de-serialization the constructor of the first non-serializable superclass is invoked instead
Comment 4 matusdekanek 2009-06-05 08:48:11 UTC
seems ok, makarking 'verified'


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo