Replies: 31 comments 135 replies
-
For me, CTRL+X in Netbeans temporarily restores the broken copy functionality, until it happens again that is. |
Beta Was this translation helpful? Give feedback.
-
Using Netbeans 23 relaxes most of the problems for me. Most of the time a copy / paste does not work, the second try succeeds. So right direction. |
Beta Was this translation helpful? Give feedback.
-
I can confirm the problem on Windows and funny thing is, sometimes it works back again. Maybe a raise condition with smth? |
Beta Was this translation helpful? Give feedback.
-
Netbeans 23 doesn't seem to improve things for me. It still happens a lot. Occasionally if I try CTRL+C twice it may fix it, but not always. |
Beta Was this translation helpful? Give feedback.
-
I can confirm that I’m experiencing this issue as well; it seems to be quite common on Windows. The |
Beta Was this translation helpful? Give feedback.
-
I completely agree with the frustration expressed in this thread. This clipboard issue is not just frustrating but quite basic and critical for daily workflow. It's concerning that such an essential feature is unreliable, as it may force many developers to switch to other IDEs just to avoid the constant interruptions. A fix for this issue is quite important and would make a huge difference for all of us who rely on NetBeans for efficient development. |
Beta Was this translation helpful? Give feedback.
-
I don’t know if this will help but I typically copy/paste between NetBeans, IntelliJ, Notepad++ and VisualCode. This is on windows 11. I tend to switch apps pretty quickly when I’m copy/pasting but I don’t know if that’s relevant. I also have two external monitors attached to my laptop. I can’t help with the code but I’ll see if I can build and run from source. Maybe I can quickly try a patched version. I’ve never built NetBeans but if it might help, I can try. I’ll have to check the policy at work on running a patched version though. |
Beta Was this translation helpful? Give feedback.
-
I think I can always copy from the Debug output window, and paste it into an external application. So is the problem only related to the main file editor? Or was this fact already known and, as always, I missed it? 😆 |
Beta Was this translation helpful? Give feedback.
-
I added a PR to introduce this new retry logic for With this, It is possible that this interference is one reason to break copy and paste in windows, since get and set clipboard could interfere each other. Using this windows hack there always was a Since there seems to be a timing or threading problem, my guess is that the So having these thoughts, making |
Beta Was this translation helpful? Give feedback.
-
Did #8024 make it into Netbeans 24? |
Beta Was this translation helpful? Give feedback.
-
@stodge Not yet. I am running on it for some time now, but the problem occurs still from time to time. However, I have the "feeling" it is much less than without #8024 and the getContents modifcation. But saying this I am aware that there are very different experiences of this problem from different users. |
Beta Was this translation helpful? Give feedback.
-
Thanks, just wanted to confirm. |
Beta Was this translation helpful? Give feedback.
-
Netbeans 24: After pasting breaks, copying is also affected. Instead of copying an empty selection (just the cursor), it copies as if the entire line was selected, even if it is (at least visibly) not. Some strange indexing is going on. |
Beta Was this translation helpful? Give feedback.
-
Any actions here? |
Beta Was this translation helpful? Give feedback.
-
After seeing this on Java's Reddit, I decided to take a look at this (even though I've never used this IDE). I was able to reproduce this issue 100% of the time right from the opening. I've found the root cause and will post a fix once I figure out why this is the case. If one puts a breakpoint here https://github.com/openjdk/jdk/blob/a891630817844c8c42994da3b3110925ca4595a0/src/java.desktop/share/classes/sun/awt/datatransfer/SunClipboard.java#L135 and forcefully sets I added a bit of checking, and indeed, that is what is happening.
Added check in
Edit: I've narrowed down the cause, and this seems to be a bug in the JDK. I'm getting assert failures building AWT with
Local fix on my machine, I haven't been able to reproduce the issue with this change. Running AWT tests |
Beta Was this translation helpful? Give feedback.
-
in version 24 using -J-Dorg.netbeans.NbClipboard.level=FINEST i had very limited problems. I run CopyPasteTest and here are the results` Iteration 1: 2025-02-23 16:07:08.557 - Pasted into Notepad Iteration 2: 2025-02-23 16:07:09.364 - Pasted into NetBeans - Error: Copied or pasted text is empty. Iteration 2: 2025-02-23 16:07:10.284 - Pasted into Notepad Iteration 3: 2025-02-23 16:07:11.077 - Pasted into NetBeans - Error: Copied or pasted text is empty. Iteration 3: 2025-02-23 16:07:11.995 - Pasted into Notepad Iteration 4: 2025-02-23 16:07:12.788 - Pasted into NetBeans - Error: Copied or pasted text is empty. Iteration 4: 2025-02-23 16:07:13.709 - Pasted into Notepad Iteration 5: 2025-02-23 16:07:14.499 - Pasted into NetBeans - Error: Copied or pasted text is empty. Iteration 5: 2025-02-23 16:07:15.478 - Pasted into Notepad Iteration 6: 2025-02-23 16:07:16.268 - Pasted into NetBeans - Error: Copied or pasted text is empty. Iteration 6: 2025-02-23 16:07:17.310 - Pasted into Notepad Iteration 7: 2025-02-23 16:07:18.100 - Pasted into NetBeans - Error: Copied or pasted text is empty. Iteration 7: 2025-02-23 16:07:19.144 - Pasted into Notepad Iteration 8: 2025-02-23 16:07:19.937 - Pasted into NetBeans - Error: Copied or pasted text is empty. Iteration 8: 2025-02-23 16:07:20.981 - Pasted into Notepad Iteration 9: 2025-02-23 16:07:21.774 - Pasted into NetBeans - Error: Copied or pasted text is empty. Iteration 9: 2025-02-23 16:07:22.812 - Pasted into Notepad Iteration 10: 2025-02-23 16:07:23.603 - Pasted into NetBeans - Error: Copied or pasted text is empty. Iteration 10: 2025-02-23 16:07:24.648 - Pasted into Notepad I tried with and without Nothing changed... Any idea suggestions? |
Beta Was this translation helpful? Give feedback.
-
Thinking about the latest findings (@xxDark) I find it strange that the clipboard seems to be not useable using the Java Editor but nearly without any problems from the Output or IDE Log windows. |
Beta Was this translation helpful? Give feedback.
-
clipboard doesn't work (( it's impossible to work |
Beta Was this translation helpful? Give feedback.
-
xxDark's clipboard-agent fixed the issue without using FINEST. Perfect results for test code, 256 iterations. Yes, java.toolchain.languageVersion.set(JavaLanguageVersion.of(23)) needs reform upon build as |
Beta Was this translation helpful? Give feedback.
-
@neilcsmith-net made me aware, that there is the idea out there, that not using flavor listeners might also fix the problem. He also mentioned, that there are not that many places in the codebase that use them. Indeed outside the tests only master...matthiasblaesing:netbeans:flavorlistener_test When run as My result was, that with 15 iterations, I could reproduce the problem without the system property and could not reproduce it anymore with flavor listeners disabled. |
Beta Was this translation helpful? Give feedback.
-
@matthiasblaesing If that works it will be amazing. Thanks for trying it! What do the flavor listeners do? Can we live without them? |
Beta Was this translation helpful? Give feedback.
-
Flavor listeners listen for clipboard changes in realtime. Yes, it does fix the problem because the problematic OpenClipboard call is made only if there are any flavor listeners registered. |
Beta Was this translation helpful? Give feedback.
-
If a fix for this has been committed, will it be introduced in an update to NetBeans 25, or will it be released in a new version, NetBeans 26? |
Beta Was this translation helpful? Give feedback.
-
So another approach. As the agent idea is not well received, I tried to reproduce the problem with a plain JTextArea and a flavor listener. The problem is not reproducible there. So it is not just the flavor listener. Based on @xxDark analysis and @mbien idea to rebuild the JDK I augemented a JDK build with logging of the I indeed saw two calls running in parallel, one from the native callback listening for clipboard changes and one coming from NetBeans copying data. The latter came from with that I get this result from the reproducer: The reference from It would be great if others (@istinnstudio, @xxDark, @bradvido) could test the nightly available from: https://github.com/apache/netbeans/suites/36719959239/artifacts/2885407474 Two comments:
|
Beta Was this translation helpful? Give feedback.
-
There's definitively a JDK bug, as @xxDark managed to cause assertion failures in the JDK when the code was called from the wrong thread. If NetBeans fixes it with an agent patch, and it proves to work well over time, that may help convince OpenJDK to fix it upstream eventually.
I don't think that's good: For the purposes of actually fixing the bug, "nearly always" is something we can work with. "Hard to reproduce" is much more frustrating. Why is there still pushback against the agent solution? |
Beta Was this translation helpful? Give feedback.
-
I will try to make a reliable reproducer. The problem is that DWM/epxlorer really does not like rapid clipboard interactions. Rapidly interacting with the clipboard causes explorer to stop responding to key presses, including ctrl-alt-delete. |
Beta Was this translation helpful? Give feedback.
-
An updated version of the "agent approach" is available from #8361 (comment: #8361 (comment)): Checks page direct download. I tested successfully with the reproducer code, more tests would be appreciated. |
Beta Was this translation helpful? Give feedback.
-
seems to be fixed in NB 26-rc1 after some hours of work !! |
Beta Was this translation helpful? Give feedback.
-
I'm still on NB 25 with the patch from @xxDark. While copy/paste works, I have issues with NB's "Paste from history" action. The Paste from history popup only seems to be filled with new entries occasionally but I'm unable to reproduce this reliably. For example, if I copy text from this text field on GitHub (Firefox), the new entries always seem to be properly added. However, if I attempt the same from open editor tabs within the IDE, it only adds new entries to the popup sometimes and almost never if I try within just one editor tab. I can't copy two code constructs at the same time in order to paste them into the same editor tab. Essentially, all I'm doing is a couple of Just tried with NB 26-rc1. Same behavior. |
Beta Was this translation helpful? Give feedback.
-
It seems this has been fixed in netbeans 26. As I was upgrading to netbeans 26, i and applying this clipboard java agent patch, I noticed this is already there in the configuration. Haven't tested, but glad to see this much needed patch is included. Thanks to everyone. @xxDark much gratitude I have been using netbeans since almost 2008, and mostly on windows. Thanks to everyone again. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Copying text in and out of NetBeans stops working for some users on windows, this thread discusses #3962 on the adventurous quest to fix the bug.
updates:
thanks to everyone who participated in this endeavor, esp to @xxDark who came up with the initial patch (#7051 (comment)), many community members who helped finding methods to reproduce the race condition more reliably and @matthiasblaesing for integrating it into NetBeans 26 #8361
Beta Was this translation helpful? Give feedback.
All reactions