|
||||||||||
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) synchronized (unless synchronization has no effect). 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.
Field Summary | |
---|---|
static InterpreterJVM |
ONLY
Singleton instance of this class. |
Fields inherited from class edu.rice.cs.util.newjvm.AbstractSlaveJVM |
---|
_pollMasterThreadName, _quitSlaveThreadName, CHECK_MAIN_VM_ALIVE_SECONDS |
Method Summary | |
---|---|
void |
addBuildDirectoryClassPath(File f)
Adds the given path to the classpath shared by ALL Java interpreters. |
void |
addExternalFilesClassPath(File f)
Adds the given path to the classpath shared by ALL Java interpreters. |
void |
addExtraClassPath(File f)
Adds the given path to the classpath 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 classpath shared by ALL Java interpreters. |
void |
addProjectFilesClassPath(File f)
Adds the given path to the classpath 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). |
List<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. |
Object[] |
getVariable(String var)
Gets the value of the variable with the given name in the current interpreter. |
String |
getVariableToString(String var)
Gets the string representation of the value of a variable in the current interpreter. |
String |
getVariableType(String var)
Gets the type of a variable 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. |
InterpretResult |
interpret(String s,
String interpreterName)
Interprets the given string of source code with the given interpreter. |
void |
junitJVMReady()
Called when the JVM used for unit tests has registered. |
void |
nonTestCase(boolean isTestAll)
Notifies Main JVM that JUnit has been invoked on a non TestCase class. |
protected void |
quitFailed(Throwable th)
This method is called if the interpreterJVM cannot be exited (likely because of a modified security manager. |
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. |
boolean |
setActiveInterpreter(String name)
Sets the current interpreter to be the one specified by the given name |
void |
setPrivateAccessible(boolean allow)
Sets the interpreter to allow access to private members. |
void |
setShowMessageOnResetFailure(boolean show)
|
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
Method Detail |
---|
protected void handleStart(MasterRemote mainJVM)
handleStart
in class AbstractSlaveJVM
public void setShowMessageOnResetFailure(boolean show)
setShowMessageOnResetFailure
in interface InterpreterJVMRemoteI
show
- Whether to show a message if a reset operation fails.protected void quitFailed(Throwable th)
quitFailed
in class AbstractSlaveJVM
public InterpretResult interpret(String s)
interpret
in interface InterpreterJVMRemoteI
s
- Source code to interpret.public InterpretResult interpret(String s, String interpreterName)
s
- Source code to interpret.interpreterName
- Name of the interpreter to use
IllegalArgumentException
- if the named interpreter does not existpublic Object[] getVariable(String var)
Option<Object>
--
an empty array corresponds to "none," and a singleton array corresponds to a "some."
public String getVariableToString(String var)
getVariableToString
in interface InterpreterJVMRemoteI
var
- the name of the variable
public String getVariableType(String var)
getVariableType
in interface InterpreterJVMRemoteI
var
- the name of the variablepublic void addInterpreter(String name)
addInterpreter
in interface InterpreterJVMRemoteI
name
- the unique name for the interpreter
IllegalArgumentException
- if the name is not uniquepublic 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 lengthpublic void removeInterpreter(String name)
removeInterpreter
in interface InterpreterJVMRemoteI
name
- Name of the interpreter to removepublic boolean setActiveInterpreter(String name)
setActiveInterpreter
in interface InterpreterJVMRemoteI
name
- the unique name of the interpreter to set active
public boolean setToDefaultInterpreter()
setToDefaultInterpreter
in interface InterpreterJVMRemoteI
public void setPrivateAccessible(boolean allow)
setPrivateAccessible
in interface InterpreterJVMRemoteI
public List<String> findTestClasses(List<String> classNames, List<File> files) throws RemoteException
findTestClasses
in interface InterpreterJVMRemoteI
classNames
- the class names to run in a testfiles
- the associated file
RemoteException
public boolean runTestSuite() throws RemoteException
runTestSuite
in interface InterpreterJVMRemoteI
RemoteException
public void nonTestCase(boolean isTestAll)
nonTestCase
in interface JUnitModelCallback
isTestAll
- whether or not it was a use of the test all buttonpublic void classFileError(ClassFileError e)
classFileError
in interface JUnitModelCallback
e
- the ClassFileError object describing the error on loading the filepublic void testSuiteStarted(int numTests)
testSuiteStarted
in interface JUnitModelCallback
numTests
- The number of tests in the suite to be run.public void testStarted(String testName)
testStarted
in interface JUnitModelCallback
testName
- The name of the test being started.public void testEnded(String testName, boolean wasSuccessful, boolean causedError)
testEnded
in interface JUnitModelCallback
testName
- 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 JUnitModelCallback
errors
- The array of errors from all failed tests in the suite.public File getFileForClassName(String className)
getFileForClassName
in interface JUnitModelCallback
className
- the name of the class for which we want to find the file
public void junitJVMReady()
JUnitModelCallback
junitJVMReady
in interface JUnitModelCallback
public void addExtraClassPath(File f)
InterpreterJVMRemoteI
addExtraClassPath
in interface InterpreterJVMRemoteI
f
- Entry to add to the accumulated classpathpublic void addProjectClassPath(File f)
InterpreterJVMRemoteI
addProjectClassPath
in interface InterpreterJVMRemoteI
f
- Entry to add to the accumulated classpathpublic void addBuildDirectoryClassPath(File f)
InterpreterJVMRemoteI
addBuildDirectoryClassPath
in interface InterpreterJVMRemoteI
f
- Entry to add to the accumulated classpathpublic void addProjectFilesClassPath(File f)
InterpreterJVMRemoteI
addProjectFilesClassPath
in interface InterpreterJVMRemoteI
f
- Entry to add to the accumulated classpathpublic void addExternalFilesClassPath(File f)
InterpreterJVMRemoteI
addExternalFilesClassPath
in interface InterpreterJVMRemoteI
f
- Entry to add to the accumulated classpathpublic List<File> getClassPath()
InterpreterJVMRemoteI
getClassPath
in interface JUnitModelCallback
getClassPath
in interface InterpreterJVMRemoteI
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |