Getting method parameters variable names

Hi,
I am trying to generate a list of methods, their parameter types as well as their localnames for a given class.
Example
TestClass
method1 (String name, int number)
method2 (Employee emp)
I checked the reflection API and it doesnt seem to give me the option to get the param name. Now its surely possible as some tools do it, like JBuilder whwne I type the method name, it give me the complete description.
Also javadocs provides the info. I wrote a subclassed doclet that provides the info, but the trouble is that I can run it from the command line using javadocs - doclet....
But how do I run it from code.
Any tips
Thanks in advance
Revon

hi,
there you are wrong: You can't retrieve the parameter name from a class file because this information isn't saved (otherwise this would have been a feature in the reflection api). Tools like JBuilder use the source files and the comment tags to retrieve further information.
best regards, Michael

Similar Messages

  • Get method parameters at runtime?

    Hey guys,
    is there a way to get the parameters of a methods parameters at runtime? I have a reference to an object and would like to know which paranmeter does a method have.?
       thx

    Hello
    You can use class CL_OO_CLASS (instance attribute METHOD_PARAMETERS ).
    Regards
      Uwe

  • How to get work area - Variable name at runtime

    hi all,
    in this snippet.
    how can we retrieve the field name.
    this write statement merely writes the contents stored.
    how is it possible to write the field name.............?
    DO.
            ASSIGN COMPONENT sy-index
                   OF STRUCTURE <wa> TO <comp>.
            IF sy-subrc = 0.
              WRITE / <comp>.
            ELSE.
              EXIT.
            ENDIF.
          ENDDO.
    Naveen...

    In More detail....
    Find the help ID for various fields:
    TYPES: MYTYPE LIKE SBOOK-CLASS.
    DATA: F1       LIKE SBOOK-LUGGWEIGHT,
          F2       TYPE MYTYPE,
          F3       LIKE F1,
          HLP(30)  TYPE C,
          NAME(30) TYPE C VALUE 'SBOOK-ORDER_DATE'.
    FIELD-SYMBOLS: <G1>, <G2>.
    DESCRIBE FIELD F1 HELP-ID HLP. WRITE: /(5) 'F1:', HLP.
    DESCRIBE FIELD F2 HELP-ID HLP. WRITE: /(5) 'F2:', HLP.
    DESCRIBE FIELD F3 HELP-ID HLP. WRITE: /(5) 'F3:', HLP.
    ASSIGN (NAME) TO <G1>.
    DESCRIBE FIELD <G1> HELP-ID HLP. WRITE: /(5) '<G1>:', HLP.
    ASSIGN F2 TO <G2>.
    DESCRIBE FIELD <G2> HELP-ID HLP. WRITE: /(5) '<G2>:', HLP.
    Result: The following help IDs are output:
       F1:   SBOOK-LUGGWEIGHT
       F2:   SBOOK-CLASS
       F3:   SBOOK-LUGGWEIGHT
       <G1>:
       <G2>: SBOOK-CLASS

  • What's user variable name using Smart View POV function (ex:HypGetActiveMember)?

    Hi,
    We want to use Smart View POV function (ex:HypGetActiveMember) to get the active member of user variables from HFM forms selected into Excel, but we don't know the user variable name in the following paragraph of Smart View developer guide:
    "To uniquely identify the user variable, provide the user variable name rather than the dimension name."
    For example, what's the user variable name of Year dimension? How to get the user variable name?
    Any information would be appreciated. Thank you!

    Hi,
    I guess user variable name is set by users/developers. I am not very clear on your question. If you have defined some variables to select any members from a dimension then it will be in HFM only. In planning we have two kinds of variables User Variables (we set it from Planning Preferences) and Substitution variable (we set it from Essbase Consol in the backend). Without looking into your application it is difficult to say the user variable name. Like for Year the user variables can be "PreviousYear", "CurrentYear", or "NextYear" etc.
    Soumya

  • How to get names of method parameters ?

    How to get names of method parameters (Not only their type and value) is it only possible during debugging ??
    for example void myFunction(int a,int b)
    I need the "a" , and the "b" The issiue is about the java.lang.reflect.InvocationHandler ,
    and its method invoke(Object proxy,
    Method method,
    Object[] args)
    throws Throwable
    I Have the parameter objects themself and their types using method.getParameters() , this is fine ,, but i need the names of the parameters !!!

    If the class file was compiled without debug information included then it is impossible to get the original parameter names, as used in the source code.
    However, If the class file does include debug information, then the method names are hidden deep within the class file. You'd need to parse the class file yourself. Check out a copy of the Java VM Specification for a detailed format of the java class file format.
    It's not a trivial task to parse the java class file, and the VM spec isn't easy reading. You'd nearly be writing a class file disassembler.

  • Obtaining custom HTTP GET / POST parameters of variable length in Application Process

    Hi, I'm trying to connect a javascript UI control within my page to an APEX Application Process.
    The control calls the application process via AJAX and appends a variable number of GET / POST parameters to its URL.
    What is the best way to obtain these parameters from within the PLSQL procedure of the process? Or is there a better way to connect my javascript AJAX control to the Database behind my APEX app?
    Thanks,
    Steffi

    Steffi,
    I'm using APEX 4.1 and I've not used Treegrid before. It does look pretty interesting.
    Firstly, I'm not sure if you are aware but GET requests aren't as secure as POST requests. GET simply appends a key/value pair to the server as part of the url which can be easily sniffed. POST request on the other hand sends the data as key/value pairs to the server in the header which makes it harder to intercept.  This is why APEX outputs forms with POST methods.
    Secondly, back to your original question.I'm not sure this is possible with an Application Process. In the passed I've used POST methods to pass values to my Application Process. I have some code using native jQuery if you would like to see how its done. Alternatively, if you convert your application process to a standard pl/sql procedure (i.e SQL Workshop>Object Browser>Procedures) you can call this procedure and pass in values as you would with any PHP page.
    Simple example (untested)
    CREATE OR REPLACE PROCEDURE  "foo" ( my_name varchar(20)  
         , count NUMBER)
    IS  
         p_name varchar(20) := my_name;
         p_count NUMBER     := count;
    BEGIN
    --Do what you want
    --output something
       htp.p(p_count || '.: '|| p_name);
    END;
    The url on the page (or ajax call) would be something like "/pls/apex/{MY SCHEMA}.foo?my_name=Alistair&count=1"
    Of course for text you will need to escape single colons and special characters etc.
    I would really like to help you further so if you could create a working demo using a free workspace on http://www.apex.oracle.com and provide me with demo username/password. I can try and have a better look for you.
    In all honesty, I'm sure you would be looking to create this as a plugin so that you can easily reuse it in various parts of your application and can easily update it or maintain it. I can help you with that as well if you want.
    Alistair
    P.S You might want to update your profile on this forum to provide your name so people dont just see "31742965-2d09-4f42-849f-e39eb2cfbc9e" your profile name

  • J2SE - Get Method Parameter Names

    Hello Gurus,
    I am trying to make a method in Java showing current running method's parameter name, the result will be some kind like below (showed in arrows):
    FUNCTION1()::BEGIN
    -TIME: 12-Jun-2013 05:39
    FUNCTION1()::PARAMETERS
    -PARAM01: val01 <!-------
    -PARAM02: val02 <!-------
    -PARAM03: val03 <!-------
    FUNCTION1()::ERROR
    -PATH: FUNCTION1()«FUNCTION2()«MAIN()
    -MSG : '/ by zero'
    FUNCTION1()::END
    So I want to retrieve the parameter names and values automatically and dynamically using the function. So far, after googling, information that I get is by using spring framework:
    private ParameterNameDiscoverer parameterNameDiscoverer;
    Method m = ... <!------ what should I put here?
    String[] names = parameterNameDiscoverer.getParameterNames(m).
    In my idea, when we call a function, e.g: public String function1(String str, int i) {} and we put the code inside, we will get the function's parameter names which are "str" and "i", also with their current values.
    Any help?

    Knowing the "true name" of the parameter gives one power over it?
    I suppose one could want to create dynamically generated documentation on arbitrary compiled code, or create some user interface to analyze objects/classes at runtime and call methods directly on them through some generically generated input fields. Perhaps as some sort of learning tool.
    In that case, it would be useful to know the parameter names when there's multiple, particularly of the same type. The names ideally would indicate their use... although you can't always assume that.
    Not that I can offer much help if the reflection classes don't provide for it already.

  • Unable to publish in Swf format. Get error message: 'Swf compilation failed. Note: Please verify if any of the actionscript keywords is used as user variable name'. Anyone know how to fix?

    Unable to publish in Swf format. Get error message reads: 'Swf compilation failed. Note: Please verify if any of the actionscript keywords is used as user variable name'. Anyone know how to fix?

    Hi There,
    Can you tell me the Operating System and Captivate version you are using?
    Also can you confirm if you are getting this issue will this one project or all the projects? Try to copy paste this project on a new blank project and then try to publish.
    Regards,
    Mayank

  • How to get the current class name in static method?

    Hi,
    I'd like to get the current class name in a static method. This class is intended to be extended. So I would expect that the subclass need not to override this method and at the runtime, the method can get the subclass name.
    getClass() doesn't work, because it is not a static method.
    I would suggest Java to make getClass() static. It makes sense.
    But in the mean time, does anybody give an idea to work around it?
    Thank you,
    Bill

    Why not create an instance in a static method and use getClass() of the instance?
    public class Test {
       public static Class getClassName() {
          return new Test().getClass();

  • Pass a variable name to a subroutine and use a method on it...

    How do I pass a variable name to a subroutine and then call a method on it?
    I have several swing text fields in a JForm. When someone enters a string in any of these fields, I want to check whether it is a number and, if now, clear that individual field and display a popup warning.
    So, I want to do something like....
    String stringcheck(String str, sometype variablename) {
            try {
                Integer.parseInt(str);
            } catch (NumberFormatException e) {
                JOptionPane.showMessageDialog(jPanel2, "These fields must be integer numbers.");
                variablename.setText("");
    }

    prometheuzz wrote:
    tsith wrote:
    prometheuzz wrote:
    NickSchurch wrote:
    thanks prometheuzz. I'm returning a string cos there are some other parts to the subroutine.Ah, now I understand.
    Well, good to hear you found a solution to it.You know, you really should have seen that from post 1.
    No offense, but seriously - does he have to draw you a picture?!
    I probably wouldn't understand the picture either: I'm not much of an art critic. Unless the OP is [Bob Ross|http://www.bobross.com/], his paintings, I understand.
    "I'm returning a string 'cos there's a happy tree over there, and I think I'll put a happy rock right here"

  • JSP : create variable dynamic variable name and get his value.

    //HI forums.sun.com !
    //What I want to do is above :
    //out.println("<td style=\"width: "+col_width_+h+" \">")
    //Variable Declaration
    String col_width_1 = "100px";
    String col_width_2 = "150px";
    //etc String col_width_N = "XXXpx";
    //loop
    for (int h = 0; h < hrecset.getRowCount(); h++)
    //some code
    //create the variable name (exemple : col_width_0 ) with the "loop counter name" to get the value
    out.println("<td style=\"width: "+col_width_+h+" \">")//Do you understand what i mean?
    //some code
    //Variable Declaration
    String col_width_1 = "100px";
    String col_width_2 = "150px";
    //etc String col_width_N = "XXXpx";
    //loop
    for (int h = 0; h < hrecset.getRowCount(); h++)
    //some code
    //create the variable name with a concat with the loop counter variable name to get the value of the concatened variable
    out.println("<td style=\"width: "+col_width_+h+" \">")//Do you understand what i mean?
    //some code

    I apologize
    1) Sure i understand it but i click on the "code" button after i inserted the text above but it doesn't worked now it do.
    2) Because the table element need to have the total width in the HTML table TAG equal to the addition of every HTML td TAG to be W3 conform
    because i have a lot of cell where i want to adjust the width.
    so here my solution
    <%
    //Variable für Breite
    String col_width_unit = "px"; // px, cm,
    Integer total_table_width = 0;
    String[] col_width=new String[3];
    col_width[0] =  "350";
    col_width[1] =  "75";
    col_width[2] =  "50";
    %>
    <table style="page-break-inside:avoid;width:<%=gesamt_table_width+col_width_unit%>;">
    <%
    for (int h = 0; h < hrecset.getRowCount(); h++)
    out.println("               <td id =\"cell"+h+"\" class=\"tdall\"  style=\"width:"+col_width[h]+col_width_unit+"\" >");               
    %>
    </table>thank you very much

  • XML Report displays Parameters instead of variable name

    I would like the actual variable name to be displayed in the XML report instead of "Parameters".  I have tried many things to make this happen with no success.  Any ideas?
    Solved!
    Go to Solution.

    Hello kwkengineer,
    What type of step are you utilizing, and which version of TestStand are you using?  I tried reproducing this behavior in TestStand 2012 with LabVIEW 2012 using a LabVIEW action step, passing a cluster of boolean arrays, and the result was the following:
    The parameters were set up as follows:
    Please let me know more details about your particular step, and I will try to reproduce the problem on my side.
    Warm Regards,
    Daniel D.
    National Instruments
    Automated Test Software R&D

  • How to get Variable name in output (Report Writer/Painter)

    Hello Experts,
    We have maintained one Repot by using Report Writer, this is the report for Cost center (periodic report), input fields are Fiscal year, Period and Cost Center. In out put system will display the selected cost center balances for individual cost element.
    Output: Excel format: in first sheet it will display balance of the total cost centers selected and from second sheet it will display individual cost center balances.
    My requirement is in the output system is displaying sheet name as CC1,CC2,CC3.......CC50, but my user want to display this as Cost Center 1, Cost Center 2, Cost Center 3...... like this. we have maintained variable name as Cost center 1, cost center 2....., but why system is displaying as CC1,CC2,.... .
    Please help me how to get the full description as sheet name in excel.
    Thanks ......Sudheer

    Hello Everybody,
    Please help me how to get variable name in Report Painter outout ( Excel format ).
    Thanks

  • I can't over give my variable to the return in the get Method!

    Hello Java Cracks
    At the moment I am working with JDOM. I am able to get access to the XML File with JDOM, but when I want to send, the value of a variable, which I get from the XML File it is not possible. When I try to send the variable to the get Method (getDtdVersion), the value I over give is always �null�. Please help me, and say what the problem is?
    I also post you the second class, where I want to use the variable I over give.
    Here is my code:
    Class 1, I take the String from this class. See the arrow
    package FahrplanXML;
    import java.io.File;
    import java.io.IOException;
    import javax.swing.JFileChooser;
    import javax.swing.filechooser.FileFilter;
    import org.jdom.Attribute;
    import org.jdom.Document;
    import org.jdom.Element;
    import org.jdom.JDOMException;
    import org.jdom.input.SAXBuilder;
    import org.xml.sax.InputSource;
    public class FileAuswahl {
    private File filenames;
    private String scheduledtdversion;
    public void ablauf() throws JDOMException, IOException {
    FileAuswaehlen();
    saxwer();
    grundoberflaeche xmloberflaeche = new grundoberflaeche();
    xmloberflaeche.grundoberflaechen();
    public void FileAuswaehlen() {
    JFileChooser datei = new JFileChooser();
    datei.setFileFilter(new FileFilter()
    @Override public boolean accept (File f)
    return f.isDirectory() ||
    f.getName().toLowerCase().endsWith(".xml");
    @Override public String getDescription()
    return "XML-Files";
    int state = datei.showOpenDialog(null);
    if (state == JFileChooser.APPROVE_OPTION )
    filenames = datei.getSelectedFile();
    System.out.println (filenames);
    if (filenames != null)
    try {
    System.out.print(filenames);
    saxwer();
    } catch (JDOMException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    else
    System.out.println("Kein File ausgew�hlt");
    else
    System.out.println("Auswahl abgebrochen");
    System.exit(0);
    //Ausgew�hlter Dateiname an saxwer �bergeben
    public File getNames() {
    System.out.println (filenames);
    return this.filenames;
    public void saxwer() throws JDOMException, IOException {
    //FileAuswahl filename = new FileAuswahl();
    File files = getNames();
    System.out.println (files);
    SAXBuilder builder = new SAXBuilder();
    Document doc = builder.build(files);
    Element schedulemessage = doc.getRootElement();
    //Root Element auslesen
    String sch_msg_dtdversion = schedulemessage.getAttributeValue ("DtdVersion"); // <---
    scheduledtdversion = sch_msg_dtdversion;
    new grundoberflaeche().grundoberflaechen();
    public String getDtdVersion() {
    System.out.println (scheduledtdversion);
    return this.scheduledtdversion;
    Now, you will see the class in which I pass the String. See also arrow...
    package FahrplanXML;
    import java.awt.Component;
    import java.awt.Container;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.IOException;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JTextField;
    import javax.swing.text.Caret;
    import org.jdom.Attribute;
    import org.jdom.JDOMException;
    public class grundoberflaeche {
    // Layout f�r Laender vorbereiten
    static void addComponent (Container cont,
    GridBagLayout diversemoegl,
    Component laenderdetails,
    int x, int y,
    int width, int height,
    double weightx, double weighty )
    GridBagConstraints grundoberflaechen = new GridBagConstraints();
    grundoberflaechen.fill = GridBagConstraints.BOTH;
    grundoberflaechen.gridx = x; grundoberflaechen.gridy = y;
    grundoberflaechen.gridwidth = width; grundoberflaechen.gridheight = height;
    grundoberflaechen.weightx = weightx; grundoberflaechen.weighty = weighty;
    diversemoegl.setConstraints(laenderdetails, grundoberflaechen);
    cont.add(laenderdetails);
    //Ausw�hlen des XML Files
    public void XMLAuswaehlen() {
    JFrame xmlauswahl = new JFrame("Fahrplan ausw�hlen");
    xmlauswahl.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container laenderdetails = xmlauswahl.getContentPane();
    GridBagLayout diversemoegl = new GridBagLayout();
    laenderdetails.setLayout(diversemoegl);
    JButton dateiauswahl = new JButton ("Datei ausw�hlen");
    addComponent(laenderdetails,diversemoegl,dateiauswahl,1,1,1,1,1,1);
    ActionListener ersterdateiauswaehler = new ActionListener()
    public void actionPerformed( ActionEvent e)
    try {
    new FileAuswahl().ablauf();
    } catch (JDOMException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
    } catch (IOException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
    dateiauswahl.addActionListener(ersterdateiauswaehler);
    xmlauswahl.setSize(150,70);
    xmlauswahl.setVisible(true);
    //Layout machen
    public void grundoberflaechen() {
    JFrame fahrplan = new JFrame("Fahrplanauswahldetails");
    fahrplan.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container laenderdetails = fahrplan.getContentPane();
    GridBagLayout diversemoegl = new GridBagLayout();
    laenderdetails.setLayout(diversemoegl);
    //Klassenobjekt aufbauen
    FileAuswahl fileauswahl = new FileAuswahl();
    // Labelsbauen und einbauen in den Fahrpl�nen
    String dtdversion = fileauswahl.getDtdVersion(); // <---
    System.out.println(dtdversion);
    JTextField DtdVersion = new JTextField(1);
    DtdVersion.setText(dtdversion);
    JTextField fahrplanzeit = new JTextField(1);
    fahrplanzeit.setText("123");
    JTextField fahrplanzeita = new JTextField(1);
    fahrplanzeita.setText("piips");
    //JButton oesterreich = new JButton("�sterreich");
    //JButton italien = new JButton("Italien");
    //JButton frankreich = new JButton("Frankreich");
    //JButton spanien = new JButton("Spanien");
    addComponent(laenderdetails,diversemoegl,new JLabel("Fahrplandetails"),0,0,1,1,0,0);
    addComponent(laenderdetails,diversemoegl,DtdVersion,1,0,1,1,0,0);
    addComponent(laenderdetails,diversemoegl,fahrplanzeit,2,0,1,1,0,0);
    addComponent(laenderdetails,diversemoegl,fahrplanzeita,3,0,1,1,0,0);
    // Action Listener f�r Dateiauswahl
    // Action Listener f�r das Speichern der Datei
    //addComponent(laenderdetails,diversemoegl,frankreich,2,1,1,1,0,0);
    //addComponent(laenderdetails,diversemoegl,spanien,3,1,1,1,0,0);
    fahrplan.setSize(600,750);
    fahrplan.setVisible(true);
    Thank you very much for your help....
    Your Java Learner

    I suspect you are setting the scheduledtdversion member in one instance of your FileAuswahl class, but are creating yet another instance of that class and printing the member of that instance, which is null. I notice you are creating a new FileAuswahl instance each time something happens, rather than reusing the same instance.
    FileAuswahl fileauswahl = new FileAuswahl();Ok, new object here. Not the same one that you previously set the scheduledtdversion member in
    String dtdversion = fileauswahl.getDtdVersion();It's null of course, for the reason above.

  • Getting the variable name

    Hi
    May be a simple question, but I can't figure out how actually.
    When I'm doing this
    var obj:Object = new Object();
    obj.test = "My Test";
    for(var i:* in obj)
         trace(i + " : " + obj[i]);    
    The output is -> test : My Test
    My problem comes when I put an object inside the object
    var obj:Object = new Object();
    obj.test = new Object()
    obj.test.secondTest = "My Test";
    for(var i:* in obj)
         trace(i + " : " + obj[i]);    
    The output is -> test : [object Object]
    So any idea how to get the variable name instead of [object Object], just like the first output but with the second code. I have an object inside an object.
    Thanks

    The following approach will dig it's way in.  I added other variables to the main object just for demo sake...
    var obj:Object = new Object();
    obj.test1 = "test string";
    obj.test = new Object();
    obj.test.secondTest = "My Test";
    obj.test2 = new Object();
    obj.test2.secondTest2 = new Object();
    obj.test2.secondTest2.val = "deeper test";
    function traceObjectVars(obj_arg:Object):void {
          for(var i:* in obj_arg){
                if(typeof(obj_arg[i]) == "object"){
                      traceObjectVars(obj_arg[i]);
                } else {
                     trace(i + " : " + obj_arg[i]);
    traceObjectVars(obj);

Maybe you are looking for

  • Reg:Invoice Creation in FB60

    Hi,       I have create a invoice in FB60 with the amount above 1lakhs its creating sucessfully.The payment block automatically change to P-payment request while verifying  the invoice number in FB03.So i cant able to  clear the payment in F110 .If a

  • SQLITE database has no tables on device?

    Hello - When I try to run my app on my iPhone, the sqlite database is found, etc., HOWEVER, when I query it, it says the table doesn't exist. In fact none of the tables do. Do I have to do something special to get the database and its tables over to

  • How to unlock Hp Desk top.

    My daughter has forgotten the password for her HP Desktop model 120-1333W that she hasn't used since high school. I need to know how to unlock the computer or how to factory reset the computer so I can give it to her younger brother?                 

  • How to remove text from photo only one layer?

    How do I remove text from this photo? plz & ty o I remove text from a photo?

  • User interface annoyances in N97

    I just basically wanted to nag about few really annoying features in hope that Nokia might actually read this post. Please feel free to reaply and add to this list. Unlocking announcements Due to security, my phone locks itself every 60 minutes when