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

Trying to use reflections-0.9.5-RC2, searching with "getTypesAnnotatedWith" and it finds nothing #65

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. If you look at my Test.java I am trying to find the annotation or subtype, 
but it doesn't find either of them.

What is the expected output? What do you see instead?
I should find one class.
Console:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in 
[jar:file:/C:/svn/Shared%20Jars/quartz/slf4j-log4j12-1.6.0.jar!/org/slf4j/impl/S
taticLoggerBinder.class]
SLF4J: Found binding in 
[jar:file:/C:/svn/Shared%20Jars/reflections/logback-classic-0.9.9.jar!/org/slf4j
/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
log4j:WARN No appenders could be found for logger (org.reflections.Reflections).
log4j:WARN Please initialize the log4j system properly.
annotated: 0
subTypes: 0

What version of the product are you using? On what operating system?
reflections-0.9.5-RC2  - on Windows XP - JRE6

Please provide any additional information below.

Original issue reported on code.google.com by curtis.p...@gmail.com on 16 Dec 2010 at 8:32

Attachments:

GoogleCodeExporter commented 9 years ago
this is definitely working. please check that the result of 
ClasspathHelper.getUrlsForPackagePrefix("your.package") contains the relevant 
url, and that the url contais the relevant class files

Original comment by ronm...@gmail.com on 22 Dec 2010 at 9:49

GoogleCodeExporter commented 9 years ago
I found that there is an issue with reflections.  It does not handle spaces in 
the file path to get to the source directory.  

This works: C:\workspaces\main\Test\src\...
This does not work C:\workspaces\main\Test Space\src\...

I end up writing my own class because I didn't want to bring around 2MB of jars 
into my project.

This was the code I used to allow me to have spaces in my file directory path:
  String path = packageName.replace('.', '/');
  Enumeration<URL> resources = null;
  try {
    resources = classLoader.getResources(path);
  } catch (IOException e) {
    logger.error(e,e);
  }
  logger.info("Find all Classes in this package: "+packageName);
  while (resources != null && resources.hasMoreElements()) {
    try {
      URL resource = resources.nextElement();
      String urlPath = resource.getFile().replaceAll("%20", " ");
      logger.info(new File(urlPath).getPath());
      classes.addAll(findClasses(new File(urlPath), packageName));
     } catch (Exception e) {
      logger.error(e.getMessage());
     }
  }

Original comment by curtis.p...@gmail.com on 5 Jan 2011 at 4:31