Skip to content

Commit 175375a

Browse files
committed
Remove deprecated method calls
1 parent a11f871 commit 175375a

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

core/mybatis-generator-maven-plugin/src/main/java/org/mybatis/generator/maven/SqlScriptRunner.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void executeScript() throws MojoExecutionException {
7979

8080
try {
8181
Class<?> driverClass = ObjectFactory.externalClassForName(driver);
82-
Driver theDriver = (Driver) driverClass.newInstance();
82+
Driver theDriver = (Driver) driverClass.getDeclaredConstructor().newInstance();
8383

8484
Properties properties = new Properties();
8585
if (userid != null) {
@@ -114,10 +114,8 @@ public void executeScript() throws MojoExecutionException {
114114
throw new MojoExecutionException("SqlException: " + e.getMessage(), e);
115115
} catch (IOException e) {
116116
throw new MojoExecutionException("IOException: " + e.getMessage(), e);
117-
} catch (InstantiationException e) {
118-
throw new MojoExecutionException("InstantiationException: " + e.getMessage());
119-
} catch (IllegalAccessException e) {
120-
throw new MojoExecutionException("IllegalAccessException: " + e.getMessage());
117+
} catch (ReflectiveOperationException e) {
118+
throw new MojoExecutionException("ReflectiveOperationException: " + e.getMessage());
121119
} finally {
122120
closeConnection(connection);
123121
}

core/mybatis-generator-systests-domtests/src/main/java/mbg/domtest/GenerateTestSourceFiles.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,20 @@ public static void main (String[] args) {
4848
}
4949
}
5050

51-
private void gatherGenerators(List<CompilationUnitGenerator> generators) throws InstantiationException, IllegalAccessException {
51+
private void gatherGenerators(List<CompilationUnitGenerator> generators) throws ReflectiveOperationException {
5252
Reflections reflections = new Reflections("mbg.domtest.generators");
5353
Set<Class<? extends CompilationUnitGenerator>> classes = reflections.getSubTypesOf(CompilationUnitGenerator.class);
5454

5555
for (Class<? extends CompilationUnitGenerator> clazz : classes) {
5656
if (clazz.getAnnotation(IgnoreDomTest.class) == null) {
57-
generators.add(clazz.newInstance());
57+
generators.add(clazz.getDeclaredConstructor().newInstance());
5858
} else {
5959
System.out.println("Generator " + clazz.getName() + " ignored");
6060
}
6161
}
6262
}
6363

64-
private void run(File outputDirectory) throws IOException, InstantiationException, IllegalAccessException {
64+
private void run(File outputDirectory) throws IOException, ReflectiveOperationException {
6565
setupOutputDirectry(outputDirectory);
6666

6767
List<CompilationUnitGenerator> generators = new ArrayList<>();

eclipse/org.mybatis.generator.eclipse.test.utilities/src/org/mybatis/generator/eclipse/test/Utilities.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public static String getResourceAsString(InputStream resource) throws IOExceptio
6060

6161
public static <T> T newInstance(Class<? extends T> type) {
6262
try {
63-
return type.newInstance();
63+
return type.getDeclaredConstructor().newInstance();
6464
} catch (Exception e) {
6565
throw new CantCreateInstanceException("error creating instance of class " + type.getName(), e);
6666
}

0 commit comments

Comments
 (0)