Merge "[501802] ensure null-safety"
diff --git a/features/org.eclipse.jst.common.fproj.enablement.jdt.feature/feature.xml b/features/org.eclipse.jst.common.fproj.enablement.jdt.feature/feature.xml
index 737695a..841c9fc 100644
--- a/features/org.eclipse.jst.common.fproj.enablement.jdt.feature/feature.xml
+++ b/features/org.eclipse.jst.common.fproj.enablement.jdt.feature/feature.xml
@@ -1,37 +1,37 @@
-<?xml version="1.0" encoding="UTF-8"?>

-<feature

-      id="org.eclipse.jst.common.fproj.enablement.jdt"

-      label="%featureName"

-      version="3.9.1.qualifier"

-      provider-name="%providerName"

-      plugin="org.eclipse.jst.common.project.facet.core"

-      license-feature="org.eclipse.license"

-      license-feature-version="1.0.1.qualifier">

-

-   <description>

-      %description

-   </description>

-

-   <copyright>

-      %copyright

-   </copyright>

-

-   <license url="%licenseURL">

-      %license

-   </license>

-

-   <plugin

-         id="org.eclipse.jst.common.project.facet.core"

-         download-size="0"

-         install-size="0"

-         version="0.0.0"

-         unpack="false"/>

-

-   <plugin

-         id="org.eclipse.jst.common.project.facet.ui"

-         download-size="0"

-         install-size="0"

-         version="0.0.0"

-         unpack="false"/>

-

-</feature>

+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+      id="org.eclipse.jst.common.fproj.enablement.jdt"
+      label="%featureName"
+      version="3.10.0.qualifier"
+      provider-name="%providerName"
+      plugin="org.eclipse.jst.common.project.facet.core"
+      license-feature="org.eclipse.license"
+      license-feature-version="1.0.1.qualifier">
+
+   <description>
+      %description
+   </description>
+
+   <copyright>
+      %copyright
+   </copyright>
+
+   <license url="%licenseURL">
+      %license
+   </license>
+
+   <plugin
+         id="org.eclipse.jst.common.project.facet.core"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.eclipse.jst.common.project.facet.ui"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+</feature>
diff --git a/features/org.eclipse.jst.common.fproj.enablement.jdt.feature/pom.xml b/features/org.eclipse.jst.common.fproj.enablement.jdt.feature/pom.xml
index 1f005b9..2dc1429 100644
--- a/features/org.eclipse.jst.common.fproj.enablement.jdt.feature/pom.xml
+++ b/features/org.eclipse.jst.common.fproj.enablement.jdt.feature/pom.xml
@@ -21,6 +21,6 @@
 

   <groupId>org.eclipse.webtools.common</groupId>

   <artifactId>org.eclipse.jst.common.fproj.enablement.jdt</artifactId>

-  <version>3.9.1-SNAPSHOT</version>

+  <version>3.10.0-SNAPSHOT</version>

   <packaging>eclipse-feature</packaging>

 </project>
diff --git a/plugins/org.eclipse.jst.common.project.facet.core/META-INF/MANIFEST.MF b/plugins/org.eclipse.jst.common.project.facet.core/META-INF/MANIFEST.MF
index c133d48..f5e2b60 100644
--- a/plugins/org.eclipse.jst.common.project.facet.core/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.jst.common.project.facet.core/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@
 Bundle-Vendor: %providerName
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.jst.common.project.facet.core; singleton:=true
-Bundle-Version: 1.5.0.qualifier
+Bundle-Version: 1.6.0.qualifier
 Bundle-ClassPath: .
 Bundle-Localization: plugin
 Export-Package: org.eclipse.jst.common.project.facet.core,
diff --git a/plugins/org.eclipse.jst.common.project.facet.core/plugin.xml b/plugins/org.eclipse.jst.common.project.facet.core/plugin.xml
index 5768ccf..fbfbbd8 100644
--- a/plugins/org.eclipse.jst.common.project.facet.core/plugin.xml
+++ b/plugins/org.eclipse.jst.common.project.facet.core/plugin.xml
@@ -27,6 +27,7 @@
     <runtime-component-version type="standard.jre" version="1.7"/>
     <runtime-component-version type="standard.jre" version="1.8"/>
     <runtime-component-version type="standard.jre" version="9"/>
+    <runtime-component-version type="standard.jre" version="10"/>
 
     <supported>
       <facet id="java" version="1.3"/>
@@ -62,6 +63,11 @@
       <facet id="java" version="9"/>
       <runtime-component id="standard.jre" version="[9"/>
     </supported>
+    
+    <supported>
+      <facet id="java" version="10"/>
+      <runtime-component id="standard.jre" version="[10"/>
+    </supported>
 
     <adapter>
       <runtime-component id="standard.jre"/>
