org.erights.e.elib.prim
Class JavaMemberNode

java.lang.Object
  |
  +--org.erights.e.elib.base.MethodNode
        |
        +--org.erights.e.elib.prim.JavaMemberNode
All Implemented Interfaces:
EStackItem, Script
Direct Known Subclasses:
ConstructorNode, InstanceMethodNode, StaticMethodNode, SugarMethodNode, VarGetterNode, VarSetterNode

public abstract class JavaMemberNode
extends MethodNode
implements EStackItem

Untamed: Abstract superclass of all the CRAPI-based wrappers of java.lang.reflect.Members for installing them in VTables as MethodNodes.

Author:
Mark S. Miller

Field Summary
private  CallCounter myCallCounter
           
(package private)  java.lang.reflect.Member myMember
           
 
Constructor Summary
(package private) JavaMemberNode(java.lang.reflect.Member member)
           
 
Method Summary
 void addJavaMemberNodesToMap(FlexMap map)
          Enabled: Add this JavaMemberNode to the map
private  Object[] coerceArgs(Object[] args, OneArgFunc optEjector)
           
 Object execute(Object self, String aVerb, Object[] args)
          Enabled:
(package private) abstract  String explain(String args)
           
 int getArity()
          Enabled:
 String getOptTypedVerb()
          Enabled:
 String getVerb()
          Enabled:
(package private) abstract  Object innerExecute(Object self, Object[] args)
           
 MessageDesc makeMessageType(String verb)
          Enabled:
protected  java.lang.reflect.Member member()
           
(package private)  Object[] optCoerceArgs(Object[] args)
           
abstract  Class[] parameterTypes()
          Enabled:
protected abstract  Class receiverType()
           
abstract  Class returnType()
          Enabled:
 Script shorten(Object optSelf, String aVerb, Object[] args)
          Enabled: Just returns this.
 void subPrintOn(TextWriter out, int priority)
          Enabled:
 String toString()
          Suppressed:
 void traceOn(TextWriter out)
          Enabled:
private static Object trySpecialCoercion(Object self, String aVerb, Object[] args, Throwable problem)
          This is called only when 'self aVerb(args)' has failed due to a coercion-to-Java failure, in which case we try a special case outside our normal coercion theory.
 
Methods inherited from class org.erights.e.elib.base.MethodNode
getDocComment, protocol, respondsTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myMember

final java.lang.reflect.Member myMember

myCallCounter

private final CallCounter myCallCounter
Constructor Detail

JavaMemberNode

JavaMemberNode(java.lang.reflect.Member member)
Method Detail

makeMessageType

public MessageDesc makeMessageType(String verb)
Enabled:

Overrides:
makeMessageType in class MethodNode

getVerb

public String getVerb()
Enabled:

Specified by:
getVerb in class MethodNode

getOptTypedVerb

public String getOptTypedVerb()
Enabled:

Specified by:
getOptTypedVerb in class MethodNode

getArity

public int getArity()
Enabled:

Specified by:
getArity in class MethodNode

addJavaMemberNodesToMap

public void addJavaMemberNodesToMap(FlexMap map)
Enabled: Add this JavaMemberNode to the map

Specified by:
addJavaMemberNodesToMap in class MethodNode

optCoerceArgs

Object[] optCoerceArgs(Object[] args)

coerceArgs

private Object[] coerceArgs(Object[] args,
                            OneArgFunc optEjector)

trySpecialCoercion

private static Object trySpecialCoercion(Object self,
                                         String aVerb,
                                         Object[] args,
                                         Throwable problem)
This is called only when 'self aVerb(args)' has failed due to a coercion-to-Java failure, in which case we try a special case outside our normal coercion theory.

The one such special case currently defined, and hopefully the only one we will define, is to have '3 + 4.5' and such coerce to '3.0 + 4.5'.

If we aren't in one of our special cases, then we should simply rethrow the problem.


shorten

public Script shorten(Object optSelf,
                      String aVerb,
                      Object[] args)
Enabled: Just returns this.

Specified by:
shorten in interface Script
Parameters:
optSelf - If present, then a script could shorten using instance-specific data.
aVerb - Must be interned
args - Typically, only its arity is used. But OverloaderNode uses the types of the arguments to select among Java overloads.
Returns:
The Script to use in lieu of this one. Note that it's always correct a Script to just return itself.

innerExecute

abstract Object innerExecute(Object self,
                             Object[] args)
                      throws InstantiationException,
                             IllegalAccessException,
                             IllegalArgumentException,
                             java.lang.reflect.InvocationTargetException
Throws:
IllegalArgumentException - if the number of actual and formal parameters differ, or if an unwrapping or method invocation conversion fails.
InstantiationException
IllegalAccessException
java.lang.reflect.InvocationTargetException

execute

public Object execute(Object self,
                      String aVerb,
                      Object[] args)
Enabled:

Specified by:
execute in interface Script

member

protected java.lang.reflect.Member member()

parameterTypes

public abstract Class[] parameterTypes()
Enabled:


returnType

public abstract Class returnType()
Enabled:


receiverType

protected abstract Class receiverType()

explain

abstract String explain(String args)

subPrintOn

public void subPrintOn(TextWriter out,
                       int priority)
                throws IOException
Enabled:

IOException

toString

public String toString()
Suppressed:

Overrides:
toString in class Object
Returns:
a string representation of the object.

traceOn

public void traceOn(TextWriter out)
             throws IOException
Enabled:

Specified by:
traceOn in interface EStackItem
IOException


comments?