Bug 500144 - More compiler warnings by default in o.e.help 

Enabld the following warnings and fix them:
* empty statement
* indirect static access
* try-with-resources not used
* raw types usage
* few others for which the codebase was already clean

Change-Id: I24e50a01af56f098bc2228b62eec0ac98a98d48d
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/org.eclipse.help/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.help/.settings/org.eclipse.jdt.core.prefs
index 8e317e6..91a0680 100644
--- a/org.eclipse.help/.settings/org.eclipse.jdt.core.prefs
+++ b/org.eclipse.help/.settings/org.eclipse.jdt.core.prefs
@@ -9,8 +9,13 @@
 org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
 org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
 org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
 org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
 org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
@@ -20,9 +25,9 @@
 org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
 org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
 org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
 org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
+org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
 org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
 org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
 org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
@@ -33,14 +38,14 @@
 org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
 org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
 org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
 org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
 org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
 org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
 org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
 org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
 org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
 org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
 org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
@@ -48,20 +53,22 @@
 org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
 org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=error
 org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
+org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
 org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
 org.eclipse.jdt.core.compiler.problem.nullReference=ignore
 org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
 org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
 org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
 org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning
 org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
 org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
 org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
 org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
 org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
+org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning
+org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
 org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
 org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
 org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
@@ -79,9 +86,9 @@
 org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
 org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
 org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=disabled
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=disabled
 org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
 org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
 org.eclipse.jdt.core.compiler.problem.unusedImport=error
