RFR: 7903963: Fix "Run Configuration" Window Freeze Issue

Oleksii Sylichenko duke at openjdk.org
Fri Mar 7 17:17:43 UTC 2025


On Fri, 7 Mar 2025 14:58:18 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> # When the Problem Occurs
>> 
>> The JTReg "Run Configuration" window freezes when the user selects a JRE that is not present in the project's SDK list.
>> 
>> # Why the Problem Occurs
>> 
>> There is a method `applyEditorTo` in the `JTRegConfigurable.java` class, which is called repeatedly while the "Run Configuration" window is open. Within this method, the method `jrePathEditor.getJrePathOrName()` is invoked. As a result, when this method is called for a JRE path not listed in IDEA, it attempts to determine the Java version. If the user has selected a raw JDK image, a Java process is launched, and the version is obtained from the process output (see [org.jetbrains.jps.model.java.impl.JdkVersionDetectorImpl#detectJdkVersionInfo](https://github.com/JetBrains/intellij-community/blob/baba77ecf93f44a2ccb34e5b206e03c60817d511/jps/model-impl/src/org/jetbrains/jps/model/java/impl/JdkVersionDetectorImpl.java#L40)). 
>> 
>> This call is too resource-intensive to be executed on the UI thread, causing the window to freeze.
>> 
>> # Steps to reproduce
>> 
>> 1. Open a JDK project.  
>> 2. Open the "Project Structure" window.  
>> 3. Navigate to "Platform Settings → SDKs".
>> 4. Remove the JDK that is used as the JRE for tests, or create a copy of this JDK on your file system.  
>> 5. Create a new "JTReg Run Configuration".  
>> 6. In the "JRE" field, select a JDK path that is not present in the Project SDK list (either the removed JDK or the copied one).  
>> 
>> ## Actual result
>> - The window starts freezing, even after saving and reopening it.
>> 
>> # Implemented Changes
>> 
>> ## JTRegConfigurable.java
>> - Fix Javadoc for the class.
>> - Remove unused class field: `jtregDir`.
>> - Add Javadoc to the methods: `createUIComponents`, `applyEditorTo`, `resetEditorFrom`
>> - Fix window freeze caused by `jrePathEditor` in the method `applyEditorTo`.
>> - Add method `applyEditorJrePathTo` to optimize data retrieval from `jrePathEditor`.
>> 
>> Since I implemented changes in this file, I also took the opportunity to clean up the code a bit.
>
> plugins/idea/src/main/java/com/oracle/plugin/jtreg/configuration/ui/JTRegConfigurable.java line 156:
> 
>> 154:             if (JdkUtil.checkForJdk(alternativeJrePath)) {
>> 155:                 // If the path is a valid JDK, add it to the ComboBox list.
>> 156:                 jrePathEditor.setPathOrName(alternativeJrePath, true);
> 
> I'd like to better understand the effect that adding the path to the list is intended to have. I think the main point here is that the next time `applyEditorTo` is called, the path will be in the list, and we will take the `if` branch instead, which at that point is faster?
> 
> The custom JRE path doesn't seem to persist if I close and re-open the run configuration dialogue.

Yes, this is so that the next time `applyEditorTo` is called, we can safely call `jrePathEditor.getJrePathOrName()` and `jrePathEditor.isAlternativeJreSelected()` (the `if` case).

The custom JRE path does indeed only exist in the list while the window is open.
I added this code to ensure that in the general case, the original `getJrePathOrName` and `isAlternativeJreSelected` calls are used.

-------------

PR Review Comment: https://git.openjdk.org/jtreg/pull/250#discussion_r1985419408


More information about the jtreg-dev mailing list