+ An Evaluator
interface is introduced, with
+ evaluate()
method. It's implementation should be registered
+ for the desired language that compiles into bytecode.
+
null
.
+ */
+ public PreprocessedInfo getPreprocessedObject() {
+ return preprocessed;
+ }
+ }
+
+ /**
+ * Context of the evaluation.
+ * This class provides the evaluation context - stack frame and context variable.
+ * Two sets of APIs can be used during the evaluation:
+ * null
.
+ */
+ public ObjectVariable getContextVariable() {
+ return contextVariable;
+ }
+
+ /**
+ * Get the context stack frame in JDI APIs.
+ * This frame corresonds to the JPDA frame returned from {@link #getCallStackFrame()}.
+ * @return stack frame in which the evaluation is performed
+ */
+ public StackFrame getStackFrame() {
+ return stackFrame;
+ }
+
+ /**
+ * Get the depth of stack frame returned from {@link #getStackFrame()}.
+ * @return the depth of stack frame
+ */
+ public int getStackDepth() {
+ return stackDepth;
+ }
+
+ /**
+ * Get an optional context object. When non-null,
+ * all methods and fields should be treated relative to the object
+ * instance.
+ * This object corresonds to the JPDA variable returned from {@link #getContextVariable()}.
+ * @return optional context object or null
.
+ */
+ public ObjectReference getContextObject() {
+ return contextObject;
+ }
+
+ /**
+ * This method is required to be called before a call to JDI
+ * that cause the current thread (sf.thread()
) to resume - e.g.
+ * {@link ObjectReference#invokeMethod(com.sun.jdi.ThreadReference, com.sun.jdi.Method, java.util.List, int)},
+ * {@link ClassType#invokeMethod(com.sun.jdi.ThreadReference, com.sun.jdi.Method, java.util.List, int)},
+ * {@link ClassType#newInstance(com.sun.jdi.ThreadReference, com.sun.jdi.Method, java.util.List, int)}.
+ */
+ public void notifyMethodToBeInvoked() {
+ methodToBeInvokedNotifier.run();
+ }
+ }
+
+ /**
+ * Evaluation result.
+ * Depending on the APIs used by the evaluation, result is either
+ * a {@link Variable} or {@link Value}.
+ */
+ public static final class Result {
+
+ private Variable var;
+ private Value v;
+
+ /**
+ * Create result from {@link Variable}.
+ * @param var result variable
+ */
+ public Result(Variable var) {
+ this.var = var;
+ }
+
+ /**
+ * Create result from {@link Value}.
+ * @param v result value
+ */
+ public Result(Value v) {
+ this.v = v;
+ }
+
+ /**
+ * Get the result variable
+ * @return the variable or null
.
+ */
+ public Variable getVariable() {
+ return var;
+ }
+
+ /**
+ * Get the result value
+ * @return the value or null
.
+ */
+ public Value getValue() {
+ return v;
+ }
+ }
+
+ /**
+ * Declarative registration of Evaluator implementation.
+ * By marking the implementation class with this annotation,
+ * you automatically register that implementation for use by debugger.
+ * The class must be public and have a public constructor which takes
+ * no arguments or takes {@link ContextProvider} as an argument.
+ *
+ * @author Martin Entlicher
+ */
+ @Retention(RetentionPolicy.SOURCE)
+ @Target({ElementType.TYPE})
+ public @interface Registration {
+ /**
+ * The language to register this evaluator for.
+ */
+ String language();
+
+ }
+
+}