|
From: <bc...@wo...> - 2001-05-04 18:09:15
|
On Wed, 2 May 2001 14:55:07 -0700, you wrote:
>Hi All.
>
>I want to use jython as a an interpreted replacement for Java classes in
>my development cycle. However, the framework I'm using expects to find
>classes using Class.forName(), and python classes show up in Java with
>funny package names.
>
>Is there a guide for how jython interfaces python classes into Java?
No.
>Is there a good reason that python classes need to show up with the funny
>package names?
Yes.
1) To avoid naming conflicts. The same class can exists in multiple
python modules. The same class name can even be used multiple times
within the same module.
2) To allow a reverse mapping of the proxy class name back to the module
and classname where the class is defined. This is used when reading a
serialized object stream with the PythonObjectInputStream class.
>If not, can someone give me a pointer as to where to fix
>up the code so that python classes show up in Java as with the same name?
Part of the name is created in PyClass.init() just before the call to
MakeProxies.makeProxy(). The rest of the name is created in the
makeProxy() method.
A real solution to this problem could maybe be to define the proxyname
somewhere in the python class:
import java
class A(java.lang.Object):
__proxyname__ = "my.package.FooBar"
The special __proxyname__ attribute must then be defined when the class
statement is executed. The value will be available in PyClass.init()
method in the dict parameter. Such a manually renamed proxy class can
never be de-serialized using java serialization.
Please keep in mind that getting the class name right is just one part
of the problem. The proxy classes are loaded by a custom classloader
(some instance of BytecodeLoader). By default, I doubt that the
Class.forName() call used by the framework will find the classes loaded
by the BytecodeLoaders. If it is jython that loads the framework, I can
ways of ensuring that the framework can find the proxyclasses.
regards,
finn
|