Bug 517514 - Eclipse shows phantom compile errors and pretends wrong
Java version would be in effect

Change-Id: Ibbfa6f2f46292f259e8492e3696986e664cea511
diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.java
index 70b12d9..8da9633 100644
--- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.java
+++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -215,6 +215,10 @@
 	public static String ProjectClasspathVariableResolver_2;
 	public static String ProjectClasspathVariableResolver_3;
 
+	public static String VMLogging_1;
+	public static String VMLogging_2;
+	public static String VMLogging_3;
+
 	static {
 		// load message values from bundle file
 		NLS.initializeMessages(BUNDLE_NAME, LaunchingMessages.class);
diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.properties b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.properties
index bf90615..6d7b9c3 100644
--- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.properties
+++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingMessages.properties
@@ -1,5 +1,5 @@
 ###############################################################################
-# Copyright (c) 2000, 2017 IBM Corporation and others.
+# Copyright (c) 2000, 2018 IBM Corporation and others.
 # All rights reserved. This program and the accompanying materials
 # are made available under the terms of the Eclipse Public License v1.0
 # which accompanies this distribution, and is available at
@@ -197,4 +197,7 @@
 VMDefinitionsContainer_9=Installed JRE of type ''{0}'' removed due to missing install path, name, and id.
 VMDefinitionsContainer_10=Installed JREs
 RunnerBootpathError=Xbootclasspath option have been removed as not supported beyond Java 8.
-RunnerBootpathPError=Xbootclasspath/p option have been removed as not supported beyond Java 8.
\ No newline at end of file
+RunnerBootpathPError=Xbootclasspath/p option have been removed as not supported beyond Java 8.
+VMLogging_1=Restoring vm library location:
+VMLogging_2=Creating Library with Java Install path:
+VMLogging_3=Default Install retrieved:
\ No newline at end of file
diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingPlugin.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingPlugin.java
index a738f22..bdc2ee4 100644
--- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingPlugin.java
+++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/internal/launching/LaunchingPlugin.java
@@ -424,6 +424,9 @@
 	 * @param info the library information, or <code>null</code> to remove
 	 */
 	public static void setLibraryInfo(String javaInstallPath, LibraryInfo info) {
+		if (isVMLogging()) {
+			LaunchingPlugin.log(LaunchingMessages.VMLogging_2 + javaInstallPath);
+		}
 		if (fgLibraryInfoMap == null) {
 			restoreLibraryInfo();
 		}
@@ -442,6 +445,11 @@
 		saveLibraryInfo();
 	}
 
+	public static boolean isVMLogging() {
+		String vmLogging = System.getProperty("jdt.debug.launching.vmLogging"); //$NON-NLS-1$
+		return "true".equalsIgnoreCase(vmLogging); //$NON-NLS-1$
+	}
+
 	/**
 	 * Return a <code>java.io.File</code> object that corresponds to the specified
 	 * <code>IPath</code> in the plug-in directory.
@@ -947,6 +955,9 @@
 							String[] extDirs = getPathsFromXML(element, "extensionDirs"); //$NON-NLS-1$
 							String[] endDirs = getPathsFromXML(element, "endorsedDirs"); //$NON-NLS-1$
 							if (location != null) {
+								if (isVMLogging()) {
+									LaunchingPlugin.log(LaunchingMessages.VMLogging_1 + location);
+								}
 								LibraryInfo info = new LibraryInfo(version, bootpath, extDirs, endDirs);
 								fgLibraryInfoMap.put(location, info);
 							}
diff --git a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java
index 0e7d06a..d9ca0f7 100644
--- a/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java
+++ b/org.eclipse.jdt.launching/launching/org/eclipse/jdt/launching/JavaRuntime.java
@@ -496,11 +496,15 @@
 	 * 			VM was set or when the default VM has been disposed.
 	 */
 	public static IVMInstall getDefaultVMInstall() {
+
 		IVMInstall install= getVMFromCompositeId(getDefaultVMId());
 		if (install != null) {
 			File location = install.getInstallLocation();
 			if (location != null) {
 				if (location.exists()) {
+					if (LaunchingPlugin.isVMLogging()) {
+						LaunchingPlugin.log(LaunchingMessages.VMLogging_3 + install.getInstallLocation());
+					}
 					return install;
 				}
 			}
@@ -514,7 +518,11 @@
 			fgVMTypes = null;
 			initializeVMs();
 		}
-		return getVMFromCompositeId(getDefaultVMId());
+		install = getVMFromCompositeId(getDefaultVMId());
+		if (LaunchingPlugin.isVMLogging()) {
+			LaunchingPlugin.log(LaunchingMessages.VMLogging_3 + install.getInstallLocation());
+		}
+		return install;
 	}
 
 	/**