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

Similar Messages

  • How to know the Column name which contains some value?

    Suppose if a table contains 30 columns, and I want to know the name of the Column that contains my search text(Value).
    For Eg. I have a Table named Allowances contains 20 columns for referencing 20 types of allowances. The columns are named like Allw_1,Allw_2,...etc..I know the allowance name(Like "Incentive") and I want to know the Column name on which this allowance name presents.
    Pls. help me.

    Change your DB model.
    A Table with columns called allw_1, allw_2, ... begs to be normalized.

  • Java class names which contain unicode characters

    I need to create, compile and load java classes which have class names that contain unicode characters.
    I am using Win2k but will neet to support unix* in future.
    When I try to create a fooXbar.jar where X is a unicode character which is not ascii I get an error when creating the file.
    My question is: how do I map java class names and package names which contain non ascii characters into
    names that the files systems will like AND that the java VM will use when trying to load .class file from the class path.
    for example what would the .java and .class file be for the following class?
    class \u6587\u66f8 {

    You could make names for .java and .class that is understandable by the filesystem. E.g. you could prepend with % and then digits for the unicode character. The problem is then how to compile the class, and how to load the class.
    You can load the class with a custom classloader, which will translate the unicode class name to the escaped file name (using %).
    The problem is then reduced to how you can compile your code (you have to map the file name to the class name somehow). I think it can be done, but I don't know the solution to that.
    Alternatively you can use meaningful names for the classes, and then make an obfuscator that can change the bytecodes so the classnames are changed to some obscure unicode names. Perhaps there is already obfuscators out there you can use that will use unicode characters.

  • Jquery - Accessing class name which contain white space

    Hi,
    My html table code is
    <- table class="t20Region t20ReportRegion" ....;>
    now I have to use the above class name "t20Region t20ReportRegion" in the below jquery . how to do this
    $header = $('table.class_name tr:first');
    how to substitute / enter class_name which has white space in them ( "t20Region t20ReportRegion" )
    Thanks in advance
    Shijesh

    I will be patient from next time.
    Thanks Dan,
    The changes made by you is working for standard template.
    However, when i created a custom report template in which I have two row for Colum Header ( Main
    Header and Sub Header), its not working.
    Credentials are the same.. and same page nos.
    How to change the code so that it will work for custome report template as well
    if a user click on total under Col1 or Col2 , i was trying to pass Header1 + ' ' + col1 or Header1 + ' ' + col2 ( concatenation of header1 and col1/2 with space in between)
    if a user click on total under Col3 or Col4 , i was trying to pass Header2 + ' ' + col3 or Header2 + ' ' + col4 ( concatenation of header2 and col3/4 with space in between)

  • How to know the class name in .ser file?

    Hi,
    I have a .ser file, could any expert help me to find out all the classes in the .ser file? Thanks!

    If you have written them as Object, then you can just read them one by one with an ObjectInputStream and when you have the object, you can print out the class name:
    Object o = in.readObject();
    if (o != null)
      System.out.println(o.getClass().getName());
    else
      System.out.println(null);

  • Converting a string to Class object and calling its method

    I have recently moved to Java and I need help on this specific issue given below.
    I have to do this :
    ValModule1 val1 = new ValModule1();
    ValModule2 val2 = new ValModule2();
    if(val1.checkModule(xmlDocument)){
    $i++;
    There are many ValModule* classes and they all have the method called checkModule in them. I need to instantiate each class and run the checkMethod which returns true or false. My problem is that I am trying to get the name of the module (if it is ValModule1 or 2 or 3) from the user. What I get from the user is the name of the class for which I should call checkModule method on.
    how can I convert this string validationname given by the user and instantiate that class and call the method?
    I have tried this:
    String str="c:/xpathtest/src/Plugin_Config.xml";
    File xmlDocument = new File(str);
    String cls = "ValModule1"; // assuming this is what the user gave me
    Class t = Class.forName("ValModule1");
    Object o = t.newInstance();
    After that if I try
    if(o.checkModule(xmlDocument)){
    $i++;
    It gives me an error saying that it is not an existing method
    cannot resolve symbol
    [javac] symbol : method checkModule (java.io.File)
    [javac] location: class java.lang.Object
    [javac] if(o.checkModule(xmlDocument)){
    [javac] ^
    [javac] 1 error
    Can you please let me know where I am screwing up :-) ? If you need me to put both the programs I can do that too. Thanks in Anticipation

    I have recently moved to Java and I need help on this
    specific issue given below.
    I have to do this :
    ValModule1 val1 = new ValModule1();
    ValModule2 val2 = new ValModule2();
    if(val1.checkModule(xmlDocument)){
    $i++;
    There are many ValModule* classes and they all have
    the method called checkModule in them. I need to
    instantiate each class and run the checkMethod which
    returns true or false. My problem is that I am trying
    to get the name of the module (if it is ValModule1 or
    2 or 3) from the user. What I get from the user is
    the name of the class for which I should call
    checkModule method on.
    how can I convert this string validationname given by
    the user and instantiate that class and call the
    method?
    Define an interface containing the method all your classes have in common, cast the Object reference returned by newInstance to that interface, then you can call that method.
    Good Luck
    Lee

  • To find out the object which called a method

    Hi all,
    Is there any way to findout the object which called a class method.
    The object name is required inside the method.
    Thanks in advance,
    Sreekanth

    Hi Sreekanth,
    You can do it by reading the CALL STACK.
    At the beginning of your method put the following code:
    data:
        begin of stackItem,
          program        type SYREPID,
          include        type SYREPID,
          line           type i,
          eventtype(12)  type c,
          event(70)      type c,
          flag_system(1) type c,
        end of stackItem,
        stack like standard table of StackItem.
      call 'ABAP_CALLSTACK' id 'DEPTH' field 2 id 'CALLSTACK' field stack.
      read table stack into stackitem index 2.
      MEssage i002(sy) with stackitem-program.
    Here stackitem-program is the calling program.
    Cheers,
    Aditya

  • How to get the Class name of an API method?

    Like most of us, it's difficult to know where every method within a Java class is. Also, many of the same methods are scattered throughout Java Classes. I know of two methods that retreive this... getClass().getName(). But, you must have an object to use these. Is there a way to find out what Class contains a method or Class variable thru an Applet or Java Application?? Obviously, I can look at API Docs; but this takes time.
    Tks Randy

    RajEndiran wrote:
    Can anyone please let me know how we can get the class name of a page or region in oracle apex?What do you mean with class name? The name of the template (e.g. the css style class name)?
    I would also like to know how we get the DOM object ID for particular item.Use firebug or inspect the source code of the rendered page to see the object IDs. Other then then, the typical ID of page items is the name of the item. For regions you can set your own ID.

  • Find the Class Name in a static method

    Hi All,
    I am trying to find the class name inside the static main method. I want to write one main method that loads an instance of the class. Other folks have suggested tricks with the security manager or creating an Exception to look at the stack trace, but these methods don�t reflect the inheritance. I want SUBCLASSES to be able to run from the command line using the inherited main method.
    public static void main(String args[]){
          JPanel thisJPanel = (JPanel) Class.forName(????).newInstance();
    }Any Ideas

    I want
    SUBCLASSES to be able to run from the command line
    using the inherited main method.Someone pointed this out already but more directly, static methods are not inherited.
    The behavior you desire ca be achieved using the Factory pattern.
    The idea of being able to subclass an application is a little bizarre. Why don't you just do something like this:
    public static void main(String[] args){
        // check that there is at least one parameter 
        JPanel thisJPanel = (JPanel) Class.forName(args[0]).newInstance();
    }

  • How to specify realm name when calling weak( ) method on ServletAuthentication class?

    I've created a bunch of custom realms and for a specific user logon (form based "uname" and "pword"), the system knows exactly which custom realm to look up against. However, in using ServletAuthentication class, one can only specify realm name in strong(req, res, realmName), not the weak() method. Any clue?
    -john

    Hi John,
    Did you find the answer to this question? I'm having a similar problem when calling the ServletAuthentication.assertIdentity() method.
    Cheers,
    Vidar

  • Urgent: Need to know a Program name which generates Numbers automatically

    Hi Peers,
    We all know that there are 2 kinds of Numbering :
    1. Internal Numbering
    2. External Numbering
    For eg: When we create an Sales Order a  new SO number is generated automatically which is called Internal number generation.
    There is an Object which generates this number  I would like to know that  Program. If  any Idea please let me know.
    The reason why I need is , Thru a transaction when we  are create entries for an Z table , the number should be generated automatically.
    Points will be suitably rewarded.
    Thanks a Lot.
    Daniel

    Hi,
    1) Goto Tcode SNRO
    2) select ur concerned OBJECT there.
    3) Click on Number Ranges Push Button.
    4) then click on Display Interval Button over there.
    *****************************************************Other code
    Create number range object using OYSN.
    Then call the following function modules.
    FORM get_next_id CHANGING p_discrep.
    DATA: last_id LIKE zrecaudit-discrep,
    quant LIKE inri-quantity, "dummy
    code LIKE inri-returncode. "returncode
    CALL FUNCTION 'NUMBER_RANGE_ENQUEUE'
    EXPORTING
    object = 'ZRECAUDIT'
    EXCEPTIONS
    foreign_lock = 1
    object_not_found = 2
    system_failure = 3
    OTHERS = 4.
    IF sy-subrc = 0.
    CALL FUNCTION 'NUMBER_GET_NEXT'
    EXPORTING
    nr_range_nr = '01'
    object = 'ZRECAUDIT'
    IMPORTING
    number = last_id
    quantity = quant
    returncode = code
    EXCEPTIONS
    interval_not_found = 1
    number_range_not_intern = 2
    object_not_found = 3
    quantity_is_0 = 4
    quantity_is_not_1 = 5
    interval_overflow = 6
    buffer_overflow = 7
    OTHERS = 8.
    CALL FUNCTION 'NUMBER_RANGE_DEQUEUE'
    EXPORTING
    object = 'ZRECAUDIT'
    EXCEPTIONS
    object_not_found = 1
    OTHERS = 2.
    ENDIF.
    ENDFORM. " get_next_id
    Don't forget to reward if useful..
    Vasanth

  • Want to know location, address & name of caller. No. 8119933774.

    Dear All Friends,
    For your kind information, i intend to inform you that, from few days a person are being disturbed to my sister as a result our family are being faced huge trouble. No. 8119933774 from which he called but when we are calling back to this cell it appears
    that it is not valid or unreachable. we think he is being called from internet through software.
    So therefore, i would request all of you that please arrange such a way so that we can easily trace this nos. with proper information of disturbing person as we registered a FIR complain in LOCAL POLICE STATION and also they are trying to find it.
    Thaks & Regard,
    Panna Debnath, State : Tripura, District : West Tripura, City : Agartala, Pin : 799001 & Cell : 9774652295.

    Hi,
    Try with Table T499S.
    Regards,
    Prabu

  • May I know the document name which I need to follow when I setup SSL on Por

    Hi Gurus,
    We have installed 9iAS Portal 90201 and upgraded it to 9023. We are trying to setup SSL for everything in the server. We have both infrastructure and middle tier on the same server. We are not sure where to start the SSL setup. Infrastructure has a HTTP server, SSo server ..etc. and the middle tier has a HTTP and OC4j and Portal, webcache..etc. Is there a standard document or list of documents in sequence which I can follow to setup SSL on our server. I have found couple of them. But not sure which one has to go first and which one has to go next. I am planning to use the trial certificate from Verisign. Please post a reply if you have sojme info about it.
    Thanks
    Raj
    ----------

    We're in the middle of trying to do the same for 904 on Solaris. If anyone has some advice, we'd really love to hear it.

  • How to do this: Link which calls a methode with a parameter?

    Hello!
    I have a small question:
    I have a jsp-site with some beans.
    On the jsp-site I have the following code which isnt functional:
    <c:forEach items="${filter.resultlist}" var="result">
        <c:url action="#{filter.selectedAoid(result.aoid)}">
             <c:out value="${result.name}" / >
         </c:url>
    </c:forEach>-> As you can see:
    I want to make a Link, which is named like the String in the List and accessable by ${result.name} and on a click it should run "filter.selectedAoid()" with an int Parameter.
    (So I can access the right object with my Aoid-identifier...)
    The List comes from a DB and I am able to access the values of the Objects in the list.
    Could someone please tell me how that is done?
    Thanks in advance
    Fuchur

    One way of hacking this problem is by dynamically updating the job step which executes the stored procedure to include the parameters the user provided.  You can do so by using
    msdb.dbo.sp_update_jobstep.
    So for example, you could create a job named "Test job" and in that job the first step would be to execute your stored procedure.  You would then use the following code to update that step at run time:
    execute msdb.dbo.sp_update_jobstep
    @job_name = N'Test job',
    @step_id = 1,
    @command = 'execute my_proc @my_variable = ''my_value'''
    You'd then use sp_start_job like so:
    execute msdb.dbo.sp_start_job @job_name = 'Test job'
    Your job would then execute using the value provided at run time for the @my_variable parameter.

  • How to get the class name  static method which exists in the parent class

    Hi,
    How to know the name of the class or reference to instance of the class with in the main/static method
    in the below example
    class AbstA
    public static void main(String[] args)
    System.out.println(getXXClass().getName());
    public class A extends AbstA
    public class B extends AbstA
    on compile all the class and run of
    java A
    should print A as the name
    java B
    should print B as the name
    Are there any suggestions to know the class name in the static method, which is in the parent class.
    Regards,
    Raja Nagendra Kumar

    Well, there's a hack you can use, but if you think you need it,Could you let me the hack solution for this..
    you probably have a design flaw and/or a misunderstanding about how to use Java.)May be, but my needs seems to be very genuine..of not repeat the main method contents in every inherited class..
    The need we have is this
    I have the test cases inheriting from common base class.
    When the main method of the test class is run, it is supposed to find all other test cases, which belong to same package and subpackages and create a entire suite and run the entire suite.
    In the above need of the logic we wrote in the main method could handle any class provided it knows what is the child class from which this main is called.
    I applicate your inputs on a better way to design without replicating the code..
    In my view getClass() should have been static as the instance it returns is one for all its instances of that class.
    I know there are complications the way compiler handles static vars and methods.. May be there is a need for OO principals to advance..
    Regards,
    Raja Nagendra Kumar
    Edited by: rajanag on Jul 26, 2009 6:03 PM

