Coder Social home page Coder Social logo

ocamljava's People

Contributors

struktured avatar xclerc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ocamljava's Issues

Failing to link a module/dependency in an OCaml script

Hello!
I encountered a problem when trying to generate the corresponding Java code for an OCaml program that is defining a dependency.

Consider the following example. The script main.ml is referring to a library:

open Libs
let () =
    let a = SimpleLib.saySomething in
    print_endline a

The library called SimpleLib is located in the directory ./libs/. For SimpleLib.ml:

let saySomething =
  "Hello!"

And SimpleLib.mli:

val saySomething : string

This call from the command-line
ocamljava -java-package wraptest -c main.ml is producing this error:

File "main.ml", line 2, characters 0-9:
Error: Unbound module Libs

How can I tell ocamljava to include this library? I use dune as build system which generates also a *.a and *.cmxa file.

The question on StackOverflow is related https://stackoverflow.com/questions/26227269/failing-to-link-standard-library-in-ocaml-java to my issue but unfortunately, the answers did not help.

My system details are:

$ ocaml --version
The OCaml toplevel, version 4.07.1
$ ocamljava -version
4.01.0
$ java -version
openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-0ubuntu0.18.04.1-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

The notation for Java classes cannot specify inner-classes.

There is no way to know whether a class is a "regular" class or
an "inner" one from the "pack'Class" notation, while it is actually
needed by the code generator, that has to issue class names in
internal form (i.e. using "/" or "$" according to the class kind).

This results in references to classes that do not exist, as the
current behavior somehow assumes that every classes are
"regular".

Inconsistent assumptions in compiler-libs interfaces

OCaml-Java 2.0-alpha1, freshly-installed from OPAM, has the following problem:

$ cat t.ml 
let g _ = Lambda.is_guarded
let h _ = Bytegen.reset
$ ocamljava -c -I +compiler-libs t.ml
File "t.ml", line 1:
Error: The files /home/jeremy/.opam/ocamljava-2.0-alpha1/lib/ocaml/compiler-libs/lambda.cmi
       and /home/jeremy/.opam/ocamljava-2.0-alpha1/lib/ocaml/compiler-libs/bytegen.cmi
       make inconsistent assumptions over interface Lambda

The ocamlobjinfo tool shows that the crcs are indeed different:

$ ocamlobjinfo bytegen.cmi lambda.cmi | grep Lambda
    f4443f50b0df5f177b11fcb7305bac35    Lambda
Unit name: Lambda
    e86623cfe85b127520d0debaecc42ab2    Lambda

Error "Java method is too long"

ocamljava fails with
"Error: Cannot compile goto_table_4081 (Java method is too long: 94429 bytes)"

The function in question is generated by Menhir into Coq, then extracted into OCaml, so I really have no way to make this function shorter.

I believe JVM methods are not limited to 65535 bytes in code length; only exception handlers are. See http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.3
code_length is a 32-bit integer. It's only the _pc fields of exception_table entries that are 16 bits. ("A historical mistake in the design" as the spec calls it.) In the Java standard library, you'll find several static class initialization methods that are > 64K in code length.

Would it be possible for ocamljava to emit this error only if there is an exception handler that overflows the first 64K of JVM code? This would fix my problem nicely, since the big function in question has no exception handlers, like all functions generated by Coq extraction.

What are the conditions of using Unix and Thread modules with ocamljava?

I was trying to determine how Unix and Thread are implemented. Do these modules still depend on C libraries or are they pure Java? I noticed, for instance, that some functions are not supported:

Unix.getpid();;
Exception: Invalid_argument "Unix.getpid not implemented".

