Skip to content

Commit

Permalink
Replace calls to deprecated Class#newInstance
Browse files Browse the repository at this point in the history
Part of apache#435 and Bugzilla Id: 62972


git-svn-id: https://svn.apache.org/repos/asf/jmeter/trunk@1847964 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
FSchumacher committed Dec 2, 2018
1 parent d08e486 commit 431108b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/core/org/apache/jmeter/gui/action/ActionRouter.java
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ public void populateCommandMap() {
}
for (String strClassName : listClasses) {
Class<?> commandClass = Class.forName(strClassName);
Command command = (Command) commandClass.newInstance();
Command command = (Command) commandClass.getDeclaredConstructor().newInstance();
for (String commandName : command.getActionNames()) {
Set<Command> commandObjects = commands.computeIfAbsent(commandName, k -> new HashSet<>());
commandObjects.add(command);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,13 @@ private void addNodesToTreeHierachically(GuiPackage guiPackage,
* @param guiPackage {@link GuiPackage}
* @param parentNode {@link JMeterTreeNode}
* @return array of {@link JMeterTreeNode}
* @throws IllegalUserActionException
* @throws ReflectiveOperationException when class instantiation for {@value #DEFAULT_IMPLEMENTATION} fails
* @throws IllegalUserActionException when {@link ThinkTimeCreator#createThinkTime(GuiPackage, JMeterTreeNode)} throws this
*/
private JMeterTreeNode[] createThinkTime(GuiPackage guiPackage, JMeterTreeNode parentNode)
throws Exception {
private JMeterTreeNode[] createThinkTime(GuiPackage guiPackage, JMeterTreeNode parentNode)
throws ReflectiveOperationException, IllegalUserActionException {
Class<?> clazz = Class.forName(DEFAULT_IMPLEMENTATION);
ThinkTimeCreator thinkTimeCreator = (ThinkTimeCreator) clazz.newInstance();
ThinkTimeCreator thinkTimeCreator = (ThinkTimeCreator) clazz.getDeclaredConstructor().newInstance();
return thinkTimeCreator.createThinkTime(guiPackage, parentNode);
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/org/apache/jmeter/util/BeanShellInterpreter.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ private void init() throws ClassNotFoundException {
throw new ClassNotFoundException(BSH_INTERPRETER);
}
try {
bshInstance = bshClass.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
bshInstance = bshClass.getDeclaredConstructor().newInstance();
} catch (IllegalArgumentException | ReflectiveOperationException | SecurityException e) {
log.error("Can't instantiate BeanShell", e);
throw new ClassNotFoundException("Can't instantiate BeanShell", e);
}
Expand Down
5 changes: 2 additions & 3 deletions test/src/org/apache/jorphan/test/AllTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -308,11 +308,10 @@ private static void initializeManager(String[] args) {
if (args.length >= 3) {
try {
System.out.println("Using initializeProperties() from " + args[2]);
UnitTestManager um = (UnitTestManager) Class.forName(args[2]).newInstance();
UnitTestManager um = (UnitTestManager) Class.forName(args[2]).getDeclaredConstructor().newInstance();
System.out.println("Setting up initial properties using: " + args[1]);
um.initializeProperties(args[1]);
} catch (ClassNotFoundException | IllegalAccessException
| InstantiationException e) {
} catch (IllegalArgumentException | ReflectiveOperationException | SecurityException e) {
System.out.println("Couldn't create: " + args[2]);
e.printStackTrace();
}
Expand Down

0 comments on commit 431108b

Please sign in to comment.