This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 244500 - Array allocations done via Array.newInstance() are sometimes not tracked
Summary: Array allocations done via Array.newInstance() are sometimes not tracked
Status: RESOLVED FIXED
Alias: None
Product: profiler
Classification: Unclassified
Component: Base (show other bugs)
Version: 8.0
Hardware: All All
: P3 normal (vote)
Assignee: Tomas Hurka
URL:
Keywords: VISUALVM
Depends on:
Blocks:
 
Reported: 2014-05-15 07:33 UTC by Tomas Hurka
Modified: 2014-07-11 09:42 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Hurka 2014-05-15 07:33:07 UTC
If the array is initially allocated by Array.newInstance(), those allocations are not tracked. Once the array is allocated by ordinary new A[1] expression, subsequect allocation via Array.newInstance() are tracked. See simple test case below:

package allocref;
import java.lang.reflect.Array;

public class Allocref {

    public static void main(String[] args) {
        Allocref r = new Allocref();    
        r.test();
    }

    private void test() {
        for (int i=0; i<100; i++) {
            Allocref[] arr = (Allocref[]) Array.newInstance(Allocref.class, 1);
            arr[0] = new Allocref();
        }
    } 
}

in this example allocref.Allocref[] instances are not tracked. If the test case is changed to:

package allocref;
import java.lang.reflect.Array;

public class Allocref {

    public static void main(String[] args) {
        Allocref r = new Allocref();
        
        r.test();
    }

    private void test() {
        Allocref[] a = new Allocref[1000];
        for (int i=0; i<100; i++) {
            Allocref[] arr = (Allocref[]) Array.newInstance(Allocref.class, 1);
            arr[0] = new Allocref();
        }
    }
    
}

[note the change in the first line of the test() method]. Everything works fine and allocref.Allocref[] instances are tracked by profiler.
Comment 1 Tomas Hurka 2014-05-15 10:49:44 UTC
Fixed in profiler-main

changeset:   273718:c6bc270a3171
user:        Tomas Hurka <thurka@netbeans.org>
date:        Thu May 15 12:47:49 2014 +0200
summary:     bugfix #244500, set instrclassId for array class, but only if it is not already set
Comment 2 Quality Engineering 2014-05-15 19:36:36 UTC
Integrated into 'main-silver', will be available in build *201405151825* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/c6bc270a3171
User: Tomas Hurka <thurka@netbeans.org>
Log: bugfix #244500, set instrclassId for array class, but only if it is not already set