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.
In order to be able to provide static context information and return value of methods, three new classes need to be added: JPDAClassType - Representation of type of an object (class, interface, array) in the target VM. ClassVariable - Representation of an instance of java.lang.Class from the target VM. ReturnVariable - Representation of a return value from a method.
Created attachment 31781 [details] The new ClassVariable class.
Created attachment 31782 [details] The new JPDAClassType class.
Created attachment 31783 [details] The new ReturnVariable class.
Created attachment 31784 [details] Other changes associated with this API change, including test.
Please review this simple API change in DebuggerJPDA module, which is necessary for the new features: issue #28936 and issue #41113. Thanks.
I see how ReturnVariable is supposed to be used and have no comment about this. It is not clear to me from attachments why you need ClassVariable and JPDAClassType. How these will be used? What is relationship between these? ObjectVariable already provides list of static fields. Why do we need to duplicate this in JPDAClassType?
The JPDAClassType and ClassVariable are used in the Local Variables window, in a similar way how This and Super are used. JPDAClassType just represents the "Static" node, which is proposed in issue #28936. It needs the staticFields() method to display the fields below the "Static" node. There is no other way, because we do not have any instance, just the class type. So we can not use ObjectVariable. ClassVariable is for representation of "class" from issue #28936. Is this explanation sufficient?
Thanks for the review, I'm going to integrate this change tomorrow.
Sorry but can you wait for a while? I do not agree with concept of Super and This interfaces. They are just adding a lot of instanceof check when they are used. Why do you need these? To build some string sdisplyed in UI using if (obj instanceof This) { name = "foo "+obj.getName()} else if (obj instanceof That) { name = "bar "+obj.getName()} else ... Inherited or Static nodes are created in VariablesModelTreeFilterSI anyway and can work without these interfaces. What information is missing? You know the class so there should be ObjectVariable representing related instance of java.lang.Class. Then you can also find its static fields and create wrapping node for these.
The test seems to test just the ReturnVariable and not ClassVariable and JPDAClassType...
To Radim: Regarding This and Super: The views are full of "intanceof" checks. They get just an Object and they need to find out what it is about. So from this point of view this looks fine to me. It's just one instanceof check instead of another ;-) A snippet from VariablesNodeModel.getDisplayName(): if (o instanceof Field) return ((Field) o).getName (); if (o instanceof LocalVariable) return ((LocalVariable) o).getName (); if (o instanceof Super) return "super"; // NOI18N if (o instanceof This) return "this"; // NOI18N There is really no other way to do this, since we have strictly split implementation module (JPDA Debugger), which have access to JDI classes, from GUI module (JPDA Debugger UI), which does not have access to JDI classes. So if we should display "this" string, we need to have a representation of this in the API. Perhaps it could be done in another way, but it went through review in this form in the past. Regarding JPDAClassType and ClassVariable: No, I do not know the class! I have a static context, and the view need to diplay a list of static fields in the current class. Where can I get the information from? There might be no other variables in Local View? I can pass there the ObjectVariable, which represents the Class object. Fine, but how do I now that it is the "class" object and not a local variable? I need ClassVariable for that. Now how do I fing the static fields? ClassVariable.getAllStaticFields() returns static fields from java.land.Class class! It's not the class I have in the static context, which I'm interested in. I need JPDAClassType, which represents the type I have and JPDAClassType.staticFields() method to get the list of static fields in that class type. I didn't find a way how to do this without an API change, if you have some idea, let me know. This is just following the original design....
To Yarda: Yes, I didn't write tests for ClassVariable and JPDAClassType, they are not directly available from any API method, their implementation is just provided to views. There is no test for Field, etc, not test for Local Variables View and other views. JPDA tests contains just tests of what's provided directly by API methods.
After discussion with Martin I accepted proposed that are changes following the original design...
Thanks for comments, the API change together with the implementation is committed to trunk: /cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/models/AbstractVariable.java,v <-- AbstractVariable.java new revision: 1.42; previous revision: 1.41 RCS file: /cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/models/ClassVariableImpl.java,v /cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/models/ClassVariableImpl.java,v <-- ClassVariableImpl.java initial revision: 1.1 /cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/models/ClassesTreeModel.java,v <-- ClassesTreeModel.java new revision: 1.13; previous revision: 1.12 RCS file: /cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/models/JPDAClassTypeImpl.java,v /cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/models/JPDAClassTypeImpl.java,v <-- JPDAClassTypeImpl.java initial revision: 1.1 /cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/models/JPDAThreadImpl.java,v <-- JPDAThreadImpl.java new revision: 1.19; previous revision: 1.18 /cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/models/LocalsTreeModel.java,v <-- LocalsTreeModel.java new revision: 1.37; previous revision: 1.36 /cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/models/ObjectTranslation.java,v <-- ObjectTranslation.java new revision: 1.5; previous revision: 1.4 RCS file: /cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/models/ReturnVariableImpl.java,v /cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/models/ReturnVariableImpl.java,v <-- ReturnVariableImpl.java initial revision: 1.1 /cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/breakpoints/BreakpointImpl.java,v <-- BreakpointImpl.java new revision: 1.29; previous revision: 1.28 /cvs/debuggerjpda/ui/src/org/netbeans/modules/debugger/jpda/ui/models/Bundle.properties,v <-- Bundle.properties new revision: 1.31; previous revision: 1.30 /cvs/debuggerjpda/ui/src/org/netbeans/modules/debugger/jpda/ui/models/VariablesNodeModel.java,v <-- VariablesNodeModel.java new revision: 1.13; previous revision: 1.12 /cvs/debuggerjpda/ui/src/org/netbeans/modules/debugger/jpda/ui/models/VariablesTableModel.java,v <-- VariablesTableModel.java new revision: 1.14; previous revision: 1.13 RCS file: /cvs/debuggerjpda/api/src/org/netbeans/api/debugger/jpda/ClassVariable.java,v /cvs/debuggerjpda/api/src/org/netbeans/api/debugger/jpda/ClassVariable.java,v <-- ClassVariable.java initial revision: 1.1 RCS file: /cvs/debuggerjpda/api/src/org/netbeans/api/debugger/jpda/JPDAClassType.java,v /cvs/debuggerjpda/api/src/org/netbeans/api/debugger/jpda/JPDAClassType.java,v <-- JPDAClassType.java initial revision: 1.1 RCS file: /cvs/debuggerjpda/api/src/org/netbeans/api/debugger/jpda/ReturnVariable.java,v /cvs/debuggerjpda/api/src/org/netbeans/api/debugger/jpda/ReturnVariable.java,v <-- ReturnVariable.java initial revision: 1.1 /cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/expr/EvaluationContext.java,v <-- EvaluationContext.java new revision: 1.6; previous revision: 1.5 /cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/expr/Evaluator.java,v <-- Evaluator.java new revision: 1.30; previous revision: 1.29 /cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/expr/Expression.java,v <-- Expression.java new revision: 1.4; previous revision: 1.3 RCS file: /cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/expr/JDIObjectVariable.java,v /cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/expr/JDIObjectVariable.java,v <-- JDIObjectVariable.java initial revision: 1.1 /cvs/debuggerjpda/src/org/netbeans/modules/debugger/jpda/JPDADebuggerImpl.java,v <-- JPDADebuggerImpl.java new revision: 1.102; previous revision: 1.101 /cvs/debuggerjpda/test/unit/src/org/netbeans/api/debugger/jpda/testapps/MethodBreakpointApp.java,v <-- MethodBreakpointApp.java new revision: 1.3; previous revision: 1.2 /cvs/debuggerjpda/test/unit/src/org/netbeans/api/debugger/jpda/MethodBreakpointTest.java,v <-- MethodBreakpointTest.java new revision: 1.11; previous revision: 1.10 /cvs/debuggerjpda/api/apichanges.xml,v <-- apichanges.xml new revision: 1.15; previous revision: 1.14 /cvs/debuggerjpda/api/manifest.mf,v <-- manifest.mf new revision: 1.18; previous revision: 1.17 /cvs/debuggerjpda/api/nbproject/project.properties,v <-- project.properties new revision: 1.8; previous revision: 1.7 /cvs/debuggerjpda/nbproject/project.properties,v <-- project.properties new revision: 1.12; previous revision: 1.11
Verified ... and Closing all issues resolved into NetBeans 6.7 and earlier.