Logo Search packages:      
Sourcecode: icedtea-web version File versions  Download package

void net::sourceforge::jnlp::runtime::JNLPClassLoader::activateJars ( final List  jars  )  [inline, protected]

Ensures that the list of jars have all been transferred, and makes them available to the classloader. If a jar contains native code, the libraries will be extracted and placed in the path.

jars the list of jars to load

Definition at line 628 of file JNLPClassLoader.java.

References acc, activateNative(), net::sourceforge::jnlp::tools::JarSigner::anyJarsSigned, available, file, net::sourceforge::jnlp::tools::JarSigner::getAlreadyTrustPublisher(), net::sourceforge::jnlp::cache::ResourceTracker::getCacheFile(), net::sourceforge::jnlp::JNLPFile::getCodeBase(), net::sourceforge::jnlp::JARDesc::getLocation(), net::sourceforge::jnlp::ResourcesDesc::getMainJAR(), net::sourceforge::jnlp::JNLPFile::getResources(), net::sourceforge::jnlp::JNLPFile::getSecurity(), jarEntries, jarIndexes, jarLocationSecurityMap, R(), tracker, net::sourceforge::jnlp::tools::JarSigner::verifyJar(), and waitForJars().

Referenced by addNextResource(), and initializeResources().

        PrivilegedAction activate = new PrivilegedAction() {

            public Object run() {
                // transfer the Jars

                for (int i=0; i < jars.size(); i++) {
                    JARDesc jar = (JARDesc) jars.get(i);


                    // add jar
                    File localFile = tracker.getCacheFile(jar.getLocation());
                    try {
                        URL location = jar.getLocation(); // non-cacheable, use source location
                        if (localFile != null) {
                            location = localFile.toURL(); // cached file

                            // This is really not the best way.. but we need some way for
                            // PluginAppletViewer::getCachedImageRef() to check if the image
                            // is available locally, and it cannot use getResources() because
                            // that prefetches the resource, which confuses MediaTracker.waitForAll()
                            // which does a wait(), waiting for notification (presumably
                            // thrown after a resource is fetched). This bug manifests itself
                            // particularly when using The FileManager applet from Webmin.

                            JarFile jarFile = new JarFile(localFile);
                            Enumeration e = jarFile.entries();
                            while (e.hasMoreElements()) {

                                JarEntry je = (JarEntry) e.nextElement();

                                // another jar in my jar? it is more likely than you think
                                if (je.getName().endsWith(".jar")) {
                                    // We need to extract that jar so that it can be loaded
                                    // (inline loading with "jar:..!/..." path will not work
                                    // with standard classloader methods)

                                    String extractedJarLocation = localFile.getParent() + "/" + je.getName();
                                    File parentDir = new File(extractedJarLocation).getParentFile();
                                    if (!parentDir.isDirectory() && !parentDir.mkdirs()) {
                                        throw new RuntimeException(R("RNestedJarExtration"));
                                    FileOutputStream extractedJar = new FileOutputStream(extractedJarLocation);
                                    InputStream is = jarFile.getInputStream(je);

                                    byte[] bytes = new byte[1024];
                                    int read = is.read(bytes);
                                    int fileSize = read;
                                    while (read > 0) {
                                        extractedJar.write(bytes, 0, read);
                                        read = is.read(bytes);
                                        fileSize += read;

                                    // 0 byte file? skip
                                    if (fileSize <= 0) {

                                    JarSigner signer = new JarSigner();

                                    if (signer.anyJarsSigned() && !signer.getAlreadyTrustPublisher()) {

                                    try {
                                        URL fileURL = new URL("file://" + extractedJarLocation);

                                        SecurityDesc jarSecurity = file.getSecurity();

                                        if (file instanceof PluginBridge) {

                                            URL codebase = null;

                                            if (file.getCodeBase() != null) {
                                                codebase = file.getCodeBase();
                                            } else {
                                                //Fixme: codebase should be the codebase of the Main Jar not
                                                //the location. Although, it still works in the current state.
                                                codebase = file.getResources().getMainJAR().getLocation();

                                            jarSecurity = new SecurityDesc(file,

                                        jarLocationSecurityMap.put(fileURL, jarSecurity);

                                     } catch (MalformedURLException mfue) {
                                        if (JNLPRuntime.isDebug())
                                            System.err.println("Unable to add extracted nested jar to classpath");





                        // there is currently no mechanism to cache files per
                        // instance.. so only index cached files
                        if (localFile != null) {
                            JarIndex index = JarIndex.getJarIndex(new JarFile(localFile.getAbsolutePath()), null);

                            if (index != null)

                        if (JNLPRuntime.isDebug())
                            System.err.println("Activate jar: "+location);
                    catch (Exception ex) {
                        if (JNLPRuntime.isDebug())

                    // some programs place a native library in any jar

                return null;

        AccessController.doPrivileged(activate, acc);

Generated by  Doxygen 1.6.0   Back to index