/jEdit/tags/jedit-4-1-pre4/bsh/commands/javap.bsh
# · Unknown · 46 lines · 38 code · 8 blank · 0 comment · 0 complexity · 6542814922bf8fb006237ebb6ed4869d MD5 · raw file
- /**
- Print the public fields and methods of the specified class (output similar
- to the JDK javap command).
- <p>
- 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.
- @method void javap( String | Object | Class )
- */
- bsh.help.javap= "usage: javap( value )";
- import bsh.Name;
- javap( Object o )
- {
- import java.lang.reflect.Modifier;
- if ( o instanceof Name.ClassIdentifier )
- clas = this.namespace.identifierToClass(o);
- if ( o instanceof String)
- clas = this.namespace.getClass((String)o);
- else if ( o instanceof Class )
- clas = o;
- else
- clas = o.getClass();
-
- print( "Class "+clas+" extends " +clas.getSuperclass() );
- methods=clas.getDeclaredMethods();
- //print("------------- Methods ----------------");
- for(int i=0; i<methods.length; i++) {
- m = methods[i];
- if ( Modifier.isPublic( m.getModifiers() ) )
- print( m );
- }
- //print("------------- Fields ----------------");
- fields=clas.getDeclaredFields();
- for(int i=0; i<fields.length; i++) {
- f = fields[i];
- if ( Modifier.isPublic( f.getModifiers() ) )
- print( f );
- }
- }