Discussion:
[jira] [Created] (PYLUCENE-37) Extended interfaces beyond first are ignored
Jesper Mattsson (JIRA)
2017-05-30 08:13:04 UTC
Permalink
Jesper Mattsson created PYLUCENE-37:
---------------------------------------

Summary: Extended interfaces beyond first are ignored
Key: PYLUCENE-37
URL: https://issues.apache.org/jira/browse/PYLUCENE-37
Project: PyLucene
Issue Type: Bug
Reporter: Jesper Mattsson


When generating wrapper for a Java interface that extends more than one other interface, then only the first extended interface is used.

In cpp.header(), the code snippets:
if cls.isInterface():
if interfaces:
superCls = interfaces.pop(0)
and:

line(out, indent, 'class %s%s : public %s {',
_dll_export, cppname(names[-1]), absname(cppnames(superNames)))
are likely responsible.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
Jesper Mattsson (JIRA)
2017-05-30 08:15:04 UTC
Permalink
[ https://issues.apache.org/jira/browse/PYLUCENE-37?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jesper Mattsson updated PYLUCENE-37:
------------------------------------
Description:
When generating wrapper for a Java interface that extends more than one other interface, then only the first extended interface is used.

In cpp.header(), the code snippets:
{{ if cls.isInterface():
if interfaces:
superCls = interfaces.pop(0)}}
and:
{{ line(out, indent, 'class %s%s : public %s {',
_dll_export, cppname(names[-1]), absname(cppnames(superNames)))}}
are likely responsible.

was:
When generating wrapper for a Java interface that extends more than one other interface, then only the first extended interface is used.

In cpp.header(), the code snippets:
if cls.isInterface():
if interfaces:
superCls = interfaces.pop(0)
and:

line(out, indent, 'class %s%s : public %s {',
_dll_export, cppname(names[-1]), absname(cppnames(superNames)))
are likely responsible.
Post by Jesper Mattsson (JIRA)
Extended interfaces beyond first are ignored
--------------------------------------------
Key: PYLUCENE-37
URL: https://issues.apache.org/jira/browse/PYLUCENE-37
Project: PyLucene
Issue Type: Bug
Reporter: Jesper Mattsson
When generating wrapper for a Java interface that extends more than one other interface, then only the first extended interface is used.
superCls = interfaces.pop(0)}}
{{ line(out, indent, 'class %s%s : public %s {',
_dll_export, cppname(names[-1]), absname(cppnames(superNames)))}}
are likely responsible.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
Jesper Mattsson (JIRA)
2017-05-30 08:15:04 UTC
Permalink
[ https://issues.apache.org/jira/browse/PYLUCENE-37?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jesper Mattsson updated PYLUCENE-37:
------------------------------------
Description:
When generating wrapper for a Java interface that extends more than one other interface, then only the first extended interface is used.

In cpp.header(), the code snippets:
if cls.isInterface():
if interfaces:
superCls = interfaces.pop(0)
and:
line(out, indent, 'class %s%s : public %s {',
_dll_export, cppname(names[-1]), absname(cppnames(superNames)))
are likely responsible.

was:
When generating wrapper for a Java interface that extends more than one other interface, then only the first extended interface is used.

In cpp.header(), the code snippets:
{{ if cls.isInterface():
if interfaces:
superCls = interfaces.pop(0)}}
and:
{{ line(out, indent, 'class %s%s : public %s {',
_dll_export, cppname(names[-1]), absname(cppnames(superNames)))}}
are likely responsible.
Post by Jesper Mattsson (JIRA)
Extended interfaces beyond first are ignored
--------------------------------------------
Key: PYLUCENE-37
URL: https://issues.apache.org/jira/browse/PYLUCENE-37
Project: PyLucene
Issue Type: Bug
Reporter: Jesper Mattsson
When generating wrapper for a Java interface that extends more than one other interface, then only the first extended interface is used.
superCls = interfaces.pop(0)
line(out, indent, 'class %s%s : public %s {',
_dll_export, cppname(names[-1]), absname(cppnames(superNames)))
are likely responsible.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
Jesper Mattsson (JIRA)
2017-05-30 08:17:04 UTC
Permalink
[ https://issues.apache.org/jira/browse/PYLUCENE-37?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jesper Mattsson updated PYLUCENE-37:
------------------------------------
Description:
When generating wrapper for a Java interface that extends more than one other interface, then only the first extended interface is used.

In cpp.header(), the code snippets:
{code}
if cls.isInterface():
if interfaces:
superCls = interfaces.pop(0)
{code}
and:
{code}
line(out, indent, 'class %s%s : public %s {',
_dll_export, cppname(names[-1]), absname(cppnames(superNames)))
{code}
are likely responsible.

was:
When generating wrapper for a Java interface that extends more than one other interface, then only the first extended interface is used.

In cpp.header(), the code snippets:
if cls.isInterface():
if interfaces:
superCls = interfaces.pop(0)
and:
line(out, indent, 'class %s%s : public %s {',
_dll_export, cppname(names[-1]), absname(cppnames(superNames)))
are likely responsible.
Post by Jesper Mattsson (JIRA)
Extended interfaces beyond first are ignored
--------------------------------------------
Key: PYLUCENE-37
URL: https://issues.apache.org/jira/browse/PYLUCENE-37
Project: PyLucene
Issue Type: Bug
Reporter: Jesper Mattsson
When generating wrapper for a Java interface that extends more than one other interface, then only the first extended interface is used.
{code}
superCls = interfaces.pop(0)
{code}
{code}
line(out, indent, 'class %s%s : public %s {',
_dll_export, cppname(names[-1]), absname(cppnames(superNames)))
{code}
are likely responsible.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
Jesper Mattsson (JIRA)
2017-05-30 13:10:04 UTC
Permalink
[ https://issues.apache.org/jira/browse/PYLUCENE-37?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jesper Mattsson updated PYLUCENE-37:
------------------------------------
Description:
When generating wrapper for a Java interface that extends more than one other interface, then only the first extended interface is used when generating the C++ class.

In cpp.header(), the code snippets:
{code}
if cls.isInterface():
if interfaces:
superCls = interfaces.pop(0)
{code}
and:
{code}
line(out, indent, 'class %s%s : public %s {',
_dll_export, cppname(names[-1]), absname(cppnames(superNames)))
{code}
are likely responsible.

was:
When generating wrapper for a Java interface that extends more than one other interface, then only the first extended interface is used.

In cpp.header(), the code snippets:
{code}
if cls.isInterface():
if interfaces:
superCls = interfaces.pop(0)
{code}
and:
{code}
line(out, indent, 'class %s%s : public %s {',
_dll_export, cppname(names[-1]), absname(cppnames(superNames)))
{code}
are likely responsible.
Post by Jesper Mattsson (JIRA)
Extended interfaces beyond first are ignored
--------------------------------------------
Key: PYLUCENE-37
URL: https://issues.apache.org/jira/browse/PYLUCENE-37
Project: PyLucene
Issue Type: Bug
Reporter: Jesper Mattsson
When generating wrapper for a Java interface that extends more than one other interface, then only the first extended interface is used when generating the C++ class.
{code}
superCls = interfaces.pop(0)
{code}
{code}
line(out, indent, 'class %s%s : public %s {',
_dll_export, cppname(names[-1]), absname(cppnames(superNames)))
{code}
are likely responsible.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
Andi Vajda (JIRA)
2017-05-30 22:14:04 UTC
Permalink
[ https://issues.apache.org/jira/browse/PYLUCENE-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16030244#comment-16030244 ]

Andi Vajda commented on PYLUCENE-37:
------------------------------------

There seems to be something off with that code indeed.
However, it would be helpful if you could include a small trivial example java code
that triggers the bug you found and an explanation of what you'd expect it
to do instead. This helps me ensure there is no misunderstanding and also helps with reproducing the bug.
Thanks !
Post by Jesper Mattsson (JIRA)
Extended interfaces beyond first are ignored
--------------------------------------------
Key: PYLUCENE-37
URL: https://issues.apache.org/jira/browse/PYLUCENE-37
Project: PyLucene
Issue Type: Bug
Reporter: Jesper Mattsson
When generating wrapper for a Java interface that extends more than one other interface, then only the first extended interface is used when generating the C++ class.
{code}
superCls = interfaces.pop(0)
{code}
{code}
line(out, indent, 'class %s%s : public %s {',
_dll_export, cppname(names[-1]), absname(cppnames(superNames)))
{code}
are likely responsible.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
Jesper Mattsson (JIRA)
2017-05-31 07:24:06 UTC
Permalink
[ https://issues.apache.org/jira/browse/PYLUCENE-37?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jesper Mattsson updated PYLUCENE-37:
------------------------------------
Attachment: Test.zip
Post by Jesper Mattsson (JIRA)
Extended interfaces beyond first are ignored
--------------------------------------------
Key: PYLUCENE-37
URL: https://issues.apache.org/jira/browse/PYLUCENE-37
Project: PyLucene
Issue Type: Bug
Reporter: Jesper Mattsson
Attachments: Test.zip
When generating wrapper for a Java interface that extends more than one other interface, then only the first extended interface is used when generating the C++ class.
{code}
superCls = interfaces.pop(0)
{code}
{code}
line(out, indent, 'class %s%s : public %s {',
_dll_export, cppname(names[-1]), absname(cppnames(superNames)))
{code}
are likely responsible.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
Jesper Mattsson (JIRA)
2017-05-31 08:08:04 UTC
Permalink
[ https://issues.apache.org/jira/browse/PYLUCENE-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16030812#comment-16030812 ]

Jesper Mattsson commented on PYLUCENE-37:
-----------------------------------------

Certainly, I should have done that when creating the issue - sorry.

I attached all the files I used when verifying the bug, but here are the highlights:

The Java interface C is defined as:
{code}
public interface C extends B, A {
void c();
}
{code}
The generated header file for it, C.h, contains (copying only the relevant lines):
{code}
#include "testjcc/B.h"

namespace testjcc {
class A;
}

namespace testjcc {
class C : public ::testjcc::B {
{code}
As you can see, A has a forward declaration, but is not included or inherited. Changing the order of the interfaces in the Java file changes the generated file so that A is inherited instead.

I'd expect both A.h & B.h to be included, and the first line of the class to be:
{code}
class C : public ::testjcc::B, public ::testjcc::A {
{code}
Post by Jesper Mattsson (JIRA)
Extended interfaces beyond first are ignored
--------------------------------------------
Key: PYLUCENE-37
URL: https://issues.apache.org/jira/browse/PYLUCENE-37
Project: PyLucene
Issue Type: Bug
Reporter: Jesper Mattsson
Attachments: Test.zip
When generating wrapper for a Java interface that extends more than one other interface, then only the first extended interface is used when generating the C++ class.
{code}
superCls = interfaces.pop(0)
{code}
{code}
line(out, indent, 'class %s%s : public %s {',
_dll_export, cppname(names[-1]), absname(cppnames(superNames)))
{code}
are likely responsible.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
Jesper Mattsson (JIRA)
2017-05-31 08:09:04 UTC
Permalink
[ https://issues.apache.org/jira/browse/PYLUCENE-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16030812#comment-16030812 ]

Jesper Mattsson edited comment on PYLUCENE-37 at 5/31/17 8:08 AM:
------------------------------------------------------------------

Certainly, I should have done that when creating the issue - sorry.

I attached all the files I used when verifying the bug, but here are the highlights:

The Java interface C is defined as:
{code}
public interface C extends B, A {
void c();
}
{code}
The generated header file for it, C.h, contains (copying only the relevant lines):
{code}
#include "testjcc/B.h"

namespace testjcc {
class A;
}

namespace testjcc {
class C : public ::testjcc::B {
{code}
As you can see, A has a forward declaration, but is not included or inherited. Changing the order of the interfaces in the Java file changes the generated file so that A is included and inherited instead.

I'd expect both A.h & B.h to be included, and the first line of the class to be:
{code}
class C : public ::testjcc::B, public ::testjcc::A {
{code}


was (Author: jmattsson):
Certainly, I should have done that when creating the issue - sorry.

I attached all the files I used when verifying the bug, but here are the highlights:

The Java interface C is defined as:
{code}
public interface C extends B, A {
void c();
}
{code}
The generated header file for it, C.h, contains (copying only the relevant lines):
{code}
#include "testjcc/B.h"

namespace testjcc {
class A;
}

namespace testjcc {
class C : public ::testjcc::B {
{code}
As you can see, A has a forward declaration, but is not included or inherited. Changing the order of the interfaces in the Java file changes the generated file so that A is inherited instead.

I'd expect both A.h & B.h to be included, and the first line of the class to be:
{code}
class C : public ::testjcc::B, public ::testjcc::A {
{code}
Post by Jesper Mattsson (JIRA)
Extended interfaces beyond first are ignored
--------------------------------------------
Key: PYLUCENE-37
URL: https://issues.apache.org/jira/browse/PYLUCENE-37
Project: PyLucene
Issue Type: Bug
Reporter: Jesper Mattsson
Attachments: Test.zip
When generating wrapper for a Java interface that extends more than one other interface, then only the first extended interface is used when generating the C++ class.
{code}
superCls = interfaces.pop(0)
{code}
{code}
line(out, indent, 'class %s%s : public %s {',
_dll_export, cppname(names[-1]), absname(cppnames(superNames)))
{code}
are likely responsible.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
Jesper Mattsson (JIRA)
2017-06-02 16:43:04 UTC
Permalink
[ https://issues.apache.org/jira/browse/PYLUCENE-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16035020#comment-16035020 ]

Jesper Mattsson commented on PYLUCENE-37:
-----------------------------------------

I made a first stab at a solution. It is only implemented in the Python 2 version, and the Python wrapper generation isn't done, but I'll attach it as a patch in the hope that it will be of use to you.
Post by Jesper Mattsson (JIRA)
Extended interfaces beyond first are ignored
--------------------------------------------
Key: PYLUCENE-37
URL: https://issues.apache.org/jira/browse/PYLUCENE-37
Project: PyLucene
Issue Type: Bug
Reporter: Jesper Mattsson
Attachments: Test.zip
When generating wrapper for a Java interface that extends more than one other interface, then only the first extended interface is used when generating the C++ class.
{code}
superCls = interfaces.pop(0)
{code}
{code}
line(out, indent, 'class %s%s : public %s {',
_dll_export, cppname(names[-1]), absname(cppnames(superNames)))
{code}
are likely responsible.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
Jesper Mattsson (JIRA)
2017-06-02 16:44:04 UTC
Permalink
[ https://issues.apache.org/jira/browse/PYLUCENE-37?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jesper Mattsson updated PYLUCENE-37:
------------------------------------
Attachment: jcc.multiple.inheritance.patch

First attempt at solution.
Post by Jesper Mattsson (JIRA)
Extended interfaces beyond first are ignored
--------------------------------------------
Key: PYLUCENE-37
URL: https://issues.apache.org/jira/browse/PYLUCENE-37
Project: PyLucene
Issue Type: Bug
Reporter: Jesper Mattsson
Attachments: jcc.multiple.inheritance.patch, Test.zip
When generating wrapper for a Java interface that extends more than one other interface, then only the first extended interface is used when generating the C++ class.
{code}
superCls = interfaces.pop(0)
{code}
{code}
line(out, indent, 'class %s%s : public %s {',
_dll_export, cppname(names[-1]), absname(cppnames(superNames)))
{code}
are likely responsible.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
Jesper Mattsson (JIRA)
2017-06-13 16:31:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/PYLUCENE-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16048084#comment-16048084 ]

Jesper Mattsson commented on PYLUCENE-37:
-----------------------------------------

I am currently unable to work any more on this beyond the patch that I sent.
Post by Jesper Mattsson (JIRA)
Extended interfaces beyond first are ignored
--------------------------------------------
Key: PYLUCENE-37
URL: https://issues.apache.org/jira/browse/PYLUCENE-37
Project: PyLucene
Issue Type: Bug
Reporter: Jesper Mattsson
Attachments: jcc.multiple.inheritance.patch, Test.zip
When generating wrapper for a Java interface that extends more than one other interface, then only the first extended interface is used when generating the C++ class.
{code}
superCls = interfaces.pop(0)
{code}
{code}
line(out, indent, 'class %s%s : public %s {',
_dll_export, cppname(names[-1]), absname(cppnames(superNames)))
{code}
are likely responsible.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
Andi Vajda
2017-06-13 18:39:14 UTC
Permalink
I have gotten to the same point as you - the Python side needs to be reworked to accomodate
multiple parents, the current static initializations don't work with multiple base classes.
It's work in progress...
Post by Jesper Mattsson (JIRA)
[ https://issues.apache.org/jira/browse/PYLUCENE-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16048084#comment-16048084 ]
-----------------------------------------
I am currently unable to work any more on this beyond the patch that I sent.
Post by Jesper Mattsson (JIRA)
Extended interfaces beyond first are ignored
--------------------------------------------
Key: PYLUCENE-37
URL: https://issues.apache.org/jira/browse/PYLUCENE-37
Project: PyLucene
Issue Type: Bug
Reporter: Jesper Mattsson
Attachments: jcc.multiple.inheritance.patch, Test.zip
When generating wrapper for a Java interface that extends more than one other interface, then only the first extended interface is used when generating the C++ class.
{code}
superCls = interfaces.pop(0)
{code}
{code}
line(out, indent, 'class %s%s : public %s {',
_dll_export, cppname(names[-1]), absname(cppnames(superNames)))
{code}
are likely responsible.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
Andi Vajda (JIRA)
2017-06-13 18:41:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/PYLUCENE-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16048226#comment-16048226 ]

Andi Vajda commented on PYLUCENE-37:
------------------------------------

I have gotten to the same point as you - the Python side needs to be reworked to accomodate
multiple parents, the current static initializations don't work with multiple base classes.
It's work in progress...
Post by Jesper Mattsson (JIRA)
Extended interfaces beyond first are ignored
--------------------------------------------
Key: PYLUCENE-37
URL: https://issues.apache.org/jira/browse/PYLUCENE-37
Project: PyLucene
Issue Type: Bug
Reporter: Jesper Mattsson
Attachments: jcc.multiple.inheritance.patch, Test.zip
When generating wrapper for a Java interface that extends more than one other interface, then only the first extended interface is used when generating the C++ class.
{code}
superCls = interfaces.pop(0)
{code}
{code}
line(out, indent, 'class %s%s : public %s {',
_dll_export, cppname(names[-1]), absname(cppnames(superNames)))
{code}
are likely responsible.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
Jesper Mattsson (JIRA)
2017-06-14 07:59:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/PYLUCENE-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16048822#comment-16048822 ]

Jesper Mattsson commented on PYLUCENE-37:
-----------------------------------------

Thanks for the update. Did you think that the changes in the patch are reasonable?
Post by Jesper Mattsson (JIRA)
Extended interfaces beyond first are ignored
--------------------------------------------
Key: PYLUCENE-37
URL: https://issues.apache.org/jira/browse/PYLUCENE-37
Project: PyLucene
Issue Type: Bug
Reporter: Jesper Mattsson
Attachments: jcc.multiple.inheritance.patch, Test.zip
When generating wrapper for a Java interface that extends more than one other interface, then only the first extended interface is used when generating the C++ class.
{code}
superCls = interfaces.pop(0)
{code}
{code}
line(out, indent, 'class %s%s : public %s {',
_dll_export, cppname(names[-1]), absname(cppnames(superNames)))
{code}
are likely responsible.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
Andi Vajda
2017-06-18 21:56:14 UTC
Permalink
Post by Jesper Mattsson (JIRA)
Thanks for the update. Did you think that the changes in the patch are reasonable?
Well, it was a start.
I had to redo this on the Python 3 side as it looks like Python types with
multiple base types are better supported there via the new
PyType_FromSpecWithBases() API.

I just now converted the jcc3 Python type object generation to use
PyType_Spec structs and PyType_FromSpec in preparation for supporting
multiple base types.

Andi..
Andi Vajda (JIRA)
2017-06-25 13:45:02 UTC
Permalink
[ https://issues.apache.org/jira/browse/PYLUCENE-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16062324#comment-16062324 ]

Andi Vajda commented on PYLUCENE-37:
------------------------------------

I've been working on this bug for a while now and I'm wondering how far a fix can get and what it achieves. I am about to check-in a large body of changes that makes a fix possible by switching Python type construction to use PyType_FromSpecWithBases() which can create a type with multiple base types. This is Python 3 only and this is fine. Python 2 support is in maintenance mode only.
What would fixing this bug achieve ?
- wrappers would be correct with regards to their super types and side-casting interfaces would work
- wrappers would inherit static fields and methods declared on interfaces beyond the first one)
Other than that, all is already working. For a non abstract java class to implement multiple interfaces, it has to have local implementations of all their methods (or inherit some from a parent class with local implementations) - thus I don't see any functional inheritance losses at the moment (beyond the static ones).
Also, Python has, to say the least, some strange layout requirements when constructing a type from multiple bases - they all have to have the same tp_basicsize. This is not the case with the JCC t_type, the types used with Python (their sizeof() is tp_basicsize), that wrap the C++/Java bridge types as they may have an array of type parameter of variable size (depending on the number of type parameters) when the java type being wrapped is generic. At the moment, I'm not even sure how much Python can support JCC types with multiple base types - maybe the t_type layout can be modified a bit to fix the size of type parameters by moving to an array pointer.
All that being said, it would be very nice if multiple inheritance could be properly supported:
- it would better model 'class foo extends bar implements baz, ..."
- it would better model the interface tree you proposed in the test
The new code now has a lot of stuff in place for supporting multiple inheritance but it is not enabled:
- placeholder for virtual inheritance
- support for multiple parents everywhere
- Python type construction supports multiple bases
The code doesn't have the change in logic yet to properly track 'extends foo implements bar' and the code still suffers from the bug reported here, only the first interface is used as parent for a sub-interface.
I'm going to continue working on this on and off as it's an interesting problem...
Post by Jesper Mattsson (JIRA)
Extended interfaces beyond first are ignored
--------------------------------------------
Key: PYLUCENE-37
URL: https://issues.apache.org/jira/browse/PYLUCENE-37
Project: PyLucene
Issue Type: Bug
Reporter: Jesper Mattsson
Attachments: jcc.multiple.inheritance.patch, Test.zip
When generating wrapper for a Java interface that extends more than one other interface, then only the first extended interface is used when generating the C++ class.
{code}
superCls = interfaces.pop(0)
{code}
{code}
line(out, indent, 'class %s%s : public %s {',
_dll_export, cppname(names[-1]), absname(cppnames(superNames)))
{code}
are likely responsible.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
Jesper Mattsson (JIRA)
2017-06-27 12:52:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/PYLUCENE-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16064779#comment-16064779 ]

Jesper Mattsson commented on PYLUCENE-37:
-----------------------------------------

We ran into it because we are developing an API where the public parts are interfaces, and the implementing classes are private. The problem was that the methods declared in the second inherited interface was not accessible.

I guess an alternate approach would be to include the methods from the inherited interfaces (except the one the C++ class inherits from). That would solve the problems we've run into so far. It looks to me that you'd run into problems when passing objects as arguments from C++, though:

Given the declarations below:
{code:java}
class A {
void f(B b) { /* ... */ }
}
interface B { /* ... */ }
class C extends D implements B { /* ... */ }
class D { /* ... */ }
interface E { /* ... */ }
interface F extends E, B { /* ... */ }
{code}
When trying to use the C++ wrappers to call A.f, wouldn't you currently get compilation errors if you passed the b argument from a reference of type C or F? What about in Python? Exception at runtime?
Post by Jesper Mattsson (JIRA)
Extended interfaces beyond first are ignored
--------------------------------------------
Key: PYLUCENE-37
URL: https://issues.apache.org/jira/browse/PYLUCENE-37
Project: PyLucene
Issue Type: Bug
Reporter: Jesper Mattsson
Attachments: jcc.multiple.inheritance.patch, Test.zip
When generating wrapper for a Java interface that extends more than one other interface, then only the first extended interface is used when generating the C++ class.
{code}
superCls = interfaces.pop(0)
{code}
{code}
line(out, indent, 'class %s%s : public %s {',
_dll_export, cppname(names[-1]), absname(cppnames(superNames)))
{code}
are likely responsible.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
Andi Vajda (JIRA)
2017-06-27 14:03:00 UTC
Permalink
[ https://issues.apache.org/jira/browse/PYLUCENE-37?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16064878#comment-16064878 ]

Andi Vajda commented on PYLUCENE-37:
------------------------------------

If you use the wrappers generated for interfaces, you're going to face the problem reported here.
If you use the wrappers generated for classes implementing said interfaces, then you should be ok with all implemented methods anywhere as the implementing class has them all (or it is abstract).

You can also force the wrapping of private classes by explicitly listing them on the command line.
Post by Jesper Mattsson (JIRA)
Extended interfaces beyond first are ignored
--------------------------------------------
Key: PYLUCENE-37
URL: https://issues.apache.org/jira/browse/PYLUCENE-37
Project: PyLucene
Issue Type: Bug
Reporter: Jesper Mattsson
Attachments: jcc.multiple.inheritance.patch, Test.zip
When generating wrapper for a Java interface that extends more than one other interface, then only the first extended interface is used when generating the C++ class.
{code}
superCls = interfaces.pop(0)
{code}
{code}
line(out, indent, 'class %s%s : public %s {',
_dll_export, cppname(names[-1]), absname(cppnames(superNames)))
{code}
are likely responsible.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Loading...