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 187395 - Categorization mark algorithm is wrong .
Summary: Categorization mark algorithm is wrong .
Status: RESOLVED FIXED
Alias: None
Product: profiler
Classification: Unclassified
Component: Ide (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P2 normal (vote)
Assignee: issues@profiler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-09 17:23 UTC by Denis Anisimov
Modified: 2010-08-02 09:37 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
list all methods ( include inherited) instead of just enclosed (1.50 KB, patch)
2010-06-15 06:56 UTC, Denis Anisimov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Denis Anisimov 2010-06-09 17:23:01 UTC
There is a bug in source code of marking class methods.
F.e. J2SE configuration XML file for defining categories contains 
mark for method FileReader's "reset()" method.
This mark will not be created ( and as result will not me matched )
because "reset()" method is not FileReader's method.
This method belongs to Reader class and inherited by FileReader.
But algorithm for marks creation search methods which is defined only 
in class itself. Inherited methods are not included.
Comment 1 Denis Anisimov 2010-06-10 17:34:18 UTC
Set priority to P2 because there is consequence of this 
behavior : categorization works incorrectly for subtype marks.
F.e. consider the following scenario :
- Extend JPanel in your project.
- Use it somewhere in your project UI code.
- Profile this project. Choose only project classes option.

As result there will be no classes in UI category.
Classes will appear only if "All classes" option is chosen on profile dialog.
This is incorrect because your custom class which extends JPanel is project class
and it subclass of JComponent. Its method "repaint()" must present in UI category.

The reason is the same as original issue description : "repaint()" method
is inherited from JComponent. But algorithm doesn't see this method because
it is not member of original class. As result mark for this method is not 
created and profiler runtime doesn't mark it also.
Comment 2 Tomas Hurka 2010-06-14 12:10:02 UTC
Can you, please, provide sample application and required steps to demonstrate this problem? Thanks.
Comment 3 Denis Anisimov 2010-06-15 06:39:41 UTC
Sorry , I have mistaken about UI category. 
JComponent configuration description contains only its own methods.

The problem is still true actually f.e. for IO Category .
There are Files subcategory which contains marks for FileReader subclasses.

Steps to reproduce:
1) Create J2SE project with main class
2) Put into main method :
        FileReader reader = new FileReader( new File(some_file));
        reader.read();
        JDialog dialog = new JDialog();
        dialog.setVisible(true);
3) Run profile on project with "Profile all classes" filer settings.
Look at drill down and live results: there are no IO category.
Live results contains method InputStreamReader.read() which is inherited by
FileReader class. This method should be categorized as IO/Files.
Comment 4 Denis Anisimov 2010-06-15 06:54:03 UTC
The easiest way to understand problem is the source code.
Just see the proposed patch :
diff -r 16b5f6a4d34b profiler/src/org/netbeans/modules/profiler/categories/MarkerProcessor.java
--- a/profiler/src/org/netbeans/modules/profiler/categories/MarkerProcessor.java        Fri Apr 09 11:02:22 2010 +0400
+++ b/profiler/src/org/netbeans/modules/profiler/categories/MarkerProcessor.java        Tue Jun 15 10:52:41 2010 +0400
@@ -272,7 +272,7 @@

             Set<ElementHandle<TypeElement>> allImplementors = new HashSet<ElementHandle<TypeElement>>();
             Set<ElementHandle<TypeElement>> implementors = controller.getClasspathInfo().getClassIndex().getElements(El
ementHandle.create(superElement), kind, scope);
-
+
             do {
                 Set<ElementHandle<TypeElement>> tmpImplementors = new HashSet<ElementHandle<TypeElement>>();
                 allImplementors.addAll(implementors);
@@ -301,9 +301,9 @@
         }
         try {
             controller.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED);
-
             // process all methods from the implementor
             for (ExecutableElement method : ElementFilter.methodsIn(type.getEnclosedElements())) {
+            //for (ExecutableElement method : ElementFilter.methodsIn( controller.getElements().getAllMembers(type))) {

                 if ((method.getKind() == ElementKind.METHOD) && !method.getModifiers().contains(Modifier.ABSTRACT)) {
                     if ((inclusive && restrictors.contains(method.getSimpleName().toString())) || (!inclusive && !restr
ictors.contains(method.getSimpleName().toString()))) {
                         try {
Comment 5 Denis Anisimov 2010-06-15 06:56:07 UTC
Created attachment 100077 [details]
list all methods ( include inherited) instead of just enclosed
Comment 6 Denis Anisimov 2010-06-15 13:41:13 UTC
I'm sorry for the wrong comments in the patch.
The string which is added should be uncommented.
The previous one should be deleted or commented :

//for (ExecutableElement method :
ElementFilter.methodsIn(type.getEnclosedElements())) {
for (ExecutableElement method : ElementFilter.methodsIn(
controller.getElements().getAllMembers(type))) {
Comment 7 Denis Anisimov 2010-06-16 14:25:44 UTC
changeset:   172914:fbf96a4d9a1e
user:        Denis Anisimov <ads@netbeans.org>
date:        Wed Jun 16 18:14:53 2010 +0400
summary:     Unit tests for J2SE project categorization feature and fixes for BZ#187395 and BZ#187397
Comment 8 Quality Engineering 2010-06-18 03:19:45 UTC
Integrated into 'main-golden', will be available in build *201006180001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/fbf96a4d9a1e
User: Denis Anisimov <ads@netbeans.org>
Log: Unit tests for J2SE project categorization feature and fixes for BZ#187395 and BZ#187397
Comment 9 J Bachorik 2010-08-02 09:37:59 UTC
Seems to be fixed in 6.9.1