Comments (6)
@slovi Your workaround works for me! Thanks for that! :)
I hope, the 0.10.3 version will be released soon to remove that hack^^
from reflections.
Same issue on openJDK 17.0.5 ... scan does not work with this version. After downgrade to 17.0.1 scanning works fine.
After some investigation I found out, that the problem is in JboosDir class which throws ClassCastException instead of returning correct instance of Vfs.Dir class.
JDK 17.0.5 extended content-type list (added application/jar-archive) which causes this ClassCastException in the end.
I used this workaround for now:
Vfs.addDefaultURLTypes(new CustomVfsUrlType());
CustomVfsUrlType:
static class CustomVfsUrlType implements Vfs.UrlType {
@Override
public boolean matches(URL url) {
return url.getProtocol().equals("vfs");
}
@Override
public Vfs.Dir createDir(URL url) throws Exception {
var virtualFile = url.openConnection().getContent();
if (virtualFile instanceof VirtualFile) {
return JbossDir.createDir(url);
} else {
Constructor<JbossDir> constructor = JbossDir.class.getDeclaredConstructor(VirtualFile.class);
constructor.setAccessible(true);
return constructor.newInstance(VFS.getChild(VFSUtils.toURI(url)));
}
}
}
This is definitely not clean approach. The method JbossDir.createDir should be redefined, but I'm not sure how to get VirtualFile from VirtualJarFileInputStream.
from reflections.
So, it has something to do with this issue? #395
Then, a commit 7ccde6e and PR #396 were made. A merge is planned for 0.10.3 #418.
from reflections.
Yes, It seems that commit 7ccde6e will fix also this issue.
from reflections.
I yesterday forked the project and tried the suggested bugfix 7ccde6e for issues (#395, #440, #427) However it did not help the error still occurs. Thus I completely removed the reflection lib and replaced the functionality with something else...
from reflections.
Maybe interesting for you to solve the issue:
I had a similar problem
java.lang.ClassCastException: class org.jboss.vfs.VirtualJarInputStream cannot be cast to class org.jboss.vfs.VirtualFile
in the context of Java 11.0.20
and WildFly Core 10.1.18.Final-redhat-00001
(in a Redhat EAP 7.3.6 GA
).
Instead of
VirtualFile virtualFile = (VirtualFile) url.openConnection().getContent();
I used
VirtualFile virtualFile = org.jboss.vfs.VFS.getChild(url.toURI());
(no cast necessary)
and it seems to do the job...
In Redhat EAP 7.4.11 GA
(WildFly Core 15.0.26.Final-redhat-00001
) the ClassCastException
does not occur
(there, url.openConnection().getContent()
is a VirtualFile
;
however, org.jboss.vfs.VFS.getChild(url.toURI())
still works there as well).
from reflections.
Related Issues (20)
- Do not support users.stream().filter(User::isCool).collect(Collectors.toList()) when use reflections.getMemberUsage(method) HOT 1
- ConfigurationBuilder#build fails on ReflectionException if there is classLoader param HOT 2
- "could not create Dir using jarUrl from url" when WebListener scan package HOT 1
- Application not deploying anymore after update JDK 17.0.5 -> 17.0.6 HOT 1
- Version release of 0.10.3 planned? HOT 6
- Cannot invoke "java.lang.Class.isInterface()" because the return value of "org.reflections.Reflections.forClass(String, java.lang.ClassLoader[])" is null
- Reflections returns classes outside of configured package HOT 1
- What polishing is necessary for release of 0.10.3? HOT 3
- reflections support jakarta HOT 1
- Close and archive AKA EOL this project HOT 1
- getSubTypesOf returning anonymous types defined in test classes
- ❗Please note: Reflections library is currently NOT under active development❗ HOT 2
- NoSuchMethodError exception in 0.10.2
- ⚠️ Reflections library is not under active development. Please prefer opening a PR instead of an issue ⚠️
- ⚠️ Please prefer opening a PR instead of an issue ⚠️
- How to support graalvm native-image?
- Reflections doesnt catch all classes with specified annotation.
- 0.10.2: Empty string as parameter for Reflections not accepted anymore HOT 1
- Reflections returns no results in unit test?
- `reflections.get(SubTypes.of(...).asClass())` does not work when resources are from an external jar. HOT 1
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 reflections.