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

Cannot discover classes using OneJar #128

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I wouldn't call this a bug, but figure it might be useful. I found a few 
questions online alluding to trying this, but did not find a solution. 
Hopefully I didn't reinvent the wheel here ... 

What steps will reproduce the problem?
1. Package application using One-Jar (one-jar.sourceforge.net)
2. reflections.getSubTypesOf(<your class>; presumably this impacts all types of 
discovery
3. Run application.

Returns no values when using the One-Jar classloader. The default classloader 
returns results as expected.

One-Jar v.97
Reflections .9.8
OS: Windows 7 x64
Java: 1.6.0-b105

Solution: Custom UrlType and custom Vfs.Dir; attached. Uses OneJarURLConnection 
to correctly read content from embedded JARs; uses 'standard' Vfs.File.

(The Vfs.UrlType.matches(..) may conflict with the existing implementation 
JarUrlType if both are added to the available UrlTypes.)

Original issue reported on code.google.com by bsl...@gmail.com on 14 Sep 2012 at 3:41

Attachments:

GoogleCodeExporter commented 9 years ago
I'm attempting to address the same issue in one of my projects.  After 
incorporating the OneJar*.java into the project and registering the 
OneJarUrlType with Vfs using addDefaultUrlTypes I was still not able to 
discover classes in the packaged jars. I'm using 1.6.0_xx under Windows 7 64 
bit, and OneJar 0.97.  The embedded jars are visible as resources but not 
navigable from any entrypoint I've tried so far.

Am I missing a step?

Original comment by mike.sco...@gmail.com on 4 Jan 2013 at 8:57

GoogleCodeExporter commented 9 years ago
Update - by using ClasspathHelper.forClass(SpecificSuperClass.class) I was able 
to find the classes in question; any other class path helper specific to a 
loader met with the same (null) results.

Original comment by mike.sco...@gmail.com on 8 Jan 2013 at 2:55

GoogleCodeExporter commented 9 years ago
I'm not sure why that's the only method that would work; but that's always
the method I use. The implementation, as you can see, should not be
specific to a particular helper or implementation.

I hope it still proved helpful!

On Tuesday, January 8, 2013, wrote:

Original comment by bsl...@gmail.com on 8 Jan 2013 at 3:47

GoogleCodeExporter commented 9 years ago
It did!  Thanks!

Original comment by mike.sco...@gmail.com on 8 Jan 2013 at 4:27

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
when this is gonna be included in library? Tried this without success.

Original comment by black.up...@gmail.com on 30 May 2014 at 10:25