caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re: [Caml-list] OCaml-Java 2.0 preview: call for testers
@ 2012-08-11  2:02 John Prevost
  2012-08-14 18:19 ` forum
  0 siblings, 1 reply; 3+ messages in thread
From: John Prevost @ 2012-08-11  2:02 UTC (permalink / raw)
  To: ocamljava; +Cc: caml-list

Tried this out on Windows under cygwin and had a couple of problems.
CCing caml-list in case anybody else has run into similar.

1) There's some special code in bin/common to check for cygwin and use
cygpath to convert JAVA_HOME to a UNIX-style path.  That works...
except in the case that there's a space in the path (which there
almost certainly is on Windows).  Each of the scripts (bin/ocaml
bin/ocamljava, etc.) should use "$OCJ_JAVA" instead of $OCJ_JAVA (that
is: quote the variable so that spaces aren't interpreted as separate
tokens).  With this change, the scripts call Java correctly.

1a) It might be appropriate to see if "java" is on the path and try to
use that if JAVA_HOME is not set (as it was not on my machine).  The
batch files appear to do this already (and quote %OCJ_JAVA%, as well.)

2) With that change, ocamljava still didn't run right away.  It
appears to be because it's trying to parse the CLASSPATH environment
variable, but it's using UNIX rules to do so.  Since I don't know
what's going on inside, I can't say exactly why, but I can report the
error message:

File "test.ml", line 1, characters 0-1:
Error: Classpath error: ".;C" does not exist

(This happens with whatever input is provided to ocamljava.)

Two things here:

2a) It's interpreting the CLASSPATH as using : as a separator, whereas
it's actually using ; as a separator.  So, it sees ".;C:\..." and
thinks the first segment is ".;C"

2b) Even though it's interpreting the CLASSPATH wrong, it probably
still should not be an error for the CLASSPATH to contain paths that
do not exist.  Those should be ignored, rather than triggering an
error.

Finally, even though a stated goal is to be able to use Java's
libraries from OCaml code, there doesn't seem to be any documentation
on how to actually do that.  I tried using external just in case, but
if that's the mechanism I'm not sure how it's meant to be used.  A
little guidance on how to call into Java from OCaml would be
appreciated.  This would be helpful both to test that it works
correctly and to figure out if the abstraction that's provided is
adequate.

Hope these comments help.

John Prevost.

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

* Re: [Caml-list] OCaml-Java 2.0 preview: call for testers
  2012-08-11  2:02 [Caml-list] OCaml-Java 2.0 preview: call for testers John Prevost
@ 2012-08-14 18:19 ` forum
  0 siblings, 0 replies; 3+ messages in thread
From: forum @ 2012-08-14 18:19 UTC (permalink / raw)
  To: caml-list; +Cc: John Prevost, ocamljava, forum

John Prevost <j.prevost@gmail.com> a écrit :

> Tried this out on Windows under cygwin and had a couple of problems.
> CCing caml-list in case anybody else has run into similar.
>
> 1) There's some special code in bin/common to check for cygwin and use
> cygpath to convert JAVA_HOME to a UNIX-style path.  That works...
> except in the case that there's a space in the path (which there
> almost certainly is on Windows).  Each of the scripts (bin/ocaml
> bin/ocamljava, etc.) should use "$OCJ_JAVA" instead of $OCJ_JAVA (that
> is: quote the variable so that spaces aren't interpreted as separate
> tokens).  With this change, the scripts call Java correctly.
>
> 1a) It might be appropriate to see if "java" is on the path and try to
> use that if JAVA_HOME is not set (as it was not on my machine).  The
> batch files appear to do this already (and quote %OCJ_JAVA%, as well.)
>
> 2) With that change, ocamljava still didn't run right away.  It
> appears to be because it's trying to parse the CLASSPATH environment
> variable, but it's using UNIX rules to do so.  Since I don't know
> what's going on inside, I can't say exactly why, but I can report the
> error message:
>
> File "test.ml", line 1, characters 0-1:
> Error: Classpath error: ".;C" does not exist
>
> (This happens with whatever input is provided to ocamljava.)
>
> Two things here:
>
> 2a) It's interpreting the CLASSPATH as using : as a separator, whereas
> it's actually using ; as a separator.  So, it sees ".;C:\..." and
> thinks the first segment is ".;C"
>
> 2b) Even though it's interpreting the CLASSPATH wrong, it probably
> still should not be an error for the CLASSPATH to contain paths that
> do not exist.  Those should be ignored, rather than triggering an
> error.

