Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Equinox Aspects 1.1 and dependencies

[Disclaimer: I don't know this is the right ML for asking about this, so excuse me if I'm wrong posting here]

I've started using Equinox Aspects 1.1 but I've a problem with the bundles since they don't start: com.ibm.oti.shared is required by the org.aspectj.osgi.service.caching bundle. I've downloader the sources from the CVS incubator and modified the Activator with the attached patch and I'd like to know about it (the package dependencies seems to refer to the IBM JVM but I'm using the SUN JDK). Note also that the META-INF/MANIFEST.MF contains:
  Import-Package: com.ibm.oti.shared;resolution:=optional,
which is fine for me but the hard import package directive in the Activator class vanifies the (I guess) intention of not hardwiring the dependency.

Probably I'm missing something but with the attached change I can finally weave my aspects at LT :) Just to make you know.

Regards
Mario
--
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." - Brian W. Kernighan
### Eclipse Workspace Patch 1.0
#P org.aspectj.osgi.service.caching
Index: src/org/aspectj/osgi/service/caching/internal/Activator.java
===================================================================
RCS file: /cvsroot/eclipse/equinox-incubator/aspects/org.aspectj.osgi.service.caching/src/org/aspectj/osgi/service/caching/internal/Activator.java,v
retrieving revision 1.3
diff -u -r1.3 Activator.java
--- src/org/aspectj/osgi/service/caching/internal/Activator.java	11 Jun 2008 09:00:16 -0000	1.3
+++ src/org/aspectj/osgi/service/caching/internal/Activator.java	12 Jun 2008 21:17:59 -0000
@@ -18,7 +18,7 @@
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
 
-import com.ibm.oti.shared.Shared;
+import java.lang.reflect.Method;
 
 /**
  * {@link BundleActivator} for "org.aspectj.osgi.service.caching".
@@ -53,15 +53,15 @@
 	private boolean shouldRegister() {
 		boolean enabled = true;
 		try {
-			Class.forName("com.ibm.oti.vm.VM"); // if this fails we are not on J9
-			boolean sharing = Shared.isSharingEnabled(); // if not using shared classes we want a different adaptor
-
-			if (sharing) {
+			Class clazz = Class.forName("com.ibm.oti.vm.VM"); // if this fails we are not on J9
+			Method method = clazz.getMethod("isSharingEnabled", null);
+			
+			Object sharing = method.invoke(clazz, new Object[0] );
+			if (Boolean.TRUE.equals( sharing )) {
 				enabled = false;
 			}
-		} catch (ClassNotFoundException ex) {
-		}
-
+		} catch (Exception ex) {
+		} 
 		return enabled;
 	}
 

Back to the top