Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > comp.lang.java.programmer > #5588

Re: Passing a Method Name to a Method

From Roedy Green <see_website@mindprod.com.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Passing a Method Name to a Method
Date 2011-06-23 09:43 -0700
Organization Canadian Mind Products
Message-ID <4vq607tagbt5k7lafac76sk7vr974j2lhn@4ax.com> (permalink)
References <81h4075t4gfjglji1n033rb20025ebho68@4ax.com>

Show all headers | View raw


On Wed, 22 Jun 2011 12:46:32 -0700, Gene Wirchenko <genew@ocis.net>
wrote, quoted or indirectly quoted someone who said :

>????? How exactly is this done?  MethodToUse(actual parms)
>        ...
 You are presuming that Java works internally like assembler or C
where all methods exist as machine code and have an address,
determined pretty much at link time.

In Java it is much more complicated than that. Before a class is ever
used, the method reference only exists as a string.  The first time it
is invoked, the class is loaded, the method offset looked up and the
caller is patched to this offset.  Later code gets converted to
machine code via hotspot, and you have machine address links rather
than offsets in byte code.

That's the bad news. The good news is you can pass methods and classes
about as strings, and dynamically invoke methods with constructed
parameter lists.  This is ugly and cumbersome and slow, but very
flexible.  See http://mindprod.com/jgloss/reflection.html
You can do a lot with simply dynamic loading of variant classes that
support an interface. See http://mindprod.com/jgloss/classforname.html
http://mindprod.com/jgloss/delegate.html
-- 
Roedy Green Canadian Mind Products
http://mindprod.com
One of the great annoyances in programming derives from the irregularity
of English spelling especially when you have international teams.  
I want to find a method or variable, but I don't know precisely
how its is spelled or worded. English is only approximately phonetic.  
Letters are randomly doubled.  The dictionary often lists variant spellings.
British, Canadian and American spellings differ.I would like to see an 
experiment where variable names were spelled in a simplified English, where 
there were no double letters.I also think you could add a number of rules 
about composing variable names so that a variable name for something would
be highly predictable. You would also need automated enforcement of the 
rules as well as possible.

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Find similar


Thread

Passing a Method Name to a Method Gene Wirchenko <genew@ocis.net> - 2011-06-22 12:46 -0700
  Re: Passing a Method Name to a Method "Fuschia, President-Elect of the Bright Purplish-Green Council" <fp-eotbp-gc@ibm.com> - 2011-06-22 16:00 -0400
    Re: Passing a Method Name to a Method Gene Wirchenko <genew@ocis.net> - 2011-06-23 14:40 -0700
      Re: isIdentifierCharacter (was: Passing a Method Name to a Method) Gene Wirchenko <genew@ocis.net> - 2011-06-23 16:09 -0700
  Re: Passing a Method Name to a Method markspace <-@.> - 2011-06-22 14:14 -0700
    Re: Passing a Method Name to a Method "Fuschia, President-Elect of the Bright Purplish-Green Council" <fp-eotbp-gc@ibm.com> - 2011-06-22 22:59 -0400
    Re: Passing a Method Name to a Method blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-06-23 17:49 +0000
      Re: Passing a Method Name to a Method markspace <-@.> - 2011-06-23 11:22 -0700
        Re: Passing a Method Name to a Method blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-06-24 19:15 +0000
  Re: Passing a Method Name to a Method Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-06-22 22:09 -0400
    Re: Passing a Method Name to a Method Gene Wirchenko <genew@ocis.net> - 2011-06-23 09:07 -0700
      Re: Passing a Method Name to a Method "Fuschia, President-Elect of the Bright Purplish-Green Council" <fp-eotbp-gc@ibm.com> - 2011-06-23 13:43 -0400
        Re: Passing a Method Name to a Method Nebulous <nebulous99@gmail.com> - 2011-06-23 13:57 -0700
      Re: Passing a Method Name to a Method Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-06-24 07:28 -0400
    Re: Passing a Method Name to a Method blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-06-23 17:53 +0000
  Re: Passing a Method Name to a Method Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-06-22 22:30 -0400
    Re: Passing a Method Name to a Method Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-06-23 09:06 -0300
      Re: Passing a Method Name to a Method Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-06-23 13:23 -0300
        Re: Passing a Method Name to a Method Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-06-23 09:33 -0700
          Re: Passing a Method Name to a Method Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-06-23 17:53 -0300
            Re: Passing a Method Name to a Method Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-06-23 19:15 -0700
              Re: Passing a Method Name to a Method "Fuschia, President-Elect of the Bright Purplish-Green Council" <fp-eotbp-gc@ibm.com> - 2011-06-24 01:48 -0400
                Re: Passing a Method Name to a Method Joshua Cranmer <Pidgeot18@verizon.invalid> - 2011-06-24 02:20 -0400
                Re: Passing a Method Name to a Method "Fuschia, President-Elect of the Bright Purplish-Green Council" <fp-eotbp-gc@ibm.com> - 2011-06-25 15:26 -0400
      Re: Passing a Method Name to a Method "Fuschia, President-Elect of the Bright Purplish-Green Council" <fp-eotbp-gc@ibm.com> - 2011-06-23 13:42 -0400
        Re: Passing a Method Name to a Method markspace <-@.> - 2011-06-23 11:32 -0700
          Re: Passing a Method Name to a Method Arved Sandstrom <asandstrom3minus1@eastlink.ca> - 2011-06-23 16:23 -0300
          Re: Passing a Method Name to a Method "Fuschia, President-Elect of the Bright Purplish-Green Council" <fp-eotbp-gc@ibm.com> - 2011-06-23 15:46 -0400
      Re: Passing a Method Name to a Method Gene Wirchenko <genew@ocis.net> - 2011-06-23 16:29 -0700
    Re: Passing a Method Name to a Method Gene Wirchenko <genew@ocis.net> - 2011-06-23 14:44 -0700
      Re: Passing a Method Name to a Method Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-06-24 07:48 -0400
  Re: Passing a Method Name to a Method Roedy Green <see_website@mindprod.com.invalid> - 2011-06-23 09:43 -0700

csiph-web