Issue1047347

classification
Title: Subclass error when you don\\\'t have a no-argument constructor
Type: Severity: normal
Components: Jythonc compiler Versions:
Milestone:
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: fwierzbicki, gcash
Priority: low Keywords:

Created on 2004-10-14.21:21:26 by gcash, last changed 2009-03-13.23:44:59 by fwierzbicki.

Messages
msg938 (view) Author: Gene Cash (gcash) Date: 2004-10-14.21:21:26
If you have a Java class signature that doesn't have a
constructor with no
arguments like:

DoSomeStuff(int foo)
DoSomeStuff(float foo)

and you DON'T have:

DoSomeStuff()

Then when you try to subclass DoSomeStuff, you get a
compile error because it
generates code to handle the non-existant
"DoSomeStuff()" case.

If StarInterpolator is a subclass of
RotationInterpolator, this causes errors
like :

Compiling .java to .class...
    [snip]
1  ./jpywork/Star.java:243: cannot resolve symbol
symbol  : constructor RotationInterpolator ()
location: class javax.media.j3d.RotationInterpolator
            super();
            ^

super() doesn't exist because RotationInterpolator()
doesn't exist.

If you go into the generated code and delete the
following code

         StarInterpolator() {
            super();
            __initProxy__(new Object[] {});
        }

then it compiles just fine.
msg939 (view) Author: Gene Cash (gcash) Date: 2004-10-14.21:39:07
Logged In: YES 
user_id=141974

Interesting, there's a no-argument prototype, but it's not
public:

[17:27:20]# javap javax.media.j3d.TransformGroup 
Compiled from "TransformGroup.java"
public class javax.media.j3d.TransformGroup extends
javax.media.j3d.Group{
    public static final int ALLOW_TRANSFORM_READ;
    public static final int ALLOW_TRANSFORM_WRITE;
    public javax.media.j3d.TransformGroup();
    public
javax.media.j3d.TransformGroup(javax.media.j3d.Transform3D);
    void createRetained();
    public void setTransform(javax.media.j3d.Transform3D);
    public void getTransform(javax.media.j3d.Transform3D);
    public javax.media.j3d.Node cloneNode(boolean);
    void duplicateAttributes(javax.media.j3d.Node,boolean);
}

I'm not a java programmer so I don't understand why, except
the no-argument version is not useful.  I set
python.security.respectJavaAccessibility = false and got the
following  traceback:

processing GearBox
Traceback (innermost last):
  File "/usr/local/jython-2.1/Tools/jythonc/jythonc.py",
line 5, in ?
  File "/usr/local/jython-2.1/Tools/jythonc/main.py", line
300, in main
  File "/usr/local/jython-2.1/Tools/jythonc/main.py", line
219, in doCompile
  File "/usr/local/jython-2.1/Tools/jythonc/compile.py",
line 195, in compilefile
  File "/usr/local/jython-2.1/Tools/jythonc/compile.py",
line 217, in compile
  File "/usr/local/jython-2.1/Tools/jythonc/compile.py",
line 274, in addDependencies
  File "/usr/local/jython-2.1/Tools/jythonc/ImportName.py",
line 63, in lookupName
  File "/usr/local/jython-2.1/Tools/jythonc/ImportName.py",
line 42, in importName
  File "/usr/local/jython-2.1/Tools/jythonc/ImportName.py",
line 85, in getattr
  File "/usr/local/jython-2.1/Tools/jythonc/ImportName.py",
line 17, in wrapJava
  File "/usr/local/jython-2.1/Tools/jythonc/ImportName.py",
line 146, in __init__
  File "/usr/local/jython-2.1/Tools/jythonc/ImportName.py",
line 74, in __init__
java.lang.NoClassDefFoundError: Lsun/awt/DrawingSurfaceInfo;
	at java.lang.Class.getDeclaredFields0(Native Method)
	at java.lang.Class.privateGetDeclaredFields(Class.java:1522)
	at java.lang.Class.getDeclaredFields(Class.java:1098)
	at
org.python.core.PyJavaClass.getAccessibleFields(PyJavaClass.java)
	at org.python.core.PyJavaClass.setFields(PyJavaClass.java)
	at org.python.core.PyJavaClass.init__dict__(PyJavaClass.java)
	at org.python.core.PyJavaClass.initialize(PyJavaClass.java)
	at org.python.core.PyJavaClass.__tojava__(PyJavaClass.java)
	at org.python.core.ReflectedArgs.matches(ReflectedArgs.java)
	at
org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java)
	at
org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java)
	at org.python.core.PyObject.__call__(PyObject.java)
	at
ImportName$py.__init__$10(/usr/local/jython-2.1/Tools/jythonc/ImportName.py:74)
	at
ImportName$py.call_function(/usr/local/jython-2.1/Tools/jythonc/ImportName.py)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyFunction.__call__(PyFunction.java)
	at org.python.core.PyMethod.__call__(PyMethod.java)
	at org.python.core.PyObject.__call__(PyObject.java)
	at org.python.core.PyObject.invoke(PyObject.java)
	at
ImportName$py.__init__$23(/usr/local/jython-2.1/Tools/jythonc/ImportName.py:146)
	at
ImportName$py.call_function(/usr/local/jython-2.1/Tools/jythonc/ImportName.py)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyFunction.__call__(PyFunction.java)
	at org.python.core.PyInstance.__init__(PyInstance.java)
	at org.python.core.PyClass.__call__(PyClass.java)
	at org.python.core.PyObject.__call__(PyObject.java)
	at
ImportName$py.wrapJava$1(/usr/local/jython-2.1/Tools/jythonc/ImportName.py:17)
	at
ImportName$py.call_function(/usr/local/jython-2.1/Tools/jythonc/ImportName.py)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyFunction.__call__(PyFunction.java)
	at
ImportName$py.getattr$11(/usr/local/jython-2.1/Tools/jythonc/ImportName.py:85)
	at
ImportName$py.call_function(/usr/local/jython-2.1/Tools/jythonc/ImportName.py)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyFunction.__call__(PyFunction.java)
	at org.python.core.PyInstance.invoke(PyInstance.java)
	at
ImportName$py.importName$3(/usr/local/jython-2.1/Tools/jythonc/ImportName.py:42)
	at
ImportName$py.call_function(/usr/local/jython-2.1/Tools/jythonc/ImportName.py)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyFunction.__call__(PyFunction.java)
	at
ImportName$py.lookupName$5(/usr/local/jython-2.1/Tools/jythonc/ImportName.py:63)
	at
ImportName$py.call_function(/usr/local/jython-2.1/Tools/jythonc/ImportName.py)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyFunction.__call__(PyFunction.java)
	at org.python.core.PyObject.invoke(PyObject.java)
	at
compile$py.addDependencies$13(/usr/local/jython-2.1/Tools/jythonc/compile.py:274)
	at
compile$py.call_function(/usr/local/jython-2.1/Tools/jythonc/compile.py)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyFunction.__call__(PyFunction.java)
	at org.python.core.PyInstance.invoke(PyInstance.java)
	at
compile$py.compile$10(/usr/local/jython-2.1/Tools/jythonc/compile.py:217)
	at
compile$py.call_function(/usr/local/jython-2.1/Tools/jythonc/compile.py)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyFunction.__call__(PyFunction.java)
	at org.python.core.PyMethod.__call__(PyMethod.java)
	at org.python.core.PyObject.__call__(PyObject.java)
	at org.python.core.PyObject.invoke(PyObject.java)
	at
compile$py.compilefile$9(/usr/local/jython-2.1/Tools/jythonc/compile.py:195)
	at
compile$py.call_function(/usr/local/jython-2.1/Tools/jythonc/compile.py)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyFunction.__call__(PyFunction.java)
	at org.python.core.PyInstance.invoke(PyInstance.java)
	at
main$py.doCompile$6(/usr/local/jython-2.1/Tools/jythonc/main.py:219)
	at
main$py.call_function(/usr/local/jython-2.1/Tools/jythonc/main.py)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyFunction.__call__(PyFunction.java)
	at
main$py.main$9(/usr/local/jython-2.1/Tools/jythonc/main.py:300)
	at
main$py.call_function(/usr/local/jython-2.1/Tools/jythonc/main.py)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyFunction.__call__(PyFunction.java)
	at org.python.core.PyObject.invoke(PyObject.java)
	at
org.python.pycode._pyx0.f$0(/usr/local/jython-2.1/Tools/jythonc/jythonc.py:5)
	at
org.python.pycode._pyx0.call_function(/usr/local/jython-2.1/Tools/jythonc/jythonc.py)
	at org.python.core.PyTableCode.call(PyTableCode.java)
	at org.python.core.PyCode.call(PyCode.java)
	at org.python.core.Py.runCode(Py.java)
	at org.python.core.__builtin__.execfile_flags(__builtin__.java)
	at
org.python.util.PythonInterpreter.execfile(PythonInterpreter.java)
	at org.python.util.jython.main(jython.java)

java.lang.NoClassDefFoundError:
java.lang.NoClassDefFoundError: Lsun/awt/DrawingSurfaceInfo;

so that doesn't help.
msg940 (view) Author: Gene Cash (gcash) Date: 2004-10-15.02:13:57
Logged In: YES 
user_id=141974

I HAVE A FIX!

In proxies.py make the following change:

*** 346,363 ****
--- 346,365 ----
      def addConstructors(self, c):
          for constructor in c.getDeclaredConstructors():
              access = constructor.modifiers
              if isPrivate(access):
                  continue
              if isNative(access):
                  access = access & ~NATIVE
              if isProtected(access):
                  access = access & ~PROTECTED | PUBLIC
+             if not access:
+                 continue
              parameters = tuple(constructor.parameterTypes)
              throws = constructor.exceptionTypes
              self.jconstructors.append( (access,
parameters, throws) )
  
      def callSuperMethod(self, name, supername, access,
ret, sig, throws=[]):
          if self.issuperproxy:
              return
          self.supermethods[supername] = supername
          args = [typeName(ret)]

This makes it ignore constructors for which you have no access.
msg4269 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2009-03-13.23:44:59
jythonc is no longer maintained
History
Date User Action Args
2009-03-13 23:44:59fwierzbickisetstatus: open -> closed
resolution: wont fix
messages: + msg4269
nosy: + fwierzbicki
2004-10-14 21:21:26gcashcreate