Skip to content

Fix flaky clipboard on Windows #8361

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

Merged
merged 2 commits into from
Apr 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion harness/apisupport.harness/external/binaries-list
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
# D4EF66C1CC8A5B3C97E0CC7C210227AAEC1F1086 jsearch-2.0_05.jar
A806D99716C5E9441BFD8B401176FDDEFC673022 bindex-2.2.jar
6FF4C411EE231AB8042C9047373F87FC64D0299D harness-launchers-8.2.zip
DB781CBFDA3565BC55742D90E0C111204764D85C https://archive.apache.org/dist/netbeans/native/netbeans-launchers/2-6c17cc6/launcher-external-binaries-2-6c17cc6.zip launcher-external-binaries-2-6c17cc6.zip
1D8777C057A3CFE0EE5A9E2BC7DF73BEC967E730 https://archive.apache.org/dist/netbeans/native/netbeans-launchers/3-282bbc032bcd/launcher-external-binaries-3-282bbc032bcd.zip launcher-external-binaries-3-282bbc032bcd.zip
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Name: NetBeans Application Launchers
Description: Windows Launchers for NetBeans Applications
Version: 2-6c17cc6
Version: 3-282bbc032bcd
License: Apache-2.0
Source: https://netbeans.org/
Origin: NetBeans
Expand Down
4 changes: 2 additions & 2 deletions harness/apisupport.harness/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ release.../../nbbuild/jdk.xml=jdk.xml
# release.external/jsearch-2.0_05.jar=antlib/jsearch-2.0_05.jar
release.external/bindex-2.2.jar=antlib/bindex-2.2.jar
#release.external/jnlp-servlet.jar=jnlp/jnlp-servlet.jar
release.external/launcher-external-binaries-2-6c17cc6.zip!/app.exe=launchers/app.exe
release.external/launcher-external-binaries-2-6c17cc6.zip!/app64.exe=launchers/app64.exe
release.external/launcher-external-binaries-3-282bbc032bcd.zip!/app.exe=launchers/app.exe
release.external/launcher-external-binaries-3-282bbc032bcd.zip!/app64.exe=launchers/app64.exe
release.external/harness-launchers-8.2.zip!/pre7_app.exe=launchers/pre7_app.exe
release.external/harness-launchers-8.2.zip!/pre7_app_w.exe=launchers/pre7_app_w.exe
nbm.executable.files=launchers/app.sh
Expand Down
65 changes: 65 additions & 0 deletions ide/o.n.agent/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-->
<project basedir="." default="netbeans" name="ide/o.n.agent">
<description>Builds, tests, and runs the project org.netbeans.agent</description>
<import file="../../nbbuild/templates/projectized.xml"/>

<target name="-jar-ant">

<mkdir dir="${agent.build.classes.dir}" />

<javac release="${javac.release}"
srcdir="${agent.src.dir}"
destdir="${agent.build.classes.dir}"
debug="true"
classpath="${agent.cp}" />

<jar destfile="${cluster}/netbeans-javaagent.jar" update="true" manifest="${agent.src.dir}/META-INF/MANIFEST.MF">
<fileset dir="${agent.build.classes.dir}" />
<fileset dir="${agent.src.dir}" includes="**/*" excludes="**/*.class" />
<mappedresources>
<fileset file="../../nbbuild/licenses/Apache-2.0" />
<globmapper from="*" to="META-INF/LICENSE"/>
</mappedresources>
<zipfileset src="${agent.asm.lib.1}">
<include name="**" />
<exclude name="module-info.class" />
<exclude name="META-INF/**" />
</zipfileset>
<zipfileset src="${agent.asm.lib.2}">
<include name="**" />
<exclude name="module-info.class" />
<exclude name="META-INF/**" />
</zipfileset>
<zipfileset src="${agent.asm.lib.3}">
<include name="**" />
<exclude name="module-info.class" />
<exclude name="META-INF/**" />
</zipfileset>
</jar>
</target>

<target name="compile" depends="-jar-ant,projectized-common.compile"/>