Is this a natural consequence of tunneling all Unix calls through the JVM (that is, java doesn't strongly support a notion of a process ID)? Is the Thread module similarly implemented?

ocamljava error during linking on Windows; ocaml, ocamlc, & ocamlrun all work

First, thanks for a Java version of OCaml. For months I've been trying to find one programming language that's a good compromise between a number of things: functional, to go along with theorem proving, but with the potential for more easily tapping into parallel programming. I noticed your ForkJoin, MapReduce, etc., and since OCaml-Java is tied into Java, there's the possibility of Jcuda.

Now the problems. The second problem is the important one.

  • An easy problem is that the batch files don't work if there are spaces in the path. That's because there are no quotes around the jar file argument. A normal line looks like this:

    "%OCJ_JAVA%" -Xss8M -jar %~dp0/../lib/ocamlc.jar %*

It's not a problem, really. I just put the argument in quotes.

  • The reason I'm submitting this is because ocamljava gives the following error due to linking:

    E:\E_1\02-p\1o_jv_w rk_test> ocamljava -o "E:\E_1\02-p\1o_jv_w rk_test\hello_world.jar" "E:\E_1\02-p\1o_jv_w rk_test\hello_world.ml"
    File "E:\E_1\02-p\1o_jv_w rk_test\hello_world.ml", line 1:
    Error: Error during linking:
    unable to open archive ("\ocamljava-2.0-alpha2\lib\ocaml\ocamlrun.jar")

Here is some additional information.

  • I'm not having any problems like that for ocaml, ocamlc, and ocamlrun, which are the only other commands I've used.
  • If I compile and link in two steps, it still doesn't work.
  • I get the same error with ocamljava-2.0-alpha1.
  • I don't get that error with ocamljava-2.0-early-access11.

Thanks.

ocamljava for 32-bit windows

I have to port a tool written in OCaml on a 32-bit JVM. I'll surely rewrite the tool in another language for now, but I think it's quite sad to do so.

Do you plan to provide support for 32-bit platforms? It would be awesome to continue to use OCaml.

ocamllex always fails on java.nio.channels.ClosedChannelException

All invocations of ocamllex (the one packaged with ocamljava) fail when generating the .ml file. (My configuration: openjdk-7 on Linux).

Repro case:

$ echo 'rule main = parse "" { () }' > foo.mll
$ ocamllex foo.mll
1 states, 0 transitions, table size 6 bytes
Fatal error: exception Sys_error("java.nio.channels.ClosedChannelException")

Can't build from source

When trying to build the whole project from source, at step 7 (build and install extended ocamlbuild), compilation is giving the following error:

/home/vertmo/.opam/ocj/bin/ocamljava.opt unix.cmja -java-package ocaml.tools.ocamlbuild ocamlbuild_pack.cmj ocamlbuildlight.cmj -o ocamlbuildlight.jar                  
File "_none_", line 1:                                                                                                                                                    
Error: Error during linking:                                                                                                                                              
unable to read entry ("ocaml/tools/ocamlbuild/Options.class")                                                                                                             
Command exited with code 2.

This is happening both with alpha3 and alpha4.
I've tried changing my ocaml version (between 4.01.0 and 4.07.1), but I haven't had any success... Anyone ever encountered this problem ?

Error when installing ocamlfind with ocamljava

Hi,

I've just installed ocamljava on opam 1.2.0 with the following commands:

opam remote add ocj http://opam.ocamljava.org
opam switch ocamljava-2.0-alpha2
eval `opam config env`

When trying to install ocamlfind I get the following error listing:

Building ocamlfind.1.5.5:
  ./configure -bindir /Users/antoine/.opam/ocamljava-2.0-alpha2/bin -sitelib /Users/antoine/.opam/ocamljava-2.0-alpha2/lib -mandir /Users/antoine/.opam/ocamljava-2.0-alpha2/man -config /Users/antoine/.opam/ocamljava-2.0-alpha2/lib/findlib.conf
  make all
  make opt
  make install
[ERROR] The compilation of ocamlfind.1.5.5 failed.
Removing ocamlfind.1.5.5.
  ocamlfind remove bytes
  ./configure -bindir /Users/antoine/.opam/ocamljava-2.0-alpha2/bin -sitelib /Users/antoine/.opam/ocamljava-2.0-alpha2/lib -mandir /Users/antoine/.opam/ocamljava-2.0-alpha2/man -config /Users/antoine/.opam/ocamljava-2.0-alpha2/lib/findlib.conf
  make uninstall


#=== ERROR while installing ocamlfind.1.5.5 ===================================#
# opam-version 1.2.0
# os           darwin
# command      make all
# path         /Users/antoine/.opam/ocamljava-2.0-alpha2/build/ocamlfind.1.5.5
# compiler     ocamljava-2.0-alpha2
# exit-code    2
# env-file     /Users/antoine/.opam/ocamljava-2.0-alpha2/build/ocamlfind.1.5.5/ocamlfind-6629-6d07ae.env
# stdout-file  /Users/antoine/.opam/ocamljava-2.0-alpha2/build/ocamlfind.1.5.5/ocamlfind-6629-6d07ae.out
# stderr-file  /Users/antoine/.opam/ocamljava-2.0-alpha2/build/ocamlfind.1.5.5/ocamlfind-6629-6d07ae.err
### stdout ###
# ...[truncated]
# ocamlc -I +compiler-libs -custom -o ocamlfind -g findlib.cma unix.cma \
#              ocaml_args.cmo frontend.cmo
# if [ "false" = "true" ]; then                 \
#       cp topfind.ml.in topfind.ml;                             \
#   else                                                             \
#       sed -e '/PPXOPT_BEGIN/,/PPXOPT_END/ d' topfind.ml.in     \
#           > topfind.ml ;                                   \
#   fi
# ocamlc -I +compiler-libs -c topfind.mli
# ocamlc -I +compiler-libs -g -c topfind.ml
### stderr ###
# File "itest-aux/ppx.ml", line 1, characters 0-25:
# Error: Unbound value Toploop.preprocess_phrase
# Makefile:160: depend: No such file or directory
# File "topfind.ml", line 1:
# Error: The files /Users/antoine/.opam/ocamljava-2.0-alpha2/lib/ocaml/compiler-libs/toploop.cmi
#        and /Users/antoine/.opam/ocamljava-2.0-alpha2/lib/ocaml/compiler-libs/parsetree.cmi
#        make inconsistent assumptions over interface Warnings
# make[1]: *** [topfind.cmo] Error 2
# make: *** [all] Error 2

Here is my config:

  • OS X 10.10
  • opam 1.2.0
  • java 1.8.0_25-b17

Do you have any idea where the error could come from?

Thanks

Support for Facebook's Reason source format

Can OCaml-Java be used with Reasons new source format at all?

Native support for Reason, plus OCaml-Java would be a compelling language shift for existing JVM developers I think.

ps: is this project still alive?

ocamlfind won't build with ocamljava

When I try to build ocamlfind using the ocaml built with ocamljava I get an inconsistent assumptions over interface errors:

File "topfind.ml", line 1:
# Error: The files /Users/cox/.opam/ocamljava-2.0-alpha3/lib/ocaml/compiler-libs/toploop.cmi
#        and /Users/cox/.opam/ocamljava-2.0-alpha3/lib/ocaml/compiler-libs/parsetree.cmi
#        make inconsistent assumptions over interface Warnings
# make[1]: *** [topfind.cmo] Error 2

I tried to figure out how to fix it, but I couldn't figure out how to make the pieces of the build work outside of build.sh

OCaml 4.02.X support

Would be excited to use the ppx_tools lib, which depends on 4.02.0 or higher. Is there a road map for upgrading the ocamljava compiler version?

Inheritance of Java classes

I'm currently experimenting with OCamlJava, and I can't find a way to extends a java class (that would for instance offer some protected methods) from OCaml code. Is there a way to do it I cannot find, or is it impossible with OCamlJava ?

ocamljava has exit code 0 even on an error

ocamljava always exits with code 0 even if an error was detected during compilation. This makes ocamljava hard to use in a build system such as make, where the exit code is what determines success or failure of compilation.

Repro case:

echo "let _ = unbound" > bad.ml
ocamljava -c bad.ml
echo $?

I'm using openjdk-7 on Linux, if that matters.

There are at least two problems here:

1- The shell scripts in bin/ in the distribution do not propagate the return code of the java invocation. The fix is easy: just change the last command from

"$OCJ_JAVA" -Xss8M -jar ...

to

exec "$OCJ_JAVA" -Xss8M -jar ...

2- Even after the fix above, or if I bypass the shell script and call "java -jar .../ocamljava.jar" directly, the exit code is still 0. So, something else is wrong in the sources of the ocamljava compiler or in the reimplementation of Sys.exit.

Installation instruction for windows

First, I think that having ocaml run on a jvm is really fantastic. It means that with a few jars installed, you can have an ocaml distribution and, even more, you can access the whole java library. So thanks a lot ! and I wish this port were part of the standard ocaml distribution !

That being said, I cannot use it on windows, when I compile a simple ml file with ocamljava, it fails because it cannot link with ocamlrun.jar...(no pb mac os...)

Support for classpath resolution of jar resources

I am limited by the fact that ocamljava requires all jars to be co-located in the same library folder. Could parameters be added to override this so it's resolved from a classpath location instead?

This is the error:

java -cp /folder1/ocamljava.jar:/folder2/ocaml-lib-files.jar:/folder3/ocamlrun.jar ocaml.compilers.ocamljavaMain javalib.cmja -java-extensions -I ... -c ... company.ml
File "company.ml", line 1:
Error: Cannot compute stack frames for create_private_company_1012
("/ocamljava-2.0-alpha1/lib/ocaml/ocamlrun.jar" does not exist)

In java, I am suggesting something along the lines of this to load resources (rather than a file system path as it appears to be now):

http://stackoverflow.com/questions/1900154/classpath-resource-within-jar

Failing to add C stubs with ocamljava

OCaml allows to interface libraries written in C, for example. Therefore, C stubs must be added to use the C library. My question is, how can I produce a *.jar from OCaml source that has a reference to C stubs?

Consider the following library ocaml-minisat. This library is a binding to the Minisat-C-1.14.1 solver. The signature of the ocaml-minisat dependency is as follows:

module Raw : sig
  external create : unit -> t = "caml_minisat_new"
  external delete : t -> unit = "caml_minisat_delete"
  (* code omitted *)
end

The C stubs are located in the same directory with the filename libminisat_stubs.c.

Running ocamljava -c Minisat.mli works fine (the interface). After calling ocamljava -c Minisat.ml the following error is produced:

File "Minisat.ml", line 1:
Error: Primitive 'caml_minisat_new' cannot be found

Is there any way to tell ocamljava where the defined C stubs of the library are located?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.