[m-rev.] diff: java varargs warnings

Peter Wang novalazy at gmail.com
Mon Jun 1 21:09:46 AEST 2009


Branches: main

The Java 5 compiler warns about a method with an array argument:

	m1(Object[] args)

overriding a method declared with varargs:

	m1(Object... args)

The Java 6 compiler accepts it, though I don't know if that was intended.


java/runtime/MethodPtr.java:
	Don't use varargs syntax for MethodPtr.call___0_0.

library/rtti_implementation.m:
	Explicitly create the Object[] arrays in foreign_procs.

Index: java/runtime/MethodPtr.java
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/java/runtime/MethodPtr.java,v
retrieving revision 1.2
diff -u -r1.2 MethodPtr.java
--- java/runtime/MethodPtr.java	30 Apr 2009 00:43:35 -0000	1.2
+++ java/runtime/MethodPtr.java	1 Jun 2009 10:54:00 -0000
@@ -10,6 +10,6 @@
 package mercury.runtime;
 
 public interface MethodPtr {
-	public abstract java.lang.Object call___0_0(java.lang.Object... args);
+	public abstract java.lang.Object call___0_0(java.lang.Object[] args);
 }
 
Index: library/rtti_implementation.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/library/rtti_implementation.m,v
retrieving revision 1.85
diff -u -r1.85 rtti_implementation.m
--- library/rtti_implementation.m	1 May 2009 05:54:11 -0000	1.85
+++ library/rtti_implementation.m	1 Jun 2009 10:54:00 -0000
@@ -796,7 +796,7 @@
     [will_not_call_mercury, promise_pure, thread_safe],
 "
     MethodPtr P = (MethodPtr) Pred;
-    Object res = P.call___0_0(X, Y);
+    Object res = P.call___0_0(new Object[] { X, Y });
     succeeded = ((Boolean) res).booleanValue();
 ").
 :- pragma foreign_proc("Java",
@@ -804,7 +804,7 @@
     [will_not_call_mercury, promise_pure, thread_safe],
 "
     MethodPtr P = (MethodPtr) Pred;
-    Object res = P.call___0_0(A, X, Y);
+    Object res = P.call___0_0(new Object[] { A, X, Y });
     succeeded = ((Boolean) res).booleanValue();
 ").
 :- pragma foreign_proc("Java",
@@ -812,7 +812,7 @@
     [will_not_call_mercury, promise_pure, thread_safe],
 "
     MethodPtr P = (MethodPtr) Pred;
-    Object res = P.call___0_0(A, B, X, Y);
+    Object res = P.call___0_0(new Object[] { A, B, X, Y });
     succeeded = ((Boolean) res).booleanValue();
 ").
 :- pragma foreign_proc("Java",
@@ -820,7 +820,7 @@
     [will_not_call_mercury, promise_pure, thread_safe],
 "
     MethodPtr P = (MethodPtr) Pred;
-    Object res = P.call___0_0(A, B, C, X, Y);
+    Object res = P.call___0_0(new Object[] { A, B, C, X, Y });
     succeeded = ((Boolean) res).booleanValue();
 ").
 :- pragma foreign_proc("Java",
@@ -828,7 +828,7 @@
     [will_not_call_mercury, promise_pure, thread_safe],
 "
     MethodPtr P = (MethodPtr) Pred;
-    Object res = P.call___0_0(A, B, C, D, X, Y);
+    Object res = P.call___0_0(new Object[] { A, B, C, D, X, Y });
     succeeded = ((Boolean) res).booleanValue();
 ").
 :- pragma foreign_proc("Java",
@@ -836,7 +836,7 @@
     [will_not_call_mercury, promise_pure, thread_safe],
 "
     MethodPtr P = (MethodPtr) Pred;
-    Object res = P.call___0_0(A, B, C, D, E, X, Y);
+    Object res = P.call___0_0(new Object[] { A, B, C, D, E, X, Y });
     succeeded = ((Boolean) res).booleanValue();
 ").
 
@@ -845,7 +845,7 @@
     [will_not_call_mercury, promise_pure, thread_safe],
 "
     MethodPtr P = (MethodPtr) Pred;
-    Res = P.call___0_0(X, Y);
+    Res = P.call___0_0(new Object[] { X, Y });
 ").
 
 :- pragma foreign_proc("Java",
@@ -853,28 +853,28 @@
     [will_not_call_mercury, promise_pure, thread_safe],
 "
     MethodPtr P = (MethodPtr) Pred;
-    Res = P.call___0_0(A, X, Y);
+    Res = P.call___0_0(new Object[] { A, X, Y });
 ").
 :- pragma foreign_proc("Java",
     result_call_6(Pred::in, Res::out, A::in, B::in, X::in, Y::in),
     [will_not_call_mercury, promise_pure, thread_safe],
 "
     MethodPtr P = (MethodPtr) Pred;
-    Res = P.call___0_0(A, B, X, Y);
+    Res = P.call___0_0(new Object[] { A, B, X, Y });
 ").
 :- pragma foreign_proc("Java",
     result_call_7(Pred::in, Res::out, A::in, B::in, C::in, X::in, Y::in),
     [will_not_call_mercury, promise_pure, thread_safe],
 "
     MethodPtr P = (MethodPtr) Pred;
-    Res = P.call___0_0(A, B, C, X, Y);
+    Res = P.call___0_0(new Object[] { A, B, C, X, Y });
 ").
 :- pragma foreign_proc("Java",
     result_call_8(Pred::in, Res::out, A::in, B::in, C::in, D::in, X::in, Y::in),
     [will_not_call_mercury, promise_pure, thread_safe],
 "
     MethodPtr P = (MethodPtr) Pred;
-    Res = P.call___0_0(A, B, C, D, X, Y);
+    Res = P.call___0_0(new Object[] { A, B, C, D, X, Y });
 ").
 :- pragma foreign_proc("Java",
     result_call_9(Pred::in, Res::out, A::in, B::in, C::in, D::in, E::in,
@@ -882,7 +882,7 @@
     [will_not_call_mercury, promise_pure, thread_safe],
 "
     MethodPtr P = (MethodPtr) Pred;
-    Res = P.call___0_0(A, B, C, D, E, X, Y);
+    Res = P.call___0_0(new Object[] { A, B, C, D, E, X, Y });
 ").
 
 %-----------------------------------------------------------------------------%

--------------------------------------------------------------------------
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