sisc.modules.s2j
Class Util

java.lang.Object
  extended by sisc.util.Util
      extended by sisc.data.Expression
          extended by sisc.data.Value
              extended by sisc.data.Procedure
                  extended by sisc.nativefun.NativeProcedure
                      extended by sisc.nativefun.FixableProcedure
                          extended by sisc.nativefun.IndexedFixableProcedure
                              extended by sisc.modules.s2j.Util
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, Immediate, NamedValue, ExpressionVisitee, Version
Direct Known Subclasses:
Conversion, Reflection

public abstract class Util
extends IndexedFixableProcedure

See Also:
Serialized Form

Nested Class Summary
static class Util.SchemeInvocationException
           
 
Field Summary
protected static Symbol S2JB
           
 
Fields inherited from class sisc.nativefun.IndexedFixableProcedure
id
 
Fields inherited from class sisc.data.Expression
annotations, EMPTYSET
 
Fields inherited from class sisc.util.Util
BACKQUOTE, BEGIN, bundles, caseSensitive, EMPTYLIST, EMPTYVEC, EOF, ERRORK, EVAL, EXPSC, EXPTOP, FALSE, FCONT, FIVE, JEXCEPTION, LAMBDA, LOCATION, maxFloatPrecision, MESSAGE, minFloatPrecision, NAME, OTHER, PARENT, permitInterrupts, QUOTE, QUOTESYM, REPORT, SETBANG, SISC, SISC_SPECIFIC, SISCB, SOURCE_COLUMN, SOURCE_FILE, SOURCE_LINE, SYMENV, THIS, TOPLEVEL, TRUE, UNQUOTE, UNQUOTE_SPLICING, VOID, ZV
 
Fields inherited from interface sisc.util.Version
VERSION
 
Constructor Summary
Util()
           
Util(int id)
           
 
Method Summary
static java.lang.Class fixClass(java.lang.Class c)
          Map classes representing primitive types to their corresponding java.lang classes.
static java.lang.Throwable javaException(SchemeException e)
           
static java.lang.Class jclass(Value o)
           
static java.lang.reflect.Constructor jconstr(Value o)
           
static java.lang.reflect.Field jfield(Value o)
           
static java.lang.reflect.Method jmethod(Value o)
           
static java.lang.Object jobj(Value o)
           
static int jtype(Value o)
           
static java.lang.Class makeArrayClass(java.lang.Class c, int dims)
          Construct a class representing an array type for an array with a certain component type and dimensions.
static JavaObject makeJObj(java.lang.Object o)
           
static JavaObject makeJObj(java.lang.Object o, java.lang.Class c)
           
static java.lang.String mangleClassName(java.lang.String s)
           
static java.lang.String mangleFieldName(java.lang.String s)
           
static java.lang.String mangleMethodName(java.lang.String s)
           
static java.lang.String namePrimitiveType(java.lang.Class c)
          Map a primitive type to it's name
static java.lang.String nameType(java.lang.Class c)
          Map a class to its corresponding type name.
static Value objArrayToVec(java.lang.Object[] objs)
           
static Pair objectsToList(java.lang.Object[] objs)
           
static java.lang.Object[] pairToObjects(Pair p)
           
static java.util.Vector pairToObjVect(Pair p)
           
static java.lang.Class resolvePrimitiveType(java.lang.String name)
          Map names of primitive types to their respective classes in the reflection API.
static java.lang.Class resolveType(java.lang.String name)
          Map a type name to its corresponding class.
static java.lang.Class resolveType(java.lang.String name, java.lang.ClassLoader cl)
          Map a type name to its corresponding class.
static JavaObject sjobj(Value o)
           
 
Methods inherited from class sisc.nativefun.IndexedFixableProcedure
deserialize, serialize
 
Methods inherited from class sisc.nativefun.FixableProcedure
apply, apply, apply, apply, apply, doApply
 
Methods inherited from class sisc.nativefun.NativeProcedure
apply, display
 
Methods inherited from class sisc.data.Procedure
error, throwArgSizeException, throwNestedPrimException, throwNestedPrimException, throwPrimException
 
Methods inherited from class sisc.data.Value
displayNamedOpaque, equals, eqv, eval, express, getValue, synopsis, synopsis, toString, valueEqual, valueHashCode, write, writeReplace
 
Methods inherited from class sisc.data.Expression
deserializeAnnotations, getAnnotation, getAnnotation, getAnnotationKeys, getAnnotations, getName, readExternal, readResolve, serializeAnnotations, setAnnotation, setAnnotation, setName, visit, visitAnnotations, writeExternal
 
