|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.rice.cs.util.newjvm.AbstractMasterJVM
edu.rice.cs.drjava.model.repl.newjvm.MainJVM
public class MainJVM
Manages a remote JVM.
Nested Class Summary | |
---|---|
static class |
MainJVM.DummyDebugModel
DebugModelCallback which does not react to events. |
static class |
MainJVM.DummyInteractionsModel
InteractionsModel which does not react to events. |
static class |
MainJVM.DummyJUnitModel
JUnitModel which does not react to events. |
Field Summary | |
---|---|
static String |
DEFAULT_INTERPRETER_NAME
|
Fields inherited from class edu.rice.cs.util.newjvm.AbstractMasterJVM |
---|
_log, _masterJVMLock, _slave, _waitForQuitThreadName |
Constructor Summary | |
---|---|
MainJVM(File wd)
Creates a new MainJVM to interface to another JVM; the MainJVM has a link to the partially initialized global model. |
Method Summary | |
---|---|
void |
addBuildDirectoryClassPath(File f)
Blocks until the interpreter is connected. |
void |
addExternalFilesClassPath(File f)
Blocks until the interpreter is connected. |
void |
addExtraClassPath(File f)
Blocks until the interpreter is connected. |
void |
addInterpreter(String name)
Adds a named interpreter to the list. |
void |
addProjectClassPath(File f)
Blocks until the interpreter is connected. |
void |
addProjectFilesClassPath(File f)
Blocks until the interpreter is connected. |
protected boolean |
allowAssertions()
Return whether to allow assertions in the InterpreterJVM. |
void |
classFileError(ClassFileError e)
Called if the slave JVM encounters an illegal class file in testing. |
void |
enableRestart()
ReEnables restarting the slave if it has been turned off by repeated startup failures. |
InterpreterJVMRemoteI |
ensureInterpreterConnected()
If an interpreter has not registered itself, this method will block until one does. |
void |
errorStartingSlave(Throwable cause)
Called if the slave JVM dies before it is able to register. |
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). |
Iterable<File> |
getClassPath()
Returns the current classpath of the interpreter as a list of unique entries. |
String |
getConsoleInput()
Asks the main jvm for input from the console. |
String |
getCurrentInterpreterName()
Accesses the cached current interpreter name. |
protected int |
getDebugPort()
Returns the debug port to use, as specified by the model. |
File |
getFileForClassName(String className)
Called when the JUnitTestManager wants to open a file that is not currently open. |
protected InterpretResult.Visitor<Void> |
getResultHandler()
Returns the visitor to handle an InterpretResult. |
String |
getVariableToString(String var)
Gets the string representation of the value of a variable in the current interpreter. |
String |
getVariableType(String var)
Gets the class name of a variable in the current interpreter. |
protected void |
handleSlaveConnected()
Called when Interpreter JVM connects to us after being started. |
protected void |
handleSlaveQuit(int status)
React if the slave JVM quits. |
void |
interpret(String s)
Interprets string s in slave JVM. |
boolean |
isInterpreterRunning()
|
boolean |
isStartupInProgress()
Returns whether a JVM is currently starting. |
void |
killInterpreter(File wd)
Kills the running interpreter JVM, and restarts with working directory wd if wd != null. |
void |
nonTestCase(boolean isTestAll)
Called if JUnit is invoked on a non TestCase class. |
void |
quitFailed(Throwable th)
This method is called by the interpreter JVM if it cannot be exited. |
void |
removeInterpreter(String name)
Removes the interpreter with the given name, if it exists. |
boolean |
runTestSuite()
Runs the JUnit test suite already cached in the Interpreter JVM. |
boolean |
setActiveInterpreter(String name)
Sets the current interpreter to the one specified by name. |
void |
setAllowAssertions(boolean allow)
Sets whether the remote JVM will run "assert" statements after the next restart. |
void |
setDebugModel(DebugModelCallback model)
Provides an object to listen to debug-related events. |
void |
setInteractionsModel(InteractionsModelCallback model)
Provides an object to listen to interactions-related events. |
void |
setJUnitModel(JUnitModelCallback model)
Provides an object to listen to test-related events. |
void |
setOptionArgs(String argString)
Sets the extra (optional) arguments to be passed to the interpreter. |
void |
setPackageScope(String packageName)
Sets the Interpreter to be in the given package. |
void |
setPrivateAccessible(boolean allow)
Sets the interpreter to allow access to private members. |
void |
setShowMessageOnResetFailure(boolean show)
Blocks until the interpreter is connected. |
void |
setStartupClassPath(String classPath)
Sets the classpath to use for starting the interpreter JVM. |
boolean |
setToDefaultInterpreter()
Sets the default interpreter to be the current one. |
boolean |
slaveJVMUsed()
|
protected void |
slaveQuitDuringStartup(int status)
Action to take if the slave JVM quits before registering. |
void |
startInterpreterJVM()
Starts the interpreter if it's not running already. |
void |
systemErrPrint(String s)
Forwards a call to System.err from InterpreterJVM to the local InteractionsModel. |
void |
systemOutPrint(String s)
Forwards a call to System.out from InterpreterJVM to the local InteractionsModel. |
void |
testEnded(String testName,
boolean wasSuccessful,
boolean causedError)
Called when a particular test has ended. |
void |
testStarted(String testName)
Called when a particular test is started. |
void |
testSuiteEnded(JUnitError[] errors)
Called when a full suite of tests has finished running. |
void |
testSuiteStarted(int numTests)
Called to indicate that a suite of tests has started running. |
Methods inherited from class edu.rice.cs.util.newjvm.AbstractMasterJVM |
---|
checkStillAlive, dispose, getSlave, invokeSlave, invokeSlave, invokeSlave, quitSlave, registerSlave, waitSlaveDone |
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.MasterRemote |
---|
checkStillAlive, registerSlave |
Field Detail |
---|
public static final String DEFAULT_INTERPRETER_NAME
Constructor Detail |
---|
public MainJVM(File wd) throws RemoteException
RemoteException
Method Detail |
---|
public boolean isInterpreterRunning()
public boolean slaveJVMUsed()
public void setInteractionsModel(InteractionsModelCallback model)
public void setJUnitModel(JUnitModelCallback model)
public void setDebugModel(DebugModelCallback model)
model
- the debug modelpublic void setAllowAssertions(boolean allow)
public void setOptionArgs(String argString)
argString
- the arguments as they would be typed at the command-linepublic void interpret(String s)
public String getVariableToString(String var)
var
- the name of the variablepublic String getVariableType(String var)
var
- the name of the variablepublic void addProjectClassPath(File f)
public void addBuildDirectoryClassPath(File f)
public void addProjectFilesClassPath(File f)
public void addExternalFilesClassPath(File f)
public void addExtraClassPath(File f)
public Iterable<File> getClassPath()
public void setPackageScope(String packageName)
packageName
- Name of the package to enter.public void setShowMessageOnResetFailure(boolean show)
show
- Whether to show a message if a reset operation fails.public void systemErrPrint(String s) throws RemoteException
systemErrPrint
in interface MainJVMRemoteI
s
- String that was printed in the other JVM
RemoteException
public void systemOutPrint(String s) throws RemoteException
systemOutPrint
in interface MainJVMRemoteI
s
- String that was printed in the other JVM
RemoteException
public List<String> findTestClasses(List<String> classNames, List<File> files) throws RemoteException
classNames
- the class names to run in a testfiles
- the associated file
RemoteException
public boolean runTestSuite() throws RemoteException
RemoteException
public void nonTestCase(boolean isTestAll) throws RemoteException
nonTestCase
in interface MainJVMRemoteI
isTestAll
- whether or not it was a use of the test all button
RemoteException
public void classFileError(ClassFileError e) throws RemoteException
classFileError
in interface MainJVMRemoteI
e
- the ClassFileError describing the error when loading the class file
RemoteException
public void testSuiteStarted(int numTests) throws RemoteException
testSuiteStarted
in interface MainJVMRemoteI
numTests
- The number of tests in the suite to be run.
RemoteException
public void testStarted(String testName) throws RemoteException
testStarted
in interface MainJVMRemoteI
testName
- The name of the test being started.
RemoteException
public void testEnded(String testName, boolean wasSuccessful, boolean causedError) throws RemoteException
testEnded
in interface MainJVMRemoteI
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.
RemoteException
public void testSuiteEnded(JUnitError[] errors) throws RemoteException
testSuiteEnded
in interface MainJVMRemoteI
errors
- The array of errors from all failed tests in the suite.
RemoteException
public File getFileForClassName(String className) throws RemoteException
getFileForClassName
in interface MainJVMRemoteI
className
- the name of the class for which we want to find the file
RemoteException
public void addInterpreter(String name)
name
- the unique name for the interpreter
IllegalArgumentException
- if the name is not uniquepublic void removeInterpreter(String name)
name
- Name of the interpreter to removepublic boolean setActiveInterpreter(String name)
name
- the unique name of the interpreter to set active
public boolean setToDefaultInterpreter()
public String getCurrentInterpreterName()
public void killInterpreter(File wd)
public void setStartupClassPath(String classPath)
classPath
- Classpath for the interpreter JVMpublic void startInterpreterJVM()
protected void handleSlaveQuit(int status)
handleSlaveQuit
in class AbstractMasterJVM
status
- Status returned by the dead process.protected void slaveQuitDuringStartup(int status)
slaveQuitDuringStartup
in class AbstractMasterJVM
status
- Status code of the JVM
TODO: revise the unit tests that kill the slave prematurely (by making them wait until the
slave registers) and remove the TEST_MODE escape.public void errorStartingSlave(Throwable cause) throws RemoteException
errorStartingSlave
in interface MasterRemote
errorStartingSlave
in class AbstractMasterJVM
cause
- The Throwable which caused the slave to die.
RemoteException
public void quitFailed(Throwable th) throws RemoteException
quitFailed
in interface MainJVMRemoteI
th
- The Throwable thrown by System.exit
RemoteException
public boolean isStartupInProgress()
isStartupInProgress
in class AbstractMasterJVM
protected void handleSlaveConnected()
handleSlaveConnected
in class AbstractMasterJVM
public void enableRestart()
protected InterpretResult.Visitor<Void> getResultHandler()
protected int getDebugPort()
protected boolean allowAssertions()
public void setPrivateAccessible(boolean allow)
public InterpreterJVMRemoteI ensureInterpreterConnected()
public String getConsoleInput()
getConsoleInput
in interface MainJVMRemoteI
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |