-
Notifications
You must be signed in to change notification settings - Fork 1
ALT-11006 Fix SDK selection blocked in 2026.1 #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,7 @@ private val LOG = logger<JdkLanguageSettings>() | |
|
|
||
| open class JdkLanguageSettings : LanguageSettings<JdkProjectSettings>() { | ||
|
|
||
| @Volatile | ||
| protected var jdk: Sdk? = null | ||
| protected val sdkModel: ProjectSdksModel = createSdkModel() | ||
|
|
||
|
|
@@ -145,52 +146,58 @@ open class JdkLanguageSettings : LanguageSettings<JdkProjectSettings>() { | |
| jdkComboBox.isEnabled = false | ||
|
|
||
| runInBackground(course.project, EduJVMBundle.message("progress.setting.suitable.jdk"), false) { | ||
| // Reset SDK model off-EDT to avoid IllegalStateException from synchronous progress on EDT | ||
| try { | ||
| val project = course.project | ||
| if (project != null) { | ||
| sdksModel.reset(project) | ||
| // Reset SDK model off-EDT to avoid IllegalStateException from synchronous progress on EDT | ||
| try { | ||
| val project = course.project | ||
| if (project != null) { | ||
| sdksModel.reset(project) | ||
| } | ||
| } | ||
| catch (e: Throwable) { | ||
| loadingState = JdkLoadingState.FAILED | ||
| // best-effort; if reset fails we'll try with whatever the model currently has | ||
| loadingError = e.message | ||
| } | ||
| } | ||
| catch (e: Throwable) { | ||
| loadingState = JdkLoadingState.FAILED | ||
| // best-effort; if reset fails we'll try with whatever the model currently has | ||
| loadingError = e.message | ||
| } | ||
|
|
||
| // Add bundled JDK if needed (must be done off-EDT as addSdk requires write action) | ||
| try { | ||
| addBundledJdkIfNeeded(sdksModel) | ||
| } | ||
| catch (_: Throwable) { | ||
| // best-effort; ignore failures | ||
| } | ||
|
|
||
| // If sdkModel is empty, try to get JDKs directly from ProjectJdkTable | ||
| val suitableJdk = findSuitableJdk(minJvmSdkVersion(course), sdksModel) | ||
| ?: findSuitableJdkFromTable(minJvmSdkVersion(course)) | ||
| // Add bundled JDK if needed (must be done off-EDT as addSdk requires write action) | ||
| try { | ||
| addBundledJdkIfNeeded(sdksModel) | ||
| } | ||
| catch (_: Throwable) { | ||
| // best-effort; ignore failures | ||
| } | ||
|
|
||
| // Check if we found any JDK at all (either suitable or any) | ||
| val anyJdkAvailable = sdksModel.sdks.any { it.sdkType == JavaSdk.getInstance() } | ||
| || ProjectJdkTable.getInstance().getSdksOfType(JavaSdk.getInstance()).isNotEmpty() | ||
| // If sdkModel is empty, try to get JDKs directly from ProjectJdkTable | ||
| jdk = findSuitableJdk(minJvmSdkVersion(course), sdksModel) | ||
| ?: findSuitableJdkFromTable(minJvmSdkVersion(course)) | ||
|
|
||
| loadingState = if (anyJdkAvailable) JdkLoadingState.LOADED | ||
| else JdkLoadingState.FAILED | ||
| // Check if we found any JDK at all (either suitable or any) | ||
| if (sdksModel.sdks.all { it.sdkType != JavaSdk.getInstance() } | ||
| && ProjectJdkTable.getInstance().getSdksOfType(JavaSdk.getInstance()).isEmpty()) { | ||
| throw RuntimeException(EduJVMBundle.message("error.no.jdk.available")) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: Throwing |
||
| } | ||
|
|
||
| loadingError = if (anyJdkAvailable) null | ||
| else EduJVMBundle.message("error.no.jdk.available") | ||
| loadingState = JdkLoadingState.LOADED | ||
| loadingError = null | ||
|
|
||
| runInBackground(course.project, EduJVMBundle.message("progress.warming.suitable.jdk"), false) { | ||
| // Pre-warm SDK validation and VFS lookups off the EDT to avoid slow operations during UI rendering | ||
| prewarmSdkValidation(suitableJdk) | ||
| runInBackground(course.project, EduJVMBundle.message("progress.warming.suitable.jdk"), false) { | ||
| // Pre-warm SDK validation and VFS lookups off the EDT to avoid slow operations during UI rendering | ||
| prewarmSdkValidation(jdk) | ||
| } | ||
| } | ||
| catch (e: Throwable) { | ||
| LOG.warn("Failed to preselect JDK", e) | ||
| loadingState = JdkLoadingState.FAILED | ||
| loadingError = e.message | ||
| } | ||
| finally { | ||
| invokeLater(ModalityState.any()) { | ||
| jdkComboBox.isEnabled = true | ||
| jdkComboBox.selectedJdk = jdk | ||
|
|
||
| invokeLater(ModalityState.any()) { | ||
| jdkComboBox.isEnabled = true | ||
| jdkComboBox.selectedJdk = suitableJdk | ||
| jdk = suitableJdk | ||
|
|
||
| notifyListeners() | ||
| notifyListeners() | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: The
<a href="{0}">...</a>links were removed from these messages. Were they previously rendered as clickable hyperlinks anywhere in the UI (e.g. in a notification or validation panel)? If so, users lose a quick shortcut to JDK settings. If they were never actually rendered as hyperlinks, the cleanup makes sense.