@@ -93,7 +100,7 @@
 org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
 org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
 org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=warning
 org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
 org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
 org.eclipse.jdt.core.compiler.source=1.8
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/CachedEntityResolver.java b/org.eclipse.help/src/org/eclipse/help/internal/CachedEntityResolver.java
index da40d3f..ac10bab 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/CachedEntityResolver.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/CachedEntityResolver.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2007, 2015 IBM Corporation and others.
+ * Copyright (c) 2007, 2016 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
@@ -42,20 +42,18 @@
         	if (!cachedCopy.exists()) {
 				try {
 					URL system = new URL(systemId);
-			        URLConnection sc = system.openConnection();
-			        BufferedReader in = new BufferedReader(
-			                                new InputStreamReader(
-			                                sc.getInputStream()));
-			        String inputLine;
-			        BufferedWriter out = new BufferedWriter(new FileWriter(cachedCopy));
-			        while ((inputLine = in.readLine()) != null) {
-			            out.write(inputLine);
-			        	out.newLine();
-			        }
-			        in.close();
-			        out.flush();
-			        out.close();
-				} catch (IOException e) {}
+					URLConnection sc = system.openConnection();
+					String inputLine;
+					try (BufferedReader in = new BufferedReader(new InputStreamReader(sc.getInputStream()));
+							BufferedWriter out = new BufferedWriter(new FileWriter(cachedCopy))) {
+						while ((inputLine = in.readLine()) != null) {
+							out.write(inputLine);
+							out.newLine();
+						}
+						out.flush();
+					}
+				} catch (IOException e) {
+				}
         	}
 	        try {
 	        	InputSource is = new InputSource(new FileReader(cachedCopy));
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/UAElementFactory.java b/org.eclipse.help/src/org/eclipse/help/internal/UAElementFactory.java
index a5a5455..838f153 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/UAElementFactory.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/UAElementFactory.java
@@ -52,7 +52,7 @@
  */
 public class UAElementFactory {
 
-	private static final Class[][] interfaceTable = new Class[][] {
+	private static final Class<?>[][] interfaceTable = new Class[][] {
 		{ ITopic.class, Topic.class },
 		{ IIndexEntry.class, IndexEntry.class },
 		{ IContext.class, Context.class },
@@ -71,10 +71,10 @@
 		{ ICriterionValueDefinition.class, CriterionValueDefinition.class },
 	};
 
-	private static final Map<String, Class> classByElementName;
+	private static final Map<String, Class<?>> classByElementName;
 
 	static {
-		classByElementName = Collections.synchronizedMap(new HashMap<String, Class>());
+		classByElementName = Collections.synchronizedMap(new HashMap<String, Class<?>>());
 		classByElementName.put(Anchor.NAME, Anchor.class);
 		classByElementName.put(Include.NAME, Include.class);
 		classByElementName.put(Toc.NAME, Toc.class);
@@ -118,7 +118,7 @@
 			Class<?> clazz = interfaceTable[i][1];
 			if (interfaze.isAssignableFrom(src.getClass())) {
 				try {
-					Constructor constructor = clazz.getConstructor(interfaze);
+					Constructor<?> constructor = clazz.getConstructor(interfaze);
 					return (UAElement) constructor.newInstance(src);
 				}
 				catch (Exception e) {
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/context/ContextFileProvider.java b/org.eclipse.help/src/org/eclipse/help/internal/context/ContextFileProvider.java
index bfcddd4..ed7aed0 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/context/ContextFileProvider.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/context/ContextFileProvider.java
@@ -192,21 +192,14 @@
 	 * (shortContextId -> Context).
 	 */
 	private Map<String, Context> loadContexts(ContextFile descriptor, String locale) {
-		try {
-			// load the file
-			InputStream in = ResourceLocator.openFromPlugin(descriptor.getBundleId(), descriptor.getFile(), locale);
+		// load the file
+		try (InputStream in = ResourceLocator.openFromPlugin(descriptor.getBundleId(), descriptor.getFile(), locale)) {
 	    	if (in != null) {
-				try {
-					return loadContextsFromInputStream(descriptor, locale, in);
-				} finally {
-					in.close();
-				}
-	    	}
-	    	else {
+				return loadContextsFromInputStream(descriptor, locale, in);
+			} else {
 	    		throw new FileNotFoundException();
 	    	}
-		}
-		catch (Throwable t) {
+		} catch (Throwable t) {
 			String msg = "Error reading context-sensitive help file /\"" + getErrorPath(descriptor, locale) + "\" (skipping file)"; //$NON-NLS-1$ //$NON-NLS-2$
 			HelpPlugin.logError(msg, t);
 		}
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/context/ContextManager.java b/org.eclipse.help/src/org/eclipse/help/internal/context/ContextManager.java
index f4f5434..6863c5f 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/context/ContextManager.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/context/ContextManager.java
@@ -58,9 +58,9 @@
 		int index = contextId.lastIndexOf('.');
 		if (index != -1) {
 			String pluginId = contextId.substring(0, index);
-			Iterator iter = getContextProviders(pluginId).iterator();
+			Iterator<AbstractContextProvider> iter = getContextProviders(pluginId).iterator();
 			while (iter.hasNext()) {
-				AbstractContextProvider provider = (AbstractContextProvider)iter.next();
+				AbstractContextProvider provider = iter.next();
 				try {
 					IContext context = provider.getContext(contextId, locale);
 					if (context != null) {
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/dynamic/ExtensionHandler.java b/org.eclipse.help/src/org/eclipse/help/internal/dynamic/ExtensionHandler.java
index f310d38..a9684d3 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/dynamic/ExtensionHandler.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/dynamic/ExtensionHandler.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2006, 2015 IBM Corporation and others.
+ * Copyright (c) 2006, 2016 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
@@ -10,10 +10,10 @@
  *******************************************************************************/
 package org.eclipse.help.internal.dynamic;
 
+import org.eclipse.help.IContentExtension;
 import org.eclipse.help.internal.Anchor;
 import org.eclipse.help.internal.UAElement;
 import org.eclipse.help.internal.UAElementFactory;
-import org.eclipse.help.internal.extension.ContentExtension;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
@@ -41,10 +41,10 @@
 	@Override
 	public short handle(UAElement element, String path) {
 		if (element instanceof Anchor) {
-			return handleExtension(element, path, ContentExtension.CONTRIBUTION);
+			return handleExtension(element, path, IContentExtension.CONTRIBUTION);
 		}
 		if (element.getAttribute(ATTRIBUTE_ID) != null) {
-			return handleExtension(element, path, ContentExtension.REPLACEMENT);
+			return handleExtension(element, path, IContentExtension.REPLACEMENT);
 		}
 		return UNHANDLED;
 	}
@@ -80,7 +80,7 @@
 			}
 		}
 		// always remove anchors, even invalid ones
-		if (type == ContentExtension.CONTRIBUTION) {
+		if (type == IContentExtension.CONTRIBUTION) {
 			uaElement.getParentElement().removeChild(uaElement);
 			return HANDLED_SKIP;
 		}
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/dynamic/ExtensionResolver.java b/org.eclipse.help/src/org/eclipse/help/internal/dynamic/ExtensionResolver.java
index be9e6c9..3ef57ce 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/dynamic/ExtensionResolver.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/dynamic/ExtensionResolver.java
@@ -128,8 +128,7 @@
 	 */
 	private Node[] getContent(String bundleId, String relativePath, String nodeId) throws IOException, SAXException, ParserConfigurationException {
 		String href = '/' + bundleId + '/' + relativePath;
-		InputStream in = HelpSystem.getHelpContent(href, locale);
-		try {
+		try (InputStream in = HelpSystem.getHelpContent(href, locale)) {
 			if (nodeId != null) {
 				Element element = findElement(in, nodeId);
 				processor.process(new UAElement(element), href);
@@ -147,12 +146,6 @@
 			}
 			return children.toArray(new Node[children.size()]);
 		}
-		finally {
-			try {
-				in.close();
-			}
-			catch (IOException e) {}
-		}
 	}
 
 	/*
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/dynamic/IncludeResolver.java b/org.eclipse.help/src/org/eclipse/help/internal/dynamic/IncludeResolver.java
index 5826ed4..5a53f1f 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/dynamic/IncludeResolver.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/dynamic/IncludeResolver.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2006, 2015 IBM Corporation and others.
+ * Copyright (c) 2006, 2016 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
@@ -43,18 +43,11 @@
 	 */
 	public UAElement resolve(String bundleId, String relativePath, String elementId) throws IOException, SAXException, ParserConfigurationException {
 		String href = '/' + bundleId + '/' + relativePath;
-		InputStream in = HelpSystem.getHelpContent(href, locale);
-		try {
+		try (InputStream in = HelpSystem.getHelpContent(href, locale)) {
 			UAElement element = findElement(in, elementId);
 			processor.process(element, href);
 			return element;
 		}
-		finally {
-			try {
-				in.close();
-			}
-			catch (IOException e) {}
-		}
 	}
 
 	/*
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/dynamic/ValidationHandler.java b/org.eclipse.help/src/org/eclipse/help/internal/dynamic/ValidationHandler.java
index cc67509..4a4739f 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/dynamic/ValidationHandler.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/dynamic/ValidationHandler.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2006, 2015 IBM Corporation and others.
+ * Copyright (c) 2006, 2016 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
@@ -22,14 +22,14 @@
  */
 public class ValidationHandler extends ProcessorHandler {
 
-	private Map requiredAttributes;
-	private Map deprecatedElements;
+	private Map<String, String[]> requiredAttributes;
+	private Map<String, String> deprecatedElements;
 
 	/*
 	 * Creates a new validator that looks for the given mapping of
 	 * element names to required attribute names.
 	 */
-	public ValidationHandler(Map requiredAttributes) {
+	public ValidationHandler(Map<String, String[]> requiredAttributes) {
 		this(requiredAttributes, null);
 	}
 
@@ -38,7 +38,7 @@
 	 * element names to required attribute names, as well as a mapping
 	 * of deprecated element names to suggested new element names.
 	 */
-	public ValidationHandler(Map requiredAttributes, Map deprecatedElements) {
+	public ValidationHandler(Map<String, String[]> requiredAttributes, Map<String, String> deprecatedElements) {
 		this.requiredAttributes = requiredAttributes;
 		this.deprecatedElements = deprecatedElements;
 	}
@@ -46,13 +46,13 @@
 	@Override
 	public short handle(UAElement element, String id) {
 		if (deprecatedElements != null) {
-			String suggestion = (String)deprecatedElements.get(element.getElementName());
+			String suggestion = deprecatedElements.get(element.getElementName());
 			if (suggestion != null) {
 				String msg = "The \"" + element.getElementName() + "\" element is deprecated in \"" + id + "\"; use \"" + suggestion + "\" instead."; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
 				HelpPlugin.logWarning(msg);
 			}
 		}
-		String[] attributes = (String[])requiredAttributes.get(element.getElementName());
+		String[] attributes = requiredAttributes.get(element.getElementName());
 		if (attributes != null) {
 			for (int i=0;i<attributes.length;++i) {
 				if (element.getAttribute(attributes[i]) == null) {
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/extension/ContentExtensionFileParser.java b/org.eclipse.help/src/org/eclipse/help/internal/extension/ContentExtensionFileParser.java
index 38347f2..0d42945 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/extension/ContentExtensionFileParser.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/extension/ContentExtensionFileParser.java
@@ -68,7 +68,7 @@
 		}
     }
 
-	private Map getRequiredAttributes() {
+	private Map<String, String[]> getRequiredAttributes() {
 		if (requiredAttributes == null) {
 			requiredAttributes = new HashMap<>();
 			requiredAttributes.put(ContentExtension.NAME_CONTRIBUTION, new String[] { ContentExtension.ATTRIBUTE_CONTENT, ContentExtension.ATTRIBUTE_PATH });
@@ -79,7 +79,7 @@
 		return requiredAttributes;
 	}
 
-	private Map getDeprecatedElements() {
+	private Map<String, String> getDeprecatedElements() {
 		if (deprecatedElements == null) {
 			deprecatedElements = new HashMap<>();
 			deprecatedElements.put(ContentExtension.NAME_CONTRIBUTION_LEGACY, ContentExtension.NAME_CONTRIBUTION);
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/extension/ContentExtensionManager.java b/org.eclipse.help/src/org/eclipse/help/internal/extension/ContentExtensionManager.java
index dda5289..f7029ea 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/extension/ContentExtensionManager.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/extension/ContentExtensionManager.java
@@ -66,7 +66,7 @@
 		if (extensionsByPath == null) {
 			loadExtensions(locale);
 		}
-		Map<String, List<ContentExtension>> map = (type == ContentExtension.CONTRIBUTION ? extensionsByPath
+		Map<String, List<ContentExtension>> map = (type == IContentExtension.CONTRIBUTION ? extensionsByPath
 				: replacesByPath);
 		List<ContentExtension> extensions = map.get(path);
 		if (extensions != null) {
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/index/IndexAssembler.java b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexAssembler.java
index 0db0362..7b87888 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/index/IndexAssembler.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexAssembler.java
@@ -310,5 +310,5 @@
 			}
 			return null;
 		}
-	};
+	}
 }
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/index/IndexFileParser.java b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexFileParser.java
index d179a57..911a6fa 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/index/IndexFileParser.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexFileParser.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2005, 2015 Intel Corporation and others.
+ * Copyright (c) 2005, 2016 Intel 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
@@ -30,21 +30,17 @@
 		if (reader == null) {
 			reader = new IndexDocumentReader();
 		}
-		InputStream in = indexFile.getInputStream();
-		if (in != null) {
-			try {
-				Index index = (Index)reader.read(in);
+		try (InputStream in = indexFile.getInputStream()) {
+			if (in != null) {
+				Index index = (Index) reader.read(in);
 				IndexContribution contrib = new IndexContribution();
-		    	contrib.setId('/' + indexFile.getPluginId() + '/' + indexFile.getFile());
+				contrib.setId('/' + indexFile.getPluginId() + '/' + indexFile.getFile());
 				contrib.setIndex(index);
 				contrib.setLocale(indexFile.getLocale());
 				return contrib;
-			} finally {
-				in.close();
+			} else {
+				throw new FileNotFoundException();
 			}
 		}
-    	else {
-    		throw new FileNotFoundException();
-    	}
     }
 }
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/index/IndexSee.java b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexSee.java
index b5d6837..53b07bc 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/index/IndexSee.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/index/IndexSee.java
@@ -18,7 +18,7 @@
 
 import com.ibm.icu.text.Collator;
 
-public class IndexSee extends UAElement implements IIndexSee, Comparable  {
+public class IndexSee extends UAElement implements IIndexSee, Comparable<Object> {
 
 	public static final String NAME = "see"; //$NON-NLS-1$
 	public static final String ATTRIBUTE_KEYWORD = "keyword"; //$NON-NLS-1$
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/toc/DocumentFinder.java b/org.eclipse.help/src/org/eclipse/help/internal/toc/DocumentFinder.java
index 07ff4fe..4113a26 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/toc/DocumentFinder.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/toc/DocumentFinder.java
@@ -64,10 +64,10 @@
 		}
 
 		// Find topics in plugin
-		Set paths = ResourceLocator.findTopicPaths(pluginDesc, directory,
+		Set<String> paths = ResourceLocator.findTopicPaths(pluginDesc, directory,
 				locale);
-		for (Iterator it = paths.iterator(); it.hasNext();) {
-			String href = "/" + pluginID + "/" + (String) it.next();  //$NON-NLS-1$//$NON-NLS-2$
+		for (Iterator<String> it = paths.iterator(); it.hasNext();) {
+			String href = "/" + pluginID + "/" + it.next();  //$NON-NLS-1$//$NON-NLS-2$
 			href = HrefUtil.normalizeDirectoryPath(href);
 			result.add(href);
 		}
@@ -89,11 +89,8 @@
 					+ url.toString() + ".", ioe); //$NON-NLS-1$
 			return result;
 		}
-		ZipFile zipFile;
-		try {
-			zipFile = new ZipFile(realZipURL.getFile());
+		try (ZipFile zipFile = new ZipFile(realZipURL.getFile())) {
 			result = createExtraTopicsFromZipFile(pluginID, zipFile, directory);
-			zipFile.close();
 		} catch (IOException ioe) {
 			HelpPlugin.logError(
 					"IOException occurred, when accessing Zip file " //$NON-NLS-1$
@@ -108,8 +105,8 @@
 			String directory) {
 		String constantHrefSegment = "/" + pluginID + "/"; //$NON-NLS-1$ //$NON-NLS-2$
 		List<String> result = new ArrayList<>();
-		for (Enumeration entriesEnum = zipFile.entries(); entriesEnum.hasMoreElements();) {
-			ZipEntry zEntry = (ZipEntry) entriesEnum.nextElement();
+		for (Enumeration<? extends ZipEntry> entriesEnum = zipFile.entries(); entriesEnum.hasMoreElements();) {
+			ZipEntry zEntry = entriesEnum.nextElement();
 			if (zEntry.isDirectory()) {
 				continue;
 			}
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/toc/TocAssembler.java b/org.eclipse.help/src/org/eclipse/help/internal/toc/TocAssembler.java
index 249971d..457bc36 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/toc/TocAssembler.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/toc/TocAssembler.java
@@ -50,14 +50,14 @@
 	private Map<String, ITocContribution[]> contributionsByLinkTo;
 	private Set<ITocContribution> processedContributions;
 	private Map<String, String[]> requiredAttributes;
-	private Set tocsToFilter;
+	private Set<String> tocsToFilter;
 
 
 	public TocAssembler() {
-		this.tocsToFilter = new HashSet();
+		this.tocsToFilter = new HashSet<>();
 	}
 
-	public TocAssembler(Set tocsToFilter) {
+	public TocAssembler(Set<String> tocsToFilter) {
 		this.tocsToFilter = tocsToFilter;
 	}
 
@@ -92,7 +92,7 @@
 	 * 3. No other toc has a link to this contribution (via "link" element).
 	 */
 	private List<TocContribution> getBooks() {
-		Map linkedContributionIds = getLinkedContributionIds(contributions);
+		Map<String, String> linkedContributionIds = getLinkedContributionIds(contributions);
 		List<TocContribution> books = new ArrayList<>();
 		Iterator<TocContribution> iter = contributions.iterator();
 		while (iter.hasNext()) {
@@ -139,7 +139,7 @@
 	 * contributions, i.e. at least one other contribution has a link element
 	 * pointing to it.
 	 */
-	private Map getLinkedContributionIds(List contributions) {
+	private Map<String, String> getLinkedContributionIds(List<TocContribution> contributions) {
 		if (processor == null) {
 			processor = new DocumentProcessor();
 		}
@@ -162,9 +162,9 @@
 			}
 		};
 		processor.setHandlers(linkFinder);
-		ListIterator iter = contributions.listIterator();
+		ListIterator<TocContribution> iter = contributions.listIterator();
 		while (iter.hasNext()) {
-			TocContribution contrib = (TocContribution)iter.next();
+			TocContribution contrib = iter.next();
 			try {
 				String id = contrib.getId();
 				if (!tocsToFilter.contains(id)) {
@@ -189,7 +189,7 @@
 		if (contrib != null) {
 			process(contrib);
 			if (anchorsByContributionId != null) {
-				Set anchors = anchorsByContributionId.get(tocContributionId);
+				Set<String> anchors = anchorsByContributionId.get(tocContributionId);
 				if (anchors != null) {
 					return anchors.contains(anchorId);
 				}
@@ -312,7 +312,7 @@
 		return contributions;
 	}
 
-	private Map getRequiredAttributes() {
+	private Map<String, String[]> getRequiredAttributes() {
 		if (requiredAttributes == null) {
 			requiredAttributes = new HashMap<>();
 			requiredAttributes.put(Toc.NAME, new String[] { Toc.ATTRIBUTE_LABEL });
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/toc/TocFileParser.java b/org.eclipse.help/src/org/eclipse/help/internal/toc/TocFileParser.java
index b08509d..ebd5a93 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/toc/TocFileParser.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/toc/TocFileParser.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2016 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
@@ -28,9 +28,8 @@
 		if (reader == null) {
 			reader = new DocumentReader();
 		}
-		InputStream in = tocFile.getInputStream();
-    	if (in != null) {
-			try {
+		try (InputStream in = tocFile.getInputStream()) {
+			if (in != null) {
 				Toc toc = (Toc) reader.read(in);
 				TocContribution contribution = new TocContribution();
 				contribution.setCategoryId(tocFile.getCategory());
@@ -41,12 +40,9 @@
 				contribution.setToc(toc);
 				contribution.setPrimary(tocFile.isPrimary());
 				return contribution;
-			} finally {
-				in.close();
+			} else {
+				throw new FileNotFoundException();
 			}
-    	}
-    	else {
-    		throw new FileNotFoundException();
-    	}
+		}
     }
 }
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/toc/TocManager.java b/org.eclipse.help/src/org/eclipse/help/internal/toc/TocManager.java
index 6fbcab5..18edf37 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/toc/TocManager.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/toc/TocManager.java
@@ -64,7 +64,7 @@
 			if (HelpPlugin.DEBUG_TOC) {
 			    System.out.println("Start to build toc for locale " + locale); //$NON-NLS-1$
 			}
-			Set tocsToFilter = getIgnoredTocContributions();
+			Set<String> tocsToFilter = getIgnoredTocContributions();
 			TocContribution[] raw = getRootTocContributions(locale, tocsToFilter);
 			TocContribution[] filtered = filterTocContributions(raw, tocsToFilter);
 			ITocContribution[] ordered = new TocSorter().orderTocContributions(filtered);
@@ -292,7 +292,7 @@
 	 * either the contribution's id or its category's id is listed in the
 	 * ignoredTocs, filter the contribution.
 	 */
-	private TocContribution[] filterTocContributions(TocContribution[] unfiltered, Set tocsToFilter) {
+	private TocContribution[] filterTocContributions(TocContribution[] unfiltered, Set<String> tocsToFilter) {
 		List<TocContribution> filtered = new ArrayList<>();
 		for (int i=0;i<unfiltered.length;++i) {
 			if (!tocsToFilter.contains(unfiltered[i].getId()) &&
@@ -303,7 +303,7 @@
 		return filtered.toArray(new TocContribution[filtered.size()]);
 	}
 
-	private TocContribution[] getRootTocContributions(String locale, Set tocsToFilter) {
+	private TocContribution[] getRootTocContributions(String locale, Set<String> tocsToFilter) {
 		TocContribution[] contributions = getTocContributionsForToc(locale);
 		List<TocContribution> unassembled = new ArrayList<>(Arrays.asList(contributions));
 		TocAssembler assembler = new TocAssembler(tocsToFilter);
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/util/ProductPreferences.java b/org.eclipse.help/src/org/eclipse/help/internal/util/ProductPreferences.java
index ef91601..6ac8a72 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/util/ProductPreferences.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/util/ProductPreferences.java
@@ -189,7 +189,7 @@
 	 * but not present are skipped, and items present but not ordered are added
 	 * at the end.
 	 */
-	public static List getOrderedList(List<String> items, List<String> order) {
+	public static List<String> getOrderedList(List<String> items, List<String> order) {
 		return getOrderedList(items, order, null, null);
 	}
 
@@ -338,27 +338,14 @@
 		if (bundle != null) {
 			URL url = bundle.getEntry(path);
 			if (url != null) {
-				InputStream in = null;
-				try {
-					in = url.openStream();
+				try (InputStream in = url.openStream()) {
 					Properties properties = new Properties();
 					properties.load(in);
 					return properties;
-				}
-				catch (IOException e) {
+				} catch (IOException e) {
 					// log the fact that it couldn't load it
 					HelpPlugin.logError("Error opening product's plugin customization file: " + bundleId + "/" + path, e); //$NON-NLS-1$ //$NON-NLS-2$
 				}
-				finally {
-					if (in != null) {
-						try {
-							in.close();
-						}
-						catch (IOException e) {
-							// nothing we can do here
-						}
-					}
-				}
 			}
 		}
 		return null;
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/util/ResourceLocator.java b/org.eclipse.help/src/org/eclipse/help/internal/util/ResourceLocator.java
index fe49730..4f7df68 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/util/ResourceLocator.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/util/ResourceLocator.java
@@ -201,7 +201,7 @@
 
 	private static ProducerDescriptor findContentProducer(IConfigurationElement [] elements, String refId) {
 		// try existing ones
-		for (Iterator iter = contentProducers.values().iterator(); iter.hasNext();) {
+		for (Iterator<Object> iter = contentProducers.values().iterator(); iter.hasNext();) {
 			Object obj = iter.next();
 			if (obj instanceof ProducerDescriptor) {
 				ProducerDescriptor desc = (ProducerDescriptor) obj;
@@ -284,7 +284,7 @@
 
 		String pluginID = pluginDesc.getSymbolicName();
 		Map<String, Object> cache = zipCache;
-		ArrayList pathPrefix = getPathPrefix(locale);
+		ArrayList<String> pathPrefix = getPathPrefix(locale);
 
 		for (int i = 0; i < pathPrefix.size(); i++) {
 
@@ -344,7 +344,7 @@
 	 */
 	public static InputStream openFromPlugin(Bundle pluginDesc, String file, String locale) {
 
-		ArrayList pathPrefix = getPathPrefix(locale);
+		ArrayList<String> pathPrefix = getPathPrefix(locale);
 		URL flatFileURL = find(pluginDesc, new Path(file), pathPrefix);
 		if (flatFileURL != null)
 			try {
@@ -361,11 +361,11 @@
 	 * Search the ws, os then nl for a resource. Platform.find can't be used directly with $nl$,
 	 * $os$ or $ws$ becuase the root directory will be searched too early.
 	 */
-	public static URL find(Bundle pluginDesc, IPath flatFilePath, ArrayList pathPrefix) {
+	public static URL find(Bundle pluginDesc, IPath flatFilePath, ArrayList<String> pathPrefix) {
 
 		// try to find the actual file.
 		for (int i = 0; i < pathPrefix.size(); i++) {
-			URL url = FileLocator.find(pluginDesc, new Path((String) pathPrefix.get(i) + flatFilePath), null);
+			URL url = FileLocator.find(pluginDesc, new Path(pathPrefix.get(i) + flatFilePath), null);
 			if (url != null)
 				return url;
 		}
@@ -383,7 +383,7 @@
 	 * @return an ArrayList that has path prefixes that need to be search. The returned ArrayList
 	 * will have an entry for the root of the plugin.
 	 */
-	public static ArrayList getPathPrefix(String locale) {
+	public static ArrayList<String> getPathPrefix(String locale) {
 		ArrayList<String> pathPrefix = new ArrayList<>(5);
 		// TODO add override for ws and os similar to how it's done with locale
 		// now
@@ -438,15 +438,15 @@
 	private static void findTopicPaths(Bundle pluginDesc, String directory, String locale, Set<String> paths) {
 		if (directory.endsWith("/")) //$NON-NLS-1$
 			directory = directory.substring(0, directory.length() - 1);
-		ArrayList pathPrefix = getPathPrefix(locale);
+		ArrayList<String> pathPrefix = getPathPrefix(locale);
 		for (int i = 0; i < pathPrefix.size(); i++) {
 			String path = pathPrefix.get(i) + directory;
 			if (path.length() == 0)
 				path = "/"; //$NON-NLS-1$
-			Enumeration entries = pluginDesc.getEntryPaths(path);
+			Enumeration<String> entries = pluginDesc.getEntryPaths(path);
 			if (entries != null) {
 				while (entries.hasMoreElements()) {
-					String topicPath = (String) entries.nextElement();
+					String topicPath = entries.nextElement();
 					if (topicPath.endsWith("/")) { //$NON-NLS-1$
 						findTopicPaths(pluginDesc, topicPath, locale, paths);
 					} else {
@@ -466,7 +466,7 @@
 	public static String getErrorPath(String pluginId, String file, String locale)  {
 		String resolvedPath = pluginId + '/' + file;
 		try {
-			ArrayList pathPrefix = ResourceLocator.getPathPrefix(locale);
+			ArrayList<String> pathPrefix = ResourceLocator.getPathPrefix(locale);
 			Bundle bundle = Platform.getBundle(pluginId);
 			URL rawURL = ResourceLocator.find(bundle, new Path(file), pathPrefix);
 			URL resolvedURL = FileLocator.resolve(rawURL);
diff --git a/org.eclipse.help/src/org/eclipse/help/internal/util/SequenceResolver.java b/org.eclipse.help/src/org/eclipse/help/internal/util/SequenceResolver.java
index a2eadc3..b6578e9 100644
--- a/org.eclipse.help/src/org/eclipse/help/internal/util/SequenceResolver.java
+++ b/org.eclipse.help/src/org/eclipse/help/internal/util/SequenceResolver.java
@@ -230,7 +230,7 @@
 			candidateItems.add(candidates[i].item);
 		}
 		for (int i=0;i<candidates.length;++i) {
-			Candidate c = candidates[i];
+			Candidate<T> c = candidates[i];
 			for (int j=0;j<candidates.length;++j) {
 				c.rank += countPrecedingItems(c.item, candidates[j].src, candidateItems);
 			}
@@ -241,9 +241,9 @@
 	 * Counts the number of elements from the given set that come before
 	 * the given item in the given list.
 	 */
-	private int countPrecedingItems(Object item, List list, Set set) {
+	private int countPrecedingItems(Object item, List<?> list, Set<?> set) {
 		int count = 0;
-		Iterator iter = list.iterator();
+		Iterator<?> iter = list.iterator();
 		while (iter.hasNext()) {
 			Object next = iter.next();
 			if (next.equals(item)) {
@@ -291,7 +291,7 @@
 		public T item;
 		public boolean isPrimary;
 		public int rank;
-		public List src;
+		public List<?> src;
 
 		@Override
 		public boolean equals(Object obj) {