This is an automated email from the ASF dual-hosted git repository.
fokko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git
The following commit(s) were added to refs/heads/master by this push:
new b64081e AVRO-2192: Remove paranamer dependency from Avro (#400)
b64081e is described below
commit b64081ee174e5b5aefcd93c3bc6c5aefe6acbf49
Author: Ismaël Mejía <[email protected]>
AuthorDate: Wed Dec 5 08:11:54 2018 +0100
AVRO-2192: Remove paranamer dependency from Avro (#400)
---
lang/java/avro/pom.xml | 24 -------------
.../java/org/apache/avro/reflect/ReflectData.java | 41 +++++++---------------
lang/java/pom.xml | 22 ++----------
.../java/tools/src/main/resources/META-INF/LICENSE | 30 ----------------
4 files changed, 15 insertions(+), 102 deletions(-)
diff --git a/lang/java/avro/pom.xml b/lang/java/avro/pom.xml
index 0eb3685..d04c055 100644
--- a/lang/java/avro/pom.xml
+++ b/lang/java/avro/pom.xml
@@ -38,7 +38,6 @@
<osgi.import>
!org.apache.avro*,
com.fasterxml.jackson*,
- com.thoughtworks.paranamer;resolution:=optional,
org.xerial.snappy;resolution:=optional,
sun.misc;resolution:=optional,
*
@@ -57,24 +56,6 @@
</resources>
<plugins>
<plugin>
- <groupId>com.thoughtworks.paranamer</groupId>
- <artifactId>paranamer-maven-plugin</artifactId>
- <version>${paranamer.version}</version>
- <executions>
- <execution>
- <id>paranamer-test</id>
- <configuration>
-
<sourceDirectory>${project.build.testSourceDirectory}</sourceDirectory>
-
<outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
- </configuration>
- <phase>process-test-classes</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
@@ -147,11 +128,6 @@
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
- <groupId>com.thoughtworks.paranamer</groupId>
- <artifactId>paranamer</artifactId>
- <optional>true</optional>
- </dependency>
- <dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
</dependency>
diff --git
a/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java
b/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java
index 3e9e079..6e9b779 100644
--- a/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java
+++ b/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java
@@ -24,6 +24,7 @@ import java.lang.reflect.Field;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
+import java.lang.reflect.Parameter;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.nio.ByteBuffer;
@@ -38,7 +39,6 @@ import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.function.Function;
import org.apache.avro.AvroRemoteException;
import org.apache.avro.AvroRuntimeException;
@@ -763,11 +763,11 @@ public class ReflectData extends SpecificData {
return schema;
}
- /** Return the protocol for a Java interface.
- * <p>Note that this requires that <a
- * href="http://paranamer.codehaus.org/">Paranamer</a> is run over compiled
- * interface declarations, since Java 6 reflection does not provide access to
- * method parameter names. See Avro's build.xml for an example. */
+ /**
+ * Return the protocol for a Java interface.
+ * <p>The correct name of the method parameters needs the
<code>-parameters</code>
+ * java compiler argument. More info at https://openjdk.java.net/jeps/118
+ */
@Override
public Protocol getProtocol(Class iface) {
Protocol protocol =
@@ -792,32 +792,15 @@ public class ReflectData extends SpecificData {
return protocol;
}
- private Function<Method, String[]> paranamer;
- private synchronized Function<Method, String[]> getParanamer() {
- if (paranamer == null) {
- try {
- final com.thoughtworks.paranamer.CachingParanamer p = new
com.thoughtworks.paranamer.CachingParanamer();
- paranamer = new Function<Method, String[]>() {
- public String[] apply(Method t) {
- return p.lookupParameterNames(t);
- }
- };
- } catch (Throwable t) {
- paranamer = new Function<Method, String[]>() {
- public String[] apply(Method t) {
- return new String[0];
- }
- };
- }
- }
- return paranamer;
- }
-
private String[] getParameterNames(Method m) {
- return getParanamer().apply(m);
+ Parameter[] parameters = m.getParameters();
+ String[] paramNames = new String[parameters.length];
+ for (int i = 0; i < parameters.length; i++) {
+ paramNames[i] = parameters[i].getName();
+ }
+ return paramNames;
}
-
private Message getMessage(Method method, Protocol protocol,
Map<String,Schema> names) {
List<Schema.Field> fields = new ArrayList<>();
diff --git a/lang/java/pom.xml b/lang/java/pom.xml
index 773d71c..9d64b6e 100644
--- a/lang/java/pom.xml
+++ b/lang/java/pom.xml
@@ -44,7 +44,6 @@
<jopt-simple.version>5.0.4</jopt-simple.version>
<junit.version>4.12</junit.version>
<netty.version>3.10.6.Final</netty.version>
- <paranamer.version>2.8</paranamer.version>
<protobuf.version>2.6.1</protobuf.version>
<thrift.version>0.9.3</thrift.version>
<slf4j.version>1.7.25</slf4j.version>
@@ -110,6 +109,9 @@
<configuration>
<source>1.8</source>
<target>1.8</target>
+ <compilerArgs>
+ <arg>-parameters</arg>
+ </compilerArgs>
</configuration>
</plugin>
<plugin>
@@ -353,19 +355,6 @@
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
- <groupId>com.thoughtworks.paranamer</groupId>
- <artifactId>paranamer-maven-plugin</artifactId>
- <versionRange>[${paranamer.version},)</versionRange>
- <goals>
- <goal>generate</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <ignore />
- </action>
- </pluginExecution>
- <pluginExecution>
- <pluginExecutionFilter>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<versionRange>[${project.version},)</versionRange>
@@ -455,11 +444,6 @@
<version>${jackson.version}</version>
</dependency>
<dependency>
- <groupId>com.thoughtworks.paranamer</groupId>
- <artifactId>paranamer</artifactId>
- <version>${paranamer.version}</version>
- </dependency>
- <dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId>
<version>${velocity.version}</version>
diff --git a/lang/java/tools/src/main/resources/META-INF/LICENSE
b/lang/java/tools/src/main/resources/META-INF/LICENSE
index 550260d..eba2996 100644
--- a/lang/java/tools/src/main/resources/META-INF/LICENSE
+++ b/lang/java/tools/src/main/resources/META-INF/LICENSE
@@ -271,36 +271,6 @@ SLF4J license text (MIT):
| WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
----------------------------------------------------------------------
-License for paranamer, included in this binary artifact:
-
-Copyright (c) 2006 Paul Hammant & ThoughtWorks Inc
-All rights reserved.
-
-| Redistribution and use in source and binary forms, with or without
-| modification, are permitted provided that the following conditions
-| are met:
-| 1. Redistributions of source code must retain the above copyright
-| notice, this list of conditions and the following disclaimer.
-| 2. Redistributions in binary form must reproduce the above copyright
-| notice, this list of conditions and the following disclaimer in the
-| documentation and/or other materials provided with the distribution.
-| 3. Neither the name of the copyright holders nor the names of its
-| contributors may be used to endorse or promote products derived from
-| this software without specific prior written permission.
-|
-| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-| AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-| IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-| ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-| LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-| CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-| INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-| CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-| ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
-| THE POSSIBILITY OF SUCH DAMAGE.
-
-----------------------------------------------------------------------
License for snappy-java, included in this binary artifact:
Copyright: 2011 Taro L. Saito and other contributors