Passing self reference to a method call.

I have classes 'A' & 'B'.
A's method 'M1' calls a B's method 'M2'which takes object of type 'A' as an argument.
Is it possible to use 'this' keyword or do I need to use Class.forName('A')
If not, is there a better way to accomplish the same.
Ex:
public class A
public M1()
//calls a method M2 on B that takes object of type 'A' as argument
B b = new B().M2(this);
}//end of class
public class B
public Object M2(A a)
}//end of class B
Thanks in advance.

Class.forName("A") returns an object of type Class, not an object of type A. So it won't work. this would work.

Similar Messages

  • Passing input parameters to the method call in ADF task flow.

    Hi,
    I have the following use case:
    There is a task flow with 2 jspx pages. In the first page I have 2 input search parameters and search button. the search button calls the webservice data control execute (GET_ACCOUNTOperation) method .
    Displaying the search results in the same page is not a problem , but my requirement is that the search results are to be displayed in the second page in tabular form.
    To achieve this, I dragged the execute method as the method call in the task flow and specified the input parameters for the method call (right click and add parameters) . I am getting the following exception :
    javax.el.MethodNotFoundException: Method not found: GET_ACCOUNTOperation.execute(java.lang.String, java.lang.String)
         at com.sun.el.util.ReflectionUtil.getMethod(Unknown Source)
         at com.sun.el.parser.AstValue.getMethodInfo(Unknown Source)
         at com.sun.el.MethodExpressionImpl.getMethodInfo(Unknown Source)
         at oracle.adf.controller.internal.util.ELInterfaceImpl.getReturnType(ELInterfaceImpl.java:214)
         at oracle.adfinternal.controller.activity.MethodCallActivityLogic.execute(MethodCallActivityLogic.java:135)
         at oracle.adfinternal.controller.engine.ControlFlowEngine.executeActivity(ControlFlowEngine.java:1035)
         at oracle.adfinternal.controller.engine.ControlFlowEngine.doRouting(ControlFlowEngine.java:921)
         at oracle.adfinternal.controller.engine.ControlFlowEngine.doRouting(ControlFlowEngine.java:820)
         at oracle.adfinternal.controller.engine.ControlFlowEngine.routeFromActivity(ControlFlowEngine.java:552)
         at oracle.adfinternal.controller.engine.ControlFlowEngine.performControlFlow(ControlFlowEngine.java:148)
         at oracle.adfinternal.controller.application.NavigationHandlerImpl.handleAdfcNavigation(NavigationHandlerImpl.java:109)
         at oracle.adfinternal.controller.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:78)
         at org.apache.myfaces.trinidadinternal.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:43)
         at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:130)
         at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:190)
         at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:475)
         at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:756)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._invokeApplication(LifecycleImpl.java:889)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:379)
         at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:194)
         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
         at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
         at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
         at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
         at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:205)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:106)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
         at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:446)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:271)
         at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:177)
         at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
         at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
         at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
         at java.security.AccessController.doPrivileged(Native Method)
         at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)
         at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)
    even though the execute method is there and the service is up and running. I am not sure whether its the correct way of doing it. Please shed some light on how to solve this use case
    Some additional info:
    Under the data controls pallete, the GET_ACCOUNTOperation method has a parameters section , which has "part" (java.lang.Object) as
    the input parameter.
    Regards,
    Rampal

    Hi,
    thanks for the quick turn-around. Jdev version that i am using is Studio Edition Version 11.1.1.6.0. And i am using SOAP. Isnt there a way without using a backing bean? I am planning to use it as a portlet. Would'nt creating a backing bean cause a problem in that case?? Also i am confused here . The method that i am dragging is GET_ACCOUNTOperation(Object). I tried passing the hashmap . It gave the following exception :
    javax.el.MethodNotFoundException: Method not found: GET_ACCOUNTOperation.execute(java.util.HashMap)
    Rampal

  • Passing the OUT parameter in method call after connection

    Hi,
        I have created the rfc connection through SAP.net Connector. Now when i want to show all the data of the particular RFC. i need to provide all the fields name and the tables name in method call.
    In that method call i need to provide one paramet which is of type OUT what is that and what i need to provide in that parameter.
    Can anybody suggest on this.
    I can send the code if u need to understand, what exactly i want.
    Regards,
    +Naren

    Its done i am able to connect.

  • Is it possible to pass a "reference to a method" as an argument to a method

    Hi all.
    I really am looking for a way to do this.
    (I may justify my need, but if the answer is "no", I may have to rethink my strategy ..)
    Hope to get a boolean answer to my question soon .. :-)
    Regards
    Ajay Garg

    Java is pass by value, ALWAYS.
    In languages that do support function pointers (a.k.a. "closures" to use the object oriented euphemism) the mechanism leads to no end of trouble as it's constantly and massively abused.
    What you want instead is something like a Strategy or Template Method pattern.

  • How to pass Method Inner Class reference to other method?

    Hi All,
    I am trying to pass the reference of "method inner class".
    Can any one explain me how to pass the reference and where other method will sit in the class, I mean either in Outer Class or in Inner Class ?
    Thanks in advance for ur reply :)
    package methosInnerClass;
    public class MethodLocalInnerClass {
         private String outerName;
         private static String statOuterName;
         public MethodLocalInnerClass(String name, String statName) {
              outerName = name;
              statOuterName = statName;
         public void methodWithLocallClass() {
              class MethodInnerClass {
                   String innerName;
                   MethodInnerClass(String name) {
                        innerName = name;
                   public void displayOuterInner() {
                        System.out.println("Outer Name: " + outerName + "\nOuter StatName: " + MethodLocalInnerClass.statOuterName + "\nInner Name: " + innerName);
              MethodInnerClass methodInner = new MethodInnerClass("Harish");
              methodInner.displayOuterInner();
                    *Pass above reference to other method*
         public static void staticMethodWithLocallClass() {
              class MethodInnerClass {
                   String innerName;
                   MethodInnerClass(String name) {
                        innerName = name;
                   public void displayOuterInner() {
                        // We can not access the non-static instance variable since this method is a static method
                        //System.out.println("Outer Name: " + outerName + "\nOuter StatName: " + MethodLocalInnerClass.statOuterName + "\nInner Name: " + innerName);
                        System.out.println("Outer StatName: " + MethodLocalInnerClass.statOuterName + "\nInner Name: " + innerName);
              new MethodInnerClass("Shakshi").displayOuterInner();
         public static void main(String[] args) {
              new MethodLocalInnerClass("Abhishek","Neeshu").methodWithLocallClass();
              System.out.println("Calling innerClass within static method !!!");
              staticMethodWithLocallClass();
    }

    package donald.test.inner_class;
    public class OutterClass {
         private String outerName;
         private final OutterClass outterClass;
         public OutterClass() {
              outterClass = this;
         public void methodWithInnerClass(final String strValueToPassToInnerClass) {
              class InnerClass {
                   private InnerClass innerClass;
                   private String innerName;
                   InnerClass(String name) {
                        innerName = name;
                   public void displayOuterInner() {
                        System.out.println("Non-Static:\tOuter Name: " + outerName + "\tInner Name: " + innerName);
                        System.out.println("");
                        System.out.println("final String strValueToPassToInnerClass = " + strValueToPassToInnerClass);
                    * @return the innerClass
                   public InnerClass getInnerClass() {
                        return innerClass;
                    * @param innerClass the innerClass to set
                   public void setInnerClass(InnerClass innerClass) {
                        this.innerClass = innerClass;
                    * @return the innerName
                   public String getInnerName() {
                        return innerName;
                    * @param innerName the innerName to set
                   public void setInnerName(String innerName) {
                        this.innerName = innerName;
              InnerClass methodInner = new InnerClass("Inner.Donald");
              methodInner.displayOuterInner();
              System.out.println("My OutterClass " + outterClass.getOuterName());
        // Unknown "MethodInnerClass "
         public void passReferenceOfInnerClassToOtherMethod(     ) {
          * @param args
         public static void main(String[] args) {
              OutterClass outterClass = new OutterClass();
              outterClass.setOuterName("Outter.Donald");
              outterClass.methodWithInnerClass("This Donald is so very cool...!!!  Yeah...!!!");
          * @return the outerName
         public String getOuterName() {
              return outerName;
          * @param outerName the outerName to set
         public void setOuterName(String outerName) {
              this.outerName = outerName;
          * @return the outterClass
         public OutterClass getOutterClass() {
              return outterClass;
    }

  • Why do we need a Self Reference "me" to use the components of a class

    Hi
    I am not clear why do we need a self reference variable "me" to call the components of its own class? when it can be accessed directly as in the following examples?
    In my first example below i can call the method display_name directly without creating a reference object or instance of the class within the class.
    In the second example i am using the self refernce Write me->name to access the component of a class.
    My question is why do we need "me" when i can use the components directly as shown in my first example.
    CLASS egocentric DEFINITION.
      PUBLIC SECTION.
        DATA:
         name(10) TYPE c READ-ONLY.
        METHODS set_name.
        METHODS display_name.
    ENDCLASS.                    "egocentric DEFINITION
    *       CLASS egocentric IMPLEMENTATION
    CLASS egocentric IMPLEMENTATION.
      METHOD set_name.
        MOVE 'Abap Objects' TO name.
        CALL method display_name.
      ENDMETHOD.                    "write_name
      METHOD display_name.
        write: name.
      ENDMETHOD.                    "display_name
    ENDCLASS.                    "egocentric IMPLEMENTATION
    *Global Data
    DATA oref TYPE REF TO egocentric.
    START-OF-SELECTION.
      CREATE OBJECT oref.
      CALL METHOD oref->set_name.
    CLASS egocentric DEFINITION.
            PUBLIC SECTION.
                DATA:
                 name(10) TYPE c VALUE u2018Instructoru2019
    READ-ONLY.
                 METHODS write_name.
    ENDCLASS.
    CLASS egocentric IMPLEMENTATION.
            METHOD write_name.
                WRITE me->name.
            ENDMETHOD.
    ENDCLASS.
    *Global Data
    DATA oref TYPE REF TO egocentric.
    START-OF-SELECTION.
            CREATE OBJECT oref.
            CALL METHOD oref->write_name.

    You can go WIKI and search with ABAP Objects.
    Or do the same in 'advanced search'  and select a search area. You are bound to find something.
    Or this link perhaps:
    [abap objects|http://help.sap.com/saphelp_nw70/helpdata/EN/ce/b518b6513611d194a50000e8353423/content.htm]

  • Arrays are passed by reference or value ?

    Hi peoples,
    I have something interesting here which I need to know. Look into the following classes :
         public class example1 {
         int i[] = {0};
         public static void main(String args[]) {
         int i[] = {1};
         change_i(i);
         System.out.println(i[0]);
         public static void change_i(int i[]) {
         i[0] = 2;
         i[0] *= 2;
         public class example2 {
         int i[] = {0};
         public static void main(String args[]) {
         int i[] = {1};
         change_i(i);
         System.out.println(i[0]);
         public static void change_i(int i[]) {
         int j[] = {2};
         i = j;
    Among the above classes, the class named 'example1' returns the value 4 whereas, the class named 'example2' returns the value 1.
    Any explanations to this one please....
    Cheers,
    Rasmeet

    minglu, you are not doing right.
    i just don't get it why you have i[] as instance variable but never use it ( i[] is declared in every method so each i you refer to in the method is a local varable not member variable that can be shared for the object ).
    your first solution work. but that i = j line is not needed because it has no effect you still cannot change the referrence of i to other int[]. your first soultion just need to be
    public static int[] change_i(int i[]) {
    int j[] = {2};
    return j;
    }anyway, using this solution, the method name will be misleading because the method didnot change i in anyway. i is changed because you assign the return array (j) to i.
    for that second solution also, you didn't use your member variable i at all. what you change is the content of i you pass so the result is correct. but then how is this method different from the first method the original poster posted?
    moreover, java never pass argument to the method by reference it ALWAYS pass by copy.i suppose you define passing by reference in the same way C++ does. all object variable in java is a refernce to Object so passing the variable to method is surely passing the reference to the method but that's not passing by reference. it's passing by copy because what is passed is the copy of the reference to the object, not the reference to the reference to Object. if it is really passing by refernce, then you will be able to change your reference to object to point anywhere because you have the access the address of the reference. but since you don't (you only know where the passed reference is pointing to (you have the COPY of value of reference) but you don't know where the refernce store its value) you can only change the content of the pointed object but not changing the pointed object.
    let me restate this, java always pass by reference.

  • How to get caller object reference from a method

    Hi,
    I am working a already existing Java Swing project, now I got a problem, in a method I need to get the caller object reference otherwise, I can't succeed this operation. So please tell me a way how to get the caller object reference from a method. that method would be static or regular method anything will do for me.
    Edited by: navaneeth.j on Jan 29, 2010 11:20 PM

    navaneeth.j wrote:
    Actually my doubt is, I have a method "addition" method, which is using by many classes so my requirement is in the addition method I want to write a code snippet which will identify and get the the caller object. Actually I tried Reflection.getcallerclass but there I am getting "CLASS" object not the actual object reference, but I want object reference.
    Actually we have a huge project which is writen plain JAVA, so in this project the authors written the Database connection package for single database transaction. so now we are using this project source code for JSF application in this web application the DB package has serve based on the dynamic db connection parameters, so if we want to change this package fully means need to solve the dependency problem in hundreds of classes, so my point is if I can access the caller object in the DB package when ever it gets called by any class from any where of the project. So actually I liked Reflection.getcallerclass, the way of implementation perfectly works for me but it is not giving caller object reference, if something gives the caller object then I can get the DB connection parameters then there is no need to pass the parameters in the hierarchy.You can add a parameter (of type Object) to your addition() method
    and everywhere you call the addition() method also pass this (which from the POW of the addition() method will be a reference to the calling class instance).
    There may be alternative solutions
    but none that require less effort.

  • Passing object references to methods

    i got the Foo class a few minutes ago from the other forum, despite passing the object reference to the baz method, it prints "2" and not "3" at the end.
    but the Passer3 code seems to be different, "p" is passed to test() , and the changes to "pass" in the test method prints "silver 7".
    so i'm totally confused about the whole call by reference thing, can anyone explain?
    class Foo {
        public int bar = 0;
        public static void main(String[] args) {
                Foo foo = new Foo();
                foo.bar = 1;
                System.out.println(foo.bar);
                baz(foo);
                // if this was pass by reference the following line would print 3
                // but it doesn't, it prints 2
                System.out.println(foo.bar);
        private static void baz(Foo foo) {
            foo.bar = 2;
            foo = new Foo();
            foo.bar = 3;
    class Passer2 {
         String str;
         int i;
         Passer2(String str, int i) {
         this.str = str;
         this.i = i;
         void test(Passer2 pass) {
         pass.str = "silver";
         pass.i = 7;
    class Passer3 {
         public static void main(String[] args) {
         Passer2 p = new Passer2("gold", 5);
         System.out.println(p.str+" "+p.i);  //prints gold 5
         p.test(p);
         System.out.println(p.str+" "+p.i);   //prints silver 7
    }

    private static void baz(Foo foo) {
    foo.bar = 2;
    foo = new Foo();
    foo.bar = 3;This sets the bar variable in the object reference by
    foo to 2.
    It then creates a new Foo and references it by foo
    (foo is a copy of the passed reference and cannot be
    seen outside the method).
    It sets the bar variable of the newly created Foo to
    3 and then exits the method.
    The method's foo variable now no longer exists and
    now there is no longer any reference to the Foo
    created in the method.thanks, i think i followed what you said.
    so when i pass the object reference to the method, the parameter is a copy of that reference, and it can be pointed to a different object.
    is that correct?

  • BCS passing dynamic inputs to methods & calling using in O365

    Hi all ,
    I have a requirement to pass dynamic values to BDC methods & retrieve data, for this I have created a BDC model file(which has SQL server as external source) with GenericInvoker methods & upload same to Admin central. how do we access these generic
    methods in Office 365 using JavaScript client object model.
    what are the options we have to invoke methods manually by passing dynamic values.
    I tried below code. but I getting below error.
    The web with URL 'http://XXXXXXXX:26110/sites/RA5' is not an app web. The GetAppBdcCatalog method must be called on an app web.
    Any help on this would be appreciated
    function retrieveListItems() {
    // This code runs when the DOM is ready and creates a context object which is needed to use the SharePoint object model
    $(document).ready(function () {
    context = SP.ClientContext.get_current();
    web = context.get_web();
    context.load(web);
    entity = web.getAppBdcCatalog().getEntity("PersonalDetails", "New external content type");
    context.load(entity);
    lob = entity.getLobSystem();
    context.load(lob);
    lobSystemInstances = lob.getLobSystemInstances();
    context.load(lobSystemInstances);
    context.executeQueryAsync(GetLobSubscribesystemInstance, onQueryFailed);
    function Entity() {
    alert("Reached the Entity method");
    //these are the helper methods and variables
    var context;
    var web;
    var user;
    var entity;
    var lob;
    var lobSystemInstance;
    var lobSystemInstances;
    // Initialize the LobSystemInstance.
    function GetLobSubscribesystemInstance() {
    var $$enum_1_0 = lobSystemInstances.getEnumerator();
    while ($$enum_1_0.moveNext()) {
    var instance = $$enum_1_0.get_current();
    lobSystemInstance = instance;
    context.load(lobSystemInstance);
    break;
    context.executeQueryAsync(Entity, onQueryFailed);
    function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
    ragava_28

    Hi all ,
    I have a requirement to pass dynamic values to BDC methods & retrieve data, for this I have created a BDC model file(which has SQL server as external source) with GenericInvoker methods & upload same to Admin central. how do we access these generic
    methods in Office 365 using JavaScript client object model.
    what are the options we have to invoke methods manually by passing dynamic values.
    I tried below code. but I getting below error.
    The web with URL 'http://XXXXXXXX:26110/sites/RA5' is not an app web. The GetAppBdcCatalog method must be called on an app web.
    Any help on this would be appreciated
    function retrieveListItems() {
    // This code runs when the DOM is ready and creates a context object which is needed to use the SharePoint object model
    $(document).ready(function () {
    context = SP.ClientContext.get_current();
    web = context.get_web();
    context.load(web);
    entity = web.getAppBdcCatalog().getEntity("PersonalDetails", "New external content type");
    context.load(entity);
    lob = entity.getLobSystem();
    context.load(lob);
    lobSystemInstances = lob.getLobSystemInstances();
    context.load(lobSystemInstances);
    context.executeQueryAsync(GetLobSubscribesystemInstance, onQueryFailed);
    function Entity() {
    alert("Reached the Entity method");
    //these are the helper methods and variables
    var context;
    var web;
    var user;
    var entity;
    var lob;
    var lobSystemInstance;
    var lobSystemInstances;
    // Initialize the LobSystemInstance.
    function GetLobSubscribesystemInstance() {
    var $$enum_1_0 = lobSystemInstances.getEnumerator();
    while ($$enum_1_0.moveNext()) {
    var instance = $$enum_1_0.get_current();
    lobSystemInstance = instance;
    context.load(lobSystemInstance);
    break;
    context.executeQueryAsync(Entity, onQueryFailed);
    function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
    ragava_28

  • Passing a method call to a facelet tag

    Hello,
    I am trying to create a JSF confirmation box that replaces the Javascript confirm() function. I am using Seam and Rich Faces 3.2.1. The confirm box is a facelet tag that pops up a modal box with 'cancel' and a 'continue' buttons. Everything is working correctly except for one crucial piece; passing the method call for continue button.
    Here is the set up for the facelets tag in the main xhtml page:
    <at:confirm
        id="confirm"
        title="Confirm"
        message="Do you want to continue"
        buttonText="Continue"
        backingBean="#{confirmAction}"
        method="testMethodTwo"
    />Here is the code for the button inside the facelets tag:
    <a4j:commandLink
        styleClass="rdSplGr1"
        href="#"
        action="#{backingBean[method]}">
        <s:span>#{buttonText}</s:span>
    </a4j:commandLink>The method simply does nothing when the use clicks the button. I am assuming this is due to the lack of "()" however there does not seem to be a way to get those in there. I have tried the following:
    1) placing the parens like this - method="testMethodTwo()"
    2) placing the parens like this - action="#{backingBean[method]()}"
    The first does nothing, the second causes an EL exception.
    I know that it has nothing to do with the modal as I have also placed a button like this into the modal:
    <a4j:commandLink
        styleClass="rdSplGr1"
        href="#"
        action="#{confirmAction.testMethodOne()}">
         <s:span>MethodOne</s:span>
    </a4j:commandLink>That button as you can see has what I am trying to create dynamically and it works like a charm.
    So how do I pass a method call correctly? Or if that is impossible how do I solve the problem of having a the continue button having a different method assigned to it?
    Thanks for any insight into this.
    Edited by: Rhythmicdevil on Aug 4, 2008 7:57 AM

    I agree, reflection should be a last resort. An
    interface would not be useful if you don't know what
    method you want to invoke at compile time. Interfaces
    are useful when you know the method you want to
    invoke, but not the class.That's not true. This is a really lame-ass example but it shows the point.
    public interface RuntimeMethod
       public void method();
    class AClass {
       public static void main(Sting[] args)
          new AClass.handleAtRuntime(
             Factory.getRuntimeMethod(Integer.parse(args[0])));
       public void handleAtRuntime(RuntimeMethod runtime)
          runtime.method();
    class Factory
       public static getRuntimeMethod(int method)
          switch(method)
             case 0: return new RuntimeMethod
                public void method()
                   methodA();
             case 2: return new RuntimeMethod
                public void method()
                   methodB();
             default:
                throw new IllegalArgumentException("bad input");
    }

  • Pass string by reference from subsequence to caller

    Hi, I am unable to pass a string parameter by reference from a subsequence to its caller. Is there a trick in doing this or is it not possible?
    Thank you,
    Chris
    Solved!
    Go to Solution.

    Right Click on the parameter in the subsequence.
    Make sure Pass By Reference is checked.
    jigg
    CTA, CLA
    teststandhelp.com
    ~Will work for kudos and/or BBQ~

  • Why are static methods called with null references,valid ?

    This is my code :
    package inheritance;
    public class inh6{
         public static void method(){
         System.out.println("Called");
         public static void main(String[] args){
              inh6 t4 = null;
         t4.method();
    O/P :
    CalledHere t4 is a null reference and yet we are able to call a method on it,why is null pointerexception not thrown.Why are we able to call static methods using null references ?
    t4 is null means it doesnot refer to any memeory address,hence how is method() called correctly.
    I hope i am clear. :)
    Thank you for your consideration.

    punter wrote:
    jverd wrote:
    Memory addresses have nothing to do with it. I doubt memory addresses are even mentioned once in the JLS.
    By memory address i mean the memory location the reference is pointing to.I know what you mean. But if you think it's relevant, can you show me where in the JLS it says anything about memory locations?
    >
    You can do that because a) t4's type is "reference to inh6" and b) method() is declared static, which means that you don't need an object to call it, just the class. That class comes from the compile time type of t4. The fact that t4 is null at runtime is irrelevant.
    So at compile time the type of t4 is inh6 and hence the method is called.Is it ? Had method() not been static a NullPointerException would have been thrown.Correct.
    With non-static, non-private, non-final methods, which implementation of the method gets called is determined at runtime, buy the class of the object on which it's being called. If any one of those "non"s goes away, then the method is entirely determined at compile time, and in the case of static methods, there's no instance necessary to call the method in the first place.

  • Repeater reference in method call

    Hi,
    I'm trying to reference a value from my repeater component in a method call and it's not working...
    <mx:Repeater id="rep" dataProvider="{data.choice}">
                    <mx:VBox>
                            <mx:Image
                            source="{rep.currentItem.image.@src}"
                            toolTip="{rep.currentItem.image.@alt}"
                            mouseDown="dragIt(event, rep.currentItem.price)"
                            />
                   </mx:VBox>
      </mx:Repeater>
    The dragIt() function looks like this:
    private function dragIt(event:MouseEvent, value:String):void {
    So I want the dragIt() function to get 2 parameters: the event and what is in "rep.currentItem.price"
    The code compiles but then nothing happens and I can't drag the image anymore.
    If I put a string in the method call it works fine...
    i.e.
      mouseDown="dragIt(event, "test")"
    I also tried
    mouseDown="dragIt(event, rep.currentItem.price as String)"
    same problem
    Can anyone help ?
    Is there another way to do this ?

    ok I solved it
    you have to use the event targets getRepeaterItem() method
    so the correct way to use it is:
    <mx:Image
                            source="{rep.currentItem.image.@src}"
                            toolTip="{rep.currentItem.image.@alt}"
                            mouseDown="dragIt(event, event.currentTarget.getRepeaterItem().price)"
                            />

  • How to pass attribute values after ExecuteWithParam to method call

    Hi,
    I am using Jdev 11.1.1.6.
    My use case is that I have mainPage BTF which has ExecuteWithParam as the default activity. This filters the VO using params. I have a requirement to store some of the attributes from current row to pageFlowScope which needs to be passed to multiple child taskflows.
    I can introduce a method call after ExecuteWithParam activity and before the page renders but not sure how should I pass the current row (or something) to this method call to store the values on pageFlowScope.
    What should I pass to this managed bean to store the values on pageFlowScope? Is there any alternative?
    Thanks,
    Jai

    I see two possible ways to get to the attributes. First you can get the iterator current row and get the attributes from there. Second you add attribute bindings to the methods pageDef file for all attributes you are interested in. Then you access them using the attribute binding. I never tested the 2nd method but I guess the framework will fill the attribute bindings like it does in a normal page.
    Sorry, can't give you sample code on this add I'm not in front of a PC.
    Timo

Maybe you are looking for

  • Problems installing Itunes.

    I had downloaded the newest Itunes and every since I did that I have had nothing but problems. I can't use Itunes at all. I have tried uninstalling it and then reinstalling it. Even using older version and it won't let me install. Right when it is ab

  • Time Machine Backup Partition on Ext drive unmounts. Other partition doesnt

    I have a 500 GB OWC Mercury Elite Pro FW/USB drive that has two 250 GB partitions. I use one for storage and one for Time Machine backups and have been using it this way for a long time. The backup partition never unmounts unless I drag it to the tra

  • VLMOVE 321 with nested Handling Unit

    Hi I have the following situation: - Handling Unit active - WM active (with Storage Unit) - QM not active I have nested HUs: .1         HU001 ...2       HU002 ......3    Material A, Batch B1, quantity 10 pcs in inspection stock ...2       HU003 .....

  • Is Logical System required for Solution Manager to work?

    Hi all We will be upgrading to SAP ERP in the near future and will have to use Solution Manager. We only have one company code and no business areas in our configuration. So that, we do not need ALE, consequently, we have not defined/used a logical s

  • "Problem downloading image" from iPhone

    When I connect my iPhone and open iphoto, it lists as "iPad" and when I try to import photos, it says that it cannot because there is a "Problem downloading image." I get an "Import error" when I try importing via Image Capture. I actually removed al