| Author |
Retrieving information of a class from a class file
|
Sujai Kaarthik
Ranch Hand
Joined: Dec 29, 2008
Posts: 162
|
|
Hi guys,
I chose 'Test Automation' as my final year project. My idea is to get a class file as the input from the user (like file attachment) and displaying all the methods in the class which asks for test data as arguments. I know we can retrieve class objects through Reflection API and it is not possible to use with my idea.
Is it possible to to get such information? If so, give me some ideas through which my idea can be implemented.
|
The greater danger for most of us is not that our aim is too high and we miss it, but that it is too low and we reach it
|
 |
Joe Harry
Ranch Hand
Joined: Sep 26, 2006
Posts: 8795
|
|
|
Like you pointed out, reflection is the only mechanism with which you can get the information about a class. What exactly do you want to acheive?
|
SCJP 1.4, SCWCD 1.4 - Hints for you, SCBCD Hints - Demnachst, SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
|
 |
Sujai Kaarthik
Ranch Hand
Joined: Dec 29, 2008
Posts: 162
|
|
Thanks for replying
In my project, the UI will request the user to select (like file attachment) a class file (may be source file). After selecting the class/source file, the user needs to click a button, which displays all the methods (in a table which comprises of method name and return type) in that class. Once a method(s) is selected from the table, the user needs to click OK, which directs to another page which displays the selected method's arguments in column, actual in another and expected in another. The user needs to enter the actual and expected and press TEST button. After this event, the test results will be displayed.
|
 |
Joe Harry
Ranch Hand
Joined: Sep 26, 2006
Posts: 8795
|
|
|
There is nothing complex in what you want to acheive. Use Reflection to get information about the class, display all the methods in a table, select a method that you want to test, display the arguments in a column with each argument having a set of expected and actual value for the arguments, call that particular method with those arguments and display the results in another page. What is the difficulty you have/
|
 |
Sujai Kaarthik
Ranch Hand
Joined: Dec 29, 2008
Posts: 162
|
|
No, there is no complexity in using Reflection. I needed to know, is there any other possible ways to achieve this thing
In using Reflection API, do we need a source code file or a class file?
|
 |
Freddy Wong
Ranch Hand
Joined: Sep 11, 2006
Posts: 959
|
|
In using Reflection API, do we need a source code file or a class file?
You need a class file.
|
SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
|
 |
Sujai Kaarthik
Ranch Hand
Joined: Dec 29, 2008
Posts: 162
|
|
thank you Shankar and Freddy
|
 |
Joe Harry
Ranch Hand
Joined: Sep 26, 2006
Posts: 8795
|
|
Sujai Kaarthik wrote:No, there is no complexity in using Reflection. I needed to know, is there any other possible ways to achieve this thing
In using Reflection API, do we need a source code file or a class file?
Ofcourse there are ways to do it (by writing something similiar like the reflection API) but why when already one is available. In any case, you need a class file without which you do not know what it inside it.
|
 |
 |
|
|
subject: Retrieving information of a class from a class file
|
|
|