~ubuntu-branches/ubuntu/precise/icedtea-web/precise

« back to all changes in this revision

Viewing changes to netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-03-03 12:35:35 UTC
  • mfrom: (1.1.18)
  • Revision ID: package-import@ubuntu.com-20120303123535-k0jedudh4q66tqkq
Tags: 1.2~pre3-1ubuntu1
Regenerate the control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
593
593
            mainClass = ad.getMainClass();
594
594
        } else
595
595
            return;
 
596
 
 
597
        // The main class may be specified in the manifest
 
598
 
 
599
        // Check main jar
 
600
        if (mainClass == null) {
 
601
            JARDesc mainJarDesc = file.getResources().getMainJAR();
 
602
            mainClass = getMainClassName(mainJarDesc.getLocation());
 
603
        }
 
604
 
 
605
        // Check first jar
 
606
        if (mainClass == null) {
 
607
            JARDesc firstJarDesc = jars.get(0);
 
608
            mainClass = getMainClassName(firstJarDesc.getLocation());
 
609
        }
 
610
 
 
611
        // Still not found? Iterate and set if only 1 was found
 
612
        if (mainClass == null) {
 
613
 
 
614
            for (JARDesc jarDesc: jars) {
 
615
                String mainClassInThisJar = getMainClassName(jarDesc.getLocation());
 
616
 
 
617
                if (mainClassInThisJar != null) {
 
618
 
 
619
                    if (mainClass == null) { // first main class
 
620
                        mainClass = mainClassInThisJar;
 
621
                    } else { // There is more than one main class. Set to null and break.
 
622
                        mainClass = null;
 
623
                        break;
 
624
                    }
 
625
                }
 
626
            }
 
627
        }
 
628
 
596
629
        String desiredJarEntryName = mainClass + ".class";
597
630
 
598
631
        for (int i = 0; i < jars.size(); i++) {
630
663
    }
631
664
 
632
665
    /**
 
666
     * Gets the name of the main method if specified in the manifest
 
667
     *
 
668
     * @param location The JAR location
 
669
     * @return the main class name, null if there isn't one of if there was an error
 
670
     */
 
671
    private String getMainClassName(URL location) {
 
672
 
 
673
        String mainClass = null;
 
674
        File f = tracker.getCacheFile(location);
 
675
 
 
676
        if( f != null) {
 
677
            try {
 
678
                JarFile mainJar = new JarFile(f);
 
679
                mainClass = mainJar.getManifest().
 
680
                        getMainAttributes().getValue("Main-Class");
 
681
            } catch (IOException ioe) {
 
682
                mainClass = null;
 
683
            }
 
684
        }
 
685
 
 
686
        return mainClass;
 
687
    }
 
688
 
 
689
    /**
633
690
     * Is called by checkForMain() to check if the jar file is signed and if it
634
691
     * contains a signed JNLP file.
635
692
     *