FileDocCategorySizeDatePackage
MyJavaP.javaAPI DocExample1722Sat Nov 25 12:55:24 GMT 2000None

MyJavaP

public class MyJavaP extends Object
JavaP prints structural information about classes. For each class, all public fields and methods are listed. "Reflectance" is used to look up the information.
author
Ian Darwin, Ian@DarwinSys.com
version
$Id: MyJavaP.java,v 1.3 2000/11/25 17:55:25 ian Exp $

Fields Summary
Modifier
m
A "Modifier" object, to decode modifiers of fields/methods
Constructors Summary
Methods Summary
protected voiddoClass(java.lang.String className)
Format the fields and methods of one class, given its name.


		try {
			Class c = Class.forName(className);
			System.out.println(m.toString(c.getModifiers()) + ' " + c + " {");
			int i, mods;
			Field fields[] = c.getFields();
			for (i = 0; i < fields.length; i++) {
				if (!m.isPrivate(fields[i].getModifiers())
				 && !m.isProtected(fields[i].getModifiers()))
					System.out.println("\t" + fields[i]);
			}

			Method methods[] = c.getMethods();
			for (i = 0; i < methods.length; i++) {
				if (!m.isPrivate(methods[i].getModifiers())
				 && !m.isProtected(methods[i].getModifiers()))
					System.out.println("\t" + methods[i]);
			}
		} catch (ClassNotFoundException e) {
			System.err.println("Error: Class " + 
				className + " not found!");
		} catch (Exception e) {
			System.err.println(e);
		} finally {
			System.out.println("}");
		}
	
public static voidmain(java.lang.String[] argv)
Simple main program, construct self, process each class name found in argv.


	            	 
	     
		MyJavaP pp = new MyJavaP();

		if (argv.length == 0) {
			System.err.println("Usage: javap className [...]");
			System.exit(1);
		} else for (int i=0; i<argv.length; i++)
			pp.doClass(argv[i]);