<target name="clean" depends="projectized-common.clean">
<delete dir="${agent.build.classes.dir}"/>
<delete file="${cluster}/netbeans-javaagent.jar"/>
</target>
</project>
5 changes: 5 additions & 0 deletions ide/o.n.agent/manifest.mf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Manifest-Version: 1.0
AutoUpdate-Show-In-Client: true
OpenIDE-Module: org.netbeans.agent
OpenIDE-Module-Localizing-Bundle: org/netbeans/agent/Bundle.properties
OpenIDE-Module-Specification-Version: 1.0
29 changes: 29 additions & 0 deletions ide/o.n.agent/nbproject/project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

javac.release=17
javac.compilerargs=-Xlint -Xlint:-serial

agent.src.dir=src-agent
agent.build.classes.dir=${build.dir}/agent/classes/
agent.jar=${cluster}/netbeans-javaagent.jar
agent.asm.lib.1=../../platform/libs.asm/external/asm-commons-9.8.jar
agent.asm.lib.2=../../platform/libs.asm/external/asm-tree-9.8.jar
agent.asm.lib.3=../../platform/libs.asm/external/asm-9.8.jar
agent.cp=${agent.asm.lib.1}:${agent.asm.lib.2}:${agent.asm.lib.3}

extra.module.files=${cluster}/netbeans-javaagent.jar
45 changes: 45 additions & 0 deletions ide/o.n.agent/nbproject/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-->
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.apisupport.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
<code-name-base>org.netbeans.agent</code-name-base>
<module-dependencies>
<dependency>
<code-name-base>org.netbeans.libs.asm</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>5.31</specification-version>
</run-dependency>
</dependency>
</module-dependencies>
<test-dependencies/>
<public-packages/>
<extra-compilation-unit>
<package-root>${agent.src.dir}</package-root>
<classpath>${agent.cp}</classpath>
<built-to>${agent.build.classes.dir}</built-to>
<built-to>${cluster}/netbeans-javaagent.jar</built-to>
</extra-compilation-unit>
</data>
</configuration>
</project>
1 change: 1 addition & 0 deletions ide/o.n.agent/src-agent/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Premain-Class: org.netbeans.agent.NetBeansAgent
44 changes: 44 additions & 0 deletions ide/o.n.agent/src-agent/META-INF/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Apache NetBeans
Copyright 2017-2025 The Apache Software Foundation

This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).

The code is based on NetBeans, that has been kindly donated to the Apache
Software Foundation by Oracle.

The code was Copyright 1997-2016 Oracle and/or its affiliates. The Initial
Developer of the Original Software was Sun Microsystems, Inc. Portions
Copyright 1997-2006 Sun Microsystems, Inc.

The agent jar embeds a copy of ASM for bytecode manipulation:

*******************************************************************************
* ASM: a very small and fast Java bytecode manipulation framework
* Copyright (c) 2000-2011 INRIA, France Telecom
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*******************************************************************************
49 changes: 49 additions & 0 deletions ide/o.n.agent/src-agent/org/netbeans/agent/NetBeansAgent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.netbeans.agent;

import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.Instrumentation;
import java.util.ArrayList;
import java.util.List;

/**
* Implementation of a java agent. The JAR containing this class must be
* referenced by the JVM with the agent infrastructure. At time of writing this
* means, that the JAR must be passed via the `-javaagent:JARPATH` construct.
* JARPATH in this case must be the absolute path to the netbeans-javaagent.jar.
*
* The `premain` method in this class is then invoked by the JVM _before_ the
* applications main method is invoked.
*
* This should be used as a last resort. For classes loaded throught the
* module system that faciliy should be prefered.
*/
public class NetBeansAgent {

public static void premain(String arg, Instrumentation instrumentation) {
List<ClassFileTransformer> transformer = new ArrayList<>(2);
if ((!Boolean.getBoolean(WClipboardTransformer.DEBUG_DISABLE_TRANSFORMER))
&& System.getProperty("os.name").toLowerCase().contains("windows")) {
transformer.add(new WClipboardTransformer(instrumentation));
}
transformer.forEach(cft -> instrumentation.addTransformer(cft, false));
}

}
Loading
Loading