Get current method through reflection. Is it possible?

Is it possible to get current method name (I mean method, which currently executes) through reflection.

it would seem i am not the one that has a problemas I said, get over it. I have no problem with you whatsoever, I merely pointed out that your solution was a massively heavyweight one that almost certainly wasn't necessary. if you really can't take this sort of opposition, that's your own look out. but don't go trying to start a flame war just because somebody disagreed with you on a couple of points
that's twice today you've posted something that actually wasn't pertinent to the original question, and rather than accept that, you insist on keeping dragging it up, re-defining terms and making passive-aggressive comments such as the one above. grow up
The End

Similar Messages

  • Invoking methods through reflection

    I need to check a property in the javax.faces.component.html.HtmlInputText.
    If i do it in the following manner,I get things fine:
    if(comp.getClass().getName().equalsIgnoreCase("javax.faces.component.html.HtmlInputText")) {
    String getter=((javax.faces.component.html.HtmlInputText)comp).getOnfocus();
    if(getter!=null) {
    System.out.println(getter);
    But if i invoke it through reflection,I get nothing.
    I am doing the following:
    Class reqClass = Class.forName("javax.faces.component.html.HtmlInputText");
    Method[] methodList = reqClass.getDeclaredMethods();
    int methodIdx = 0;
    for (int i = 0; i < methodList.length; i++) {
    Method reqMethod =methodList;
    if(reqMethod.getName().indexOf("getOn")== 0) //method starts with getOn
    // method accepts parameters, define the types in order here as Class[]
    Class[] classParams = new Class [] {};
    // set the method of the class object
    Method method = reqClass.getMethod( reqMethod.getName(), classParams );
    // pass values to fill parameters of method
    Object[] arguments = new Object [] {};
    // invoke method via reflection.Note that class has default constructor
    Object retobj=method.invoke( reqClass.newInstance() ,
    arguments );
    String getterResult = (String)retobj;
    if(getterResult!=null)
    System.out.println(reqMethod.getName() + " ## " + getterResult);
    What am i doing wrong while invoking the method through reflection.
    I get no exception either.

    It is a simple typo.
    An alternative I tried is the following ,but that does not work either.
    Class reqClass = Class.forName("javax.faces.component.html.HtmlInputText");
    Method[] methodList = reqClass.getDeclaredMethods();
    int methodIdx = 0;
    for (int i = 0; i < methodList.length; i++) {
    Method reqMethod =methodList;
    if(reqMethod.getName().startsWith("getOn")) //method starts with getOn
    System.out.println(reqMethod.getName());
    // pass values to fill parameters of method
    Object[] arguments = new Object [] {};
    // invoke method via reflection
    Object retobj=reqMethod.invoke( reqClass.newInstance(), arguments );
    String getterResult = (String)retobj;
    if(getterResult!=null)
    System.out.println(reqMethod.getName() + " ## " +getterResult);

  • To get current user through trigger

    Hi,
    I want audit trail through database trigger. But I noticed in trigger 'portal30.wwctx_api.get_user' is failed to parse. Is there any way to get the current user in trigger?
    Thanks,
    Sumita

    Prior to calling the get_user function you'd need to set the context first by invoking the wwctx_api.set_context method.
    Peter

  • ADF: getting current week through sysdate

    hi,
    Im using Jdev 11G.
    i have a table with sysdate displaying.
    now i need to calculate week by this sysdate and display in another column of the table.
    for ex: if sysdate is 3/2/2012 then the week should be 09 (bcoz 2nd March 2012 is the 9th week for the year 2012).
    How can i achieve this.
    Thanks.

    Hi,
    Have you tried adding to_char(sysdate,'WW') as a new column (calculated) in your VO's query.
    Ex :
    select to_char(to_date('3/2/2012','mm/dd/yyyy'),'WW') from dual-Arun

  • Getting the value of a String through reflection

    I have a class with a member variable that is of type String. How can I retrieve this value through reflection?
    I have tried the following
    String x = (String) myclass.getClass().getField("myvar").get(new String());
    If I try this I get IllegalArguemtnException can not set java.lang.String field pkg.myclass to java.lang.String

    ajavauser wrote:
    I have a class with a member variable that is of type String. How can I retrieve this value through reflection?
    I have tried the following
    String x = (String) myclass.getClass().getField("myvar").get(new String());
    If I try this I get IllegalArguemtnException can not set java.lang.String field pkg.myclass to java.lang.StringThat error message probably comes from another piece of code?
    (Since it says "set" and you are calling "get")
    The argument to the get method is however wrong. The String class does not have an attribute named "myvar". The argument to get should be the instance that you want to read the "myvar" value from.
    kaj

  • How to get Current row of ViewObject in the DoDML methode

    Hi all
    I have two ViewObject EmplyesView and DeptView
    How to get Current row of ViewObject DeptView in the DoDML methode of EmplyesView

    OK, we can play this game on and on...
    I'll ask for a use case (http://en.wikipedia.org/wiki/Use_case) and you don't give any info we don't already know. After an other 10 posts we probably know what you real problem is and can give you the advice which you could have gotten in the fist place.
    So please take some time and describe the problem as if you would ask your mother for help. Tell us how the data model is build and how the VO are related. Is there any input from an user involved? Which information from the other view do you need? How do you get to the doDML method? Is there a button in the ui involved?
    Timo

  • Getter & Setter Method not getting called for a field enhanced through AET

    Hello,
    I am new to SAP CRM 7.0 and working on a requirement.
    A Z-field was added by our functional guy in CRM 7.0 WebGui through AET in the 'Create Opportunity' transaction (Header data).
    Now the requirement is, as soon as the opportunity is created through the WebGui, I should post a document in R/3 and paste that document number back to the enhanced Z-field in opportunity.
    Work done by me:
    I pressed F2 on the enhanced Z-field in the WebGui screen and took the details of view, component name etc. After this I went to normal SAP CRM system and open tcode "BSP_WD_CMPWB", located the corresponding view "BT111H_OPPT/Details" and right clicked & enhanced the same.
    Then I opened the structure of this view, expanded context node, located context "BTOPPORTH" and inside this, located my Z-attribute. Now right clicked on the Z-attribute & selected the option "Generate SETTER & GETTER Methods" and these were generated successfully.
    Problem:
    The problem is even after putting external break points in these methods, these methods are not getting called while creating, modifying & displaying the Opportunity in WebGui.
    I hope that for the requirements that I have, I have to do the coding in "Getter & Setter" methods. But since these are not getting called, I am unable to proceed.
    Please help/suggest how to achieve this.
    Thanks in anticipation.
    Best Regards,
    Rahul Malani

    Hi,
    If you can see the field in UI and still get_ method is not being triggered then try to regenerate these methods. If it still doesn't work then please look for SAP notes or raise an OSS.
    There should be some note for the issue you faced.
    please refer:
    Help Needed immediately - AET getter setter methods not getting triggered
    Regards,
    BJ

  • Getting HeapDump on out of memory error when executing method through JNI

    I have a C++ code that executes a method inside the jvm through the JNI.
    I have a memory leak in my java code that results an out of memory error, this exception is caught in my C++ code and as a result the heap dump is not created on the disk.
    I am running the jvm with
    -XX:+HeapDumpOnOutOfMemoryError
    -XX:HeapDumpPath=C:\x.hprof
    Any suggestions?
    Thanks

    I'll rephrase it then.
    I have a java class named PbsExecuter and one static method in it ExecuteCommand.
    I am calling this method through JNI (using CallStaticObjectMethod). sometimes this method causes the jvm to throw OutOfMemoryError and I would like to get a heap dump on the disk when this happens in order to locate my memory leak.
    I've started the jvm with JNI_CreateJavaVM and I've put two options inside the JavaVMInitArgs that is used to create the Jvm. -XX:+HeapDumpOnOutOfMemoryError and -XX:HeapDumpPath=C:\x.hprof
    which supposed to create a heap dump on the disk when OutOfMemoryError occurs.
    Normally if I would execute normal java code, when this exception would occur and I wouldn't catch it the Jvm would crash and the heap dump would be created on the disk.
    Since I need to handle errors in my C++ code I am use ExceptionOccured() and extracts the exception message from the exception it self and write it.
    For some reason when I execute this method through JNI it doesn't create the dump.

  • I want to upgrade the software (currently I have Mac OS X 10.6.4) but when the mac is downloading the new version i get an error message and is not possible get the most updated software: Mac OS X 10.6.8 or either the most recent itunes why?!?!?!

    I want to upgrade the software (currently I have Mac OS X 10.6.4) but when the mac is downloading the new version i get an error message and is not possible get the most updated software: Mac OS X 10.6.8 or either the most recent itunes why?!?!?!

    Then you either have a network problem or a hardware problem or a corrupted hard drive. You might try:
    Repair the Hard Drive and Permissions
    Boot from your Snow Leopard Installer disc. After the installer loads select your language and click on the Continue button. When the menu bar appears select Disk Utility from the Utilities menu. After DU loads select your hard drive entry (mfgr.'s ID and drive size) from the the left side list.  In the DU status area you will see an entry for the S.M.A.R.T. status of the hard drive.  If it does not say "Verified" then the hard drive is failing or failed. (SMART status is not reported on external Firewire or USB drives.) If the drive is "Verified" then select your OS X volume from the list on the left (sub-entry below the drive entry,) click on the First Aid tab, then click on the Repair Disk button. If DU reports any errors that have been fixed, then re-run Repair Disk until no errors are reported. If no errors are reported click on the Repair Permissions button. Wait until the operation completes, then quit DU and return to the installer.
    If DU reports errors it cannot fix, then you will need Disk Warrior and/or Tech Tool Pro to repair the drive. If you don't have either of them or if neither of them can fix the drive, then you will need to reformat the drive and reinstall OS X.
    You can also try downloading from another computer on a different network connection.

  • I currently have Photoshop CS5 standard, and want to updgrade to CS5 Extended to get the 3D capabilities.  Is this possible, I don't see any CS5 upgrades available?

    I currently have Photoshop CS5 standard, and want to upgrade to CS5 Extended to get the 3D capabilities.  Is this possible, I don't see any CS5 upgrades available?  I tried to download a new trial version as well, but my current operating system will not support it, so I'd like to stick w/ a version of CS5 that will allow me to work in 3D.  What are my options?

    You can upgrade to CS6 extended for $400

  • HT4061 I lost my Iphone and I need IMEI number, but I have only serial number. Can I get IMEI number through Iphone serial number ? if possible please help and let me know how

    I lost my Iphone and I need IMEI number, but I have only serial number. Can I get IMEI number through Iphone serial number ? if possible please help and let me know how

    If you go to the computer where your sync your phone to and open itunes and then go to edit in the tool bar then preferences then device preferences then devices.. hover the mouse pointer over your device name in the back up lists that appear there and it shows the IMEI

  • Is knowing of Class Name, which called current method, possible?

    Hallo everyone,
    My method is called from inside some method of some class. Can I know which class called my method.
    In other words I would like to know is that possible to have a name of class from which my current method is called? It's sometrhing like I need an access to the call stack.
    thanks!

    You can do the same thing before 1.4 as well:
          Throwable t;
          PrintStream ps;
          PrintWriter pw;
          String str;
          StringBuffer sb;
          StringWriter st;
          t = new Throwable();
          st = new StringWriter();
          pw = new PrintWriter(st);
          t.printStackTrace(pw);
          sb = st.getBuffer();
          str = sb.toString();You now have the stack as a String in the variable str.
    The problem is that you have to parse the String to separate methods from classes and so on. And different platform may produce slightly different string representations of the stack.
    So, it is easier in Java 1.4

  • Get the current method's class

    I need to get the Method object representing the method I'm executing. How can I get this in an easy way? (I use J2SE 1.4.2)
    It looks like I must do something like this
    public String methodName(Object obj1, Object obj2) {
    this.getClass().getMethod("methodName", new Class[] {obj1.getClass(), obj2.getClass()});
    }

    The getMethod() of Class will return the method. Below is the syntax for that
    public Method getMethod(String name,
                            Class[] parameterTypes)

  • How to get current PopUp Window

    Dear All,
    I am using NetWeaver 7.1 sp1 and facing a problem. Actually I want to show a view in popup window. The popup window works fine but i want to get currently popup window. How can i get it in View and controller ??
    I found a solution : wdContext.currentPopupElement().getWindowInstacnce();
    but in wdContext there is no method like .currentPopupElement(). plz help.

    Hi
    wdContext.currentPopupElement().getWindowInstacnce();
      Here PopupElement is a attribute of IWDWindow type where u have to put the window instances (say For close or life control of that popup)
    For further plz go through these doc
    1. [Dialog|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/903fed0d-7be4-2a10-cd96-9136707374e1&overridelayout=true]
    2. [Popup Window|http://www.sdn.sap.com/irj/scn/index?rid=/library/uuid/a04870c5-749b-2b10-06ba-d25515ef39e3&overridelayout=true]
    Best Regards
    Satish Kumar

  • How does BR get current date, user, and associate member with Attribute Dim

    I need use Business rules or Calc script to implement following functions:
    1. Get current date and the name of user who is running the BR and save the information to cube.
    I don't find any functions to get current date and users.
    Also, since text and date is store in relational database and essbase cube only stores the index, it looks that the value can't be changed or stored by using "==" directly, is there any function to change value of members with Text or Date types in BR/Calc script?
    2. End users select attribute value (via smart list) of products or projects(Sparse dimensions) in data form, run BR to update the association of these members with attribute dimension.
    I don't find any functions to change the attribute association in BR/Calc, is there any CDF (Custom Defined Function) that can do it?
    Thanks!

    Hi,
    For the date functionality, check out the post below.
    Re: Days behaviour between two dates
    As for the username, there is a little tricky way that requires an unused or a new dimension along with a smart list of user names. It's also possible to capture the user name from the cookies and pass it on to the form. The latter is possible through validatedata.js however requires hefty coding here and there.
    As for the attributes, it's not possible to update metadata through business rule. So no luck in there.
    Cheers,
    Alp

Maybe you are looking for