use of com.sun.jdi.ClassLoaderReference in project intellij-community by JetBrains.
the class TypeEvaluator method evaluate.
/**
* @return ReferenceType in the target VM, with the given fully qualified name
*/
public Object evaluate(EvaluationContextImpl context) throws EvaluateException {
ClassLoaderReference classLoader = context.getClassLoader();
ReferenceType lastRes = SoftReference.dereference(myLastResult);
if (lastRes != null && classLoader == SoftReference.dereference(myLastClassLoader)) {
// if class loader is null, check that vms match
if (classLoader != null || lastRes.virtualMachine().equals(context.getDebugProcess().getVirtualMachineProxy().getVirtualMachine())) {
return lastRes;
}
}
DebugProcessImpl debugProcess = context.getDebugProcess();
String typeName = myTypeName.getName(debugProcess);
ReferenceType type = debugProcess.findClass(context, typeName, classLoader);
if (type == null) {
throw EvaluateExceptionUtil.createEvaluateException(DebuggerBundle.message("error.class.not.loaded", typeName));
}
myLastClassLoader = new WeakReference<>(classLoader);
myLastResult = new WeakReference<>(type);
return type;
}
use of com.sun.jdi.ClassLoaderReference in project intellij-community by JetBrains.
the class CompilingEvaluator method evaluate.
@Override
public Value evaluate(final EvaluationContext evaluationContext) throws EvaluateException {
DebugProcess process = evaluationContext.getDebugProcess();
EvaluationContextImpl autoLoadContext = ((EvaluationContextImpl) evaluationContext).createEvaluationContext(evaluationContext.getThisObject());
autoLoadContext.setAutoLoadClasses(true);
ClassLoaderReference classLoader = ClassLoadingUtils.getClassLoader(autoLoadContext, process);
autoLoadContext.setClassLoader(classLoader);
String version = ((VirtualMachineProxyImpl) process.getVirtualMachineProxy()).version();
Collection<ClassObject> classes = compile(JdkVersionUtil.getVersion(version));
defineClasses(classes, autoLoadContext, process, classLoader);
try {
// invoke base evaluator on call code
SourcePosition position = ContextUtil.getSourcePosition(evaluationContext);
ExpressionEvaluator evaluator = DebuggerInvocationUtil.commitAndRunReadAction(myProject, new EvaluatingComputable<ExpressionEvaluator>() {
@Override
public ExpressionEvaluator compute() throws EvaluateException {
TextWithImports callCode = getCallCode();
PsiElement copyContext = myData.getAnchor();
CodeFragmentFactory factory = DebuggerUtilsEx.findAppropriateCodeFragmentFactory(callCode, copyContext);
return factory.getEvaluatorBuilder().build(factory.createCodeFragment(callCode, copyContext, myProject), position);
}
});
return evaluator.evaluate(autoLoadContext);
} catch (Exception e) {
throw new EvaluateException("Error during generated code invocation " + e, e);
}
}
Aggregations