[m-rev.] diff: assorted java library fixes

Peter Wang novalazy at gmail.com
Wed Apr 22 13:04:01 AEST 2009


Branches: main

java/runtime/ForeignEnumFunctorDesc.java:
java/runtime/TypeCtorInfo_Struct.java:
java/runtime/TypeFunctors.java:
library/backjump.m:
library/builtin.m:
library/io.m:
library/math.m:
library/mutvar.m:
library/par_builtin.m:
library/private_builtin.m:
library/region_builtin.m:
library/rtti_implementation.m:
library/store.m:
library/string.m:
library/thread.semaphore.m:
library/time.m:
library/type_desc.m:
        Assorted library fixes and stubs for the Java backend.

diff --git a/java/runtime/ForeignEnumFunctorDesc.java
b/java/runtime/ForeignEnumFunctorDesc.java
index 378836c..8f41dc9 100644
--- a/java/runtime/ForeignEnumFunctorDesc.java
+++ b/java/runtime/ForeignEnumFunctorDesc.java
@@ -15,6 +15,6 @@ public class ForeignEnumFunctorDesc {
 	public ForeignEnumFunctorDesc(String name, int ordinal, int value) {
 		foreign_enum_functor_name = name;
 		foreign_enum_functor_ordinal = ordinal;
-		foreign_enum_functor_value = value
+		foreign_enum_functor_value = value;
 	}
 }
