Issue1132

classification
Title: Metaclasses for Java-derived objects
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.5
Milestone:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ericjacobs, fwierzbicki, pjenvey, zyasoft
Priority: low Keywords:

Created on 2008-09-15.17:45:32 by ericjacobs, last changed 2018-03-07.19:53:16 by jeff.allen.

Messages
msg3600 (view) Author: Eric Jacobs (ericjacobs) Date: 2008-09-15.17:45:31
It should be possible to assign metaclasses to classes that are derived
from Java classes.

import java

class MyClass(java.lang.Object):

    class __metaclass__(type(java.lang.Object)):
        def __new__(cls, name, bases, dict):
            return super(cls, cls).__new__(cls, name, bases, dict)
            
            
o = MyClass()


This results in the cryptic error message:

TypeError: class.__new__(__metaclass__) is not safe, use
__metaclass__.__new__()
msg3601 (view) Author: Philip Jenvey (pjenvey) Date: 2008-09-15.18:33:26
Note that this is the same error message emitted by the failing test_copy 
test_copy_atomic and test_deepcopy_atomic -- so they may be related to 
this issue
msg3610 (view) Author: Eric Jacobs (ericjacobs) Date: 2008-09-20.16:51:32
Okay, I've looked at the test_copy and entered that as a separate issue
-- as it was unrelated.

It looks like the best way to go forward with fixing the problems with
the Java object support is to bite the bullet, kill the hacks into
PyClass/PyInstance, and refactor PyJavaClass as a proper new-style type.
This is the approach I will take.
msg8545 (view) Author: Jim Baker (zyasoft) Date: 2014-05-22.01:41:11
For the case provided by the user, we get java.lang.InstantiationException: java.lang.InstantiationException: can't subclass final class

I believe this of java.lang.Object, but this seems to be broader as well. Let's revisit this interesting corner case.

Note that 7175:b4ae9e2893c8 introduced some changes in how Java types act as metaclass bases, as is used by Clamp.
msg8546 (view) Author: Jim Baker (zyasoft) Date: 2014-05-22.01:43:09
Duhh, java.lang.Object is the root of all classes, not a bottom type :)
msg9635 (view) Author: Jim Baker (zyasoft) Date: 2015-03-12.00:36:59
2.7.1
History
Date User Action Args
2018-03-07 19:53:16jeff.allensetmilestone: Jython 2.7.2 ->
2016-02-26 19:24:17zyasoftsetmilestone: Jython 2.7.2
2015-03-12 00:36:59zyasoftsetmessages: + msg9635
2014-09-26 06:10:31zyasoftsetpriority: normal -> low
2014-05-22 01:43:09zyasoftsetmessages: + msg8546
2014-05-22 01:41:11zyasoftsetnosy: + zyasoft
messages: + msg8545
2013-02-26 17:16:33fwierzbickisetnosy: + fwierzbicki
2013-02-25 18:46:21fwierzbickisetversions: + Jython 2.5, - 2.5.1
2009-03-14 14:22:02fwierzbickisetpriority: normal
versions: + 2.5.1, - 2.2.2
2009-03-14 14:06:18fwierzbickisetversions: + 2.2.2, - 2.2.1rc1
2008-09-20 16:51:33ericjacobssetmessages: + msg3610
2008-09-15 18:33:26pjenveysetnosy: + pjenvey
messages: + msg3601
2008-09-15 17:45:32ericjacobscreate