Skip to content

Commit 47cc4c7

Browse files
committed
[refactor] Use new way to get clazz.newInstance()
1 parent ac11d8e commit 47cc4c7

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

exist-ant/src/main/java/org/exist/ant/AbstractXMLDBTask.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ protected void registerDatabase() throws BuildException
167167
}
168168

169169
final Class<?> clazz = Class.forName( driver );
170-
final Database database = (Database)clazz.newInstance();
170+
final Database database = (Database)clazz.getDeclaredConstructor().newInstance();
171171
database.setProperty( "create-database", createDatabase ? "true" : "false" );
172172
database.setProperty( "ssl-enable", ssl ? "true" : "false" );
173173

extensions/modules/scheduler/src/main/java/org/exist/xquery/modules/scheduler/ScheduleFunctions.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.exist.xquery.XQueryContext;
3838
import org.exist.xquery.value.*;
3939

40+
import java.lang.reflect.InvocationTargetException;
4041
import java.util.Properties;
4142

4243

@@ -312,15 +313,16 @@ else if( isCalledAs( SCHEDULE_JAVA_CRON_JOB ) || isCalledAs( SCHEDULE_JAVA_PERIO
312313

313314
//Check if the Class is a UserJob
314315
Class<?> jobClass = Class.forName( resource );
315-
job = jobClass.newInstance();
316+
job = jobClass.getDeclaredConstructor().newInstance();
316317

317318
if( !( job instanceof UserJavaJob ) ) {
318319
LOG.error("Cannot Schedule job. Class {} is not an instance of org.exist.scheduler.UserJavaJob", resource);
319320
return( BooleanValue.FALSE );
320321
}
321322
( ( UserJavaJob )job ).setName( jobName );
322323
}
323-
catch( ClassNotFoundException | InstantiationException | IllegalAccessException cnfe ) {
324+
catch(ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException |
325+
InvocationTargetException cnfe ) {
324326
LOG.error( cnfe );
325327
return( BooleanValue.FALSE );
326328
}

0 commit comments

Comments
 (0)