This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Re: define-simple-class and Java constructors


Vladimir Tsichevski wrote:

        Another question: how to execute methods on `super' in such
        classes?

The intention is that
  (invoke (this <name-of-super-class>) 'method-name args ...)
or something like it should work - but I very much doubt it does.

   It does not. You need special syntax to call methods as super. It
   has to compile to
   `invokespecial' (183) Java bytecode instead of `invokevirtual' (182).

   I've added to kawa (see attachement) a new built-in primitive syntax
   `primitive-super-method', so, for example,
   the following scheme declaration:

      ((primitive-super-method <javax.swing.tree.DefaultTreeCellRenderer>
                   "getTreeCellRendererComponent"
                   <java.awt.Component>
                   (
                    <javax.swing.JTree>
                    <object>
                    <boolean>
                    <boolean>
                    <boolean>
                    <int>
                    <boolean>))
       (this) tree value sel expanded leaf row hasFocus)

now is equivalent to Jave code:

       super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf,
                          row, hasFocus);

   To implement this I significally redesigned the
   kawa.standard.prim_method class. The main problem with that class
   was in that
   the 183 opcode required to call "as super" is used also in Java
   constructors and kawa  implicitly assumes
   that 183 opcode alwais means constructor, so I had to change all
   sentences like this

if ( op_code == 183 ) // it must be constructor

to more adequate

if("<init>".equals(method.getName())

   Now I humbly ask you to check the code and add this or equivalent
   functionality to future kawa releases.
   I'm sure it would help many kawa users who need to use existing Java
   libraries.

Regards,

Vladimir Tsichevski

Attachment: kawa-call-super-patch.tar.gz
Description: GNU Zip compressed data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]