Git Product home page Git Product logo

Comments (6)

cech12 avatar cech12 commented on August 17, 2024 2

@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.

slovi avatar slovi commented on August 17, 2024 1

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.

cech12 avatar cech12 commented on August 17, 2024

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.

slovi avatar slovi commented on August 17, 2024

Yes, It seems that commit 7ccde6e will fix also this issue.

from reflections.

Lonzak avatar Lonzak commented on August 17, 2024

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.

michaelMarquard avatar michaelMarquard commented on August 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.