Menu

Resolving dependencies from class files

Developers
David Mohr
2008-11-22
2012-10-08
  • David Mohr

    David Mohr - 2008-11-22

    Hi,
    I'm trying to run recoder on a program which uses a library. So I added the library to the search path (and verified with sc.getProjectSettings().getSearchPathList()) that it is actually included. But recoder still complains that it cannot resolve the dependency.

    I had a look around, grabbed the PathList, and tried to use PathList.find to get a reference to the class file. When I pass in "some.package.MyClass" it does not work, but with some/package/MyClass.class I do get a hit. Now I don't know how recoder looks up dependencies, but in the end it does not work. I also checked to make sure that class.search.mode is set to 'sc'.

    What am I doing wrong?

    ~David

     
    • David Mohr

      David Mohr - 2008-11-24

      Ok, I switched to the RecoderProgram class from sourcerer, even though I think the one I had before was very similar anyways (diff didn't work too well because of different line break styles and I was too lazy to apply some pretty print on it first). That didn't change much.

      In the end there is no bug, I just had a misconception. I inserted my code to check the SearchPath in the constructor of my Transformation. There I saw the the search path was initialized to the contents of my classpath. But of course this constructor is executed before RecoderProgram.execute() is run, which changes the SearchPath and sets it to the input.path property of the project file.

      So the calls to NameInfo.getClassType() did actually do something, because they operated at the time when search path still contained the directories that I had set up.

      Somehow I just assumed that 'input.path' was just the path where the source files should be found, I did not realized that it behaves like the classpath (and can contain a list of directories).

       
    • Tobias Gutzmann

      Tobias Gutzmann - 2008-11-22

      Hej,

      sounds very strange that it doesn't work for you. How exactly does the code that you use to add something to the search path look like?

      Try to use NameInfo.getClassType("some.package.MyClass") instead; does that work?

      This code usually works:

      getServiceConfiguration().getProjectSettings().getSearchPathList().add(args[i]);

      Note that you can even say "/*.jar" and all .jar files in a directory are added to the search path if you use the project settings "PropertyNames.INPUT_PATH".

      If that doesn't help, can you send me a complete example?

      /Tobias

       
      • David Mohr

        David Mohr - 2008-11-23

        I used the simple examples as a boiler plate to boostrap my project. So I'm just using the RecoderProgram class that shipped with the 0.90 version. I did notice however that it seems to almost ignore the input.path setting of the .prj file and uses the CLASSPATH instead.

        While using your suggestion of NameInfo.getClassType() to see if it can find the class I noticed something strange: it did find the class, and suddenly I don't get an error for the class in question anymore - but I still get unresolvable errors for other classes. So I took the first class it could not find this time, again added a getClassType() call to my constructor, repeated the process 2 more times and suddenly it can find all the classes... looks like some strange bug to me!

        ~David

         
        • Tobias Gutzmann

          Tobias Gutzmann - 2008-11-23

          Is it .class or .java files that are contained in the .jar file?

          The "RecoderProgram" classes in the documentation are all different for the different sample-programs. The one from "sourcerer", however, works for sure.

           

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.