Message4857
It is not possible to inherit from a dynamically compiled Java class (
using the Java 6 Compiler API ) which wasn't previously dumped to a file
and reloaded.
In order to reproduce the failure case one needs the following Jython module
http://www.fiber-space.de/misc/jcompile.py
It defines the function
createJavaClass(classname : str, code : str ) -> type
which keeps a classname and a Java source string and returns a new
Jython class which wraps the compiled and loaded Java class. The
following code is an example:
code = '''
public class Foo
{
public static int f(int i)
{
return i*3;
}
}'''
Foo = createJavaClass("Foo", code)
The result is a new Jython class Foo that works as expected:
print Foo # <type 'Foo'>
Foo.f(5) # = 15
However, if one intends to subclass Foo one gets following exception
class Bar(Foo): pass
Traceback (most recent call last):
File "C:\lang\Jython\jannotations.py", line 185, in <module>
class Bar(Foo):pass
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.lang.ClassLoader.defineClass(ClassLoader.java:466)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError:
org/python/core/PyProxy (wrong name: Foo) |
|
Date |
User |
Action |
Args |
2009-06-28 16:09:19 | schluehk | set | recipients:
+ schluehk |
2009-06-28 16:09:19 | schluehk | set | messageid: <1246205359.25.0.297991434198.issue1387@psf.upfronthosting.co.za> |
2009-06-28 16:09:19 | schluehk | link | issue1387 messages |
2009-06-28 16:09:18 | schluehk | create | |
|