Giter Site home page Giter Site logo

reflections's Introduction

❗ Please note: Reflections library is currently NOT under active development or maintenance ❗

Thank you for your continuous support!
There are open issues and also workarounds. Release version will be considered incase contributing PR fixing the main issues.

Last released org.reflections:reflections:0.10.2 (Oct 2021)


Java runtime metadata analysis

Build Status

Reflections scans and indexes your project's classpath metadata, allowing reverse transitive query of the type system on runtime.

Using Reflections you can query for example:

  • Subtypes of a type
  • Types annotated with an annotation
  • Methods with annotation, parameters, return type
  • Resources found in classpath
    And more...

Reflections was written in the spirit of Scannotations library

Usage

Add Reflections dependency to your project:

# Maven
<dependency>
    <groupId>org.reflections</groupId>
    <artifactId>reflections</artifactId>
    <version>0.10.2</version>
</dependency>

# Gradle
implementation 'org.reflections:reflections:0.10.2'

Create Reflections instance and use the query functions:

Reflections reflections = new Reflections("com.my.project");

Set<Class<?>> subTypes =
  reflections.get(SubTypes.of(SomeType.class).asClass());

Set<Class<?>> annotated = 
  reflections.get(SubTypes.of(TypesAnnotated.with(SomeAnnotation.class)).asClass());

Or using previous 0.9.x APIs, for example:

Set<Class<? extends SomeType>> subTypes =
  reflections.getSubTypesOf(SomeType.class);

Set<Class<?>> annotated = 
  reflections.getTypesAnnotatedWith(SomeAnnotation.class);

Note that there are some breaking changes with Reflections 0.10+, along with performance improvements and more functional API, see below.

Scan

Creating Reflections instance requires ConfigurationBuilder, typically configured with packages and Scanners to use:

// typical usage: scan package with the default scanners SubTypes, TypesAnnotated
Reflections reflections = new Reflections(
  new ConfigurationBuilder()
    .forPackage("com.my.project")
    .filterInputsBy(new FilterBuilder().includePackage("com.my.project")));

Other examples:

import static org.reflections.scanners.Scanners.*;

// scan package with specific scanners
Reflections reflections = new Reflections(
  new ConfigurationBuilder()
    .forPackage("com.my.project")
    .filterInputsBy(new FilterBuilder().includePackage("com.my.project").excludePackage("com.my.project.exclude"))
    .setScanners(TypesAnnotated, MethodsAnnotated, MethodsReturn));

Note that:

  • Scanner must be configured in order to be queried, otherwise an empty result is returned
    If not specified, default scanners will be used SubTypes, TypesAnnotated.
    For all standard scanners use Scanners.values(). See more scanners in the source package.
  • All relevant URLs should be configured
    Consider .filterInputsBy() in case too many classes are scanned.
    If required, Reflections will expand super types in order to get the transitive closure metadata without scanning large 3rd party urls.
  • Classloader can optionally be used for resolving runtime classes from names.

Query

Once Reflections was instantiated and scanning was successful, it can be used for querying the indexed metadata.

import static org.reflections.scanners.Scanners.*;

// SubTypes
Set<Class<?>> modules = 
  reflections.get(SubTypes.of(Module.class).asClass());

// TypesAnnotated (*1)
Set<Class<?>> singletons = 
  reflections.get(TypesAnnotated.with(Singleton.class).asClass());

// MethodsAnnotated
Set<Method> resources =
  reflections.get(MethodsAnnotated.with(GetMapping.class).as(Method.class));

// FieldsAnnotated
Set<Field> ids = 
  reflections.get(FieldsAnnotated.with(Id.class).as(Field.class));

// Resources
Set<String> properties = 
  reflections.get(Resources.with(".*\\.properties"));

More scanners:

// MethodsReturn
Set<Method> voidMethods = 
  reflections.get(MethodsReturn.with(void.class).as(Method.class));

// MethodsSignature
Set<Method> someMethods = 
  reflections.get(MethodsSignature.of(long.class, int.class).as(Method.class));

// MethodsParameter
Set<Method> pathParam = 
  reflections.get(MethodsParameter.of(PathParam.class).as(Method.class));

// ConstructorsAnnotated
Set<Constructor> injectables =
  reflections.get(ConstructorsAnnotated.with(Inject.class).as(Constructor.class));

// ConstructorsSignature
Set<Constructor> someConstructors = 
  reflections.get(ConstructorsSignature.of(String.class).as(Constructor.class));

// MethodParameterNamesScanner
List<String> parameterNames =
  reflections.getMemberParameterNames(member);

// MemberUsageScanner
Set<Member> usages =
  reflections.getMemberUsages(member)

See more examples in ReflectionsQueryTest.

Note that previous 0.9.x APIs are still supported

Compare Scanners and previous 0.9.x API (*)
Scanners previous 0.9.x API previous Scanner
get(SubType.of(T)) getSubTypesOf(T) SubTypesScanner
get(SubTypes.of(
    TypesAnnotated.with(A)))
getTypesAnnotatedWith(A) (1) TypeAnnotationsScanner
get(MethodsAnnotated.with(A)) getMethodsAnnotatedWith(A) MethodAnnotationsScanner
get(ConstructorsAnnotated.with(A)) getConstructorsAnnotatedWith(A) (2) MethodAnnotationsScanner
get(FieldsAnnotated.with(A)) getFieldsAnnotatedWith(A) FieldAnnotationsScanner
get(Resources.with(regex)) getResources(regex) ResourcesScanner
get(MethodsParameter.with(P)) getMethodsWithParameter(P) (3)
getMethodsWithAnyParamAnnotated(P)
MethodParameterScanner
obsolete
get(MethodsSignature.of(P, ...)) getMethodsWithSignature(P, ...) (3)
getMethodsMatchParams(P, ...)
"
get(MethodsReturn.of(T)) getMethodsReturn(T) (3) "
get(ConstructorsParameter.with(P)) getConstructorsWithParameter(P) (3)
getConstructorsWithAnyParamAnnotated(P)
"
get(ConstructorsSignature.of(P, ...)) getConstructorsWithSignature(P, ...) (3)
getConstructorsMatchParams(P, ...)
"

Note: asClass() and as() mappings were omitted

(1): The equivalent of getTypesAnnotatedWith(A) is get(SubTypes.of(TypesAnnotated.with(A))), including SubTypes

(2): MethodsAnnotatedScanner does not include constructor annotation scanning, use instead Scanners.ConstructorsAnnotated

(3): MethodParameterScanner is obsolete, use instead as required:
Scanners.MethodsParameter, Scanners.MethodsSignature, Scanners.MethodsReturn, Scanners.ConstructorsParameter, Scanners.ConstructorsSignature

ReflectionUtils

Apart from scanning classpath metadata using Javassist, Java Reflection convenient methods are available using ReflectionsUtils:

import static org.reflections.ReflectionUtils.*;

Set<Class<?>>    superTypes   = get(SuperTypes.of(T));
Set<Field>       fields       = get(Fields.of(T));
Set<Constructor> constructors = get(Constructors.of(T));
Set<Methods>     methods      = get(Methods.of(T));
Set<URL>         resources    = get(Resources.with(T));

Set<Annotation>  annotations  = get(Annotations.of(T));
Set<Class<? extends Annotation>> annotationTypes = get(AnnotationTypes.of(T));

Previous ReflectionUtils 0.9.x API is still supported though marked for removal, more info in the javadocs.

Query API

Each Scanner and ReflectionUtils function implements QueryBuilder, and supports:

  • get() - function returns direct values
  • with() or of() - function returns all transitive values

For example, Scanners.SubTypes.get(T) return direct subtypes, while Scanners.SubTypes.of(T) return transitive subtypes hierarchy. Same goes for Scanners.TypesAnnotated and ReflectionUtils.SuperTypes etc.

Next, each function implements QueryFunction, and provides fluent functional interface for composing filter(), map(), flatMap(), as() and more, such that:

// filter, as/map
QueryFunction<Store, Method> getters =
  Methods.of(C1.class)
    .filter(withModifier(Modifier.PUBLIC))
    .filter(withPrefix("get").and(withParametersCount(0)))
    .as(Method.class);

// compose Scanners and ReflectionUtils functions 
QueryFunction<Store, Method> methods = 
  SubTypes.of(type).asClass()  // <-- classpath scanned metadata
    .flatMap(Methods::of);     // <-- java reflection api

// function of function
QueryFunction<Store, Class<? extends Annotation>> queryAnnotations = 
  Annotations.of(Methods.of(C4.class))
    .map(Annotation::annotationType);

See more in ReflectionUtilsQueryTest

A more complex example demonstrates getting merged annotations of rest controllers endpoints:

// get all annotations of RequestMapping hierarchy (GetMapping, PostMapping, ...)
Set<Class<?>> metaAnnotations =
  reflections.get(TypesAnnotated.getAllIncluding(RequestMapping.class.getName()).asClass());

QueryFunction<Store, Map<String, Object>> queryAnnotations =
  // get all controller endpoint methods      
  MethodsAnnotated.with(metaAnnotations).as(Method.class)
    .map(method ->
      // get both method's + declaring class's RequestMapping annotations   
      get(Annotations.of(method.getDeclaringClass())
        .add(Annotations.of(method))
        .filter(a -> metaAnnotations.contains(a.annotationType())))
        .stream()
        // merge annotations' member values into a single hash map
        .collect(new AnnotationMergeCollector(method)));

// apply query and map merged hashmap into java annotation proxy
Set<RequestMapping> mergedAnnotations = 
  reflections.get(mergedAnnotation
    .map(map -> ReflectionUtils.toAnnotation(map, metaAnnotation)));

Check the tests folder for more examples and API usage

What else?

  • Integrating with build lifecycle
    It is sometime useful to Reflections.save() the scanned metadata into xml/json as part of the build lifecycle for generating resources, and then collect it on bootstrap with Reflections.collect() and avoid scanning. See reflections-maven for example.
  • JavaCodeSerializer - scanned metadata can be persisted into a generated Java source code. Although less common, it can be useful for accessing types and members in a strongly typed manner. (see example)
  • AnnotationMergeCollector - can be used to merge similar annotations. (see test)
  • MemberUsageScanner - experimental scanner allow querying for member usages getMemberUsages() of packages/types/elements in the classpath. Can be used for finding usages between packages, layers, modules, types etc.

Spread the spirit of open-source and collaboration, clean code and simplicity

reflections's People

Contributors

actong avatar alinkov avatar argggh avatar cschneider avatar dependabot[bot] avatar framiere avatar g7r avatar ge0ffrey avatar ht290 avatar jackielii avatar jodastephen avatar jotomo avatar kaxelson avatar kennymacleod avatar markkolich avatar michael-schnell avatar nigelsim avatar rapster avatar robertotru avatar ronmamo avatar srowen avatar sschuberth avatar stephan202 avatar valentinsviridov avatar wolf480pl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

reflections's Issues

Annotations are missing on found classes ...

It seems that classes identified with the following code are VERY sparse in the result:

final Set<Class<?>> classes = new Reflections("some.package").getTypesAnnotatedWith(SomeAnnotation.class);

That goes fine ... but when inspecting the result the 'annotation' variable in the following code the annotation variable is null. Is that on purpose?

    for(Class<?> someClass : classes)
    {
        SomeAnnotation annotation = someClass.getClass().getAnnotation(SomeAnnotation.class);

I'm using v0.9.9-RC1

JarInputFile is broken for class files with size < BufferedInputStream buffer size (8192)

    public InputStream openInputStream() throws IOException {
        return new InputStream() {
            @Override
            public int read() throws IOException {
                if (jarInputDir.cursor >= fromIndex && jarInputDir.cursor <= endIndex) {
                    int read = jarInputDir.jarInputStream.read();
                    jarInputDir.cursor++;
                    return read;
                } else {
                    throw new ReflectionsException("could not read input stream, cursor beyond endInputStream");
                }
            }
        };
    }

This implementation breaks InputStream contract for read() which says:

Returns:
the next byte of data, or -1 if the end of the stream is reached.

Javassist uses BufferedInputStream internally to read class info, and BufferedInputStream tries to fill it's buffer which is 8192 bytes. So if class file size is less than 8192 bytes we get ReflectionsException.

Solution: obey the contract and return -1 if cursor>endIndex.

getTypesAnnotatedWith with false default for "honorInherited"

Hello,

first of all thanks for this very useful library! If I understand the documentation at

http://reflections.googlecode.com/svn/trunk/reflections/javadoc/apidocs/index.html?org/reflections/Reflections.html

correct - the behavior between 0.9.8 and 0.9.9 should be the same while calling the method "getTypesAnnotatedWith(SomeAnnotation.class)". I think this should be redirected to: "getTypesAnnotatedWith(SomeAnnotation.class, true)" - like documentation describes. But it is redirected to "getTypesAnnotatedWith(SomeAnnoation.class, false)".

Since 0.9.9 all SubTypes of "really" annotated class/ interface are returned, at 0.9.8 only the "really" annotated class/ interface was returned - not the implementing or extending classes of this interface containing the annotation.

If I'm right it would be great if you can fix this little error.

Best regards

Oli

ConfigurationBuilder.build() violates the principle of least surprise

I tried to use ConfigurationBuilder to add MethodAnnotationsScanner to my Reflections instance, but encountered some behavior that violates my principle of least surprise.

Here's what I wrote:

    return new Reflections(new ConfigurationBuilder()
                           .setScanners(new MethodAnnotationsScanner(),
                                        new SubTypesScanner(),
                                        new TypeAnnotationsScanner())
                           .build());

I was very annoyed to find that I was still unable to call getMethodsAnnotatedWith() on this Reflections instance. After digging through the code, I discovered that ConfigurationBuilder is a nonstandard application of the builder pattern. Rather than encapsulating mutable state and producing an immutable Configuration when you call .build(), the ConfigurationBuilder is itself the configuration, and Configuration is just an interface. Calling a static method on an instance of a class invokes the static method, which returns a default configuration even though the code superficially appears to create a custom one.

Recommendations:

  • Eliminate the Configuration interface.
  • Rename ConfigurationBuilder to Configuration.
  • (Optional) Make Configuration immutable, add a new ConfigurationBuilder which encapsulates the mutability and produces a Configuration when .build() is called.

Trouble with classes containing Lambda's

I'm using the MethodAnnotationScanner to look for annotations on the constructor of classes. However, when classes contain Lambda's, these annotations are no longer found. Removing the Lambda's and converting them to anonymous inner classes solves the issue.

This is using 0.9.9-RC1 from maven central.

consumption of reflections library from play framework (scala)

Yields the following error message when 'play compile' is issued:

[warn] Caught: java.lang.NullPointerException while parsing annotations in /usr/local/play-2.2.0/repository/local/org.reflections/reflections/0.9.8/jars/reflections.jar(org/reflections/Reflections.class)
[error] error while loading Reflections, class file '/usr/local/play-2.2.0/repository/local/org.reflections/reflections/0.9.8/jars/reflections.jar(org/reflections/Reflections.class)' is broken
[error] (class java.lang.RuntimeException/bad constant pool tag 8 at byte 661)
[error] [src_file_redacted]:[line_number_redacted]: org.reflections.Reflections does not have a constructor
[error]   val reflections = new Reflections(classOf[class_name_redacted].getPackage.getName)
[error]                     ^
[warn] two warnings found
[error] two errors found
[error] (compile:compile) Compilation failed

Possible bug in getSubTypesOf

I have the following code:

String rootPackage = "blah.definitions";
Set<Class<? extends ModelDefinition>> all = 
  new Reflections(rootPackage).getSubTypesOf(ModelDefinition.class);
Set<Class<? extends ModelDefinition>> adminOnly = 
  new Reflections(rootPackage + ".admin").getSubTypesOf(ModelDefinition.class);
Set<Class<? extends ModelDefinition>> pubOnly = 
  new Reflections(rootPackage + ".publisher").getSubTypesOf(ModelDefinition.class);
Set<Class<? extends ModelDefinition>> userOnly = 
  new Reflections(rootPackage + ".user").getSubTypesOf(ModelDefinition.class);
Set<Class<? extends ModelDefinition>> commonOnly = 
  new Reflections(rootPackage, new FilterBuilder()
    .exclude(rootPackage + ".admin.*")
    .exclude(rootPackage + ".user.*")
    .exclude(rootPackage + ".publisher.*")
    .exclude(rootPackage + ".anon.*")
  ).getSubTypesOf(ModelDefinition.class);

where ModelDefinition is a custom class of which there can be subclasses in different subpackages that can have the same class name.

The 5 sets contain the following:

all = [class blah.definitions.AppRefModelDefinition, 
  class blah.definitions.publisher.AppDefinition, 
  class blah.definitions.user.ProfileModelDefinition, 
  class blah.definitions.publisher.ProfileModelDefinition, 
  class blah.definitions.RootAppModelDefinition, 
  class blah.definitions.user.UserAccessModelDefinition, 
  class blah.definitions.admin.AppDefinition]

adminOnly = []

pubOnly = [class blah.definitions.publisher.ProfileModelDefinition]

userOnly = [class blah.definitions.user.ProfileModelDefinition, 
  class blah.definitions.user.UserAccessModelDefinition]

commonOnly = [class blah.definitions.AppRefModelDefinition, 
  class blah.definitions.RootAppModelDefinition]

The adminOnly set is wrong because it should contain blah.definitions.admin.AppDefinition; the pubOnly is also wrong because it does not contain the blah.definitions.publisher.AppDefinition class. Note that the two AppDefinition both extend RootAppModelDefinition, which might be relevant.

I can add more code to reproduce it if needed.

Is this a known bug?

Reflections with Jacoco

Hi,
I have a project where I'm using Reflections and I want to use Jacoco for coverage (as it's Java 8 project). However, when I run tests with Jacoco agent in place, tests start to fail. I found in Jacoco FAQ:

My code uses reflection. Why does it fail when I execute it with JaCoCo?

To collect execution data JaCoCo instruments the classes under test which adds two members to the classes: A private static field $jacocoData and a private static method $jacocoInit(). Both members are marked as synthetic.

Please change your code to ignore synthetic members. This is a good practice anyways as also the Java compiler creates synthetic members in certain situation.

Is it something you guys do in your code ? Or do you think it may not be the cause ?

Handle leak during scan

Jar file scanning leaves an open handle to the jar file. On Windows, this prevents the jar file from being deleted until the JVM exits. The leak happens in Reflections.scan(URL), which calls Vfs.fromURL without ever closing the returned Vfs.Dir instance.

Reflections.collect() on Websphere 8.5.5.x

On Websphere 8.5.5.1 collect() is working not properly (no jars are found from classpath). Solution I come with is:

  • Append / to end of META-INF/reflections Folder
Reflections.collect(
        "META-INF/reflections/",
        new FilterBuilder().include(".*-reflections.json"),
        new JsonSerializer()
)
  • Change ClasspathHelper.forResource (line 114). wsjar is returned from classloader, but URL should be with protocol jar
if (index != -1) {
    result.add(new URL(url.toExternalForm().substring(0, index).replaceFirst("^wsjar", "jar")));
} else {
    result.add(new URL(
            url.getProtocol().replaceFirst("^wsjar", "jar"), url.getHost(), url.getFile())
    ); //whatever
}

Vfs.addDefaultURLTypes(...)

Hello,
since 0.9.9 reflections add a lot of DefaultURLTypes by default. Even a quite old implementation of the 'vfs' (used at JBoss 3 or something like that).

IMHO it's not useful to add all these "DefaultURLTypes". I think it's much better the user adds the URL-Types he needs. The framework can provide implementations, but while initializing the user should add what he needs. But this is not a bug - only my opinion.

Even it's not nice to do things like match this protocol to everything contains ".jar" - which is the latest entry at list: Vfs.getDefaultUrlTypes()

But the real BUG is how the "Vfs.addDefaultURLTypes(...)" add a new DefaultType - this methods add the new URL-Type at the end of list and while searching for a handler the search starts at the beginning of this list. If I add with this method a own implementation of 'vfs'-Protokoll this never work because of two reasons!
1.) The already added implementation of protocol 'vfs' is used, because it matches first (but it is not working with JBoss7!).
2.) The URLType which matches everything with '.jar' inside URL is used before my one is added. That means it's nearly never working to add a new URL-Handler to reflections framework. :-(

It's a workaround to add manually the URLType to the beginning of the list (at least this should do the method "Vfs.addDefaultURLTypes(...)"). That means first the new URLType the user added is used before the already inserted URL-Types are added - thats the behavior every user is IMHO expecting. Workaround:

Vfs.getDefaultUrlTypes().add(0, new ReflectionsVFSFileHandler()); // important need to add at first position!

Suggest a solution:
If you add the new URLTypes to the beginning - IMHO this should work and is ok. Because with this the URLTypes added last will be used first. This means the new URL-Type overrides the already given URL-Types and if no matching URLType is manually added your already URL-Type is doing the job.

It's important that the URLTypes from the user is used first if it is matching the URL.

Thanks in advance for fixing this. Best Regards, Oli

org.reflections.ReflectionUtils#withAnnotations broken

Test case

import org.junit.Test;
import org.reflections.ReflectionUtils;

import javax.validation.constraints.NotNull;

import static org.junit.Assert.assertTrue;

public class ReflectionsTest {

  @Test
  public void testWithAnnotationsPredicate() {
    assertTrue(ReflectionUtils.getAllFields(Testos.class, ReflectionUtils.withAnnotations(NotNull.class)).size() == 1);
  }

  private static final class Testos {
    @NotNull
    private String notNull;
  }
}

Root cause
withAnnotations compares the Annotation[] from input.getAnnotations() with the Class[] from the parameter.

public static <T extends AnnotatedElement> Predicate<T> withAnnotations(final Class<? extends Annotation>... annotations) {
        return new Predicate<T>() {
            public boolean apply(@Nullable T input) {
                return input != null && Arrays.equals(annotations, input.getAnnotations());
            }
        };
    }

Release 0.9.10 or 0.10?

Hi, it's been quite some time since the last release (Sep 25, 2014), and there are some great improvements since then, could you cut a new release? I'm not sure which version it could / should be.

Would be great.

Thanks a ton!

Callback that reports detected annotation during scan

Currently the API collects the annotated elements and returns them in a collection. An efficient approach would be to call a callback each time an annotation is detected:

reflections.getTypesAnnotatedWith(
        javax.inject.Singleton.class,
        (Class<?> c) -> System.out.println(c.getName()));

What do you think?

Can't build due to test failures

Hello, and thank you for this great tool.

I've been using this in my development environment for a little while now, utilizing the already built jars available on your Google Code downloads page. But now I have come to the moment where I'd like to actually integrate into our production code base, and I would like to include source and javadoc jars, as well as more recent code.

However, I have been unsuccessful in my attempts to build the jar. I will preface this all by saying that I am not a maven user, so maybe something obvious is going on and it will be easy to correct.

The command I am running is mvn package -P build

Everything successfully compiles and I get to the [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ reflections --- step. Most of the tests run successfully, but some fail.

Building off of master, I get this failure:

Running org.reflections.JavaCodeSerializerTest
113 [main] INFO org.reflections.Reflections - Reflections took 77 ms to scan 1 urls, producing 22 keys and 73 values
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.167 sec <<< FAILURE!
org.reflections.JavaCodeSerializerTest  Time elapsed: 0.167 sec  <<< ERROR!
java.lang.RuntimeException
    at org.reflections.serializers.JavaCodeSerializer.save(JavaCodeSerializer.java:114)
    at org.reflections.Reflections.save(Reflections.java:625)
    at org.reflections.JavaCodeSerializerTest.generateAndSave(JavaCodeSerializerTest.java:33)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

I also tried going back to an older version and checked out the commit labeled with 9.10, but I got a different set of test failures.

Running org.reflections.ClasspathHelperTest
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.063 sec <<< FAILURE!
testForClassLoaderShouldntReorderUrls(org.reflections.ClasspathHelperTest)  Time elapsed: 0.053 sec  <<< FAILURE!
URLs returned from forClassLoader should be in the same order as source URLs: arrays first differed at element [0]; expected:<file://baz:1111baz> but was:<file://foo:1111foo>
    at org.junit.Assert.internalArrayEquals(Assert.java:381)
    at org.junit.Assert.assertArrayEquals(Assert.java:166)
    at org.reflections.ClasspathHelperTest.testForClassLoaderShouldntReorderUrls(ClasspathHelperTest.java:33)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
    at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

Running org.reflections.FilterBuilderTest
Tests run: 17, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 sec
Running org.reflections.JavaCodeSerializerTest
112 [main] INFO org.reflections.Reflections - Reflections took 82 ms to scan 1 urls, producing 22 keys and 73 values
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.176 sec <<< FAILURE!
org.reflections.JavaCodeSerializerTest  Time elapsed: 0.176 sec  <<< ERROR!
java.lang.RuntimeException
    at org.reflections.serializers.JavaCodeSerializer.save(JavaCodeSerializer.java:114)
    at org.reflections.Reflections.save(Reflections.java:625)
    at org.reflections.JavaCodeSerializerTest.generateAndSave(JavaCodeSerializerTest.java:33)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

Running org.reflections.ReflectionsCollectTest
238 [main] INFO org.reflections.Reflections - Reflections took 47 ms to scan 1 urls, producing 37 keys and 100 values
287 [main] INFO org.reflections.Reflections - Reflections successfully saved in /Users/chris.parker/work/reflections/target/test-classes/META-INF/reflections/testModel-reflections.xml using XmlSerializer
296 [main] INFO org.reflections.Reflections - Reflections took 7 ms to scan 1 urls, producing 12 keys and 50 values
382 [main] INFO org.reflections.Reflections - Reflections successfully saved in /Users/chris.parker/work/reflections/target/test-classes/META-INF/reflections/testModel-reflections.json using JsonSerializer
439 [main] INFO org.reflections.Reflections - Reflections took 56 ms to collect 1 url, producing 38 keys and 102 values [file:/Users/chris.parker/work/reflections/target/test-classes/]
462 [main] INFO org.reflections.Reflections - Reflections took 22 ms to collect 1 url, producing 12 keys and 50 values [file:/Users/chris.parker/work/reflections/target/test-classes/]
472 [main] INFO org.reflections.Reflections - Reflections took 6 ms to scan 1 urls, producing 4 keys and 4 values
543 [main] INFO org.reflections.Reflections - Reflections took 7 ms to scan 1 urls, producing 15 keys and 37 values
Tests run: 11, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.362 sec
Running org.reflections.ReflectionsParallelTest
572 [main] INFO org.reflections.Reflections - Reflections took 17 ms to scan 1 urls, producing 50 keys and 152 values [using 4 cores]
577 [main] INFO org.reflections.Reflections - Reflections took 4 ms to scan 1 urls, producing 2 keys and 2 values
596 [main] INFO org.reflections.Reflections - Reflections took 6 ms to scan 1 urls, producing 15 keys and 37 values
Tests run: 11, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.05 sec
Running org.reflections.ReflectionsTest
620 [main] INFO org.reflections.Reflections - Reflections took 21 ms to scan 1 urls, producing 50 keys and 152 values
625 [main] INFO org.reflections.Reflections - Reflections took 4 ms to scan 1 urls, producing 2 keys and 2 values
650 [main] INFO org.reflections.Reflections - Reflections took 11 ms to scan 1 urls, producing 15 keys and 37 values
Tests run: 11, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.05 sec
Running org.reflections.ReflectionUtilsTest
681 [main] INFO org.reflections.Reflections - Reflections took 12 ms to scan 1 urls, producing 1 keys and 2 values
Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.042 sec
Running org.reflections.VfsTest
testVfsDir(file:/Users/chris.parker/work/reflections/target/test-classes/dir+with%20spaces)
testVfsDir(file:/System/Library/Java/Extensions/QTJava.zip)
testVfsDir(file:/Users/chris.parker/work/reflections/)
testVfsDir(jar:file:/System/Library/Java/Extensions/QTJava.zip!/)
Tests run: 9, Failures: 1, Errors: 2, Skipped: 1, Time elapsed: 0.205 sec <<< FAILURE!
vfsFromJar(org.reflections.VfsTest)  Time elapsed: 0 sec  <<< ERROR!
org.reflections.ReflectionsException: could not create Vfs.Dir from url, no matching UrlType was found [file:/System/Library/Java/Extensions/QTJava.zip]
either use fromURL(final URL url, final List<UrlType> urlTypes) or use the static setDefaultURLTypes(final List<UrlType> urlTypes) or addDefaultURLTypes(UrlType urlType) with your specialized UrlType.
    at org.reflections.vfs.Vfs.fromURL(Vfs.java:109)
    at org.reflections.vfs.Vfs.fromURL(Vfs.java:91)
    at org.reflections.VfsTest.testVfsDir(VfsTest.java:142)
    at org.reflections.VfsTest.vfsFromJar(VfsTest.java:117)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
    at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

findFilesFromEmptyMatch(org.reflections.VfsTest)  Time elapsed: 0.002 sec  <<< ERROR!
org.reflections.ReflectionsException: could not create Vfs.Dir from url, no matching UrlType was found [file:/System/Library/Java/Extensions/QTJava.zip]
either use fromURL(final URL url, final List<UrlType> urlTypes) or use the static setDefaultURLTypes(final List<UrlType> urlTypes) or addDefaultURLTypes(UrlType urlType) with your specialized UrlType.
    at org.reflections.vfs.Vfs.fromURL(Vfs.java:109)
    at org.reflections.vfs.Vfs.fromURL(Vfs.java:91)
    at org.reflections.vfs.Vfs$2.iterator(Vfs.java:146)
    at com.google.common.collect.Iterables$6.iterator(Iterables.java:586)
    at com.google.common.collect.Iterables$3.transform(Iterables.java:509)
    at com.google.common.collect.Iterables$3.transform(Iterables.java:506)
    at com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48)
    at com.google.common.collect.Iterators$5.hasNext(Iterators.java:543)
    at org.reflections.VfsTest.findFilesFromEmptyMatch(VfsTest.java:135)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
    at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

allKindsOfShittyUrls(org.reflections.VfsTest)  Time elapsed: 0.001 sec  <<< FAILURE!
java.lang.AssertionError:
    at org.junit.Assert.fail(Assert.java:91)
    at org.junit.Assert.assertTrue(Assert.java:43)
    at org.junit.Assert.assertTrue(Assert.java:54)
    at org.reflections.VfsTest.allKindsOfShittyUrls(VfsTest.java:36)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:73)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:46)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)
    at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:220)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)


Results :

Failed tests:   testForClassLoaderShouldntReorderUrls(org.reflections.ClasspathHelperTest): URLs returned from forClassLoader should be in the same order as source URLs: arrays first differed at element [0]; expected:<file://baz:1111baz> but was:<file://foo:1111foo>
  allKindsOfShittyUrls(org.reflections.VfsTest)

Tests in error:
  org.reflections.JavaCodeSerializerTest
  vfsFromJar(org.reflections.VfsTest): could not create Vfs.Dir from url, no matching UrlType was found [file:/System/Library/Java/Extensions/QTJava.zip](..)
  findFilesFromEmptyMatch(org.reflections.VfsTest): could not create Vfs.Dir from url, no matching UrlType was found [file:/System/Library/Java/Extensions/QTJava.zip](..)

And the 9.9 commit produces a yet different set of test failures (all seeming to have something to do with a missing libmlib_jai.jnilib jar)

Do you have any thoughts on how to resolve this? Is this expected, or is there something else that I should be doing?

I appreciate and look forward to your response.

Convenient way to get all classes in package

As already mentioned in #13: A convenient way to get all classes in a package would be nice. My guess would be that this is a common usecase. The current workaround would be:

final Reflections reflections= new Reflections("myPackage", new SubTypesScanner(false));
.. = reflections.getSubTypesOf(Object.class);

However, something like

final Reflections reflections= new Reflections("myPackage");
.. = reflections.getAllClasses();

or

.. = ReflectionUtils.getAllClassesInPackage("myPackage");

would be better.

MacOS FileNotFolderException

Hi guys,

this is what I'm doing:

final Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forClassLoader()));

it works perfectly fine on Windows and Linux, however on MAC OS it fails with:

2015-03-23 10:34:51,266 org.springframework.boot.SpringApplication [main] ERROR: Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultBeanPostProcessor' defined in class path resource [com/mycompany/platform/config/PlatformCoreConfig.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.cache.annotation.ProxyCachingConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultCacheManager' defined in class path resource [com/mycompany/platform/config/PlatformCoreCachingConfigurerConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cache.CacheManager]: Factory method 'cacheManager' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.mycompany.platform.module.cache.hazelcast.core.config.HazelcastCacheConfig': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cacheRegions' defined in class path resource [com/samplestore/core/config/ProjectCoreConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.util.Set]: Factory method 'defaultPlatformCoreCacheRegions' threw exception; nested exception is java.lang.RuntimeException: org.apache.commons.vfs2.FileNotFolderException: Could not list the contents of "file:///usr/lib/java/libjdns_sd.jnilib" because it is not a folder.
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:472)

Seem like reflections is internally using vfs2 which complains that

java.lang.RuntimeException: org.apache.commons.vfs2.FileNotFolderException: Could not list the contents of "file:///usr/lib/java/libjdns_sd.jnilib" because it is not a folder.

I'm using java 1.7.0_71 and reflections 0.9.9

Internal limitation or big code-18?

Not sure if I'm doing something wrong of of there is some kind of technical limitation to what Reflections can do, I get very weird results when using the API; I have an Interface, TO that extends Serializable (and does nothing else, no extra methods, nothing), but when I scan for Serializable, I don't seem to get all the TOs, far from it:

Reflections reflections = new Reflections("my.project.pkg2", new SubTypesScanner(false));
Set<Class<? extends Serializable>> serializables = reflections.getSubTypesOf(Serializable.class); //676 classes
Set<Class<? extends TO>> TOs = reflections.getSubTypesOf(my.project.pkg1.TO.class); //446 classes
Collection intersec = CollectionUtils.intersection(serializables, TOs); //8 classes WTF!!!

TO is actually in another package than the one I'm scanning and the project is quite large. Using (old) Java 6 on Windows if it matters; and yes I tried to do the intersection manually to make sure the Apache Commons lib didn't contain a bug.

Bug, limit, code-18, what is happening here?

SubtypeScanner

First, great Tool.
But finding this bug after refactoring took some time... ;-D

I have a package "a.b.c" and one "a.b.c.impl".
In the first package, I have an (abstract class) "X" and another abstract class "Y" extending X.
In the second package, I have classes Z extending Y, so Z instanceof X is true.

So far, now comes the fun: I need to have the classes inside the second package, not the abstract ones. Intuition (and docs) say, this is the way to go:
final Reflections r = new Reflections("a.b.c.impl");
Set... = r.getSubTypesOf(X.class);

But the set is empty - too bad.

This one works, but I have to filter the abstract classes...? strange.

final Reflections r = new Reflections("a.b.c"); (without ".impl")
Set... = r.getSubTypesOf(X.class);

or maybe i missed s.th.?

All classes in a package and combine several filters

First of all, congratulations for your work.

I do not know if it is the right place for this question and if it is really a feature that is not developed.
If I write, for example, three different classes:

package controllers;
public class A {}

package controllers;
public class B extends A {}

package controllers;
@MyAnnotation
public class C extends A {}

  1. How could I get all the classes in a given package (controllers in this case)? getAllTypes() returns a Set[String] but not an Set[Class[?]]
  2. How I can combine multiple filters at once?
    new Reflections("controllers").getSubTypesOf(A.class).getTypesAnnotatedWith(MyAnnotation.class);

Thanks in advance.

Collect all resources with a given extension in the whole classpath

Hi,

Thank you for the great library!

I have a question for a best practice. Sorry if this is not the right forum!
I have a web application and few of the jars in WEB-INF/lib/ folder contain .less files both in the package structure (e.g. in com/example/) and in META-INF/resources/less/.

Using new Reflections("", new ResourceScanner()).collectResources(Pattern.compile("\\.less$")) returns empty set because the prefix is empty string. I cannot use "com" because it will filter the resources in "META-INT/" and vice versa.

I don't want to create two instances of Reflections because this will scan the classpath twice (or I'm wrong?!).

So at the moment I use this rather hacky way to achieve my goal:

ConfigurationBuilder builder = ConfigurationBuilder.build();
builder.addScanners(new ResourcesScanner());

ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
if (contextClassLoader instanceof URLClassLoader) {
     URL[] urls = ((URLClassLoader) contextClassLoader).getURLs();
     builder.addUrls(urls);
}

reflections = new Reflections(builder);

Is there a more idiomatic way to collect all resources by given criteria (e.g. name.endsWith(".less")) in the classpath ?

Please avoid e.printStackTrace()

Hi

Please avoid e.printStackTrace() calls in the code. For example in UrlTypeVFS class int the method createDir when catch Exception appear two e.printStackTrace();.

Can you replace e.printStackTrace(); with log.warn() ?

thanks, Antoni Nadal

Websphere - urls in the format "wsjar:file:/<path>"

The patch from isse 159 (http://code.google.com/p/reflections/issues/detail?id=159) is not is not applied successfully .
It definitely should be :

if (path.startsWith("wsjar:")) path = path.substring("wsjar:".length());
if (path.startsWith("file:")) path = path.substring("file:".length());

and not

if (path.startsWith("file:")) path = path.substring("file:".length());
if (path.startsWith("wsjar:")) path = path.substring("wsjar:".length());

Removing protocol from url will fail and file wont be created in next line:

if ((file = new java.io.File(path)).exists()) return file;

Exception in Reflection helpers

Exception in thread "main" org.reflections.ReflectionsException: could not get type for name org.reflections.serializers.JsonSerializer$1
at org.reflections.ReflectionUtils.forName(ReflectionUtils.java:389)
at org.reflections.ReflectionUtils.forNames(ReflectionUtils.java:398)
at org.reflections.Reflections.getSubTypesOf(Reflections.java:357)
at com.costco.rnd.Bulkthing.doWork(Bulkthing.java:31)
at com.costco.rnd.Bulkthing.main(Bulkthing.java:19)

Using the following dependencies

<dependencies>
       <dependency>
         <groupId>org.reflections</groupId>
         <artifactId>reflections</artifactId>
         <version>0.9.9</version>
     </dependency>
     <dependency>
        <groupId>org.neo4j</groupId>
        <artifactId>neo4j-rest-graphdb</artifactId>
        <version>1.9.3-SNAPSHOT</version>
     </dependency>
  </dependencies>

In this basic class

package com.costco.rnd;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

import org.reflections.Reflections;
import org.reflections.scanners.ResourcesScanner;
import org.reflections.scanners.SubTypesScanner;
import org.reflections.util.ClasspathHelper;
import org.reflections.util.ConfigurationBuilder;
import org.reflections.util.FilterBuilder;

public class Bulkthing {
     Reflections reflections;
     public static void main(String[] args){
         Bulkthing myThing = new Bulkthing();
         myThing.doWork();
     }

     public void doWork(){
         List<ClassLoader> classLoadersList = new LinkedList<ClassLoader>();
         classLoadersList.add(ClasspathHelper.contextClassLoader());
         classLoadersList.add(ClasspathHelper.staticClassLoader());

          reflections = new Reflections(new ConfigurationBuilder()
             .setScanners(new SubTypesScanner(false /* don't exclude Object.class */), new ResourcesScanner())
             .setUrls(ClasspathHelper.forClassLoader(classLoadersList.toArray(new ClassLoader[0])))
             .filterInputsBy(new FilterBuilder().include(FilterBuilder.prefix("org"))));
          Set<Class<?>> classes = reflections.getSubTypesOf(Object.class);
          Iterator<Class<?>> i = classes.iterator();
          while (i.hasNext()){
              Class<?> x = i.next();
              classwork(x);
          }
     }

     public void classwork(Class<?> inClass){
          Package path = inClass.getClass().getPackage();
          path.toString();
          System.out.println(inClass.toString());

     }

}

FilterBuilder parse documentation incorrect

The documentation of FilterBuilder.parse() is incorrect:

for example parse("-java., -javax., -sun., -com.sun.") or 
parse("+com.myn,-com.myn.excluded")

In fact, the parse() method takes strings in regex format, which is rather unexpected, as it would require escaping of the dots, this the correct documentation would be:

for example parse("-java\\..*, -javax\\..*, -sun\\..*, -com\\.sun\\..*") or 
parse("+com\\.myn\\..*,-com\\.myn\\.excluded\\..*")

which is decidely less readable.

Forthcoming patch will add a new parsePackages method to handle this more sensibly.

reflections-spring discontinued?

There is a page* in Reflections wiki that suggests a reflections-spring project... I can't find it's repository. Was this project discontinued for some reason?

I'm asking because during an experiment related to Spring application context loading time, I tried to use reflections-spring and ended up fixing some things in it and adding others as I needed. Now I think it could be useful for others to have the fixes I did (maybe).

Problem with "." entry in classpath

I have an application that uses Reflections for finding all the classes in the classpath implementing a particular interface.
This worked fine when run under Eclipse. However, the same application was giving me strange problems when run from a console.

After some debugging I realized that the problem was caused because the classpath environment variable is defined as:
export CLASSPATH=.:

These two details are important:

  • I was testing the application from my user directory.
  • My eclipse workspace (containing unrelated projects) is located in "~/Documents/workspace".

So the problem seems to be that Reflections is scanning all the subdirectories in my user directory, eventually arriving to my entire Eclipse workspace and reporting classes that should not be included.

To solve the problem I just suppressed the "." in my classpath entry. However,
I think this is a very common way to define a classpath environment variable and I think users of my library will face the same problem.

What is the best way to proceed ? Writing in my installation manual that "." should be avoided in the classpath variable is a bit weird since it is a kind of common practice.
Is there any alternative workaround for it ?

Reflections with java.lang package is not working

If I have the following code:

Reflections reflections = new Reflections("java.lang",new SubTypesScanner(false));

Set<Class<?>> types = reflections.getSubTypesOf(Object.class);

types is empty and it should contains at least java.lang.String.

Additional query possibility

While using your reflections library I am missing additional query possibilities. For example: In our project I want to make sure that all JUnit test classes extend a specific abstract test class.
Steps necessary:

  • Get all classes in the test package
  • Filter abstract classes out
  • Filter classes out which do not contain methods annotated with @test
  • Filter classes out which do not extend our abstract test class
  • Check what is still left...

It is of course possible to get all classes from our test package with your library. It would probably also be possible to filter the abstract classes out using an own scanner/filter. But what next? Now I have to manually search my collection to detect whether the classes contain said methods or not.

If I search on the other hand only methods annotated with @test in the package (via the ReflectionsUtils class) I cannot easily convert this collection into a collection/set containing only the containing classes.

I stand to be corrected.

Dependency Issue

javassist and guava do not have valid version numbers in the deployed versions (pom.xml). This causes ivy dependency resolution problems. Please ensure valid version numbers exists for all dependencies.

Exception with multi-maven builds (exclude current folder from scanned classpath)

Hello,

I have the following project setup:

master
    |----> module1
        |----> class ClassA (has annotation @Annotation)
    |----> module2
        |----> class ClassB (also has annotation @Annotation)

and I'm building it with maven, and I use an AbstractProcessor during compilation to find all types annotated with @Annotation. When I build it from the module1 level it all works fine. The problem appears when I build it from master level. Then, what happens is I get an exception that class B cannot be found.

Caused by: org.reflections.ReflectionsException: could not get type for name ClassB
    at org.reflections.ReflectionUtils.forName(ReflectionUtils.java:389)
    at org.reflections.ReflectionUtils.forNames(ReflectionUtils.java:398)
    at org.reflections.Reflections.getTypesAnnotatedWith(Reflections.java:385)
    at org.reflections.Reflections.getTypesAnnotatedWith(Reflections.java:370)

Here's how I find the types annotated with @Annotation:

        final Reflections reflections =
                        new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forClassLoader(ClasspathHelper.staticClassLoader())).setScanners(
                                        new TypeAnnotationsScanner(), new SubTypesScanner()));
        return reflections.getTypesAnnotatedWith(Annotation.class);

What happens is that the classloader will find also the following url:

/home/petar/workspace/master/./

and then it will be given to Reflections (method scan on line 235 in Reflections class ) where it will be treated as a SystemDir so reflections will recursively go thorough all the subfolders and add all the classes it finds (which also includes module2/target/classes/ClassB.class). Then it will try to load it and it will produce the error I pasted above. Now i'm not sure who's passing the master folder to the classpath, but I checked the maven classpath and I'm 100% sure it is not coming from maven. I also tried to add a filterInputsBy with a FilterBuilder.Exclude but that only allows me to filter on incoming files, and not the master folder (plus I have a project with more than 50 modules so I can't really exclude all the classes).

Also in my case I have a project with more than 50 modules, so reflections will be really slow if it scans the master folder. I think the proper solution is not the scan the master folder at all.

ClasspathHelper.forPackage not working with dynamically created ClassLoader

I've created a ClassLoader dynamically at Runtime.

File[] files;
URL[] resources;
URLClassLoader classLoader;
int i;
...
files = lib.listFiles();
resources = new URL[files.length];

for(i = 0; i < files.length; i++) {
    resources[i] = files[i].toURI().toURL();
}

classLoader = new URLClassLoader(resources);
...

When trying to retrieve the paths for a particular package that I know exists within the ClassLoader I get nothing.

ClasspathHelper.forPackage("some.package.name", pluginClassLoader);

I looked at the source code and noticed the usage of ClassLoader.getResources in the execution path of this method. I run into the same issue when trying to use that method directly on my ClassLoader with a '/' delimited path.

pluginClassLoader.getResources("some/package/name");

Is this utility class only supposed to be used for ClassLoaders that are on the classpath of the containing JVM or is this an issue. If this is a non-issue please show me the proper course of action for using dynamically created ClassLoaders.

Non-Recursive Scanning Not Supported or Documented

This might be more of a question than an issue. I have a package I want to scan for classes (i.e. package "a.b.c" ) but I am not interested in the classes of its sub packages (i.e. package "a.b.c.d"). How do get a hold of only classes in package "a.b.c"?

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Predicate

Error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Predicate
at SQLUtils.getDriver(SQLUtils.java:5)
at Main.main(Main.java:3)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Predicate
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more

Process finished with exit code 1

Code:
https://github.com/Woolworths/reflectionstest

Get all classes from package

I have seen the example like
Set<Class<? extends Module>> modules = reflections.getSubTypesOf(com.google.inject.Module.class);

But, I'd like to get all classes from package wihout especified the class, something like

List clazz = reflections.getClassFromPackage("com.someproject.model");

is it possible? how can I do that with Reflection library?

Loading all annotated classes from all class loaders

Hi

Thanks for the tool. I am trying to load annotated classes in a Netbeans plugin. Plugin has multiple Netbeans modules. The scanning happens in one but the annotation declaration can happen in any module. For some reaon, the scanning doesn't yield any results. I have unit tested my code within the module where the scanning happens, turns out it is picking up annotated classes when they are in the same module.

I know netbeans creates a new classloader for each module. So, I guess that begs the question, does Reflections scan all the class loaders ? If so, would you give me a sample code that will do this ?

Thanks again.

Move the Serializers to separate Maven packages?

I am trying to reduce my own projects dependencies, and noticed Reflections depends on dom4j. Since I don't use XML serialization, I would rather not include the library in my deployments.

Looking at your code, it is obvious that Serializers are already well compartmentalized.

Getting rid of the dependency would be a matter of moving the XmlSerializer to a separate project, creating a POM for it and moving the dom4j-dependency there.

Could you do that?

eclipse plugin : java.lang.LinkageError: loader constraint violation in interface itable initialization

I develop eclipse plugins. One of them is pom-first plugin plugin.libs containing all non-osgi dependencies. I wanted to integrate reflections into this plugin. However only adding (not even using) org.reflections into classpath is causing exception:

java.lang.LinkageError: loader constraint violation in interface itable initialization: when resolving method "org.eclipse.persistence.jaxb.JAXBMarshaller.getNode(Ljava/lang/Object;)Lorg/w3c/dom/Node;" the class loader (instance of org/eclipse/osgi/internal/baseadaptor/DefaultClassLoader) of the current class, org/eclipse/persistence/jaxb/JAXBMarshaller, and the class loader (instance of ) for interface javax/xml/bind/Marshaller have different Class objects for the type bject;)Lorg/w3c/dom/Node; used in the signature
at org.eclipse.persistence.jaxb.JAXBContext$JAXBContextState.createMarshaller(JAXBContext.java:1442)
at org.eclipse.persistence.jaxb.JAXBContext.createMarshaller(JAXBContext.java:343)
at org.eclipse.persistence.jaxb.JAXBContext.createMarshaller(JAXBContext.java:1)
at org.eclipse.persistence.jaxb.rs.MOXyJsonProvider.writeTo(MOXyJsonProvider.java:788)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor$TerminalWriterInterceptor.aroundWriteTo(WriterInterceptorExecutor.java:194)
at org.glassfish.jersey.message.internal.WriterInterceptorExecutor.proceed(WriterInterceptorExecutor.java:139)
at org.glassfish.jersey.message.internal.MessageBodyFactory.writeTo(MessageBodyFactory.java:1005)
at org.glassfish.jersey.client.ClientRequest.writeEntity(ClientRequest.java:430)
at org.glassfish.jersey.client.HttpUrlConnector._apply(HttpUrlConnector.java:290)
at org.glassfish.jersey.client.HttpUrlConnector.apply(HttpUrlConnector.java:203)
at org.glassfish.jersey.client.ClientRuntime.invoke(ClientRuntime.java:215)
... 81 more

Reflections dependency breaks selenium-java dependency

  1. Start with an empty Maven project
  2. Add selenium-java dependency
<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-java</artifactId>
  <version>2.42.2</version>
</dependency>
  1. Test it with simple main class:
public static void main(String[] args) {
    new FirefoxDriver();
}
  1. It should run without errors and launch Firefox browser (providing you have one installed)

  2. Then add reflections dependency after selenium:

<dependency>
   <groupId>org.reflections</groupId>
   <artifactId>reflections</artifactId>
   <version>0.9.9-RC2</version>
</dependency>
  1. Now start again main class and there will be an error java.lang.NoClassDefFoundError: org/w3c/dom/ElementTraversal

  2. The same will happen if you swap both dependencies in the pom.xml

  3. The reason I found is too old xml-apis dependency in the reflections artifact. The solution fixing it temporary was to insert a newer version of xml-apis explicitly in the pom.xml to override the older one in the classpath. So only in the following configuration both selenium and reflections work together:

<dependency>
         <groupId>org.reflections</groupId>
         <artifactId>reflections</artifactId>
         <version>0.9.9-RC2</version>
</dependency>
<dependency>
    <groupId>xml-apis</groupId>
    <artifactId>xml-apis</artifactId>
    <version>1.4.01</version>
</dependency>
<dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.42.2</version>
</dependency>

I think you should update the xml-apis dependency in org.reflections from current beta 1.0.b2 to 1.4.01, which is widely used by other artifacts.

Checked version: org.reflections:reflections:0.9.9-RC2 on Windows 7 x64.

Java 8 reflection fails

Trying to scan a class that uses a lambda expression fails. Specifically, the error I'm seeing is:

org.reflections.Reflections - could not scan file _ in url _ with scanner SubTypesScanner
org.reflections.Reflections - could not scan file _ in url _ with scanner TypeAnnotationsScanner

Digging into the AbstractScanner.scan method, the inner exception is:

java.io.IOException: invalid constant type: 18 at 8

withParametersAssignableTo

The withParametersAssignableTo Predicate seems to have a problem. The isAssignableFrom check is done backward.

// from "org.reflections.ReflectionUtils.withParametersAssignableTo(final Class... types)", line 246
if (!types[i].isAssignableFrom(parameterTypes[i])) {
     return false;
}

In the exemple above, types represents the Class<?>[] parameter passed to the predicate, while parameterTypes is retreive from the Method's signature.

The isAssignableFrom check should be done from the method's parameter type, with the parameter type received has arguments.

// fixed
if (!parameterTypes[i].isAssignableFrom(types[i])) {
     return false;
}

Here's my sample usecase:

import static org.reflections.ReflectionUtils.getMethods;
import static org.reflections.ReflectionUtils.withParametersAssignableTo;

import java.lang.reflect.Method;
import java.util.Set;

public class ReflectionTest {

    private interface IFruit {}

    public class Apple implements IFruit {}
    public class Orange implements IFruit {}

    public static void main(String[] args) {
        new ReflectionTest();
    }

    public ReflectionTest() {
        boolean a = IFruit.class.isAssignableFrom(Apple.class);
        boolean b = IFruit.class.isAssignableFrom(Orange.class);
        boolean c = Apple.class.isAssignableFrom(IFruit.class);
        boolean d = Orange.class.isAssignableFrom(IFruit.class);

        System.out.println(a); // true
        System.out.println(b); // true
        System.out.println(c); // false
        System.out.println(d); // false

        Exemple(new Apple()); // class ReflectionTest$Apple
        Exemple(new Orange()); // class ReflectionTest$Orange

        // Currently this returns an empty Set<Method> but it should return the a Set with a size of 1 containing the
        // Exemple(IFruit) Method object.
        Set<Method> methods = getMethods(ReflectionTest.class, withParametersAssignableTo(new Class<?>[] { Apple.class }));

        System.out.println(methods.size()); // 0
    }

    public void Exemple(IFruit fruit) {
        System.out.println(fruit.getClass());
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.