kicker10bog / reflections Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/reflections
License: Do What The F*ck You Want To Public License
Automatically exported from code.google.com/p/reflections
License: Do What The F*ck You Want To Public License
JavassistAdapter.iterateClasses iterate over all jar files (and
directories) and not just classes but at the same time treat all of them as
classes.
This results with many exceptions catched and printed to sysout.
Original issue reported on code.google.com by [email protected]
on 17 Dec 2008 at 1:51
What steps will reproduce the problem?
1. Include a JAR in the classpath which only contains:
package x.y;
@Documented
@Inherited
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface X {
}
2. create an instance with
new Reflections("x.y")
3. an NPE is generated.
What is the expected output? What do you see instead?
Apparently an @interface is not regarded as a class. Thus, in
Reflections.scan(), fileObjects can have a null value,
which leads to the NPE in the call to
ParallelStrategyHelper.apply(configuration.getParallelStrategy(), fileObjects,
scanFileProcedure);
What version of the product are you using? On what operating system?
0.9.4 / Java version "1.5.0_20" / Mac OS X 10.5.8
Please provide any additional information below.
I get round this by only calling ParallelStrategyHelper.apply if fileObjects !=
null
Original issue reported on code.google.com by [email protected]
on 13 Nov 2009 at 1:25
ClasspathHelper gets classpath urls of the current URLClassLoader but does not
walk the classloader stack. In my case
(running under Grails) this doesn't wok but walking the stack does. A simple
patch is below.
In a more general case, I think it would be useful to give users a hook to
provide a "find all classes matching a filter"
implementation for custom classloaders.
Index: reflections/src/main/java/org/reflections/util/ClasspathHelper.java
===================================================================
---
reflections/src/main/java/org/reflections/util/ClasspathHelper.java (revision
42)
+++
reflections/src/main/java/org/reflections/util/ClasspathHelper.java (working
copy)
@@ -12,6 +12,7 @@
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Collection;
+import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
@@ -42,12 +43,16 @@
ClassLoader loader = Utils.getContextClassLoader();
//is URLClassLoader?
- if (loader instanceof URLClassLoader) {
- return ImmutableList.of(((URLClassLoader) loader).getURLs());
+ List<URL> urls = Lists.newArrayList();
+ for (; loader != null; loader = loader.getParent()) {
+ if (loader instanceof URLClassLoader) {
+ Collections.addAll(urls, ((URLClassLoader) loader).getURLs());
+ }
}
+
+ if (! urls.isEmpty())
+ return Collections.unmodifiableList(urls);
- List<URL> urls = Lists.newArrayList();
-
//get from java.class.path
String javaClassPath = System.getProperty("java.class.path");
if (javaClassPath != null) {
Original issue reported on code.google.com by [email protected]
on 2 Dec 2009 at 12:02
What steps will reproduce the problem?
1. Checkout code from repository on a macosx machine
2. mvn install
What is the expected output? What do you see instead?
The install should work, but instead a dependency error appears:
[INFO] Failed to resolve artifact.
Missing:
----------
1) com.sun:tools:jar:1.5.0
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=com.sun -DartifactId=tools
-Dversion=1.5.0 -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file
there:
mvn deploy:deploy-file -DgroupId=com.sun -DartifactId=tools
-Dversion=1.5.0 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url]
-DrepositoryId=[id]
Path to dependency:
1) org.apache.maven.plugins:maven-plugin-plugin:maven-plugin:2.3
2) org.jfrog.maven.annomojo:maven-plugin-tools-anno:jar:1.3.1
3) com.sun:tools:jar:1.5.0
Please provide any additional information below.
The problem is with the POM of the jfrog library that provides a system
path for tools.jar which is not compatible with mac os x (it should point
to ${java.home}/../Classes/classes.jar instead of
${java.home}/../lib/tools.jar.
BTW: do you have a public repository where reflections can be accessed
without having to recompile it?
Original issue reported on code.google.com by [email protected]
on 14 Feb 2009 at 10:18
What steps will reproduce the problem?
1. Create an example class:
package org.example;
public class Example
{
@Deprecated
public void printIds(long[] ids) {
for (long id : ids) {
System.out.println("id = " + id);
}
}
}
2. Create an ExampleTest class:
package org.example;
import org.junit.Test;
import org.reflections.Reflections;
import org.reflections.scanners.MethodAnnotationsScanner;
import org.reflections.util.AbstractConfiguration;
import org.reflections.util.ClasspathHelper;
import java.lang.reflect.Method;
import java.util.Set;
public class ExampleTest
{
@Test
public void test()
throws Exception
{
Reflections reflections = new Reflections(new AbstractConfiguration()
{{
setUrls(ClasspathHelper.getUrlsForPackagePrefix("org.example"));
setScanners(new MethodAnnotationsScanner());
}});
Set<Method> methods =
reflections.getMethodsAnnotatedWith(Deprecated.class);
for (Method method : methods) {
System.out.println("method.getName() = " + method.getName());
}
}
}
3. Run the test
What is the expected output? What do you see instead?
I expect to see "printIds" printed to standard out. Instead I get:
Nov 17, 2009 1:22:40 PM org.reflections.Reflections scan
INFO: Reflections took 375 ms to scan 1 urls, producing 2 keys and 2 values
[using 2 cores] [187 ms per value]
org.reflections.ReflectionsException: could not resolve type long[]
at
org.reflections.util.DescriptorHelper.resolveType(DescriptorHelper.java:129
)
at org.reflections.util.Utils.forNames(Utils.java:30)
at
org.reflections.Reflections.getMethodFromDescriptor(Reflections.java:544)
at
org.reflections.Reflections.getMethodsAnnotatedWith(Reflections.java:379)
at org.example.ExampleTest.test(ExampleTest.java:25)
<snip>
Caused by: java.lang.ClassNotFoundException: long
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at
org.reflections.util.DescriptorHelper.resolveType(DescriptorHelper.java:127
)
... 32 more
What version of the product are you using? On what operating system?
0.9.4, Windows XP
Original issue reported on code.google.com by [email protected]
on 17 Nov 2009 at 7:29
Version of the product: 0.9.2
OS: Windowns, AIX
There is multiproject with structure:
Project
|- FirstSubProject is packaged as ear
|- SecondSubProject is packaged as jar and located in the root of
FirstSubProject.ear
|- ThirdSubProject is packaged as jar and located in the root of
FirstSubProject.ear
SecondSubProject and ThirdSubProject contain each own xml resource generated by
reflections-maven-plugin.
FirstSubProject.ear
|- SecondSubProject.jar
|- ThirdSubProject.jar
Problem description:
When Reflections collects xml resources the following method is executed:
ClasspathHelper.getMatchingJarResources(urls, resourceNameFilter)
In this method:
for (URL url : urls) - urls contains only URL of
FirstSubProject.ear
......
if (resourceNameFilter.accept(resourceName)) - the first found resourceName
will be accepted
{
matchingJarResources.add(resourceName);
break; //only one - this break will finish the inner "for-each", but because
} the urls in the outer
"for-each" contains only one URL
the outer "for-each" will finish also (but it doesn't).
This "break" should be removed.
Original issue reported on code.google.com by [email protected]
on 3 Jun 2009 at 11:36
Using
Reflections-0.9.4
commons-vfs-1.0
jvm-1.5_06
on Windows XP
I get a NullPointerException if I have a jar in my class path.
The reason is:
In the line 150 of Reflections.java you have:
FileObject fileObject = Utils.getVFSManager().resolveFile(url.getPath());
This results for me using commons-vfs.1.0 in the FileObject beeing instance
of ...commons.vfs.provider.local.LocalFile instead of JarFile.
The reason is that url.getPath() returns something similar to
"file:///myjar.jar"
for resolveFile to work it expects "jar:///myjar.jar!"
One solution perhaps could be changing this line to:
FileObject fileObject = Utils.getVFSManager().resolveFile(url.toString());
Also this problem results in null pointer exception in:
line 155:
ParallelStrategyHelper.apply(configuration.getParallelStrategy(),
fileObjects, scanFileProcedure);
This should be changed to:
if(fileObjects != null )
ParallelStrategyHelper.apply(configuration.getParallelStrategy(),
fileObjects, scanFileProcedure);
Regards,
Lukasz
Original issue reported on code.google.com by [email protected]
on 24 Aug 2009 at 1:11
protected Set<String> getSubTypesClosure(final String type) {
Set<String> result = new HashSet<String>();
Set<String> subResult = new HashSet<String>();
Set<String> subTypes = store.get(SubTypesScanner.indexName).get(type);
if (subTypes != null) {
// arhar
result.addAll(subTypes);
for (String aClass : result) {
subResult.clear();
subResult.addAll(getSubTypesClosure(aClass));
}
result.addAll(subResult);
}
return result;
}
Original issue reported on code.google.com by [email protected]
on 5 Dec 2008 at 2:48
Hi, small bug here -
Line 38 in ClasspathHelper:
The test: if (patterns != null)
should actually be: if (patterns !=null || patterns.size() == 0)
Since your recent changes, ClasspathHelper.getUrlsForCurrentClasspath()
returns nothing and I have to work around with
ClasspathHelper.getUrlsForCurrentClasspath(null).
Thanks!
Original issue reported on code.google.com by [email protected]
on 14 Aug 2009 at 5:22
What steps will reproduce the problem?
1. use setUrls(ClasspathHelper.getUrlsForCurrentClasspath());
2. create a new Reflections object.
What is the expected output? What do you see instead?
I would expect no output at all. lots of odd output on standard output that
looks like error output.
What version of the product are you using? On what operating system?
0.9.1, Linux 2.6.26-1-amd64 #1 SMP Wed Nov 26 18:26:02 UTC 2008 x86_64
GNU/Linux
Please provide any additional information below.
I used the following dependency libraries: google-collect-snapshot-20080820
and javassist-3.9.0.
I checked out the source code and found the source of output:
In the JavasistAdapter
public Iterator<ClassFile> iterateClasses(final Collection<URL> urls, final
Filter<String> filter)
...
protected ClassFile computeNext()
...
catch (IOException e) {
System.out.println(e.getMessage());
// throw new RuntimeException(e);
}
I looked into this issue a little more and found why this happens. The
problem is that the virtualFileIterator returns all files (<filename>.*)
and directories(!) on the classpath, only class files should be handled here.
I've added a very lame fix in the attached JavassistAdapter in attachment,
most likely there is a better way.
Original issue reported on code.google.com by [email protected]
on 19 Dec 2008 at 4:26
Attachments:
What steps will reproduce the problem?
1. checkout trunk
2. mvn install
Jars I had to add to my maven repo via maven:install-file :-
maven-plugin-tools-anno-1.3.1.jar
jade-plugin-common-1.3.8.jar
Now I'm at the following and giving up..........
Downloading: http://google-maven-
repository.googlecode.com/svn/repository//org/jfrog/jade/plugins/common/jade-plu
gin-
common/1.3.8/jade-plugin-common-1.3.8.pom
Downloading:
http://repo1.maven.org/maven2/org/jfrog/jade/plugins/common/jade-plugin-
common/1.3.8/jade-plugin-common-1.3.8.pom
[INFO] ---------------------------------------------------------------------
---
[ERROR] BUILD ERROR
[INFO] ---------------------------------------------------------------------
---
[INFO] Error extracting plugin descriptor: 'Failed to extract plugin
descriptor.'
org.jfrog.maven.annomojo.annotations.MojoAnnotation
[INFO] ---------------------------------------------------------------------
---
[INFO] For more information, run Maven with the -e switch
[INFO] ---------------------------------------------------------------------
---
[INFO] Total time: 4 seconds
[INFO] Finished at: Wed Feb 25 05:34:21 PST 2009
[INFO] Final Memory: 9M/23M
[INFO] ---------------------------------------------------------------------
---
Original issue reported on code.google.com by [email protected]
on 25 Feb 2009 at 1:39
A file: classpath url with spaces in the path is not handled correctly. The
spaces should be decoded before the path is passed to java.io.File. Patch:
Index: reflections/src/test/java/org/reflections/VfsTest.java
===================================================================
--- reflections/src/test/java/org/reflections/VfsTest.java (revision 42)
+++ reflections/src/test/java/org/reflections/VfsTest.java (working copy)
@@ -111,6 +111,7 @@
Assert.assertEquals("remove extra / at the end", Vfs.normalizePath(new URL("file:/path/file.ext/")), "/path/file.ext");
Assert.assertEquals("remove multiple slashes", Vfs.normalizePath(new URL("file://path///file.ext//")), "/path/file.ext");
Assert.assertEquals("remove jar url prefix and ! postfix", Vfs.normalizePath(new URL("jar:file:/path/file.jar!/something")), "/path/file.jar");
+ Assert.assertEquals("decode spaces in the url", Vfs.normalizePath(new
URL("file:/C:/Documents%20and%20Settings/Administrator/")), "/Documents and
Settings/Administrator");
}
//
Index: reflections/src/main/java/org/reflections/vfs/Vfs.java
===================================================================
--- reflections/src/main/java/org/reflections/vfs/Vfs.java (revision 42)
+++ reflections/src/main/java/org/reflections/vfs/Vfs.java (working copy)
@@ -1,16 +1,19 @@
package org.reflections.vfs;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import org.reflections.ReflectionsException;
-import org.reflections.util.Utils;
-
import java.io.IOException;
import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
import java.net.URL;
+import java.net.URLDecoder;
import java.util.List;
+import org.reflections.ReflectionsException;
+import org.reflections.util.Utils;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+
/**
* a simple virtual file system bridge
* <p><p>use the {@link org.reflections.vfs.Vfs#fromURL(java.net.URL)} to get a {@link org.reflections.vfs.Vfs.Dir}
@@ -166,7 +169,13 @@
//todo remove this method?
//todo this should be removed and normaliztion should happen per UrlType and it is it's responsibility
public static String normalizePath(final String urlPath) {
- String path = urlPath;
+ String path;
+
+ try {
+ path = URLDecoder.decode(urlPath, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
path = path.replace("/", java.io.File.separator); //normalize separators
path = path.replace("\\", java.io.File.separator); //normalize separators
Original issue reported on code.google.com by [email protected]
on 3 Dec 2009 at 1:06
I'm trying to filter annotations by value the contain. I have a hierachy of
classes, let's say A<-B (A is a base class), A is annotated with my annotation.
When I do
reflections.getMethodsAnnotatedWith(AnnotationX.class);
I'll get classes A and B as a result.
when I do
reflections.getTypesAnnotatedWith(new AnnotationX() {
@Override
public String info() { return "To be done";}
@Override
public Class<? extends Annotation> annotationType() {
return AnnotationX.class;
}
});
I'll get null pointer exception, because of line:
if
(annotationMap.equals(getAnnotationMap(annotated.getAnnotation(annotationType)))
)
of function getTypesAnnotatedWith(Annotation x)
The problem is, that AnnotationX should influence object B, but is not
present on it, so trying to get value of AnnotationX on class B produces
this Exception.
Original issue reported on code.google.com by [email protected]
on 6 May 2009 at 1:14
It seems to me that reflections does not take
java.lang.annotation.@Inherited into account at all.
I'd have expected that when querying types with a specific annotation via
reflections.getTypesAnnotatedWith(annotation) I only get those types that
really declare the specific annotation OR if the annotation is declared
@Inherited, I also get the subtypes of a type that is annotated.
However, with reflections 0.9.2 this behaviour is not working correctly:
1. I tried two different reflection configurations regarding scanners:
a) with both new SubTypesScanner() and new ClassAnnotationsScanner()
b) with only ClassAnnotationScanner()
2. @Inherited is not recognized at all
For 1.a) when querying classes with annotation X all types AND THEIR
SUBTYPES are resolved regardless of whether the subtypes are really
annotated X (not matter of @Inherited specified or not).
IMO this is not correct behavior, subtypes should only be returned if X is
@Inherited.
For 1.b) when querying classes with annotation X only those classes are
returned that really annotated X. However, no matter if annotation X is
marked @Inherited or not, subtypes would not have been resolved.
IMO this is not correct behavior, subtypes should also be returned if X is
@Inherited.
Please contact me if you need further information.
Thanks a lot for your work!
Original issue reported on code.google.com by [email protected]
on 30 May 2009 at 12:13
Add a method with similar signature to the Reflection class:
public Set<Class<?>> getTypesAnnotatedWith(String annotation)
Original issue reported on code.google.com by [email protected]
on 24 Dec 2008 at 11:58
Hi could you change your direct dependency on log4j to SLF4J or
commons-logging?
Original issue reported on code.google.com by [email protected]
on 18 Mar 2009 at 9:50
What steps will reproduce the problem?
1. Try to use reflections under Mac Os X
2. Try to use the ClasspathHelper.getUrlsForPackagePrefix with a package in
a source folder
3. see it fail with runtime exception.
What is the expected output? What do you see instead?
The output should be that the package is recognized, instead a runtime
exception is thrown cos the url representing the package directory is not
recognized as a directory. The failure is in the VirtualFile class
What version of the product are you using? On what operating system?
Version 0.9.2, SO MacOsX 10.5, JDK 1.5
Please provide any additional information below.
I guess the check in the isDirectory method is not working under *nix
systems. I've fixed it with the following change in the VirtualFile class:
public static boolean isDirectory(final URL url) {
final File f = new File(url.getFile());
return f.exists() && f.isDirectory();
}
Original issue reported on code.google.com by [email protected]
on 14 Feb 2009 at 11:31
What steps will reproduce the problem?
1. Set up reflections with the following config:
Reflections reflections = new Reflections(new AbstractConfiguration()
{
{
Predicate<String> filter = new FilterBuilder().include(".*");
setFilter(filter);
setUrls(Arrays.asList(new URL[] { new URL(
"<path to some class files eclipse built>") }));
setScanners(new MethodAnnotationsScanner());
}
});
2. Find annotated methods:
Set<Method> annotated = reflections.getMethodsAnnotatedWith(Test.class);
//Junit 4 tests
What is the expected output? What do you see instead?
It all works fine, but the process doesn't die. Reflections creates a
ThreadPoolParallelStrategy that spawns 2 threads (I'm on a dual core
system) in an ExecutorService. There's never a call to shutdown(), so the
threads prevent the JVM from exiting without a system.exit() call.
What version of the product are you using? On what operating system?
trunk version of Reflections... looks current as of 9.29.09
Please provide any additional information below.
To fix it, I added a shutdown() to ParallelStrategy. Reflections.java
should call it at the end of the scan() method. I changed
Jsr166ParallelStrategy to call forkJoinPool.shutdown() (is that correct?
I'm not familiar with those types of pools), SingleThreadedParallelStrategy
does nothing, and ThreadPoolParallelStrategy should call
executorService.shutdown().
Original issue reported on code.google.com by [email protected]
on 30 Sep 2009 at 10:54
Attachments:
What steps will reproduce the problem?
1.
Add
<plugin>
<groupId>org.reflections</groupId>
<artifactId>reflections-maven</artifactId>
<version>0.9</version>
<executions>
<execution>
<goals>
<goal>reflections</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
</plugin>
to my maven build section
2. include the reflections-maven jar in my local repository
3. run mvn -e install
What is the expected output? What do you see instead?
I expect the task to run - instead i get :
+ Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] --------------------------------------------------------------------
----
[INFO] Building test
[INFO] task-segment: [clean, install]
[INFO] --------------------------------------------------------------------
----
Downloading: http://repo1.maven.org/maven2/org/reflections/reflections-
maven/0.9.4/reflections-maven-0.9.4.pom
[INFO] Unable to find resource 'org.reflections:reflections-
maven:pom:0.9.4' in repository central (http://repo1.ma
ven.org/maven2)
Downloading: http://repo1.maven.org/maven2/org/reflections/reflections-
maven/0.9.4/reflections-maven-0.9.4.pom
[INFO] Unable to find resource 'org.reflections:reflections-
maven:pom:0.9.4' in repository central (http://repo1.ma
ven.org/maven2)
[INFO] --------------------------------------------------------------------
----
[ERROR] BUILD ERROR
[INFO] --------------------------------------------------------------------
----
[INFO] Error building POM (may not be this project's POM).
Project ID: org.reflections:reflections-maven
Reason: POM 'org.reflections:reflections-maven' not found in repository:
Unable to download the artifact from any r
epository
org.reflections:reflections-maven:pom:0.9.4
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
for project org.reflections:reflections-maven
[INFO] --------------------------------------------------------------------
----
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Unable to build
project for plugin 'org.reflections:reflect
ions-maven': POM 'org.reflections:reflections-maven' not found in
repository: Unable to download the artifact from
any repository
org.reflections:reflections-maven:pom:0.9.4
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
for project org.reflections:reflections-maven
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin
(DefaultLifecycleExecutor.java:1557)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.bindPluginToLifecycle
(DefaultLifecycleExecutor.java:
1503)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.constructLifecycleMappi
ngs(DefaultLifecycleExecutor.
java:1282)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal
(DefaultLifecycleExecutor.java:534)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFai
lures(DefaultLifecycleExecuto
r.java:387)
at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments
(DefaultLifecycleExecutor.java:34
8)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute
(DefaultLifecycleExecutor.java:180)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
at org.apache.maven.cli.compat.CompatibleMain.main
(CompatibleMain.java:60)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.classworlds.Launcher.launchEnhanced
(Launcher.java:315)
at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
at org.codehaus.classworlds.Launcher.mainWithExitCode
(Launcher.java:430)
at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.InvalidPluginException: Unable to build
project for plugin 'org.reflections:refl
ections-maven': POM 'org.reflections:reflections-maven' not found in
repository: Unable to download the artifact fr
om any repository
org.reflections:reflections-maven:pom:0.9.4
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
for project org.reflections:reflections-maven
at
org.apache.maven.plugin.DefaultPluginManager.checkRequiredMavenVersion
(DefaultPluginManager.java:293)
at
org.apache.maven.plugin.DefaultPluginManager.verifyVersionedPlugin
(DefaultPluginManager.java:205)
at org.apache.maven.plugin.DefaultPluginManager.verifyPlugin
(DefaultPluginManager.java:184)
at
org.apache.maven.plugin.DefaultPluginManager.loadPluginDescriptor
(DefaultPluginManager.java:1642)
at org.apache.maven.lifecycle.DefaultLifecycleExecutor.verifyPlugin
(DefaultLifecycleExecutor.java:1540)
... 18 more
Caused by: org.apache.maven.project.ProjectBuildingException:
POM 'org.reflections:reflections-maven' not found in
repository: Unable to download the artifact from any repository
org.reflections:reflections-maven:pom:0.9.4
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
for project org.reflections:reflections-maven
at
org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository
(DefaultMavenProjectBuilder.j
ava:605)
at
org.apache.maven.project.DefaultMavenProjectBuilder.buildFromRepository
(DefaultMavenProjectBuilder.java:
251)
at
org.apache.maven.plugin.DefaultPluginManager.checkRequiredMavenVersion
(DefaultPluginManager.java:277)
... 22 more
Caused by: org.apache.maven.artifact.resolver.ArtifactNotFoundException:
Unable to download the artifact from any r
epository
org.reflections:reflections-maven:pom:0.9.4
from the specified remote repositories:
central (http://repo1.maven.org/maven2)
at
org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve
(DefaultArtifactResolver.java:228)
at
org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve
(DefaultArtifactResolver.java:90)
at
org.apache.maven.project.DefaultMavenProjectBuilder.findModelFromRepository
(DefaultMavenProjectBuilder.j
ava:558)
... 24 more
Caused by: org.apache.maven.wagon.ResourceDoesNotExistException: Unable to
download the artifact from any repositor
y
at
org.apache.maven.artifact.manager.DefaultWagonManager.getArtifact
(DefaultWagonManager.java:404)
at
org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolve
(DefaultArtifactResolver.java:216)
... 26 more
[INFO] --------------------------------------------------------------------
----
[INFO] Total time: 2 seconds
[INFO] Finished at: Sat Sep 05 09:48:14 BST 2009
[INFO] Final Memory: 2M/4M
[INFO] --------------------------------------------------------------------
----
C:\Users\russell\workspace\webconsole>
What version of the product are you using? On what operating system?
0.9 of the reflections-maven and 0.9.4 of reflections.
maven 2.2.1
java 1_6_0_02
Please provide any additional information below.
If i remove the build target then the maven pom can find the jar files
okay but as soons as I add the build command it crashes. Any ideas?
Original issue reported on code.google.com by [email protected]
on 5 Sep 2009 at 8:53
public Iterator<ClassFile> iterateClasses(final Collection<URL> urls, final
Filter<String> filter) {
...
catch (IOException e) {
// arhar
// System.out.println(e.getMessage());
// throw new RuntimeException(e);
logger.debug(e.getMessage())
}
Original issue reported on code.google.com by [email protected]
on 5 Dec 2008 at 2:46
builder for IncludeExcludeChain
Original issue reported on code.google.com by [email protected]
on 2 Aug 2009 at 8:46
public class SubTypesScanner extends AbstractScanner {
public static final String indexName = "SubTypes";
public void scan(final Object cls) {
String className = getMetadataAdapter().getClassName(cls);
String superclass = getMetadataAdapter().getSuperclassName(cls);
List<String> interfaces = getMetadataAdapter().getInterfacesNames(cls);
// arhar
if (superclass != null && accept(superclass)) {
populate(superclass, className);
}
for (String anInterface : interfaces) {
if (accept(anInterface)) {
populate(anInterface, className);
}
}
}
public String getIndexName() {
return indexName;
}
}
Original issue reported on code.google.com by [email protected]
on 5 Dec 2008 at 2:49
The attached patch uses the strategy pattern for parallel execution, and
includes 3
implementations: Jsr166, a ThreadPool version, and a Single-threaded version
that just runs
everything on the the calling thread.
This eliminates the run-time requirement for jsr166 (though the user can still
opt to use it by
setting the strategy on the Configuration object.)
It also includes some small changes to allow compilation with Java 1.5
(String.isEmpty is 1.6+),
and also fixes a problem in the unit test suite where the xml file was
generated in the wrong
path. Finally, it sets the unit tests to run by default (not sure if there is
a good reason why
they're not running by default?)
I release all this code under the GNU LGPL license (just trying to match the
project- I don't really
care about the actual license!)
Original issue reported on code.google.com by [email protected]
on 9 Aug 2009 at 8:06
Attachments:
Version of the product: 0.9.2
OS: Windowns, AIX
Problem description:
There is AAA project.
1. reflections-maven-plugin generated reflections.xml file with the default
destination:
"${project.build.outputDirectory}/META-INF/reflections/${project.artifactId}-ref
lections.xml"
Generated file: /META-INF/reflections/AAA-reflections.xml
2. Reflections tries to collect saved xml resources in:
Reflections(final Collection<URL> urls, final Filter<String> resourceNameFilter)
Collection "urls" is correct
Filter<String> "resourceNameFilter" is "META-INF/reflections/.*-reflections.xml"
(Project Home Page has example with this filter, but it doesn't work - double
backslash shouldn't be in the
filter)
2.1. for (String resource : ClasspathHelper.getMatchingJarResources(urls,
resourceNameFilter))
finds all matched resources and returns thier simple names
Found resource: AAA-reflections.xml
2.2. InputStream stream = classLoader.getResourceAsStream(resource);
stream will be null because such resource not found. It should be
"META-INF/reflections/AAA-reflections.xml"
2.3. store.merge((Store) xStream.fromXML(stream));
It will throw NullPointerException
Original issue reported on code.google.com by [email protected]
on 3 Jun 2009 at 11:07
Attached a little patch to support reflections within JBoss 5. It basically
reverts the vfszip and vfsfile jboss url to something that common-vfs would
accept. There is also a test class, that needs some resource in
src/test/resources. I don't know how to include them in the patch, but it
should be quite easy to recreate them.
Thanks a lot for the great work (and version 0.9.4 looks like a huge
improvement).
R.
Original issue reported on code.google.com by [email protected]
on 26 Aug 2009 at 10:53
Attachments:
What steps will reproduce the problem?
use a MethodAnnotationsScanner
What is the expected output? What do you see instead?
Expected: MethodAnnotationsScanner applies the filter on the classname.
Actual: MethodAnnotationsScanner applies the filter on the class of method
annotations.
What version of the product are you using? On what operating system?
0.9.2
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 19 Mar 2009 at 5:58
The Utils.java class uses the System classloader when returning a Set of
scanned classes. It is possible to obtain the Set<String> of class names
implementing a particular interface from the store and create class
instances using a separate classloader. It would be nice if the library
handled it.
One line change in Utils.java takes care of this.
What steps will reproduce the problem?
0. Create SomeInterface.class and create an implementing class.
1. Create a class/jar of the implementing and do NOT add it to the
classpath of the application using reflections.
2. Create a new class loader (extending URLClassLoader) with the URL of the
new jar
2. Set the current classloader to the one created in 2 by
Thread.currentThread().setContextClassLoader
3. Pass the urls to Reflections instance using ConfigurationBuilder
4. Call a method on the reflections instance e.g.
getSubTypesOf(SomeInterface.class)
This is a scenario for dynamic class loading and invoking an implementation.
Output:
Exception in thread "main" java.lang.RuntimeException:
java.lang.ClassNotFoundException: com.test.SomeInterfaceImpl
at org.reflections.util.Utils.forName(Utils.java:41)
at org.reflections.util.Utils.forNames(Utils.java:55)
at org.reflections.Reflections.getSubTypesOf(Reflections.java:222)
Changing the line 39 in Utils.java to:
return Class.forName(type, true,
Thread.currentThread().getContextClassLoader());
loads the class correctly.
Original issue reported on code.google.com by [email protected]
on 1 Dec 2009 at 4:36
What steps will reproduce the problem?
1. Use Current version of google Collections
2. Use the example code (reduces to the simple annotion)
3. run
What is the expected output? What do you see instead?
none - got the Message:
Exception in thread "DatagramHandlerThread" java.lang.NoSuchMethodError:
com.google.common.collect.Iterators.forEnumeration(Ljava/util/
Enumeration;)Ljava/util/Iterator;
at org.reflections.util.VirtualFile$JarFileIterator.<init>
(VirtualFile.java:154)
at org.reflections.util.VirtualFile$4.iterator(VirtualFile.java:97)
at org.reflections.util.VirtualFile$5.transform
(VirtualFile.java:169)
at org.reflections.util.VirtualFile$5.transform
(VirtualFile.java:167)
at org.reflections.util.FluentIterable$3.transform
(FluentIterable.java:43)
at org.reflections.util.FluentIterable$3.transform
(FluentIterable.java:41)
at org.reflections.util.FluentIterable$ForkIterator.computeNext
(FluentIterable.java:81)
at com.google.common.collect.AbstractIterator.tryToComputeNext
(AbstractIterator.java:135)
at com.google.common.collect.AbstractIterator.hasNext
(AbstractIterator.java:130)
at org.reflections.util.FluentIterable$FilterIterator.computeNext
(FluentIterable.java:102)
at com.google.common.collect.AbstractIterator.tryToComputeNext
(AbstractIterator.java:135)
at com.google.common.collect.AbstractIterator.hasNext
(AbstractIterator.java:130)
at org.reflections.util.FluentIterable
$TransformIterator.computeNext(FluentIterable.java:124)
at com.google.common.collect.AbstractIterator.tryToComputeNext
(AbstractIterator.java:135)
at com.google.common.collect.AbstractIterator.hasNext
(AbstractIterator.java:130)
at org.reflections.Reflections.scan(Reflections.java:69)
at org.reflections.Reflections.<init>(Reflections.java:47)
What version of the product are you using? On what operating system?
I'am running 0.9.2 on gentoo linux using sun jd 1.6.0.13
Please provide any additional information below.
Sorry, there is nothing more i can tell.
Original issue reported on code.google.com by [email protected]
on 24 Apr 2009 at 7:09
Hi gang,
I found Reflections via an entry in Bill Burke's blog. I see the
Reflections build was created with Maven and was wondering if y'all had any
plans to put to publish it to the central repo? Would be very cool to be
able to get it from there!
Cheers, Brian
Original issue reported on code.google.com by brian.topping
on 23 Apr 2009 at 6:35
I did not see a mailing list or group so I posted here. If this project is
no longer being actively developed please let me know so I can find another
alternative.
there are several issues I need fixed to continue using this project.
Thanks,
Wes
Original issue reported on code.google.com by wesandevie
on 13 Nov 2009 at 7:13
What steps will reproduce the problem?
1. Configure a Reflections instance as:
Reflections reflections = new Reflections(new AbstractConfiguration()
{
{
Predicate<String> filter = new FilterBuilder().include(".*");
setFilter(filter);
String jarName = "jar:file://"+(new
File(classRepo)).toURL().getPath()+"!/";
setUrls(Arrays.asList(new URL[] { new URL(jarName) }));
setScanners(new MethodAnnotationsScanner());
}
});
Where classRepo is a final String representing a relative path to a jar.
The constructor will fail with an NPE:
Exception in thread "main" java.lang.NullPointerException
at com.google.common.collect.Lists.newArrayList(Lists.java:89)
at
org.reflections.adapters.ParallelStrategyHelper.apply(ParallelStrategyHelper.jav
a:39)
at org.reflections.Reflections.scan(Reflections.java:156)
at org.reflections.Reflections.<init>(Reflections.java:106)
at
com.sas.perfUnit.framework.PerformanceTester.startTests(PerformanceTester.java:7
6)
at
com.sas.perfUnit.framework.PerformanceTester.startTests(PerformanceTester.java:7
1)
at
com.sas.perfUnit.framework.PerformanceTester.main(PerformanceTester.java:43)
What is the expected output? What do you see instead?
I expect for the call to work, resulting in a log message like Reflections
took 375 ms to scan 1 urls, producing 6 keys and 210 values [using 2 cores]
[1 ms per value]
What version of the product are you using? On what operating system?
Latest in the trunk.
Please provide any additional information below.
Looks like Reflections uses URL.getPath around line 150. That causes the
jar: to get knocked off, but the '!' character at the end stays (resulting
in a bad file URL). Using URL.toString instead fixes the issue. This
should probably be tested with jars over a protocol other than file:///
just to be safe.
Original issue reported on code.google.com by [email protected]
on 5 Oct 2009 at 10:01
Attachments:
/**
* urls in current classpath from System property java.class.path
*/
public static Set<URL> getUrlsForCurrentClasspath(String... patterns) {
Set<URL> urls = Sets.newHashSet();
String javaClassPath = System.getProperty("java.class.path");
if (javaClassPath != null) {
for (String path : javaClassPath.split(File.pathSeparator)) {
try {
URL url = new File(path).toURI().toURL();
for (int i = 0; i < patterns.length; i++) {
URL normalizeURL = normalize(url);
if(normalizeURL.toExternalForm().contains(patterns[i])){
urls.add(normalizeURL);
}
}
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
}
return urls;
}
Original issue reported on code.google.com by [email protected]
on 5 Dec 2008 at 2:54
What steps will reproduce the problem? (not a problem)
1.
urlsToLoad = ["http://www......com/jars/archive.jar"]
URLClassLoader loader = URLClassLoader.newInstance(urlsToLoad);
2.
Configuration configuration = new AbstractConfiguration() {
{
this.setUrls(urlsToLoad);
//Can use not olny file:// ?
setScanners(new SubTypesScanner(), new ClassAnnotationsScanner());
setFilter(new IncludeExcludeChain(new
IncludePrefix("com.test.some")));
}
What version of the product are you using? On what operating system?
google-collections 0.9
reflections 0.92
Ubuntu 9 64
Jdk 1.6_12
Please provide any additional information below.
Here de error:
ang.IllegalArgumentException: URI scheme is not "file"
at java.io.File.<init>(File.java:366)
at org.reflections.util.VirtualFile.iterable(VirtualFile.java:77)
Original issue reported on code.google.com by [email protected]
on 7 May 2009 at 6:20
public static Set<Class<?>> forNames(final Collection<String> classes) {
Set<Class<?>> result = new HashSet<Class<?>>(classes.size());
for (String aClass : classes) {
try {
result.add(Class.forName(aClass));
}
catch (ClassNotFoundException e) {
// arhar
System.out.println("Class not found: " + aClass);
// throw new RuntimeException(e);
}
}
return result;
}
Original issue reported on code.google.com by [email protected]
on 5 Dec 2008 at 2:52
[deleted issue]
Reflections.java contains the following snippet, beggining on line 175:
log.info(format("Reflections took %d ms to scan %d urls%s,
producing %d keys and %d values [%d ms per value]",
time, configuration.getUrls().size(),
configuration.shouldUseForkjoin() ? " [using " +
forkJoinPool.getParallelismLevel() + " cores]" : "",
keys, values, time / values
));
The expression time / values causes an ArithmeticException to be thrown
when values is zero.
Original issue reported on code.google.com by [email protected]
on 30 Jul 2009 at 4:06
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.