Thanks for your detailed report. I have fixed all these issues, and
uploaded a new version of the archive. Would you be kind enough to
test if everything is fixed on your installation too?
The address is the same:
     http://ocamljava.x9c.fr/ocamljava-2.0-early-access.tar.gz


> Finally, even though a stated goal is to be able to use Java's
> libraries from OCaml code, there doesn't seem to be any documentation
> on how to actually do that.  I tried using external just in case, but
> if that's the mechanism I'm not sure how it's meant to be used.  A
> little guidance on how to call into Java from OCaml would be
> appreciated.  This would be helpful both to test that it works
> correctly and to figure out if the abstraction that's provided is
> adequate.

Well, I provided no guidance because the current build does not
include the typer extensions allowing to manipulate Java elements
from OCaml code. Such extensions are not complete yet (some tests
are missing, and arrays are not handled yet), and will be integrated
in a future build (hopefully in september).

In the meantime, here is how it works. Some "special" functions behave
as "printf", meaning that their actual type is based on a "format"
string literal. For example,
     Java.make "javax.swing.JButton(java.lang.String,javax.swing.Icon)" (x, y)
will create a "javax.swing.JButton" instance. The OCaml type of the
instance is "javax'swing'JButton java_instance" where "java_instance"
is a particular type whose parameter designates a Java class name
where dots are replaced by simple quote (to fit OCaml syntax).


> Hope these comments help.

They surely do! Thanks again!


Kind regards,

Xavier Clerc


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

* [Caml-list] OCaml-Java 2.0 preview: call for testers
@ 2012-08-02 15:21 forum
  0 siblings, 0 replies; 3+ messages in thread
From: forum @ 2012-08-02 15:21 UTC (permalink / raw)
  To: caml-list; +Cc: forum

Dear list,

The OCaml-Java is a project whose goal is to allow compilation
of OCaml sources to Java bytecode, thus allowing execution on
any JVM. The objectives are to gain access to a greater number
of libraries, and to be able to take advantage of multiple cores.

Quite a lot of work has been done in order to greatly improve
the performances of the code generated by the "ocamljava"
compiler. Roughly speaking, some preliminary benchmarks
seem to indicate that ocamljava-generated code is most of
the time less than three times slower than ocamlopt-generated one.

This very mail is sent to try to gather feedback from the community.
As of today, the source is neither stabilized nor complete, and only
a binary version is available. Installation is very simple: uncompress
the archive, and put the "bin" subdirectory in your path.
More information can be found in the "README" file of the archive.
The archive can be downloaded at the following address:
     http://ocamljava.x9c.fr/ocamljava-2.0-early-access.tar.gz

For this version, I am mostly interested in compatibility reports,
and performance considerations. Although the compiler is already
able to compile itself, it is probably wise to start with smaller
examples...


Thanks in advance for your feedback,

Xavier Clerc


PS: I would have prefered to put the file on http://forge.ocamlcore.org,
but was not able to upload such a big file (about 63 Mb)



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

end of thread, other threads:[~2012-08-14 18:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-11  2:02 [Caml-list] OCaml-Java 2.0 preview: call for testers John Prevost
2012-08-14 18:19 ` forum
  -- strict thread matches above, loose matches on Subject: below --
2012-08-02 15:21 forum

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 NNTP newsgroup(s).