Trouble in dynamic method invocation

hai forum,
Your previous responses on this topic 'method invocation' has greatly helped me in writing a code to invoke method dynamically.As some experts pointed out,the parameters had to be type casted.
Please help me out of my latest trouble.I invoke only a particular method 'methodName' of a particular calss instance 'instance'.But when i run the code Exceptions are thrown for all the methods of that class whereas i require exceptions connected with "methodName" only.
I just could not figure out my mistake, so please help me out.
Thank you.
    private class MethodInvoke implements ActionListener
        private String methodName=""; //name of the method
        Object instance;                          //instance of the class
        private int paraNum=0;             //num of parameters
        public void setParameters(String methodName,Object instance,int paraNum)
            this.methodName = methodName;
            this.instance=instance;
            this.paraNum=paraNum;
        public void actionPerformed(ActionEvent e)
             try
                       //TAKE PARAMETERS FROM USER USING TEXTFIELDS INTO AN ARRAY LIST
                    Component[] cList = textfieldPanel.getComponents();
                    ArrayList parameterList = new ArrayList(paraNum);
                    Object[] parameters = new Object[parameterList.size()];
                     for (int x = 0; x < paraNum; x++)
                            if (cList[x] instanceof JTextField)
                                String value = ((JTextField) cList[x]).getText(); 
                                parameterList.add(value);
                    Method[] allMethods = instance.getClass().getMethods();
                    Method method = null;
                    for (int i = 0; i < allMethods.length; i++)
                            if (allMethods.getName().equals(methodName))
method = allMethods[i];
break;
if (method == null)
throw new RuntimeException("Method not found");
Class[] types = method.getParameterTypes();
for (int i = 0; i < paraNum; i++)
String values = (String)parameterList.get(i);
if (types[i].equals(Integer.class))
parameters[i] = new Integer(values);
else if (types[i].equals(Long.class))
parameters[i] = new Long(values);
else if (types[i].equals(String.class))
parameters[i] = values;
else if (types[i].equals(Float.class))
parameters[i]=new Float(values);
else if (types[i].equals(Boolean.class))
parameters[i]=new Boolean(values);
else
System.out.println("Do not support the data type");
Object result = method.invoke(instance, parameters);
System.out.println("Invoked result: " + result);
catch(Exception e3)
System.out.println(e3);

