File tree Expand file tree Collapse file tree 3 files changed +7
-9
lines changed
mybatis-generator-maven-plugin/src/main/java/org/mybatis/generator/maven
mybatis-generator-systests-domtests/src/main/java/mbg/domtest
eclipse/org.mybatis.generator.eclipse.test.utilities/src/org/mybatis/generator/eclipse/test Expand file tree Collapse file tree 3 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ public void executeScript() throws MojoExecutionException {
79
79
80
80
try {
81
81
Class <?> driverClass = ObjectFactory .externalClassForName (driver );
82
- Driver theDriver = (Driver ) driverClass .newInstance ();
82
+ Driver theDriver = (Driver ) driverClass .getDeclaredConstructor (). newInstance ();
83
83
84
84
Properties properties = new Properties ();
85
85
if (userid != null ) {
@@ -114,10 +114,8 @@ public void executeScript() throws MojoExecutionException {
114
114
throw new MojoExecutionException ("SqlException: " + e .getMessage (), e );
115
115
} catch (IOException e ) {
116
116
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 ());
121
119
} finally {
122
120
closeConnection (connection );
123
121
}
Original file line number Diff line number Diff line change @@ -48,20 +48,20 @@ public static void main (String[] args) {
48
48
}
49
49
}
50
50
51
- private void gatherGenerators (List <CompilationUnitGenerator > generators ) throws InstantiationException , IllegalAccessException {
51
+ private void gatherGenerators (List <CompilationUnitGenerator > generators ) throws ReflectiveOperationException {
52
52
Reflections reflections = new Reflections ("mbg.domtest.generators" );
53
53
Set <Class <? extends CompilationUnitGenerator >> classes = reflections .getSubTypesOf (CompilationUnitGenerator .class );
54
54
55
55
for (Class <? extends CompilationUnitGenerator > clazz : classes ) {
56
56
if (clazz .getAnnotation (IgnoreDomTest .class ) == null ) {
57
- generators .add (clazz .newInstance ());
57
+ generators .add (clazz .getDeclaredConstructor (). newInstance ());
58
58
} else {
59
59
System .out .println ("Generator " + clazz .getName () + " ignored" );
60
60
}
61
61
}
62
62
}
63
63
64
- private void run (File outputDirectory ) throws IOException , InstantiationException , IllegalAccessException {
64
+ private void run (File outputDirectory ) throws IOException , ReflectiveOperationException {
65
65
setupOutputDirectry (outputDirectory );
66
66
67
67
List <CompilationUnitGenerator > generators = new ArrayList <>();
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ public static String getResourceAsString(InputStream resource) throws IOExceptio
60
60
61
61
public static <T > T newInstance (Class <? extends T > type ) {
62
62
try {
63
- return type .newInstance ();
63
+ return type .getDeclaredConstructor (). newInstance ();
64
64
} catch (Exception e ) {
65
65
throw new CantCreateInstanceException ("error creating instance of class " + type .getName (), e );
66
66
}
You can’t perform that action at this time.
0 commit comments