OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [scripts/] [showval.java] - Blame information for rev 775

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 762 jeremybenn
// Show a value given class name and constant name.
2
 
3
/* Copyright (C) 2000  Free Software Foundation
4
 
5
   This file is part of libgcj.
6
 
7
This software is copyrighted work licensed under the terms of the
8
Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
9
details.  */
10
 
11
/* Written by Tom Tromey <tromey@redhat.com>.  */
12
 
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.
20
 
21
import java.lang.reflect.*;
22
 
23
public class showval
24
{
25
  public static void main (String[] args)
26
  {
27
    int ch = args[0].lastIndexOf ('.');
28
    String className = args[0].substring (0, ch);
29
    String constName = args[0].substring (ch + 1);
30
    try
31
      {
32
        Class klass = Class.forName (className);
33
        Field field = klass.getField (constName);
34
        System.out.println (constName + " = " + field.getInt (null));
35
      }
36
    catch (Throwable _)
37
      {
38
        System.out.println (_);
39
      }
40
  }
41
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.