aboutsummaryrefslogtreecommitdiff
path: root/src/eclipseAgent/lombok/launch/PatchFixesHider.java
diff options
context:
space:
mode:
authorReinier Zwitserloot <r.zwitserloot@projectlombok.org>2023-01-12 00:40:22 +0100
committerReinier Zwitserloot <r.zwitserloot@projectlombok.org>2023-01-12 00:40:22 +0100
commit073ec78dd523e6108f18325f321204912b311f26 (patch)
treedaf106051643d435f734e7425dd4fe8767149f78 /src/eclipseAgent/lombok/launch/PatchFixesHider.java
parentc16f6e90849ea2186adc6f81c0303b1d0720ffc0 (diff)
parentffd364b964e671eac8fb6ae700834d5d977b5b00 (diff)
downloadlombok-073ec78dd523e6108f18325f321204912b311f26.tar.gz
lombok-073ec78dd523e6108f18325f321204912b311f26.tar.bz2
lombok-073ec78dd523e6108f18325f321204912b311f26.zip
Merge branch 'Rawi01-eclipse-tests'
Diffstat (limited to 'src/eclipseAgent/lombok/launch/PatchFixesHider.java')
-rwxr-xr-xsrc/eclipseAgent/lombok/launch/PatchFixesHider.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/eclipseAgent/lombok/launch/PatchFixesHider.java b/src/eclipseAgent/lombok/launch/PatchFixesHider.java
index a844239f..c7bdbc31 100755
--- a/src/eclipseAgent/lombok/launch/PatchFixesHider.java
+++ b/src/eclipseAgent/lombok/launch/PatchFixesHider.java
@@ -27,6 +27,7 @@ import java.io.OutputStream;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.security.CodeSource;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
@@ -854,4 +855,28 @@ final class PatchFixesHider {
return isGenerated(adjustment.getMember());
}
}
+
+ public static class Tests {
+ public static Object getBundle(Object original, Class<?> c) {
+ if (original != null) {
+ return original;
+ }
+
+ CodeSource codeSource = c.getProtectionDomain().getCodeSource();
+ if (codeSource == null) {
+ return null;
+ }
+
+ String jar = codeSource.getLocation().getFile();
+ String bundleName = jar.substring(jar.lastIndexOf("/") + 1, jar.indexOf("_"));
+
+ org.osgi.framework.Bundle[] bundles = org.eclipse.core.runtime.adaptor.EclipseStarter.getSystemBundleContext().getBundles();
+ for (org.osgi.framework.Bundle bundle : bundles) {
+ if (bundleName.equals(bundle.getSymbolicName())) {
+ return bundle;
+ }
+ }
+ return null;
+ }
+ }
}