Determining class information of method calls.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Determining class information of method calls.

Kenneth Shine

 

Can someone please help understand how, when writing my own checks in CheckStyle, to determine class information of method calls?

 

How do I determine the class of an instance making a method call?  How can I determine the method call is of a method in the class or in a super class or interface?  How can I determine super classes or interfaces of an instance of a class?  This is assuming that the class I am trying to determine is specified in an import statement and not defined in the same file as my code.

 

 

For example, consider the following code fragment:

 

 

public class myClass

{

public void writeToStream(ObjectOutputStream os, String s)

throws IOException

{

os.writeObject (s);

}

}

 

When I running CheckStyle, I can determing that os.writeObject (s) is a method call. 

 

How can I determine that the os in os.writeObject is an instance of class ObjectOutputStream?

 

How can I determine that the os in os.writeObject is a class derived from java.io.OutputStream?

 

How can I determine whether the write method in os.writeObject is a method in os’s class  ObjectOutputStream as opposed to a method in os’s parent class java.io.OutputStream?

 

How can I determine whether the write method in os.writeObject is a method in overridden ObjectOutputStream as opposed to the method in parent class OutputStream?

 

How can I determine that the os in os.writeObject is a class that implements interface DataOutput?

 

How can I determine all the methods of ObjectOutputStream, or OutputStream or DataOutput, etc.

 

 

Thank you for any help in this matter.

 

Ken