Methods inherited from class sisc.util.Util
annotated, annotatedAppEval, append, argCheck, argsToSymbols, assq, bininport, bininstream, binoutport, binoutstream, box, character, charinport, charinreader, charoutport, charoutwriter, charsetFromString, chr, cont, currentClassLoader, env, error, error, error, error, error, error, error, expr, getDefaultCharacterSet, immutablePair, immutableVector, inport, javaExceptionToString, javaWrap, justify, length, liMessage, liMessage, liMessage, liMessage, liMessage, liMessage, liMessage, list, list, list, list, list, makeURL, mapcar, memq, nlib, num, outport, pair, pairToExpressions, pairToExpVect, pairToValues, proc, read, registerBundle, reverse, reverseInPlace, simpleErrorToString, sourceAnnotations, str, string, sym, symbol, symval, truePair, truth, truth, typeError, typeError, updateName, url, url, url, valArrayToList, valArrayToList, valArrayToVec, vec, warn, warn, warn
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface sisc.data.NamedValue
getName, setName
 

Field Detail

S2JB

protected static final Symbol S2JB
Constructor Detail

Util

public Util()

Util

public Util(int id)
Method Detail

javaException

public static java.lang.Throwable javaException(SchemeException e)

jtype

public static final int jtype(Value o)

sjobj

public static final JavaObject sjobj(Value o)

jobj

public static final java.lang.Object jobj(Value o)

jclass

public static final java.lang.Class jclass(Value o)

jconstr

public static final java.lang.reflect.Constructor jconstr(Value o)

jmethod

public static final java.lang.reflect.Method jmethod(Value o)

jfield

public static final java.lang.reflect.Field jfield(Value o)

makeJObj

public static final JavaObject makeJObj(java.lang.Object o)

makeJObj

public static final JavaObject makeJObj(java.lang.Object o,
                                        java.lang.Class c)

objArrayToVec

public static final Value objArrayToVec(java.lang.Object[] objs)

objectsToList

public static final Pair objectsToList(java.lang.Object[] objs)

pairToObjVect

public static java.util.Vector pairToObjVect(Pair p)

pairToObjects

public static final java.lang.Object[] pairToObjects(Pair p)

makeArrayClass

public static java.lang.Class makeArrayClass(java.lang.Class c,
                                             int dims)
Construct a class representing an array type for an array with a certain component type and dimensions. The Java reflection API offers no easy way of doing this, so instead we have to create an array instance of the specific type with zero-length dimensions and then get its class.

Parameters:
c - component type of the array type
dims - number of dimensions of the array type
Returns:
array type

resolvePrimitiveType

public static java.lang.Class resolvePrimitiveType(java.lang.String name)
Map names of primitive types to their respective classes in the reflection API.

Parameters:
name - primitive type name
Returns:
class corresponding to the primitive type, or null if the name was not recognized as that of a primitive type

namePrimitiveType

public static java.lang.String namePrimitiveType(java.lang.Class c)
Map a primitive type to it's name

Parameters:
c - primitive type class
Returns:
name corresponding to the primitive type, or null if the class was not recognized as that of a primitive type

resolveType

public static java.lang.Class resolveType(java.lang.String name,
                                          java.lang.ClassLoader cl)
                                   throws java.io.IOException
Map a type name to its corresponding class. At the center of this is the Class.forName method. However, that method cannot handle primitive types and array types (actually it can, but one needs to use the VM-internal type coding scheme), so we handle these case separately.

Parameters:
name - type name
cl - classloader to use
Returns:
a Class value
Throws:
java.io.IOException

resolveType

public static java.lang.Class resolveType(java.lang.String name)
                                   throws java.io.IOException
Map a type name to its corresponding class. This just calls resolveType(name, currentClassLoader()).

Throws:
java.io.IOException

nameType

public static java.lang.String nameType(java.lang.Class c)
Map a class to its corresponding type name. At the center of this is the Class.getName() method. However, that method cannot handle primitive types and array types (actually it can, but one needs to use the VM-internal type coding scheme), so we handle these case separately.

Parameters:
c - class
Returns:
string naming the type

fixClass

public static java.lang.Class fixClass(java.lang.Class c)
Map classes representing primitive types to their corresponding java.lang classes. This is a hack so that we can pretend that primitive types are assignable to their respective java.lang classes and visa versa.

Parameters:
c - class
Returns:
if c is a class representing a primitive type then the corresponding java.lang class is returned, otherwise the original class.

mangleFieldName

public static java.lang.String mangleFieldName(java.lang.String s)

mangleMethodName

public static java.lang.String mangleMethodName(java.lang.String s)

mangleClassName

public static java.lang.String mangleClassName(java.lang.String s)