diff options
author | Aurélien Mora | 2019-04-18 08:58:43 +0000 |
---|---|---|
committer | Aurélien Mora | 2019-04-18 09:07:00 +0000 |
commit | 8b5dc1f0d89c3312c7620c78272d32f13e777ef4 (patch) | |
tree | 387f3305f2de500c3b44bef772d6ef50d14909b6 /plugins/org.eclipse.emf.ecore/src/org/eclipse/emf | |
parent | ebaf792041945ac032116ac65473f5ce818a6f06 (diff) | |
download | org.eclipse.emf-8b5dc1f0d89c3312c7620c78272d32f13e777ef4.tar.gz org.eclipse.emf-8b5dc1f0d89c3312c7620c78272d32f13e777ef4.tar.xz org.eclipse.emf-8b5dc1f0d89c3312c7620c78272d32f13e777ef4.zip |
[546547] Class.newInstance() is deprecated (Since java9)
Signed-off-by: Aurélien Mora <ealrann@gmail.com>
Diffstat (limited to 'plugins/org.eclipse.emf.ecore/src/org/eclipse/emf')
6 files changed, 41 insertions, 7 deletions
diff --git a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EPackageImpl.java b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EPackageImpl.java index 6a52838ee..a024b042c 100644 --- a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EPackageImpl.java +++ b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EPackageImpl.java @@ -758,7 +758,7 @@ public class EPackageImpl extends ENamedElementImpl implements EPackage, BasicEx { try { - resourceFactory = (Resource.Factory)CommonPlugin.loadClass("org.eclipse.emf.ecore.xmi", "org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl").newInstance(); + resourceFactory = (Resource.Factory)CommonPlugin.loadClass("org.eclipse.emf.ecore.xmi", "org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl").getDeclaredConstructor().newInstance(); } catch (Throwable exception) { diff --git a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EPackageRegistryImpl.java b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EPackageRegistryImpl.java index 483eb8b2e..d58afbf07 100644 --- a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EPackageRegistryImpl.java +++ b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/impl/EPackageRegistryImpl.java @@ -75,7 +75,7 @@ public class EPackageRegistryImpl extends HashMap<String, Object> implements EPa } else { - return (EPackage.Registry)Class.forName(className).newInstance(); + return (EPackage.Registry)Class.forName(className).getDeclaredConstructor().newInstance(); } } catch (Exception exception) diff --git a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/AnnotationValidatorRegistryReader.java b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/AnnotationValidatorRegistryReader.java index e93069746..050751c64 100644 --- a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/AnnotationValidatorRegistryReader.java +++ b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/AnnotationValidatorRegistryReader.java @@ -9,6 +9,7 @@ package org.eclipse.emf.ecore.plugin; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.RegistryFactory; @@ -49,7 +50,7 @@ class AnnotationValidatorRegistryReader extends RegistryReader catch (NoSuchFieldError e) { // If not, create a new instance. - return (EAnnotationValidator)javaClass.newInstance(); + return (EAnnotationValidator) javaClass.getDeclaredConstructor().newInstance(); } } catch (ClassNotFoundException e) @@ -68,6 +69,22 @@ class AnnotationValidatorRegistryReader extends RegistryReader { throw new WrappedException(e); } + catch (IllegalArgumentException e) + { + throw new WrappedException(e); + } + catch (InvocationTargetException e) + { + throw new WrappedException(e); + } + catch (NoSuchMethodException e) + { + throw new WrappedException(e); + } + catch (SecurityException e) + { + throw new WrappedException(e); + } } } diff --git a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/ContentHandlerRegistryReader.java b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/ContentHandlerRegistryReader.java index 98e5de1de..45829e412 100644 --- a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/ContentHandlerRegistryReader.java +++ b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/ContentHandlerRegistryReader.java @@ -76,7 +76,7 @@ class ContentHandlerRegistryReader extends RegistryReader } ContentHandler contentHandler = parameters.isEmpty() ? - contributorHandlerClass.newInstance() : + contributorHandlerClass.getDeclaredConstructor().newInstance() : contributorHandlerClass.getConstructor(Map.class).newInstance(parameters); ContentHandler.Registry.INSTANCE.put(priority, contentHandler); List<ContentHandler> contributions = CONTRIBUTION_MAP.get(contributorName); diff --git a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/RegistryReader.java b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/RegistryReader.java index 86a0495f0..6dd9afea1 100644 --- a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/RegistryReader.java +++ b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/plugin/RegistryReader.java @@ -12,6 +12,7 @@ package org.eclipse.emf.ecore.plugin; import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; import java.util.HashSet; import java.util.Set; @@ -345,7 +346,7 @@ public abstract class RegistryReader try { Class<?> javaClass = CommonPlugin.loadClass(element.getDeclaringExtension().getContributor().getName(), element.getAttribute(attributeName)); - return (EFactory)javaClass.newInstance(); + return (EFactory) javaClass.getDeclaredConstructor().newInstance(); } catch (ClassNotFoundException e) { @@ -359,6 +360,22 @@ public abstract class RegistryReader { throw new WrappedException(e); } + catch (IllegalArgumentException e) + { + throw new WrappedException(e); + } + catch (InvocationTargetException e) + { + throw new WrappedException(e); + } + catch (NoSuchMethodException e) + { + throw new WrappedException(e); + } + catch (SecurityException e) + { + throw new WrappedException(e); + } } public EPackage.Descriptor getOverridenDescriptor() diff --git a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/util/DateConversionDelegateFactory.java b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/util/DateConversionDelegateFactory.java index 02f7ac451..c88f8b20e 100644 --- a/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/util/DateConversionDelegateFactory.java +++ b/plugins/org.eclipse.emf.ecore/src/org/eclipse/emf/ecore/util/DateConversionDelegateFactory.java @@ -220,7 +220,7 @@ public class DateConversionDelegateFactory implements EDataType.Internal.Convers { // Test that the builder will actually function when used. // - Object builder = calendarBuilderClass.newInstance(); + Object builder = calendarBuilderClass.getDeclaredConstructor().newInstance(); setCalendarTypeMethod.invoke(builder, calendarType); setInstantMethod.invoke(builder, System.currentTimeMillis()); buildMethod.invoke(builder); @@ -232,7 +232,7 @@ public class DateConversionDelegateFactory implements EDataType.Internal.Convers { try { - Object builder = calendarBuilderClass.newInstance(); + Object builder = calendarBuilderClass.getDeclaredConstructor().newInstance(); setCalendarTypeMethod.invoke(builder, calendarType); setInstantMethod.invoke(builder, timeInstant); return (Calendar)buildMethod.invoke(builder); |