public inbox for kawa@sourceware.org
 help / color / mirror / Atom feed
* Class does not implement the requested interface
@ 2024-01-03 23:33 Panicz Maciej Godek
  2024-01-04  1:18 ` Per Bothner
  0 siblings, 1 reply; 4+ messages in thread
From: Panicz Maciej Godek @ 2024-01-03 23:33 UTC (permalink / raw)
  To: kawa

[-- Attachment #1: Type: text/plain, Size: 2408 bytes --]

I have another weird bug.
When I run a test suite for GRASP (by running Kawa directly, without
precompiling), I get the following error:

Exception in thread "main" java.lang.IncompatibleClassChangeError: Class
editor.interfaces.NoEditor does not implement the requested interface
editor.interfaces.WithCursor
at
;editor.CharPainter.markEditorCursor$Ex(text-painter.scm:85)
(stack trace continues)

The thing is, that all the required methods from the interface WithCursor
are implemented by NoEditor.

When I analyze the compiled classes, I get this (sorry for the formatting):

$ javap WithCursor.class
Compiled from "painting.scm"
public interface editor.interfaces.WithCursor {
public abstract void markCursor$Ex(gnu.math.RealNum, gnu.math.RealNum);
public abstract editor.interfaces.Position cursorPosition();
public abstract void setCursorColumn$Ex(gnu.math.RealNum);
public abstract gnu.math.RealNum cursorColumn();
public abstract gnu.math.RealNum currentLineHeight();
public abstract gnu.math.RealNum previousLineHeight();
}

$ javap Editor.class
Compiled from "elements.scm"
public interface editor.interfaces.Editor extends
editor.interfaces.Embeddable,java.lang.Cloneable,editor.interfaces.WithCursor
{
public abstract void addPostDrawAction$Ex(gnu.mapping.Procedure);
}

$ javap NoEditor.class
Compiled from "elements.scm"
public class editor.interfaces.NoEditor extends editor.interfaces.NullPane
implements editor.interfaces.Editor {
public editor.interfaces.Position marked;
public void addPostDrawAction$Ex(gnu.mapping.Procedure);
public void markCursor$Ex(gnu.math.RealNum, gnu.math.RealNum);
public gnu.math.RealNum currentLineHeight();
public gnu.math.RealNum previousLineHeight();
public editor.interfaces.Position cursorPosition();
public void setCursorColumn$Ex(gnu.math.RealNum);
public gnu.math.RealNum cursorColumn();
public editor.interfaces.NoEditor();
}

So it seems that all the requested methods of WithCursor (in particular
mark-cursor!) are present in the compiled code

NoEditor isn't used by the compiled code (it's a null-object that is
substituted by the actual instance early in the program's life time), but I
wanted to use it in the test suite to limit the dependencies of the test -
so I'm not sure if the compiled code wouldn't break here as well.

But I wonder why Kawa claims that the interface isn't implemented when
clearly all the required methods are present.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Class does not implement the requested interface
  2024-01-03 23:33 Class does not implement the requested interface Panicz Maciej Godek
@ 2024-01-04  1:18 ` Per Bothner
  2024-01-04  6:59   ` Panicz Maciej Godek
  0 siblings, 1 reply; 4+ messages in thread
From: Per Bothner @ 2024-01-04  1:18 UTC (permalink / raw)
  To: Panicz Maciej Godek, kawa

On 1/3/24 15:33, Panicz Maciej Godek via Kawa wrote:
> The thing is, that all the required methods from the interface WithCursor
> are implemented by NoEditor.
> 
> But I wonder why Kawa claims that the interface isn't implemented when
> clearly all the required methods are present.

Kawa, like Java, requires an interface to be *explicitly* implemented by a class.
It is not enough to implement all the methods of the interface.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Class does not implement the requested interface
  2024-01-04  1:18 ` Per Bothner
@ 2024-01-04  6:59   ` Panicz Maciej Godek
  2024-01-04  9:49     ` Panicz Maciej Godek
  0 siblings, 1 reply; 4+ messages in thread
From: Panicz Maciej Godek @ 2024-01-04  6:59 UTC (permalink / raw)
  To: Per Bothner; +Cc: kawa

[-- Attachment #1: Type: text/plain, Size: 805 bytes --]

Thanks for explanation.
But if the Editor interface extends WithCursor interface, and NoEditor
implements Editor interface, doesn't it imply that it implements WithCursor
interface?

czw., 4 sty 2024, 02:19 użytkownik Per Bothner <per@bothner.com> napisał:

> On 1/3/24 15:33, Panicz Maciej Godek via Kawa wrote:
> > The thing is, that all the required methods from the interface WithCursor
> > are implemented by NoEditor.
> >
> > But I wonder why Kawa claims that the interface isn't implemented when
> > clearly all the required methods are present.
>
> Kawa, like Java, requires an interface to be *explicitly* implemented by a
> class.
> It is not enough to implement all the methods of the interface.
> --
>         --Per Bothner
> per@bothner.com   http://per.bothner.com/
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Class does not implement the requested interface
  2024-01-04  6:59   ` Panicz Maciej Godek
@ 2024-01-04  9:49     ` Panicz Maciej Godek
  0 siblings, 0 replies; 4+ messages in thread
From: Panicz Maciej Godek @ 2024-01-04  9:49 UTC (permalink / raw)
  To: Per Bothner; +Cc: kawa

[-- Attachment #1: Type: text/plain, Size: 1366 bytes --]

I have found the reason for the misbehavior:

Editor and NoEditor are defined in (editor interfaces elements), whereas
WithCursor is defined in (editor interfaces painting).

The (editor interfaces painting) is imported as a dependency by (editor
interfaces elements). The test imported both modules, but it imported
(editor interfaces elements) before its dependency.

Swapping the order of imports resolved the issue.

czw., 4 sty 2024, 07:59 użytkownik Panicz Maciej Godek <
godek.maciek@gmail.com> napisał:

> Thanks for explanation.
> But if the Editor interface extends WithCursor interface, and NoEditor
> implements Editor interface, doesn't it imply that it implements WithCursor
> interface?
>
> czw., 4 sty 2024, 02:19 użytkownik Per Bothner <per@bothner.com> napisał:
>
>> On 1/3/24 15:33, Panicz Maciej Godek via Kawa wrote:
>> > The thing is, that all the required methods from the interface
>> WithCursor
>> > are implemented by NoEditor.
>> >
>> > But I wonder why Kawa claims that the interface isn't implemented when
>> > clearly all the required methods are present.
>>
>> Kawa, like Java, requires an interface to be *explicitly* implemented by
>> a class.
>> It is not enough to implement all the methods of the interface.
>> --
>>         --Per Bothner
>> per@bothner.com   http://per.bothner.com/
>>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-01-04 10:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-03 23:33 Class does not implement the requested interface Panicz Maciej Godek
2024-01-04  1:18 ` Per Bothner
2024-01-04  6:59   ` Panicz Maciej Godek
2024-01-04  9:49     ` Panicz Maciej Godek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).