jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fschumac...@apache.org
Subject svn commit: r1847981 - in /jmeter/trunk/src: components/org/apache/jmeter/visualizers/ components/org/apache/jmeter/visualizers/backend/graphite/ core/org/apache/jmeter/ core/org/apache/jmeter/engine/util/ core/org/apache/jmeter/gui/ core/org/apache/jm...
Date Sun, 02 Dec 2018 11:23:44 GMT
Author: fschumacher
Date: Sun Dec  2 11:23:44 2018
New Revision: 1847981

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

Part of #435 and Bugzilla Id: 62972

Modified:
    jmeter/trunk/src/components/org/apache/jmeter/visualizers/RequestPanel.java
    jmeter/trunk/src/components/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java
    jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/graphite/GraphiteBackendListenerClient.java
    jmeter/trunk/src/core/org/apache/jmeter/NewDriver.java
    jmeter/trunk/src/core/org/apache/jmeter/engine/util/CompoundVariable.java
    jmeter/trunk/src/core/org/apache/jmeter/gui/GuiPackage.java
    jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/ReportGenerator.java
    jmeter/trunk/src/core/org/apache/jmeter/save/converters/TestElementConverter.java
    jmeter/trunk/src/core/org/apache/jmeter/save/converters/TestElementPropertyConverter.java
    jmeter/trunk/src/core/org/apache/jmeter/testelement/property/CollectionProperty.java
    jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/config/gui/JavaConfigGui.java

Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/RequestPanel.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/RequestPanel.java?rev=1847981&r1=1847980&r2=1847981&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/RequestPanel.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/RequestPanel.java Sun Dec  2
11:23:44 2018
@@ -63,7 +63,7 @@ public class RequestPanel {
         for (String clazz : classesToAdd) {
             try {
                 // Instantiate requestview classes
-                final RequestView requestView = (RequestView) Class.forName(clazz).newInstance();
+                final RequestView requestView = (RequestView) Class.forName(clazz).getDeclaredConstructor().newInstance();
                 if (rawTab.equals(requestView.getLabel())) {
                     rawObject = requestView; // use later
                 } else {

Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java?rev=1847981&r1=1847980&r2=1847981&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java
(original)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/ViewResultsFullVisualizer.java
Sun Dec  2 11:23:44 2018
@@ -459,7 +459,7 @@ implements ActionListener, TreeSelection
         for (String clazz : classesToAdd) {
             try {
                 // Instantiate render classes
-                final ResultRenderer renderer = (ResultRenderer) Class.forName(clazz).newInstance();
+                final ResultRenderer renderer = (ResultRenderer) Class.forName(clazz).getDeclaredConstructor().newInstance();
                 if (textRenderer.equals(renderer.toString())){
                     textObject=renderer;
                 }

Modified: jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/graphite/GraphiteBackendListenerClient.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/graphite/GraphiteBackendListenerClient.java?rev=1847981&r1=1847980&r2=1847981&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/graphite/GraphiteBackendListenerClient.java
(original)
+++ jmeter/trunk/src/components/org/apache/jmeter/visualizers/backend/graphite/GraphiteBackendListenerClient.java
Sun Dec  2 11:23:44 2018
@@ -340,7 +340,7 @@ public class GraphiteBackendListenerClie
             }
         }
         Class<?> clazz = Class.forName(graphiteMetricsSenderClass);
-        this.graphiteMetricsManager = (GraphiteMetricsSender) clazz.newInstance();
+        this.graphiteMetricsManager = (GraphiteMetricsSender) clazz.getDeclaredConstructor().newInstance();
         graphiteMetricsManager.setup(graphiteHost, graphitePort, rootMetricsPrefix);
         if (useRegexpForSamplersList) {
             pattern = Pattern.compile(samplersList);

Modified: jmeter/trunk/src/core/org/apache/jmeter/NewDriver.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/NewDriver.java?rev=1847981&r1=1847980&r2=1847981&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/NewDriver.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/NewDriver.java Sun Dec  2 11:23:44 2018
@@ -240,7 +240,7 @@ public final class NewDriver {
 
             try {
                 Class<?> initialClass = loader.loadClass("org.apache.jmeter.JMeter");//
$NON-NLS-1$
-                Object instance = initialClass.newInstance();
+                Object instance = initialClass.getDeclaredConstructor().newInstance();
                 Method startup = initialClass.getMethod("start", new Class[] { new String[0].getClass()
});// $NON-NLS-1$
                 startup.invoke(instance, new Object[] { args });
             } catch(Throwable e){ // NOSONAR We want to log home directory in case of exception

Modified: jmeter/trunk/src/core/org/apache/jmeter/engine/util/CompoundVariable.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/engine/util/CompoundVariable.java?rev=1847981&r1=1847980&r2=1847981&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/engine/util/CompoundVariable.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/engine/util/CompoundVariable.java Sun Dec  2 11:23:44
2018
@@ -72,7 +72,7 @@ public class CompoundVariable implements
             List<String> classes = ClassFinder.findClassesThatExtend(JMeterUtils.getSearchPaths(),
                     new Class[] { Function.class }, true, contain, notContain);
             for (String clazzName : classes) {
-                Function tempFunc = (Function) Class.forName(clazzName).newInstance();
+                Function tempFunc = (Function) Class.forName(clazzName).getDeclaredConstructor().newInstance();
                 String referenceKey = tempFunc.getReferenceKey();
                 if (referenceKey.length() > 0) { // ignore self
                     functions.put(referenceKey, tempFunc.getClass());
@@ -195,7 +195,7 @@ public class CompoundVariable implements
     static Object getNamedFunction(String functionName) throws InvalidVariableException {
         if (functions.containsKey(functionName)) {
             try {
-                return functions.get(functionName).newInstance();
+                return functions.get(functionName).getDeclaredConstructor().newInstance();
             } catch (Exception e) {
                 log.error("Exception occurred while instantiating a function: {}", functionName,
e); // $NON-NLS-1$
                 throw new InvalidVariableException(e);

Modified: jmeter/trunk/src/core/org/apache/jmeter/gui/GuiPackage.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/gui/GuiPackage.java?rev=1847981&r1=1847980&r2=1847981&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/gui/GuiPackage.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/gui/GuiPackage.java Sun Dec  2 11:23:44 2018
@@ -363,7 +363,7 @@ public final class GuiPackage implements
                     "Missing jar? See log file." ,
                     JOptionPane.ERROR_MESSAGE);
             throw new RuntimeException(e.toString(), e); // Probably a missing jar
-        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
e) {
+        } catch ( ReflectiveOperationException e) {
             log.error("Problem retrieving gui for " + objClass, e);
             throw new RuntimeException(e.toString(), e); // Programming error: bail out.
         }
@@ -389,9 +389,9 @@ public final class GuiPackage implements
      * @throws IllegalAccessException
      *             if access rights do not allow the default constructor to be
      *             called
+     * @throws ReflectiveOperationException when construction of guiClass fails
      */
-    private JMeterGUIComponent getGuiFromCache(Class<?> guiClass, Class<?> testClass)
throws InstantiationException,
-            IllegalAccessException {
+    private JMeterGUIComponent getGuiFromCache(Class<?> guiClass, Class<?> testClass)
throws ReflectiveOperationException {
         JMeterGUIComponent comp;
         if (guiClass == TestBeanGUI.class) {
             comp = testBeanGUIs.get(testClass);
@@ -402,7 +402,7 @@ public final class GuiPackage implements
         } else {
             comp = guis.get(guiClass);
             if (comp == null) {
-                comp = (JMeterGUIComponent) guiClass.newInstance();
+                comp = (JMeterGUIComponent) guiClass.getDeclaredConstructor().newInstance();
                 if (!(comp instanceof UnsharedComponent)) {
                     guis.put(guiClass, comp);
                 }
@@ -909,7 +909,7 @@ public final class GuiPackage implements
 
             try {
                 Class<?> implementationClass = Class.forName(namingPolicyImplementation);
-                this.namingPolicy = (TreeNodeNamingPolicy) implementationClass.newInstance();
+                this.namingPolicy = (TreeNodeNamingPolicy) implementationClass.getDeclaredConstructor().newInstance();
 
             } catch (Exception ex) {
                 log.error("Failed to create configured naming policy:" + namingPolicyImplementation
+ ", will use default one", ex);

Modified: jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/ReportGenerator.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/ReportGenerator.java?rev=1847981&r1=1847980&r2=1847981&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/ReportGenerator.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/report/dashboard/ReportGenerator.java Sun Dec
 2 11:23:44 2018
@@ -333,7 +333,7 @@ public class ReportGenerator {
         String className = graphConfiguration.getClassName();
         try {
             Class<?> clazz = Class.forName(className);
-            Object obj = clazz.newInstance();
+            Object obj = clazz.getDeclaredConstructor().newInstance();
             AbstractGraphConsumer graph = (AbstractGraphConsumer) obj;
             graph.setName(graphName);
             
@@ -358,8 +358,7 @@ public class ReportGenerator {
                     .excludesControllers() ? excludeControllerFilter
                     : nameFilter;
             entryPoint.addSampleConsumer(graph);
-        } catch (ClassNotFoundException | IllegalAccessException
-                | InstantiationException | ClassCastException ex) {
+        } catch (ClassCastException | IllegalArgumentException |  ReflectiveOperationException
| SecurityException ex) {
             String error = String.format(INVALID_CLASS_FMT, className);
             log.error(error, ex);
             throw new GenerationException(error, ex);
@@ -373,14 +372,13 @@ public class ReportGenerator {
         String className = exporterConfiguration.getClassName();
         try {
             Class<?> clazz = Class.forName(className);
-            Object obj = clazz.newInstance();
+            Object obj = clazz.getDeclaredConstructor().newInstance();
             DataExporter exporter = (DataExporter) obj;
             exporter.setName(exporterName);
 
             // Export data
             exporter.export(sampleContext, testFile, configuration);
-        } catch (ClassNotFoundException | IllegalAccessException
-                | InstantiationException | ClassCastException ex) {
+        } catch (ReflectiveOperationException | ClassCastException ex) {
             String error = String.format(INVALID_CLASS_FMT, className);
             throw new GenerationException(error, ex);
         } catch (ExportException ex) {

Modified: jmeter/trunk/src/core/org/apache/jmeter/save/converters/TestElementConverter.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/save/converters/TestElementConverter.java?rev=1847981&r1=1847980&r2=1847981&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/save/converters/TestElementConverter.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/save/converters/TestElementConverter.java Sun
Dec  2 11:23:44 2018
@@ -96,7 +96,7 @@ public class TestElementConverter extend
         }
         context.put(SaveService.TEST_CLASS_NAME, targetName); // needed by property converters
 (Bug 52466)
         try {
-            TestElement el = (TestElement) type.newInstance();
+            TestElement el = (TestElement) type.getDeclaredConstructor().newInstance();
             // No need to check version, just process the attributes if present
             ConversionHelp.restoreSpecialProperties(el, reader);
             // Slight hack - we need to ensure the TestClass is not reset by the previous
call
@@ -110,7 +110,7 @@ public class TestElementConverter extend
                 reader.moveUp();
             }
             return el;
-        } catch (InstantiationException | IllegalAccessException e) {
+        } catch (IllegalArgumentException | ReflectiveOperationException | SecurityException
e) {
             log.error("TestElement not instantiable: {}", type, e);
             return null;
         }

Modified: jmeter/trunk/src/core/org/apache/jmeter/save/converters/TestElementPropertyConverter.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/save/converters/TestElementPropertyConverter.java?rev=1847981&r1=1847980&r2=1847981&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/save/converters/TestElementPropertyConverter.java
(original)
+++ jmeter/trunk/src/core/org/apache/jmeter/save/converters/TestElementPropertyConverter.java
Sun Dec  2 11:23:44 2018
@@ -101,7 +101,7 @@ public class TestElementPropertyConverte
             prop.setName(ConversionHelp.decode(reader.getAttribute(ConversionHelp.ATT_NAME)));
             String element = reader.getAttribute(ConversionHelp.ATT_ELEMENT_TYPE);
             boolean isHeader = HEADER_CLASSNAME.equals(element);
-            prop.setObjectValue(mapper().realClass(element).newInstance());// Always decode
+            prop.setObjectValue(mapper().realClass(element).getDeclaredConstructor().newInstance());//
Always decode
             TestElement te = (TestElement)prop.getObjectValue();
             // No need to check version, just process the attributes if present
             ConversionHelp.restoreSpecialProperties(te, reader);
@@ -122,7 +122,7 @@ public class TestElementPropertyConverte
                 reader.moveUp();
             }
             return prop;
-        } catch (InstantiationException | IllegalAccessException e) {
+        } catch (IllegalArgumentException | ReflectiveOperationException | SecurityException
e) {
             log.error("Couldn't unmarshall TestElementProperty", e);
             return new TestElementProperty("ERROR", new ConfigTestElement());// $NON-NLS-1$
         }

Modified: jmeter/trunk/src/core/org/apache/jmeter/testelement/property/CollectionProperty.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/testelement/property/CollectionProperty.java?rev=1847981&r1=1847980&r2=1847981&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/testelement/property/CollectionProperty.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/testelement/property/CollectionProperty.java Sun
Dec  2 11:23:44 2018
@@ -143,7 +143,7 @@ public class CollectionProperty extends
     private Collection<JMeterProperty> cloneCollection() {
         try {
             @SuppressWarnings("unchecked") // value is of type Collection<JMeterProperty>
-            Collection<JMeterProperty> newCol = value.getClass().newInstance();
+            Collection<JMeterProperty> newCol = value.getClass().getDeclaredConstructor().newInstance();
             for (JMeterProperty jMeterProperty : this) {
                 newCol.add(jMeterProperty.clone());
             }

Modified: jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/config/gui/JavaConfigGui.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/config/gui/JavaConfigGui.java?rev=1847981&r1=1847980&r2=1847981&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/config/gui/JavaConfigGui.java
(original)
+++ jmeter/trunk/src/protocol/java/org/apache/jmeter/protocol/java/config/gui/JavaConfigGui.java
Sun Dec  2 11:23:44 2018
@@ -190,7 +190,7 @@ public class JavaConfigGui extends Abstr
         String className = classNameLabeledChoice.getText().trim();
         try {
             JavaSamplerClient client = (JavaSamplerClient) Class.forName(className, true,
-                    Thread.currentThread().getContextClassLoader()).newInstance();
+                    Thread.currentThread().getContextClassLoader()).getDeclaredConstructor().newInstance();
 
             Arguments currArgs = new Arguments();
             argsPanel.modifyTestElement(currArgs);
@@ -270,7 +270,7 @@ public class JavaConfigGui extends Abstr
     private boolean classOk(String className) {
         try {
             JavaSamplerClient client = (JavaSamplerClient) Class.forName(className, true,
-                    Thread.currentThread().getContextClassLoader()).newInstance();
+                    Thread.currentThread().getContextClassLoader()).getDeclaredConstructor().newInstance();
             // Just to use client
             return client != null;
         } catch (Exception ex) {



Mime
View raw message