use of org.eclipse.osgi.storage.bundlefile.BundleEntry in project rt.equinox.framework by eclipse.
the class ClasspathManager method findClassImpl.
private Class<?> findClassImpl(String name, ClasspathEntry classpathEntry, List<ClassLoaderHook> hooks) {
if (debug.DEBUG_LOADER)
// $NON-NLS-1$ //$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$
Debug.println("ModuleClassLoader[" + classloader.getBundleLoader() + " - " + classpathEntry.getBundleFile() + "].findClassImpl(" + name + ")");
// $NON-NLS-1$
String filename = name.replace('.', '/').concat(".class");
BundleEntry entry = classpathEntry.findEntry(filename);
if (entry == null)
return null;
byte[] classbytes;
try {
classbytes = entry.getBytes();
} catch (IOException e) {
if (debug.DEBUG_LOADER)
// $NON-NLS-1$ //$NON-NLS-2$
Debug.println(" IOException reading " + filename + " from " + classpathEntry.getBundleFile());
// $NON-NLS-1$
throw (LinkageError) new LinkageError("Error reading class bytes: " + name).initCause(e);
}
if (debug.DEBUG_LOADER) {
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
Debug.println(" read " + classbytes.length + " bytes from " + classpathEntry.getBundleFile() + "!/" + filename);
// $NON-NLS-1$
Debug.println(" defining class " + name);
}
try {
return defineClass(name, classbytes, classpathEntry, entry, hooks);
} catch (Error e) {
if (debug.DEBUG_LOADER)
// $NON-NLS-1$
Debug.println(" error defining class " + name);
throw e;
}
}
use of org.eclipse.osgi.storage.bundlefile.BundleEntry in project rt.equinox.framework by eclipse.
the class ClasspathEntry method getMRBundleFiles.
private static List<BundleFile> getMRBundleFiles(BundleFile bundlefile, Generation generation) {
Storage storage = generation.getBundleInfo().getStorage();
if (storage.getRuntimeVersion().getMajor() < 9) {
return Collections.emptyList();
}
List<BundleFile> mrBundleFiles = new ArrayList<>();
for (int i = storage.getRuntimeVersion().getMajor(); i > 8; i--) {
String versionPath = BundleInfo.MULTI_RELEASE_VERSIONS + i + '/';
BundleEntry versionEntry = bundlefile.getEntry(versionPath);
if (versionEntry != null) {
mrBundleFiles.add(storage.createNestedBundleFile(versionPath, bundlefile, generation, BundleInfo.MULTI_RELEASE_FILTER_PREFIXES));
}
}
return Collections.unmodifiableList(mrBundleFiles);
}
use of org.eclipse.osgi.storage.bundlefile.BundleEntry in project rt.equinox.framework by eclipse.
the class Handler method findBundleEntry.
protected BundleEntry findBundleEntry(URL url, Module module) throws IOException {
ModuleRevision current = module.getCurrentRevision();
ModuleWiring wiring = current == null ? null : current.getWiring();
ModuleClassLoader classloader = (ModuleClassLoader) (current == null ? null : wiring.getClassLoader());
if (classloader == null)
throw new FileNotFoundException(url.getPath());
BundleEntry entry = classloader.getClasspathManager().findLocalEntry(url.getPath(), url.getPort());
if (entry == null) {
// this isn't strictly needed but is kept to maintain compatibility
entry = classloader.getClasspathManager().findLocalEntry(url.getPath());
}
if (entry == null) {
throw new FileNotFoundException(url.getPath());
}
return entry;
}
use of org.eclipse.osgi.storage.bundlefile.BundleEntry in project rt.equinox.framework by eclipse.
the class NativeCodeFinder method searchEclipseVariants.
private String searchEclipseVariants(String path) {
List<String> ECLIPSE_LIB_VARIANTS = generation.getBundleInfo().getStorage().getConfiguration().ECLIPSE_LIB_VARIANTS;
for (String variant : ECLIPSE_LIB_VARIANTS) {
BundleFile baseBundleFile = generation.getBundleFile();
BundleEntry libEntry = baseBundleFile.getEntry(variant + path);
if (libEntry != null) {
File libFile = baseBundleFile.getFile(variant + path, true);
if (libFile == null)
return null;
// see bug 88697 - HP requires libraries to have executable permissions
if (org.eclipse.osgi.service.environment.Constants.OS_HPUX.equals(generation.getBundleInfo().getStorage().getConfiguration().getOS())) {
try {
// use the string array method in case there is a space in the path
// $NON-NLS-1$ //$NON-NLS-2$
Runtime.getRuntime().exec(new String[] { "chmod", "755", libFile.getAbsolutePath() }).waitFor();
} catch (Exception e) {
e.printStackTrace();
}
}
return libFile.getAbsolutePath();
}
}
return null;
}
use of org.eclipse.osgi.storage.bundlefile.BundleEntry in project rt.equinox.framework by eclipse.
the class Storage method findInSystemBundle.
private InputStream findInSystemBundle(Generation systemGeneration, String entry) {
BundleFile systemContent = systemGeneration.getBundleFile();
BundleEntry systemEntry = systemContent != null ? systemContent.getEntry(entry) : null;
InputStream result = null;
if (systemEntry != null) {
try {
result = systemEntry.getInputStream();
} catch (IOException e) {
// Do nothing
}
}
if (result == null) {
// Check the ClassLoader in case we're launched off the Java boot classpath
ClassLoader loader = getClass().getClassLoader();
result = loader == null ? ClassLoader.getSystemResourceAsStream(entry) : loader.getResourceAsStream(entry);
}
return result;
}
Aggregations