Fix comparision of java versions during class loading in evaluate expression.
Do not catch EvaluateException during class loading to show more useful error to user. ^KT-22830 Fixed
This commit is contained in:
+11
-7
@@ -21,7 +21,7 @@ import com.intellij.debugger.engine.evaluation.EvaluateException
|
||||
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl
|
||||
import com.intellij.debugger.impl.ClassLoadingUtils
|
||||
import com.intellij.debugger.impl.DebuggerUtilsEx
|
||||
import com.intellij.openapi.projectRoots.JdkVersionUtil
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion
|
||||
import com.intellij.openapi.util.SystemInfo
|
||||
import com.sun.jdi.ClassLoaderReference
|
||||
import com.sun.jdi.ClassType
|
||||
@@ -51,14 +51,18 @@ class OrdinaryClassLoadingAdapter : ClassLoadingAdapter {
|
||||
throw EvaluateException("Error creating evaluation class loader: " + e, e)
|
||||
}
|
||||
|
||||
val version = process.virtualMachineProxy.version()
|
||||
val sdkVersion = JdkVersionUtil.getVersion(version)
|
||||
val debugProcessVersionString = process.virtualMachineProxy.version()
|
||||
val debugProcessVersion = JavaSdkVersion.fromVersionString(debugProcessVersionString)
|
||||
?: throw EvaluateException("Unable to parse java version from $debugProcessVersionString.")
|
||||
|
||||
if (!SystemInfo.isJavaVersionAtLeast(sdkVersion.description)) {
|
||||
val ideaJavaVersion = JavaSdkVersion.fromVersionString(SystemInfo.JAVA_RUNTIME_VERSION)
|
||||
?: throw EvaluateException("Unable to parse java version from ${SystemInfo.JAVA_RUNTIME_VERSION}.")
|
||||
|
||||
if (!ideaJavaVersion.isAtLeast(debugProcessVersion)) {
|
||||
throw EvaluateException(
|
||||
"Unable to compile for target level ${sdkVersion.description}. " +
|
||||
"Need to run IDEA on java version at least ${sdkVersion.description}, " +
|
||||
"currently running on ${SystemInfo.JAVA_RUNTIME_VERSION}")
|
||||
"Unable to compile for target level ${debugProcessVersion.description}. " +
|
||||
"Need to run IDEA on java version at least $debugProcessVersion, " +
|
||||
"currently running on $ideaJavaVersion")
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.debugger.evaluate.compilingEvaluator
|
||||
|
||||
import com.intellij.debugger.engine.evaluation.EvaluateException
|
||||
import com.intellij.debugger.engine.evaluation.EvaluationContextImpl
|
||||
import com.sun.jdi.ClassLoaderReference
|
||||
import org.jetbrains.kotlin.idea.debugger.evaluate.LOG
|
||||
@@ -25,6 +26,8 @@ import org.jetbrains.kotlin.idea.debugger.evaluate.classLoading.ClassToLoad
|
||||
fun loadClassesSafely(evaluationContext: EvaluationContextImpl, classes: Collection<ClassToLoad>): ClassLoaderReference? {
|
||||
return try {
|
||||
loadClasses(evaluationContext, classes)
|
||||
} catch (e: EvaluateException) {
|
||||
throw e
|
||||
} catch (e: Throwable) {
|
||||
LOG.debug("Failed to evaluate expression", e)
|
||||
null
|
||||
|
||||
Reference in New Issue
Block a user