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.
There is a problem with marks which assigned to methods on Profiling procedure. Methods could be marked via org.netbeans.lib.profiler.results.cpu.marking.MarkingEngine class method markMethod(int methodId,... ) . Which uses MarkMapper class: public Mark markMethod(int methodId, ProfilingSessionStatus status) { synchronized(mapper) { return mapper.getMark(methodId, status); } } This is the code of MarkMapper.getMark method : public Mark getMark(int methodId, ProfilingSessionStatus status) { if (status == null) { return Mark.DEFAULT; } synchronized (marksGuard) { Mark mark = (Mark) markMap.get(Integer.valueOf(methodId)); if (mark == null) { mark = MarkingEngine.getDefault().mark(methodId, status); // do mark the method markMap.put(Integer.valueOf(methodId), mark); } return mark; } } MarkingEngine class is singleton. So each call to its "markMethod" method delegate to the same MarkMapper class. As result "markMap" HashMap is used the same. Here is the problem : only the very first profile action uses empty MarkMapper.markMap HashMap. All subsequent "Proflile" action calls uses already filled map . This can lead to unexpected result. Methods with same id ( but different unrelated profile session ) could be marked incorrectly ( because of non-empty hash map ). Solution is : MarkMapper.markMap should be cleared on each "Profiler" start action. There are already methods for this : reset() which is called from stateChanged(MarkingEngine) method. The latter method is "observer" method of interface MarkingEngine.StateObserver. It is supposed to be called when new "Profile" action is called. But it called for WRONG INSTANCE of MarkMapper! MarkMapper is registered in the default lookup as MarkingEngine.StateObserver observer for MarkingEngine class. And it is set on "Profile" action call: MarkingEngine.getDefault().configure(ctg.getMappings(), Lookup.getDefault().lookupAll(MarkingEngine.StateObserver.class)); As result instance WHICH IS REGISTERED IN THE DEFAULT LOOKUP will be notified about change state for MarkingEngine. But MarkingEngine constructor uses DIFFERENT instance of MarkMapper : private MarkingEngine() { mapper = new MarkMapper(); } This latter mapper instance is used for methods marking. And it's method stateChanged() is never called . So it keeps state over different profiler runs. These runs could be performed on the same project which was modified dramatically between profiler runs or even for different projects. So such stateful behavior is very serious issue.
Yes, indeed :(
changeset: 173644:231fb0963173 user: Denis Anisimov <ads@netbeans.org> date: Thu Jul 01 20:39:48 2010 +0400 summary: Fix for IZ#187723, unit tests for J2SE project categorization feature.
Integrated into 'main-golden', will be available in build *201007080001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/231fb0963173 User: Denis Anisimov <ads@netbeans.org> Log: Fix for IZ#187723, unit tests for J2SE project categorization feature.