comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: Ada/JVM: cannot import abstract subprogram
Date: Sat, 23 Mar 2013 11:09:24 -0700 (PDT)
Date: 2013-03-23T11:09:24-07:00	[thread overview]
Message-ID: <b9decf56-3529-47a9-a9ac-40b21f6b042d@googlegroups.com> (raw)
In-Reply-To: <nospam-04B5D0.10530723032013@news.aioe.org>

On Saturday, March 23, 2013 8:53:07 AM UTC-6, John B. Matthews wrote:
> 
> In Java, it's possible to instantiate an anonymous subclass of an 
> abstract class [1], but it's a compile-time error to instantiate an 
> abstract class directly [2].
> 
> Absent first-hand experience with jvm2ada, might this represent a way 
> to enforce a similar compile-time restriction on an Ada client that 
> tries to import an abstract parent, rather than a concrete subclass?

No. It's the same sort of error to try to create an instantiation of an abstract type in Ada. -- The problem is that jvm2ada is "helpfully" transliterating the the class-structure for the Java API... but taking no account of whether or not a subprogram spec already translated is abstract or not, OR that the jvm-gnat compiler is unable to say "ah, 'abstract' is the same thing in Ada and in Java, so the 'import' should be of no effect."

I went with the heavy-handed/inelegant method of trying to compile [with the -k switch] and then commenting out the import pragmas which were flagged as errors. {A poor solution but one that allows me to generate a good* class-file.}

So now I'm stumped on some other errors, namely: "must override interface operation 'WindowOpened' at java-awt-event-windowlistener.ads:38" {and related}. This is kind of odd, because Ada 2005 got the Java-style interfaces ** and the reason for the [new] error seems to be interfaces: http://docs.adacore.com/gnatvm-docs/jgnat_ug.html#Using-Java-Interfaces

* Oddly the compilation neglects an 'adainit' function; in order to use Ada.Text_IO.Put/Put_Line I have to import it from a different class that was generated in attempting to get everything working.

** Er, so why does the jvm2ada program for GNAT 2012 not generate interface types?



  reply	other threads:[~2013-03-23 18:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-22 19:56 Ada/JVM: cannot import abstract subprogram Shark8
2013-03-23 14:53 ` John B. Matthews
2013-03-23 18:09   ` Shark8 [this message]
2013-04-02 20:10     ` Blady
2013-04-03 12:05       ` Stephen Leake
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox