ridencww / goldengine

Java implementation of Devin Cook's GOLD Parser engine
Other
35 stars 14 forks source link

URL encoded path causes problem in loading classes #4

Closed nimatrueway closed 10 years ago

nimatrueway commented 12 years ago

Hello dear friend,

Firstly i want to thank you because of your handful and clean engine which you shared with us, And then i want to mention a little bug :

The library in my PC (OS: windows 7) is in the path "D:\Science\Lessons\Compiler\Gold-Grammer\Ralph Iden Engine\JavaLib"

and spaces in path causes a corrupted path in here :

File : ResourceHelper.java Function: findClassesInPackage Part-Codes:

        URL resource = resources.nextElement();
        jarFile = getJarFile(resource.toString());  <-- !!! problem here
        if (jarFile != null) {                
            break;
        }
        dirs.add(new File(resource.getFile()));  <-- !!! and here

--> the deal is that when you convert URL to normal path through functions "getFile" and "toString" some special non-alphabetic characters will stay in URL form like space which was converted to %20 and that makes a incorrect path.

i changed it a little bit like this, so it is working well now. -->

"D:\Science\Lessons\Compiler\Gold-Grammer\Ralph%20Iden%20Engine\JavaLib"

        URL resource = resources.nextElement();
        String path = URLDecoder.decode(resource.getFile(), "UTF-8");
        jarFile = getJarFile(path);
        if (jarFile != null) {                
            break;
        }
        dirs.add(new File(path));
ridencww commented 12 years ago

Thank you for identifying the issue and providing a solution. I will write a failing unit test and incorporate your changes. I appreciate the feedback.

ridencww commented 12 years ago

Writing a failing unit without creating a lot of noise and potential issues with Eclipse or other OS platforms has proved more challenging than expected. I need to give this more consideration. In the meanwhile, I have verified nimatrueway's fix using a local unit test and have updated the repository. I will provide an official label and promote to the Maven Central Repository in a day or two.

ridencww commented 10 years ago

Addressed in 5.0.3-SNAPSHOT and the 5.0.3 release. Thanks again for the contributing the fix.