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