PageRenderTime 47ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-1-pre5/bsh/commands/javap.bsh

#
Unknown | 46 lines | 38 code | 8 blank | 0 comment | 0 complexity | 6542814922bf8fb006237ebb6ed4869d MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. /**
  2. Print the public fields and methods of the specified class (output similar
  3. to the JDK javap command).
  4. <p>
  5. If the argument is a
  6. string it is considered to be a class name. If the argument is an object,
  7. the class of the object is used. If the arg is a class, the class is used.
  8. @method void javap( String | Object | Class )
  9. */
  10. bsh.help.javap= "usage: javap( value )";
  11. import bsh.Name;
  12. javap( Object o )
  13. {
  14. import java.lang.reflect.Modifier;
  15. if ( o instanceof Name.ClassIdentifier )
  16. clas = this.namespace.identifierToClass(o);
  17. if ( o instanceof String)
  18. clas = this.namespace.getClass((String)o);
  19. else if ( o instanceof Class )
  20. clas = o;
  21. else
  22. clas = o.getClass();
  23. print( "Class "+clas+" extends " +clas.getSuperclass() );
  24. methods=clas.getDeclaredMethods();
  25. //print("------------- Methods ----------------");
  26. for(int i=0; i<methods.length; i++) {
  27. m = methods[i];
  28. if ( Modifier.isPublic( m.getModifiers() ) )
  29. print( m );
  30. }
  31. //print("------------- Fields ----------------");
  32. fields=clas.getDeclaredFields();
  33. for(int i=0; i<fields.length; i++) {
  34. f = fields[i];
  35. if ( Modifier.isPublic( f.getModifiers() ) )
  36. print( f );
  37. }
  38. }