Search in sources :

Example 6 with BundleEntry

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;
    }
}
Also used : IOException(java.io.IOException) BundleEntry(org.eclipse.osgi.storage.bundlefile.BundleEntry)

Example 7 with BundleEntry

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);
}
Also used : Storage(org.eclipse.osgi.storage.Storage) ArrayList(java.util.ArrayList) BundleFile(org.eclipse.osgi.storage.bundlefile.BundleFile) BundleEntry(org.eclipse.osgi.storage.bundlefile.BundleEntry)

Example 8 with BundleEntry

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;
}
Also used : ModuleClassLoader(org.eclipse.osgi.internal.loader.ModuleClassLoader) ModuleWiring(org.eclipse.osgi.container.ModuleWiring) FileNotFoundException(java.io.FileNotFoundException) ModuleRevision(org.eclipse.osgi.container.ModuleRevision) BundleEntry(org.eclipse.osgi.storage.bundlefile.BundleEntry)

Example 9 with BundleEntry

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;
}
Also used : BundleFile(org.eclipse.osgi.storage.bundlefile.BundleFile) File(java.io.File) BundleFile(org.eclipse.osgi.storage.bundlefile.BundleFile) BundleEntry(org.eclipse.osgi.storage.bundlefile.BundleEntry) InvalidSyntaxException(org.osgi.framework.InvalidSyntaxException)

Example 10 with BundleEntry

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;
}
Also used : BufferedInputStream(java.io.BufferedInputStream) ReferenceInputStream(org.eclipse.osgi.storage.url.reference.ReferenceInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) DataInputStream(java.io.DataInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) NestedDirBundleFile(org.eclipse.osgi.storage.bundlefile.NestedDirBundleFile) ZipBundleFile(org.eclipse.osgi.storage.bundlefile.ZipBundleFile) DirBundleFile(org.eclipse.osgi.storage.bundlefile.DirBundleFile) BundleFile(org.eclipse.osgi.storage.bundlefile.BundleFile) BundleEntry(org.eclipse.osgi.storage.bundlefile.BundleEntry)

Aggregations

BundleEntry (org.eclipse.osgi.storage.bundlefile.BundleEntry)11 BundleFile (org.eclipse.osgi.storage.bundlefile.BundleFile)5 IOException (java.io.IOException)3 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 ModuleRevision (org.eclipse.osgi.container.ModuleRevision)2 BufferedInputStream (java.io.BufferedInputStream)1 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DataInputStream (java.io.DataInputStream)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 Certificate (java.security.cert.Certificate)1 ArrayList (java.util.ArrayList)1 ModuleWiring (org.eclipse.osgi.container.ModuleWiring)1 FrameworkLogEntry (org.eclipse.osgi.framework.log.FrameworkLogEntry)1 ModuleClassLoader (org.eclipse.osgi.internal.loader.ModuleClassLoader)1 SignerInfo (org.eclipse.osgi.signedcontent.SignerInfo)1 BundleInfo (org.eclipse.osgi.storage.BundleInfo)1