Skip to content

Commit

Permalink
Merge branch 'issue-208-replace-asm-with-bytebuddy-typepool'
Browse files Browse the repository at this point in the history
  • Loading branch information
jqno committed Dec 3, 2018
2 parents 6a08b44 + 73008fe commit 92036d2
Show file tree
Hide file tree
Showing 13 changed files with 213 additions and 266 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0


## [Unreleased]
### Changed
- Removed direct dependency on ASM by re-writing the annotation processor to Byte-Buddy. ([Issue 208](https://github.com/jqno/equalsverifier/issues/208))


<a name="3.x"/>
Expand Down
16 changes: 0 additions & 16 deletions pom.xml
Expand Up @@ -87,11 +87,6 @@
<artifactId>byte-buddy</artifactId>
<version>1.9.4</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>7.0</version>
</dependency>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-annotations</artifactId>
Expand Down Expand Up @@ -248,16 +243,11 @@
<minimizeJar>true</minimizeJar>
<artifactSet>
<includes>
<artifact>org.ow2.asm:asm</artifact>
<artifact>net.bytebuddy:byte-buddy</artifact>
<artifact>org.objenesis:objenesis</artifact>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>org.objectweb.asm</pattern>
<shadedPattern>nl.jqno.equalsverifier.internal.lib.asm</shadedPattern>
</relocation>
<relocation>
<pattern>net.bytebuddy</pattern>
<shadedPattern>nl.jqno.equalsverifier.internal.lib.bytebuddy</shadedPattern>
Expand All @@ -268,12 +258,6 @@
</relocation>
</relocations>
<filters>
<filter>
<artifact>org.objectweb.asm:*</artifact>
<excludes>
<exclude>META-INF/**</exclude>
</excludes>
</filter>
<filter>
<artifact>net.bytebuddy:*</artifact>
<excludes>
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/nl/jqno/equalsverifier/EqualsVerifierApi.java
Expand Up @@ -7,7 +7,6 @@
import nl.jqno.equalsverifier.internal.prefabvalues.FactoryCache;
import nl.jqno.equalsverifier.internal.util.*;
import nl.jqno.equalsverifier.internal.util.Formatter;
import org.objectweb.asm.Type;

import java.util.*;

Expand All @@ -29,7 +28,7 @@ public class EqualsVerifierApi<T> {
private Set<String> allExcludedFields = new HashSet<>();
private Set<String> allIncludedFields = new HashSet<>();
private Set<String> nonnullFields = new HashSet<>();
private Set<String> ignoredAnnotationDescriptors = new HashSet<>();
private Set<String> ignoredAnnotationClassNames = new HashSet<>();
private List<T> equalExamples = new ArrayList<>();
private List<T> unequalExamples = new ArrayList<>();

Expand Down Expand Up @@ -214,7 +213,7 @@ public EqualsVerifierApi<T> withNonnullFields(String... fields) {
public EqualsVerifierApi<T> withIgnoredAnnotations(Class<?>... annotations) {
validateAnnotationsAreValid(annotations);
for (Class<?> ignoredAnnotation : annotations) {
ignoredAnnotationDescriptors.add(Type.getDescriptor(ignoredAnnotation));
ignoredAnnotationClassNames.add(ignoredAnnotation.getCanonicalName());
}
return this;
}
Expand Down Expand Up @@ -389,7 +388,7 @@ private void performVerification() {
private Configuration<T> buildConfig() {
return Configuration.build(type, allExcludedFields, allIncludedFields, nonnullFields, cachedHashCodeInitializer,
hasRedefinedSuperclass, redefinedSubclass, usingGetClass, warningsToSuppress, factoryCache,
ignoredAnnotationDescriptors, actualFields, equalExamples, unequalExamples);
ignoredAnnotationClassNames, actualFields, equalExamples, unequalExamples);
}

private void verifyWithoutExamples(Configuration<T> config) {
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/nl/jqno/equalsverifier/internal/reflection/Util.java
@@ -1,5 +1,9 @@
package nl.jqno.equalsverifier.internal.reflection;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public final class Util {
private Util() {
// Do not instantiate
Expand Down Expand Up @@ -74,4 +78,16 @@ public static Object[] objects(Object first, Object second) {
public static Object[] objects(Object first, Object second, Object third) {
return new Object[] { first, second, third };
}

/**
* Helper method to create a set of object.
*
* @param ts The objects to add to the set.
* @param <T> The type of objects to add to the set.
* @return A set with the given objets.
*/
@SafeVarargs
public static <T> Set<T> setOf(T... ts) {
return new HashSet<>(Arrays.asList(ts));
}
}
Expand Up @@ -12,22 +12,27 @@
*/
public interface Annotation {
/**
* One or more strings that contain the annotation's class name. A
* descriptor can be the annotation's fully qualified canonical name, or a
* One or more strings that contain the annotation's (partial) class name.
* This can be the annotation's fully qualified canonical name, or a
* substring thereof.
*
* An annotation can be described by more than one descriptor. For
* An annotation can be described by more than one partial class name. For
* instance, @Nonnull, @NonNull and @NotNull have the same semantics; their
* descriptors can be grouped together in one {@link Annotation} instance.
* partialClassNames can be grouped together in one {@link Annotation}
* instance.
*
* @return An Iterable of annotation descriptor strings.
* @return A Set of potentially partial annotation class names.
*/
public Iterable<String> descriptors();
public Set<String> partialClassNames();

/**
* Whether the annotation applies to the class in which is appears only, or
* whether it applies to that class and all its subclasses.
*
* Note: this encompasses more than {@see java.lang.annotation.Inherited}
* does: this flag also applies, for example, to annotations on fields that
* are declared in a superclass.
*
* @return True if the annotation is inherited by subclasses of the class
* in which the annotation appears.
*/
Expand All @@ -38,7 +43,7 @@ public interface Annotation {
*
* @param properties An object that contains information about the annotation.
* @param annotationCache A cache containing all annotations for known types.
* @param ignoredAnnotations A collection of type descriptors for annotations
* @param ignoredAnnotations A collection of type partialClassNames for annotations
* to ignore.
* @return True if the annotation is valid and can be used as intended.
*/
Expand Down

0 comments on commit 92036d2

Please sign in to comment.