Hi, I am confused. Which project is running A or B? Is com.example.A.test1 in project A or B?
What is the type of the object that you do create? Try this: Object tmp = c.newInstance(); System.out.println(tmp); Is framework/base in project A or B? Finally, and this may not be important at all, but try using Class.forName() instead of the class loader directly. On Mar 19, 4:03 am, Jove <jove.c...@gmail.com> wrote: > Hi guys, > I meet a problem when using jar files, I simplify my question by > below examples: > > test.jar include a class of "com.example.test.class" > eclipse project A using test.jar and declare test1 extend from > com.example.test > eclipse project B using test.jar too and declare test2 extend from > com.example.test > Both project build sucessfull. > Then I try to using reflection in project B to instaniance a > instance of test1 > > Class <?> c = tmpCtxt.getClassLoader().loadClass > ("com.example.A.test1"); > test tmp = (test) c.newInstance() // > it throw java.lang.ClassCastException. (but if I put > com.example.test.class into frameworks/base", it's OK) > Anyidea about this issue? > Any advice is appreciated. > > Regards, > Jove --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---