This is the Emp class which iam calling.Hope this will help you.
import java.io.*;
public class Emp
     private String designation;
     private int salary;
     private int id;
     private String name;
     public Emp()
     public void setId(int i)
          id=i;
     public int getId()
          return id;
     public void setDesignation(String d)
          designation=d;
     public void setName(String d)
          name=d;
     public void setSalary(int s)
          salary=s;
     public String getDesignation()
          return designation;
     public int getSalary()
          return salary;
     public String getName()
          return name;
     public void setAll()
          try
               System.out.println("Enter name:");
               BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
               String n=br.readLine();
               setName(n);
               System.out.println("Enter ID:");
               setId(Integer.parseInt(br.readLine()));
               System.out.println("Enter Designation:");
               n=br.readLine();
               setDesignation(n);
               //System.out.println("Enter Salary:");
               //setSalary(Integer.parseInt(br.readLine()));
          catch(Exception e)
     public void getAll()
          System.out.println("Name: "+getName()+"\n ID: "+getId()+
                    "\n Designation: "+getDesignation());
     public void pay(int w)
          getAll();
          System.out.println("Name: "+name+"\nAmount to be paid : "+w);
     /*public static void main(String[] args)
          Emp e=new Emp();
          e.setAll();
          e.getAll();
}

Similar Messages

  • TROUBLE WITH PAYMENT METHOD USED DIFFRENT VISA PAYMENTS STILL WONT WORK

    TROUBLE WITH PAYMENT METHOD USED DIFFRENT VISA PAYMENTS STILL WONT WORK

    This is a case for the iTunes Store Support:
    1. Go to expresslane.apple.com
    2. select 'itunes' and then 'itunes store' on the right
    3. select a topic and a subject
    4. click 'continue' and then 'email'
    5. fill out the form and explain your situation
    6. they will respond within 24 hours usually
    Good luck
    Stijn

  • How to solve the "Method invocation failed" error in script?

    Hello,
    I'm trying to modify the script that enumerates all the txt (csv) files on folder and deletes empty columns, but with no luck. The script is working when I execute it on single csv file. But when I put script on loop, it generates errors:
    Method invocation failed because [System.Management.Automation.PSCustomObject] does not contain a method named 'split'.
    At C:\scripts\populate.ps1:25 char:1
    + $b = $line.split(",")
    + ~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (split:String) [], RuntimeException
        + FullyQualifiedErrorId : MethodNotFound
    The script looks the following:
    $files = Get-ChildItem C:\scripts\Results\csv\* -include *.txt
    #Process files by performing a search and replace
    foreach ($infile in $files)
    $infilen = 'C:\scripts\Results\csv\'+[io.path]::GetFileName($infile)
    $infile = import-csv $infilen
    ##remove blank coloumns##
    $cStore = @() # array to store used column numbers
    $rNumber = 0
    foreach ($line in $infile)
    if ($rNumber -eq 0)
    {# ignore header
    else
    $b = $line.split(",")
    $fieldNum = 0
    foreach ($field in $b)
    if ($field -ne '')
    if ($cStore -notcontains $fieldNum) {$cStore += $fieldNum}
    $fieldNum += 1
    $rNumber +=1
    # array $cStore now contains column numbers with values
    $cStore = $cStore | sort
    foreach ($line in $infile)
    $nLine = ""
    $c = $line.split(",")
    foreach ($ar in $cStore)
    $nLine += $c[$ar]+","
    # remove trailing ,
    $nLine = $nLine.Substring(0, $nLine.Length-1)
    $fnFriendly = [io.path]::GetFileNameWithoutExtension($infile)
    $result=$fnFriendly+'cl.txt'
    Write-Output $nLine >> $result
    Also I have found the explanation on this error on this
    link but it seems this is not the case.  Can you help to solve this?
    Thanks!

    You are importing a CSV file which implies that you are creating an object (pscustomobject) and each item in that object is represented by $line. The issue is that this $line has multiple properties (for each column of the CSV) that you need to decide
    on which one to split:
    $c = $line.propertyname.split(",")
    I'm not sure, but it seems that if you are trying to split by a comma, then maybe you are assuming that you did something similar to a
    get-content on the file in which the original approach that you have done would work.
    Boe Prox
    Blog |
    Twitter
    PoshWSUS |
    PoshPAIG | PoshChat |
    PoshEventUI
    PowerShell Deep Dives Book

  • Why must this method invocation be caught?!

    Hi there. I have this following piece of code:
    public class Dog extends Animal {
         public static void main(String[] args) {
              Animal animal = new Dog();
              System.out.println(animal.getAge(args[0]));
         int getAge(String arg) {
              return Integer.parseInt(arg);
    class Animal {
         int getAge(String x) throws Exception {
              return 5;
    }Ok, I compiled this an received this notification from the compiler:
    Dog.java:4: unreported exception java.lang.Exception; must be caught or declared
    to be thrown
                    System.out.println(animal.getAge(args[0]));
                                                    ^
    1 errorIm a little confused here as to why I am receiving this notification...
    The reason being is firstly I thought that when you override a method you can declare fewer or narrower checked
    exceptions than the method that is being overridden and secondly,
    this is a polymorphic method invocation on line 4 as Dog's getAge method is being called,
    not class Animal's getAge method.
    Any clarification would be well received,
    thank you indeed.
    Edited by: shamrock08 on May 6, 2008 10:23 AM
    Edited by: shamrock08 on May 6, 2008 10:23 AM

    shamrock08 wrote:
    BigDaddyLoveHandles wrote:
    you don't get that compile-time error. Why do you get it with the first code? In expression animal.getAge(args[0]), variable animal is of type Animal, and Animal's getAge method signature includes "throws Exception". Typing is done statically, at compile-time, hence the syntax error.Im not sure im entirely understanding.
    I thought that in relation to overridden instance methods, the Object type determines which method
    will be invoked at runtime. Yes.
    So in this case wont the Dog getAge method be invoked? Yes.
    Im just a little confused as my book says that
    when a method overrides an inherited instance method it can declare fewer or narrower checked exceptions,
    Thanks for the input & regards.That's also true. I think what you are missing is the realization that compiler errors are based on static type information not runtime information.
    Consider this method:
    void f(Dog d, Animal a) {
        d.getAge("");
        a.getAge("");
    }The method invocation d.getAge("") doesn't throw Exception, because that is how you overrode getAge in class Dog.
    The method invocation a.getAge("") may throw a checked exception, because that is how the method is defined in class Animal. So the compiler will complain about this line: either catch or propagate the exception. Note that this compiler error is independent of what object a refers to -- a could be pointing to a Dog, it doesn't matter. Only the static typing matters at compile-time.

  • Error sending method invocation request(oc4j 10g(10.1.3.1))

    Dear,
    I have two applications a.ear and b.ear. They both are deployed on same oc4j container (10g(10.1.3.1))
    Both applications use each others session beans. In order to make communications between these two applications possible I set global-jndi-lookup-enabled attribute in <application-server> element in server.xml file, to be true.
    One of the applications use hibernate 3.1. According to some of posts from your forum, I replaced antlr.jar from toplink\jlib folder with one form with the one provided by the Hibernate 3 distribution.
    In order to integrate Hibernate with Container managed transactions, I set in hibernate.cfg.xml:
    hibernate.transaction.factory_class parameter to: org.hibernate.transaction.CMTTransactionFactory and
    hibernate.transaction.manager_lookup_class to: org.hibernate.transaction.OC4JTransactionManagerLookup.
    Everything works well since I save/update data in database. I save or update data, calling method from remote session bean.
    I am getting java.lang.NullPointerException. Here is my error log:
    2007-02-23 13:03:32.687 WARNING J2EE EJB-08002 [WorkflowManager] thread HTTPThreadGroup-12 encountered an exception while trying to end the transaction: oracle.oc4j.rmi.OracleRemoteException: An exception occurred during transaction completion: ; nested exception is:
    javax.transaction.RollbackException
    WARN processException, Unhandled Exception thrown: class com.ed.ecomm.edcore.exception.RepException
    2007-02-23 13:03:32.750 ERROR ServletException cause
    mermig > 13:03:32.765 ERROR SecurityFilter - EXCEPTION:
    Error sending method invocation request; nested exception is:
    java.lang.NullPointerException
    javax.servlet.ServletException: Error sending method invocation request; nested exception is:
    java.lang.NullPointerException
    at org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:516)
    at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:423)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
    at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
    at oracle.security.jazn.oc4j.JAZNFilter$1.run(JAZNFilter.java:396)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
    at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:410)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:621)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:368)
    at com.evermind.server.http.ServletRequestDispatcher.unprivileged_forward(ServletRequestDispatcher.java:259)
    at com.evermind.server.http.ServletRequestDispatcher.access$100(ServletRequestDispatcher.java:50)
    at com.evermind.server.http.ServletRequestDispatcher$2.oc4jRun(ServletRequestDispatcher.java:193)
    at oracle.oc4j.security.OC4JSecurity.doPrivileged(OC4JSecurity.java:283)
    at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:198)
    at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1056)
    at org.apache.struts.tiles.TilesRequestProcessor.doForward(TilesRequestProcessor.java:261)
    at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:388)
    at org.apache.struts.tiles.TilesRequestProcessor.processForwardConfig(TilesRequestProcessor.java:316)
    at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:231)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
    at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:397)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:64)
    at com.ed.mermig2plus.web.filters.AuthorizationFilter.doFilter(AuthorizationFilter.java:115)
    at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:15)
    at com.ed.ecomm.edcore.web.filters.MonitoringFilter.doFilter(MonitoringFilter.java:180)
    at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:17)
    at com.ed.ecomm.edcore.web.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:93)
    at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:17)
    at com.ed.ecomm.edcore.web.filters.DoFilterPrivilegedAction.run(DoFilterPrivilegedAction.java:65)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:320)
    at com.ed.ecomm.edcore.web.filters.jaas.OracleJAASProvider.performAction(OracleJAASProvider.java:166)
    at com.ed.ecomm.edcore.web.filters.SecurityFilter.performAction(SecurityFilter.java:595)
    at com.ed.ecomm.edcore.web.filters.SecurityFilter.doFilter(SecurityFilter.java:292)
    at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:17)
    at oracle.security.jazn.oc4j.JAZNFilter$1.run(JAZNFilter.java:396)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAsPrivileged(Subject.java:500)
    at oracle.security.jazn.oc4j.JAZNFilter.doFilter(JAZNFilter.java:410)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:619)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:368)
    at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:866)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:448)
    at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:216)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:117)
    at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:110)
    at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
    at oracle.oc4j.network.ServerSocketAcceptHandler.procClientSocket(ServerSocketAcceptHandler.java:239)
    at oracle.oc4j.network.ServerSocketAcceptHandler.access$700(ServerSocketAcceptHandler.java:34)
    at oracle.oc4j.network.ServerSocketAcceptHandler$AcceptHandlerHorse.run(ServerSocketAcceptHandler.java:880)
    at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:298)
    at java.lang.Thread.run(Thread.java:534)
    Can you help me? I can not find anything about this exception
    The same works for me in 10.1.2.0.2
    Thanks and regards,
    -- Smiljka

    OC4J can work with many different DataSources implementations to work against many different databases. We have not hardcoded it work only against an Oracle database. We have reworked the Data Source area in 10.1.3 to make it simpler and more consistent.
    I'd recommend having a read of the the J2EE Services Guide for 10.1.3 (http://download-west.oracle.com/otn/java/oc4j/1013/doc/web.1013/b14427.pdf)
    and have a look at chapter 4 where our new and improved DataSource implementation s discussed.
    -steve-

  • Dynamic method calls in bounded task flows?

    Hi!
    I have the following scenario:
    We are developing a framework in which we would include modules as ADF libraries (as JAR files) with bounded task flows. This framework contains a bean class with bindings for some UI components in framework which I enable or disable (depends on user action). That is the main reason bean class should be present in framework application.
    I have a bounded task flow in every module which needs to call a method in bean with UI component's bindings that would enable or disable that component.
    How can I achieve that? To pass bean as a parameter into bounded task flow and then call its methods? That is dynamic method calls for bean.
    I'm using JDeveloper 11.1.2.1.0
    Thanks for your help
    Regards, Marko

    Hi,
    I explained this; +"I have a bounded task flow in every module which needs to call a method in bean with UI component's bindings that would enable or disable that component. How can I achieve that? To pass bean as a parameter into bounded task flow and then call its methods?"+ a couple of times already (not sure if it was all for you) and don't think I change my position here. I also explained how to use a ValueExpression to lookp a managed bean containing component bindings (should be in requestscope).
    Frank

  • Detecting the source of a method invocation.

    Within a given method, is there a way to detect what class/method made the invocation call?
    I need to find a way to modify instance variables within a method, based on the invoking class ... I thought of navigating back through the Stack, but I am working with a multi-threaded application so I fear that I cannot absolutely depend on the last Stack call being the actual invoking class/method. Any ideas? - please help.
    Many thanks,
    Thomas

    How does one access the method invocation stack?I'm not sure if an easier way exists, but you can extend SecurityManager to fetch the Class context of the current Thread, which will provide you with an array of Class obejcts, ordered according to the method invocation stack. Thus, you can determine what Class invoked a particular method, but you can not determine what Object (not via the SecurityManager funcationality).
    Here is a simple class I often use for such a need (excuse any formating issues- or misspellings in the documenation)... ... although, it should be stated, this class may not work in certain environments- specifically ones that deny permission "createSecurityManager".
    * This class provides static utility methods for retrieving information
    * on the class context.  The methods in this class can provide a
    * resource with a list of the classes that invoked it, thus allowing
    * clases to determine if a particular method is being accessed by
    * the proper caller or allow Class variables to be initialized statically,
    * with out having to instantiate the type.
    * <p>This class is meant to provide simple functionality in familiar
    * environments.  Its funcationality may not work properly when executing
    * in an enviroment with strigent security permissions.  Specifically, if
    * permission is denied to construct a new SecurityManager instance, the
    * methods of this class will fail.
    * @author: Sean Flanerry
    public final class ClassLookup extends SecurityManager {
      private static final ClassLookup instance = new ClassLookup();
      private ClassLookup() { }
      * This method returns the class context for the current thread in format
      * <ul>
      * <li>Class for currently executing method
      * <li>Class that invoked the above method
      * <li>Class that invoked the above method...
      * </ul>
      * The first two elements in the returned array will be of type ClassLookup.
      * @see java.lang.SecurityManager#getClassContext()
      public static Class [] fetchClassContext() {
        return instance.getClassContext();
      * This method returns the Class that invoked this method.  This method
      * is used primarily by static initializers that have to retrieve a handle
      * to the java.lang.Class instance that wraps the current type, but that
      * can not instantiate the current type, eg <br>
      * <code>public static final Class currentClass = ClassLookup.getCallingClass();
      public static Class getCallingClass() {
        return instance.getClassContext()[3];
      * This returns the Class that invoked the current method on the calling
      * Class.  If for example, Race.startRace() invokes Runner.sprint(), Runner.sprint()
      * can determine what class invoked it by calling this method.  In other
      * words, this method lets other methods determine which class invoked
      * it.
      * <p>Remember that this method returns a Class instance for which
      * ever type contains the method which invoked the caller so the
      * Object returned by this method might be the caller's type if the
      * caller was spawned by a method with in the same class.  Consider,
      * <ul>
      * <li>Race.start() invokes
      * <li>Runner.sprint() which invokes
      * <li>Runner.fatigue()
      * </ul>
      * If Runner.fatigue() invokes this method, an instance of Runner.class will
      * be returned, <b>not</b> Race.class because fatigue was invoked by sprint.
      * <p>This method is typically used by resources that wish to determine
      * if the current method is being invoked via the proper context, ie the
      * invoking class is a trused resource.
      public static Class getInvokingClass() {
        return instance.getClassContext()[4];
      public static void main(String args[]) {
        Class [] c = fetchClassContext();
        for (int i = 0; i < c.length; i++) {
          System.out.println(c.getName());

  • Type conflict during dynamic method call.

    While executing the following program I get the error "Type conflict during dynamic method call.":
    DATA: container_r  TYPE REF TO object,
          grid_r       TYPE REF TO object,
          itab_saplane TYPE TABLE OF saplane.
    * IMPORTANT NOTE: class names must be in UPPER CASE
    DATA: str_cnt TYPE seoclsname VALUE 'CL_GUI_CUSTOM_CONTAINER',
          str_gui TYPE seoclsname VALUE 'CL_GUI_ALV_GRID',
          meth_name TYPE STRING VALUE 'SET_TABLE_FOR_FIRST_DISPLAY'.
    TYPE-POOLS abap.
    DATA: ptab    TYPE abap_parmbind_tab,
          wa_ptab LIKE LINE OF ptab,
          ref     TYPE REF TO data.
    CREATE OBJECT container_r TYPE (str_cnt)
      EXPORTING container_name = 'CUSTOM_CONTROL1'. " Name of the custom control area (UC!)
    * Construct parameter itab
    GET REFERENCE OF container_r INTO ref.
    wa_ptab-name  = 'I_PARENT'.  " Must be upper-case
    wa_ptab-value = ref.
    INSERT wa_ptab INTO TABLE ptab.
    *   EXPORTING i_parent = container_r.
    CREATE OBJECT grid_r TYPE (str_gui)
      PARAMETER-TABLE ptab.
    SELECT * FROM saplane INTO CORRESPONDING FIELDS OF TABLE itab_saplane.
    * Cannot call set_table_for_first_display directly...
    CALL METHOD grid_r->(meth_name)
      EXPORTING I_STRUCTURE_NAME = 'SAPLANE'  " Type of the rows in the internal table  (UC!)
      CHANGING  IT_OUTTAB = itab_saplane.     " The internal table itself
    CALL SCREEN 100.
    Any help would be appreciated!

    Hi ...
    Apologies ... for confusion ... actually both are required ...
    the type 'E' as well as CL_GUI_CONTAINER.
    The below code worked for me ...
    check out how I cast it to the parent class type ...
      DATA : lv_container   TYPE seoclsname VALUE 'CL_GUI_CUSTOM_CONTAINER',
             lv_control     TYPE seoclsname VALUE 'CL_GUI_ALV_GRID',
             lv_method      TYPE string VALUE 'SET_TABLE_FOR_FIRST_DISPLAY',
             lt_par_tab     TYPE abap_parmbind_tab,
             ls_param       LIKE LINE OF lt_par_tab,
             lref_cont      TYPE REF TO cl_gui_container,
             lv_data        TYPE REF TO data.
    CREATE OBJECT lref_container
          TYPE
            (lv_container)
          EXPORTING
            container_name = 'ALV_AREA'.
        ls_param-name = 'I_PARENT'.
        ls_param-kind = 'E'.
        lref_cont ?= lref_container.
        GET REFERENCE OF lref_cont INTO lv_data.
        ls_param-value = lv_data.
        INSERT ls_param INTO TABLE lt_par_tab.
    **  Now create ALV Control.
        CREATE OBJECT lref_alv_ctrl
          TYPE
            (lv_control)
          PARAMETER-TABLE
            lt_par_tab.
    **  Set table for 1st display
        DATA : lv.
        lv = lref_alv_ctrl->mc_fc_print.
        CALL METHOD lref_alv_ctrl->(lv_method)
          EXPORTING
            i_structure_name = 'T001'
          CHANGING
            it_outtab        = lt_company.
    Cheers
    Edited by: Varun Verma on Aug 12, 2008 4:19 PM

  • Automatically call specific method at other method invocation~ish?

    I have a class which basically acts as a wrapper around a List. It contains a List object and some methods that do something with that list.
    Now, in order to prevent exceptions, I've made a basic method that just checks if the List field is null and, if so, it will create a new ArrayList and chuck it in that field.
    Right now, I just have a call to that particular method in each other method that performs an operation on the list, like so:
    public class SomeClass<T> {
       private List<T> list;
       private void checkList() {
         if ( list == null) {
           list = new ArrayList<T>();
      public int method() {
        checkList();
        return list.doSomething();
      }Is there a way, prefferably a native Java way, to automatically have the checkList() method called before each and any method invocation? As in, whenever a method is called in the SomeClass, Java / the JVM automatically calls the checkList method?
    }

    Yop wrote:
    I have a class which basically acts as a wrapper around a List. It contains a List object and some methods that do something with that list.
    Now, in order to prevent exceptions, I've made a basic method that just checks if the List field is null and, if so, it will create a new ArrayList and chuck it in that field.
    Right now, I just have a call to that particular method in each other method that performs an operation on the list, like so:
    public class SomeClass<T> {
    private List<T> list;
    private void checkList() {
    if ( list == null) {
    list = new ArrayList<T>();
    public int method() {
    checkList();
    return list.doSomething();
    }Is there a way, prefferably a native Java way, to automatically have the checkList() method called before each and any method invocation? As in, whenever a method is called in the SomeClass, Java / the JVM automatically calls the checkList method?
    }Why not return the List<T> in the check() method? Like this:
    List<T> check() {
       if (list == null) list= new ArrayList<T>();
       return list;
    void otherMethod(T t) {
       check().add(t);
    }Instead of using variable 'list' directly, use the 'check()' method.
    kind regards,
    Jos

  • JVMTI & jni  - object tracing and method invocation

    I need to log all method invocations in the form:
    <caller object's tag, called object's tag>
    May be I 'll elaborate:
    Suppose some object of class B say b invokes a method on an object of
    class A, say instance a..
    In need the info: <object tag of b, object tag of a>
    (P.S. I donot want just the class name.. thats is available in
    stacktrace.)
    Assume tagging is done and each instance is tagged with its
    instantiation history, so two instances of same class may have have
    different tags.
    How do I do this.
    It would be great if I could get some help.

    Hi,
    are you providing in your Setup class (i am assuming is the RMI server) the two arguments constructor needed by Activatable OBject??
    it should look like this
    public Setup(ActivationID id, MarshalledObject data)
    that hopefully solves your problems
    regards
    marco

  • Hi,i am trying to edit a BP and i get this error;An attempt was made to execute a dynamic method callon an initial(NULL-) object reference. The reference must refer to an object. what could be missing?

    BP_....AccountActivitiesOV.htm....application BPBT.
    what could be wrong? An attempt was made to execute a dynamic method callon an initial(NULL-) object reference. The reference must refer to an object???

    Hi Dunamis,
    Please check if below links can help you;
    Error on execution of Web Interface
    Help! I meet this Business Server Page (BSP) error CX_SY_REF_IS_INITIAL
    Strange Error in Transformation of 2LiS_03_BF with 0IC_C03
    Regards,
    Kamfrk.

  • Generic method invocations with explicit type parameters

    If I interpret the JSR14 public draft spec (June 23, 2003) section 5.6 correctly the following method invocations with explicit type parameters should compile: package generics;
    public class G121 {
      void f() {
        this.<String>f2();
        <String>f2(); // compilation error
        <String>f3(); // compilation error
      <T> void f2() {
      static <T> void f3() {
    }but the class does not compile: jc -J-showversion generics\G121.javajava version "1.5.0-beta"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
    Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)
    generics\G121.java:6: illegal start of expression
        <String>f2(); // compilation error
                ^
    generics\G121.java:8: illegal start of expression
        <String>f3(); // compilation error
                ^
    2 errors
    >A bug or do I miss something?

    I get this error:
    LineCount.java:104: cannot find symbol
    symbol : method <java.io.File>sort(java.util.List<java.io.File>)
    location: class java.util.Collections
    Collections.<File>sort( list );
    ^
    1 errorYou don't need the explicit type argument there, but anyway...
    If you look at the docs for Collections.sort(List<T> list) you'll see it is declared as:
    static <T extends Comparable<? super T>> void Collections.sort(List<T> list) Unfortunately, although File implements Comparable, it doesn't actually implement Comparable<File> or even Comparable<Object>, so I guess it can't satisfy the bound.
    You can get it to compile by removing the explicit type argument and casting to the raw type List, but that's not very nice.
    This seems like an oversight to me - File already has both int compareTo(Object o) and int compareTo(File pathname) so I don't see why it can't implement Comparable<File>. This isn't the only such case in the API though, so maybe I'm missing something.
    Mark

  • Dynamic WebService Invocation

    Hi All,
    i am facing a small issue regarding dynamic invocation of webservice from another webservice....
    the probelm is when i tried to invoke a simple webmethod with string return type its working as expected.. and the same method is returning an array of string it started saying cant be able to deserialze the data....
    i dont understand the meaning of this exception... can any body aware of this?
    Regs,
    Veeru

    Hello,
    When you have this error it is often because the JAX-RPC client does not know how to deserialize a specific XML type. In this case you have probably to use a custom mapping type.
    It is quite hard to help you without any "real" information, could you please post the WSDL, the SOAP Response and the error. Also define how you exactly call the WS? JAX-RPC DII?
    In the same time, you may know that we have on OTN a forum dedicated to Web Services
    Regards
    Tugdual Grall

  • Can AS do reflection and method invocation?

    Hello,
    Can actionscript do reflection, instantiation, and subsequent
    invocation of a method, as in java ?
    this.incidentVO=incident;
    Class c = IncidentRules.class;
    Class[] parameterTypes = null;
    Method methodName;
    methodName =
    c.getMethod("validate"+commandName,parameterTypes);
    methodName.setAccessible(true);
    methodName.invoke(this,null);

    Unlike Java, AS is dynamic:
    var ClassReference:Class =
    getDefinitionByName(“flash.display.Sprite”) as Class;
    var instance:Object = new ClassReference();
    instance.graphics.beginFill(bgColor);
    instance.graphics.drawRect(0, 0, size, size);
    instance.graphics.endFill();
    addChild(DisplayObject(instance));
    Note the type of variable called 'instance'. It's Object.
    Still, it's calling method(s) of the underlying object without a
    compile time warning.
    Also, unlike Java AS has construct like object["property"]
    which would either return the reference to the property of null if
    object doesn't have given property.
    Also in AS you have class called Function that represents a
    function.
    Now, the real fun begins! Although AS doesn't have OO
    reflection like Java, but we can combine above constructs to do the
    job.
    here is you basic class with two functions:
    public class XV
    public function hello1(s:String) : void {
    trace('message from XV.hello1: ' + s);
    public function hello2(s:String) : void {
    trace('message from XV.hello2: ' + s);
    now you want to call hello1 and hello2.
    Now, if you run code like:
    1 var xv:XV = new XV();
    2 var m:String = "hello";
    3 var f:Function = xv[m + "1"];
    4 f.call(this, 'Hello World!');
    note line 3 above. You're looking for a property called
    hello1 and you *know* it's a function so you get a reference of it.
    On line 4 so simply call it with only argument of type String!
    Hope this helps!
    ATTA

  • Working with class based exception and dynamic method calls

    Hi Gurus,
    we just changed out ERP from EHP6 to EHP7.
    Since we did so we are facing an issue with an Z-Report we are using quite often.
    This reports looks up Workitems and executes the according methods so that we can go into debugging if we were facing any problems or errors.
    since the EHP Upgrade this statement has problems:
      data:        lt_parmbind   type abap_parmbind_tab,         lt_excpbind   type abap_excpbind_tab,         lo_runtime    type ref to object.     call method lo_runtime->(iv_cls_method)       parameter-table       lt_parmbind       exception-table       lt_excpbind.this CALL METHOD Statement has Problem with the Exception Table. We are quite often getting DYN_CALL_METH_EXCP_NOT_FOUND short dumps with Exception "CX_SY_DYN_CALL_EXCP_NOT_FOUND".
    The system has problems handling the content of lt_excpbind. if i clear this table the CALL METHOD statement works fine.
    AS an example we are trying to call /IDXGC/CL_PD_PROCESS_STEPS-->CREATE_DATA. This method has 2 exceptions
    /IDXGC/CX_PROCESS_ERROR
    Process Layer Exception
    CX_BO_TEMPORARY
    Temporary Business Exception
    The Content of LT_EXCPBIND is
    INDEX
    NAME
    VALUE
    2
    /IDXGC/CX_PROCESS_ERROR
    1
    2
    CX_BO_TEMPORARY
    2
    From my point of view the Problem ist, that they are marked as "class based". I think so because if you looked up the SAP Help for the EXCEPTION-TABLE Statement it is written that is statement only works for none-classbased exception.
    I think that restriction is quiet clear. But what i am wondering about is.. that restriction also exists for EHP6. And in EHP6 it work. Does anyone know why? Or how i can change me CALL METHOD Statement that i will work again?
    Best Regards
    Udo

    Class-based exceptions must be caught using try/catch statement.
    Calling dynamically a method catchable exceptions are:
    CX_SY_DYN_CALL_EXCP_NOT_FOUND
    CX_SY_DYN_CALL_ILLEGAL_CLASS 
    CX_SY_DYN_CALL_ILLEGAL_METHOD
    CX_SY_DYN_CALL_PARAM_MISSING 
    CX_SY_DYN_CALL_PARAM_NOT_FOUND 
    CX_SY_REF_IS_INITIAL
    Anyway catching cx_root (as shown by Matthias) will catch everything is catchable.

Maybe you are looking for

  • Customizing of banks

    Hello, Is there a place in the customizing of bank/payments FBZP, to set up: Domestic payments - the fees charges supposed to be paid by the sender bank, Abroad payments - the fees is to be divided into sender/receiver bank. We have contacted the ban

  • Trying to update now iTunes is gone

    I tried the most recent update and it didnt complete, now the iTunes icon is gone and in looking at the program files it won't appear there either.  In trying to reinstall it won't let me as I need to delete the previous program files first but I can

  • Clicking issue - G560

    I would first like to point out that I'm new to this and if I leave anything rather important out, I'll provide it afterward, I guess. My laptop (Model G560) has been in my possession for over a year now and this morning when I turned it on I could m

  • RMAN scripts needed?

    Hi all, I need RMAN scripts to perform both online and offline backup/recover in windows and unix. I am using oracle 9i. Could you post some examples or links for me? Your help would be greatly appreciated.

  • How to drill down and stay on the dashboard

    Hi: OBIEE 11.1.1.6 I created an Action Link that calls another Answers report, and I display the report on a dashboard. The drill down works, but the target report opens in a new window. How can I provide this simple drill functionality but remain on