Poll: Is a Java Method an Instance of the Java Classjava.lang.reflect.Method? Please reply with YES

Discussion in 'Java' started by Paka Small, Feb 5, 2012.

  1. Paka Small

    Paka Small Guest

    Hi,

    Poll: Is a Java Method an Instance of the Java Class
    java.lang.reflect.Method?

    Please put YES or NO as the first word in your reply. Add comments
    after it if you wish.

    I'll make a YES/NO count after some time.

    Kind regards, Paka
     
    Paka Small, Feb 5, 2012
    #1
    1. Advertising

  2. Paka Small

    Lew Guest

    Paka Small wrote:
    > Poll: Is a Java Method an Instance of the Java Class
    > java.lang.reflect.Method?


    It's not subject to vote. It's defined by the language. You might as well ask, "Is 'int' a primitive or a reference type?". Your vote will not change reality.

    > Please put YES or NO as the first word in your reply. Add comments
    > after it if you wish.
    >
    > I'll make a YES/NO count after some time.


    And what exactly do you hope to accomplish by this exercise? Distinguish who
    knows Java from those who don't?

    A method is not a class, and a class is not a method. That's reality in Java.
    The law of gravity is not subject to repeal by opinion, and neither is this.

    Instead of wasting your time and trying to waste ours conducting meaningless
    polls, why don't you read the material linked upthread and learn the truth for
    yourself?

    Learn the truth and it will set you free, or at least keep you from making
    errors like claiming that methods and classes are the same in Java.

    --
    Lew
     
    Lew, Feb 5, 2012
    #2
    1. Advertising

  3. Paka Small

    Paka Small Guest

    On 5 feb, 20:38, Lew <> wrote:
    > Paka Small wrote:
    > > Poll: Is a Java Method an Instance of the Java Class
    > > java.lang.reflect.Method?

    >
    > It's not subject to vote. It's defined by the language. You might as wellask, "Is 'int' a primitive or a reference type?". Your vote will not change reality.
    >
    > > Please put YES or NO as the first word in your reply. Add comments
    > > after it if you wish.

    >
    > > I'll make a YES/NO count after some time.

    >
    > And what exactly do you hope to accomplish by this exercise? Distinguish who
    > knows Java from those who don't?
    >
    > A method is not a class, and a class is not a method. That's reality in Java.
    > The law of gravity is not subject to repeal by opinion, and neither is this.
    >
    > Instead of wasting your time and trying to waste ours conducting meaningless
    > polls, why don't you read the material linked upthread and learn the truth for
    > yourself?
    >
    > Learn the truth and it will set you free, or at least keep you from making
    > errors like claiming that methods and classes are the same in Java.


    >
    > --
    > Lew


    Dear Lew,

    You write "> Learn the truth and it will set you free, or at least
    keep you from making
    > errors like claiming that methods and classes are the same in Java.". Nowhere and never I have stated that methods are classes. Again please have the decency not to put words in my mouth! Or show me where I have claimed that methods and classes are the same.


    What I have put forward here in this poll and in an earlier discussion
    is that a Java Method is an Instance of the Java Class
    java.lang.reflect.Method. I'm glad you finally admit to this truth.

    Kind regards, Paka
     
    Paka Small, Feb 5, 2012
    #3
  4. Paka Small

    Lew Guest

    Paka Small wrote:
    > Nowhere and never I have stated that methods are classes. Again please have
    > the decency not to put words in my mouth! Or show me where I have claimed
    > that methods and classes are the same.


    I answered that in the other thread, quoting you precisely saying exactly that.

    > What I have put forward here in this poll and in an earlier discussion
    > is that a Java Method is an Instance of the Java Class
    > java.lang.reflect.Method. I'm glad you finally admit to this truth.


    A Java method is not an instance of the Java class java.lang.reflect.Method. A
    method is not an instance of anything in Java. You saying that I "finally admit
    to this truth" doesn't change what I am saying, nor the truth.

    You are mistaken. I have pointed you to the correct documentation.

    Quite frankly I am mystified by your obstinance. The truth is the truth. Why is
    it unpleasant to learn the truth? You seem to have so much invested in
    promulgating this canard that a method is an instance of a class, or that it is
    a class, or that a method is an instance of 'Method'. None of those statements
    are true.

    --
    Lew
     
    Lew, Feb 6, 2012
    #4
  5. Paka Small

    Paka Small Guest

    On 6 feb, 10:55, Lew <> wrote:
    > Paka Small wrote:
    > > Nowhere and never I have stated that methods are classes. Again please have
    > > the decency not to put words in my mouth! Or show me where I have claimed
    > > that methods and classes are the same.

    >
    > I answered that in the other thread, quoting you precisely saying exactly that.
    >
    > > What I have put forward here in this poll and in an earlier discussion
    > > is that a Java Method is an Instance of the Java Class
    > > java.lang.reflect.Method. I'm glad you finally admit to this truth.

    >
    > A Java method is not an instance of the Java class java.lang.reflect.Method. A
    > method is not an instance of anything in Java. You saying that I "finally admit
    > to this truth" doesn't change what I am saying, nor the truth.
    >
    > You are mistaken. I have pointed you to the correct documentation.
    >
    > Quite frankly I am mystified by your obstinance. The truth is the truth. Why is
    > it unpleasant to learn the truth? You seem to have so much invested in
    > promulgating this canard that a method is an instance of a class, or that it is
    > a class, or that a method is an instance of 'Method'. None of those statements
    > are true.
    >
    > --
    > Lew


    Hi,

    Example code proving beyond any doubt that a method is an instance of
    the class java.lang.reflect.Method in Java:

    public final void setValue(BaseObject baseObject, Object value) {
    java.lang.reflect.Method setMethod = null;
    try {
    setMethod =
    baseObjectClass.getJavaClass().getMethod(this.getSetMethodName(), new
    Class[]{this.type});
    } catch (NoSuchMethodException ex) {

    Logger.getLogger(BaseObjectAttribute.class.getName()).log(Level.SEVERE,
    null, ex);
    } catch (SecurityException ex) {

    Logger.getLogger(BaseObjectAttribute.class.getName()).log(Level.SEVERE,
    null, ex);
    }
    try {
    setMethod.invoke(baseObject, new Object[]{value});
    } catch (IllegalAccessException ex) {

    Logger.getLogger(BaseObjectAttribute.class.getName()).log(Level.SEVERE,
    null, ex);
    } catch (IllegalArgumentException ex) {

    Logger.getLogger(BaseObjectAttribute.class.getName()).log(Level.SEVERE,
    null, ex);
    } catch (InvocationTargetException ex) {

    Logger.getLogger(BaseObjectAttribute.class.getName()).log(Level.SEVERE,
    null, ex);
    }
    }

    Kind regards, Paka
     
    Paka Small, Feb 6, 2012
    #5
  6. Paka Small

    Lew Guest

    Paka Small wrote:
    > Example code proving beyond any doubt that a method is an instance of
    > the class java.lang.reflect.Method in Java:


    Posting the same code twice does not make your point any less false.

    --
    Lew
     
    Lew, Feb 7, 2012
    #6
  7. Re: Poll: Is a Java Method an Instance of the Java Class java.lang.reflect.Method?Please reply with YES or NO.

    On 2/5/2012 10:56 AM, Paka Small wrote:
    > Hi,
    >
    > Poll: Is a Java Method an Instance of the Java Class
    > java.lang.reflect.Method?


    .... Hell no, even if you stretch the definitions greatly.

    The latter class is an object which uses internal APIs to the VM to
    collect metadata needed for methods; it is not an instance of any
    internal object itself. It may be the case that it is uniqued to some
    internal construct representing the executable handle for a method
    (IIRC, there are four or five these of though, at least in OpenJDK).

    --
    Beware of bugs in the above code; I have only proved it correct, not
    tried it. -- Donald E. Knuth
     
    Joshua Cranmer, Feb 7, 2012
    #7
  8. Paka Small

    Paul Cager Guest

    On Feb 7, 5:58 am, Patricia Shanahan <> wrote:
    > On 2/5/2012 8:56 AM, Paka Small wrote:

    ....
    > > Poll: Is a Java Method an Instance of the Java Class
    > > java.lang.reflect.Method?

    >
    > Historically, JDK 1.0 had methods, but not java.lang.reflect. If methods
    > were instances of java.lang.reflect.Method they could not have existed
    > before the class existed.


    Much as I agree with your conclusion, I'm not sure about your logic
    there. You could say that JDK 1.0 had java.util.Hashtable but not
    java.util.Map; therefore Hashtable cannot implement Map.
     
    Paul Cager, Feb 7, 2012
    #8
  9. Paka Small

    Paul Cager Guest

    No.

    On Feb 5, 4:56 pm, Paka Small <> wrote:
    > Hi,
    >
    > Poll: Is a Java Method an Instance of the Java Class
    > java.lang.reflect.Method?
    >
    > Please put YES or NO as the first word in your reply. Add comments
    > after it if you wish.
    >
    > I'll make a YES/NO count after some time.


    No, Java methods are not instances of a class.

    java.lang.reflect.Method's Javadoc defines j.l.r.Method as:

    "A Method provides information about, and access to, a single method
    on a class or interface."

    If your question was rephrased as "is it useful to think of Java
    methods as instances of j.l.r.Method?" I'd still have to say "no". It
    just muddies the terminology without any noticeable benefits. It's a
    bit like saying "I like to regard java.util.Dates as Strings with a
    few additional methods".
     
    Paul Cager, Feb 7, 2012
    #9
  10. Paka Small

    Mayeul Guest

    Re: Poll: Is a Java Method an Instance of the Java Class java.lang.reflect.Method?Please reply with YES or NO.

    On 05/02/2012 17:56, Paka Small wrote:
    > Hi,
    >
    > Poll: Is a Java Method an Instance of the Java Class
    > java.lang.reflect.Method?
    >
    > Please put YES or NO as the first word in your reply. Add comments
    > after it if you wish.
    >
    > I'll make a YES/NO count after some time.


    NO.

    Rationale: I suppose by 'Java Method' the question meant 'Java method',
    without needless capitalization of the word 'method'. And a 'Java
    method' seems clearly to mean a 'method of a class in Java'.

    A method is not an instance of any class, in particular it is not an
    instance of the class java.lang.reflect.Method. Hence the answer no.

    Rationale for my supposition: If 'Java Method' did not mean 'Java
    method', the only reasonable thing it could mean instead, would be, 'an
    instance of the Method class in Java' and the Method class is usually
    assumed to be java.lang.reflect.Method.
    In that case, the question would be asking a tautolgy, which bears less
    point than anything else.

    --
    Mayeul
     
    Mayeul, Feb 7, 2012
    #10
  11. Paka Small

    Stefan Ram Guest

    Re: Poll: Is a Java Method an Instance of the Java Class java.lang.reflect.Method? Please reply with YES or NO.

    Paka Small <> writes:
    >Poll: Is a Java Method an Instance of the Java Class
    >java.lang.reflect.Method?


    It's »method«, »instance«, and »class«;
    not »Method«, »Instance«, and »Class«.

    The JLS3 says:

    »A method declares executable code that can be invoked,
    passing a fixed number of values as arguments.«, 8.4.

    (So, and when a method already declares something,
    what then is a »method declaration«? The declaration
    of a declaration?)

    JDK 1.0 and 1.1 have no reflection, so when then answer
    would be »yes«, then they would have no methods.
     
    Stefan Ram, Feb 7, 2012
    #11
  12. Paka Small

    Stefan Ram Guest

    Re: Poll: Is a Java Method an Instance of the Java Class java.lang.reflect.Method? Please reply with YES or NO.

    Joshua Cranmer <> writes:
    >The latter class is an object which uses internal APIs to the VM to


    A class is never an object. (The class X has the class object X.class,
    though.)
     
    Stefan Ram, Feb 7, 2012
    #12
  13. Paka Small

    Stefan Ram Guest

    Re: Poll: Is a Java Method an Instance of the Java Class java.lang.reflect.Method? Please reply with YES or NO.

    Paul Cager <> writes:
    >You could say that JDK 1.0 had java.util.Hashtable but not
    >java.util.Map; therefore Hashtable cannot implement Map.


    It is true, that in JDK 1.0, »java.util.Hashtable« does not
    implement »java.util.Map«.

    Of course, mixing versions can lead to contradictions, for
    example: »java.util.Hashtable« does (1.7) and does not (1.0)
    implement »java.util.Map«.

    Usually, we refer to 1.7. But in this case one may refer to
    1.0, which already had methods, but no »java.lang.reflect.Method«.
    In this argument, versions are not mixed, but both the word
    »method« and the class name »java.lang.reflect.Method« refer
    to the JDK 1.0.
     
    Stefan Ram, Feb 7, 2012
    #13
  14. Paka Small

    Daniel Pitts Guest

    Re: Poll: Is a Java Method an Instance of the Java Class java.lang.reflect.Method?Please reply with YES or NO.

    On 2/6/12 11:57 AM, Paka Small wrote:
    > On 6 feb, 10:55, Lew<> wrote:
    >> Paka Small wrote:
    >>> Nowhere and never I have stated that methods are classes. Again please have
    >>> the decency not to put words in my mouth! Or show me where I have claimed
    >>> that methods and classes are the same.

    >>
    >> I answered that in the other thread, quoting you precisely saying exactly that.
    >>
    >>> What I have put forward here in this poll and in an earlier discussion
    >>> is that a Java Method is an Instance of the Java Class
    >>> java.lang.reflect.Method. I'm glad you finally admit to this truth.

    >>
    >> A Java method is not an instance of the Java class java.lang.reflect.Method. A
    >> method is not an instance of anything in Java. You saying that I "finally admit
    >> to this truth" doesn't change what I am saying, nor the truth.
    >>
    >> You are mistaken. I have pointed you to the correct documentation.
    >>
    >> Quite frankly I am mystified by your obstinance. The truth is the truth. Why is
    >> it unpleasant to learn the truth? You seem to have so much invested in
    >> promulgating this canard that a method is an instance of a class, or that it is
    >> a class, or that a method is an instance of 'Method'. None of those statements
    >> are true.
    >>
    >> --
    >> Lew

    >
    > Hi,
    >
    > Example code proving beyond any doubt that a method is an instance of
    > the class java.lang.reflect.Method in Java:
    >
    > public final void setValue(BaseObject baseObject, Object value) {
    > java.lang.reflect.Method setMethod = null;
    > try {
    > setMethod =
    > baseObjectClass.getJavaClass().getMethod(this.getSetMethodName(), new
    > Class[]{this.type});
    > } catch (NoSuchMethodException ex) {
    >
    > Logger.getLogger(BaseObjectAttribute.class.getName()).log(Level.SEVERE,
    > null, ex);
    > } catch (SecurityException ex) {
    >
    > Logger.getLogger(BaseObjectAttribute.class.getName()).log(Level.SEVERE,
    > null, ex);
    > }
    > try {
    > setMethod.invoke(baseObject, new Object[]{value});
    > } catch (IllegalAccessException ex) {
    >
    > Logger.getLogger(BaseObjectAttribute.class.getName()).log(Level.SEVERE,
    > null, ex);
    > } catch (IllegalArgumentException ex) {
    >
    > Logger.getLogger(BaseObjectAttribute.class.getName()).log(Level.SEVERE,
    > null, ex);
    > } catch (InvocationTargetException ex) {
    >
    > Logger.getLogger(BaseObjectAttribute.class.getName()).log(Level.SEVERE,
    > null, ex);
    > }
    > }
    >
    > Kind regards, Paka


    java.lang.reflect.Method instances are abstracts around the details of a
    method and ways of invoking Java methods. They are not themselves
    methods. Methods are a "signature" + bytecode. Methods are not classes,
    they are part of classes. Methods are not objects, they act on objects.
     
    Daniel Pitts, Feb 7, 2012
    #14
  15. Paka Small

    Lew Guest

    On Tuesday, February 7, 2012 2:41:03 AM UTC-8, Paul Cager wrote:
    > On Feb 7, 5:58 am, Patricia Shanahan
    > wrote:
    > > On 2/5/2012 8:56 AM, Paka Small wrote:

    > ...
    > > > Poll: Is a Java Method an Instance of the Java Class
    > > > java.lang.reflect.Method?

    > >
    > > Historically, JDK 1.0 had methods, but not java.lang.reflect. If methods
    > > were instances of java.lang.reflect.Method they could not have existed
    > > before the class existed.

    >
    > Much as I agree with your conclusion, I'm not sure about your logic
    > there. You could say that JDK 1.0 had java.util.Hashtable but not
    > java.util.Map; therefore Hashtable cannot implement Map.


    That is a red herring. Patricia said that the existence of methods as objects
    would have had to predate the existence of 'Method', not that they couldn't
    have been retrofitted (although really they can't be - another difference from
    your analogy). Patricia's logic is flawless.

    --
    Lew
     
    Lew, Feb 7, 2012
    #15
  16. Paka Small

    Lew Guest

    Stefan Ram wrote:
    > Paka Small writes:
    >> Poll: Is a Java Method an Instance of the Java Class
    >> java.lang.reflect.Method?


    > It's »method«, »instance«, and »class«;
    > not »Method«, »Instance«, and »Class«.


    Right on!

    Case counts, Paka. Carelessness is harmful.

    > The JLS3 says:
    >
    > »A method declares executable code that can be invoked,
    > passing a fixed number of values as arguments.«, 8.4.
    >
    > (So, and when a method already declares something,
    > what then is a »method declaration«? The declaration
    > of a declaration?)


    Good point, Stefan. I have to conclude that "declares" in the cited passage
    means the usual English meaning, not the specific Java meaning. They should
    have said, "A method comprises executable code that ..."

    > JDK 1.0 and 1.1 have no reflection, so when then answer
    > would be »yes«, then they would have no methods.


    But really, Paka, taking a poll about what is real is stupid and pointless.
    Opinion doesn't alter reality. However, the correct, factual, real answers that
    you get from everyone agree with each other. What does that tell you, Paka?

    It's time to start arguing that there's no train bearing down on you and to
    step off the tracks, Paka.

    --
    Lew
     
    Lew, Feb 7, 2012
    #16
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    562
  2. birdsong

    select.poll.poll() never blocks

    birdsong, Feb 12, 2009, in forum: Python
    Replies:
    2
    Views:
    454
    birdsong
    Feb 12, 2009
  3. Jean-Paul Calderone

    Re: select.poll.poll() never blocks

    Jean-Paul Calderone, Feb 12, 2009, in forum: Python
    Replies:
    3
    Views:
    443
    birdsong
    Feb 12, 2009
  4. Jamie Herre
    Replies:
    1
    Views:
    200
    why the lucky stiff
    Jan 7, 2005
  5. Michael Herrmann

    10 sec poll - please reply!

    Michael Herrmann, Nov 20, 2012, in forum: Python
    Replies:
    60
    Views:
    703
    Michael Herrmann
    Nov 29, 2012
Loading...

Share This Page