summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJohn Keiser <shalom@gnu.org>1998-08-01 23:51:56 +0000
committerJohn Keiser <shalom@gnu.org>1998-08-01 23:51:56 +0000
commita87276fa39d5467b220b49dc263848c5fe8e3391 (patch)
tree5a304a0677c5b9e2722d067eaf50a4cc975f9859 /test
parent2b76ba4cebebcc8dc7dd400cfadeefc3ea90df64 (diff)
downloadclasspath-a87276fa39d5467b220b49dc263848c5fe8e3391.tar.gz
OutputClass will allow us to compare our sigs and exceptions with Sun's.
Diffstat (limited to 'test')
-rwxr-xr-xtest/base/OutputClass.java96
1 files changed, 96 insertions, 0 deletions
diff --git a/test/base/OutputClass.java b/test/base/OutputClass.java
new file mode 100755
index 000000000..430827a68
--- /dev/null
+++ b/test/base/OutputClass.java
@@ -0,0 +1,96 @@
+import java.io.*;
+import gnu.java.lang.*;
+import java.lang.reflect.*;
+
+public class OutputClass {
+ public static void main(String[] args) {
+ for(int i=1;i<args.length;i++) {
+ if(args[i].endsWith(".class")) {
+ args[i] = args[i].substring(0,args[i].length()-6);
+ }
+ args[i] = args[i].replace('/','.');
+ try {
+ try {
+ OutputClass.outputClass(Class.forName(args[i]),new FileOutputStream(args[i]+".out-"+args[0]));
+ } catch(ClassNotFoundException E) {
+ new PrintStream(new FileOutputStream(args[i]+".out-"+args[0])).println(args[i] + ": class missing.");
+ }
+ } catch(IOException e) {
+ }
+ }
+ }
+
+ static void outputClass(Class c, OutputStream o) {
+ PrintStream out = new PrintStream(o);
+ out.println("%class%" + Modifier.toString(sanitizeModifier(c.getModifiers())));
+ // Put implemented interfaces here
+ Field[] f = ClassHelper.getAllFields(c);
+ for(int i=0;i<f.length;i++) {
+ if(Modifier.isPublic(f[i].getModifiers()) || Modifier.isProtected(f[i].getModifiers())) {
+ out.println(
+ "%field%"
+ + Modifier.toString(sanitizeModifier(f[i].getModifiers()))
+ + " "
+ + f[i].getType().getName()
+ + " "
+ + ClassHelper.getTruncatedName(f[i].getName()));
+ }
+ }
+
+ Method[] m = ClassHelper.getAllMethods(c);
+ for(int i=0;i<m.length;i++) {
+ if(Modifier.isPublic(m[i].getModifiers()) || Modifier.isProtected(m[i].getModifiers())) {
+ out.println(
+ "%method%"
+ + Modifier.toString(sanitizeModifier(m[i].getModifiers()))
+ + " "
+ + m[i].getReturnType().getName()
+ + " "
+ + ClassHelper.getTruncatedName(m[i].getName())
+ + "("
+ + printArgs(m[i].getParameterTypes())
+ + ")"
+ + printExceptions(m[i].getExceptionTypes()));
+ }
+ }
+
+ Constructor[] cl = c.getDeclaredConstructors();
+ for(int i=0;i<cl.length;i++) {
+ if(Modifier.isPublic(cl[i].getModifiers()) || Modifier.isProtected(cl[i].getModifiers())) {
+ out.println(
+ "%constructor%"
+ + Modifier.toString(sanitizeModifier(cl[i].getModifiers()))
+ + " "
+ + ClassHelper.getTruncatedName(cl[i].getName())
+ + "("
+ + printArgs(cl[i].getParameterTypes())
+ + ")"
+ + printExceptions(m[i].getExceptionTypes()));
+ }
+ }
+ }
+
+ static String printArgs(Class[] args) {
+ StringBuffer sb = new StringBuffer();
+ for(int i=0;i<args.length;i++) {
+ sb.append(args[i]);
+ if(i!=args.length-1) {
+ sb.append(",");
+ }
+ }
+ return sb.toString();
+ }
+
+ static String printExceptions(Class[] exceptions) {
+ StringBuffer sb = new StringBuffer();
+ for(int i=0;i<exceptions.length;i++) {
+ sb.append(" ");
+ sb.append(exceptions[i].getName());
+ }
+ return sb.toString();
+ }
+
+ static int sanitizeModifier(int modifier) {
+ return modifier & ~(Modifier.SYNCHRONIZED | Modifier.TRANSIENT | Modifier.VOLATILE | Modifier.NATIVE);
+ }
+}