Issue531256

classification
Title: Constructor problem using newInstance()
Type: Severity: normal
Components: Core Versions:
Milestone:
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: bckfnn Nosy List: bckfnn, ianzsk
Priority: normal Keywords:

Created on 2002-03-18.08:41:49 by ianzsk, last changed 2002-05-31.12:38:23 by bckfnn.

Messages
msg624 (view) Author: ian west (ianzsk) Date: 2002-03-18.08:41:49
Firstly I want to say -- fantastic work guys!!!
Now to the problem :-(.

If a Java constructor uses <Class>.newInstance() within
its body and <Class> is a PyProxy class then. a
Type Error occurs from within in Py.initProxy(...).

I think the problem is because the
ThreadState.{get/push/pop}InitializingProxy()
methods are being "subverted" 
by the direct call to Class.newInstance() below:


#****** Jython 2.1 part
# File xx.py
from x import X,Y
class PyX(X): pass
class PyY(Y): pass
PyX.useClass(PyY)
X() # OK
PyX() # Not OK prints 'TypeError: Proxy instance reused'

//*****Java part
// File x/X.java
package x;
public class X {
	static Class myClass;
	// register a class to construct
	public static void useClass(Class cls) {
		myClass=cls;
	}
	Object o;
	public X() throws Exception {
		o=myClass.newInstance();
	}
}
// File x/Y.java
package x;
public class Y { public Y() {} }

msg625 (view) Author: Finn Bock (bckfnn) Date: 2002-05-31.12:35:50
Logged In: YES 
user_id=4201

Your analysis is correct, the use of newInstance does not
work when there is a python class instance ctor on the stack.

Both python class ctor and newInstance() work correctly,
they just don't mix.

To the best of my knowledge, there is no way to improve the
situation.

msg626 (view) Author: Finn Bock (bckfnn) Date: 2002-05-31.12:38:23
Logged In: YES 
user_id=4201

Added as test364.
History
Date User Action Args
2002-03-18 08:41:49ianzskcreate