Maybe you are looking for

  • Thinkpad Edge 15 TVSU "Not applicable" after fresh wipe of Windows 8.1 and install of Windows 7

    Hello, I have a user that purchased a Lenovo laptop and is having problems downloading drivers to support the machine now that it has Windows 7 (via Volume Licensing) on it. When running System Update after Windows updates, it will tell me that "Ther

  • Closed Lid operation

    Hi, I was wondering, while having my macbook hooked up to an external monitor, is there anyway to prevent the computer from shutting down when the lid is closed? in windows there is the option "do nothing when lid is closed" is there such a thing in

  • Trying to get my air video app and my airport extreme router to work.

    Hi there. I am getting really frustrated and desperate. I just purchased the app "air video" on my iPad. Installed the software on my mac. Works awesome when I'm on MY WIRELESS NETWORK. I didn't think it would be an issue once I left the house and tr

  • [SOLVED-unhappily] can't access httpd server externally

    --EDIT-- due to here and here i have learned that my ISP is in fact blocking inbound TCP connections on port 80.  i have sent an email to RCN requesting they're "static IP service" which that second link claims has no ports blocked. if/when they open

  • I am unable to import photos from iPhone to Mac.

    I am unable to import photos from iPhone to Mac.  The most recently taken photos are not showing up on the screen ready to import as usual.  Any thoughts as to why?