-
-
Notifications
You must be signed in to change notification settings - Fork 704
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
[0.10.2] Reflections do not detect classes with Java 11.0.16+ #440
Comments
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. |
Yes, It seems that commit 7ccde6e will fix also this issue. |
@slovi Your workaround works for me! Thanks for that! :) |
Maybe interesting for you to solve the issue: I had a similar problem In |
I am using your library (reflections 0.10.2) in a Wildlfy (24.0.1) environment. My application is packed in an EAR file. The reflection code lies in a WAR inside of the EAR and should detect annotations of the JAR files next to it in the EAR.
With Java 11.0.15 it works good but with the update to 11.0.17 (and to 11.0.16 as well) it does not find the classes of the JAR files. It only detects the classes of the WAR itself.
I use the following code:
Maybe it has something to do with #373 but the workarounds do not work for me and a downgrade to Java 11.0.15 works.
I tested the JDKs of Temurin (11.0.15, 11.0.16, 11.0.17) and GraalVM (22.1.0 [11.0.15], 22.2.0 [11.0.16], 22.3.0 [11.0.17]).
Temurin 11.0.15 and GraalVM 22.1.0 are not producing the issue, the others do.
I hope, you can help me. :)
The text was updated successfully, but these errors were encountered: