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

No way to gracefully continue scanning of unloadable classes #69

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run Reflections against a classpath containing invalid class files
2. Classloader throws RuntimeException "could not create class file from XYZ"
3. App dies.

What is the expected output? What do you see instead?
Scanning should continue, logging a warning.
Possibly create a scanner specifically for invalid classes.

What version of the product are you using? On what operating system?
0.9.5-RC2

Please provide any additional information below.

I wrote a wrapper "FaultTolerantScanner" hoping to simple augment existing 
scanners, but I quickly found that the implementation relies on the scanner 
class as a key into the Store. So I had to write another getSubTypesOf(..) 
method which used my class for the lookups. :-(

The change to scanners would be simple:

  @Override
  public void scan(File file) {
    try {
      super.scan(file);
    }
    catch (RuntimeException ex) {
      logger.warn(ex.getMessage());
      // Carry on!
    }
  }

Whether scanning should continue or not could be made configurable, but at the 
very least I should not get a RuntimeException thrown out of the  Reflections 
constructor.

Original issue reported on code.google.com by mark.ren...@gmail.com on 10 Feb 2011 at 2:02

GoogleCodeExporter commented 9 years ago
fixed on trunk

Original comment by ronm...@gmail.com on 12 May 2011 at 7:49