@@ -92,6 +98,8 @@
     <project-facet-version facet="java" version="1.8"/>
 
     <project-facet-version facet="java" version="9"/>
+    
+    <project-facet-version facet="java" version="10"/>
 
     <action facet="java" type="install" id="java.install">
       <delegate class="org.eclipse.jst.common.project.facet.core.internal.JavaFacetInstallDelegate"/>
diff --git a/plugins/org.eclipse.jst.common.project.facet.core/pom.xml b/plugins/org.eclipse.jst.common.project.facet.core/pom.xml
index 0fdfd81..9cb4838 100644
--- a/plugins/org.eclipse.jst.common.project.facet.core/pom.xml
+++ b/plugins/org.eclipse.jst.common.project.facet.core/pom.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>

 <!--

-  Copyright (c) 2012, 2017 Eclipse Foundation and others.

+  Copyright (c) 2012, 2018 Eclipse Foundation and others.

   All rights reserved. This program and the accompanying materials

   are made available under the terms of the Eclipse Distribution License v1.0

   which accompanies this distribution, and is available at

@@ -21,6 +21,6 @@
 

   <groupId>org.eclipse.webtools.common</groupId>

   <artifactId>org.eclipse.jst.common.project.facet.core</artifactId>

-  <version>1.5.0-SNAPSHOT</version>

+  <version>1.6.0-SNAPSHOT</version>

   <packaging>eclipse-plugin</packaging>

 </project>
diff --git a/plugins/org.eclipse.jst.common.project.facet.core/src/org/eclipse/jst/common/project/facet/core/JavaFacet.java b/plugins/org.eclipse.jst.common.project.facet.core/src/org/eclipse/jst/common/project/facet/core/JavaFacet.java
index 9a68c08..c0e4a6b 100644
--- a/plugins/org.eclipse.jst.common.project.facet.core/src/org/eclipse/jst/common/project/facet/core/JavaFacet.java
+++ b/plugins/org.eclipse.jst.common.project.facet.core/src/org/eclipse/jst/common/project/facet/core/JavaFacet.java
@@ -1,5 +1,5 @@
 /******************************************************************************
- * Copyright (c) 2010, 2017 Oracle
+ * Copyright (c) 2010, 2018 Oracle
  * 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
@@ -8,6 +8,7 @@
  * Contributors:
  *    Konstantin Komissarchik - initial implementation and ongoing maintenance
  *    Carl Anderson - Java 9 support
+ *    John Collier - Java 10 support
  ******************************************************************************/
 
 package org.eclipse.jst.common.project.facet.core;
@@ -36,6 +37,7 @@
     public static final IProjectFacetVersion VERSION_1_7 = FACET.getVersion( "1.7" ); //$NON-NLS-1$
     public static final IProjectFacetVersion VERSION_1_8 = FACET.getVersion( "1.8" ); //$NON-NLS-1$
     public static final IProjectFacetVersion VERSION_9 = FACET.getVersion( "9" ); //$NON-NLS-1$
+    public static final IProjectFacetVersion VERSION_10 = FACET.getVersion( "10" ); //$NON-NLS-1$
 
     @Deprecated
     public static final IProjectFacetVersion JAVA_13 = VERSION_1_3;
diff --git a/plugins/org.eclipse.jst.common.project.facet.core/src/org/eclipse/jst/common/project/facet/core/StandardJreRuntimeComponent.java b/plugins/org.eclipse.jst.common.project.facet.core/src/org/eclipse/jst/common/project/facet/core/StandardJreRuntimeComponent.java
index 8e228bb..924e73c 100644
--- a/plugins/org.eclipse.jst.common.project.facet.core/src/org/eclipse/jst/common/project/facet/core/StandardJreRuntimeComponent.java
+++ b/plugins/org.eclipse.jst.common.project.facet.core/src/org/eclipse/jst/common/project/facet/core/StandardJreRuntimeComponent.java
@@ -1,5 +1,5 @@
 /******************************************************************************
- * Copyright (c) 2010, 2017 Oracle
+ * Copyright (c) 2010, 2018 Oracle
  * 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
@@ -8,6 +8,7 @@
  * Contributors:
  *    Konstantin Komissarchik - initial implementation and ongoing maintenance
  *    Carl Anderson - Java 9 support
+ *    John Collier - Java 10 support
  ******************************************************************************/
 
 package org.eclipse.jst.common.project.facet.core;
@@ -37,6 +38,7 @@
     public static final IRuntimeComponentVersion VERSION_1_7 = TYPE.getVersion( "1.7" ); //$NON-NLS-1$
     public static final IRuntimeComponentVersion VERSION_1_8 = TYPE.getVersion( "1.8" ); //$NON-NLS-1$
     public static final IRuntimeComponentVersion VERSION_9 = TYPE.getVersion( "9" ); //$NON-NLS-1$
