Main Content

What methods are available on this Java object?

Archive - Originally posted on "The Horse's Mouth" - 2010-07-08 23:25:01 - Graham Ellis

Q: "What can I do with an ArrayIndexOutOfBoundsException?" for example ...

A: Use the javap utility to ask what methods are available on the class ... and descent into its base class structure too, using further javap calls:

wizard:java graham$ javap java.lang.ArrayIndexOutOfBoundsException
Compiled from "ArrayIndexOutOfBoundsException.java"
public class java.lang.ArrayIndexOutOfBoundsException extends java.lang.IndexOutOfBoundsException{
public java.lang.ArrayIndexOutOfBoundsException();
public java.lang.ArrayIndexOutOfBoundsException(int);
public java.lang.ArrayIndexOutOfBoundsException(java.lang.String);
}
 
wizard:java graham$ javap java.lang.IndexOutOfBoundsException
Compiled from "IndexOutOfBoundsException.java"
public class java.lang.IndexOutOfBoundsException extends java.lang.RuntimeException{
public java.lang.IndexOutOfBoundsException();
public java.lang.IndexOutOfBoundsException(java.lang.String);
}
 
wizard:java graham$ javap java.lang.RuntimeException
Compiled from "RuntimeException.java"
public class java.lang.RuntimeException extends java.lang.Exception{
static final long serialVersionUID;
public java.lang.RuntimeException();
public java.lang.RuntimeException(java.lang.String);
public java.lang.RuntimeException(java.lang.String, java.lang.Throwable);
public java.lang.RuntimeException(java.lang.Throwable);
}
 
wizard:java graham$ javap java.lang.Exception
Compiled from "Exception.java"
public class java.lang.Exception extends java.lang.Throwable{
static final long serialVersionUID;
public java.lang.Exception();
public java.lang.Exception(java.lang.String);
public java.lang.Exception(java.lang.String, java.lang.Throwable);
public java.lang.Exception(java.lang.Throwable);
}
 
wizard:java graham$ javap java.lang.Throwable
Compiled from "Throwable.java"
public class java.lang.Throwable extends java.lang.Object implements java.io.Serializable{
public java.lang.Throwable();
public java.lang.Throwable(java.lang.String);
public java.lang.Throwable(java.lang.String, java.lang.Throwable);
public java.lang.Throwable(java.lang.Throwable);
public java.lang.String getMessage();
public java.lang.String getLocalizedMessage();
public java.lang.Throwable getCause();
public synchronized java.lang.Throwable initCause(java.lang.Throwable);
public java.lang.String toString();
public void printStackTrace();
public void printStackTrace(java.io.PrintStream);
public void printStackTrace(java.io.PrintWriter);
public synchronized native java.lang.Throwable fillInStackTrace();
public java.lang.StackTraceElement[] getStackTrace();
public void setStackTrace(java.lang.StackTraceElement[]);
}
 
wizard:java graham$ javap java.lang.Object
Compiled from "Object.java"
public class java.lang.Object{
public java.lang.Object();
public final native java.lang.Class getClass();
public native int hashCode();
public boolean equals(java.lang.Object);
protected native java.lang.Object clone() throws java.lang.CloneNotSupportedException;
public java.lang.String toString();
public final native void notify();
public final native void notifyAll();
public final native void wait(long) throws java.lang.InterruptedException;
public final void wait(long, int) throws java.lang.InterruptedException;
public final void wait() throws java.lang.InterruptedException;
protected void finalize() throws java.lang.Throwable;
static {};
}


I can feel a bit of scripting coming on (Jython would seem appropriate!) if I wanted to do that sort of thing on a regular basis!