2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libjava / scripts / showval.java
blobdca399f89f920b8b7adb68ec5d743e42cd707f72
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
9 details. */
11 /* Written by Tom Tromey <tromey@redhat.com>. */
13 // Use like this to print a `static final' value (integers only, not
14 // strings yet):
15 // java showval java.awt.geom.AffineTransform.TYPE_IDENTITY
16 // Prints result like:
17 // TYPE_IDENTITY = 0
18 // In conjunction with a keyboard macro you can do a number of
19 // constants very easily.
21 import java.lang.reflect.*;
23 public class showval
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);
30 try
32 Class klass = Class.forName (className);
33 Field field = klass.getField (constName);
34 System.out.println (constName + " = " + field.getInt (null));
36 catch (Throwable _)
38 System.out.println (_);