This is an automated email from the ASF dual-hosted git repository.
asf-gitbox-commits pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ant-antlibs-cyclonedx.git
The following commit(s) were added to refs/heads/main by this push:
new 4ac4b16 use Ant's Locator instead of reinventing it
4ac4b16 is described below
commit 4ac4b166f1b1e1901450efd18e36a6da3e9f6b74
Author: Stefan Bodewig <[email protected]>
AuthorDate: Mon Jun 8 21:30:24 2026 +0200
use Ant's Locator instead of reinventing it
---
src/main/org/apache/ant/cyclonedx/ToolData.java | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/src/main/org/apache/ant/cyclonedx/ToolData.java
b/src/main/org/apache/ant/cyclonedx/ToolData.java
index f48abd2..cbbfc1c 100644
--- a/src/main/org/apache/ant/cyclonedx/ToolData.java
+++ b/src/main/org/apache/ant/cyclonedx/ToolData.java
@@ -3,13 +3,12 @@ package org.apache.ant.cyclonedx;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.net.URL;
-import java.security.CodeSource;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
+import org.apache.tools.ant.launch.Locator;
import org.apache.tools.ant.types.resources.FileResource;
import org.apache.tools.ant.types.resources.URLResource;
@@ -116,13 +115,9 @@ class ToolData {
}
private static File findAntlib() {
- CodeSource antlibSource =
ToolData.class.getProtectionDomain().getCodeSource();
- if (antlibSource == null) {
- return null;
- }
- URL location = antlibSource.getLocation();
- if ("file".equals(location.getProtocol())) {
- return new File(location.getPath());
+ File f = Locator.getClassSource(ToolData.class);
+ if (f != null && f.isFile()) {
+ return f;
}
return null;
}