-
Notifications
You must be signed in to change notification settings - Fork 0
SED-4497-referencing-a-keyword-from-an-ap-library-doesnt-work #120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,7 @@ | |
| import java.util.Set; | ||
| import java.util.stream.Collectors; | ||
|
|
||
| import io.github.classgraph.ClassInfo; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
|
|
@@ -209,6 +210,26 @@ public Set<Method> getMethodsWithAnnotation(Class<? extends Annotation> annotati | |
| return result; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the URL of the classpath element (JAR or directory) from which the given class was | ||
| * loaded during scanning. | ||
| * | ||
| * <p>This is determined from ClassGraph's scan metadata at scan time — before the class is | ||
| * actually loaded by the JVM — and is therefore not affected by {@link SecurityManager} | ||
| * restrictions on {@link Class#getProtectionDomain()} nor by JDK version differences. | ||
| * Returns {@code null} if the class name is not present in the scan result. | ||
| * | ||
| * @param className the binary class name (e.g. {@code "com.example.MyKeywords"}) | ||
| * @return the URL of the JAR or directory that contains the class, or {@code null} | ||
| */ | ||
| public URL getClasspathElementUrl(String className) { | ||
| if (className == null) { | ||
| throw new IllegalArgumentException("className must not be null"); | ||
| } | ||
| ClassInfo classInfo = scanResult.getClassInfo(className); | ||
| return classInfo != null ? classInfo.getClasspathElementURL() : null; | ||
|
Comment on lines
+229
to
+230
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The if (className == null) {
return null;
}
ClassInfo classInfo = scanResult.getClassInfo(className);
return classInfo != null ? classInfo.getClasspathElementURL() : null;
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Classname value check added, but we do not accept null value and now throw an IllegalArgumentException |
||
| } | ||
|
|
||
| /** | ||
| * Alternative implementation of {@link Class#isAnnotationPresent(Class)} which | ||
| * doesn't rely on class equality but class names. The class loaders of the | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new public method should be covered by unit tests in
AnnotationScannerTest.java. Please add tests for at least the following cases:null).nullclass name.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Junit tests added