Author: fschumacher
Date: Sun Dec  2 11:09:06 2018
New Revision: 1847964

URL: http://svn.apache.org/viewvc?rev=1847964&view=rev
Log:
Replace calls to deprecated Class#newInstance

Part of #435 and Bugzilla Id: 62972

Modified:
    jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionRouter.java
    
jmeter/trunk/src/core/org/apache/jmeter/gui/action/AddThinkTimeBetweenEachStep.java
    jmeter/trunk/src/core/org/apache/jmeter/util/BeanShellInterpreter.java
    jmeter/trunk/test/src/org/apache/jorphan/test/AllTests.java

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionRouter.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionRouter.java?rev=1847964&r1=1847963&r2=1847964&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionRouter.java 
(original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/action/ActionRouter.java Sun 
Dec  2 11:09:06 2018
@@ -369,7 +369,7 @@ public final class ActionRouter implemen
             }
             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);

Modified: 
jmeter/trunk/src/core/org/apache/jmeter/gui/action/AddThinkTimeBetweenEachStep.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/action/AddThinkTimeBetweenEachStep.java?rev=1847964&r1=1847963&r2=1847964&view=diff
==============================================================================
--- 
jmeter/trunk/src/core/org/apache/jmeter/gui/action/AddThinkTimeBetweenEachStep.java
 (original)
+++ 
jmeter/trunk/src/core/org/apache/jmeter/gui/action/AddThinkTimeBetweenEachStep.java
 Sun Dec  2 11:09:06 2018
@@ -132,12 +132,13 @@ public class AddThinkTimeBetweenEachStep
      * @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);
     }
     

Modified: jmeter/trunk/src/core/org/apache/jmeter/util/BeanShellInterpreter.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/util/BeanShellInterpreter.java?rev=1847964&r1=1847963&r2=1847964&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/util/BeanShellInterpreter.java 
(original)
+++ jmeter/trunk/src/core/org/apache/jmeter/util/BeanShellInterpreter.java Sun 
Dec  2 11:09:06 2018
@@ -114,8 +114,8 @@ public class BeanShellInterpreter {
             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);
         } 

Modified: jmeter/trunk/test/src/org/apache/jorphan/test/AllTests.java
URL: 
http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jorphan/test/AllTests.java?rev=1847964&r1=1847963&r2=1847964&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jorphan/test/AllTests.java (original)
+++ jmeter/trunk/test/src/org/apache/jorphan/test/AllTests.java Sun Dec  2 
11:09:06 2018
@@ -308,11 +308,10 @@ public final class AllTests {
         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();
             }


Reply via email to