Exemplo n.º 1
0
 /**
  * Sets the default interpreter to be the current one. The result is "none" if the remote JVM is
  * unavailable or if an exception occurs. Blocks until the interpreter is connected.
  *
  * @return Status flags: whether the current interpreter changed, and whether it is busy; or
  *     "none" on an error
  */
 public Option<Pair<Boolean, Boolean>> setToDefaultInterpreter() {
   InterpreterJVMRemoteI remote = _state.value().interpreter(false);
   if (remote == null) {
     return Option.none();
   }
   try {
     return Option.some(remote.setToDefaultInterpreter());
   } catch (RemoteException e) {
     _handleRemoteException(e);
     return Option.none();
   }
 }
Exemplo n.º 2
0
 /**
  * Runs the JUnit test suite already cached in the Interpreter JVM. Blocks until the remote JVM is
  * available. Returns {@code false} if no test suite is cached, the remote JVM is unavailable, or
  * an error occurs.
  */
 public boolean runTestSuite() {
   InterpreterJVMRemoteI remote = _state.value().interpreter(true);
   if (remote == null) {
     return false;
   }
   try {
     return remote.runTestSuite();
   } catch (RemoteException e) {
     _handleRemoteException(e);
     return false;
   }
 }
Exemplo n.º 3
0
 /**
  * Returns the current class path of the interpreter as a list of unique entries. The result is
  * "none" if the remote JVM is unavailable or if an exception occurs. Blocks until the interpreter
  * is connected.
  */
 public Option<Iterable<File>> getClassPath() {
   InterpreterJVMRemoteI remote = _state.value().interpreter(false);
   if (remote == null) {
     return Option.none();
   }
   try {
     return Option.some(remote.getClassPath());
   } catch (RemoteException e) {
     _handleRemoteException(e);
     return Option.none();
   }
 }
Exemplo n.º 4
0
 /**
  * Sets up a JUnit test suite in the Interpreter JVM and finds which classes are really TestCase
  * classes (by loading them). Blocks until the interpreter is connected and the operation
  * completes.
  *
  * @param classNames the class names to run in a test
  * @param files the associated file
  * @return the class names that are actually test cases
  */
 public Option<List<String>> findTestClasses(List<String> classNames, List<File> files) {
   InterpreterJVMRemoteI remote = _state.value().interpreter(false);
   if (remote == null) {
     return Option.none();
   }
   try {
     return Option.some(remote.findTestClasses(classNames, files));
   } catch (RemoteException e) {
     _handleRemoteException(e);
     return Option.none();
   }
 }
Exemplo n.º 5
0
 /**
  * Gets the string representation of the value of a variable in the current interpreter, or "none"
  * if the remote JVM is unavailable or an error occurs. Blocks until the interpreter is connected.
  *
  * @param var the name of the variable
  */
 public Option<Pair<String, String>> getVariableToString(String var) {
   InterpreterJVMRemoteI remote = _state.value().interpreter(false);
   if (remote == null) {
     return Option.none();
   }
   try {
     return Option.some(remote.getVariableToString(var));
   } catch (RemoteException e) {
     _handleRemoteException(e);
     return Option.none();
   }
 }
Exemplo n.º 6
0
 /**
  * Require variable declarations to include an explicit type. The result is {@code false} if the
  * remote JVM is unavailable or if an exception occurs. Blocks until the interpreter is connected.
  */
 public boolean setRequireVariableType(boolean require) {
   InterpreterJVMRemoteI remote = _state.value().interpreter(false);
   if (remote == null) {
     return false;
   }
   try {
     remote.setRequireVariableType(require);
     return true;
   } catch (RemoteException e) {
     _handleRemoteException(e);
     return false;
   }
 }
Exemplo n.º 7
0
 /**
  * Sets the interpreter to enforce access to private members. The result is {@code false} if the
  * remote JVM is unavailable or if an exception occurs. Blocks until the interpreter is connected.
  */
 public boolean setEnforcePrivateAccess(boolean enforce) {
   InterpreterJVMRemoteI remote = _state.value().interpreter(false);
   if (remote == null) {
     return false;
   }
   try {
     remote.setEnforcePrivateAccess(enforce);
     return true;
   } catch (RemoteException e) {
     _handleRemoteException(e);
     return false;
   }
 }