+    public static final IRuntimeComponentVersion VERSION_10 = TYPE.getVersion( "10" ); //$NON-NLS-1$
 
     @Deprecated
     public static final IRuntimeComponentVersion VERSION_5_0 = VERSION_1_5;
@@ -91,9 +93,13 @@
         {
             rcv = StandardJreRuntimeComponent.VERSION_9;
         }
+        else if( jvmver.startsWith( "10" ) ) //$NON-NLS-1$
+        {
+            rcv = StandardJreRuntimeComponent.VERSION_10;
+        }
         else 
         {
-            rcv = StandardJreRuntimeComponent.VERSION_9;
+            rcv = StandardJreRuntimeComponent.VERSION_10;
         }
         
         final Map<String,String> properties = new HashMap<String,String>();
diff --git a/plugins/org.eclipse.jst.common.project.facet.core/src/org/eclipse/jst/common/project/facet/core/internal/JavaFacetUtil.java b/plugins/org.eclipse.jst.common.project.facet.core/src/org/eclipse/jst/common/project/facet/core/internal/JavaFacetUtil.java
index 6c66597..7a3c7ba 100644
--- a/plugins/org.eclipse.jst.common.project.facet.core/src/org/eclipse/jst/common/project/facet/core/internal/JavaFacetUtil.java
+++ b/plugins/org.eclipse.jst.common.project.facet.core/src/org/eclipse/jst/common/project/facet/core/internal/JavaFacetUtil.java
@@ -1,5 +1,5 @@
 /******************************************************************************
- * Copyright (c) 2010, 2017 Oracle
+ * Copyright (c) 2010, 2018 Oracle
  * 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
@@ -8,6 +8,7 @@
  * Contributors:
  *    Konstantin Komissarchik - initial implementation and ongoing maintenance
  *    Carl Anderson - Java 9 support
+ *    John Collier - Java 10 support
  ******************************************************************************/
 
 package org.eclipse.jst.common.project.facet.core.internal;
@@ -63,6 +64,7 @@
         FACET_VER_TO_EXEC_ENV.put( JavaFacet.VERSION_1_7, "JavaSE-1.7" ); //$NON-NLS-1$
         FACET_VER_TO_EXEC_ENV.put( JavaFacet.VERSION_1_8, "JavaSE-1.8" ); //$NON-NLS-1$
         FACET_VER_TO_EXEC_ENV.put( JavaFacet.VERSION_9, "JavaSE-9" ); //$NON-NLS-1$
+        FACET_VER_TO_EXEC_ENV.put( JavaFacet.VERSION_10, "JavaSE-10" ); //$NON-NLS-1$
     }
     
     public static String getCompilerLevel()
diff --git a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualFolder.java b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualFolder.java
index 0753a61..dd1a12e 100644
--- a/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualFolder.java
+++ b/plugins/org.eclipse.wst.common.modulecore/modulecore-src/org/eclipse/wst/common/componentcore/internal/resources/VirtualFolder.java
@@ -178,32 +178,30 @@
 	}
 
 	public IPath getFirstTaggedResource(String tag) {
-		WorkbenchComponent aComponent = null;
-		IPath path = null;
-		
-		aComponent = getReadOnlyComponent();
-		ComponentResource[] resources = aComponent.findResourcesByRuntimePath(getRuntimePath());
-		for (ComponentResource resource:resources){
-			if (tag.equals(resource.getTag())){
-				path = resource.getSourcePath();
-				break;
-			}
-		}		
-		return path;
+		List<IPath> paths = internalGetTaggedResources(tag, true);
+		return !paths.isEmpty() ? paths.get(0) : null;
 	}
 
 	public IPath[] getTaggedResources(String tag) {
+		return internalGetTaggedResources(tag, false).toArray(new IPath[0]);
+	}
+	
+	private List<IPath> internalGetTaggedResources (String tag, boolean firstOnly) {
 		WorkbenchComponent aComponent = null;
 		List<IPath> paths = new ArrayList<IPath>();
 		
 		aComponent = getReadOnlyComponent();
-		ComponentResource[] resources = aComponent.findResourcesByRuntimePath(getRuntimePath());
-		for (ComponentResource resource:resources){
-			if (tag.equals(resource.getTag())){
-				paths.add(resource.getSourcePath());
+		if (aComponent != null) {
+			ComponentResource[] resources = aComponent.findResourcesByRuntimePath(getRuntimePath());
+			for (ComponentResource resource:resources){
+				if (tag.equals(resource.getTag())){
+					paths.add(resource.getSourcePath());
+					if (firstOnly)
+						break;
+				}
 			}
-		}		
-		return paths.toArray(new IPath[0]);
+		}
+		return paths;
 	}
 
 }