|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rice.cs.util.newjvm.AbstractSlaveJVM
edu.rice.cs.drjava.model.repl.newjvm.InterpreterJVM
public class InterpreterJVM
This is the main class for the interpreter JVM. All public methods except those involving remote calls (callbacks) use synchronizazion on _stateLock (unless synchronization has no effect). The class is not ready for remote calls until handleStart has been executed. This class is loaded in the Interpreter JVM, not the Main JVM. (Do not use DrJava's config framework here.)
Note that this class is specific to DynamicJava. It must be refactored to accommodate other interpreters.
| Nested Class Summary | |
|---|---|
private static class |
InterpreterJVM.DebugMethodContext
A custom context for interpreting within the body of a defined method. |
| Field Summary | |
|---|---|
private Pair<String,Interpreter> |
_activeInterpreter
|
private Set<Interpreter> |
_busyInterpreters
|
private ClassPathManager |
_classPathManager
|
private Interpreter |
_defaultInterpreter
|
private ClassLoader |
_interpreterLoader
|
private InteractionsPaneOptions |
_interpreterOptions
|
private Map<String,Interpreter> |
_interpreters
|
private JUnitTestManager |
_junitTestManager
Responsible for running JUnit tests in this JVM. |
private MainJVMRemoteI |
_mainJVM
Remote reference to the MainJVM class in DrJava's primary JVM. |
private Object |
_stateLock
|
static InterpreterJVM |
ONLY
Singleton instance of this class. |
| Fields inherited from class edu.rice.cs.util.newjvm.AbstractSlaveJVM |
|---|
CHECK_MAIN_VM_ALIVE_SECONDS |
| Constructor Summary | |
|---|---|
private |
InterpreterJVM()
Private constructor; use the singleton ONLY instance. |
| Method Summary | |
|---|---|
void |
addBuildDirectoryClassPath(File f)
Adds the given path to the class path shared by ALL Java interpreters. |
private boolean |
addBusyInterpreter(Interpreter i)
|
void |
addExternalFilesClassPath(File f)
Adds the given path to the class path shared by ALL Java interpreters. |
void |
addExtraClassPath(File f)
Adds the given path to the class path shared by ALL Java interpreters. |
void |
addInterpreter(String name)
Adds a named Interpreter to the list. |
void |
addInterpreter(String name,
Object thisVal,
Class<?> thisClass,
Object[] localVars,
String[] localVarNames,
Class<?>[] localVarClasses)
Adds a named Interpreter in the given environment to the list. |
void |
addProjectClassPath(File f)
Adds the given path to the class path shared by ALL Java interpreters. |
void |
addProjectFilesClassPath(File f)
Adds the given path to the class path shared by ALL Java interpreters. |
void |
classFileError(ClassFileError e)
Notifies the main JVM that JUnitTestManager has encountered an illegal class file. |
List<String> |
findTestClasses(List<String> classNames,
List<File> files)
Sets up a JUnit test suite in the Interpreter JVM and finds which classes are really TestCases classes (by loading them). |
static String |
getClassName(Class<?> c)
|
Iterable<File> |
getClassPath()
Returns the current class path. |
File |
getFileForClassName(String className)
Called when the JUnitTestManager wants to open a file that is not currently open. |
private Interpreter |
getInterpreter(String name)
|
Pair<Object,String>[] |
getVariable(String var)
Gets the value and type string of the variable with the given name in the current interpreter. |
Pair<String,String> |
getVariableToString(String var)
Gets the string representation of the value of a variable in the current interpreter. |
Object[] |
getVariableValue(String var)
Gets the value of the variable with the given name in the current interpreter. |
protected void |
handleStart(MasterRemote mainJVM)
Actions to perform when this JVM is started (through its superclass, AbstractSlaveJVM). |
InterpretResult |
interpret(String s)
Interprets the given string of source code in the active interpreter. |
private InterpretResult |
interpret(String input,
Interpreter interpreter)
|
InterpretResult |
interpret(String s,
String name)
Interprets the given string of source code with the given interpreter. |
private boolean |
isBusyInterpreter(Interpreter i)
|
private boolean |
isInterpreterName(String name)
|
void |
junitJVMReady()
Called when the JVM used for unit tests has registered. |
void |
nonTestCase(boolean isTestAll,
boolean didCompileFail)
Notifies Main JVM that JUnit has been invoked on a non TestCase class. |
private Interpreter |
putInterpreter(String name,
Interpreter i)
|
private boolean |
removeBusyInterpreter(Interpreter i)
|
void |
removeInterpreter(String name)
Removes the interpreter with the given name, if it exists. |
boolean |
runTestSuite()
Runs JUnit test suite already cached in the Interpreter JVM. |
Pair<Boolean,Boolean> |
setActiveInterpreter(String name)
Sets the current interpreter to be the one specified by the given name |
void |
setEnforceAllAccess(boolean enforce)
Check that all access of class members is permitted by accessibility controls. |
void |
setEnforcePrivateAccess(boolean enforce)
Check that access of private class members is permitted (irrelevant if setEnforceAllAccess() is set to true). |
void |
setRequireSemicolon(boolean require)
Require a semicolon at the end of statements. |
void |
setRequireVariableType(boolean require)
Require variable declarations to include an explicit type. |
Pair<Boolean,Boolean> |
setToDefaultInterpreter()
Sets the default interpreter to be active. |
void |
testEnded(String testName,
boolean wasSuccessful,
boolean causedError)
Notifies that a particular test has ended. |
void |
testStarted(String testName)
Notifies that a particular test has started. |
void |
testSuiteEnded(JUnitError[] errors)
Notifies that a full suite of tests has finished running. |
void |
testSuiteStarted(int numTests)
Notifies that a suite of tests has started running. |
| Methods inherited from class edu.rice.cs.util.newjvm.AbstractSlaveJVM |
|---|
beforeQuit, quit, start |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface edu.rice.cs.util.newjvm.SlaveRemote |
|---|
quit, start |
| Field Detail |
|---|
public static final InterpreterJVM ONLY
private final InteractionsPaneOptions _interpreterOptions
private volatile Pair<String,Interpreter> _activeInterpreter
private final Interpreter _defaultInterpreter
private final Map<String,Interpreter> _interpreters
private final Set<Interpreter> _busyInterpreters
private final ClassPathManager _classPathManager
private final ClassLoader _interpreterLoader
private final Object _stateLock
private final JUnitTestManager _junitTestManager
private volatile MainJVMRemoteI _mainJVM
| Constructor Detail |
|---|
private InterpreterJVM()
| Method Detail |
|---|
protected void handleStart(MasterRemote mainJVM)
handleStart in class AbstractSlaveJVMprivate Interpreter getInterpreter(String name)
private boolean isInterpreterName(String name)
private Interpreter putInterpreter(String name,
Interpreter i)
public void removeInterpreter(String name)
InterpreterJVMRemoteI
removeInterpreter in interface InterpreterJVMRemoteIname - Name of the interpreter to removeprivate boolean addBusyInterpreter(Interpreter i)
private boolean removeBusyInterpreter(Interpreter i)
private boolean isBusyInterpreter(Interpreter i)
public InterpretResult interpret(String s)
interpret in interface InterpreterJVMRemoteIs - Source code to interpret.
public InterpretResult interpret(String s,
String name)
s - Source code to interpret.interpreterName - Name of the interpreter to use
IllegalArgumentException - if the named interpreter does not exist
private InterpretResult interpret(String input,
Interpreter interpreter)
public Object[] getVariableValue(String var)
Option<Object> --
an empty array corresponds to "none," and a singleton array corresponds to a "some."
var - name of the variable to look up
JPDADebugger.GET_VARIABLE_VALUE_SIG,
JPDADebugger._copyVariablesFromInterpreter()public Pair<Object,String>[] getVariable(String var)
Option<Object> --
an empty array corresponds to "none," and a singleton array corresponds to a "some."
public Pair<String,String> getVariableToString(String var)
getVariableToString in interface InterpreterJVMRemoteIvar - the name of the variable
public static String getClassName(Class<?> c)
public void addInterpreter(String name)
addInterpreter in interface InterpreterJVMRemoteIname - the unique name for the interpreter
IllegalArgumentException - if the name is not unique
public void addInterpreter(String name,
Object thisVal,
Class<?> thisClass,
Object[] localVars,
String[] localVarNames,
Class<?>[] localVarClasses)
name - The unique name for the interpreterthisVal - The value of this (may be null, implying this is a static context)thisClass - The class in whose context the interpreter is to be createdlocalVars - Values of local variableslocalVarNames - Names of the local variableslocalVarClasses - Classes of the local variables. To simplify the work callers must
do, a value with a primitive type may have a null entry here.
IllegalArgumentException - if the name is not unique, or if the local var arrays
are not all of the same lengthJPDADebugger.ADD_INTERPRETER_SIG,
JPDADebugger._dumpVariablesIntoInterpreterAndSwitch()public Pair<Boolean,Boolean> setActiveInterpreter(String name)
setActiveInterpreter in interface InterpreterJVMRemoteIname - the unique name of the interpreter to set active
public Pair<Boolean,Boolean> setToDefaultInterpreter()
setToDefaultInterpreter in interface InterpreterJVMRemoteIpublic void setEnforceAllAccess(boolean enforce)
setEnforceAllAccess in interface InterpreterJVMRemoteIpublic void setEnforcePrivateAccess(boolean enforce)
setEnforcePrivateAccess in interface InterpreterJVMRemoteIpublic void setRequireSemicolon(boolean require)
setRequireSemicolon in interface InterpreterJVMRemoteIpublic void setRequireVariableType(boolean require)
setRequireVariableType in interface InterpreterJVMRemoteI
public List<String> findTestClasses(List<String> classNames,
List<File> files)
throws RemoteException
findTestClasses in interface InterpreterJVMRemoteIclassNames - the class names to run in a testfiles - the associated file
RemoteException
public boolean runTestSuite()
throws RemoteException
runTestSuite in interface InterpreterJVMRemoteIRemoteException
public void nonTestCase(boolean isTestAll,
boolean didCompileFail)
nonTestCase in interface JUnitModelCallbackisTestAll - whether or not it was a use of the test all buttondidCompileFail - whether or not a compile before this JUnit attempt failedpublic void classFileError(ClassFileError e)
classFileError in interface JUnitModelCallbacke - the ClassFileError object describing the error on loading the filepublic void testSuiteStarted(int numTests)
testSuiteStarted in interface JUnitModelCallbacknumTests - The number of tests in the suite to be run.public void testStarted(String testName)
testStarted in interface JUnitModelCallbacktestName - The name of the test being started.
public void testEnded(String testName,
boolean wasSuccessful,
boolean causedError)
testEnded in interface JUnitModelCallbacktestName - The name of the test that has ended.wasSuccessful - Whether the test passed or not.causedError - If not successful, whether the test caused an error or simply failed.public void testSuiteEnded(JUnitError[] errors)
testSuiteEnded in interface JUnitModelCallbackerrors - The array of errors from all failed tests in the suite.public File getFileForClassName(String className)
getFileForClassName in interface JUnitModelCallbackclassName - the name of the class for which we want to find the file
public void junitJVMReady()
JUnitModelCallback
junitJVMReady in interface JUnitModelCallbackpublic void addExtraClassPath(File f)
InterpreterJVMRemoteI
addExtraClassPath in interface InterpreterJVMRemoteIf - Entry to add to the accumulated class pathpublic void addProjectClassPath(File f)
InterpreterJVMRemoteI
addProjectClassPath in interface InterpreterJVMRemoteIf - Entry to add to the accumulated class pathpublic void addBuildDirectoryClassPath(File f)
InterpreterJVMRemoteI
addBuildDirectoryClassPath in interface InterpreterJVMRemoteIf - Entry to add to the accumulated class pathpublic void addProjectFilesClassPath(File f)
InterpreterJVMRemoteI
addProjectFilesClassPath in interface InterpreterJVMRemoteIf - Entry to add to the accumulated class pathpublic void addExternalFilesClassPath(File f)
InterpreterJVMRemoteI
addExternalFilesClassPath in interface InterpreterJVMRemoteIf - Entry to add to the accumulated class pathpublic Iterable<File> getClassPath()
InterpreterJVMRemoteI
getClassPath in interface JUnitModelCallbackgetClassPath in interface InterpreterJVMRemoteI
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||