[m-rev.] diff: make rtti serialisable in java

Peter Wang novalazy at gmail.com
Mon Sep 7 13:11:05 AEST 2009


Branches: main

Mark Java RTTI classes as implementing java.io.Serializable to
enable serialization of existentially typed values.

java/runtime/DuExistInfo.java:
java/runtime/DuExistLocn.java:
java/runtime/DuFunctorDesc.java:
java/runtime/DuPtagLayout.java:
java/runtime/EnumFunctorDesc.java:
java/runtime/ForeignEnumFunctorDesc.java:
java/runtime/MethodPtr.java:
java/runtime/NotagFunctorDesc.java:
java/runtime/PseudoTypeInfo.java:
java/runtime/ReservedAddrFunctorDesc.java:
java/runtime/Sectag_Locn.java:
java/runtime/TypeClassConstraint.java:
java/runtime/TypeClassDeclStruct.java:
java/runtime/TypeClassId.java:
java/runtime/TypeClassMethod.java:
java/runtime/TypeCtorInfo_Struct.java:
java/runtime/TypeCtorRep.java:
java/runtime/TypeFunctors.java:
java/runtime/TypeInfo_Struct.java:
java/runtime/TypeLayout.java:
        As above.

        TypeCtorInfo_Struct.unify() cannot rely on the uniqueness of
        TypeCtorInfo_Struct instances, as deserialisation will create new
        copies.

diff --git a/java/runtime/DuExistInfo.java b/java/runtime/DuExistInfo.java
index 0c70de5..3860f8b 100644
--- a/java/runtime/DuExistInfo.java
+++ b/java/runtime/DuExistInfo.java
@@ -6,7 +6,7 @@
 
 package jmercury.runtime;
 
-public class DuExistInfo {
+public class DuExistInfo implements java.io.Serializable {
 	
 	public int exist_typeinfos_plain;
 	public int exist_typeinfos_in_tci;
diff --git a/java/runtime/DuExistLocn.java b/java/runtime/DuExistLocn.java
index 3611f3c..abb2db8 100644
--- a/java/runtime/DuExistLocn.java
+++ b/java/runtime/DuExistLocn.java
@@ -8,7 +8,7 @@ package jmercury.runtime;
 
 // Corresponds to MR_DuExistLocn in runtime/mercury_type_info.h
 
-public class DuExistLocn {
+public class DuExistLocn implements java.io.Serializable {
 	public int exist_arg_num;
 	public int exist_offset_in_tci;
 
diff --git a/java/runtime/DuFunctorDesc.java b/java/runtime/DuFunctorDesc.java
index 3483500..1deb3e6 100644
--- a/java/runtime/DuFunctorDesc.java
+++ b/java/runtime/DuFunctorDesc.java
@@ -6,7 +6,7 @@
 
 package jmercury.runtime;
 
-public class DuFunctorDesc {
+public class DuFunctorDesc implements java.io.Serializable {
     
 	public java.lang.String du_functor_name;
 	public int du_functor_orig_arity;
diff --git a/java/runtime/DuPtagLayout.java b/java/runtime/DuPtagLayout.java
index 583f095..993eed6 100644
--- a/java/runtime/DuPtagLayout.java
+++ b/java/runtime/DuPtagLayout.java
@@ -6,7 +6,7 @@
 
 package jmercury.runtime;
 
-public class DuPtagLayout {
+public class DuPtagLayout implements java.io.Serializable {
 	
 	public int sectag_sharers;
 	public Sectag_Locn sectag_locn;
diff --git a/java/runtime/EnumFunctorDesc.java b/java/runtime/EnumFunctorDesc.java
index a2468fa..84077a2 100644
--- a/java/runtime/EnumFunctorDesc.java
+++ b/java/runtime/EnumFunctorDesc.java
@@ -6,7 +6,7 @@
 
 package jmercury.runtime;
 
-public class EnumFunctorDesc {
+public class EnumFunctorDesc implements java.io.Serializable {
 	
 	public java.lang.String enum_functor_name;
 	public int              enum_functor_ordinal;
diff --git a/java/runtime/ForeignEnumFunctorDesc.java b/java/runtime/ForeignEnumFunctorDesc.java
index 1f18eb7..e69d35a 100644
--- a/java/runtime/ForeignEnumFunctorDesc.java
+++ b/java/runtime/ForeignEnumFunctorDesc.java
@@ -6,7 +6,7 @@
 
 package jmercury.runtime;
 
-public class ForeignEnumFunctorDesc {
+public class ForeignEnumFunctorDesc implements java.io.Serializable {
 
 	public java.lang.String		foreign_enum_functor_name;
 	public int			foreign_enum_functor_ordinal;
diff --git a/java/runtime/MethodPtr.java b/java/runtime/MethodPtr.java
index 5a6dee0..a0002f5 100644
--- a/java/runtime/MethodPtr.java
+++ b/java/runtime/MethodPtr.java
@@ -9,6 +9,6 @@
 
 package jmercury.runtime;
 
-public interface MethodPtr {
+public interface MethodPtr extends java.io.Serializable {
 }
 
diff --git a/java/runtime/NotagFunctorDesc.java b/java/runtime/NotagFunctorDesc.java
index dc43aca..1ff3d2f 100644
--- a/java/runtime/NotagFunctorDesc.java
+++ b/java/runtime/NotagFunctorDesc.java
@@ -6,7 +6,7 @@
 
 package jmercury.runtime;
 
-public class NotagFunctorDesc {
+public class NotagFunctorDesc implements java.io.Serializable {
 	
 	public java.lang.String no_tag_functor_name;
 	public PseudoTypeInfo no_tag_functor_arg_type;
diff --git a/java/runtime/PseudoTypeInfo.java b/java/runtime/PseudoTypeInfo.java
index 318f360..45d9a77 100644
--- a/java/runtime/PseudoTypeInfo.java
+++ b/java/runtime/PseudoTypeInfo.java
@@ -21,7 +21,7 @@ package jmercury.runtime;
 //     which extends PseudoTypeInfo, and uses the protected constructor
 //     which sets variable_number to -1.
 //
-public class PseudoTypeInfo {
+public class PseudoTypeInfo implements java.io.Serializable {
 	public int variable_number;
 	public    PseudoTypeInfo(int n) { variable_number = n; }
 	protected PseudoTypeInfo()      { variable_number = -1; }
diff --git a/java/runtime/ReservedAddrFunctorDesc.java b/java/runtime/ReservedAddrFunctorDesc.java
index 3baa452..3b9ecc5 100644
--- a/java/runtime/ReservedAddrFunctorDesc.java
+++ b/java/runtime/ReservedAddrFunctorDesc.java
@@ -9,7 +9,7 @@
 
 package jmercury.runtime;
 
-public class ReservedAddrFunctorDesc {
+public class ReservedAddrFunctorDesc implements java.io.Serializable {
 	public java.lang.String		ra_functor_name;
 	public int			ra_ordinal;
 	public java.lang.Object		ra_reserved_addr;
diff --git a/java/runtime/Sectag_Locn.java b/java/runtime/Sectag_Locn.java
index d56e3c3..ff1d38e 100644
--- a/java/runtime/Sectag_Locn.java
+++ b/java/runtime/Sectag_Locn.java
@@ -6,7 +6,7 @@
 
 package jmercury.runtime;
 
-public class Sectag_Locn {
+public class Sectag_Locn implements java.io.Serializable {
 	
 	public static final int MR_SECTAG_NONE = 0;
 	public static final int MR_SECTAG_LOCAL = 1;
diff --git a/java/runtime/TypeClassConstraint.java b/java/runtime/TypeClassConstraint.java
index cc4279b..c64b502 100644
--- a/java/runtime/TypeClassConstraint.java
+++ b/java/runtime/TypeClassConstraint.java
@@ -9,7 +9,7 @@ package jmercury.runtime;
 // This corresponds to the C type MR_TypeClassConstraint
 // in runtime/mercury_type_info.h.
 
-public class TypeClassConstraint {
+public class TypeClassConstraint implements java.io.Serializable {
 	public TypeClassDeclStruct	tc_constr_type_class;
 	public PseudoTypeInfo		tc_constr_arg_ptis[];
 
diff --git a/java/runtime/TypeClassDeclStruct.java b/java/runtime/TypeClassDeclStruct.java
index ce07e95..d643806 100644
--- a/java/runtime/TypeClassDeclStruct.java
+++ b/java/runtime/TypeClassDeclStruct.java
@@ -10,7 +10,7 @@ package jmercury.runtime;
 // in runtime/mercury_types.h, i.e. the C struct
 // "struct MR_TypeClassDecl_Struct" in runtime/mercury_typeclass_info.h.
 
-public class TypeClassDeclStruct {
+public class TypeClassDeclStruct implements java.io.Serializable {
 	public TypeClassId		tc_decl_id;
 	public int			tc_decl_version_number;
 	public int			tc_decl_num_supers; // redundant
diff --git a/java/runtime/TypeClassId.java b/java/runtime/TypeClassId.java
index 0f35f7a..efdcf56 100644
--- a/java/runtime/TypeClassId.java
+++ b/java/runtime/TypeClassId.java
@@ -9,7 +9,7 @@ package jmercury.runtime;
 // This corresponds to the C type MR_TypeClassId
 // in runtime/mercury_typeclass_info.h.
 
-public class TypeClassId {
+public class TypeClassId implements java.io.Serializable {
 	public String			tc_id_module_name;
 	public String			tc_id_name;
 	public int			tc_id_arity;
diff --git a/java/runtime/TypeClassMethod.java b/java/runtime/TypeClassMethod.java
index 379fe97..c51d3c5 100644
--- a/java/runtime/TypeClassMethod.java
+++ b/java/runtime/TypeClassMethod.java
@@ -9,7 +9,7 @@ package jmercury.runtime;
 // This corresponds to the C type MR_TypeClassMethod
 // in runtime/mercury_typeclass_info.h.
 
-public class TypeClassMethod {
+public class TypeClassMethod implements java.io.Serializable {
 	public /* final */ java.lang.String		tc_method_name;
 	public /* final */ int				tc_method_arity;
 	public /* final */ int /* PredFunc */		tc_method_pred_func;
diff --git a/java/runtime/TypeCtorInfo_Struct.java b/java/runtime/TypeCtorInfo_Struct.java
index 8e8448d..c2dc547 100644
--- a/java/runtime/TypeCtorInfo_Struct.java
+++ b/java/runtime/TypeCtorInfo_Struct.java
@@ -9,8 +9,9 @@ package jmercury.runtime;
 // This corresponds to the C type "struct MR_TypeCtorInfo_Struct"
 // in runtime/mercury_type_info.h.
 
-public class TypeCtorInfo_Struct extends PseudoTypeInfo {
-    
+public class TypeCtorInfo_Struct extends PseudoTypeInfo
+	implements java.io.Serializable
+{
 	public int                  arity;
 	public int                  type_ctor_version;
 	public int                  type_ctor_num_ptags; // if DU
@@ -57,11 +58,11 @@ public class TypeCtorInfo_Struct extends PseudoTypeInfo {
 
 		// XXX this should be renamed `equals'
 	public boolean unify(TypeCtorInfo_Struct tci) {
-		return this == tci;
-		/*
+		if (this == tci) {
+			return true;
+		}
 		return type_ctor_module_name.equals(tci.type_ctor_module_name)
 				&& type_ctor_name.equals(tci.type_ctor_name)
 				&& arity == tci.arity;
-		*/
 	}
 }
diff --git a/java/runtime/TypeCtorRep.java b/java/runtime/TypeCtorRep.java
index 71e47ef..b1ec0ec 100644
--- a/java/runtime/TypeCtorRep.java
+++ b/java/runtime/TypeCtorRep.java
@@ -6,7 +6,7 @@
 
 package jmercury.runtime;
 
-public class TypeCtorRep {
+public class TypeCtorRep implements java.io.Serializable {
 	
 	// Constants
 	
diff --git a/java/runtime/TypeFunctors.java b/java/runtime/TypeFunctors.java
index c9ea1f9..dd5cad2 100644
--- a/java/runtime/TypeFunctors.java
+++ b/java/runtime/TypeFunctors.java
@@ -13,7 +13,7 @@ package jmercury.runtime;
 //   mercury compiler.  That way we can just use the `instanceof' operator
 //   to work out what each instance is.
 
-public class TypeFunctors {
+public class TypeFunctors implements java.io.Serializable {
 	public java.lang.Object functors_init;
 	// the above field should contain one of the following types:
 	public DuFunctorDesc[] functors_du() {
diff --git a/java/runtime/TypeInfo_Struct.java b/java/runtime/TypeInfo_Struct.java
index 992db10..e328350 100644
--- a/java/runtime/TypeInfo_Struct.java
+++ b/java/runtime/TypeInfo_Struct.java
@@ -6,7 +6,9 @@
 
 package jmercury.runtime;
 
-public class TypeInfo_Struct extends PseudoTypeInfo {
+public class TypeInfo_Struct extends PseudoTypeInfo
+	implements java.io.Serializable
+{
 
 	public TypeCtorInfo_Struct type_ctor;
 	public PseudoTypeInfo args[];
diff --git a/java/runtime/TypeLayout.java b/java/runtime/TypeLayout.java
index cf64392..91fdab1 100644
--- a/java/runtime/TypeLayout.java
+++ b/java/runtime/TypeLayout.java
@@ -6,7 +6,7 @@
 	
 package jmercury.runtime;
 
-public class TypeLayout {
+public class TypeLayout implements java.io.Serializable {
 		// This should hold a value of one of the types
 		// accessible by the access functions that follow.
 	public java.lang.Object layout_init;

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