mirror of https://github.com/apache/jclouds.git
Address error-prone ClassNewInstance errors
Previous behavior deprecated in Java 9.
This commit is contained in:
parent
ed7ff648e8
commit
28ed955183
|
@ -45,6 +45,7 @@ import static org.jclouds.rest.config.BinderUtils.bindHttpApi;
|
|||
import static org.jclouds.util.Throwables2.propagateAuthorizationOrOriginalException;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NoSuchElementException;
|
||||
|
@ -437,11 +438,15 @@ public class ContextBuilder {
|
|||
@Override
|
||||
public Module apply(Class<? extends Module> arg0) {
|
||||
try {
|
||||
return arg0.newInstance();
|
||||
return arg0.getConstructor().newInstance();
|
||||
} catch (InstantiationException e) {
|
||||
throw propagate(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw propagate(e);
|
||||
} catch (InvocationTargetException e) {
|
||||
throw propagate(e);
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw propagate(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import static org.jclouds.util.Strings2.toStringAndClose;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.osgi.framework.Bundle;
|
||||
|
@ -97,9 +98,11 @@ public final class Bundles {
|
|||
public T apply(Class<?> in) {
|
||||
checkNotNull(in, "input class");
|
||||
try {
|
||||
return clazz.cast(in.newInstance());
|
||||
return clazz.cast(in.getConstructor().newInstance());
|
||||
} catch (InstantiationException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
} catch (InvocationTargetException e) {
|
||||
} catch (NoSuchMethodException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue