vancetang / reflections

Automatically exported from code.google.com/p/reflections
Do What The F*ck You Want To Public License
0 stars 0 forks source link

NullPointerException catched in ReflectionUtils.forNames without any warning #108

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

Execute the following code:

public class ReflectionUtilsAndClassesNotFound {

  public static void main(String[] args) {
    List<String> classes = ImmutableList.of("a.class.that.does.not.exist");

    List<?> result = ReflectionUtils.forNames(classes);

    ImmutableSet.copyOf(result); // throws NullPointerException
  }
}

The expected situation is that every classname that can't be resolved as a 
type, log a message and don't be added to the collection as null ( or Have it 
been done for some reason in this way? )

We access through an instance of Reflections, which we have no way to filter 
out null elements that come to the classnames' collection (or we haven't found 
it);

We create & use the Reflections instance like this:

    new Reflections(new ConfigurationBuilder()
        .filterInputsBy(FilterBuilder.parse(SOME_OWN_FILTER))
        .setUrls(VALID_JAR_URLS_TO_SCAN)
        .setScanners(new TypeAnnotationsScanner())
    ).getTypesAnnotatedWith(ANNOTATION_TO_FIND);

The NullPointerException is catched in the 
org.reflections.ReflectionUtils#forName without any warning;

We are using Reflections 0.9.5 on winxp

Thanks in advance
Diego M.

Original issue reported on code.google.com by Diegoariel83@gmail.com on 17 Apr 2012 at 4:24

GoogleCodeExporter commented 9 years ago
fixed on 0.9.7-RC1 and trunk. comments?

Original comment by ronm...@gmail.com on 2 May 2012 at 3:44

GoogleCodeExporter commented 9 years ago
fixed 0.9.7

Original comment by ronm...@gmail.com on 22 May 2012 at 7:47