Varargs reflection methods and try-with-resources.

Change-Id: Ib1f5311b9a5f7fde578129b96613fbeacfe0a0c0
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/base/DisplayUtils.java b/org.eclipse.help.base/src/org/eclipse/help/internal/base/DisplayUtils.java
index 5e1c719..0b9620f 100644
--- a/org.eclipse.help.base/src/org/eclipse/help/internal/base/DisplayUtils.java
+++ b/org.eclipse.help.base/src/org/eclipse/help/internal/base/DisplayUtils.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2019 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -44,8 +44,8 @@
 				return;
 			}
 			Class<?> c = bundle.loadClass(LOOP_CLASS_NAME);
-			Method m = c.getMethod(method, new Class[]{});
-			m.invoke(null, new Object[]{});
+			Method m = c.getMethod(method);
+			m.invoke(null);
 		} catch (Exception e) {
 		}
 	}
diff --git a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/util/ResourceManager.java b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/util/ResourceManager.java
index 6898192..209426e 100644
--- a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/util/ResourceManager.java
+++ b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/util/ResourceManager.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2011, 2018 Google, Inc.
+ * Copyright (c) 2011, 2019 Google, Inc. and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -389,17 +389,17 @@
 			Class<?> BundleClass = Class.forName("org.osgi.framework.Bundle"); //$NON-NLS-1$
 			Class<?> BundleContextClass = Class.forName("org.osgi.framework.BundleContext"); //$NON-NLS-1$
 			if (BundleContextClass.isAssignableFrom(plugin.getClass())) {
-				Method getBundleMethod = BundleContextClass.getMethod("getBundle", new Class[0]); //$NON-NLS-1$
-				Object bundle = getBundleMethod.invoke(plugin, new Object[0]);
+				Method getBundleMethod = BundleContextClass.getMethod("getBundle"); //$NON-NLS-1$
+				Object bundle = getBundleMethod.invoke(plugin);
 				//
 				Class<?> PathClass = Class.forName("org.eclipse.core.runtime.Path"); //$NON-NLS-1$
-				Constructor<?> pathConstructor = PathClass.getConstructor(new Class[] { String.class });
-				Object path = pathConstructor.newInstance(new Object[] { name });
+				Constructor<?> pathConstructor = PathClass.getConstructor(String.class);
+				Object path = pathConstructor.newInstance(name);
 				//
 				Class<?> IPathClass = Class.forName("org.eclipse.core.runtime.IPath"); //$NON-NLS-1$
 				Class<?> PlatformClass = Class.forName("org.eclipse.core.runtime.Platform"); //$NON-NLS-1$
-				Method findMethod = PlatformClass.getMethod("find", new Class[] { BundleClass, IPathClass }); //$NON-NLS-1$
-				return (URL) findMethod.invoke(null, new Object[] { bundle, path });
+				Method findMethod = PlatformClass.getMethod("find", BundleClass, IPathClass); //$NON-NLS-1$
+				return (URL) findMethod.invoke(null, bundle, path);
 			}
 		} catch (Throwable e) {
 			// Ignore any exceptions
@@ -410,12 +410,12 @@
 			if (PluginClass.isAssignableFrom(plugin.getClass())) {
 				//
 				Class<?> PathClass = Class.forName("org.eclipse.core.runtime.Path"); //$NON-NLS-1$
-				Constructor<?> pathConstructor = PathClass.getConstructor(new Class[] { String.class });
-				Object path = pathConstructor.newInstance(new Object[] { name });
+				Constructor<?> pathConstructor = PathClass.getConstructor(String.class);
+				Object path = pathConstructor.newInstance(name);
 				//
 				Class<?> IPathClass = Class.forName("org.eclipse.core.runtime.IPath"); //$NON-NLS-1$
-				Method findMethod = PluginClass.getMethod("find", new Class[] { IPathClass }); //$NON-NLS-1$
-				return (URL) findMethod.invoke(plugin, new Object[] { path });
+				Method findMethod = PluginClass.getMethod("find", IPathClass); //$NON-NLS-1$
+				return (URL) findMethod.invoke(plugin, path);
 			}
 		}
 		return null;
