You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by fs...@apache.org on 2018/12/02 11:19:45 UTC
svn commit: r1847977 - in /jmeter/trunk/src:
core/org/apache/jmeter/testelement/AbstractTestElement.java
core/org/apache/jmeter/testelement/property/AbstractProperty.java
protocol/http/org/apache/jmeter/protocol/http/parser/BaseParser.java
Author: fschumacher
Date: Sun Dec 2 11:19:45 2018
New Revision: 1847977
URL: http://svn.apache.org/viewvc?rev=1847977&view=rev
Log:
Replace calls to deprecated Class#newInstance method
Part of #435 and Bugzilla Id: 62972
Modified:
jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractTestElement.java
jmeter/trunk/src/core/org/apache/jmeter/testelement/property/AbstractProperty.java
jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/BaseParser.java
Modified: jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractTestElement.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractTestElement.java?rev=1847977&r1=1847976&r2=1847977&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractTestElement.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/testelement/AbstractTestElement.java Sun Dec 2 11:19:45 2018
@@ -71,7 +71,7 @@ public abstract class AbstractTestElemen
@Override
public Object clone() {
try {
- TestElement clonedElement = this.getClass().newInstance();
+ TestElement clonedElement = this.getClass().getDeclaredConstructor().newInstance();
PropertyIterator iter = propertyIterator();
while (iter.hasNext()) {
@@ -79,7 +79,7 @@ public abstract class AbstractTestElemen
}
clonedElement.setRunningVersion(runningVersion);
return clonedElement;
- } catch (InstantiationException | IllegalAccessException e) {
+ } catch (IllegalArgumentException | ReflectiveOperationException | SecurityException e) {
throw new AssertionError(e); // clone should never return null
}
}
Modified: jmeter/trunk/src/core/org/apache/jmeter/testelement/property/AbstractProperty.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/core/org/apache/jmeter/testelement/property/AbstractProperty.java?rev=1847977&r1=1847976&r2=1847977&view=diff
==============================================================================
--- jmeter/trunk/src/core/org/apache/jmeter/testelement/property/AbstractProperty.java (original)
+++ jmeter/trunk/src/core/org/apache/jmeter/testelement/property/AbstractProperty.java Sun Dec 2 11:19:45 2018
@@ -255,7 +255,7 @@ public abstract class AbstractProperty i
protected JMeterProperty getBlankProperty() {
try {
- JMeterProperty prop = getPropertyType().newInstance();
+ JMeterProperty prop = getPropertyType().getDeclaredConstructor().newInstance();
if (prop instanceof NullProperty) {
return new StringProperty();
}
@@ -295,7 +295,7 @@ public abstract class AbstractProperty i
protected Collection<JMeterProperty> normalizeList(Collection<?> coll) {
try {
@SuppressWarnings("unchecked") // empty collection
- Collection<JMeterProperty> newColl = coll.getClass().newInstance();
+ Collection<JMeterProperty> newColl = coll.getClass().getDeclaredConstructor().newInstance();
for (Object item : coll) {
newColl.add(convertObject(item));
}
@@ -317,7 +317,7 @@ public abstract class AbstractProperty i
protected Map<String, JMeterProperty> normalizeMap(Map<?,?> coll) {
try {
@SuppressWarnings("unchecked") // empty collection
- Map<String, JMeterProperty> newColl = coll.getClass().newInstance();
+ Map<String, JMeterProperty> newColl = coll.getClass().getDeclaredConstructor().newInstance();
for (Map.Entry<?,?> entry : coll.entrySet()) {
Object key = entry.getKey();
Object prop = entry.getValue();
Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/BaseParser.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/BaseParser.java?rev=1847977&r1=1847976&r2=1847977&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/BaseParser.java (original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/parser/BaseParser.java Sun Dec 2 11:19:45 2018
@@ -63,14 +63,13 @@ public abstract class BaseParser impleme
}
try {
- Object clazz = Class.forName(parserClassName).newInstance();
+ Object clazz = Class.forName(parserClassName).getDeclaredConstructor().newInstance();
if (clazz instanceof LinkExtractorParser) {
parser = (LinkExtractorParser) clazz;
} else {
throw new LinkExtractorParseException(new ClassCastException(parserClassName));
}
- } catch (InstantiationException | ClassNotFoundException
- | IllegalAccessException e) {
+ } catch (IllegalArgumentException | ReflectiveOperationException | SecurityException e) {
throw new LinkExtractorParseException(e);
}
LOG.info("Created " + parserClassName);