1 // Show a value given class name and constant name.
3 /* Copyright (C) 2000 Free Software Foundation
5 This file is part of libgcj.
7 This software is copyrighted work licensed under the terms of the
8 Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
11 /* Written by Tom Tromey <tromey@redhat.com>. */
13 // Use like this to print a `static final' value (integers only, not
15 // java showval java.awt.geom.AffineTransform.TYPE_IDENTITY
16 // Prints result like:
18 // In conjunction with a keyboard macro you can do a number of
19 // constants very easily.
21 import java
.lang
.reflect
.*;
25 public static void main (String
[] args
)
27 int ch
= args
[0].lastIndexOf ('.');
28 String className
= args
[0].substring (0, ch
);
29 String constName
= args
[0].substring (ch
+ 1);
32 Class klass
= Class
.forName (className
);
33 Field field
= klass
.getField (constName
);
34 System
.out
.println (constName
+ " = " + field
.getInt (null));
38 System
.out
.println (_
);