Issue1387
Created on 2009-06-28.16:09:19 by schluehk, last changed 2009-08-15.19:47:09 by cgroves.
Messages | |||
---|---|---|---|
msg4857 (view) | Author: Kay Schluehr (schluehk) | Date: 2009-06-28.16:09:18 | |
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) |
|||
msg4871 (view) | Author: Jim Baker (zyasoft) | Date: 2009-07-02.04:17:59 | |
Although this doesn't directly address this problem, which is an important one for us to solve, you might want to take a look at using ASM for creating Java classes. It might be useful for more specific use case like your Jython annotations work, and it has the advantage of working with Java 5 (or earlier with retrotranslator). Tobias created a useful project demonstrating this for the 2007 GSOC program; see https://jython.svn.sourceforge.net/svnroot/jython/trunk/sandbox/pyasm/, specifically pyasm.py. (Such classes do not have any problems, because it just hooks into our existing class loader mechanism.) Also be sure to look at the proxy generators in org.python.compiler, JavaMaker and ProxyMaker. |
|||
msg5015 (view) | Author: Kay Schluehr (schluehk) | Date: 2009-08-11.16:17:17 | |
The issue 1387 is obsolete and can be closed. The bug was caused by a custom classloader which defined findClass() that was called with a "org.python.core.PyProxy" string argument which couldn't be properly handled. There are a few ways to fix this without affecting the Jython runtime. |
|||
msg5025 (view) | Author: Charlie Groves (cgroves) | Date: 2009-08-15.19:47:09 | |
Closing this according to Kay's wishes. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2009-08-15 19:47:09 | cgroves | set | status: open -> closed resolution: invalid messages: + msg5025 nosy: + cgroves |
2009-08-11 16:17:18 | schluehk | set | messages: + msg5015 |
2009-07-02 04:17:59 | zyasoft | set | nosy:
+ zyasoft messages: + msg4871 |
2009-06-28 16:09:19 | schluehk | create |
Supported by Python Software Foundation,
Powered by Roundup