Menu

reflection problems

2005-11-24
2013-04-17
  • andrew barnes

    andrew barnes - 2005-11-24

    Hi guys

    I'm having a problem with ClassInfo.forName(). It is throwing a ClassNotFoundException even though the class exists and the classpath is set properly. The ClassAlgorithm is evaluating within the _global space, but the function returned is undefined.

    Is this a classpath problem, or is it something else I'm missing

    Regards
    Andy

     
    • Martin Heidegger

      Reflections are not bound to any classpath settings.

      Your problem may be that the certain class does not get compiled. That happens if you do not have any usage of this class in your main application.

      For MM Compiler you only need to put a reference like this

      com.class.MainClass;

      in your first frame action. Mtasc needs a little more like to use the class in a method call.

      yours
      Martin.

       
    • andrew barnes

      andrew barnes - 2005-11-29

      The classes in question are being compiled, but they are not being used until the second scene, while the ClassInfo.forName() call is being made in the first scene, so I think this is a class loading problem. When I declare a variable of the class I want to get info for
      before the forName() method is called, it finds it OK.

      Is there any way around this as we want to be able to put fully qualified class names in XML files, so they can be swapped out at run time

      Regards
      Andy

       
      • Martin Heidegger

        To be honest, I havn't worked with scenes for a very long time. I tried it right now and it seems if you have a useage for a class in the seconds scene, the class will be available in the first scene too, so that seems to be not the problem.

        The only case I know, where you might get real problems with classes and reflections is if its executed within a static construct like:

        class MyClass {
          private static var myApplication:MyApplication = new MyApplication();
        }

        class MyApplication {
          public function MyApplication() {
             trace(ClassInfo.forName("...."));
          }
        }

        because MM's does that maybe before other classes are loaded (nothing we can work against).

        Maybe you send me some sources so I understand your problem, because eighter I or You mix up some stuff.

         

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.