diff options
author | Thomas Watson | 2006-04-12 20:13:24 +0000 |
---|---|---|
committer | Thomas Watson | 2006-04-12 20:13:24 +0000 |
commit | 8d879b57efaf467f412e1cdd36d4c26ebb2198b2 (patch) | |
tree | a7f8d041b6bb5e48fcbeb49b1d83e4b42988c9dd | |
parent | c226d1685bfaa34065d1dcb4640885fb0587861c (diff) | |
download | rt.equinox.framework-8d879b57efaf467f412e1cdd36d4c26ebb2198b2.tar.gz rt.equinox.framework-8d879b57efaf467f412e1cdd36d4c26ebb2198b2.tar.xz rt.equinox.framework-8d879b57efaf467f412e1cdd36d4c26ebb2198b2.zip |
Bug 133343 Unable to load some native libraries on AIX platformsv20060412-1700
2 files changed, 34 insertions, 2 deletions
diff --git a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseClassLoadingHook.java b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseClassLoadingHook.java index d752d20af..cf472b205 100644 --- a/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseClassLoadingHook.java +++ b/bundles/org.eclipse.osgi/defaultAdaptor/src/org/eclipse/osgi/internal/baseadaptor/BaseClassLoadingHook.java @@ -21,8 +21,28 @@ import org.eclipse.osgi.baseadaptor.loader.*; import org.eclipse.osgi.framework.adaptor.BundleProtectionDomain; import org.eclipse.osgi.framework.adaptor.ClassLoaderDelegate; import org.eclipse.osgi.framework.debug.Debug; +import org.eclipse.osgi.framework.internal.core.FrameworkProperties; +import org.eclipse.osgi.util.ManifestElement; public class BaseClassLoadingHook implements ClassLoadingHook { + private static final String[] LIB_EXTENSIONS = ManifestElement.getArrayFromList(FrameworkProperties.getProperty("osgi.framework.library.extensions"), ","); //$NON-NLS-1$ //$NON-NLS-2$ + private static final String[] EMPTY_STRINGS = new String[0]; + + /* + * Maps an already mapped library name to additional library file extensions. + * This is needed on platforms like AIX where .a and .so can be used as library file + * extensions, but System.mapLibraryName only returns a single string. + */ + public static String[] mapLibraryNames(String mappedLibName) { + int extIndex = mappedLibName.lastIndexOf('.'); + if (LIB_EXTENSIONS.length == 0 || extIndex < 0) + return EMPTY_STRINGS; + String libNameBase = mappedLibName.substring(0, extIndex); + String[] results = new String[LIB_EXTENSIONS.length]; + for (int i = 0; i < results.length; i++) + results[i] = libNameBase + LIB_EXTENSIONS[i]; + return results; + } public String findLibrary(BaseData data, String libName) { String mappedName = System.mapLibraryName(libName); @@ -31,6 +51,11 @@ public class BaseClassLoadingHook implements ClassLoadingHook { Debug.println(" mapped library name: " + mappedName); //$NON-NLS-1$ path = findNativePath(data, mappedName); if (path == null) { + String[] mappedNames = mapLibraryNames(mappedName); + for (int i = 0; i < mappedNames.length && path == null; i++) + path = findNativePath(data, mappedNames[i]); + } + if (path == null) { if (Debug.DEBUG && Debug.DEBUG_LOADER) Debug.println(" library does not exist: " + mappedName); //$NON-NLS-1$ path = findNativePath(data, libName); diff --git a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseClassLoadingHook.java b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseClassLoadingHook.java index bb634ad1c..d9ec64e7b 100644 --- a/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseClassLoadingHook.java +++ b/bundles/org.eclipse.osgi/eclipseAdaptor/src/org/eclipse/core/runtime/internal/adaptor/EclipseClassLoadingHook.java @@ -25,6 +25,7 @@ import org.eclipse.osgi.baseadaptor.loader.*; import org.eclipse.osgi.framework.adaptor.BundleProtectionDomain; import org.eclipse.osgi.framework.adaptor.ClassLoaderDelegate; import org.eclipse.osgi.framework.internal.core.FrameworkProperties; +import org.eclipse.osgi.internal.baseadaptor.BaseClassLoadingHook; public class EclipseClassLoadingHook implements ClassLoadingHook, HookConfigurator { private static String[] NL_JAR_VARIANTS = buildNLJarVariants(EclipseEnvironmentInfo.getDefault().getNL()); @@ -217,8 +218,14 @@ public class EclipseClassLoadingHook implements ClassLoadingHook, HookConfigurat return null; if (libName.charAt(0) == '/' || libName.charAt(0) == '\\') libName = libName.substring(1); - libName = System.mapLibraryName(libName); - return searchVariants(data, libName); + String mappedLibName = System.mapLibraryName(libName); + String result = searchVariants(data, mappedLibName); + if (result != null) + return result; + String[] mappedLibNames = BaseClassLoadingHook.mapLibraryNames(mappedLibName); + for (int i = 0; i < mappedLibNames.length && result == null; i++) + result = searchVariants(data, mappedLibNames[i]); + return result; } private String searchVariants(BaseData bundledata, String path) { |