Skip to content

Commit

Permalink
ProcessImplementation module cleanup
Browse files Browse the repository at this point in the history
 - module can use the API without reflection since build requires JDK
   17 by now (impl itself was not altered)
 - added some logging

remove now redundant module

 - merge ide/extexecution.process.jdk9 into ide/extexecution.process
 - module-auto-deps.xml should delegate at build time to use the right
   module
  • Loading branch information
mbien committed Aug 22, 2024
1 parent 72d62a3 commit 3f435c2
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 306 deletions.
7 changes: 0 additions & 7 deletions ide/extexecution.process.jdk9/manifest.mf

This file was deleted.

19 changes: 0 additions & 19 deletions ide/extexecution.process.jdk9/nbproject/project.properties

This file was deleted.

57 changes: 0 additions & 57 deletions ide/extexecution.process.jdk9/nbproject/project.xml

This file was deleted.

This file was deleted.

This file was deleted.

19 changes: 0 additions & 19 deletions ide/extexecution.process/external/binaries-list

This file was deleted.

This file was deleted.

28 changes: 0 additions & 28 deletions ide/extexecution.process/external/winp-1.28-license.txt

This file was deleted.

2 changes: 1 addition & 1 deletion ide/extexecution.process/manifest.mf
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ Manifest-Version: 1.0
AutoUpdate-Show-In-Client: false
OpenIDE-Module: org.netbeans.modules.extexecution.process
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/extexecution/process/resources/Bundle.properties
OpenIDE-Module-Specification-Version: 1.53
OpenIDE-Module-Specification-Version: 1.54
OpenIDE-Module-Provides: org.netbeans.spi.extexecution.base.ProcessesImplementation
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,21 @@
under the License.
-->
<project basedir="." default="build" name="ide/extexecution.process.jdk9">
<description>Builds, tests, and runs the project org.netbeans.modules.extexecution.process.jdk9</description>
<import file="../../nbbuild/templates/projectized.xml"/>
</project>

<!DOCTYPE transformations PUBLIC "-//NetBeans//DTD Module Automatic Dependencies 1.0//EN" "http://www.netbeans.org/dtds/module-auto-deps-1_0.dtd">

<transformations version="1.0">
<transformationgroup>
<description>Merged o.n.m.extexecution.process.jdk9 into o.n.m.extexecution.process</description>
<transformation>
<trigger-dependency type="cancel">
<module-dependency codenamebase="org.netbeans.modules.extexecution.process.jdk9"/>
</trigger-dependency>
<implies>
<result>
<module-dependency codenamebase="org.netbeans.modules.extexecution.process" spec="1.54"/>
</result>
</implies>
</transformation>
</transformationgroup>
</transformations>
6 changes: 2 additions & 4 deletions ide/extexecution.process/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,5 @@
# specific language governing permissions and limitations
# under the License.
is.autoload=true
javac.source=1.8
javac.compilerargs=-Xlint -Xlint:-serial
release.external/winp-1.28.jar=modules/ext/winp-1.28.jar
release.external/processtreekiller-2.0.1.jar=modules/ext/processtreekiller-2.0.1.jar
javac.release=11
javac.compilerargs=-Xlint -Xlint:-serial
17 changes: 0 additions & 17 deletions ide/extexecution.process/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@
<data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
<code-name-base>org.netbeans.modules.extexecution.process</code-name-base>
<module-dependencies>
<dependency>
<code-name-base>org.netbeans.libs.jna</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>2</release-version>
<specification-version>2.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.extexecution.base</code-name-base>
<build-prerequisite/>
Expand Down Expand Up @@ -61,14 +52,6 @@
</dependency>
</module-dependencies>
<public-packages/>
<class-path-extension>
<runtime-relative-path>ext/winp-1.28.jar</runtime-relative-path>
<binary-origin>external/winp-1.28.jar</binary-origin>
</class-path-extension>
<class-path-extension>
<runtime-relative-path>ext/processtreekiller-2.0.1.jar</runtime-relative-path>
<binary-origin>external/processtreekiller-2.0.1.jar</binary-origin>
</class-path-extension>
</data>
</configuration>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,35 @@
package org.netbeans.modules.extexecution.process;

import java.util.Map;
import org.netbeans.processtreekiller.ProcessTreeKiller;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Stream;
import org.netbeans.spi.extexecution.base.ProcessesImplementation;
import org.openide.util.lookup.ServiceProvider;

/**
*
* @author mkleint
*/
@ServiceProvider(service=ProcessesImplementation.class)
@ServiceProvider(service=ProcessesImplementation.class, position = 1000)
public class ProcessesImpl implements ProcessesImplementation {

private static final Logger LOGGER = Logger.getLogger(ProcessesImpl.class.getName());

@Override
public void killTree(Process process, Map<String, String> environment) {
try {
ProcessTreeKiller.get().kill(process, environment);
} catch (LinkageError e) {
throw new UnsupportedOperationException(null, e);
ProcessHandle handle = process.toHandle();
try (Stream<ProcessHandle> tree = handle.descendants()) {
destroy("proc", handle);
tree.forEach(ch -> destroy("child", ch));
}
}

private static void destroy(String kind, ProcessHandle handle) {
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.log(Level.FINE, "destroying {0}: {1}; info: {2}", new Object[]{kind, handle, handle.info()});
}
handle.destroy();
}

}
Loading

0 comments on commit 3f435c2

Please sign in to comment.