Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Poll: Is a Java Method an Instance of the Java Classjava.lang.reflect.Method? Please reply with YES or NO.

Reply
Thread Tools

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

 
 
Stefan Ram
Guest
Posts: n/a
 
      02-07-2012
Paka Small <(E-Mail Removed)> 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.

 
Reply With Quote
 
 
 
 
Stefan Ram
Guest
Posts: n/a
 
      02-07-2012
Joshua Cranmer <(E-Mail Removed)> 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.)

 
Reply With Quote
 
 
 
 
Stefan Ram
Guest
Posts: n/a
 
      02-07-2012
Paul Cager <(E-Mail Removed)> 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.

 
Reply With Quote
 
Daniel Pitts
Guest
Posts: n/a
 
      02-07-2012
On 2/6/12 11:57 AM, Paka Small wrote:
> On 6 feb, 10:55, Lew<(E-Mail Removed)> 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.getS etMethodName(), 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.
 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      02-07-2012
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
 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      02-07-2012
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why no one ,no reply for this query??please reply me raviprakash976@gmail.com VHDL 2 12-24-2008 07:04 AM
why can't an instance instantiated within a class method access aprotected instance method? Greg Hauptmann Ruby 9 06-16-2008 10:16 AM
instance method adding another instance method to the class Raj Singh Ruby 2 05-29-2008 10:09 PM
Kernel.y and yes,yes,yes not least surprise Jamie Herre Ruby 1 01-07-2005 07:33 PM
yes yes Kevin Walsh Computer Support 1 08-30-2004 12:55 AM



Advertisments