bsh.util.commands.javap.bsh Maven / Gradle / Ivy
The newest version!
/**
Print the public fields and methods of the specified class (output similar
to the JDK javap command).
If the argument is a string it is considered to be a class name. If the
argument is an object, the class of the object is used. If the arg is a
class, the class is used. If the argument is a class identifier, the class
identified by the class identifier will be used. e.g. If the argument is
the empty string an error will be printed.
// equivalent
javap( java.util.Date ); // class identifier
javap( java.util.Date.class ); // class
javap( "java.util.Date" ); // String name of class
javap( new java.util.Date() ); // instance of class
@method void javap( String | Object | Class | ClassIdentifier )
*/
bsh.help.javap= "usage: javap( value )";
import bsh.ClassIdentifier;
import java.lang.reflect.Modifier;
javap( Object o )
{
Class clas;
if ( o instanceof ClassIdentifier )
clas = this.caller.namespace.identifierToClass(o);
else if ( o instanceof String )
{
if ( o.length() < 1 ) {
error("javap: Empty class name.");
return;
}
clas = this.caller.namespace.getClass((String)o);
} else if ( o instanceof Class )
clas = o;
else
clas = o.getClass();
print( "Class "+clas+" extends " +clas.getSuperclass() );
this.dmethods=clas.getDeclaredMethods();
//print("------------- Methods ----------------");
for(int i=0; i
© 2015 - 2024 Weber Informatics LLC | Privacy Policy