Exemplo n.º 8
0
 /**
  * Removes the interpreter with the given name, if it exists. The result is {@code false} if the
  * remote JVM is unavailable or if an exception occurs. Blocks until the interpreter is connected.
  *
  * @param name Name of the interpreter to remove
  */
 public boolean removeInterpreter(String name) {
   InterpreterJVMRemoteI remote = _state.value().interpreter(false);
   if (remote == null) {
     return false;
   }
   try {
     remote.removeInterpreter(name);
     return true;
   } catch (RemoteException e) {
     _handleRemoteException(e);
     return false;
   }
 }
Exemplo n.º 9
0
 /**
  * Sets the Interpreter to be in the given package. Blocks until the interpreter is connected.
  *
  * @param packageName Name of the package to enter.
  */
 public boolean setPackageScope(String packageName) {
   InterpreterJVMRemoteI remote = _state.value().interpreter(false);
   if (remote == null) {
     return false;
   }
   try {
     remote.interpret("package " + packageName + ";");
     return true;
   } catch (RemoteException e) {
     _handleRemoteException(e);
     return false;
   }
 }
Exemplo n.º 10
0
 /**
  * Blocks until the interpreter is connected. Returns {@code true} if the change was successfully
  * passed to the remote JVM.
  */
 public boolean addExtraClassPath(File f) {
   InterpreterJVMRemoteI remote = _state.value().interpreter(false);
   if (remote == null) {
     return false;
   }
   try {
     remote.addExtraClassPath(f);
     return true;
   } catch (RemoteException e) {
     _handleRemoteException(e);
     return false;
   }
 }
Exemplo n.º 11
0
    @Override
    public void started(InterpreterJVMRemoteI i) {
      if (_state.compareAndSet(this, new FreshRunningState(i))) {
        boolean enforceAllAccess =
            DrJava.getConfig()
                .getSetting(OptionConstants.DYNAMICJAVA_ACCESS_CONTROL)
                .equals(
                    OptionConstants.DynamicJavaAccessControlChoices.PRIVATE_AND_PACKAGE); // "all"
        try {
          i.setEnforceAllAccess(enforceAllAccess);
        } catch (RemoteException re) {
          _handleRemoteException(re);
        }

        boolean enforcePrivateAccess =
            !DrJava.getConfig()
                .getSetting(OptionConstants.DYNAMICJAVA_ACCESS_CONTROL)
                .equals(OptionConstants.DynamicJavaAccessControlChoices.DISABLED); // not "none"
        try {
          i.setEnforcePrivateAccess(enforcePrivateAccess);
        } catch (RemoteException re) {
          _handleRemoteException(re);
        }

        Boolean requireSemicolon =
            DrJava.getConfig().getSetting(OptionConstants.DYNAMICJAVA_REQUIRE_SEMICOLON);
        try {
          i.setRequireSemicolon(requireSemicolon);
        } catch (RemoteException re) {
          _handleRemoteException(re);
        }

        Boolean requireVariableType =
            DrJava.getConfig().getSetting(OptionConstants.DYNAMICJAVA_REQUIRE_VARIABLE_TYPE);
        try {
          i.setRequireVariableType(requireVariableType);
        } catch (RemoteException re) {
          _handleRemoteException(re);
        }

        // Note that _workingDir isn't guaranteed to be the dir at the time startup began.  Is that
        // a problem?
        // (Is the user ever going to see a working dir message that doesn't match the actual
        // setting?)
        _interactionsModel.interpreterReady(_workingDir);
        _junitModel.junitJVMReady();
      } else {
        _state.value().started(i);
      }
    }
Exemplo n.º 12
0
 /**
  * Interprets string s in the remote JVM. Blocks until the interpreter is connected and evaluation
  * completes.
  *
  * @return {@code true} if successful; {@code false} if the subprocess is unavailable, the
  *     subprocess dies during the call, or an unexpected exception occurs.
  */
 public boolean interpret(final String s) {
   InterpreterJVMRemoteI remote = _state.value().interpreter(true);
   if (remote == null) {
     return false;
   }
   try {
     debug.logStart("Interpreting " + s);
     InterpretResult result = remote.interpret(s);
     result.apply(resultHandler());
     debug.logEnd("result", result);
     return true;
   } catch (RemoteException e) {
     debug.logEnd();
     _handleRemoteException(e);
     return false;
   }
 }