Move away of deprecated Class.newInstance.

Use the Constructor.newInstance instead.

Change-Id: I7814d2850d77a5dc5e88f5e1f55e4e3275e7d990
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/ant/org.eclipse.ant.core/src/org/eclipse/ant/core/AntRunner.java b/ant/org.eclipse.ant.core/src/org/eclipse/ant/core/AntRunner.java
index f07dcdd..ecae6ce 100644
--- a/ant/org.eclipse.ant.core/src/org/eclipse/ant/core/AntRunner.java
+++ b/ant/org.eclipse.ant.core/src/org/eclipse/ant/core/AntRunner.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
@@ -235,7 +235,7 @@
 		ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
 		try {
 			classInternalAntRunner = getInternalAntRunner();
-			runner = classInternalAntRunner.newInstance();
+			runner = classInternalAntRunner.getConstructor().newInstance();
 			basicConfigure(classInternalAntRunner, runner);
 
 			// get the info for each targets
@@ -317,7 +317,7 @@
 		ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
 		try {
 			classInternalAntRunner = getInternalAntRunner();
-			runner = classInternalAntRunner.newInstance();
+			runner = classInternalAntRunner.getConstructor().newInstance();
 			// set build file
 			Method setBuildFileLocation = classInternalAntRunner.getMethod("setBuildFileLocation", new Class[] { String.class }); //$NON-NLS-1$
 			setBuildFileLocation.invoke(runner, new Object[] { buildFileLocation });
@@ -509,7 +509,7 @@
 			ClassLoader loader = getClassLoader();
 			Thread.currentThread().setContextClassLoader(loader);
 			Class<?> classInternalAntRunner = loader.loadClass("org.eclipse.ant.internal.core.ant.InternalAntRunner"); //$NON-NLS-1$
-			Object runner = classInternalAntRunner.newInstance();
+			Object runner = classInternalAntRunner.getConstructor().newInstance();
 			Method run = classInternalAntRunner.getMethod("run", new Class[] { Object.class }); //$NON-NLS-1$
 			run.invoke(runner, new Object[] { argArray });
 		}
diff --git a/ant/org.eclipse.ant.core/src/org/eclipse/ant/core/Property.java b/ant/org.eclipse.ant.core/src/org/eclipse/ant/core/Property.java
index 44e896b..53d98d9 100644
--- a/ant/org.eclipse.ant.core/src/org/eclipse/ant/core/Property.java
+++ b/ant/org.eclipse.ant.core/src/org/eclipse/ant/core/Property.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2013 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
@@ -14,6 +14,8 @@
  *******************************************************************************/
 package org.eclipse.ant.core;
 
+import java.lang.reflect.InvocationTargetException;
+
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.variables.VariablesPlugin;
 
@@ -102,16 +104,13 @@
 				return null;
 			}
 			try {
-				valueProvider = (IAntPropertyValueProvider) cls.newInstance();
+				valueProvider = (IAntPropertyValueProvider) cls.getConstructor().newInstance();
 			}
-			catch (InstantiationException e) {
+			catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException
+					| SecurityException e) {
 				AntCorePlugin.log(e);
 				return null;
 			}
-			catch (IllegalAccessException ex) {
-				AntCorePlugin.log(ex);
-				return null;
-			}
 			loader = null;
 			className = null;
 		}
diff --git a/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InputHandlerSetter.java b/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InputHandlerSetter.java
index 6b4c859..2e568e3 100644
--- a/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InputHandlerSetter.java
+++ b/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InputHandlerSetter.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- *  Copyright (c) 2000, 2013 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
@@ -32,10 +32,11 @@
 			handler = new DefaultInputHandler();
 		} else {
 			try {
-				handler = (InputHandler) (Class.forName(inputHandlerClassname).newInstance());
+				handler = (InputHandler) (Class.forName(inputHandlerClassname).getConstructor().newInstance());
 			}
 			catch (ClassCastException e) {
-				String msg = MessageFormat.format(InternalAntMessages.InternalAntRunner_handler_does_not_implement_InputHandler5, new Object[] { inputHandlerClassname });
+				String msg = MessageFormat.format(InternalAntMessages.InternalAntRunner_handler_does_not_implement_InputHandler5, new Object[] {
+						inputHandlerClassname });
 				throw new BuildException(msg, e);
 			}
 			catch (Exception e) {
diff --git a/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntRunner.java b/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntRunner.java
index 3049d67..4245e09 100644
--- a/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntRunner.java
+++ b/ant/org.eclipse.ant.core/src_ant/org/eclipse/ant/internal/core/ant/InternalAntRunner.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- *  Copyright (c) 2000, 2017 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
@@ -236,7 +236,7 @@
 				for (Iterator<String> iterator = buildListeners.iterator(); iterator.hasNext();) {
 					className = iterator.next();
 					Class<?> listener = Class.forName(className);
-					project.addBuildListener((BuildListener) listener.newInstance());
+					project.addBuildListener((BuildListener) listener.getConstructor().newInstance());
 				}
 			}
 		}
