Comments (12)
Note that to find annotation javax.persistence.Entity
, you must have javax.persistence
in your whitelisted path list. This didn't use to be the case, the whitelist would "spill over" by one link if a class in a non-whitelisted package was referenced by a whitelisted path. I made the whitelisting "hermetic" in 1.9.10, so only classes in whitelisted packages are matched or returned.
I suspect this is the problem you are running into, since all of the annotation types you listed are in third-party packages, but please verify. Meanwhile, I'll update the docs to make this more explicit.
from classgraph.
Just released 1.9.15, please try with that version.
from classgraph.
With 1.9.15 I get:
java.lang.IllegalArgumentException: Can't scan for javax.jws.WebService, it is in a package that is either blacklisted or not whitelisted
While this now clearly points to the problem, I find it pretty counterintuitive to include something that I do not want to scan for.
What if javax.persistence
contained a class that is annotated with javax.persistence.Entity
?
I guess adding javax.persistence
to scanSpec
would match that class too. This is not what I want and I'm inclined to say that most users would not expect this behaviour.
I my point of view (from a strict user perspective), javax.persistence.Entity
is just a "matcher criteria", not something I want to scan for.
Am I making sense?
from classgraph.
Yes, that makes sense. What if you could whitelist class names, not just package names, in the scanning criteria? e.g. new FastClasspathScanner("com.mypkg", "+javax.persistence.Entity")
-- would this work for you?
from classgraph.
Well, this would be a workaround.
The major downside of this is that you need to "duplicate" all annotations and classes you use in the the matcher methods. This is especially cumbersome if you add a dynamic number of processors.
Couldn't the scanner just auto-add the classes/annotations from the match-invocations?
Why do you need to "scan" for javax.persistence.Entity
in the first place?
Do you read it's bytecode? If yes, why?
from classgraph.
No, the bytecode is not read. It was an intentional change to be clean, since methods like getNamesOfAllClasses()
/ getNamesOfAllAnnotations()
were returning what could amount to a large number of classes that weren't even whitelisted. Maybe I can just add a method like .includeReferencedClasses()
to not exclude these.
from classgraph.
In my opinion the class parameters of the match...
invocations should not be included in any of the lists (getNamesOfAllClasses()
etc.).
So .includeReferencedClasses()
does not fit 100%.
I wouldn't call those class parameters "referenced" at all.
To be fair, javax.persistence.Entity
is in deed referenced by each entity class but the class parameters are a different thing.
from classgraph.
You raise good points -- I implemented this with the semantics you suggested. See the entry in the docs about this. I think this will do what you need, but if not, please re-open. Will push out 1.9.16 with this fix.
from classgraph.
Does 1.9.16 work as you expect?
from classgraph.
I added a couple more fixes for this, let me know if it doesn't work for you. I'll push out 1.9.17 with these fixes.
from classgraph.
I haven't had the time to test 1.9.16 or .17 yet, but I will do so in the next two weeks or so.
from classgraph.
OK, thanks. Skip 1.9.16, it won't work for you, you'll need 1.9.17.
On Jan 20, 2016 2:52 AM, "moldowan" [email protected] wrote:
I haven't had the time to test 1.9.16 or .17 yet, but I will do so in the
next two weeks or so.—
Reply to this email directly or view it on GitHub
#39 (comment)
.
from classgraph.
Related Issues (20)
- Don't allow `PlatformClassLoader` or `AppClassLoader` as override classloaders HOT 10
- Why is ClassGraph so much slower then ClassPathScanningCandidateComponentProvider? HOT 5
- unknown method type annotation target 0x13: element size unknown, cannot continue reading class HOT 4
- Paths with Spaces and Hash don't work when using Nested JARs HOT 3
- Documentation issue HOT 2
- META-INF/MANIFEST.MF must include Dependencies: jdk.unsupported HOT 8
- Issue 673 test sometimes fails
- ClassGraph can't scan the jce.jar in jdk on the linux system, why? HOT 1
- ClassGraph thinks the application jars are JRE_LIB_OR_EXT_JARS HOT 5
- Get the Class and method comments HOT 2
- How to expose the full classpath from classloader? HOT 1
- Feature request:Add getClassesWithAllAnnotations HOT 8
- Expose a way to get the jar version that a Resource belongs to HOT 2
- zip64 bug in LogicalZipFile HOT 3
- JBoss EAP 7.4.15 class loading issue on EJB Modules HOT 17
- ClassRefTypeSignature.getFullyQualifiedClassName() can return incorrect classnames in some circumstances, using "." instead of "$" HOT 4
- Trouble with GraalVM native-image post compile HOT 3
- classgraph cannot scan all files of guava 33.2.1 HOT 4
- GraalVM static initializer -- unsure if actually working? HOT 1
- Consider bridge to nio Path HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from classgraph.