Move away of deprecated Class.newInstnace.

Class.getDeclaredConstructor().newInstance() is the preferred way.

Change-Id: I3a555fdd9db6b233b53d22a7ac3bfac490b98120
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/ContainerTypeDescription.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/ContainerTypeDescription.java
index 597650d..fb7d278 100644
--- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/ContainerTypeDescription.java
+++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/ContainerTypeDescription.java
@@ -11,6 +11,7 @@
  *****************************************************************************/
 package org.eclipse.ecf.core;
 
+import java.lang.reflect.InvocationTargetException;
 import java.util.*;
 import org.eclipse.core.runtime.*;
 import org.eclipse.ecf.core.provider.IContainerInstantiator;
@@ -124,7 +125,15 @@
 		// Load instantiator class
 		Class clazz = Class.forName(instantiatorClass);
 		// Make new instance
-		instantiator = (IContainerInstantiator) clazz.newInstance();
+		try {
+			instantiator = (IContainerInstantiator) clazz.getDeclaredConstructor().newInstance();
+		} catch (InvocationTargetException e) {
+			throw new ClassNotFoundException("Invocation target exception accessing null constructor for class=" + clazz, e); //$NON-NLS-1$
+		} catch (NoSuchMethodException e) {
+			throw new ClassNotFoundException("No null constructor found on class=" + clazz, e); //$NON-NLS-1$
+		} catch (SecurityException e) {
+			throw new ClassNotFoundException("Security exception accessing null constructor for class=" + clazz, e); //$NON-NLS-1$
+		}
 	}
 
 	/**
diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/util/OSGIObjectInputStream.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/util/OSGIObjectInputStream.java
index 46ddd90..87e13c3 100644
--- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/util/OSGIObjectInputStream.java
+++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/core/util/OSGIObjectInputStream.java
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2018 Composent, Inc. and others.
+ * Copyright (c) 2018, 2020 Composent, Inc. and others.
  *
  * This program and the accompanying materials are made
  * available under the terms of the Eclipse Public License 2.0
@@ -210,7 +210,7 @@
 		Class<?> clazz = loadClass(in.readUTF());
 		Object result = null;
 		try {
-			result = clazz.newInstance();
+			result = clazz.getDeclaredConstructor().newInstance();
 			for (Field f : clazz.getFields()) {
 				final int mod = f.getModifiers();
 				// If it's static or transient then ignore
@@ -257,7 +257,7 @@
 
 	protected Object createInstance(Class<?> clazz) throws IOException {
 		try {
-			return clazz.newInstance();
+			return clazz.getDeclaredConstructor().newInstance();
 		} catch (Exception e) {
 			throw new IOException("Could create new instance of class=" + clazz.getName() + ".  Class must have public no-arg constructor"); //$NON-NLS-1$ //$NON-NLS-2$
 		}
diff --git a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/ECFPlugin.java b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/ECFPlugin.java
index c9673f5..0ba112f 100644
--- a/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/ECFPlugin.java
+++ b/framework/bundles/org.eclipse.ecf/src/org/eclipse/ecf/internal/core/ECFPlugin.java
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 2004 Composent, Inc. and others.
+ * Copyright (c) 2004, 2020 Composent, Inc. and others.
  *
  * This program and the accompanying materials are made
  * available under the terms of the Eclipse Public License 2.0
@@ -141,7 +141,7 @@
 		// initialize the default ssl socket factory 
 		try {
 			Class ecfSocketFactoryClass = Class.forName("org.eclipse.ecf.internal.ssl.ECFTrustManager"); //$NON-NLS-1$
-			ecfTrustManager = (BundleActivator) ecfSocketFactoryClass.newInstance();
+			ecfTrustManager = (BundleActivator) ecfSocketFactoryClass.getDeclaredConstructor().newInstance();
 			ecfTrustManager.start(ctxt);
 		} catch (ClassNotFoundException e) {
 			// will occur if fragment is not installed or not on proper execution environment