Gregor Mückl wrote: > The code to obtain a reference to a ClassLoader inside Qt Jambi is > quite complex and I am not completely sure if I traced it correctly. But it > seems to me that Qt Jambi goes straight to a new instance of > java.lang.ClassLoader for its queries, which actually acts as a simple > forwarder to the system-wide classloader that is used at application startup. >
Qt Jambi resolves classes in the function qtjambi_find_class() in qtjambi/qtjambi_core.cpp. This function looks quite complex, but that is actually just to support the Eclipse integration, where classes have to be resolved outside the default class loader. When this is needed, it will use a custom URLClassLoader with a location passed in through System.setProperty() by the Eclipse Integration. Since this all had to be written in JNI, it looks a lot more horrible than it actually is. The key part of qtjambi_find_class() however, which is used in other cases, is just a simple call to JNIEnv::FindClass() which is documented to look in the CLASSPATH for the class. This is where we would have to add code to support other class loaders. Unfortunately, there is no context in the qtjambi_find_class() function, as I suppose the correct thing to do when resolving the types in a method signature, would be to ask the class loader of the class containing the method to find the classes? One way might be to add this context, and fall back to FindClass() only when it is not available. I suspect this would require changes to several steps down the code path. Another way would be, like Gregor suggested, to have API for registering custom class loaders. However, this approach would be problematic if two classes are named the same and owned by different class loaders, as Qt Jambi would only be able to resolve one of them. Note that this issue is mainly relevant for QObjects (and the methods and properties they contain.) I can't think of any other cases where it might be a problem right now. -- Eskil _______________________________________________ Qt-jambi-interest mailing list [email protected] http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest
