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

P

Paka Small

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
 
L

Lew

Paka said:
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.
 
P

Paka Small

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.



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.

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
 
L

Lew

Paka said:
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.
 
P

Paka Small

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


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.

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
 
L

Lew

Paka said:
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.
 
J

Joshua Cranmer

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).
 
P

Paul Cager

On 2/5/2012 8:56 AM, Paka Small wrote: ....

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.
 
P

Paul Cager

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.

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".
 
M

Mayeul

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.
 
S

Stefan Ram

Paka Small said:
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.
 
S

Stefan Ram

Joshua Cranmer said:
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.)
 
S

Stefan Ram

Paul Cager said:
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.
 
D

Daniel Pitts

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


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.

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.
 
L

Lew

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.
 
L

Lew

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top