@@ -798,7 +798,7 @@
 			buildLogger = new DefaultLogger();
 		} else if (!IAntCoreConstants.EMPTY_STRING.equals(loggerClassname)) {
 			try {
-				buildLogger = (BuildLogger) (Class.forName(loggerClassname).newInstance());
+				buildLogger = (BuildLogger) (Class.forName(loggerClassname).getConstructor().newInstance());
 			}
 			catch (ClassCastException e) {
 				String message = MessageFormat.format(InternalAntMessages.InternalAntRunner_not_an_instance_of_apache_ant_BuildLogger, new Object[] {
diff --git a/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/InputHandlerSetter.java b/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/InputHandlerSetter.java
index 9be8c2c..ff0f4ab 100644
--- a/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/InputHandlerSetter.java
+++ b/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/InputHandlerSetter.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2013 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
@@ -32,14 +32,16 @@
 			handler = new DefaultInputHandler();
 		} else {
 			try {
-				handler = (InputHandler) (Class.forName(inputHandlerClassname).newInstance());
+				handler = (InputHandler) (Class.forName(inputHandlerClassname).getConstructor().newInstance());
 			}
 			catch (ClassCastException e) {
-				String msg = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.The_specified_input_handler_class_{0}_does_not_implement_the_org.apache.tools.ant.input.InputHandler_interface_5"), new Object[] { inputHandlerClassname }); //$NON-NLS-1$
+				String msg = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.The_specified_input_handler_class_{0}_does_not_implement_the_org.apache.tools.ant.input.InputHandler_interface_5"), new Object[] { //$NON-NLS-1$
+						inputHandlerClassname });
 				throw new BuildException(msg, e);
 			}
 			catch (Exception e) {
-				String msg = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Unable_to_instantiate_specified_input_handler_class_{0}___{1}_6"), new Object[] { inputHandlerClassname, e.getClass().getName() }); //$NON-NLS-1$
+				String msg = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.Unable_to_instantiate_specified_input_handler_class_{0}___{1}_6"), new Object[] { //$NON-NLS-1$
+						inputHandlerClassname, e.getClass().getName() });
 				throw new BuildException(msg, e);
 			}
 		}
diff --git a/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/InternalAntRunner.java b/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/InternalAntRunner.java
index af88bb6..4e8e3cd 100644
--- a/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/InternalAntRunner.java
+++ b/ant/org.eclipse.ant.launching/remote/org/eclipse/ant/internal/launching/remote/InternalAntRunner.java
@@ -178,7 +178,7 @@
 				for (String className : buildListeners) {
 					clazz = className;
 					Class<?> listener = Class.forName(className);
-					project.addBuildListener((BuildListener) listener.newInstance());
+					project.addBuildListener((BuildListener) listener.getConstructor().newInstance());
 				}
 			}
 		}
@@ -565,7 +565,7 @@
 			buildLogger = new DefaultLogger();
 		} else if (!IAntCoreConstants.EMPTY_STRING.equals(loggerClassname)) {
 			try {
-				buildLogger = (BuildLogger) (Class.forName(loggerClassname).newInstance());
+				buildLogger = (BuildLogger) (Class.forName(loggerClassname).getConstructor().newInstance());
 			}
 			catch (ClassCastException e) {
 				String message = MessageFormat.format(RemoteAntMessages.getString("InternalAntRunner.{0}_which_was_specified_to_perform_logging_is_not_an_instance_of_org.apache.tools.ant.BuildLogger._2"), new Object[] { //$NON-NLS-1$
diff --git a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorCompletionProcessor.java b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorCompletionProcessor.java
index 56a63b3..f54ec89 100644
--- a/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorCompletionProcessor.java
+++ b/ant/org.eclipse.ant.ui/Ant Editor/org/eclipse/ant/internal/ui/editor/AntEditorCompletionProcessor.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2002, 2015 GEBIT Gesellschaft fuer EDV-Beratung
+ * Copyright (c) 2002, 2019 GEBIT Gesellschaft fuer EDV-Beratung
  * und Informatik-Technologien mbH, 
  * Berlin, Duesseldorf, Frankfurt (Germany) and others.
  *
@@ -950,10 +950,8 @@
 			try {
 				addEnumeratedAttributeValueProposals(attributeType, prefix, proposals);
 			}
-			catch (InstantiationException e) {
-				// do nothing
-			}
-			catch (IllegalAccessException e) {
+			catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException
+					| SecurityException e) {
 				// do nothing
 			}
 		} else if (Reference.class == attributeType) {
@@ -961,8 +959,8 @@
 		}
 	}
 
-	private void addEnumeratedAttributeValueProposals(Class<?> type, String prefix, List<ICompletionProposal> proposals) throws InstantiationException, IllegalAccessException {
-		EnumeratedAttribute ea = (EnumeratedAttribute) type.newInstance();
+	private void addEnumeratedAttributeValueProposals(Class<?> type, String prefix, List<ICompletionProposal> proposals) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
+		EnumeratedAttribute ea = (EnumeratedAttribute) type.getConstructor().newInstance();
 		String enumerated;
 		for (String value : ea.getValues()) {
 			enumerated = value.toLowerCase();