comp.lang.ada
 help / color / mirror / Atom feed
* Ada/JVM: cannot import abstract subprogram
@ 2013-03-22 19:56 Shark8
  2013-03-23 14:53 ` John B. Matthews
  0 siblings, 1 reply; 5+ messages in thread
From: Shark8 @ 2013-03-22 19:56 UTC (permalink / raw)


A couple of years ago or so I got the three interesting GNAT compilers (Ada->native-windows, Ada->Dotnet-VM, and Ada->Java-VM) I remember getting some simple things working on the JVM one, enough that I could output text to the console via Java's println or Ada's Print_line as well as doing some minor applet manipulation (drawing shapes for a class).

Anyway, I was wondering about perhaps applying the idea over here ( http://ruby-in-browser.googlecode.com/svn/trunk/evalruby/index.html ), combining w/ OpenToken (which, IIUC, has an already-working out-of-the-box Ada tokenizer) and seeing what all I could do towards getting a <Script language="Ada"> tag working. {Yes, I know I'd also need a DOM package... but XML/Ada says it has one.}

So I went and grabbed the 2012 JVM-GNAT and tried the bind_jre program (after some failures w/ JVM2Ada) and found that it could not handle the new Java 7 (version 51 class-files, IIUC)... or the version 50 class files. So, I obtained Java 1.4 and installed that in an effort to get one that would bind... I was half-way successful: it dumped out the million-and-a-half (actually 3622) ADS files.

But there's a problem: in many of the files there are subprograms marked abstract and then pragmas for importation yielding the error of  "cannot import abstract subprogram" -- this leads me to believe there is something wrong with the jvm2ada packaged w/ GNAT GPL 2012 {remember it didn't generate these errors a couple years ago}... is anyone else having similar troubles? (I remember it being fairly easy to get the JVM-GNAT to generate [and interface w/] class-files, the rough spot being the Java-ideology of having all operations be on references and the Ada-ideology of operating on the types themselves.)

Also, it seems a bit odd that they [Adacore] didn't use the opportunity to show off the interfacing Aspects of Ada 2012 in this version of jvm2ada.



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

* Re: Ada/JVM: cannot import abstract subprogram
  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
  0 siblings, 1 reply; 5+ messages in thread
From: John B. Matthews @ 2013-03-23 14:53 UTC (permalink / raw)


In article <f011046e-f3ba-4fc3-86b1-2aded0036fe7@googlegroups.com>,
 Shark8 <onewingedshark@gmail.com> wrote:
[...]
> But there's a problem: in many of the files there are subprograms 
> marked abstract and then pragmas for importation yielding the error 
> of  "cannot import abstract subprogram" -- this leads me to believe 
> there is something wrong with the jvm2ada packaged w/ GNAT GPL 2012 
> {remember it didn't generate these errors a couple years ago}... is 
> anyone else having similar troubles? (I remember it being fairly easy 
> to get the JVM-GNAT to generate [and interface w/] class-files, the 
> rough spot being the Java-ideology of having all operations be on 
> references and the Ada-ideology of operating on the types 
> themselves.)

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?

[...]

[1]: <http://stackoverflow.com/a/13671003/230513>
[2]: <http://docs.oracle.com/javase/specs/jls/se7/html/jls-8.html#jls-8.1.1.1>
-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>



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

* Re: Ada/JVM: cannot import abstract subprogram
  2013-03-23 14:53 ` John B. Matthews
@ 2013-03-23 18:09   ` Shark8
  2013-04-02 20:10     ` Blady
  0 siblings, 1 reply; 5+ messages in thread
From: Shark8 @ 2013-03-23 18:09 UTC (permalink / raw)


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?



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

* Re: Ada/JVM: cannot import abstract subprogram
  2013-03-23 18:09   ` Shark8
@ 2013-04-02 20:10     ` Blady
  2013-04-03 12:05       ` Stephen Leake
  0 siblings, 1 reply; 5+ messages in thread
From: Blady @ 2013-04-02 20:10 UTC (permalink / raw)


Hello, a patch has to be applied on source code from JVM-GNAT.
See:
http://blady.pagesperso-orange.fr/telechargements/jgnat/jvm-gnat-gpl-2011.diff

These changes have been initiated by Stephe Leake (http://www.stephe- 
leake.org/) but they no longer seem to be on his web site.

You can have also a look on my web site page:
http://blady.pagesperso-orange.fr/alpha.html

On Mac OS X Intel, all seems to be fine but not with Applet, I've got an 
error: java.lang.ClassNotFoundException: Applet

Not fixed since then.

HTH, Pascal.

Le 23/03/13 19:09, Shark8 a �crit :
> 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?
>




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

* Re: Ada/JVM: cannot import abstract subprogram
  2013-04-02 20:10     ` Blady
@ 2013-04-03 12:05       ` Stephen Leake
  0 siblings, 0 replies; 5+ messages in thread
From: Stephen Leake @ 2013-04-03 12:05 UTC (permalink / raw)


Blady <p.p11@orange.fr> writes:

> Hello, a patch has to be applied on source code from JVM-GNAT.
> See:
> http://blady.pagesperso-orange.fr/telechargements/jgnat/jvm-gnat-gpl-2011.diff
>
> These changes have been initiated by Stephe Leake (http://www.stephe- 
> leake.org/) but they no longer seem to be on his web site.

Right; I gave up on JVM-GNAT for Android apps. I may find time to try
again when GNAT 2013 comes out.

-- 
-- Stephe



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

end of thread, other threads:[~2013-04-03 12:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2013-04-02 20:10     ` Blady
2013-04-03 12:05       ` Stephen Leake

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