Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

Signature.java

00001 package gov.nasa.arc.ase.jpf.tools;
00002 
00003 //#ifdef BUCHI && BANDERA
00004 import java.lang.reflect.*;
00005 
00006 class Signature {
00007   private static String getArrayTypeName(Class c) {
00008     return "[" + name(c.getComponentType());
00009   }  
00010   private static String getPrimitiveTypeName(String s) {
00011     if(s.equals("boolean")) return "Z";
00012     if(s.equals("character")) return "C";
00013     if(s.equals("byte")) return "B";
00014     if(s.equals("short")) return "S";
00015     if(s.equals("int")) return "I";
00016     if(s.equals("long")) return "J";
00017     if(s.equals("float")) return "F";
00018     if(s.equals("double")) return "D";
00019     if(s.equals("void")) return "V";
00020 
00021     return null;
00022   }  
00023   public static String getSignature(Method m) {
00024     StringBuffer sb = new StringBuffer();
00025 
00026     sb.append(m.getName());
00027 
00028     sb.append('(');
00029 
00030     Class[] types = m.getParameterTypes();
00031     for(int j = 0, l1 = types.length; j < l1; j++)
00032       sb.append(name(types[j]));
00033 
00034     sb.append(')');
00035 
00036     sb.append(name(m.getReturnType()));
00037 
00038     return sb.toString();
00039   }  
00040   private static String name(Class c) {
00041     if(c.isPrimitive())
00042       return getPrimitiveTypeName(c.getName());
00043     else if(c.isArray())
00044       return getArrayTypeName(c);
00045     else
00046       return "L" + c.getName().replace('.', '/') + ";";
00047   }  
00048 }

Generated at Thu Feb 7 06:54:52 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001