f



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

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
0
paka-en (25)
2/5/2012 4:56:49 PM
comp.lang.java.programmer 52714 articles. 1 followers. Post Follow

19 Replies
1686 Views

Similar Articles

[PageSpeed] 56

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
0
lewbloch (1508)
2/5/2012 7:38:05 PM
On 5 feb, 20:38, Lew <lewbl...@gmail.com> 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 well=
 ask, "Is 'int' a primitive or a reference type?". Your vote will not chang=
e 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 J=
ava.
> The law of gravity is not subject to repeal by opinion, and neither is th=
is.
>
> Instead of wasting your time and trying to waste ours conducting meaningl=
ess
> polls, why don't you read the material linked upthread and learn the trut=
h for
> yourself?
>
> Learn the truth and it will set you free, or at least keep you from makin=
g
> 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.". Now=
here and never I have stated that methods are classes. Again please have th=
e decency not to put words in my mouth! Or show me where I have claimed tha=
t 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
0
paka-en (25)
2/5/2012 10:53:47 PM
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
0
lewbloch (1508)
2/6/2012 9:55:00 AM
On 6 feb, 10:55, Lew <lewbl...@gmail.com> 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
0
paka-en (25)
2/6/2012 7:57:35 PM
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
0
lewbloch (1508)
2/7/2012 1:14:46 AM
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
0
Pidgeot18 (1520)
2/7/2012 5:54:04 AM
On 2/5/2012 8:56 AM, 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.
>
> Kind regards, Paka

NO

Though I think a little JLS reading would be better than a poll.

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.

Patricia
0
pats (3556)
2/7/2012 5:58:50 AM
Paka Small <paka-en@tumia.org> wrote:
> Hi,
> 
> Poll: Is a Java Method an Instance of the Java Class
> java.lang.reflect.Method?

Is a file on the filesystem an instance of java.lang.File?

Is a database an instance of javax.sql.DataSource?

Are you an instance of some.corporation.datamodel.Person?

You're confusing a reference to the thing with the thing
itself. 

-- 
Leif Roar Moldskred

0
leifm1143 (162)
2/7/2012 7:09:45 AM
On Feb 7, 5:58=A0am, Patricia Shanahan <p...@acm.org> 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.
0
paul.cager (69)
2/7/2012 10:41:03 AM
No.

On Feb 5, 4:56=A0pm, Paka Small <paka...@tumia.org> 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".
0
paul.cager (69)
2/7/2012 11:01:19 AM
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
0
2/7/2012 11:13:45 AM
Paka Small <paka-en@tumia.org> 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.

0
ram (2986)
2/7/2012 1:42:59 PM
Joshua Cranmer <Pidgeot18@verizon.invalid> 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.)

0
ram (2986)
2/7/2012 1:48:29 PM
Paul Cager <paul.cager@googlemail.com> 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.

0
ram (2986)
2/7/2012 2:19:25 PM
Paul Cager wrote:
> On Feb 7, 5:58 am, Patricia Shanahan <p...@acm.org> 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.

I think an object existing before its class is a lot more problematic
than a class existing before an interface it implements.

Patricia
0
pats (3556)
2/7/2012 5:35:35 PM
On 2/6/12 11:57 AM, Paka Small wrote:
> On 6 feb, 10:55, Lew<lewbl...@gmail.com>  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.
0
2/7/2012 5:52:10 PM
On Tuesday, February 7, 2012 2:41:03 AM UTC-8, Paul Cager wrote:
> On Feb 7, 5:58=A0am, Patricia Shanahan=20
>  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 method=
s
> > were instances of java.lang.reflect.Method they could not have existed
> > before the class existed.
>=20
> 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 objec=
ts=20
would have had to predate the existence of 'Method', not that they couldn't=
=20
have been retrofitted (although really they can't be - another difference f=
rom=20
your analogy). Patricia's logic is flawless.

--=20
Lew
0
lewbloch (1508)
2/7/2012 6:59:38 PM
Stefan Ram wrote:
> Paka Small writes:
>> Poll: Is a Java Method an Instance of the Java Class
>> java.lang.reflect.Method?

>   It's =BBmethod=AB, =BBinstance=AB, and =BBclass=AB;
>   not =BBMethod=AB, =BBInstance=AB, and =BBClass=AB.

Right on!

Case counts, Paka. Carelessness is harmful.

>   The JLS3 says:
>=20
>       =BBA method declares executable code that can be invoked,
>       passing a fixed number of values as arguments.=AB, 8.4.
>=20
>   (So, and when a method already declares something,
>   what then is a =BBmethod declaration=AB? 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=
=20
have said, "A method comprises executable code that ..."

>   JDK 1.0 and 1.1 have no reflection, so when then answer
>   would be =BByes=AB, then they would have no methods.

But really, Paka, taking a poll about what is real is stupid and pointless.=
=20
Opinion doesn't alter reality. However, the correct, factual, real answers =
that=20
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=
=20
step off the tracks, Paka.

--=20
Lew
0
lewbloch (1508)
2/7/2012 7:04:46 PM
In article <7747b7da-e579-4514-bdff-a9eb8842cc51
@l16g2000vbl.googlegroups.com>, paka-en@tumia.org says...
> 
> 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.

NO.
Instances of java.lang.reflect.Method are objects to provide additional 
access to Java methods and they have not been part of the Java ecosystem 
until the reflection API has been introduced.

The Java virtual machine does not instantiate java.lang.reflect.Method 
objects either, if a method call is required, not even the Java bytecode 
expresses something like that.

I don't see why you put up a poll to answer this question, it's not 
disputed and it's not possible to argue about it.

Kind regards,
Wanja

-- 
...Alesi's problem was that the back of the car was jumping up and down 
dangerously - and I can assure you from having been teammate to 
Jean Alesi and knowing what kind of cars that he can pull up with, 
when Jean Alesi says that a car is dangerous - it is. [Jonathan Palmer]

--- Posted via news://freenews.netfront.net/ - Complaints to news@netfront.net ---
0
brixomatic (103)
2/8/2012 3:05:27 PM
Reply: