View | Details | Raw Unified | Return to bug 195509 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/util/Util.java (-47 / +74 lines)
Lines 639-685 Link Here
639
 * Example of use: [org.eclipse.jdt.core.tests.util.Util.getJavaClassLib()]
639
 * Example of use: [org.eclipse.jdt.core.tests.util.Util.getJavaClassLib()]
640
*/
640
*/
641
public static String[] getJavaClassLibs() {
641
public static String[] getJavaClassLibs() {
642
    String jreDir = getJREDirectory();
642
	// check bootclasspath properties for Sun, JRockit and Harmony VMs
643
    final String osName = System.getProperty("os.name");
643
	String bootclasspathProperty = System.getProperty("sun.boot.class.path"); //$NON-NLS-1$
644
    if (jreDir == null) {
644
	if ((bootclasspathProperty == null) || (bootclasspathProperty.length() == 0)) {
645
        return new String[] {};
645
		// IBM J9 VMs
646
    }
646
		bootclasspathProperty = System.getProperty("vm.boot.class.path"); //$NON-NLS-1$
647
    if (osName.startsWith("Mac")) {
647
		if ((bootclasspathProperty == null) || (bootclasspathProperty.length() == 0)) {
648
        return new String[] {
648
			// Harmony using IBM VME
649
            toNativePath(jreDir + "/../Classes/classes.jar")
649
			bootclasspathProperty = System.getProperty("org.apache.harmony.boot.class.path"); //$NON-NLS-1$
650
        };
650
		}
651
    }
651
	}
652
    final String vmName = System.getProperty("java.vm.name");
652
	String[] jars = null;
653
    if ("J9".equals(vmName)) {
653
	if ((bootclasspathProperty != null) && (bootclasspathProperty.length() != 0)) {
654
        return new String[] {
654
		StringTokenizer tokenizer = new StringTokenizer(bootclasspathProperty, File.pathSeparator);
655
            toNativePath(jreDir + "/lib/jclMax/classes.zip")
655
		final int size = tokenizer.countTokens();
656
        };
656
		jars = new String[size];
657
    }
657
		int i = 0;
658
	if ("DRLVM".equals(vmName)) {
658
		while (tokenizer.hasMoreTokens()) {
659
		FilenameFilter jarFilter = new FilenameFilter() {
659
			final String fileName = toNativePath(tokenizer.nextToken());
660
			public boolean accept(File dir, String name) {
660
			if (new File(fileName).exists()) {
661
				return name.endsWith(".jar") & !name.endsWith("-src.jar");
661
				jars[i] = fileName;
662
				i++;
662
			}
663
			}
663
		};
664
		String[] jars = new File(jreDir + "/lib/boot/").list(jarFilter);
665
		for (int i = 0; i < jars.length; i++) {
666
			jars[i] = toNativePath(jreDir + "/lib/boot/" + jars[i]);
667
		}
664
		}
668
		return jars;
665
		if (size != i) {
666
			// resize
667
			System.arraycopy(jars, 0, (jars = new String[i]), 0, i);
668
		}
669
	} else {
670
		String jreDir = getJREDirectory();
671
		final String osName = System.getProperty("os.name");
672
		if (jreDir == null) {
673
			return new String[] {};
674
		}
675
		if (osName.startsWith("Mac")) {
676
			return new String[] {
677
					toNativePath(jreDir + "/../Classes/classes.jar")
678
			};
679
		}
680
		final String vmName = System.getProperty("java.vm.name");
681
		if ("J9".equals(vmName)) {
682
			return new String[] {
683
					toNativePath(jreDir + "/lib/jclMax/classes.zip")
684
			};
685
		}
686
		String[] jarsNames = null;
687
		ArrayList paths = new ArrayList();
688
		if ("DRLVM".equals(vmName)) {
689
			FilenameFilter jarFilter = new FilenameFilter() {
690
				public boolean accept(File dir, String name) {
691
					return name.endsWith(".jar") & !name.endsWith("-src.jar");
692
				}
693
			};
694
			jarsNames = new File(jreDir + "/lib/boot/").list(jarFilter);
695
			addJarEntries(jreDir + "/lib/boot/", jarsNames, paths);
696
		} else {
697
			jarsNames = new String[] {
698
					"/lib/vm.jar",
699
					"/lib/rt.jar",
700
					"/lib/core.jar",
701
					"/lib/security.jar",
702
					"/lib/xml.jar",
703
					"/lib/graphics.jar"
704
			};
705
			addJarEntries(jreDir, jarsNames, paths);
706
		}
707
		jars = new String[paths.size()];
708
		paths.toArray(jars);
669
	}
709
	}
670
    ArrayList paths = new ArrayList();
710
	return jars;
671
    String[] jarsNames = new String[] {
672
    		"/lib/vm.jar",
673
    		"/lib/rt.jar",
674
    		"/lib/core.jar",
675
    		"/lib/security.jar",
676
    		"/lib/xml.jar",
677
    		"/lib/graphics.jar"
678
    };
679
    addJarEntries(jreDir, jarsNames, paths);
680
    String[] result = new String[paths.size()];
681
    paths.toArray(result);
682
    return result;
683
}
711
}
684
private static void addJarEntries(String jreDir, String[] jarNames, ArrayList paths) {
712
private static void addJarEntries(String jreDir, String[] jarNames, ArrayList paths) {
685
	for (int i = 0, max = jarNames.length; i < max; i++) {
713
	for (int i = 0, max = jarNames.length; i < max; i++) {
Lines 691-705 Link Here
691
	}
719
	}
692
}
720
}
693
public static String getJavaClassLibsAsString() {
721
public static String getJavaClassLibsAsString() {
694
    String[] classLibs = getJavaClassLibs();
722
	String[] classLibs = getJavaClassLibs();
695
    StringBuffer buffer = new StringBuffer();
723
	StringBuffer buffer = new StringBuffer();
696
    for (int i = 0, max = classLibs.length; i < max; i++) {
724
	for (int i = 0, max = classLibs.length; i < max; i++) {
697
        buffer
725
		buffer
698
            .append(classLibs[i])
726
		.append(classLibs[i])
699
            .append(File.pathSeparatorChar);
727
		.append(File.pathSeparatorChar);
700
728
	}
701
    }
729
	return buffer.toString();
702
    return buffer.toString();
703
}
730
}
704
/**
731
/**
705
 * Returns the JRE directory this tests are running on.
732
 * Returns the JRE directory this tests are running on.

Return to bug 195509