Issue1147

classification
Title: Inherited nested classes cannot be referenced
Type: behaviour Severity: normal
Components: Core Versions: 2.5alpha3
Milestone:
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: cgroves Nosy List: cgroves, fwierzbicki, garyh
Priority: Keywords:

Created on 2008-10-09.22:07:20 by garyh, last changed 2008-10-28.07:59:17 by cgroves.

Files
File name Uploaded Description Edit Remove
static_nested_class.patch garyh, 2008-10-09.22:07:19 Patch to use java.lang.Class.getClasses() method for resolving inner class references
Messages
msg3648 (view) Author: Gary Helmling (garyh) Date: 2008-10-09.22:07:18
Jython fails to resolve references to static nested classes when
referenced through a subclass.

For an example, assume you have the hierarchy:

public class Base {
    public static class NestedBase {
        public static final int ONE=1;
    }
}

public class Child extends Base {
}

Then in jython:
print "Child.NestedBase.ONE=%d" % (Child.NestedBase.ONE)

This will throw:
AttributeError: class 'Child' has no attribute 'NestedBase'

even though the reference is valid in Java.
msg3649 (view) Author: Gary Helmling (garyh) Date: 2008-10-09.22:10:00
The uploaded patch uses java.lang.Class.getClasses() to obtain
references to nested classes.

Don't know if there are any performance considerations here, but doesn't
seem like it would be slower than loading the class...
msg3650 (view) Author: Gary Helmling (garyh) Date: 2008-10-10.15:33:54
One more note -- this patch does not produce any new regressions in tests.

Ran the regrtest build target on both the pristine trunk and patched
trunk and both produce the same output on my setup:

     [exec] 265 tests OK.
     [exec] 5 tests skipped:
     [exec]     test__rawffi test_subprocess test_urllib2net test_urllibnet
     [exec]     test_zipfile64
     [exec] 1 skip unexpected:
     [exec]     test__rawffi
     [exec] 17 tests failed:
     [exec]     test_compiler test_copy test_cpickle test_doctest
test_generators
     [exec]     test_mailbox test_multibytecodec test_multibytecodec_support
     [exec]     test_pwd test_socket test_struct test_syntax test_tarfile
     [exec]     test_trace test_unicode test_unicodedata test_with
     [exec] 17 fails unexpected:
     [exec]     test_compiler test_copy test_cpickle test_doctest
test_generators
     [exec]     test_mailbox test_multibytecodec test_multibytecodec_support
     [exec]     test_pwd test_socket test_struct test_syntax test_tarfile
     [exec]     test_trace test_unicode test_unicodedata test_with
msg3706 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2008-10-27.18:05:36
Hey Charlie, since PyJavaClass is in a little flux lately, I didn't want
to try to apply this just in case you are working nearby.  I assigned
this to you, but If the dust has settled and you want to assign this
back to me, go ahead.
msg3711 (view) Author: Charlie Groves (cgroves) Date: 2008-10-28.07:59:16
Applied in r5523.  Thanks!
History
Date User Action Args
2008-10-28 07:59:17cgrovessetstatus: open -> closed
resolution: accepted
messages: + msg3711
2008-10-27 18:05:36fwierzbickisetassignee: fwierzbicki -> cgroves
messages: + msg3706
nosy: + cgroves
2008-10-13 16:35:28fwierzbickisetassignee: fwierzbicki
nosy: + fwierzbicki
2008-10-10 15:33:55garyhsetmessages: + msg3650
2008-10-09 22:10:01garyhsetmessages: + msg3649
2008-10-09 22:07:20garyhcreate