cailin186 / 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

Reflections fails to find classes within jars files that do not contain 'structural' directory elements #139

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Extract make_jar.tar 
tar xvf make_jar.tar

2. Run cmake/make . to create hello.jar
cmake .
make

3. Extract all Jars from reflections-0.9.8-uberjar.jar into lib

4. Compile FindHello.java against reflections-0.9.8
javac -cp 'lib/*:hello.jar' FindHello.java

5. Execute FindHello
java -cp 'lib/*:hello.jar:.' FindHello

What is the expected output? What do you see instead?

Expected:
Found subtypes of Hello [class a.b.c.HelloImpl]

Actual:
Found subtypes of Hello []

What version of the product are you using? On what operating system?
reflections-0.9.8
Reproduced on Darwin 12.2.0 and also Redhat release 5.3 (Tikanga)  

Please provide any additional information below.

The issue appears to be that Reflections relies on the existence of 
'structural' directory entries with the JAR (e.g. a/, a/b, a/b/c in this case) 
in order to find the classes within the jar.  If these directory elements are 
absent, Reflections fails to find the classes.

Such jar files are created by default by Cmake (UseJava module/add_jar 
function), but can also be easily created on the command line with the jar 
command.

jar cf hello.jar  a/b/c/Hello.class a/b/c/HelloImpl.class

jar tvf hello.jar 
     0 Tue Jan 15 23:17:46 GMT 2013 META-INF/
    60 Tue Jan 15 23:17:46 GMT 2013 META-INF/MANIFEST.MF
    97 Tue Jan 15 23:05:10 GMT 2013 a/b/c/Hello.class
   217 Tue Jan 15 23:05:10 GMT 2013 a/b/c/HelloImpl.class

Original issue reported on code.google.com by keith.w...@gmail.com on 15 Jan 2013 at 11:24

Attachments:

GoogleCodeExporter commented 9 years ago
this should work unless your classpath is like a bordel of jars/sources/classes.
in that case getResources('a/b') returns './a/b' which contain java sources. if 
cleaned, getResources will find hello.jar!/a/b.

Original comment by ronm...@gmail.com on 17 Feb 2013 at 8:13

GoogleCodeExporter commented 9 years ago

Original comment by ronm...@gmail.com on 20 Feb 2013 at 9:14