diff --git a/org.eclipse.jdt.launching.macosx/macosx/org/eclipse/jdt/internal/launching/macosx/MacOSXVMInstallType.java b/org.eclipse.jdt.launching.macosx/macosx/org/eclipse/jdt/internal/launching/macosx/MacOSXVMInstallType.java index 0007690..2cf6540 100644 --- a/org.eclipse.jdt.launching.macosx/macosx/org/eclipse/jdt/internal/launching/macosx/MacOSXVMInstallType.java +++ b/org.eclipse.jdt.launching.macosx/macosx/org/eclipse/jdt/internal/launching/macosx/MacOSXVMInstallType.java @@ -61,7 +61,7 @@ * src.zip * * - * The directory structure for Snow Leopard and Lion VMs is: + * The directory structure for Snow Leopard and Lion VMs is: *
  * /System/Library/Java/JavaVirtualMachines/
  *   1.6.0.jdk/
@@ -84,6 +84,21 @@
 	private static final String JAVADOC_LOC= "/Developer/Documentation/Java/Reference/";	//$NON-NLS-1$
 	/** The doc for 1.4.1 is kept in a sub directory of the above. */ 
 	private static final String JAVADOC_SUBDIR= "/doc/api";	//$NON-NLS-1$
+	/**
+	 * The name of the src.zip file for the JDK source
+	 * @since 3.2.200
+	 */
+	static final String SRC_ZIP = "src.zip"; //$NON-NLS-1$
+	/**
+	 * The name of the source used for libraries on the Mac
+	 * @since 3.2.200
+	 */
+	static final String SRC_NAME = "src"; //$NON-NLS-1$
+	/**
+	 * The name of the Contents folder found within a JRE/JDK folder
+	 * @since 3.2.200
+	 */
+	static final String JVM_CONTENTS = "Contents"; //$NON-NLS-1$
 				
 	@Override
 	public String getName() {
@@ -147,18 +162,15 @@
 	 * @return file that points to the default JRE install
 	 */
 	private File detectInstallLocationOld() {
-		
 		String javaVMName= System.getProperty("java.vm.name");	//$NON-NLS-1$
 		if (javaVMName == null) {
 			return null;
 		}
-
 		if (!JVM_VERSIONS_FOLDER.exists() || !JVM_VERSIONS_FOLDER.isDirectory()) {
 			String message= NLS.bind(MacOSXLaunchingPlugin.getString("MacOSXVMType.error.jvmDirectoryNotFound"), JVM_VERSIONS_FOLDER);  //$NON-NLS-1$
 			LaunchingPlugin.log(message);
 			return null;
 		}
-
 		// find all installed VMs
 		File defaultLocation= null;
 		File[] versions= getAllVersionsOld();
@@ -232,6 +244,11 @@
 	 */
 	@Override
 	protected LibraryInfo getDefaultLibraryInfo(File installLocation) {
+		IPath rtjar = getDefaultSystemLibrary(installLocation);
+		if(rtjar.toFile().isFile()) {
+			//not a Mac OS VM, default to the standard VM type info collection
+			return super.getDefaultLibraryInfo(installLocation);
+		}
 		File classes = new File(installLocation, "../Classes"); //$NON-NLS-1$
 		File lib1= new File(classes, "classes.jar"); //$NON-NLS-1$
 		File lib2= new File(classes, "ui.jar"); //$NON-NLS-1$
@@ -261,21 +278,20 @@
 	 */
 	@Override
 	protected IPath getDefaultSystemLibrarySource(File libLocation) {
-		File parent= libLocation.getParentFile();
-		while (parent != null) {
-			File home= new File(parent, JVM_HOME);
-			File parentsrc= new File(home, "src.jar"); //$NON-NLS-1$
-			if (parentsrc.isFile()) {
-				setDefaultRootPath("src");//$NON-NLS-1$
-				return new Path(parentsrc.getPath());
-			}
-			parentsrc= new File(home, "src.zip"); //$NON-NLS-1$
-			if (parentsrc.isFile()) {
-				setDefaultRootPath(""); //$NON-NLS-1$
-				return new Path(parentsrc.getPath());
+		File parent = libLocation.getParentFile();
+		File src = null;
+		//walk the parent hierarchy, stop if we run out of parents or we hit the /Contents dir
+		while (parent != null && !JVM_CONTENTS.equals(parent.getName())) {
+			src = new File(parent, SRC_ZIP);
+			if (src.isFile()) {
+				setDefaultRootPath(SRC_NAME);
+				return new Path(src.getPath());
 			}
 			parent = parent.getParentFile();
 		}
+		//in very old VM cases ~1.3/1.4 the /Home dir is co-located to the /Classes dir
+		//should we add a fall-back case for this? those VMs cannot be installed on a Mac
+		//any longer
 		setDefaultRootPath(""); //$NON-NLS-1$
 		return Path.EMPTY;
 	}