Package randoop.util
Class ReflectionCode
- java.lang.Object
-
- randoop.util.ReflectionCode
-
- Direct Known Subclasses:
ConstructorReflectionCode
,MethodReflectionCode
,ObjectContractReflectionCode
public abstract class ReflectionCode extends Object
Wraps a method or constructor together with its arguments. Can be run only once.hasRun()
indicates whether it has been run.Implemented by parts of Randoop that want to execute reflection code via ReflectionExecutor.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
ReflectionCode.ReflectionCodeException
Indicates a bug in the ReflectionCode class.
-
Field Summary
Fields Modifier and Type Field Description protected Throwable
exceptionThrown
The exception thrown by execution.private boolean
hasRun
Has this been executed already?private boolean
hasStarted
Has this started execution?protected Object
retval
The value yielded by execution.
-
Constructor Summary
Constructors Constructor Description ReflectionCode()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Throwable
getExceptionThrown()
Object
getReturnValue()
boolean
hasRun()
boolean
hasStarted()
void
runReflectionCode()
Runs the reflection code that this object represents.protected abstract void
runReflectionCodeRaw()
Execute the reflection code.protected void
setHasRun()
protected void
setHasStarted()
protected String
status()
A suffix to be called by toString().
-
-
-
Method Detail
-
hasStarted
public final boolean hasStarted()
-
hasRun
public final boolean hasRun()
-
setHasStarted
protected final void setHasStarted()
-
setHasRun
protected final void setHasRun()
-
runReflectionCode
public final void runReflectionCode() throws ReflectionCode.ReflectionCodeException
Runs the reflection code that this object represents.- This method calls
runReflectionCodeRaw()
to perform the actual work.runReflectionCodeRaw()
sets theretVal
orexceptionThrown
field, or throws an exception if there is a bug in Randoop.
- Throws:
ReflectionCode.ReflectionCodeException
- if execution results in conflicting error and success states; this results from a bug in Randoop
- This method calls
-
runReflectionCodeRaw
protected abstract void runReflectionCodeRaw() throws ReflectionCode.ReflectionCodeException
Execute the reflection code. All Randoop implementation errors must be thrown as ReflectionCodeException because everything else is caught.- Throws:
ReflectionCode.ReflectionCodeException
- if execution results in conflicting error and success states; this results from a bug in Randoop
-
getReturnValue
public Object getReturnValue()
-
getExceptionThrown
public Throwable getExceptionThrown()
-
status
protected String status()
A suffix to be called by toString().- Returns:
- the status of the command
-
-