diff --git a/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/util/CheatSheetModelSerializer.java b/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/util/CheatSheetModelSerializer.java
index b599211..479b00a 100644
--- a/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/util/CheatSheetModelSerializer.java
+++ b/org.eclipse.ua.tests/cheatsheet/org/eclipse/ua/tests/cheatsheet/util/CheatSheetModelSerializer.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2004, 2017 IBM Corporation and others.
+ * Copyright (c) 2004, 2019 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -203,7 +203,7 @@
 						Class<?>[] params = method.getParameterTypes();
 						if (params.length == 2 && params[0].isAssignableFrom(c) && params[1].equals(String.class)) {
 							try {
-								buf.append(method.invoke(null, new Object[] {obj, indent + "   "}));
+								buf.append(method.invoke(null, obj, indent + "   "));
 							}
 							catch(Exception e) {
 								buf.append(indent + "   " + e + ", cause: " + e.getCause());
@@ -254,7 +254,7 @@
 						Class<?>[] params = method.getParameterTypes();
 						if (params.length == 2 && params[0].isAssignableFrom(c) && params[1].equals(String.class)) {
 							try {
-								buf.append(method.invoke(null, new Object[] {obj, indent + "   "}));
+								buf.append(method.invoke(null, obj, indent + "   "));
 							}
 							catch(Exception e) {
 								buf.append(indent + "   " + e + ", cause: " + e.getCause());
diff --git a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/ChildLinkInsertion.java b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/ChildLinkInsertion.java
index 907efa2..09cd575 100644
--- a/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/ChildLinkInsertion.java
+++ b/org.eclipse.ua.tests/help/org/eclipse/ua/tests/help/webapp/ChildLinkInsertion.java
@@ -181,19 +181,17 @@
 	}
 
 	private void checkEncoding(String input, String expectedEncoding) {
-		ByteArrayOutputStream output = new ByteArrayOutputStream();
-		TestableReplacementStream filteredOutput = new TestableReplacementStream(output, null, "../");
-		try {
+		try (ByteArrayOutputStream output = new ByteArrayOutputStream();
+				TestableReplacementStream filteredOutput = new TestableReplacementStream(output, null, "../")) {
 			filteredOutput.write(input.getBytes());
-			filteredOutput.close();
+			if (expectedEncoding == null) {
+				assertNull(filteredOutput.getCharset());
+			} else {
+				assertEquals(expectedEncoding, filteredOutput.getCharset());
+			}
 		} catch (IOException e) {
 			fail("IO Exception");
 		}
-		if (expectedEncoding == null) {
-			assertNull(filteredOutput.getCharset());
-		} else {
-			assertEquals(expectedEncoding, filteredOutput.getCharset());
-		}
 	}
 
 }
diff --git a/org.eclipse.ui.cheatsheets/META-INF/MANIFEST.MF b/org.eclipse.ui.cheatsheets/META-INF/MANIFEST.MF
index 6609528..b8886c7 100644
--- a/org.eclipse.ui.cheatsheets/META-INF/MANIFEST.MF
+++ b/org.eclipse.ui.cheatsheets/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: %PLUGIN_NAME
 Bundle-SymbolicName: org.eclipse.ui.cheatsheets; singleton:=true
-Bundle-Version: 3.5.300.qualifier
+Bundle-Version: 3.5.400.qualifier
 Bundle-Activator: org.eclipse.ui.internal.cheatsheets.CheatSheetPlugin
 Bundle-Vendor: %PROVIDER_NAME
 Bundle-Localization: plugin
diff --git a/org.eclipse.ui.cheatsheets/pom.xml b/org.eclipse.ui.cheatsheets/pom.xml
index 1929a4b..6ea5453 100644
--- a/org.eclipse.ui.cheatsheets/pom.xml
+++ b/org.eclipse.ui.cheatsheets/pom.xml
@@ -19,7 +19,7 @@
   </parent>
   <groupId>org.eclipse.ui</groupId>
   <artifactId>org.eclipse.ui.cheatsheets</artifactId>
-  <version>3.5.300-SNAPSHOT</version>
+  <version>3.5.400-SNAPSHOT</version>
   <packaging>eclipse-plugin</packaging>
 
   <properties>
diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/TaskEditorManager.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/TaskEditorManager.java
index 093917e..f51a8bc 100644
--- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/TaskEditorManager.java
+++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/composite/views/TaskEditorManager.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2005, 2017 IBM Corporation and others.
+ * Copyright (c) 2005, 2019 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -63,7 +63,7 @@
 			}
 			try {
 				if (extClass != null) {
-					Constructor<?> c = extClass.getConstructor(new Class[0]);
+					Constructor<?> c = extClass.getConstructor();
 					editorInstance = (TaskEditor) c.newInstance();
 				}
 			} catch (Exception e) {
diff --git a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetItemExtensionElement.java b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetItemExtensionElement.java
index 59f3a0e..d7e5a6c 100644
--- a/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetItemExtensionElement.java
+++ b/org.eclipse.ui.cheatsheets/src/org/eclipse/ui/internal/cheatsheets/registry/CheatSheetItemExtensionElement.java
@@ -13,6 +13,7 @@
  *******************************************************************************/
 package org.eclipse.ui.internal.cheatsheets.registry;
 
+
 import java.lang.reflect.Constructor;
 
 import org.eclipse.core.runtime.IAdaptable;