diff --git a/java/runtime/TypeCtorInfo_Struct.java
b/java/runtime/TypeCtorInfo_Struct.java
index bc637a0..085ae6e 100644
--- a/java/runtime/TypeCtorInfo_Struct.java
+++ b/java/runtime/TypeCtorInfo_Struct.java
@@ -23,6 +23,7 @@ public class TypeCtorInfo_Struct extends PseudoTypeInfo {
 	public mercury.runtime.TypeLayout       type_layout;
 	public int 			        type_ctor_num_functors;
 	public /* short */ int 			type_ctor_flags;
+	public java.lang.Integer[]		type_functor_number_map;

 	public TypeCtorInfo_Struct(
 			int type_arity, int version, int num_ptags, int rep,
@@ -32,7 +33,8 @@ public class TypeCtorInfo_Struct extends PseudoTypeInfo {
 			java.lang.Object name_ordered_functor_descs,
 			// mercury.runtime.TypeLayout
 			java.lang.Object value_ordered_functor_descs,
-			int num_functors, int flags)
+			int num_functors, int flags,
+			java.lang.Integer[] functor_number_map)
 	{
 		arity = type_arity;
 		type_ctor_version = version;
@@ -47,6 +49,7 @@ public class TypeCtorInfo_Struct extends PseudoTypeInfo {
 		type_layout = (mercury.runtime.TypeLayout)
 			value_ordered_functor_descs;
 		type_ctor_flags = flags;
+		type_functor_number_map = functor_number_map;
 	}

 		// XXX this should be renamed `equals'
diff --git a/java/runtime/TypeFunctors.java b/java/runtime/TypeFunctors.java
index c89793c..1cec178 100644
--- a/java/runtime/TypeFunctors.java
+++ b/java/runtime/TypeFunctors.java
@@ -22,7 +22,7 @@ public class TypeFunctors {
 	public mercury.runtime.EnumFunctorDesc[] functors_enum() {
 		return (mercury.runtime.EnumFunctorDesc[]) functors_init;
 	}
-	public mercury.runtime.ForeignFunctorDesc[] functors_foreign_enum() {
+	public mercury.runtime.ForeignEnumFunctorDesc[] functors_foreign_enum() {
 		return (mercury.runtime.ForeignEnumFunctorDesc[]) functors_init;
 	}
 	public mercury.runtime.NotagFunctorDesc functors_notag() {
diff --git a/library/backjump.m b/library/backjump.m
index 59c89f7..4006f07 100644
--- a/library/backjump.m
+++ b/library/backjump.m
@@ -425,6 +425,25 @@
mercury_sys_init_backjumps_write_out_proc_statics(FILE *deep_fp,

 %-----------------------------------------------------------------------------%

+:- pragma foreign_code("Java", "
+
+    public static void
+    builtin_choice_id_1_p_0(mercury.runtime.MethodPtr cont,
+        /* env_ptr */ java.lang.Object cont_env_ptr)
+    {
+        throw new java.lang.Error(""builtin_choice_id/1 not implemented"");
+    }
+
+    public static void
+    builtin_backjump_1_p_0(int Id_2)
+    {
+        throw new java.lang.Error(""builtin_backjump/1 not implemented"");
+    }
+
+").
+
+%-----------------------------------------------------------------------------%
+
 :- pragma foreign_export("C", report_invalid_backjump(in, di, uo),
     "ML_report_invalid_backjump").

diff --git a/library/builtin.m b/library/builtin.m
index 4584b27..28ccfbf 100644
--- a/library/builtin.m
+++ b/library/builtin.m
@@ -1057,14 +1057,14 @@ namespace mercury.builtin {
     //

     public static boolean
-    __Unify____tuple_0_0(mercury.builtin.Tuple_0 x, mercury.builtin.Tuple_0 y)
+    __Unify____tuple_0_0(java.lang.Object[] x, java.lang.Object[] y)
     {
         // stub only
         throw new java.lang.Error (""unify/2 for tuple types not
implemented"");
     }

     public static boolean
-    __Unify____func_0_0(mercury.builtin.Func_0 x, mercury.builtin.Func_0 y)
+    __Unify____func_0_0(java.lang.Object[] x, java.lang.Object[] y)
     {
         // stub only
         throw new java.lang.Error (""unify/2 for tuple types not
implemented"");
@@ -1099,7 +1099,7 @@ namespace mercury.builtin {
     }

     public static Comparison_result_0
-    __Compare____func_0_0(mercury.builtin.Func_0 x, mercury.builtin.Func_0 y)
+    __Compare____func_0_0(java.lang.Object[] x, java.lang.Object[] y)
     {
         // comparing values of higher-order types is a run-time error
         throw new java.lang.Error (""compare/3 called for func type"");
diff --git a/library/io.m b/library/io.m
index d2accce..5995425 100644
--- a/library/io.m
+++ b/library/io.m
@@ -5651,7 +5651,7 @@ namespace mercury {
         public  int                         line_number = 1;

         // pushback is non-null only for input streams
-        private java.util.Stack             pushback    = null;
+        private java.util.Stack<Integer>    pushback    = null;

         // input is non-null only for text input streams
         private java.io.InputStreamReader   input       = null;
@@ -5704,7 +5704,7 @@ namespace mercury {
             if (mode == 'r') {
                 openstring = ""r"";
                 this.mode = INPUT;
-                pushback = new java.util.Stack();
+                pushback = new java.util.Stack<Integer>();
             } else if (mode == 'w' || mode == 'a') {
                 openstring = ""rw"";
                 this.mode = OUTPUT;
@@ -5730,7 +5730,7 @@ namespace mercury {
         {
             id          = ML_next_stream_id++;
             mode        = INPUT;
-            pushback    = new java.util.Stack();
+            pushback    = new java.util.Stack<Integer>();

             if (!openAsBinary) {
                 input = new java.io.InputStreamReader(stream);
@@ -5776,8 +5776,8 @@ namespace mercury {

             try {
                 java.lang.reflect.Method size_mth =
-                    channel.getClass().getMethod(""size"", null);
-                return ((Long) size_mth.invoke(channel, null)).intValue();
+                    channel.getClass().getMethod(""size"");
+                return ((Long) size_mth.invoke(channel)).intValue();
             } catch (java.lang.Exception e) {
                 if (binary_output != null) {
                     return position;
@@ -5828,7 +5828,7 @@ namespace mercury {
                     ""from the current position"");
             }

-            pushback = new java.util.Stack();
+            pushback = new java.util.Stack<Integer>();

             try {
                 switch (flag) {
@@ -5866,7 +5866,7 @@ namespace mercury {
         ** will still compile for Java versions < 1.4.
         */
         private void channelSeek(int flag, int offset) {
-            pushback = new java.util.Stack();
+            pushback = new java.util.Stack<Integer>();

             try {
                 switch (flag) {
@@ -5914,8 +5914,8 @@ namespace mercury {

             try {
                 java.lang.reflect.Method posn_mth =
-                    channel.getClass().getMethod(""position"", null);
-                return ((Long) posn_mth.invoke(channel, null)).intValue();
+                    channel.getClass().getMethod(""position"");
+                return ((Long) posn_mth.invoke(channel)).intValue();
             } catch (java.lang.Exception e) {
                 if (binary_input != null || binary_output != null) {
                     return position;
@@ -5945,7 +5945,7 @@ namespace mercury {
                     throw new java.lang.RuntimeException(e.getMessage());
                 }
             } else {
-                c = ((java.lang.Integer)pushback.pop()).intValue();
+                c = pushback.pop();
             }

             if (c == '\\n') {
@@ -5982,7 +5982,7 @@ namespace mercury {
                     throw new java.lang.RuntimeException(e.getMessage());
                 }
             } else {
-                c = ((java.lang.Integer)pushback.pop()).intValue();
+                c = pushback.pop();
             }
             position++;

@@ -6005,7 +6005,7 @@ namespace mercury {
                 line_number--;
             }

-            pushback.push(new Integer(c));
+            pushback.push(c);
             position--;
         }

@@ -6174,9 +6174,9 @@ namespace mercury {
             //  return o.getChannel();
             // using reflection.
             java.lang.reflect.Method getChannel_mth =
-                o.getClass().getMethod(""getChannel"", null);
+                o.getClass().getMethod(""getChannel"");

-            return getChannel_mth.invoke(o, null);
+            return getChannel_mth.invoke(o);
         }
         catch (java.lang.Exception e) {
             return null;
@@ -7398,28 +7398,28 @@ io.putback_byte(binary_input_stream(Stream),
Character, !IO) :-
 }").

 :- pragma foreign_proc("Java",
-    io.read_char_code(File::in, CharCode::out, _IO0::di, _IO::uo),
+    io.read_char_code_2(File::in, CharCode::out, _IO0::di, _IO::uo),
     [will_not_call_mercury, promise_pure],
 "
     CharCode = File.read_char();
 ").

 :- pragma foreign_proc("Java",
-    io.read_byte_val(File::in, ByteVal::out, _IO0::di, _IO::uo),
+    io.read_byte_val_2(File::in, ByteVal::out, _IO0::di, _IO::uo),
     [will_not_call_mercury, promise_pure],
 "
     ByteVal = File.read_byte();
 ").

 :- pragma foreign_proc("Java",
-    io.putback_char(File::in, Character::in, _IO0::di, _IO::uo),
+    io.putback_char_2(File::in, Character::in, _IO0::di, _IO::uo),
     [may_call_mercury, promise_pure, terminates],
 "
     File.ungetc(Character);
 ").

 :- pragma foreign_proc("Java",
-    io.putback_byte(File::in, Byte::in, _IO0::di, _IO::uo),
+    io.putback_byte_2(File::in, Byte::in, _IO0::di, _IO::uo),
     [may_call_mercury, promise_pure, terminates],
 "
     File.ungetc(Byte);
@@ -8119,14 +8119,14 @@
io.flush_binary_output(binary_output_stream(Stream), !IO) :-
 ").

 :- pragma foreign_proc("Java",
-    io.write_byte(Stream::in, Byte::in, _IO0::di, _IO::uo),
+    io.write_byte_2(Stream::in, Byte::in, _IO0::di, _IO::uo),
     [may_call_mercury, promise_pure, thread_safe, tabled_for_io, terminates],
 "
     Stream.put(Byte);
 ").

 :- pragma foreign_proc("Java",
-    io.write_bytes(Stream::in, Message::in, _IO0::di, _IO::uo),
+    io.write_bytes_2(Stream::in, Message::in, _IO0::di, _IO::uo),
     [may_call_mercury, promise_pure, thread_safe, tabled_for_io, terminates],
 "
     Stream.write(Message);
@@ -8140,7 +8140,7 @@
io.flush_binary_output(binary_output_stream(Stream), !IO) :-
 ").

 :- pragma foreign_proc("Java",
-    io.flush_binary_output(Stream::in, _IO0::di, _IO::uo),
+    io.flush_binary_output_2(Stream::in, _IO0::di, _IO::uo),
     [may_call_mercury, promise_pure, thread_safe, tabled_for_io, terminates],
 "
     Stream.flush();
@@ -8820,7 +8820,7 @@
io.set_binary_output_stream(binary_output_stream(NewStream),
 ").

 :- pragma foreign_proc("Java",
-    io.get_line_number(Stream::in, LineNum::out, _IO0::di, _IO::uo),
+    io.get_line_number_2(Stream::in, LineNum::out, _IO0::di, _IO::uo),
     [will_not_call_mercury, promise_pure, tabled_for_io],
 "{
     LineNum = Stream.line_number;
@@ -8834,7 +8834,7 @@
io.set_binary_output_stream(binary_output_stream(NewStream),
 ").

 :- pragma foreign_proc("Java",
-    io.set_line_number(Stream::in, LineNum::in, _IO0::di, _IO::uo),
+    io.set_line_number_2(Stream::in, LineNum::in, _IO0::di, _IO::uo),
     [will_not_call_mercury, promise_pure, tabled_for_io],
 "{
     Stream.line_number = LineNum;
@@ -8848,7 +8848,7 @@
io.set_binary_output_stream(binary_output_stream(NewStream),
 ").

 :- pragma foreign_proc("Java",
-    io.get_output_line_number(Stream::in, LineNum::out, _IO0::di, _IO::uo),
+    io.get_output_line_number_2(Stream::in, LineNum::out, _IO0::di, _IO::uo),
     [will_not_call_mercury, promise_pure, tabled_for_io],
 "{
     LineNum = Stream.line_number;
@@ -8862,7 +8862,7 @@
io.set_binary_output_stream(binary_output_stream(NewStream),
 ").

 :- pragma foreign_proc("Java",
-    io.set_output_line_number(Stream::in, LineNum::in, _IO0::di, _IO::uo),
+    io.set_output_line_number_2(Stream::in, LineNum::in, _IO0::di, _IO::uo),
     [will_not_call_mercury, promise_pure, tabled_for_io],
 "{
     Stream.line_number = LineNum;
@@ -8873,7 +8873,7 @@
io.set_binary_output_stream(binary_output_stream(NewStream),
     % Returns the previous stream.

 :- pragma foreign_proc("Java",
-    io.set_input_stream(NewStream::in, OutStream::out, _IO0::di, _IO::uo),
+    io.set_input_stream_2(NewStream::in, OutStream::out, _IO0::di, _IO::uo),
     [will_not_call_mercury, promise_pure, tabled_for_io],
 "
     OutStream = mercury_current_text_input;
@@ -8881,7 +8881,7 @@
io.set_binary_output_stream(binary_output_stream(NewStream),
 ").

 :- pragma foreign_proc("Java",
-    io.set_output_stream(NewStream::in, OutStream::out, _IO0::di, _IO::uo),
+    io.set_output_stream_2(NewStream::in, OutStream::out, _IO0::di, _IO::uo),
     [will_not_call_mercury, promise_pure, tabled_for_io],
 "
     OutStream = mercury_current_text_output;
@@ -8889,7 +8889,7 @@
io.set_binary_output_stream(binary_output_stream(NewStream),
 ").

 :- pragma foreign_proc("Java",
-    io.set_binary_input_stream(NewStream::in, OutStream::out,
+    io.set_binary_input_stream_2(NewStream::in, OutStream::out,
         _IO0::di, _IO::uo),
     [will_not_call_mercury, promise_pure, tabled_for_io],
 "
@@ -8898,7 +8898,7 @@
io.set_binary_output_stream(binary_output_stream(NewStream),
 ").

 :- pragma foreign_proc("Java",
-    io.set_binary_output_stream(NewStream::in, OutStream::out,
+    io.set_binary_output_stream_2(NewStream::in, OutStream::out,
         _IO0::di, _IO::uo),
     [will_not_call_mercury, promise_pure, tabled_for_io],
 "
diff --git a/library/math.m b/library/math.m
index b55384b..3bc1c32 100644
--- a/library/math.m
+++ b/library/math.m
@@ -446,12 +446,6 @@ math.e = 2.7182818284590452353602874713526625.
 "
     Rounded = java.lang.Math.round(Num);
 ").
-:- pragma foreign_proc("Java",
-    math.round(Num::in) = (Rounded::out),
-    [will_not_call_mercury, promise_pure, thread_safe],
-"
-    Rounded = java.lang.Math.round(Num);
-").
 :- pragma foreign_proc("Erlang",
     math.round(Num::in) = (Rounded::out),
     [will_not_call_mercury, promise_pure, thread_safe],
diff --git a/library/mutvar.m b/library/mutvar.m
index c6354b5..46abf56 100644
--- a/library/mutvar.m
+++ b/library/mutvar.m
@@ -142,6 +142,13 @@ new_mutvar(X, Ref) :-
 "
     public static class Mutvar {
         public Object object;
+
+        public Mutvar() {
+        }
+
+        public Mutvar(Object o) {
+            object = o;
+        }
     }
 ").

diff --git a/library/par_builtin.m b/library/par_builtin.m
index c90f2a5..7dc7efc 100644
--- a/library/par_builtin.m
+++ b/library/par_builtin.m
@@ -93,8 +93,8 @@

     % Placeholder only.
 :- pragma foreign_type(il, future(T), "class [mscorlib]System.Object").
-
 :- pragma foreign_type("Erlang", future(T), "").
+:- pragma foreign_type("Java", future(T), "java.lang.Object").

 :- pragma foreign_proc("C",
     new_future(Future::uo),
diff --git a/library/private_builtin.m b/library/private_builtin.m
index 73f1e2f..312ceb4 100644
--- a/library/private_builtin.m
+++ b/library/private_builtin.m
@@ -1692,6 +1692,16 @@ no_clauses(PredName) :-
     }

     public static boolean
+    __Unify____type_ctor_info_0_0(
+        mercury.runtime.TypeCtorInfo_Struct x,
+        mercury.runtime.TypeCtorInfo_Struct y)
+    {
+        // stub only
+        throw new java.lang.Error
+            (""unify/2 for type type_ctor_info/1"");
+    }
+
+    public static boolean
     __Unify____type_ctor_info_1_0(mercury.runtime.TypeInfo_Struct ti,
         mercury.runtime.TypeCtorInfo_Struct x,
         mercury.runtime.TypeCtorInfo_Struct y)
@@ -1702,6 +1712,16 @@ no_clauses(PredName) :-
     }

     public static boolean
+    __Unify____type_info_0_0(
+        mercury.runtime.TypeInfo_Struct x,
+        mercury.runtime.TypeInfo_Struct y)
+    {
+        // stub only
+        throw new java.lang.Error
+            (""unify/2 for type type_info/0"");
+    }
+
+    public static boolean
     __Unify____type_info_1_0(mercury.runtime.TypeInfo_Struct ti,
         mercury.runtime.TypeInfo_Struct x,
         mercury.runtime.TypeInfo_Struct y)
@@ -1712,6 +1732,14 @@ no_clauses(PredName) :-
     }

     public static boolean
+    __Unify____base_typeclass_info_0_0(
+        java.lang.Object[] x, java.lang.Object[] y)
+    {
+        // stub only
+        throw new java.lang.Error(""unify/2 for type typeclass_info/0"");
+    }
+
+    public static boolean
     __Unify____base_typeclass_info_1_0(mercury.runtime.TypeInfo_Struct ti,
         java.lang.Object[] x, java.lang.Object[] y)
     {
@@ -1720,6 +1748,14 @@ no_clauses(PredName) :-
     }

     public static boolean
+    __Unify____typeclass_info_0_0(java.lang.Object[] x, java.lang.Object[] y)
+    {
+        // stub only
+        throw new java.lang.Error
+            (""unify/2 for type typeclass_info/1"");
+    }
+
+    public static boolean
     __Unify____typeclass_info_1_0(mercury.runtime.TypeInfo_Struct ti,
         java.lang.Object[] x, java.lang.Object[] y)
     {
@@ -1747,6 +1783,16 @@ no_clauses(PredName) :-
     }

     public static mercury.builtin.Comparison_result_0
+    __Compare____type_ctor_info_0_0(
+        mercury.runtime.TypeCtorInfo_Struct x,
+        mercury.runtime.TypeCtorInfo_Struct y)
+    {
+        // stub only
+        throw new java.lang.Error
+            (""compare/2 for type type_ctor_info/1"");
+    }
+
+    public static mercury.builtin.Comparison_result_0
     __Compare____type_ctor_info_1_0(mercury.runtime.TypeInfo_Struct ti,
         mercury.runtime.TypeCtorInfo_Struct x,
         mercury.runtime.TypeCtorInfo_Struct y)
@@ -1757,6 +1803,16 @@ no_clauses(PredName) :-
     }

     public static mercury.builtin.Comparison_result_0
+    __Compare____type_info_0_0(
+        mercury.runtime.TypeInfo_Struct x,
+        mercury.runtime.TypeInfo_Struct y)
+    {
+        // stub only
+        throw new java.lang.Error
+            (""compare/2 for type type_info/0"");
+    }
+
+    public static mercury.builtin.Comparison_result_0
     __Compare____type_info_1_0(mercury.runtime.TypeInfo_Struct ti,
         mercury.runtime.TypeInfo_Struct x,
         mercury.runtime.TypeInfo_Struct y)
@@ -1767,6 +1823,14 @@ no_clauses(PredName) :-
     }

     public static mercury.builtin.Comparison_result_0
+    __Compare____base_typeclass_info_0_0(
+        java.lang.Object[] x, java.lang.Object[] y)
+    {
+        // stub only
+        throw new java.lang.Error(""compare/2 for type typeclass_info/1"");
+    }
+
+    public static mercury.builtin.Comparison_result_0
     __Compare____base_typeclass_info_1_0(mercury.runtime.TypeInfo_Struct ti,
         java.lang.Object[] x, java.lang.Object[] y)
     {
@@ -1775,6 +1839,14 @@ no_clauses(PredName) :-
     }

     public static mercury.builtin.Comparison_result_0
+    __Compare____typeclass_info_0_0(java.lang.Object[] x, java.lang.Object[] y)
+    {
+        // stub only
+        throw new java.lang.Error
+            (""compare/2 for type typeclass_info/0"");
+    }
+
+    public static mercury.builtin.Comparison_result_0
     __Compare____typeclass_info_1_0(mercury.runtime.TypeInfo_Struct ti,
         java.lang.Object[] x, java.lang.Object[] y)
     {
@@ -1835,5 +1907,17 @@ no_clauses(PredName) :-
     SUCCESS_INDICATOR = false
 ").

+:- pragma foreign_proc("Java",
+    trace_evaluate_runtime_condition,
+    [will_not_call_mercury, thread_safe, promise_semipure,
+        does_not_affect_liveness],
+"
+    if (true) {
+        /* All uses of this predicate should override the body. */
+        throw new java.lang.RuntimeException(
+            ""trace_evaluate_runtime_condition called"");
+    }
+").
+
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
diff --git a/library/region_builtin.m b/library/region_builtin.m
index 90c30e0..5f62abc 100644
--- a/library/region_builtin.m
+++ b/library/region_builtin.m
@@ -52,6 +52,8 @@
 :- pragma foreign_type("C", region, "MR_RegionHeader *",
     [can_pass_as_mercury_type]).

+:- pragma foreign_type("Java", region, "java.lang.Object"). % dummy
+
 :- pragma foreign_proc("C",
     create_region(Region::out),
     [will_not_call_mercury],
diff --git a/library/rtti_implementation.m b/library/rtti_implementation.m
index befc654..0e17266 100644
--- a/library/rtti_implementation.m
+++ b/library/rtti_implementation.m
@@ -2575,7 +2575,7 @@ foreign_enum_functor_desc(_, Num, TypeFunctors)
= ForeignEnumFunctorDesc :-
         TypeFunctors::in) = (ForeignEnumFunctorDesc::out),
     [will_not_call_mercury, promise_pure, thread_safe],
 "
-    ForeignEnumFunctorDesc = (TypeFunctors.functors_enum())[X];
+    ForeignEnumFunctorDesc = (TypeFunctors.functors_foreign_enum())[X];
 ").

 :- func foreign_enum_functor_name(foreign_enum_functor_desc) = string.
@@ -2587,7 +2587,7 @@ foreign_enum_functor_name(ForeignEnumFunctorDesc) =
     foreign_enum_functor_name(ForeignEnumFunctorDesc::in) = (Name::out),
     [will_not_call_mercury, promise_pure, thread_safe],
 "
-    Name = ForeignEnumFunctorDesc.enum_functor_name;
+    Name = ForeignEnumFunctorDesc.foreign_enum_functor_name;
 ").

  %--------------------------%
diff --git a/library/store.m b/library/store.m
index ebbf3ab..6723b2d 100644
--- a/library/store.m
+++ b/library/store.m
@@ -291,7 +291,7 @@ store.new(S) :-
     store.do_init(_S0::uo),
     [will_not_call_mercury, promise_pure],
 "
-    // TypeInfo_for_S
+    TypeInfo_for_S = null;
 ").
 :- pragma foreign_proc("Erlang",
     store.do_init(_S0::uo),
@@ -416,7 +416,7 @@ copy_mutvar(Mutvar, Copy, !S) :-
     unsafe_new_uninitialized_mutvar(Mutvar::out, _S0::di, _S::uo),
     [will_not_call_mercury, promise_pure],
 "
-    Mutvar = new mercury.mutvar.Mutvar(null);
+    Mutvar = new mercury.mutvar.Mutvar();
 ").

 store.new_cyclic_mutvar(Func, MutVar, !Store) :-
diff --git a/library/string.m b/library/string.m
index 50eb29c..93d455a 100644
--- a/library/string.m
+++ b/library/string.m
@@ -1219,6 +1219,14 @@ string.c_pointer_to_string(C_Pointer, Str) :-
     private_builtin.unsafe_type_cast(C_Pointer, Int),
     Str = "c_pointer(0x" ++ string.int_to_base_string(Int, 16) ++ ")".

+:- pragma foreign_proc("Java",
+    string.c_pointer_to_string(C_Pointer::in, Str::uo),
+    [will_not_call_mercury, promise_pure, thread_safe],
+"
+    /* Within the spirit of the function, at least. */
+    Str = C_Pointer.toString();
+").
+
 string.int_to_string_thousands(N) =
     string.int_to_base_string_group(N, 10, 3, ",").

diff --git a/library/thread.semaphore.m b/library/thread.semaphore.m
index 002b882..8e06e48 100644
--- a/library/thread.semaphore.m
+++ b/library/thread.semaphore.m
@@ -96,6 +96,7 @@ public class ML_Semaphore {
 :- pragma foreign_type("IL", semaphore,
     "class [mercury]mercury.thread.semaphore__csharp_code.mercury_code.ML_Semaphore").
 :- pragma foreign_type("Erlang", semaphore, "").
+:- pragma foreign_type("Java", semaphore, "java.util.concurrent.Semaphore").

 :- pragma foreign_decl("C", "
 extern void
diff --git a/library/time.m b/library/time.m
index 37dd9fc..42e499a 100644
--- a/library/time.m
+++ b/library/time.m
@@ -911,8 +911,8 @@ getDSTSavings(java.util.TimeZone tz) {
         // using reflection.

         return ((java.lang.Integer) (tz.getClass().
-            getMethod(""getDSTSavings"", null).
-            invoke(tz, null))).intValue();
+            getMethod(""getDSTSavings"").
+            invoke(tz))).intValue();
     }
     catch (java.lang.Exception e) {
         throw new java.lang.RuntimeException(
diff --git a/library/type_desc.m b/library/type_desc.m
index 8976bd4..b430928 100644
--- a/library/type_desc.m
+++ b/library/type_desc.m
@@ -400,6 +400,29 @@
ground_pseudo_type_desc_to_type_desc_det(PseudoTypeDesc) = TypeDesc :-
         error("ground_pseudo_type_desc_to_type_desc_det: not ground")
     ).

+:- pragma foreign_proc("Java",
+    ground_pseudo_type_desc_to_type_desc(PseudoTypeDesc::in) = (TypeDesc::out),
+    [will_not_call_mercury, promise_pure, thread_safe, will_not_modify_trail],
+"
+    /* PseudoTypeDesc, TypeDesc */
+    if (true) {
+        throw new java.lang.Error(
+            ""ground_pseudo_type_desc_to_type_desc/2 not implemented"");
+    }
+").
+
+:- pragma foreign_proc("Java",
+    ground_pseudo_type_desc_to_type_desc_det(PseudoTypeDesc::in)
+        = (TypeDesc::out),
+    [will_not_call_mercury, promise_pure, thread_safe, will_not_modify_trail],
+"
+    /* PseudoTypeDesc, TypeDesc */
+    if (true) {
+        throw new java.lang.Error(
+            ""ground_pseudo_type_desc_to_type_desc_det/2 not implemented"");
+    }
+").
+
 :- pragma foreign_proc("C",
     type_of(_Value::unused) = (TypeInfo::out),
     [will_not_call_mercury, thread_safe, promise_pure, will_not_modify_trail,
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list