diff --git a/org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHelper.java b/org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHelper.java
index 96dbb5fb6..018417226 100644
--- a/org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHelper.java
+++ b/org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHelper.java
@@ -1,5 +1,5 @@
/* InconsistentTypeCodeHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/DynamicAny/DynAnyHelper.java b/org/omg/DynamicAny/DynAnyHelper.java
index a238bf48b..315cddbd2 100644
--- a/org/omg/DynamicAny/DynAnyHelper.java
+++ b/org/omg/DynamicAny/DynAnyHelper.java
@@ -1,5 +1,5 @@
/* DynAnyHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,9 +41,9 @@ package org.omg.DynamicAny;
import gnu.CORBA.OrbRestricted;
+import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.MARSHAL;
@@ -86,15 +86,13 @@ public abstract class DynAnyHelper
* Narrow the given object to the DynAny. For the objects that are
* always local, this operation does not differ from the ordinary
* {@link #narrow} (ClassCastException will be thrown if narrowing something
- * different).
+ * different). See also OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted DynAny.
*
* @since 1.5
- *
- * @see OMG issue 4158.
*/
public static DynAny unchecked_narrow(org.omg.CORBA.Object obj)
{
@@ -160,7 +158,7 @@ public abstract class DynAnyHelper
* This should read DynAny from the CDR input stream, but (following the JDK
* 1.5 API) it does not.
*
- * @param input a org.omg.CORBA.portable stream to read from.
+ * @param output a org.omg.CORBA.portable stream to write into.
*
* @specenote Sun throws the same exception.
*
diff --git a/org/omg/DynamicAny/DynAnyOperations.java b/org/omg/DynamicAny/DynAnyOperations.java
index 73d8fac23..a009f4c88 100644
--- a/org/omg/DynamicAny/DynAnyOperations.java
+++ b/org/omg/DynamicAny/DynAnyOperations.java
@@ -1,5 +1,5 @@
/* DynAnyOperations.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
@@ -263,7 +263,7 @@ public interface DynAnyOperations
* Insert the {@link Any} value into the enclosed {@link Any} inside this
* DynAny.
*
- * @param a_x the value being inserted.
+ * @param an_any the value being inserted.
* @throws InvalidValue if the value type does not match the typecode of the
* enclosed {@link Any}.
*/
@@ -452,7 +452,7 @@ public interface DynAnyOperations
throws InvalidValue, TypeMismatch;
/**
- * Advances the internal pointer, described in the {@link current_component},
+ * Advances the internal pointer, described in the {@link #current_component},
* one position forward.
*
* @return true if the pointer now points to the new component, false if there
@@ -462,13 +462,13 @@ public interface DynAnyOperations
boolean next();
/**
- * Moves the internal pointer, described in the {@link current_component}, to
+ * Moves the internal pointer, described in the {@link #current_component}, to
* the first component.
*/
void rewind();
/**
- * Moves the internal pointer, described in the {@link current_component}, to
+ * Moves the internal pointer, described in the {@link #current_component}, to
* the given position.
*
* @param p the number of the internal component on that the internal pointer
diff --git a/org/omg/DynamicAny/DynAnyPackage/InvalidValueHelper.java b/org/omg/DynamicAny/DynAnyPackage/InvalidValueHelper.java
index 0258d3589..d27ad6a6b 100644
--- a/org/omg/DynamicAny/DynAnyPackage/InvalidValueHelper.java
+++ b/org/omg/DynamicAny/DynAnyPackage/InvalidValueHelper.java
@@ -1,5 +1,5 @@
/* InvalidValueHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/DynamicAny/DynAnyPackage/TypeMismatchHelper.java b/org/omg/DynamicAny/DynAnyPackage/TypeMismatchHelper.java
index 244a98aa0..7d4fc8789 100644
--- a/org/omg/DynamicAny/DynAnyPackage/TypeMismatchHelper.java
+++ b/org/omg/DynamicAny/DynAnyPackage/TypeMismatchHelper.java
@@ -1,5 +1,5 @@
/* TypeMismatchHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/DynamicAny/DynAnySeqHelper.java b/org/omg/DynamicAny/DynAnySeqHelper.java
index 66208ea19..f7550fd79 100644
--- a/org/omg/DynamicAny/DynAnySeqHelper.java
+++ b/org/omg/DynamicAny/DynAnySeqHelper.java
@@ -1,5 +1,5 @@
/* DynAnySeq.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -51,7 +51,7 @@ import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
/**
- * A helper operations for the array of {@link DynAny} ({@link DynAnySeq}).
+ * A helper operations for the array of {@link DynAny} (DynAny[]).
* Following the 1.5 JDK specifications, DynAny (and hence an sequence of
* DynAny's) is always a local object, so the two methods of this helper
* ({@link #read} and {@link #write} are not in use, always throwing
@@ -133,7 +133,7 @@ public abstract class DynAnySeqHelper
* The method should write this object to the CDR input stream, but
* (following the JDK 1.5 API) it does not.
*
- * @param input a org.omg.CORBA.portable stream to read from.
+ * @param output a org.omg.CORBA.portable stream to write into.
*
* @specenote Sun throws the same exception.
*
diff --git a/org/omg/DynamicAny/DynArrayHelper.java b/org/omg/DynamicAny/DynArrayHelper.java
index 26824d747..4cd3e3a52 100644
--- a/org/omg/DynamicAny/DynArrayHelper.java
+++ b/org/omg/DynamicAny/DynArrayHelper.java
@@ -1,5 +1,5 @@
/* DynArrayHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,9 +40,9 @@ package org.omg.DynamicAny;
import gnu.CORBA.OrbRestricted;
+import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.MARSHAL;
@@ -85,16 +85,14 @@ public abstract class DynArrayHelper
* Narrow the given object to the DynArray. For the objects that are
* always local, this operation does not differ from the ordinary
* {@link #narrow} (ClassCastException will be thrown if narrowing something
- * different).
+ * different). See OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted DynArray.
*
* @since 1.5
- *
- * @see OMG issue 4158.
- */
+ */
public static DynArray unchecked_narrow(org.omg.CORBA.Object obj)
{
return narrow(obj);
@@ -159,7 +157,7 @@ public abstract class DynArrayHelper
* This should read DynArray from the CDR input stream, but (following the JDK
* 1.5 API) it does not.
*
- * @param input a org.omg.CORBA.portable stream to read from.
+ * @param output a org.omg.CORBA.portable stream to write into.
*
* @specenote Sun throws the same exception.
*
diff --git a/org/omg/DynamicAny/DynEnumHelper.java b/org/omg/DynamicAny/DynEnumHelper.java
index 9af2e1194..da63e844f 100644
--- a/org/omg/DynamicAny/DynEnumHelper.java
+++ b/org/omg/DynamicAny/DynEnumHelper.java
@@ -1,5 +1,5 @@
/* DynEnumHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,9 +41,9 @@ package org.omg.DynamicAny;
import gnu.CORBA.OrbRestricted;
+import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.MARSHAL;
@@ -86,15 +86,13 @@ public abstract class DynEnumHelper
* Narrow the given object to the DynEnum. For the objects that are
* always local, this operation does not differ from the ordinary
* {@link #narrow} (ClassCastException will be thrown if narrowing something
- * different).
+ * different). See OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted DynEnum.
*
* @since 1.5
- *
- * @see OMG issue 4158.
*/
public static DynEnum unchecked_narrow(org.omg.CORBA.Object obj)
{
@@ -160,7 +158,7 @@ public abstract class DynEnumHelper
* This should read DynEnum from the CDR input stream, but (following the JDK
* 1.5 API) it does not.
*
- * @param input a org.omg.CORBA.portable stream to read from.
+ * @param output a org.omg.CORBA.portable stream to write into.
*
* @specenote Sun throws the same exception.
*
diff --git a/org/omg/DynamicAny/DynFixedHelper.java b/org/omg/DynamicAny/DynFixedHelper.java
index 4471bb26b..e730d43bb 100644
--- a/org/omg/DynamicAny/DynFixedHelper.java
+++ b/org/omg/DynamicAny/DynFixedHelper.java
@@ -1,5 +1,5 @@
/* DynFixedHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,9 +41,9 @@ package org.omg.DynamicAny;
import gnu.CORBA.OrbRestricted;
+import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.MARSHAL;
@@ -86,15 +86,13 @@ public abstract class DynFixedHelper
* Narrow the given object to the DynFixed. For the objects that are
* always local, this operation does not differ from the ordinary
* {@link #narrow} (ClassCastException will be thrown if narrowing something
- * different).
+ * different). See OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted DynFixed.
*
* @since 1.5
- *
- * @see OMG issue 4158.
*/
public static DynFixed unchecked_narrow(org.omg.CORBA.Object obj)
{
@@ -160,7 +158,7 @@ public abstract class DynFixedHelper
* This should read DynFixed from the CDR input stream, but (following the JDK
* 1.5 API) it does not.
*
- * @param input a org.omg.CORBA.portable stream to read from.
+ * @param output a org.omg.CORBA.portable stream to write into.
*
* @specenote Sun throws the same exception.
*
diff --git a/org/omg/DynamicAny/DynSequenceHelper.java b/org/omg/DynamicAny/DynSequenceHelper.java
index 0aa7cdd2a..f330108b0 100644
--- a/org/omg/DynamicAny/DynSequenceHelper.java
+++ b/org/omg/DynamicAny/DynSequenceHelper.java
@@ -1,5 +1,5 @@
/* DynSequenceHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,9 +40,9 @@ package org.omg.DynamicAny;
import gnu.CORBA.OrbRestricted;
+import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.MARSHAL;
@@ -85,15 +85,13 @@ public abstract class DynSequenceHelper
* Narrow the given object to the DynSequence. For the objects that are
* always local, this operation does not differ from the ordinary
* {@link #narrow} (ClassCastException will be thrown if narrowing something
- * different).
+ * different). See OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted DynSequence.
*
* @since 1.5
- *
- * @see OMG issue 4158.
*/
public static DynSequence unchecked_narrow(org.omg.CORBA.Object obj)
{
@@ -159,7 +157,7 @@ public abstract class DynSequenceHelper
* This should read DynSequence from the CDR input stream, but (following the
* JDK 1.5 API) it does not.
*
- * @param input a org.omg.CORBA.portable stream to read from.
+ * @param output a org.omg.CORBA.portable stream to write into.
*
* @specenote Sun throws the same exception.
*
diff --git a/org/omg/DynamicAny/DynStructHelper.java b/org/omg/DynamicAny/DynStructHelper.java
index c683260f6..077b7d098 100644
--- a/org/omg/DynamicAny/DynStructHelper.java
+++ b/org/omg/DynamicAny/DynStructHelper.java
@@ -1,5 +1,5 @@
/* DynStructHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,9 +40,9 @@ package org.omg.DynamicAny;
import gnu.CORBA.OrbRestricted;
+import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.MARSHAL;
@@ -85,15 +85,13 @@ public abstract class DynStructHelper
* Narrow the given object to the DynStruct. For the objects that are
* always local, this operation does not differ from the ordinary
* {@link #narrow} (ClassCastException will be thrown if narrowing something
- * different).
+ * different). See OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted DynStruct.
*
* @since 1.5
- *
- * @see OMG issue 4158.
*/
public static DynStruct unchecked_narrow(org.omg.CORBA.Object obj)
{
@@ -159,7 +157,7 @@ public abstract class DynStructHelper
* This should read DynStruct from the CDR input stream, but (following the
* JDK 1.5 API) it does not.
*
- * @param input a org.omg.CORBA.portable stream to read from.
+ * @param output a org.omg.CORBA.portable stream to write into.
*
* @specenote Sun throws the same exception.
*
diff --git a/org/omg/DynamicAny/DynStructOperations.java b/org/omg/DynamicAny/DynStructOperations.java
index 3b5af1710..03524b2f9 100644
--- a/org/omg/DynamicAny/DynStructOperations.java
+++ b/org/omg/DynamicAny/DynStructOperations.java
@@ -1,5 +1,5 @@
/* DynStructOperations.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
@@ -101,7 +101,7 @@ public interface DynStructOperations
* @specnote The name-based value assignment is not supported by Sun's jdk
* 1.4.
*
- * @param an array of NameDynValuePair's, each defining a single field in the
+ * @param value an array of NameDynValuePair's, each defining a single field in the
* structure.
*
* @throws TypeMismatch if the member of the passed array has a different type
@@ -125,7 +125,7 @@ public interface DynStructOperations
* @specnote The name-based value assignment is not supported by Sun's jdk
* 1.4.
*
- * @param an array of NameValuePair's, each defining a single field in the
+ * @param value an array of NameValuePair's, each defining a single field in the
* structure.
*
* @throws TypeMismatch if the member of the passed array has a different type
diff --git a/org/omg/DynamicAny/DynUnionHelper.java b/org/omg/DynamicAny/DynUnionHelper.java
index e868ea412..f1016d078 100644
--- a/org/omg/DynamicAny/DynUnionHelper.java
+++ b/org/omg/DynamicAny/DynUnionHelper.java
@@ -1,5 +1,5 @@
/* DynUnionHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,9 +40,9 @@ package org.omg.DynamicAny;
import gnu.CORBA.OrbRestricted;
+import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.MARSHAL;
@@ -85,15 +85,13 @@ public abstract class DynUnionHelper
* Narrow the given object to the DynUnion. For the objects that are
* always local, this operation does not differ from the ordinary
* {@link #narrow} (ClassCastException will be thrown if narrowing something
- * different).
+ * different). See OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted DynUnion.
*
* @since 1.5
- *
- * @see OMG issue 4158.
*/
public static DynUnion unchecked_narrow(org.omg.CORBA.Object obj)
{
@@ -159,7 +157,7 @@ public abstract class DynUnionHelper
* This should read DynUnion from the CDR input stream, but (following the JDK
* 1.5 API) it does not.
*
- * @param input a org.omg.CORBA.portable stream to read from.
+ * @param output a org.omg.CORBA.portable stream to write into.
*
* @specenote Sun throws the same exception.
*
diff --git a/org/omg/DynamicAny/DynValueHelper.java b/org/omg/DynamicAny/DynValueHelper.java
index ad75bc31f..17d9bbc5a 100644
--- a/org/omg/DynamicAny/DynValueHelper.java
+++ b/org/omg/DynamicAny/DynValueHelper.java
@@ -1,5 +1,5 @@
/* DynValueHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,9 +40,9 @@ package org.omg.DynamicAny;
import gnu.CORBA.OrbRestricted;
+import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.MARSHAL;
@@ -85,15 +85,13 @@ public abstract class DynValueHelper
* Narrow the given object to the DynValue. For the objects that are
* always local, this operation does not differ from the ordinary
* {@link #narrow} (ClassCastException will be thrown if narrowing something
- * different).
+ * different). See OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted DynValue.
*
* @since 1.5
- *
- * @see OMG issue 4158.
*/
public static DynValue unchecked_narrow(org.omg.CORBA.Object obj)
{
@@ -159,7 +157,7 @@ public abstract class DynValueHelper
* This should read DynValue from the CDR input stream, but (following the JDK
* 1.5 API) it does not.
*
- * @param input a org.omg.CORBA.portable stream to read from.
+ * @param output a org.omg.CORBA.portable stream to write into.
*
* @specenote Sun throws the same exception.
*
diff --git a/org/omg/DynamicAny/FieldNameHelper.java b/org/omg/DynamicAny/FieldNameHelper.java
index f15b8adfa..fb5ea1c7f 100644
--- a/org/omg/DynamicAny/FieldNameHelper.java
+++ b/org/omg/DynamicAny/FieldNameHelper.java
@@ -59,7 +59,7 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class FieldNameHelper
{
/**
- * Insert the FieldName into Any (uses {@link Any.insert_string}).
+ * Insert the FieldName into Any (uses {@link Any#insert_string}).
*
* @param a the Any to insert into.
* @param that the string to insert.
@@ -70,7 +70,7 @@ public abstract class FieldNameHelper
}
/**
- * Extract the FieldName from Any ((uses {@link Any.extract_string}).
+ * Extract the FieldName from Any ((uses {@link Any#extract_string}).
*
* @param a the Any to extract from.
*/
@@ -100,7 +100,7 @@ public abstract class FieldNameHelper
/**
* Calls {@link InputStream#read_string()}.
*
- * @param instream the stream to read from.
+ * @param istream the stream to read from.
*/
public static String read(InputStream istream)
{
@@ -108,7 +108,7 @@ public abstract class FieldNameHelper
}
/**
- * Calls {@link OutputStream#write_string()}.
+ * Calls {@link OutputStream#write_string(String)}.
*
* @param ostream the stream to write into.
* @param value the string (FieldName) value to write.
diff --git a/org/omg/DynamicAny/NameDynAnyPairHelper.java b/org/omg/DynamicAny/NameDynAnyPairHelper.java
index a9d9edba7..4e133a513 100644
--- a/org/omg/DynamicAny/NameDynAnyPairHelper.java
+++ b/org/omg/DynamicAny/NameDynAnyPairHelper.java
@@ -1,5 +1,5 @@
/* NameDynAnyPairHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -151,7 +151,7 @@ public abstract class NameDynAnyPairHelper
* The method should write this object to the CDR input stream, but
* (following the JDK 1.5 API) it does not.
*
- * @param input a org.omg.CORBA.portable stream to read from.
+ * @param output a org.omg.CORBA.portable stream to write into.
*
* @specenote Sun throws the same exception.
*
diff --git a/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java b/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java
index 56e6104ec..817ed8a70 100644
--- a/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java
+++ b/org/omg/DynamicAny/NameDynAnyPairSeqHelper.java
@@ -1,5 +1,5 @@
/* NameDynAnyPairSeq.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -52,7 +52,7 @@ import org.omg.CORBA.portable.OutputStream;
/**
* A helper operations for the array of {@link NameDynAnyPair}
- * ({@link NameDynAnyPairSeq}).
+ * (NameDynAnyPair[]).
*
* Following the 1.5 JDK specifications, DynAny (and hence the sequence
* of structures, containing DynAny) is always a local object.
@@ -132,7 +132,7 @@ public abstract class NameDynAnyPairSeqHelper
* The method should write this object to the CDR input stream, but
* (following the JDK 1.5 API) it does not.
*
- * @param input a org.omg.CORBA.portable stream to read from.
+ * @param output a org.omg.CORBA.portable stream to write into.
*
* @specenote Sun throws the same exception.
*
diff --git a/org/omg/IOP/CodecFactoryHelper.java b/org/omg/IOP/CodecFactoryHelper.java
index 89404f7d5..d3dc40935 100644
--- a/org/omg/IOP/CodecFactoryHelper.java
+++ b/org/omg/IOP/CodecFactoryHelper.java
@@ -1,5 +1,5 @@
/* CodecFactoryHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,10 +41,10 @@ package org.omg.IOP;
import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.CompletionStatus;
import org.omg.CORBA.MARSHAL;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -120,15 +120,13 @@ public abstract class CodecFactoryHelper
* Narrow the given object to the CodecFactory. For the objects that are
* always local, this operation does not differ from the ordinary
* {@link #narrow} (ClassCastException will be thrown if narrowing something
- * different).
+ * different). See OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted CodecFactory.
*
* @since 1.5
- *
- * @see OMG issue 4158.
*/
public static CodecFactory unchecked_narrow(org.omg.CORBA.Object obj)
{
@@ -141,7 +139,7 @@ public abstract class CodecFactoryHelper
*
* @specnote Suns implementation (1.4) throws this exception either.
*
- * @throws {@link MARSHAL}, minor code 0 and incomplete, always.
+ * @throws MARSHAL, minor code 0 and incomplete, always.
*/
public static CodecFactory read(InputStream input)
{
@@ -154,7 +152,7 @@ public abstract class CodecFactoryHelper
*
* @specnote Suns implementation (1.4) throws this exception either.
*
- * @throws {@link MARSHAL}, minor code 0 and incomplete, always.
+ * @throws MARSHAL, minor code 0 and incomplete, always.
*/
public static void write(OutputStream output, CodecFactory value)
{
diff --git a/org/omg/IOP/CodecFactoryPackage/UnknownEncodingHelper.java b/org/omg/IOP/CodecFactoryPackage/UnknownEncodingHelper.java
index 8861e43da..2110f0d5b 100644
--- a/org/omg/IOP/CodecFactoryPackage/UnknownEncodingHelper.java
+++ b/org/omg/IOP/CodecFactoryPackage/UnknownEncodingHelper.java
@@ -1,5 +1,5 @@
/* UnknownEncodingHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -45,7 +45,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.StructMember;
import org.omg.CORBA.portable.InputStream;
diff --git a/org/omg/IOP/CodecOperations.java b/org/omg/IOP/CodecOperations.java
index 3dfae1207..873f54607 100644
--- a/org/omg/IOP/CodecOperations.java
+++ b/org/omg/IOP/CodecOperations.java
@@ -1,5 +1,5 @@
/* CodecOperations.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -66,7 +66,7 @@ public interface CodecOperations
* by this {@link Codec} (wide char and wide string are not supported
* by ENCODING_CDR_ENCAPS v 1.0).
*
- * @see decode(byte[])
+ * @see #decode(byte[])
*/
byte[] encode(Any that)
throws InvalidTypeForEncoding;
@@ -83,7 +83,7 @@ public interface CodecOperations
*
* @throws FormatMismatch on the invalid structure of the byte array.
*
- * @see encode(Any)
+ * @see #encode(Any)
*/
Any decode(byte[] them)
throws FormatMismatch;
@@ -96,7 +96,7 @@ public interface CodecOperations
* @return the array, containing the encoded value alone (no preceeding
* typecode).
*
- * @see decode_value(byte[], TypeCode)
+ * @see #decode_value(byte[], TypeCode)
*/
byte[] encode_value(Any that_value)
throws InvalidTypeForEncoding;
@@ -119,7 +119,7 @@ public interface CodecOperations
* @throws TypeMismatch if discovered that the the byte array defines a
* different structure.
*
- * @see encode_value(Any)
+ * @see #encode_value(Any)
*/
Any decode_value(byte[] them, TypeCode type)
throws FormatMismatch, TypeMismatch;
diff --git a/org/omg/IOP/CodecPackage/FormatMismatchHelper.java b/org/omg/IOP/CodecPackage/FormatMismatchHelper.java
index 2a9295ae8..020975617 100644
--- a/org/omg/IOP/CodecPackage/FormatMismatchHelper.java
+++ b/org/omg/IOP/CodecPackage/FormatMismatchHelper.java
@@ -1,5 +1,5 @@
/* FormatMismatchHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/IOP/CodecPackage/InvalidTypeForEncodingHelper.java b/org/omg/IOP/CodecPackage/InvalidTypeForEncodingHelper.java
index e2a8c9057..246a1b93f 100644
--- a/org/omg/IOP/CodecPackage/InvalidTypeForEncodingHelper.java
+++ b/org/omg/IOP/CodecPackage/InvalidTypeForEncodingHelper.java
@@ -1,5 +1,5 @@
/* InvalidTypeForEncodingHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/IOP/CodecPackage/TypeMismatchHelper.java b/org/omg/IOP/CodecPackage/TypeMismatchHelper.java
index 432e84d24..88e00a243 100644
--- a/org/omg/IOP/CodecPackage/TypeMismatchHelper.java
+++ b/org/omg/IOP/CodecPackage/TypeMismatchHelper.java
@@ -1,5 +1,5 @@
/* TypeMismatchHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/IOP/ComponentIdHelper.java b/org/omg/IOP/ComponentIdHelper.java
index 35ffd9a69..f94187698 100644
--- a/org/omg/IOP/ComponentIdHelper.java
+++ b/org/omg/IOP/ComponentIdHelper.java
@@ -1,5 +1,5 @@
/* ComponentIdHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,7 +43,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
-import org.omg.CORBA.StructMember;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
diff --git a/org/omg/IOP/ExceptionDetailMessage.java b/org/omg/IOP/ExceptionDetailMessage.java
index 167ab1ac7..92a068cba 100644
--- a/org/omg/IOP/ExceptionDetailMessage.java
+++ b/org/omg/IOP/ExceptionDetailMessage.java
@@ -1,5 +1,5 @@
/* ExceptionDetailMessage.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,7 +44,7 @@ package org.omg.IOP;
* USER_EXCEPTION reply status, as the alternative to the stack trace
* that might contain sensitive or unwanted information. The service
* context contains the CDR-encapsulated wide string, usually
- * returned by {@link Exception#getMessage}.
+ * returned by {@link Exception#getMessage()}.
*
* The applications may also send the more comprehensive UnknownExceptionInfo
* ( = 9 ) service context that contains the thrown exception, written
diff --git a/org/omg/IOP/MultipleComponentProfileHelper.java b/org/omg/IOP/MultipleComponentProfileHelper.java
index 1c04ec54f..6a941dee6 100644
--- a/org/omg/IOP/MultipleComponentProfileHelper.java
+++ b/org/omg/IOP/MultipleComponentProfileHelper.java
@@ -1,5 +1,5 @@
/* MultipleComponentProfileHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,7 +44,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.portable.OutputStream;
@@ -52,7 +51,7 @@ import org.omg.CORBA.portable.InputStream;
/**
* A helper operations for the array of {@link TaggedComponent}
- * ({@link MultipleComponentProfile}).
+ * (MultipleComponentProfile).
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
diff --git a/org/omg/IOP/ProfileIdHelper.java b/org/omg/IOP/ProfileIdHelper.java
index 340fa27d5..362b2dff3 100644
--- a/org/omg/IOP/ProfileIdHelper.java
+++ b/org/omg/IOP/ProfileIdHelper.java
@@ -1,5 +1,5 @@
/* ProfileIdHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,7 +43,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
-import org.omg.CORBA.StructMember;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
diff --git a/org/omg/IOP/ServiceContextListHelper.java b/org/omg/IOP/ServiceContextListHelper.java
index 7875db29e..9de0b6ffd 100644
--- a/org/omg/IOP/ServiceContextListHelper.java
+++ b/org/omg/IOP/ServiceContextListHelper.java
@@ -1,5 +1,5 @@
/* ServiceContextListHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,21 +43,20 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
/**
* The helper operations for the
-* CORBA object {@link ServiceContext[]}.
+* CORBA object {@link ServiceContext}[].
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
public abstract class ServiceContextListHelper
{
/**
- * Get the type code of the {@link ServiceContext[]}.
+ * Get the type code of the {@link ServiceContext}[].
*/
public static TypeCode type()
{
diff --git a/org/omg/IOP/ServiceIdHelper.java b/org/omg/IOP/ServiceIdHelper.java
index 084dbd06d..9c4cbbe4a 100644
--- a/org/omg/IOP/ServiceIdHelper.java
+++ b/org/omg/IOP/ServiceIdHelper.java
@@ -1,5 +1,5 @@
/* ServiceIdHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,7 +43,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
-import org.omg.CORBA.StructMember;
import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
diff --git a/org/omg/IOP/TAG_CODE_SETS.java b/org/omg/IOP/TAG_CODE_SETS.java
index cc7752483..07c5c9c32 100644
--- a/org/omg/IOP/TAG_CODE_SETS.java
+++ b/org/omg/IOP/TAG_CODE_SETS.java
@@ -1,5 +1,5 @@
/* TAG_CODE_SETS.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,7 +44,7 @@ package org.omg.IOP;
* profile provides information about the native and supported encodings
* for the "narrow" (usually 8 bit) and "wide" (usually 16 bit) characters.
* In Gnu Classpath implementation the class, responsible for providing
- * this information is {@link gnu.CORBA.CharSets_OSF}.
+ * this information is {@link gnu.CORBA.GIOP.CharSets_OSF}.
*
*
* If this profile is missing, it is assumed, that the "narrow" characters
diff --git a/org/omg/PortableInterceptor/ClientRequestInfoOperations.java b/org/omg/PortableInterceptor/ClientRequestInfoOperations.java
index 73efa122f..e4d70211a 100644
--- a/org/omg/PortableInterceptor/ClientRequestInfoOperations.java
+++ b/org/omg/PortableInterceptor/ClientRequestInfoOperations.java
@@ -1,5 +1,5 @@
/* ClientRequestInfoOperations.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableInterceptor;
import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_INV_ORDER;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.INV_POLICY;
import org.omg.CORBA.Policy;
@@ -285,8 +286,6 @@ public interface ClientRequestInfoOperations extends RequestInfoOperations
* @param type the type of the policy being requested.
*
* @return should return the policy that applies to this operation.
- *
- * @throws NO_IMPLEMENT always.
*/
Policy get_request_policy(int type) throws INV_POLICY;
diff --git a/org/omg/PortableInterceptor/ClientRequestInterceptorOperations.java b/org/omg/PortableInterceptor/ClientRequestInterceptorOperations.java
index 4a60b77f5..efd98707b 100644
--- a/org/omg/PortableInterceptor/ClientRequestInterceptorOperations.java
+++ b/org/omg/PortableInterceptor/ClientRequestInterceptorOperations.java
@@ -1,5 +1,5 @@
/* ClientRequestInterceptorOperations.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.PortableInterceptor;
+import org.omg.CORBA.SystemException;
+
/**
* Defines operations, applicable to the client side request interceptor. The
diff --git a/org/omg/PortableInterceptor/CurrentHelper.java b/org/omg/PortableInterceptor/CurrentHelper.java
index e453f6010..88ab0e270 100644
--- a/org/omg/PortableInterceptor/CurrentHelper.java
+++ b/org/omg/PortableInterceptor/CurrentHelper.java
@@ -1,5 +1,5 @@
/* CurrentHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -42,13 +42,12 @@ import gnu.CORBA.Minor;
import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.MARSHAL;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
-import org.omg.PortableServer.ServantActivator;
/**
* The helper operations for the CORBA object {@link Current}.
@@ -123,15 +122,13 @@ public abstract class CurrentHelper
* Narrow the given object to the Current. For the objects that are
* always local, this operation does not differ from the ordinary
* {@link #narrow} (ClassCastException will be thrown if narrowing something
- * different).
+ * different). See also OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted Current.
*
* @since 1.5
- *
- * @see OMG issue 4158.
*/
public static Current unchecked_narrow(org.omg.CORBA.Object obj)
{
diff --git a/org/omg/PortableInterceptor/IORInfo.java b/org/omg/PortableInterceptor/IORInfo.java
index 9495d79ec..ec7235102 100644
--- a/org/omg/PortableInterceptor/IORInfo.java
+++ b/org/omg/PortableInterceptor/IORInfo.java
@@ -1,5 +1,5 @@
/* IORInfo.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,7 @@ import java.io.Serializable;
* Provides the server-side ORB service possibility to add components to the new
* IOR being created. Also, provides access to policies, applicable to the
* object, referenced by that IOR. The ORB passes an instance of IORInfo as a
- * parameter to {@link IORInterceptor#establish_components}.
+ * parameter to {@link IORInterceptorOperations#establish_components}.
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
diff --git a/org/omg/PortableInterceptor/IORInterceptor_3_0Helper.java b/org/omg/PortableInterceptor/IORInterceptor_3_0Helper.java
index 926974f1a..71fb928f7 100644
--- a/org/omg/PortableInterceptor/IORInterceptor_3_0Helper.java
+++ b/org/omg/PortableInterceptor/IORInterceptor_3_0Helper.java
@@ -1,5 +1,5 @@
/* IORInterceptor_3_0Helper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,7 +44,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.Delegate;
import org.omg.CORBA.portable.InputStream;
diff --git a/org/omg/PortableInterceptor/ORBIdHelper.java b/org/omg/PortableInterceptor/ORBIdHelper.java
index 8332845a6..6b73b1151 100644
--- a/org/omg/PortableInterceptor/ORBIdHelper.java
+++ b/org/omg/PortableInterceptor/ORBIdHelper.java
@@ -1,5 +1,5 @@
/* ORBIdHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -58,7 +58,7 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class ORBIdHelper
{
/**
- * Insert the ORB Id into Any (uses {@link Any.insert_string}).
+ * Insert the ORB Id into Any (uses {@link Any#insert_string}).
*
* @param a the Any to insert into.
* @param that the string to insert.
@@ -69,7 +69,7 @@ public abstract class ORBIdHelper
}
/**
- * Extract the ORB Id from Any ((uses {@link Any.extract_string}).
+ * Extract the ORB Id from Any ((uses {@link Any#extract_string}).
*
* @param a the Any to extract from.
*/
@@ -107,7 +107,7 @@ public abstract class ORBIdHelper
}
/**
- * Calls {@link OutputStream#write_string()}.
+ * Calls {@link OutputStream#write_string(String)}.
*
* @param output the stream to write into.
* @param value the string (ORB Id) value to write.
diff --git a/org/omg/PortableInterceptor/ORBInitInfoOperations.java b/org/omg/PortableInterceptor/ORBInitInfoOperations.java
index 7b545ff81..16710a08a 100644
--- a/org/omg/PortableInterceptor/ORBInitInfoOperations.java
+++ b/org/omg/PortableInterceptor/ORBInitInfoOperations.java
@@ -1,5 +1,5 @@
/* ORBInitInfoOperations.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.PortableInterceptor;
+import org.omg.CORBA.BAD_INV_ORDER;
+import org.omg.CORBA.ORB;
import org.omg.IOP.CodecFactory;
import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName;
@@ -90,7 +92,7 @@ public interface ORBInitInfoOperations
throws DuplicateName;
/**
- * Allocate a slot on a {@link PortableInterceptor.Current}. While slots can
+ * Allocate a slot on a {@link Current} of this interceptor. While slots can
* be allocated by this method, they cannot be initialized.
* {@link CurrentOperations#get_slot} and {@link CurrentOperations#set_slot}
* throw {@link org.omg.CORBA.BAD_INV_ORDER} while called from the interceptor
@@ -103,8 +105,8 @@ public interface ORBInitInfoOperations
/**
* Returns the arguments passed to the ORB.init.
*
- * @return the first parameter, passed to the method
- * {@link org.omg.CORBA.ORB#init}.
+ * @return the first parameter, passed to the methods from the group
+ * org.omg.CORBA.ORB#init(String[], ...).
*/
String[] arguments();
@@ -127,7 +129,7 @@ public interface ORBInitInfoOperations
/**
* Register the initial reference. The registered object will be accessible by
- * the {@link ORB.resolve_initial_references} under the object_name.
+ * the {@link ORB#resolve_initial_references} under the object_name.
*
* @param object_name the name of the object to register.
* @param object the object to register.
diff --git a/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java b/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java
index a87a3b747..329fcf564 100644
--- a/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java
+++ b/org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHelper.java
@@ -1,5 +1,5 @@
/* InvalidNameHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/PortableInterceptor/ORBInitializerOperations.java b/org/omg/PortableInterceptor/ORBInitializerOperations.java
index 90c2325f2..d5dd771fd 100644
--- a/org/omg/PortableInterceptor/ORBInitializerOperations.java
+++ b/org/omg/PortableInterceptor/ORBInitializerOperations.java
@@ -1,5 +1,5 @@
/* ORBInitializerOperations.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -67,7 +67,7 @@ public interface ORBInitializerOperations
* @param info the object describing ORB being created and containing methods
* to register the interceptor.
*
- * @see ORBInitInfoOperations#register_initial_references
+ * @see ORBInitInfoOperations#register_initial_reference
*/
void post_init(ORBInitInfo info);
}
\ No newline at end of file
diff --git a/org/omg/PortableInterceptor/ObjectReferenceFactoryHelper.java b/org/omg/PortableInterceptor/ObjectReferenceFactoryHelper.java
index 72c864811..b9a237dce 100644
--- a/org/omg/PortableInterceptor/ObjectReferenceFactoryHelper.java
+++ b/org/omg/PortableInterceptor/ObjectReferenceFactoryHelper.java
@@ -1,5 +1,5 @@
/* ObjectReferenceFactoryHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -44,7 +44,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.ValueMember;
import org.omg.CORBA.portable.InputStream;
diff --git a/org/omg/PortableInterceptor/ObjectReferenceTemplateHelper.java b/org/omg/PortableInterceptor/ObjectReferenceTemplateHelper.java
index 014c11308..0ea54ea5f 100644
--- a/org/omg/PortableInterceptor/ObjectReferenceTemplateHelper.java
+++ b/org/omg/PortableInterceptor/ObjectReferenceTemplateHelper.java
@@ -1,5 +1,5 @@
/* ObjectReferenceTemplateHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,7 +43,6 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.VM_ABSTRACT;
import org.omg.CORBA.ValueMember;
diff --git a/org/omg/PortableInterceptor/RequestInfoOperations.java b/org/omg/PortableInterceptor/RequestInfoOperations.java
index f865a14d2..10b9662a6 100644
--- a/org/omg/PortableInterceptor/RequestInfoOperations.java
+++ b/org/omg/PortableInterceptor/RequestInfoOperations.java
@@ -1,5 +1,5 @@
/* RequestInfoOperations.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -40,6 +40,7 @@ package org.omg.PortableInterceptor;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.NO_RESOURCES;
import org.omg.CORBA.TypeCode;
import org.omg.Dynamic.Parameter;
import org.omg.IOP.ServiceContext;
@@ -182,7 +183,7 @@ public interface RequestInfoOperations
* the client. However up till JDK 1.5 inclusive this method always returns
* SYNC_WITH_TRANSPORT.
*
- * @return {@link org.omg.Messaging.SYNC_WITH_TRANSPORT.value (1), always.
+ * @return {@link org.omg.Messaging.SYNC_WITH_TRANSPORT#value} (1), always.
*
* @specnote as defined in the Suns 1.5 JDK API.
*/
diff --git a/org/omg/PortableInterceptor/ServerIdHelper.java b/org/omg/PortableInterceptor/ServerIdHelper.java
index e4f8fe9c2..84ffdfa8e 100644
--- a/org/omg/PortableInterceptor/ServerIdHelper.java
+++ b/org/omg/PortableInterceptor/ServerIdHelper.java
@@ -1,5 +1,5 @@
/* ServerIdHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -58,7 +58,7 @@ import org.omg.CORBA.portable.OutputStream;
public abstract class ServerIdHelper
{
/**
- * Insert the Server Id into Any (uses {@link Any.insert_string}).
+ * Insert the Server Id into Any (uses {@link Any#insert_string}).
*
* @param a the Any to insert into.
* @param that the string to insert.
@@ -69,7 +69,7 @@ public abstract class ServerIdHelper
}
/**
- * Extract the Server Id from Any ((uses {@link Any.extract_string}).
+ * Extract the Server Id from Any ((uses {@link Any#extract_string}).
*
* @param a the Any to extract from.
*/
@@ -107,7 +107,7 @@ public abstract class ServerIdHelper
}
/**
- * Calls {@link OutputStream#write_string()}.
+ * Calls {@link OutputStream#write_string(String)}.
*
* @param output the stream to write into.
* @param value the string (Server Id) value to write.
diff --git a/org/omg/PortableInterceptor/ServerRequestInfoOperations.java b/org/omg/PortableInterceptor/ServerRequestInfoOperations.java
index a9ee7d920..52de9d824 100644
--- a/org/omg/PortableInterceptor/ServerRequestInfoOperations.java
+++ b/org/omg/PortableInterceptor/ServerRequestInfoOperations.java
@@ -1,5 +1,5 @@
/* ServerRequestInfoOperations.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableInterceptor;
import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_INV_ORDER;
import org.omg.CORBA.INV_POLICY;
import org.omg.CORBA.Policy;
import org.omg.IOP.ServiceContext;
@@ -287,7 +288,7 @@ public interface ServerRequestInfoOperations
/**
* Checks if the servant is the given repository id.
*
- * @param the repository id to compare.
+ * @param id the repository id to compare.
*
* @return true if the servant repository id matches the parameter, false
* otherwise.
diff --git a/org/omg/PortableInterceptor/ServerRequestInterceptorOperations.java b/org/omg/PortableInterceptor/ServerRequestInterceptorOperations.java
index b57ca28f7..ccba1a76e 100644
--- a/org/omg/PortableInterceptor/ServerRequestInterceptorOperations.java
+++ b/org/omg/PortableInterceptor/ServerRequestInterceptorOperations.java
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.PortableInterceptor;
+import org.omg.CORBA.SystemException;
+
/**
* Defines operations, applicable to the server side request interceptor. The
@@ -50,16 +52,16 @@ public interface ServerRequestInterceptorOperations
{
/**
* ORB calls this method before invoking the servant manager. Operation
- * parameters are not available at this point. The interceptor has possibility
+ * parameters are not available at this point. The interceptor has possibility
* to forward the request by throwing {@link ForwardRequest}.
- *
- * @throws SystemException if it does, the receive_request_service_contexts is
- * not called for the subsequent interceptors, calling send_exception instead.
- * The completion status of such exception must be COMPLETED_NO.
- *
+ *
+ * @throws SystemException if it does, the receive_request_service_contexts is
+ * not called for the subsequent interceptors, calling
+ * send_exception instead. The completion status of such exception
+ * must be COMPLETED_NO.
* @throws ForwardRequest to forward the invocation to another target. The
- * receive_request_service_contexts is not called for the subsequent
- * interceptors, calling send_other instead.
+ * receive_request_service_contexts is not called for the subsequent
+ * interceptors, calling send_other instead.
*/
void receive_request_service_contexts(ServerRequestInfo info)
throws ForwardRequest;
diff --git a/org/omg/PortableServer/AdapterActivatorOperations.java b/org/omg/PortableServer/AdapterActivatorOperations.java
index dcf7edd04..d1091852e 100644
--- a/org/omg/PortableServer/AdapterActivatorOperations.java
+++ b/org/omg/PortableServer/AdapterActivatorOperations.java
@@ -1,5 +1,5 @@
/* AdapterActivatorOperations.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,6 +38,8 @@ exception statement from your version. */
package org.omg.PortableServer;
+import org.omg.CORBA.OBJECT_NOT_EXIST;
+
/**
* Defines the operations, applicable to the AdapterActivator.
diff --git a/org/omg/PortableServer/CurrentHelper.java b/org/omg/PortableServer/CurrentHelper.java
index 3afbf669b..f201e38bc 100644
--- a/org/omg/PortableServer/CurrentHelper.java
+++ b/org/omg/PortableServer/CurrentHelper.java
@@ -1,5 +1,5 @@
/* CurrentHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,9 +41,9 @@ package org.omg.PortableServer;
import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.NO_IMPLEMENT;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/PortableServer/CurrentPackage/NoContextHelper.java b/org/omg/PortableServer/CurrentPackage/NoContextHelper.java
index 02c74c535..4a2a9a6a0 100644
--- a/org/omg/PortableServer/CurrentPackage/NoContextHelper.java
+++ b/org/omg/PortableServer/CurrentPackage/NoContextHelper.java
@@ -1,5 +1,5 @@
/* NoContextHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/PortableServer/ForwardRequestHelper.java b/org/omg/PortableServer/ForwardRequestHelper.java
index b30a2abeb..d5d5751b9 100644
--- a/org/omg/PortableServer/ForwardRequestHelper.java
+++ b/org/omg/PortableServer/ForwardRequestHelper.java
@@ -1,5 +1,5 @@
/* ForwardRequestHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,6 +39,7 @@ exception statement from your version. */
package org.omg.PortableServer;
import gnu.CORBA.Minor;
+import gnu.CORBA.ObjectCreator;
import gnu.CORBA.OrbRestricted;
import gnu.CORBA.Poa.ForwardRequestHolder;
diff --git a/org/omg/PortableServer/IdAssignmentPolicyValue.java b/org/omg/PortableServer/IdAssignmentPolicyValue.java
index ac81d389c..cc6f3962a 100644
--- a/org/omg/PortableServer/IdAssignmentPolicyValue.java
+++ b/org/omg/PortableServer/IdAssignmentPolicyValue.java
@@ -1,5 +1,5 @@
/* IdAssignmentPolicyValue.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,7 @@ package org.omg.PortableServer;
import gnu.CORBA.Minor;
import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.portable.IDLEntity;
import java.io.Serializable;
diff --git a/org/omg/PortableServer/IdUniquenessPolicyValue.java b/org/omg/PortableServer/IdUniquenessPolicyValue.java
index c0f281249..0294ee209 100644
--- a/org/omg/PortableServer/IdUniquenessPolicyValue.java
+++ b/org/omg/PortableServer/IdUniquenessPolicyValue.java
@@ -1,5 +1,5 @@
/* IdUniquenessPolicyValue.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,7 @@ package org.omg.PortableServer;
import gnu.CORBA.Minor;
import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.portable.IDLEntity;
import java.io.Serializable;
diff --git a/org/omg/PortableServer/ImplicitActivationPolicyValue.java b/org/omg/PortableServer/ImplicitActivationPolicyValue.java
index 9d81d5fab..6631424c4 100644
--- a/org/omg/PortableServer/ImplicitActivationPolicyValue.java
+++ b/org/omg/PortableServer/ImplicitActivationPolicyValue.java
@@ -1,5 +1,5 @@
/* ImplicitActivationPolicyValue.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,7 @@ package org.omg.PortableServer;
import gnu.CORBA.Minor;
import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.portable.IDLEntity;
import java.io.Serializable;
diff --git a/org/omg/PortableServer/LifespanPolicyValue.java b/org/omg/PortableServer/LifespanPolicyValue.java
index 117eb5a3c..e1ab856b0 100644
--- a/org/omg/PortableServer/LifespanPolicyValue.java
+++ b/org/omg/PortableServer/LifespanPolicyValue.java
@@ -1,5 +1,5 @@
/* LifespanPolicyValue.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,7 @@ package org.omg.PortableServer;
import gnu.CORBA.Minor;
import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.portable.IDLEntity;
import java.io.Serializable;
diff --git a/org/omg/PortableServer/POA.java b/org/omg/PortableServer/POA.java
index 863a12bf8..624d658da 100644
--- a/org/omg/PortableServer/POA.java
+++ b/org/omg/PortableServer/POA.java
@@ -1,5 +1,5 @@
/* POA.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -55,8 +55,8 @@ import org.omg.CORBA.portable.IDLEntity;
* strategies are possible.
*
*
- * @see org.omg.CORBA.ORB.resolve_initial_references
- * @see POAOperations.servant_to_reference
+ * @see org.omg.CORBA.ORB#resolve_initial_references
+ * @see POAOperations#servant_to_reference
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
diff --git a/org/omg/PortableServer/POAHelper.java b/org/omg/PortableServer/POAHelper.java
index d6a951be5..122cfb304 100644
--- a/org/omg/PortableServer/POAHelper.java
+++ b/org/omg/PortableServer/POAHelper.java
@@ -1,5 +1,5 @@
/* POAHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,9 +41,9 @@ package org.omg.PortableServer;
import gnu.CORBA.Minor;
import gnu.CORBA.OrbRestricted;
+import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.TypeCode;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.Any;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.MARSHAL;
@@ -139,7 +139,7 @@ public abstract class POAHelper
* it doesnot. The jdk 1.5 API specification defines that POA cannot be
* exported.
*
- * @param input a org.omg.CORBA.portable stream to read from.
+ * @param output a org.omg.CORBA.portable stream to write into.
*
* @specenote Sun throws the same exception.
*
diff --git a/org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java b/org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java
index e23d11997..e6a3068af 100644
--- a/org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java
+++ b/org/omg/PortableServer/POAManagerPackage/AdapterInactiveHelper.java
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/PortableServer/POAManagerPackage/State.java b/org/omg/PortableServer/POAManagerPackage/State.java
index 9e856098b..b32d420a8 100644
--- a/org/omg/PortableServer/POAManagerPackage/State.java
+++ b/org/omg/PortableServer/POAManagerPackage/State.java
@@ -1,5 +1,5 @@
/* State.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,8 @@ package org.omg.PortableServer.POAManagerPackage;
import gnu.CORBA.Minor;
import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.TRANSIENT;
import org.omg.CORBA.portable.IDLEntity;
import java.io.Serializable;
@@ -54,7 +56,7 @@ import java.io.Serializable;
* receive and process requests.
* DISCARDING When the manager is in the discarding state,
* the associated POAs discard all incoming requests. The sending clients
- * receive the {@link org.omg.TRANSIENT} system exception, with standard
+ * receive the {@link TRANSIENT} system exception, with standard
* minor code 1. This mode is needed for flow control, when the system is
* flooded with requests.
*
diff --git a/org/omg/PortableServer/POAOperations.java b/org/omg/PortableServer/POAOperations.java
index 1c22ceed2..58d062d2b 100644
--- a/org/omg/PortableServer/POAOperations.java
+++ b/org/omg/PortableServer/POAOperations.java
@@ -1,5 +1,5 @@
/* POAOperations.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,7 +38,11 @@ exception statement from your version. */
package org.omg.PortableServer;
+import org.omg.CORBA.BAD_INV_ORDER;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.OBJ_ADAPTER;
import org.omg.CORBA.Policy;
+import org.omg.CORBA.TRANSIENT;
import org.omg.PortableServer.POAPackage.AdapterAlreadyExists;
import org.omg.PortableServer.POAPackage.AdapterNonExistent;
import org.omg.PortableServer.POAPackage.InvalidPolicy;
@@ -107,7 +111,7 @@ public interface POAOperations
* the Active Object Map using this Id a a key. If the servant
* activator is set, its incarnate method will be called. In this case,
* the passed servant in this method can be null; in this case, the servant,
- * returned by {@link ServantLocatorOperations#incarnate} will
+ * returned by {@link ServantActivatorOperations#incarnate} will
* be used.
*
* @param a_servant a servant that would serve the object with the
@@ -129,7 +133,7 @@ public interface POAOperations
* object with the provided Object Id. If the servant activator is
* set, its incarnate method will be called. In this case,
* the passed servant in this method can be null; in this case, the servant,
- * returned by {@link ServantLocatorOperations#incarnate} will
+ * returned by {@link ServantActivatorOperations#incarnate} will
* be used.
*
* @param an_Object_Id an object id for the given object.
@@ -241,7 +245,7 @@ public interface POAOperations
/**
* Set a servant manager for this POA.
*
- * @param a servant manager being set. If the RETAIN policy applies, the
+ * @param a_manager servant manager being set. If the RETAIN policy applies, the
* manager must implement a {@link ServantActivator}. If the NON_RETAIN
* policy applies, the manager must implement a {@link ServantLocator}.
*
@@ -298,7 +302,7 @@ public interface POAOperations
* @param the_Object_Id the object id.
*
* @throws ObjectNotActive if there is no active object with such Id.
- * @throws WrongPolicy. This method requires either RETAIN or
+ * @throws WrongPolicy This method requires either RETAIN or
* USE_DEFAULT_SERVANT policies and reaises the WrongPolicy if none of them
* apply to this POA.
*/
@@ -328,7 +332,7 @@ public interface POAOperations
*
* @throws ObjectNotActive if none of the conditions above are satisfied.
* @throws WrongAdapter if the object reference was not created with this POA.
- * @throws WrongPolicy. This method requires either RETAIN or
+ * @throws WrongPolicy This method requires either RETAIN or
* USE_DEFAULT_SERVANT policies and reaises the WrongPolicy if none of them
* apply to this POA.
*/
@@ -408,7 +412,7 @@ public interface POAOperations
/**
* Set the adapter activator for this POA.
*
- * @param the activator being set.
+ * @param activator the activator being set.
*/
void the_activator(AdapterActivator activator);
@@ -437,7 +441,7 @@ public interface POAOperations
* Destroy this POA and all descendant POAs. The destroyed POAs can be
* later re-created via {@link AdapterActivator} or by invoking
* {@link #create_POA}.
- * This differs from {@link PoaManagerOperations#deactivate} that does
+ * This differs from {@link POAManagerOperations#deactivate} that does
* not allow recreation of the deactivated POAs. After deactivation,
* recreation is only possible if the POAs were later destroyed.
*
@@ -462,7 +466,7 @@ public interface POAOperations
/**
* Create the IdUniquenessPolicy policy.
*
- * @param value states which one Id uniqueness policy will apply.
+ * @param a_value states which one Id uniqueness policy will apply.
*
* @return the created policy.
*/
@@ -471,7 +475,7 @@ public interface POAOperations
/**
* Create the ImplicitActivationPolicy policy.
*
- * @param value states which one activation policy will apply.
+ * @param a_value states which one activation policy will apply.
*
* @return the created policy.
*/
@@ -480,7 +484,7 @@ public interface POAOperations
/**
* Create the LifespanPolicy policy.
*
- * @param value states which one object lifespan policy will apply.
+ * @param a_value states which one object lifespan policy will apply.
*
* @return the created policy.
*/
@@ -489,7 +493,7 @@ public interface POAOperations
/**
* Create the RequestProcessingPolicy policy.
*
- * @param value states which one request processing policy will apply.
+ * @param a_value states which one request processing policy will apply.
*
* @return the created policy.
*/
@@ -498,7 +502,7 @@ public interface POAOperations
/**
* Create the ServantRetentionPolicy policy.
*
- * @param value states which one servant retention policy will apply.
+ * @param a_value states which one servant retention policy will apply.
*
* @return the created policy.
*/
@@ -507,7 +511,7 @@ public interface POAOperations
/**
* Create the ThreadPolicy policy.
*
- * @param value states which one thread policy will apply.
+ * @param a_value states which one thread policy will apply.
*
* @return the created policy.
*/
diff --git a/org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHelper.java b/org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHelper.java
index f616637ae..6476eeaa5 100644
--- a/org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHelper.java
+++ b/org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHelper.java
@@ -1,5 +1,5 @@
/* AdapterAlreadyExistsHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/PortableServer/POAPackage/AdapterNonExistentHelper.java b/org/omg/PortableServer/POAPackage/AdapterNonExistentHelper.java
index bad920a5a..1c007fb43 100644
--- a/org/omg/PortableServer/POAPackage/AdapterNonExistentHelper.java
+++ b/org/omg/PortableServer/POAPackage/AdapterNonExistentHelper.java
@@ -1,5 +1,5 @@
/* AdapterNonExistentHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/PortableServer/POAPackage/InvalidPolicy.java b/org/omg/PortableServer/POAPackage/InvalidPolicy.java
index 51ef615fb..470d9af4a 100644
--- a/org/omg/PortableServer/POAPackage/InvalidPolicy.java
+++ b/org/omg/PortableServer/POAPackage/InvalidPolicy.java
@@ -69,7 +69,7 @@ public final class InvalidPolicy
/**
* Create InvalidPolicy with no explaining
- * message and leaving {@link index} with default 0 value.
+ * message and leaving {@link #index} with default 0 value.
*/
public InvalidPolicy()
{
@@ -77,7 +77,7 @@ public final class InvalidPolicy
/**
* Create the InvalidPolicy with explaining
- * message and initialisintg {@link index} to the passed value.
+ * message and initialisintg {@link #index} to the passed value.
*
* @param why a string, explaining, why this exception has been thrown.
* @param a_index a value for index.
@@ -90,7 +90,7 @@ public final class InvalidPolicy
/**
* Create the InvalidPolicy without explaining
- * message and initialisintg {@link index} to the passed value.
+ * message and initialisintg {@link #index} to the passed value.
*
* @param a_index a value for index.
*/
diff --git a/org/omg/PortableServer/POAPackage/NoServantHelper.java b/org/omg/PortableServer/POAPackage/NoServantHelper.java
index b9afb8ed7..56e8c4d16 100644
--- a/org/omg/PortableServer/POAPackage/NoServantHelper.java
+++ b/org/omg/PortableServer/POAPackage/NoServantHelper.java
@@ -1,5 +1,5 @@
/* NoServantHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHelper.java b/org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHelper.java
index bf5e9cd9e..7f2e1484c 100644
--- a/org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHelper.java
+++ b/org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHelper.java
@@ -1,5 +1,5 @@
/* ObjectAlreadyActiveHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/PortableServer/POAPackage/ObjectNotActiveHelper.java b/org/omg/PortableServer/POAPackage/ObjectNotActiveHelper.java
index 2f5867cbd..4cdf80891 100644
--- a/org/omg/PortableServer/POAPackage/ObjectNotActiveHelper.java
+++ b/org/omg/PortableServer/POAPackage/ObjectNotActiveHelper.java
@@ -1,5 +1,5 @@
/* ObjectNotActiveHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/PortableServer/POAPackage/ServantAlreadyActiveHelper.java b/org/omg/PortableServer/POAPackage/ServantAlreadyActiveHelper.java
index 33ca06674..30b0b52d0 100644
--- a/org/omg/PortableServer/POAPackage/ServantAlreadyActiveHelper.java
+++ b/org/omg/PortableServer/POAPackage/ServantAlreadyActiveHelper.java
@@ -1,5 +1,5 @@
/* ServantAlreadyActiveHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/PortableServer/POAPackage/ServantNotActiveHelper.java b/org/omg/PortableServer/POAPackage/ServantNotActiveHelper.java
index e86f4e948..f77ecfc50 100644
--- a/org/omg/PortableServer/POAPackage/ServantNotActiveHelper.java
+++ b/org/omg/PortableServer/POAPackage/ServantNotActiveHelper.java
@@ -1,5 +1,5 @@
/* ServantNotActiveHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/PortableServer/POAPackage/WrongAdapterHelper.java b/org/omg/PortableServer/POAPackage/WrongAdapterHelper.java
index 7650014c1..f1181fe61 100644
--- a/org/omg/PortableServer/POAPackage/WrongAdapterHelper.java
+++ b/org/omg/PortableServer/POAPackage/WrongAdapterHelper.java
@@ -1,5 +1,5 @@
/* WrongAdapterHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/PortableServer/POAPackage/WrongPolicyHelper.java b/org/omg/PortableServer/POAPackage/WrongPolicyHelper.java
index a9e7fc594..bd09c2e96 100644
--- a/org/omg/PortableServer/POAPackage/WrongPolicyHelper.java
+++ b/org/omg/PortableServer/POAPackage/WrongPolicyHelper.java
@@ -1,5 +1,5 @@
/* WrongPolicyHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -46,7 +46,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.ORB;
import org.omg.CORBA.StructMember;
-import org.omg.CORBA.TCKind;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
diff --git a/org/omg/PortableServer/RequestProcessingPolicyValue.java b/org/omg/PortableServer/RequestProcessingPolicyValue.java
index 0b1ce4d0b..2f22e3090 100644
--- a/org/omg/PortableServer/RequestProcessingPolicyValue.java
+++ b/org/omg/PortableServer/RequestProcessingPolicyValue.java
@@ -1,5 +1,5 @@
/* RequestProcessingPolicyValue.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,7 @@ package org.omg.PortableServer;
import gnu.CORBA.Minor;
import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.portable.IDLEntity;
import java.io.Serializable;
diff --git a/org/omg/PortableServer/Servant.java b/org/omg/PortableServer/Servant.java
index 5c99ee1a0..24eb715a9 100644
--- a/org/omg/PortableServer/Servant.java
+++ b/org/omg/PortableServer/Servant.java
@@ -80,7 +80,7 @@ import gnu.CORBA.Poa.gnuPOA;
* The Servant type is a CORBA native
type.
*
*
- * @see POA.servant_to_reference(Servant)
+ * @see POA#servant_to_reference(Servant)
*
* @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
*/
@@ -128,8 +128,7 @@ public abstract class Servant
* Checks if the passed servant is an instance of the given CORBA IDL type.
* By default, forwards the requet to the delegate.
*
- * @param a_servant a servant to check.
- * @param an_id a repository ID, representing an IDL type for that the
+ * @param repository_id a repository ID, representing an IDL type for that the
* servant must be checked.
*
* @return true if the servant is an instance of the given type, false
@@ -166,7 +165,7 @@ public abstract class Servant
* reference "RootPOA" for that orb. By default, forwards request to the
* delegate.
*
- * @see ORB.resolve_initial_references
+ * @see ORB#resolve_initial_references
*/
public POA _default_POA()
{
@@ -214,7 +213,7 @@ public abstract class Servant
* the given servant. This is important when the same servant serves
* multiple objects. If the servant is not yet connected to the passed
* orb, the method will try to connect it to that orb on POA, returned
- * by the method {@link _default_POA}. That method can be overridden to
+ * by the method {@link #_default_POA}. That method can be overridden to
* get poa where the object must be automatically connected when
* calling this method.
*
diff --git a/org/omg/PortableServer/ServantActivatorHelper.java b/org/omg/PortableServer/ServantActivatorHelper.java
index e1c4f09c8..48598aa20 100644
--- a/org/omg/PortableServer/ServantActivatorHelper.java
+++ b/org/omg/PortableServer/ServantActivatorHelper.java
@@ -1,5 +1,5 @@
/* ServantActivatorHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -45,7 +45,6 @@ import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.MARSHAL;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -121,15 +120,13 @@ public abstract class ServantActivatorHelper
* Narrow the given object to the ServantActivator. For the objects that are
* always local, this operation does not differ from the ordinary
* {@link #narrow} (ClassCastException will be thrown if narrowing something
- * different).
+ * different). See OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted ServantActivator.
*
* @since 1.5
- *
- * @see OMG issue 4158.
*/
public static ServantActivator unchecked_narrow(org.omg.CORBA.Object obj)
{
diff --git a/org/omg/PortableServer/ServantLocatorHelper.java b/org/omg/PortableServer/ServantLocatorHelper.java
index 7bb933f7b..467464791 100644
--- a/org/omg/PortableServer/ServantLocatorHelper.java
+++ b/org/omg/PortableServer/ServantLocatorHelper.java
@@ -1,5 +1,5 @@
/* ServantLocatorHelper.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -43,8 +43,8 @@ import gnu.CORBA.OrbRestricted;
import org.omg.CORBA.Any;
import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.MARSHAL;
-import org.omg.CORBA.ORB;
import org.omg.CORBA.TypeCode;
import org.omg.CORBA.portable.InputStream;
import org.omg.CORBA.portable.OutputStream;
@@ -121,15 +121,13 @@ public abstract class ServantLocatorHelper
* Narrow the given object to the ServantLocator. For the objects that are
* always local, this operation does not differ from the ordinary
* {@link #narrow} (ClassCastException will be thrown if narrowing something
- * different).
+ * different). See OMG issue 4158.
*
* @param obj the object to cast.
*
* @return the casted ServantLocator.
*
* @since 1.5
- *
- * @see OMG issue 4158.
*/
public static ServantLocator unchecked_narrow(org.omg.CORBA.Object obj)
{
diff --git a/org/omg/PortableServer/ServantLocatorOperations.java b/org/omg/PortableServer/ServantLocatorOperations.java
index 6ed214e2f..58448c1af 100644
--- a/org/omg/PortableServer/ServantLocatorOperations.java
+++ b/org/omg/PortableServer/ServantLocatorOperations.java
@@ -1,5 +1,5 @@
/* ServantLocatorOperations.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -60,7 +60,7 @@ public interface ServantLocatorOperations
* @param operation the name of the method or operation being invoked.
* @param cookie_holder the holder where the servant manager can store
* an arbitrary java.lang.Object. This object will be later passed as a
- * cookie
parameter for {@link postinvoke}, to create tie
+ * cookie
parameter for {@link #postinvoke}, to create tie
* between preinvoke and postinvoke. The application should not
* suppose that each call of preinvoke is followed by the subsequent
* postinvoke for the same invocation; under multi threaded policy these
diff --git a/org/omg/PortableServer/ServantRetentionPolicyValue.java b/org/omg/PortableServer/ServantRetentionPolicyValue.java
index 0b6ecf62f..607df1293 100644
--- a/org/omg/PortableServer/ServantRetentionPolicyValue.java
+++ b/org/omg/PortableServer/ServantRetentionPolicyValue.java
@@ -1,5 +1,5 @@
/* ServantRetentionPolicyValue.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,7 @@ package org.omg.PortableServer;
import gnu.CORBA.Minor;
import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.portable.IDLEntity;
import java.io.Serializable;
diff --git a/org/omg/PortableServer/ThreadPolicyValue.java b/org/omg/PortableServer/ThreadPolicyValue.java
index 5c771a7d6..2ba1b8e82 100644
--- a/org/omg/PortableServer/ThreadPolicyValue.java
+++ b/org/omg/PortableServer/ThreadPolicyValue.java
@@ -1,5 +1,5 @@
/* ThreadPolicyValue.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -41,6 +41,7 @@ package org.omg.PortableServer;
import gnu.CORBA.Minor;
import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.BAD_PARAM;
import org.omg.CORBA.portable.IDLEntity;
import java.io.Serializable;
diff --git a/org/omg/PortableServer/_ServantActivatorStub.java b/org/omg/PortableServer/_ServantActivatorStub.java
index 6f9071593..f323f6d38 100644
--- a/org/omg/PortableServer/_ServantActivatorStub.java
+++ b/org/omg/PortableServer/_ServantActivatorStub.java
@@ -1,5 +1,5 @@
/* _ServantActivatorStub.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,18 +38,10 @@ exception statement from your version. */
package org.omg.PortableServer;
-import org.omg.CORBA.MARSHAL;
-import org.omg.CORBA.ORB;
-import org.omg.CORBA.ObjectHelper;
-import org.omg.CORBA.portable.ApplicationException;
-import org.omg.CORBA.portable.Delegate;
-import org.omg.CORBA.portable.InputStream;
-import org.omg.CORBA.portable.ObjectImpl;
-import org.omg.CORBA.portable.OutputStream;
-import org.omg.CORBA.portable.RemarshalException;
-
import java.io.Serializable;
+import org.omg.CORBA.portable.ObjectImpl;
+
/**
* This ServantActivator stub is an optional base for the
* servant activators. This stub cannot accept remote invocations, as
diff --git a/org/omg/PortableServer/_ServantLocatorStub.java b/org/omg/PortableServer/_ServantLocatorStub.java
index 8234ba2c7..9f142e1e8 100644
--- a/org/omg/PortableServer/_ServantLocatorStub.java
+++ b/org/omg/PortableServer/_ServantLocatorStub.java
@@ -1,5 +1,5 @@
/* _ServantLocatorStub.java --
- Copyright (C) 2005 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006 Free Software Foundation, Inc.
This file is part of GNU Classpath.
diff --git a/resource/gnu/classpath/tools/common/Messages.properties b/resource/gnu/classpath/tools/common/Messages.properties
new file mode 100644
index 000000000..989fde74e
--- /dev/null
+++ b/resource/gnu/classpath/tools/common/Messages.properties
@@ -0,0 +1,40 @@
+# MessagesBundle.properties -- English language messages
+# Copyright (C) 2006 Free Software Foundation, Inc.
+#
+# This file is part of GNU Classpath.
+#
+# GNU Classpath is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Classpath is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Classpath; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+#
+# Linking this library statically or dynamically with other modules is
+# making a combined work based on this library. Thus, the terms and
+# conditions of the GNU General Public License cover the whole
+# combination.
+#
+# As a special exception, the copyright holders of this library give you
+# permission to link this library with independent modules to produce an
+# executable, regardless of the license terms of these independent
+# modules, and to copy and distribute the resulting executable under
+# terms of your choice, provided that you also meet, for each linked
+# independent module, the terms and conditions of the license of that
+# module. An independent module is a module which is not derived from
+# or based on this library. If you modify this library, you may extend
+# this exception to your version of the library, but you are not
+# obligated to do so. If you do not wish to do so, delete this
+# exception statement from your version.
+
+ClasspathToolParser.JArgument=pass argument to the Java runtime
+ClasspathToolParser.JName=OPTION
+ClasspathToolParser.VersionFormat={0} (GNU Classpath) {1}\n\nCopyright 2006 Free Software Foundation, Inc.\nThis is free software; see the source for copying conditions. There is NO\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/resource/gnu/classpath/tools/getopt/Messages.properties b/resource/gnu/classpath/tools/getopt/Messages.properties
index 42827e6e3..a747ab4b4 100644
--- a/resource/gnu/classpath/tools/getopt/Messages.properties
+++ b/resource/gnu/classpath/tools/getopt/Messages.properties
@@ -38,12 +38,9 @@
Parser.StdOptions=Standard options
Parser.PrintHelp=print this help, then exit
Parser.PrintVersion=print version number, then exit
-Parser.JArgument=pass argument to the Java runtime
-Parser.JName=OPTION
Parser.ArgReqd=option ''{0}'' requires an argument
Parser.Unrecognized=unrecognized option ''{0}''
Parser.NoArg=option ''{0}'' doesn''t allow an argument
Parser.UnrecDash=unrecognized option ''-{0}''
Parser.TryHelpShort=Try ''{0} -help'' for more information
Parser.TryHelpLong=Try ''{0} --help'' for more information
-ClasspathToolParser.VersionFormat={0} (GNU Classpath) {1}\n\nCopyright 2006 Free Software Foundation, Inc.\nThis is free software; see the source for copying conditions. There is NO\nwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff --git a/resource/gnu/classpath/tools/orbd/messages.properties b/resource/gnu/classpath/tools/orbd/messages.properties
new file mode 100644
index 000000000..b427d102b
--- /dev/null
+++ b/resource/gnu/classpath/tools/orbd/messages.properties
@@ -0,0 +1,46 @@
+# messages.properties -- English language messages
+# Copyright (C) 2006 Free Software Foundation, Inc.
+#
+# This file is part of GNU Classpath.
+#
+# GNU Classpath is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Classpath is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Classpath; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+#
+# Linking this library statically or dynamically with other modules is
+# making a combined work based on this library. Thus, the terms and
+# conditions of the GNU General Public License cover the whole
+# combination.
+#
+# As a special exception, the copyright holders of this library give you
+# permission to link this library with independent modules to produce an
+# executable, regardless of the license terms of these independent
+# modules, and to copy and distribute the resulting executable under
+# terms of your choice, provided that you also meet, for each linked
+# independent module, the terms and conditions of the license of that
+# module. An independent module is a module which is not derived from
+# or based on this library. If you modify this library, you may extend
+# this exception to your version of the library, but you are not
+# obligated to do so. If you do not wish to do so, delete this
+# exception statement from your version.
+
+Main.Usage=Usage: orbd [OPTIONS]
+Main.ORBInitialPort=port on which persistent naming service is to be started
+Main.Port=PORT
+Main.IOR=file in which to store persistent naming service's IOR reference
+Main.IORFile=FILE
+Main.Restart=restart persistent naming service, clearing persistent naming database
+Main.Directory=directory in which to store persistent data
+Main.DirectoryArgument=DIRECTORY
+Main.InternalError=orbd: internal error:
diff --git a/resource/gnu/classpath/tools/rmic/messages.properties b/resource/gnu/classpath/tools/rmic/messages.properties
new file mode 100644
index 000000000..7be7cb0c7
--- /dev/null
+++ b/resource/gnu/classpath/tools/rmic/messages.properties
@@ -0,0 +1,61 @@
+# messages.properties -- English language messages
+# Copyright (C) 2006 Free Software Foundation, Inc.
+#
+# This file is part of GNU Classpath.
+#
+# GNU Classpath is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Classpath is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Classpath; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+#
+# Linking this library statically or dynamically with other modules is
+# making a combined work based on this library. Thus, the terms and
+# conditions of the GNU General Public License cover the whole
+# combination.
+#
+# As a special exception, the copyright holders of this library give you
+# permission to link this library with independent modules to produce an
+# executable, regardless of the license terms of these independent
+# modules, and to copy and distribute the resulting executable under
+# terms of your choice, provided that you also meet, for each linked
+# independent module, the terms and conditions of the license of that
+# module. An independent module is a module which is not derived from
+# or based on this library. If you modify this library, you may extend
+# this exception to your version of the library, but you are not
+# obligated to do so. If you do not wish to do so, delete this
+# exception statement from your version.
+
+Main.Usage:rmic [OPTIONS] CLASSNAME...
+Main.NoWarn:show no warnings
+Main.NoWrite:check for errors and do not write any files
+Main.Verbose:show verbose output
+Main.DirOpt:write generated files to given directory
+Main.DirArg:DIRECTORY
+Main.ClasspathOpt:where to find input classes
+Main.ClasspathArg:PATH
+Main.BootclasspathOpt:where to find classes used to run rmic (ignored)
+Main.BootclasspathArg:PATH
+Main.ExtdirsOpt:where to find extension classes used to run rmic (ignored)
+Main.ExtdirsArg:PATH
+Main.IIOP:generate stubs and ties for IIOP
+Main.Always:always overwrite generated files (ignored)
+Main.AlwaysGenerate:same as -always
+Main.NoLocalStubs:do not create same-process stubs (ignored)
+Main.POA:generate servant-based ties
+Main.Keep:keep generated stub, skeleton and tie sources
+Main.KeepGenerated:same as -keep
+Main.v11:generate JDK 1.1 protocol stubs and skeletons
+Main.v12:generate JDK 1.2 JRMP stubs (default)
+Main.vcompat:generate JDK 1.1 protocol and JDK 1.2 JRMP stubs
+Main.DebugInfo:include debugging information in generated classes
+Main.InternalError:rmic: internal error:
diff --git a/resource/gnu/classpath/tools/rmid/messages.properties b/resource/gnu/classpath/tools/rmid/messages.properties
new file mode 100644
index 000000000..234cea12a
--- /dev/null
+++ b/resource/gnu/classpath/tools/rmid/messages.properties
@@ -0,0 +1,50 @@
+# messages.properties -- English language messages
+# Copyright (C) 2006 Free Software Foundation, Inc.
+#
+# This file is part of GNU Classpath.
+#
+# GNU Classpath is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Classpath is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Classpath; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+#
+# Linking this library statically or dynamically with other modules is
+# making a combined work based on this library. Thus, the terms and
+# conditions of the GNU General Public License cover the whole
+# combination.
+#
+# As a special exception, the copyright holders of this library give you
+# permission to link this library with independent modules to produce an
+# executable, regardless of the license terms of these independent
+# modules, and to copy and distribute the resulting executable under
+# terms of your choice, provided that you also meet, for each linked
+# independent module, the terms and conditions of the license of that
+# module. An independent module is a module which is not derived from
+# or based on this library. If you modify this library, you may extend
+# this exception to your version of the library, but you are not
+# obligated to do so. If you do not wish to do so, delete this
+# exception statement from your version.
+
+Main.Usage=Usage: rmid [OPTIONS]
+Main.ControlGroup=Activation process control
+Main.PortOption=port on which activation system is to be started
+Main.Port=PORT
+Main.Restart=restart activation system, clearing persistent naming database, if any
+Main.Stop=stop activation system
+Main.PersistenceGroup=Persistence
+Main.Persistent=make activation system persistent
+Main.Directory=directory in which to store persistent data
+Main.DirectoryArgument=DIRECTORY
+Main.DebugGroup=Debugging
+Main.Verbose=log binding events to standard out
+Main.InternalError=rmid: internal error:
diff --git a/resource/gnu/classpath/tools/rmiregistry/messages.properties b/resource/gnu/classpath/tools/rmiregistry/messages.properties
new file mode 100644
index 000000000..46f7cfdb7
--- /dev/null
+++ b/resource/gnu/classpath/tools/rmiregistry/messages.properties
@@ -0,0 +1,48 @@
+# messages.properties -- English language messages
+# Copyright (C) 2006 Free Software Foundation, Inc.
+#
+# This file is part of GNU Classpath.
+#
+# GNU Classpath is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Classpath is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Classpath; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+#
+# Linking this library statically or dynamically with other modules is
+# making a combined work based on this library. Thus, the terms and
+# conditions of the GNU General Public License cover the whole
+# combination.
+#
+# As a special exception, the copyright holders of this library give you
+# permission to link this library with independent modules to produce an
+# executable, regardless of the license terms of these independent
+# modules, and to copy and distribute the resulting executable under
+# terms of your choice, provided that you also meet, for each linked
+# independent module, the terms and conditions of the license of that
+# module. An independent module is a module which is not derived from
+# or based on this library. If you modify this library, you may extend
+# this exception to your version of the library, but you are not
+# obligated to do so. If you do not wish to do so, delete this
+# exception statement from your version.
+
+Main.Usage=Usage: rmiregistry [OPTIONS] [PORT]
+Main.ControlGroup=Registry process control
+Main.Restart=restart RMI naming service, clearing persistent naming database, if any
+Main.Stop=stop RMI naming service
+Main.PersistenceGroup=Persistence
+Main.Persistent=make RMI naming service persistent
+Main.Directory=directory in which to store persistent data
+Main.DirectoryArgument=DIRECTORY
+Main.DebugGroup=Debugging
+Main.Verbose=log binding events to standard out
+Main.InternalError=rmiregistry: internal error:
diff --git a/resource/gnu/classpath/tools/tnameserv/messages.properties b/resource/gnu/classpath/tools/tnameserv/messages.properties
new file mode 100644
index 000000000..3861e24ba
--- /dev/null
+++ b/resource/gnu/classpath/tools/tnameserv/messages.properties
@@ -0,0 +1,43 @@
+# messages.properties -- English language messages
+# Copyright (C) 2006 Free Software Foundation, Inc.
+#
+# This file is part of GNU Classpath.
+#
+# GNU Classpath is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# GNU Classpath is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Classpath; see the file COPYING. If not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301 USA.
+#
+# Linking this library statically or dynamically with other modules is
+# making a combined work based on this library. Thus, the terms and
+# conditions of the GNU General Public License cover the whole
+# combination.
+#
+# As a special exception, the copyright holders of this library give you
+# permission to link this library with independent modules to produce an
+# executable, regardless of the license terms of these independent
+# modules, and to copy and distribute the resulting executable under
+# terms of your choice, provided that you also meet, for each linked
+# independent module, the terms and conditions of the license of that
+# module. An independent module is a module which is not derived from
+# or based on this library. If you modify this library, you may extend
+# this exception to your version of the library, but you are not
+# obligated to do so. If you do not wish to do so, delete this
+# exception statement from your version.
+
+Main.Usage=Usage: tnameserv [OPTIONS]
+Main.ORBInitialPort=port on which naming service is to be started
+Main.Port=PORT
+Main.IOR=file in which to store naming service's IOR reference
+Main.IORFile=FILE
+Main.InternalError=tnameserv: internal error:
diff --git a/scripts/check_jni_methods.sh b/scripts/check_jni_methods.sh
index 4cc00cc17..b46e37821 100755
--- a/scripts/check_jni_methods.sh
+++ b/scripts/check_jni_methods.sh
@@ -35,9 +35,6 @@ cat > $TMPFILE3 << EOF
-Java_gnu_java_awt_peer_gtk_GtkMenuComponentPeer_dispose
-Java_java_lang_VMSystem_arraycopy
-Java_java_lang_VMSystem_identityHashCode
--Java_gnu_java_util_prefs_gconf_GConfNativePeer_finalize_1class
--Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1id_1cache
--Java_gnu_java_util_prefs_gconf_GConfNativePeer_init_1class
EOF
# Compare again silently.
diff --git a/tools/.cvsignore b/tools/.cvsignore
index 49dfefd00..a013e8d16 100644
--- a/tools/.cvsignore
+++ b/tools/.cvsignore
@@ -12,3 +12,8 @@ gjar
gnative2ascii
gserialver
gjavah
+gorbd
+grmic
+grmid
+grmiregistry
+gtnameserv
diff --git a/tools/Makefile.am b/tools/Makefile.am
index b6bc4fbe2..04c2f2bbf 100755
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -15,12 +15,14 @@ endif
if USE_ASM
javah = gjavah
+rmic = grmic
endif
if CREATE_WRAPPERS
bin_SCRIPTS =
bin_PROGRAMS = gappletviewer gjarsigner gkeytool \
- gjar gnative2ascii gserialver $(javah)
+ gjar gnative2ascii gserialver $(javah) grmiregistry \
+ gtnameserv gorbd grmid $(rmic)
AM_CPPFLAGS = -Wall \
@@ -58,23 +60,50 @@ gserialver_CFLAGS = \
-DTOOLPACKAGE="\"serialver\"" \
-DTOOLNAME="\"gserialver\""
+grmiregistry_SOURCES = toolwrapper.c
+grmiregistry_CFLAGS = \
+ -DTOOLPACKAGE="\"rmiregistry\"" \
+ -DTOOLNAME="\"grmiregistry\""
+
+gtnameserv_SOURCES = toolwrapper.c
+gtnameserv_CFLAGS = \
+ -DTOOLPACKAGE="\"tnameserv\"" \
+ -DTOOLNAME="\"gtnameserv\""
+
+gorbd_SOURCES = toolwrapper.c
+gorbd_CFLAGS = \
+ -DTOOLPACKAGE="\"orbd\"" \
+ -DTOOLNAME="\"gorbd\""
+
+grmid_SOURCES = toolwrapper.c
+grmid_CFLAGS = \
+ -DTOOLPACKAGE="\"rmid\"" \
+ -DTOOLNAME="\"grmid\""
+
if USE_ASM
gjavah_SOURCES = toolwrapper.c
gjavah_CFLAGS = \
-DTOOLPACKAGE="\"javah\"" \
-DTOOLNAME="\"gjavah\""
+
+grmic_SOURCES = toolwrapper.c
+grmic_CFLAGS = \
+ -DTOOLPACKAGE="\"rmic\"" \
+ -DTOOLNAME="\"grmic\""
endif
else
bin_SCRIPTS = gappletviewer gjarsigner gkeytool \
- gjar gnative2ascii gserialver $(javah)
+ gjar gnative2ascii gserialver $(javah) grmiregistry \
+ gtnameserv gorbd grmid $(rmic)
bin_PROGRAMS =
endif
EXTRA_DIST = toolwrapper.c gappletviewer.in gjarsigner.in gkeytool.in \
- gjar.in gnative2ascii.in gserialver.in gjavah.in
+ gjar.in gnative2ascii.in gserialver.in gjavah.in grmiregistry.in \
+ gtnameserv.in gorbd.in grmid.in grmic.in
# All our example java source files
-TOOLS_JAVA_FILES = $(srcdir)/gnu/classpath/tools/*.java $(srcdir)/gnu/classpath/tools/*/*.java $(srcdir)/gnu/classpath/tools/*/*/*.java
+TOOLS_JAVA_FILES = $(srcdir)/gnu/classpath/tools/*/*.java
# The zip files with classes we want to produce.
TOOLS_ZIP = tools.zip
@@ -82,26 +111,14 @@ TOOLS_ZIP = tools.zip
# Extra objects that will not exist until configure-time
BUILT_SOURCES = $(TOOLS_ZIP)
-# The templates that must be included into the generated zip file.
-GRMIC_TEMPLATES = $(srcdir)/gnu/classpath/tools/giop/grmic/templates/*.jav
-RMIC_TEMPLATES = $(srcdir)/gnu/classpath/tools/rmi/rmic/templates/*.jav
-
-TOOLS_TEMPLATES = $(GRMIC_TEMPLATES) $(RMIC_TEMPLATES)
-
-# This covers the built-in help texts, both for giop and rmic subpackages.
-GIOP_HELPS = $(srcdir)/gnu/classpath/tools/giop/*.txt
-RMI_HELPS = $(srcdir)/gnu/classpath/tools/rmi/*.txt
-
-TOOLS_HELPS = $(GIOP_HELPS) $(RMI_HELPS)
-
-# The tool specific README files.
-READMES = $(srcdir)/gnu/classpath/tools/giop/README
+# RMIC templates that must be included in the generated zip file.
+RMIC_TEMPLATES = $(srcdir)/gnu/classpath/tools/rmic/templates/*.jav
# All the files we find "interesting"
-ALL_TOOLS_FILES = $(TOOLS_JAVA_FILES) $(TOOLS_TEMPLATES) $(TOOLS_HELPS) $(READMES)
+ALL_TOOLS_FILES = $(TOOLS_JAVA_FILES) $(RMIC_TEMPLATES)
# Some architecture independent data to be installed.
-TOOLS_DATA = $(TOOLS_ZIP) README
+TOOLS_DATA = $(TOOLS_ZIP)
# Where we want these data files installed.
TOOLSdir = $(pkgdatadir)
@@ -125,20 +142,29 @@ dist-hook:
# immediately. And copy the template files we use to the classes dir
# so they get also included.
$(TOOLS_ZIP): $(TOOLS_JAVA_FILES)
- mkdir -p classes/gnu/classpath/tools/giop/grmic/templates
- mkdir -p classes/gnu/classpath/tools/rmi/rmic/templates
mkdir -p classes/gnu/classpath/tools/appletviewer
+ mkdir -p classes/gnu/classpath/tools/common
+ mkdir -p classes/gnu/classpath/tools/getopt
+ mkdir -p classes/gnu/classpath/tools/jar
mkdir -p classes/gnu/classpath/tools/jarsigner
mkdir -p classes/gnu/classpath/tools/keytool
- cp $(RMIC_TEMPLATES) classes/gnu/classpath/tools/rmi/rmic/templates
- cp $(GRMIC_TEMPLATES) classes/gnu/classpath/tools/giop/grmic/templates
- cp $(RMI_HELPS) classes/gnu/classpath/tools/rmi/
- cp $(GIOP_HELPS) classes/gnu/classpath/tools/giop/
+ mkdir -p classes/gnu/classpath/tools/native2ascii
+ mkdir -p classes/gnu/classpath/tools/orbd
+ mkdir -p classes/gnu/classpath/tools/rmid
+ mkdir -p classes/gnu/classpath/tools/rmiregistry
+ mkdir -p classes/gnu/classpath/tools/serialver
+ mkdir -p classes/gnu/classpath/tools/tnameserv
find $(srcdir)/gnu/classpath/tools -name '*.java' -print > classes.lst
if test -z "$(PATH_TO_ASM)"; then \
mv classes.lst classes.tmp; \
fgrep -v /javah/ classes.tmp > classes.lst; \
+ mv classes.lst classes.tmp; \
+ fgrep -v /rmic/ classes.tmp > classes.lst; \
rm -f classes.tmp;\
+ else \
+ mkdir -p classes/gnu/classpath/tools/javah; \
+ mkdir -p classes/gnu/classpath/tools/rmic/templates; \
+ cp $(RMIC_TEMPLATES) classes/gnu/classpath/tools/rmic/templates; \
fi
$(JCOMPILER) -d classes @classes.lst
(cd classes; \
diff --git a/tools/gnu/classpath/tools/AbstractMethodGenerator.java b/tools/gnu/classpath/tools/AbstractMethodGenerator.java
deleted file mode 100644
index d82284988..000000000
--- a/tools/gnu/classpath/tools/AbstractMethodGenerator.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/* AbstractMethodGenerator.java -- the abstract method generator
- Copyright (C) 2006 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package gnu.classpath.tools;
-
-public interface AbstractMethodGenerator
-{
- /**
- * Generate this method for the Stub (remote caller) class.
- */
- String generateStubMethod();
-
- /**
- * Generate this method for the Tie (remote servant) class.
- */
- String generateTieMethod();
-
-}
diff --git a/tools/gnu/classpath/tools/HelpPrinter.java b/tools/gnu/classpath/tools/HelpPrinter.java
deleted file mode 100644
index 89468918a..000000000
--- a/tools/gnu/classpath/tools/HelpPrinter.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/* HelpPrinter -- help message printer
- Copyright (C) 2006 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath.tools;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-/**
- * The shared class to print the help message and exit, when applicable.
- * Support the --help key.
- *
- * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
- */
-public class HelpPrinter
-{
- /**
- * Check for the --help, -help and -? keys. If one is found, print help and
- * exit the program.
- *
- * @param args the program arguments.
- * @param helpResourcePath the path to the help resource, related to the
- * HelpPrinter class.
- */
- public static void checkHelpKey(String[] args, String helpResourcePath)
- {
- for (int i = 0; i < args.length; i++)
- {
- String a = args[i];
- if (a.equals("-?") || a.equalsIgnoreCase("-help")
- || a.equalsIgnoreCase("--help"))
- printHelpAndExit(helpResourcePath);
- }
- }
-
- /**
- * Prints the contents of the resource specified by the designated path.
- *
- * @param helpResourcePath the path to a help resource, related to the
- * HelpPrinter class.
- */
- public static void printHelp(String helpResourcePath)
- {
- InputStream in = HelpPrinter.class.getResourceAsStream(helpResourcePath);
- BufferedReader br = new BufferedReader(new InputStreamReader(in));
- try
- {
- String s;
- while ((s = br.readLine()) != null)
- System.out.println(s);
- }
- catch (IOException x)
- {
- System.err.print("Resource loading is broken:");
- x.printStackTrace(System.err);
- }
- finally
- {
- try
- {
- br.close();
- }
- catch (IOException ignored)
- {
- }
- }
- }
-
- /**
- * Prints the help message and terminates.
- *
- * @param helpResourcePath the path to the help resource, related to the
- * HelpPrinter class.
- */
- public static void printHelpAndExit(String helpResourcePath)
- {
- printHelp(helpResourcePath);
- System.exit(0);
- }
-}
diff --git a/tools/gnu/classpath/tools/appletviewer/Main.java b/tools/gnu/classpath/tools/appletviewer/Main.java
index 1d9fed2b0..b22368003 100644
--- a/tools/gnu/classpath/tools/appletviewer/Main.java
+++ b/tools/gnu/classpath/tools/appletviewer/Main.java
@@ -37,17 +37,19 @@ exception statement from your version. */
package gnu.classpath.tools.appletviewer;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
import gnu.classpath.tools.getopt.Parser;
import java.applet.Applet;
import java.awt.Dimension;
+import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.URL;
import java.util.ArrayList;
@@ -249,6 +251,7 @@ class Main
if (pluginMode)
{
+ // Plugin will warn user about missing security manager.
InputStream in;
OutputStream out;
@@ -259,6 +262,33 @@ class Main
}
else
{
+ // Warn user about missing security manager.
+ System.err.println("WARNING: CURRENTLY GAPPLETVIEWER RUNS WITH NO SECURITY MANAGER.\n\n"
+ + "THIS MEANS THAT APPLETS YOU LOAD CAN DO ANYTHING A JAVA APPLICATION\n"
+ + "THAT YOU DOWNLOAD AND RUN CAN DO. BE *VERY* CAREFUL WHICH APPLETS YOU RUN.\n"
+ + "DO NOT USE GAPPLETVIEWER ON YOUR SYSTEM IF YOUR SYSTEM STORES IMPORTANT DATA.\n"
+ + "THIS DATA CAN BE DESTROYED OR STOLEN IF YOU LOAD A MALICIOUS APPLET.\n");
+
+ System.err.println("[press 'c' or 'C' to continue or anything else to quit]");
+
+ BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
+ String response = null;
+
+ try
+ {
+ response = stdin.readLine();
+ }
+ catch (IOException e)
+ {
+ System.err.println("failed to read response to warning message: " + e);
+ System.exit(1);
+ }
+
+ if (!(response.equals("c") || response.equals("C")))
+ {
+ System.exit(0);
+ }
+
if (code == null)
{
// The --code option wasn't given and there are no URL
diff --git a/tools/gnu/classpath/tools/common/ClasspathToolParser.java b/tools/gnu/classpath/tools/common/ClasspathToolParser.java
new file mode 100644
index 000000000..e44b9011c
--- /dev/null
+++ b/tools/gnu/classpath/tools/common/ClasspathToolParser.java
@@ -0,0 +1,87 @@
+/* ClasspathToolParser.java -- Parser subclass for classpath tools
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.common;
+
+import java.text.MessageFormat;
+
+import gnu.classpath.Configuration;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.Parser;
+
+/**
+ * This is like the Parser class, but is specialized for use by
+ * tools distributed with GNU Classpath. In particular it automatically
+ * computes the version string using the program's name.
+ */
+public class ClasspathToolParser
+ extends Parser
+{
+ private static String getVersionString(String programName)
+ {
+ String fmt = (Messages.getString("ClasspathToolParser.VersionFormat")); //$NON-NLS-1$
+ return MessageFormat.format(fmt,
+ new Object[]
+ {
+ programName,
+ Configuration.CLASSPATH_VERSION
+ });
+ }
+
+ public ClasspathToolParser(String programName)
+ {
+ this(programName, false);
+ }
+
+ public ClasspathToolParser(String programName, boolean longOnly)
+ {
+ super(programName, getVersionString(programName), longOnly);
+ addFinal(new Option('J',
+ Messages.getString("ClasspathToolParser.JArgument"),//$NON-NLS-1$
+ Messages.getString("ClasspathToolParser.JName"), //$NON-NLS-1$
+ true)
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ // -J should be handled by the wrapper binary.
+ // We add it here so that it shows up in the --help output.
+ }
+ });
+ }
+}
diff --git a/tools/gnu/classpath/tools/common/Messages.java b/tools/gnu/classpath/tools/common/Messages.java
new file mode 100644
index 000000000..1c92d348d
--- /dev/null
+++ b/tools/gnu/classpath/tools/common/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- i18n support for tools common code
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.common;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+class Messages
+{
+ private static final String BUNDLE_NAME
+ = "gnu.classpath.tools.common.Messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE
+ = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages()
+ {
+ }
+
+ public static String getString(String key)
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString(key);
+ }
+ catch (MissingResourceException e)
+ {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/tools/gnu/classpath/tools/common/Persistent.java b/tools/gnu/classpath/tools/common/Persistent.java
new file mode 100644
index 000000000..5a2b48a8d
--- /dev/null
+++ b/tools/gnu/classpath/tools/common/Persistent.java
@@ -0,0 +1,87 @@
+/* PersistentBidiHasthable.java -- Constants for the persistent tables.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.common;
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+/**
+ * The static fields, shared by the multiple classes, implementing the
+ * persistent work.
+ *
+ * @author Audrius Meskauskas (audriusa@bioinformatics.org)
+ */
+public interface Persistent
+{
+ /**
+ * Sheduled termination task.
+ */
+ static class ExitTask extends TimerTask
+ {
+ public void run()
+ {
+ System.exit(0);
+ }
+ }
+
+ /**
+ * The timer, sheduling all disk database update events, shared by all
+ * instances.
+ */
+ static Timer timer = new Timer(true);
+
+ /**
+ * The longest time, in ms, after that the database content on the disk must
+ * be updated. The algorithm is written to avoid the very frequent writings to
+ * the disk.
+ */
+ static long SAVE_AT_MOST_AFTER = 5000;
+
+ /**
+ * States how long the database may stay not updated during the intensive
+ * operations, in ms. Otherwise the intensively used structure may never
+ * be stored to the disk.
+ */
+ static long ALWAYS_UPDATE = 300000;
+
+ /**
+ * Write the database content to the disk.
+ */
+ void writeContent();
+
+}
diff --git a/tools/gnu/classpath/tools/getopt/ClasspathToolParser.java b/tools/gnu/classpath/tools/getopt/ClasspathToolParser.java
deleted file mode 100644
index e712056ef..000000000
--- a/tools/gnu/classpath/tools/getopt/ClasspathToolParser.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/* ClasspathToolParser.java -- Parser subclass for classpath tools
- Copyright (C) 2006 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package gnu.classpath.tools.getopt;
-
-import java.text.MessageFormat;
-
-import gnu.classpath.Configuration;
-
-/**
- * This is like the Parser class, but is specialized for use by
- * tools distributed with GNU Classpath. In particular it automatically
- * computes the version string using the program's name.
- */
-public class ClasspathToolParser
- extends Parser
-{
- private static String getVersionString(String programName)
- {
- String fmt = (Messages.getString("ClasspathToolParser.VersionFormat")); //$NON-NLS-1$
- return MessageFormat.format(fmt,
- new Object[]
- {
- programName,
- Configuration.CLASSPATH_VERSION
- });
- }
-
- public ClasspathToolParser(String programName)
- {
- super(programName, getVersionString(programName));
- }
-
- public ClasspathToolParser(String programName, boolean longOnly)
- {
- super(programName, getVersionString(programName), longOnly);
- }
-}
diff --git a/tools/gnu/classpath/tools/getopt/Messages.java b/tools/gnu/classpath/tools/getopt/Messages.java
index 3c963d786..19f101743 100644
--- a/tools/gnu/classpath/tools/getopt/Messages.java
+++ b/tools/gnu/classpath/tools/getopt/Messages.java
@@ -41,7 +41,7 @@ package gnu.classpath.tools.getopt;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
-public class Messages
+class Messages
{
private static final String BUNDLE_NAME
= "gnu.classpath.tools.getopt.Messages"; //$NON-NLS-1$
diff --git a/tools/gnu/classpath/tools/getopt/Option.java b/tools/gnu/classpath/tools/getopt/Option.java
index 6f775e4a1..53255811e 100644
--- a/tools/gnu/classpath/tools/getopt/Option.java
+++ b/tools/gnu/classpath/tools/getopt/Option.java
@@ -44,7 +44,10 @@ package gnu.classpath.tools.getopt;
* like '--verbose'; if the parser is working in "long option only" mode, then a
* long flag has a single dash, like '-verbose'. Both a long and a short form
* may be specified; it is not valid to have neither. A description is mandatory
- * for options; this is used to automatically generate '--help' output.
+ * for options; this is used to automatically generate '--help' output. An option
+ * which takes an argument and which has a short form can also be "joined", in
+ * this case the option's argument can either be separated, like "-I path" or
+ * joined with the short option name, like "-Ipath".
*/
public abstract class Option
{
@@ -56,6 +59,8 @@ public abstract class Option
private String argumentName;
+ private boolean joined;
+
/**
* Create a new option with the given short name and description.
*
@@ -64,6 +69,8 @@ public abstract class Option
*/
protected Option(char shortName, String description)
{
+ if (shortName == 0)
+ throw new IllegalArgumentException("short name must not be \\0");
this.shortName = shortName;
this.description = description;
}
@@ -78,11 +85,33 @@ public abstract class Option
*/
protected Option(char shortName, String description, String argumentName)
{
+ if (shortName == 0)
+ throw new IllegalArgumentException("short name must not be \\0");
this.shortName = shortName;
this.description = description;
this.argumentName = argumentName;
}
+ /**
+ * Create a new option with the given short name and description.
+ *
+ * @param shortName the short name
+ * @param description the description
+ * @param argumentName the descriptive name of the argument, if this option
+ * takes an argument; otherwise null
+ * @param joined true if the short option is joined to its argument
+ */
+ protected Option(char shortName, String description, String argumentName,
+ boolean joined)
+ {
+ if (shortName == 0)
+ throw new IllegalArgumentException("short name must not be \\0");
+ this.shortName = shortName;
+ this.description = description;
+ this.argumentName = argumentName;
+ this.joined = joined;
+ }
+
/**
* Create a new option with the given long name and description. The long name
* should be specified without any leading dashes.
@@ -122,6 +151,8 @@ public abstract class Option
*/
protected Option(String longName, char shortName, String description)
{
+ if (shortName == 0)
+ throw new IllegalArgumentException("short name must not be \\0");
this.shortName = shortName;
this.longName = longName;
this.description = description;
@@ -140,10 +171,35 @@ public abstract class Option
protected Option(String longName, char shortName, String description,
String argumentName)
{
+ if (shortName == 0)
+ throw new IllegalArgumentException("short name must not be \\0");
+ this.shortName = shortName;
+ this.longName = longName;
+ this.argumentName = argumentName;
+ this.description = description;
+ }
+
+ /**
+ * Create a new option with the given short and long names and description.
+ * The long name should be specified without any leading dashes.
+ *
+ * @param longName the long name
+ * @param shortName the short name
+ * @param description the description
+ * @param argumentName the descriptive name of the argument, if this option
+ * takes an argument; otherwise null
+ * @param joined true if the short option is joined to its argument
+ */
+ protected Option(String longName, char shortName, String description,
+ String argumentName, boolean joined)
+ {
+ if (shortName == 0)
+ throw new IllegalArgumentException("short name must not be \\0");
this.shortName = shortName;
this.longName = longName;
this.argumentName = argumentName;
this.description = description;
+ this.joined = joined;
}
/**
@@ -187,6 +243,16 @@ public abstract class Option
return description;
}
+ /**
+ * Return true if this is a "joined" option, false otherwise.
+ * Only the short form of an option can be joined; this will always
+ * return false for an option which does not have a short form.
+ */
+ public boolean isJoined()
+ {
+ return joined;
+ }
+
/**
* This is called by the parser when this option is recognized. It may be
* called multiple times during a single parse. If this option takes an
diff --git a/tools/gnu/classpath/tools/getopt/OptionGroup.java b/tools/gnu/classpath/tools/getopt/OptionGroup.java
index f7d966d94..63853b2d0 100644
--- a/tools/gnu/classpath/tools/getopt/OptionGroup.java
+++ b/tools/gnu/classpath/tools/getopt/OptionGroup.java
@@ -231,10 +231,7 @@ public class OptionGroup
{
if (argName != null)
{
- // This is a silly hack just for '-J'. We don't
- // support joined options in general, but this option
- // is filtered out before argument processing can see it.
- if (option.getShortName() != 'J')
+ if (! option.isJoined())
{
out.print(' ');
++column;
diff --git a/tools/gnu/classpath/tools/getopt/Parser.java b/tools/gnu/classpath/tools/getopt/Parser.java
index 3c6cf6f46..b142836a5 100644
--- a/tools/gnu/classpath/tools/getopt/Parser.java
+++ b/tools/gnu/classpath/tools/getopt/Parser.java
@@ -72,6 +72,8 @@ public class Parser
private OptionGroup defaultGroup = new OptionGroup();
+ private OptionGroup finalGroup;
+
// These are used while parsing.
private int currentIndex;
@@ -166,7 +168,7 @@ public class Parser
this.longOnly = longOnly;
// Put standard options in their own section near the end.
- OptionGroup finalGroup = new OptionGroup(Messages.getString("Parser.StdOptions")); //$NON-NLS-1$
+ finalGroup = new OptionGroup(Messages.getString("Parser.StdOptions")); //$NON-NLS-1$
finalGroup.add(new Option("help", Messages.getString("Parser.PrintHelp")) //$NON-NLS-1$ //$NON-NLS-2$
{
public void parsed(String argument) throws OptionException
@@ -183,15 +185,6 @@ public class Parser
System.exit(0);
}
});
- finalGroup.add(new Option('J', Messages.getString("Parser.JArgument"), Messages.getString("Parser.JName")) //$NON-NLS-1$ //$NON-NLS-2$
- {
- public void parsed(String argument) throws OptionException
- {
- // -J should be handled by the appletviewer wrapper binary.
- // We add it here so that it shows up in the --help output.
- // Note that there is a special case for this in OptionGroup.
- }
- });
add(finalGroup);
add(defaultGroup);
@@ -229,6 +222,18 @@ public class Parser
defaultGroup.add(opt);
}
+ /**
+ * This is like {@link #add(Option)}, but adds the option to the "final"
+ * group. This should be used sparingly, if at all; it is intended for
+ * other very generic options like --help or --version.
+ * @param opt the option to add
+ */
+ protected synchronized void addFinal(Option opt)
+ {
+ options.add(opt);
+ finalGroup.add(opt);
+ }
+
/**
* Add an option group to this parser. All the options in this group will be
* recognized by the parser.
@@ -314,11 +319,10 @@ public class Parser
String option = real.substring(index);
String justName = option;
int eq = option.indexOf('=');
- if (eq != - 1)
+ if (eq != -1)
justName = option.substring(0, eq);
- char shortName = 0;
- if (justName.length() == 1)
- shortName = justName.charAt(0);
+ boolean isPlainShort = justName.length() == 1;
+ char shortName = justName.charAt(0);
Option found = null;
for (int i = options.size() - 1; i >= 0; --i)
{
@@ -328,8 +332,14 @@ public class Parser
found = opt;
break;
}
- if (shortName != 0 && opt.getShortName() == shortName)
+ if ((isPlainShort || opt.isJoined())
+ && opt.getShortName() == shortName)
{
+ if (! isPlainShort)
+ {
+ // The rest of the option string is the argument.
+ eq = 0;
+ }
found = opt;
break;
}
@@ -343,7 +353,7 @@ public class Parser
String argument = null;
if (found.getTakesArgument())
{
- if (eq == - 1)
+ if (eq == -1)
argument = getArgument(real);
else
argument = option.substring(eq + 1);
@@ -358,35 +368,42 @@ public class Parser
found.parsed(argument);
}
- private void handleShortOption(char option) throws OptionException
+ private void handleShortOptions(String option) throws OptionException
{
- Option found = null;
- for (int i = options.size() - 1; i >= 0; --i)
+ for (int charIndex = 1; charIndex < option.length(); ++charIndex)
{
- Option opt = (Option) options.get(i);
- if (option == opt.getShortName())
+ char optChar = option.charAt(charIndex);
+ Option found = null;
+ for (int i = options.size() - 1; i >= 0; --i)
{
- found = opt;
- break;
+ Option opt = (Option) options.get(i);
+ if (optChar == opt.getShortName())
+ {
+ found = opt;
+ break;
+ }
}
- }
- if (found == null)
- {
- String msg = MessageFormat.format(Messages.getString("Parser.UnrecDash"), //$NON-NLS-1$
- new Object[] { "" + option }); //$NON-NLS-1$
- throw new OptionException(msg);
- }
- String argument = null;
- if (found.getTakesArgument())
- argument = getArgument("-" + option); //$NON-NLS-1$
- found.parsed(argument);
- }
-
- private void handleShortOptions(String option) throws OptionException
- {
- for (int i = 1; i < option.length(); ++i)
- {
- handleShortOption(option.charAt(i));
+ if (found == null)
+ {
+ String msg = MessageFormat.format(Messages.getString("Parser.UnrecDash"), //$NON-NLS-1$
+ new Object[] { "" + optChar }); //$NON-NLS-1$
+ throw new OptionException(msg);
+ }
+ String argument = null;
+ if (found.getTakesArgument())
+ {
+ // If this is a joined short option, and there are more
+ // characters left in this argument, use those as the
+ // argument.
+ if (found.isJoined() && charIndex + 1 < option.length())
+ {
+ argument = option.substring(charIndex + 1);
+ charIndex = option.length();
+ }
+ else
+ argument = getArgument("-" + optChar); //$NON-NLS-1$
+ }
+ found.parsed(argument);
}
}
diff --git a/tools/gnu/classpath/tools/giop/GRMIC.java b/tools/gnu/classpath/tools/giop/GRMIC.java
deleted file mode 100644
index c910d7083..000000000
--- a/tools/gnu/classpath/tools/giop/GRMIC.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/* GRMIC.java -- GIOP support for RMIC.
- Copyright (C) 2006 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-*/
-
-package gnu.classpath.tools.giop;
-
-import gnu.classpath.tools.HelpPrinter;
-import gnu.classpath.tools.giop.grmic.GiopRmicCompiler;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * The main class of the GIOP compiler to generate stubs and ties for
- * javax.rmi package.
- *
- * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
- */
-public class GRMIC
-{
- /**
- * The version of the compiler.
- */
- public static String VERSION = "0.0 alpha pre";
-
- /**
- * The GRMIC compiler methods
- *
- * @param args the compiler parameters.
- */
- public static void main(String[] args)
- {
- boolean noWrite = false;
- boolean verbose = false;
-
- String HelpPath = "giop/GRMIC.txt";
-
- HelpPrinter.checkHelpKey(args, HelpPath);
-
- File output = new File(".");
-
- if (args.length == 0)
- {
- HelpPrinter.printHelpAndExit(HelpPath);
- }
- else
- {
- GiopRmicCompiler compiler = new GiopRmicCompiler();
-
- int cl = - 1;
-
- Options: for (int i = 0; i < args.length; i++)
- {
- String c = args[i];
- if (c.equals("-poa"))
- compiler.setPoaMode(true);
- else if (c.equals("-impl"))
- compiler.setPoaMode(false);
- else if (c.equals("-v"))
- {
- printVersion();
- System.exit(0);
- }
- else if (c.equals("-nowrite"))
- noWrite = true;
- else if (c.equals("-nowarn"))
- compiler.setWarnings(false);
- else if (c.equals("-verbose"))
- {
- verbose = true;
- compiler.setVerbose(true);
- }
- else if (c.equals("-force"))
- {
- compiler.setForce(true);
- }
- else if (c.equals("-d"))
- {
- int f = i + 1;
- if (f < args.length)
- {
- output = new File(args[f]);
- i++;
- }
- else
- HelpPrinter.printHelpAndExit(HelpPath);
- }
- else if (c.equals("-classpath"))
- {
- int f = i + 1;
- if (f < args.length)
- {
- compiler.setClassPath(args[f]);
- i++;
- }
- else
- HelpPrinter.printHelpAndExit(HelpPath);
- }
- else if (c.charAt(0) != '-')
- // No more options - start of class list.
- {
- cl = i;
- break Options;
- }
- }
-
- if (cl < 0)
- HelpPrinter.printHelpAndExit(HelpPath);
-
- if (verbose)
- System.out.println("Compiling to " + output.getAbsolutePath());
-
- // Compile classes
- Compile: for (int i = cl; i < args.length; i++)
- {
- if (args[i].charAt(0) != '-')
- {
- compiler.reset();
- Class c = compiler.loadClass(args[i]);
-
- compiler.compile(c);
- String packag = compiler.getPackageName().replace('.', '/');
- File fw = new File(output, packag);
-
- // Generate stub.
- String stub = compiler.generateStub();
- String subName = "_" + compiler.getStubName() + "_Stub.java";
-
- compiler.reset();
- compiler.compile(c);
-
- // Generate tie
- String tie = compiler.generateTie();
- String tieName = "_" + compiler.name(c) + "_Tie.java";
-
- if (noWrite)
- continue Compile;
-
- try
- {
- fw.mkdirs();
- OutputStream out = new FileOutputStream(new File(fw,
- subName));
- out.write(stub.getBytes());
- out.close();
-
- out = new FileOutputStream(new File(fw, tieName));
- out.write(tie.getBytes());
- out.close();
- }
- catch (IOException ioex)
- {
- System.err.println("Output path not accessible");
- ioex.printStackTrace();
- System.exit(1);
- }
- }
- }
- }
- }
-
- /**
- * Print the version information.
- */
- public static void printVersion()
- {
- System.out.println
- ("grmic v "+VERSION+" - GIOP stub and tie generator for javax.rmi.* ");
- }
-}
diff --git a/tools/gnu/classpath/tools/giop/GRMIC.txt b/tools/gnu/classpath/tools/giop/GRMIC.txt
deleted file mode 100644
index 875bcdbcf..000000000
--- a/tools/gnu/classpath/tools/giop/GRMIC.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-GIOP stub and tie generator source code generator for javax.rmi.*, omg.org.*
-
-Copyright 2006 Free Software Foundation, Inc.
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-Please report bugs at http://www.gnu.org/software/classpath/bugs.html
-
-Usage: grmic
-
- where includes:
- -poa Generate the Servant based ties (default)
- -impl Generate the obsoleted ObjectImpl based ties
- (for backward compatibility)
- -nowarn Show no warnings
- -nowrite Do not write any files (check for errors only)
- -d Place generated files into the given folder
- -classpath Specifies the path, where to find the classes being
- compiled
-
- -help Print this help text
- -v Print version
- -verbose Verbose output
- -force Try to generate code even if the input classes seem not
- consistent with RMI specification.
-
-
- and can include one or more non abstract classes that implement
- Remote and are accessible via current class path.
-
-* This tool generates the source code that must be compiled with java compiler.
-* GRMIC is invoked from RMIC if the -iiop or -giop keys are specified.
-
diff --git a/tools/gnu/classpath/tools/giop/IorParser.java b/tools/gnu/classpath/tools/giop/IorParser.java
deleted file mode 100644
index 411b8997d..000000000
--- a/tools/gnu/classpath/tools/giop/IorParser.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/* IorParser.java -- IOR parser.
- Copyright (C) 2006 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-*/
-
-
-package gnu.classpath.tools.giop;
-
-import gnu.CORBA.IOR;
-import gnu.classpath.tools.HelpPrinter;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-
-import org.omg.CORBA.BAD_PARAM;
-
-/**
- * Parses the information, encoded in the Interoperable Object References
- * (IORs).
- *
- * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
- */
-public class IorParser
-{
- /**
- * Parse and print IOR reference. The system exit code is 0 if the parsed
- * IOR was correct, 1 if it was invalid or missing.
- *
- * @param args supports -f file to read IOR from the file.
- */
- public static void main(String[] args)
- {
- boolean ok = false;
- String HelpResource = "giop/IorParser.txt";
- HelpPrinter.checkHelpKey(args, HelpResource);
- if (args.length == 0)
- HelpPrinter.printHelpAndExit(HelpResource);
- else if (args[0].equals("-f") && args.length==2)
- {
- File file = new File(args[1]);
- if (!file.exists())
- System.err.println("The file "+file.getAbsolutePath()+" is missing.");
- // Read IOR reference from file.
- String ior = null;
- try
- {
- FileReader fr = new FileReader(file);
- BufferedReader br = new BufferedReader(fr);
- ior = br.readLine();
- br.close();
- ok = parseAndPrint(ior);
- }
- catch (IOException e)
- {
- System.err.print("Unable to read the file "+file);
- e.printStackTrace();
- }
-
- }
- else if (args.length == 1)
- ok = parseAndPrint(args[0]);
- else
- HelpPrinter.printHelpAndExit(HelpResource);
-
- if (ok)
- System.exit(0);
- else
- System.exit(1);
- }
-
- /**
- * Parse and print IOR.
- *
- * @param ior the IOR string to anlyse.
- * @return true if the passed value is a valid IOR, false otherwise.
- */
- public static boolean parseAndPrint(String ior)
- {
- try
- {
- IOR gior = IOR.parse(ior);
- System.out.println(gior.toStringFormatted());
- return true;
- }
- catch (BAD_PARAM e)
- {
- System.out.println("Invalid ior: "+e.getMessage());
- return false;
- }
- }
-}
diff --git a/tools/gnu/classpath/tools/giop/IorParser.txt b/tools/gnu/classpath/tools/giop/IorParser.txt
deleted file mode 100644
index 3b04224f1..000000000
--- a/tools/gnu/classpath/tools/giop/IorParser.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-Copyright 2006 Free Software Foundation, Inc.
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-Please report bugs at http://www.gnu.org/software/classpath/bugs.html
-
-IOR (interoperable GIOP object reference) parser,
- usage: IorParser -f ior_file
- or: IorParser -f ior_string
-
diff --git a/tools/gnu/classpath/tools/giop/NameService.java b/tools/gnu/classpath/tools/giop/NameService.java
deleted file mode 100644
index 7e13185f2..000000000
--- a/tools/gnu/classpath/tools/giop/NameService.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/* NameService.java -- Transient GIOP naming service.
- Copyright (C) 2006 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath.tools.giop;
-
-import gnu.CORBA.NamingService.NamingServiceTransient;
-import gnu.classpath.tools.HelpPrinter;
-
-/**
- * The implementation of the transient naming service. The naming service
- * is a kind of the network server that registers local and remote objects
- * by name, and later can provide the object reference in response to the
- * given name.
- *
- * GNU Classpath currently works with this naming service and is also
- * interoperable with the Sun Microsystems naming services from releases 1.3 and
- * 1.4, both transient tnameserv and persistent orbd.
- *
- * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
- */
-public class NameService
-{
- /**
- * Start the naming service on the current host at the given port. The
- * parameter -org.omg.CORBA.ORBInitialPort NNN or -ORBInitialPort NNN, if
- * present, specifies the port, on that the service must be started. If this
- * key is not specified, the service starts at the port 900.
- *
- * The parameter -ior FILE_NAME, if present, forces to store the ior string of
- * this naming service to the specified file.
- *
- * @param args the parameter string.
- */
- public static void main(String[] args)
- {
- HelpPrinter.checkHelpKey(args, "giop/NamingService.txt");
- System.out.println("Please use --help for options.");
- NamingServiceTransient.main(args);
- }
-
-}
diff --git a/tools/gnu/classpath/tools/giop/NameServicePersistent.java b/tools/gnu/classpath/tools/giop/NameServicePersistent.java
deleted file mode 100644
index df0c9539d..000000000
--- a/tools/gnu/classpath/tools/giop/NameServicePersistent.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/* NamingServicePersistent.java -- The persistent naming service.
- Copyright (C) 2006 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath.tools.giop;
-
-import gnu.CORBA.OrbFunctional;
-import gnu.CORBA.IOR;
-import gnu.CORBA.NamingService.Ext;
-import gnu.classpath.tools.HelpPrinter;
-import gnu.classpath.tools.giop.nameservice.PersistentContext;
-
-import org.omg.CosNaming.NamingContextExt;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.PrintStream;
-import java.io.UnsupportedEncodingException;
-
-/**
- * The server for the gnu classpath persistent naming service.
- *
- * GNU Classpath currently works with this naming service and is also
- * interoperable with the Sun Microsystems naming services from releases 1.3 and
- * 1.4, both transient tnameserv and persistent orbd.
- *
- * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
- */
-public class NameServicePersistent
-{
- /**
- * The default port (900), on that the naming service starts if no
- * -ORBInitialPort is specified in the command line.
- */
- public static final int PORT = 900;
-
- /**
- * Get the object key for the naming service. The default key is the string
- * "NameService" in ASCII.
- *
- * @return the byte array.
- */
- public static byte[] getDefaultKey()
- {
- try
- { // NameService
- return "NameService".getBytes("UTF-8");
- }
- catch (UnsupportedEncodingException ex)
- {
- throw new InternalError("UTF-8 unsupported");
- }
- }
-
- /**
- * Start the naming service on the current host at the given port. The
- * parameter -org.omg.CORBA.ORBInitialPort NNN or -ORBInitialPort NNN, if
- * present, specifies the port, on that the service must be started. If this
- * key is not specified, the service starts at the port 900. The parameter
- * -ior FILE_NAME, if present, forces to store the ior string of this naming
- * service to the specified file.
- *
- * @param args the parameter string.
- */
- public static void main(String[] args)
- {
- HelpPrinter.checkHelpKey(args, "giop/NameServicePersistent.txt");
- System.out.println("Please use --help for options.");
-
- int port = PORT;
- String iorf = null;
- boolean reset = false;
- String folder = "";
- try
- {
- // Create and initialize the ORB
- final OrbFunctional orb = new OrbFunctional();
-
- for (int i = 0; i < args.length; i++)
- {
- if (i < args.length - 1)
- {
- if (args[i].endsWith("ORBInitialPort"))
- port = Integer.parseInt(args[i + 1]);
-
- if (args[i].equals("-ior"))
- iorf = args[i + 1];
-
- if (args[i].equals("-folder"))
- folder = args[i + 1];
- }
- if (args[i].equals("-reset"))
- reset = true;
- }
-
- OrbFunctional.setPort(port);
-
- // Create the servant and register it with the ORB
- File dataFolder = new File(folder);
- System.out.println("Persistent data stored at "
- + dataFolder.getAbsolutePath());
- dataFolder.mkdirs();
-
- // / TODO support more starting modes.
- NamingContextExt namer = new Ext(
- new PersistentContext(
- orb,
- dataFolder,
- reset));
-
- // Case with the key "NameService".
- orb.connect(namer, "NameService".getBytes());
-
- // Storing the IOR reference.
- String ior = orb.object_to_string(namer);
- IOR iorr = IOR.parse(ior);
- if (iorf != null)
- {
- FileOutputStream f = new FileOutputStream(iorf);
- PrintStream p = new PrintStream(f);
- p.print(ior);
- p.close();
- }
-
- System.out.println("GNU Classpath persistent naming service "
- + "started at " + iorr.Internet.host + ":"
- + iorr.Internet.port + " key 'NameService'.\n\n"
- + "Copyright (C) 2006 Free Software Foundation\n"
- + "This tool comes with ABSOLUTELY NO WARRANTY. "
- + "This is free software, and you are\nwelcome to "
- + "redistribute it under conditions, defined in "
- + "GNU Classpath license.\n\n" + ior);
-
- new Thread()
- {
- public void run()
- {
- // Wait for invocations from clients.
- orb.run();
- }
- }.start();
- }
- catch (Exception e)
- {
- System.err.println("ERROR: " + e);
- e.printStackTrace(System.out);
- }
-
- // Restore the default value for allocating ports for the subsequent
- // objects.
- OrbFunctional.setPort(OrbFunctional.DEFAULT_INITIAL_PORT);
- }
-}
diff --git a/tools/gnu/classpath/tools/giop/NameServicePersistent.txt b/tools/gnu/classpath/tools/giop/NameServicePersistent.txt
deleted file mode 100644
index 3de15f62a..000000000
--- a/tools/gnu/classpath/tools/giop/NameServicePersistent.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-Copyright 2006 Free Software Foundation, Inc.
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-Please report bugs at http://www.gnu.org/software/classpath/bugs.html
-
-GNU Classpath GIOP persitent naming service.
- usage: NameServicePersistent
-
- where includes:
-* -org.omg.CORBA.ORBInitialPort NNN
- or -ORBInitialPort NNN - specifies the port, on that the
- service must be started. If this key
- is not specified, the service starts
- at the port 900.
-
-* -ior FILE_NAME - store the IOR reference to this naming
- service to the specified file. The
- IOR reference contains enough
- information to locate the service
- on the web.
-* - folder FOLDER - store the persistent information
- to the given folder
-* - reset - discard any previously stored
- persistent information (cold start)
-
-
-
diff --git a/tools/gnu/classpath/tools/giop/NamingService.txt b/tools/gnu/classpath/tools/giop/NamingService.txt
deleted file mode 100644
index f57e4ac66..000000000
--- a/tools/gnu/classpath/tools/giop/NamingService.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-Copyright 2006 Free Software Foundation, Inc.
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-Please report bugs at http://www.gnu.org/software/classpath/bugs.html
-
-GNU Classpath GIOP naming service, usage: NameService
-
- where includes:
-* -org.omg.CORBA.ORBInitialPort NNN or
-* -ORBInitialPort NNN - specifies the port, on that the
- service must be started. If this key
- is not specified, the service starts
- at the port 900.
-
-* -ior FILE_NAME - store the IOR reference to this naming
- service to the specified file. The
- IOR reference contains enough
- information to locate the service
- on the web.
-
diff --git a/tools/gnu/classpath/tools/giop/README b/tools/gnu/classpath/tools/giop/README
deleted file mode 100644
index 94fc2f158..000000000
--- a/tools/gnu/classpath/tools/giop/README
+++ /dev/null
@@ -1,19 +0,0 @@
-This package defines GIOP tools for creating the applications that use this
-protocol. It provides necessary support for org.omg.* and javax.rmi.*
-packages.
-
-All GIOP tools support the --help option.
-
-The list of the currently available tools:
-
-* GRMIC - RMI-IIOP stub and tie generator.
-* NameService - GIOP transient naming service (this tool is called
- tnameserv in Sun's package).
-* NameServicePersistent
- - GIOP persistent naming service (this tool is called
- orbd in Sun's package).
-* IorParser - Parses the stringified form of the interoperable
- object references (IOR's).
-* RMIC - RMI stub and tie source code generator (complements
- the ASM based bytecode generator in the separate
- tools package).
\ No newline at end of file
diff --git a/tools/gnu/classpath/tools/giop/grmic/CompilationError.java b/tools/gnu/classpath/tools/giop/grmic/CompilationError.java
deleted file mode 100644
index d1fa814ee..000000000
--- a/tools/gnu/classpath/tools/giop/grmic/CompilationError.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/* CompilationError.java -- Thrown on compilation error.
- Copyright (C) 2006 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-*/
-
-package gnu.classpath.tools.giop.grmic;
-
-/**
- * This error is thrown when the target being compiled has illegal
- * strutures.
- *
- * @author Audrius Meskauskas, Lithuania (audriusa@Bioinformatics.org)
- */
-public class CompilationError extends Error
-{
- /**
- * Use serialVersionUID for interoperability.
- */
- private static final long serialVersionUID = 1;
-
- /**
- * Create error with explaining message and cause.
- */
- public CompilationError(String message, Throwable cause)
- {
- super(message, cause);
- }
-
- /**
- * Create error with explaining message
- */
- public CompilationError(String message)
- {
- super(message);
- }
-}
diff --git a/tools/gnu/classpath/tools/giop/grmic/Generator.java b/tools/gnu/classpath/tools/giop/grmic/Generator.java
deleted file mode 100644
index 17ab821ec..000000000
--- a/tools/gnu/classpath/tools/giop/grmic/Generator.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/* Generator.java -- Generic code generator.
- Copyright (C) 2006 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-*/
-
-package gnu.classpath.tools.giop.grmic;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.StringReader;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-
-/**
- * Contains basic methods, used in code generation.
- *
- * @author Audrius Meskauskas, Lithuania (audriusa@Bioinformatics.org)
- */
-public class Generator
-{
- /**
- * Get resource with the given name, as string.
- *
- * @param name the resource name
- * @return the resourse string (in subfolder /templates).
- */
- public String getResource(String name)
- {
- String resourcePath = "templates/" + name;
- InputStream in = getClass().getResourceAsStream(resourcePath);
-
- if (in == null)
- throw new InternalError(getClass().getName() + ": no resource "
- + resourcePath);
-
- BufferedReader r = new BufferedReader(new InputStreamReader(in));
- StringBuffer b = new StringBuffer();
-
- String s;
- try
- {
- while ((s = r.readLine()) != null)
- {
- b.append(s);
- b.append('\n');
- }
- r.close();
- }
- catch (IOException e)
- {
- InternalError ierr = new InternalError("No expected resource " + name);
- ierr.initCause(e);
- throw ierr;
- }
-
- return b.toString();
- }
-
- /**
- * Replace the variable references (starting from #) in the template string by
- * the values, present in the given map. The strings, not present in the
- * variable map, are ignored.
- *
- * @param template
- * the template string
- * @param variables
- * the map of variables (name to value) to replace.
- * @return the string with replaced values.
- */
- public String replaceAll(String template, Map variables)
- {
- BufferedReader r = new BufferedReader(new StringReader(template));
- String s;
- StringBuffer b = new StringBuffer(template.length());
- try
- {
- Iterator iter;
- Collection vars = variables.keySet();
- while ((s = r.readLine()) != null)
- {
- // At least one variable must appear in the string to make
- // the string scan sensible.
- if (s.indexOf('#') >= 0)
- {
- iter = vars.iterator();
- String variable;
- while (iter.hasNext())
- {
- variable = (String) iter.next();
- if (s.indexOf(variable) >= 0)
- s = s.replaceAll(variable,
- (String) variables.get(variable));
- }
- }
- b.append(s);
- b.append('\n');
- }
- r.close();
- }
- catch (IOException e)
- {
- // This should never happen.
- InternalError ierr = new InternalError("");
- ierr.initCause(e);
- throw ierr;
- }
- return b.toString();
- }
-}
diff --git a/tools/gnu/classpath/tools/giop/grmic/GiopIo.java b/tools/gnu/classpath/tools/giop/grmic/GiopIo.java
deleted file mode 100644
index 0e0df7bc5..000000000
--- a/tools/gnu/classpath/tools/giop/grmic/GiopIo.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/* GiopIo.java -- Generates GIOP input/output statements.
- Copyright (C) 2006 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-*/
-
-package gnu.classpath.tools.giop.grmic;
-
-import java.rmi.Remote;
-
-import org.omg.CORBA.portable.ObjectImpl;
-
-/**
- * Generates the code for reading and writing data over GIOP stream.
- *
- * @author Audrius Meskauskas, Lithuania (audriusa@Bioinformatics.org)
- */
-public class GiopIo
-{
- /**
- * Get the statement for writing the variable of the given type to the GIOP ({@link org.omg.CORBA_2_3.portable.OutputStream) stream. The
- * stream is always named "out".
- *
- * @param c
- * the class of the object being written
- * @param variable
- * the variable, where the object value is stored
- * @param r
- * the parent generator, used to name the class
- * @return the write statement.
- */
- public static String getWriteStatement(Class c, String variable, GiopRmicCompiler r)
- {
- if (c.equals(boolean.class))
- return "out.write_boolean(" + variable + ");";
- if (c.equals(byte.class))
- return "out.write_octet(" + variable + ");";
- else if (c.equals(short.class))
- return "out.write_int(" + variable + ");";
- else if (c.equals(int.class))
- return "out.write_long(" + variable + ");";
- else if (c.equals(long.class))
- return "out.write_long_long(" + variable + ");";
- else if (c.equals(double.class))
- return "out.write_double(" + variable + ");";
- else if (c.equals(float.class))
- return "out.write_float(" + variable + ");";
- else if (c.equals(char.class))
- return "out.write_char(" + variable + ");";
- else if (Remote.class.isAssignableFrom(c))
- return "Util.writeRemoteObject(out, " + variable + ");";
- else if (ObjectImpl.class.isAssignableFrom(c))
- return "out.write_Object(" + variable + ");";
- else
- return "out.write_value(" + variable + ", " + r.name(c) + ".class);";
- }
-
- /**
- * Get the statement for reading the value of the given type from to the GIOP ({@link org.omg.CORBA_2_3.portable.InputStream) stream. The
- * stream is always named "in".
- *
- * @param c
- * the class of the object being written
- * @param r
- * the parent generator, used to name the class
- * @return the right side of the read statement.
- */
- public static String getReadStatement(Class c, GiopRmicCompiler r)
- {
- if (c.equals(boolean.class))
- return "in.read_boolean();";
- else if (c.equals(byte.class))
- return "in.read_octet();";
- else if (c.equals(short.class))
- return "in.read_int();";
- else if (c.equals(int.class))
- return "in.read_long();";
- else if (c.equals(long.class))
- return "in.read_long_long();";
- else if (c.equals(double.class))
- return "in.read_double();";
- else if (c.equals(float.class))
- return "in.read_float();";
- else if (c.equals(char.class))
- return "in.read_char();";
- else if (Remote.class.isAssignableFrom(c))
- return "(" + r.name(c)
- + ") PortableRemoteObject.narrow(in.read_Object()," + r.name(c)
- + ".class);";
- else if (ObjectImpl.class.isAssignableFrom(c))
- return "in.read_Object();";
- else
- return "(" + r.name(c)
- + ") in.read_value(" + r.name(c) + ".class);";
- }
-
-}
diff --git a/tools/gnu/classpath/tools/giop/grmic/GiopRmicCompiler.java b/tools/gnu/classpath/tools/giop/grmic/GiopRmicCompiler.java
deleted file mode 100644
index 6d895a14c..000000000
--- a/tools/gnu/classpath/tools/giop/grmic/GiopRmicCompiler.java
+++ /dev/null
@@ -1,593 +0,0 @@
-/* GiopRmicCompiler -- Central GIOP-based RMI stub and tie compiler class.
- Copyright (C) 2006 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-*/
-
-package gnu.classpath.tools.giop.grmic;
-
-import gnu.classpath.tools.AbstractMethodGenerator;
-
-import java.io.File;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.StringTokenizer;
-import java.util.TreeSet;
-
-/**
- * Provides the extended rmic functionality to generate the POA - based classes
- * for GIOP (javax.rmi.CORBA package).
- *
- * @author Audrius Meskauskas, Lithuania (audriusa@Bioinformatics.org)
- */
-public class GiopRmicCompiler
- extends Generator implements Comparator
-{
- /** The package name. */
- protected String packag;
-
- /**
- * The "basic" name (normally, the interface name, unless several Remote -
- * derived interfaces are implemented.
- */
- protected String name;
-
- /**
- * The name (without package) of the class, passed as the parameter.
- */
- protected String implName;
-
- /**
- * The proposed name for the stub.
- */
- protected String stubName;
-
- /**
- * The Remote's, implemented by this class.
- */
- protected Collection implementedRemotes = new HashSet();
-
- /**
- * The extra classes that must be imported.
- */
- protected Collection extraImports = new HashSet();
-
- /**
- * The methods we must implement.
- */
- protected Collection methods = new HashSet();
-
- /**
- * The map of all code generator variables.
- */
- public Properties vars = new Properties();
-
- /**
- * If this flag is set (true by default), the compiler generates the Servant
- * based classes. If set to false, the compiler generates the old style
- * ObjectImpl based classes.
- */
- protected boolean poaMode = true;
-
- /**
- * If this flag is set (true by default), the compiler emits warnings.
- */
- protected boolean warnings = true;
-
- /**
- * Verbose output
- */
- protected boolean verbose = false;
-
- /**
- * Force mode - do not check the exceptions
- */
- protected boolean force = false;
-
- /**
- * The class loader to load the class being compiled.
- */
- ClassLoader classLoader;
-
- /**
- * Clear data, preparing for the next compilation.
- */
- public void reset()
- {
- packag = name = implName = stubName = null;
- implementedRemotes.clear();
- extraImports.clear();
- methods.clear();
- vars.clear();
- }
-
- /**
- * Set the class path (handle the -classpath key)
- *
- * @param classPath the class path to set.
- */
- public void setClassPath(String classPath)
- {
- classLoader = Thread.currentThread().getContextClassLoader();
- StringTokenizer tok = new StringTokenizer(classPath, File.pathSeparator,
- true);
- ArrayList urls = new ArrayList(tok.countTokens());
- String s = null;
- try
- {
- while (tok.hasMoreTokens())
- {
- s = tok.nextToken();
- if (s.equals(File.pathSeparator))
- urls.add(new File(".").toURL());
- else
- {
- urls.add(new File(s).toURL());
- if (tok.hasMoreTokens())
- {
- // Skip the separator.
- tok.nextToken();
- // If the classpath ended with a separator,
- // append the current directory.
- if (! tok.hasMoreTokens())
- urls.add(new File(".").toURL());
- }
- }
- }
- }
- catch (MalformedURLException ex)
- {
- System.err.println("Malformed path '" + s + "' in classpath '"
- + classPath + "'");
- System.exit(1);
- }
- URL[] u = new URL[urls.size()];
- for (int i = 0; i < u.length; i++)
- {
- u[i] = (URL) urls.get(i);
- }
-
- classLoader = new URLClassLoader(u, classLoader);
- }
-
- /**
- * Loads the class with the given name (uses class path, if applicable)
- *
- * @param name the name of the class.
- */
- public Class loadClass(String name)
- {
- ClassLoader loader = classLoader;
- if (loader == null)
- loader = Thread.currentThread().getContextClassLoader();
- try
- {
- return loader.loadClass(name);
- }
- catch (ClassNotFoundException e)
- {
- System.err.println(name+" not found on "+loader);
- System.exit(1);
- // Unreacheable code.
- return null;
- }
- }
-
- /**
- * Compile the given class (the instance of Remote), generating the stub and
- * tie for it.
- *
- * @param remote
- * the class to compile.
- */
- public synchronized void compile(Class remote)
- {
- reset();
- String s;
-
- // Get the package.
- s = remote.getName();
- int p = s.lastIndexOf('.');
- if (p < 0)
- {
- // Root package.
- packag = "";
- implName = name = s;
- }
- else
- {
- packag = s.substring(0, p);
- implName = name = s.substring(p + 1);
- }
-
- name = convertStubName(name);
-
- stubName = name;
-
- vars.put("#name", name);
- vars.put("#package", packag);
- vars.put("#implName", implName);
-
- if (verbose)
- System.out.println("Package " + packag + ", name " + name + " impl "
- + implName);
-
- // Get the implemented remotes.
- Class[] interfaces = remote.getInterfaces();
-
- for (int i = 0; i < interfaces.length; i++)
- {
- if (Remote.class.isAssignableFrom(interfaces[i]))
- {
- if (! interfaces[i].equals(Remote.class))
- {
- implementedRemotes.add(interfaces[i]);
- }
- }
- }
-
- vars.put("#idList", getIdList(implementedRemotes));
-
- // Collect and process methods.
- Iterator iter = implementedRemotes.iterator();
-
- while (iter.hasNext())
- {
- Class c = (Class) iter.next();
- Method[] m = c.getMethods();
-
- // Check if throws RemoteException.
- for (int i = 0; i < m.length; i++)
- {
- Class[] exc = m[i].getExceptionTypes();
- boolean remEx = false;
-
- for (int j = 0; j < exc.length; j++)
- {
- if (RemoteException.class.isAssignableFrom(exc[j]))
- {
- remEx = true;
- break;
- }
- }
- if (! remEx && !force)
- throw new CompilationError(m[i].getName() + ", defined in "
- + c.getName()
- + ", does not throw "
- + RemoteException.class.getName());
- AbstractMethodGenerator mm = createMethodGenerator(m[i]);
- methods.add(mm);
- }
- }
- }
-
- /**
- * Create the method generator for the given method.
- *
- * @param m the method
- *
- * @return the created method generator
- */
- protected AbstractMethodGenerator createMethodGenerator(Method m)
- {
- return new MethodGenerator(m, this);
- }
-
- /**
- * Get the name of the given class. The class is added to imports, if not
- * already present and not from java.lang and not from the current package.
- *
- * @param nameIt
- * the class to name
- * @return the name of class as it should appear in java language
- */
- public String name(Class nameIt)
- {
- if (nameIt.isArray())
- {
- // Mesure dimensions:
- int dimension = 0;
- Class finalComponent = nameIt;
- while (finalComponent.isArray())
- {
- finalComponent = finalComponent.getComponentType();
- dimension++;
- }
-
- StringBuffer brackets = new StringBuffer();
-
- for (int i = 0; i < dimension; i++)
- {
- brackets.append("[]");
- }
-
- return name(finalComponent) + " " + brackets;
- }
- else
- {
- String n = nameIt.getName();
- if (! nameIt.isArray() && ! nameIt.isPrimitive())
- if (! n.startsWith("java.lang")
- && ! (packag != null && n.startsWith(packag)))
- extraImports.add(n);
-
- int p = n.lastIndexOf('.');
- if (p < 0)
- return n;
- else
- return n.substring(p + 1);
- }
- }
-
- /**
- * Get the RMI-style repository Id for the given class.
- *
- * @param c
- * the interface, for that the repository Id must be created.
- * @return the repository id
- */
- public String getId(Class c)
- {
- return "RMI:" + c.getName() + ":0000000000000000";
- }
-
- /**
- * Get repository Id string array declaration.
- *
- * @param remotes
- * the collection of interfaces
- * @return the fully formatted string array.
- */
- public String getIdList(Collection remotes)
- {
- StringBuffer b = new StringBuffer();
-
- // Keep the Ids sorted, ensuring, that the same order will be preserved
- // between compilations.
- TreeSet sortedIds = new TreeSet();
-
- Iterator iter = remotes.iterator();
- while (iter.hasNext())
- {
- sortedIds.add(getId((Class) iter.next()));
- }
-
- iter = sortedIds.iterator();
- while (iter.hasNext())
- {
- b.append(" \"" + iter.next() + "\"");
- if (iter.hasNext())
- b.append(", \n");
- }
- return b.toString();
- }
-
- /**
- * Generate stub. Can only be called from {@link #compile}.
- *
- * @return the string, containing the text of the generated stub.
- */
- public String generateStub()
- {
- String template = getResource("Stub.jav");
-
- // Generate methods.
- StringBuffer b = new StringBuffer();
- Iterator iter = methods.iterator();
- while (iter.hasNext())
- {
- AbstractMethodGenerator m = (AbstractMethodGenerator) iter.next();
- b.append(m.generateStubMethod());
- }
-
- vars.put("#stub_methods", b.toString());
- vars.put("#imports", getImportStatements());
- vars.put("#interfaces", getAllInterfaces());
-
- String output = replaceAll(template, vars);
- return output;
- }
-
- /**
- * Get the list of all interfaces, implemented by the class, that are
- * derived from Remote.
- *
- * @return the string - all interfaces.
- */
- public String getAllInterfaces()
- {
- StringBuffer b = new StringBuffer();
- Iterator iter = implementedRemotes.iterator();
-
- while (iter.hasNext())
- {
- b.append(name((Class) iter.next()));
- if (iter.hasNext())
- b.append(", ");
- }
-
- return b.toString();
- }
-
- /**
- * Generate Tie. Can only be called from {@link #compile}.
- *
- * @return the string, containing the text of the generated Tie.
- */
- public String generateTie()
- {
- String template;
- if (poaMode)
- template = getResource("Tie.jav");
- else
- template = getResource("ImplTie.jav");
-
- // Generate methods.
- HashFinder hashFinder = new HashFinder();
-
- // Find the hash character position:
- Iterator iter = methods.iterator();
- String[] names = new String[methods.size()];
- int p = 0;
-
- for (int i = 0; i < names.length; i++)
- names[i] = ((MethodGenerator) iter.next()).getGiopMethodName();
-
- int hashCharPosition = hashFinder.findHashCharPosition(names);
-
- iter = methods.iterator();
- while (iter.hasNext())
- ((MethodGenerator) iter.next()).hashCharPosition = hashCharPosition;
-
- vars.put("#hashCharPos", Integer.toString(hashCharPosition));
-
- ArrayList sortedMethods = new ArrayList(methods);
- Collections.sort(sortedMethods, this);
-
- iter = sortedMethods.iterator();
-
- StringBuffer b = new StringBuffer();
-
- MethodGenerator prev = null;
-
- while (iter.hasNext())
- {
- MethodGenerator m = (MethodGenerator) iter.next();
- m.previous = prev;
- m.hashCharPosition = hashCharPosition;
- prev = m;
- b.append(m.generateTieMethod());
- }
-
- vars.put("#tie_methods", b.toString());
-
- vars.put("#imports", getImportStatements());
-
- String output = replaceAll(template, vars);
- return output;
- }
-
- public int compare(Object a, Object b)
- {
- MethodGenerator g1 = (MethodGenerator) a;
- MethodGenerator g2 = (MethodGenerator) b;
-
- return g1.getHashChar() - g2.getHashChar();
- }
-
- /**
- * Import the extra classes, used as the method parameters and return values.
- *
- * @return the additional import block.
- */
- protected String getImportStatements()
- {
- TreeSet imp = new TreeSet();
-
- Iterator it = extraImports.iterator();
- while (it.hasNext())
- {
- String ic = it.next().toString();
- imp.add("import " + ic + ";\n");
- }
-
- StringBuffer b = new StringBuffer();
- it = imp.iterator();
-
- while (it.hasNext())
- {
- b.append(it.next());
- }
- return b.toString();
- }
-
- /**
- * If this flag is set (true by default), the compiler generates the Servant
- * based classes. If set to false, the compiler generates the old style
- * ObjectImpl based classes.
- */
- public void setPoaMode(boolean mode)
- {
- poaMode = mode;
- }
-
- /**
- * Set the verbose output mode (false by default)
- *
- * @param isVerbose the verbose output mode
- */
- public void setVerbose(boolean isVerbose)
- {
- verbose = isVerbose;
- }
-
- /**
- * If this flag is set (true by default), the compiler emits warnings.
- */
- public void setWarnings(boolean warn)
- {
- warnings = warn;
- }
-
- /**
- * Set the error ignore mode.
- */
- public void setForce(boolean isforce)
- {
- force = isforce;
- }
-
- /**
- * Get the package name.
- */
- public String getPackageName()
- {
- return packag;
- }
-
- /**
- * Get the proposed stub name
- */
- public String getStubName()
- {
- return stubName;
- }
-
- /**
- * Additional processing of the stub name.
- */
- public String convertStubName(String name)
- {
- // Drop the Impl suffix, if one exists.
- if (name.endsWith("Impl"))
- return name.substring(0, name.length() - "Impl".length());
- else
- return name;
- }
-}
diff --git a/tools/gnu/classpath/tools/giop/grmic/HashFinder.java b/tools/gnu/classpath/tools/giop/grmic/HashFinder.java
deleted file mode 100644
index 2efdb1e76..000000000
--- a/tools/gnu/classpath/tools/giop/grmic/HashFinder.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/* HashFinder.java -- finds the hash character.
- Copyright (C) 2006 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-*/
-
-
-package gnu.classpath.tools.giop.grmic;
-
-import java.util.HashSet;
-
-/**
- * This class finds the hash character (the most different character in
- * the passed array of strings). This character is used to accelerate the
- * method invocation by name.
- *
- * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
- */
-public class HashFinder
-{
- /**
- * Find the hash char position in the given collection of strings.
- *
- * @param strings the string collection
- *
- * @return the optimal hash character position, always less then the
- * length of the shortest string.
- */
- public int findHashCharPosition(String[] strings)
- {
- // Find the length of the shortest string:
-
- int l = strings[0].length();
- for (int i = 1; i < strings.length; i++)
- {
- if (strings[i].length() < l)
- l = strings[i].length();
- }
-
- // Find the position with the smallest number of the matching characters:
- HashSet[] charLists = new HashSet[l];
-
- for (int i = 0; i < charLists.length; i++)
- {
- charLists[i] = new HashSet(strings.length);
- }
-
- for (int i = 0; i < strings.length; i++)
- for (int p = 0; p < l; p++)
- {
- charLists[p].add(new Integer(strings[i].charAt(p)));
- }
-
- int m = 0;
- int v = charLists[0].size();
-
- for (int i = 1; i < charLists.length; i++)
- {
- // Replace on equality also, seeking the hash char closer to the end
- // of line.
- if (charLists[i].size()>=v)
- {
- m = i;
- v = charLists[i].size();
- }
- }
- return m;
- }
-}
diff --git a/tools/gnu/classpath/tools/giop/grmic/MethodGenerator.java b/tools/gnu/classpath/tools/giop/grmic/MethodGenerator.java
deleted file mode 100644
index 80148d51a..000000000
--- a/tools/gnu/classpath/tools/giop/grmic/MethodGenerator.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/* MethodGenerator.java -- Generates methods for GIOP rmic compiler.
- Copyright (C) 2006 Free Software Foundation
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-*/
-
-package gnu.classpath.tools.giop.grmic;
-
-import gnu.classpath.tools.AbstractMethodGenerator;
-
-import java.lang.reflect.Method;
-import java.util.Properties;
-
-/**
- * Keeps information about the single method and generates the code fragments,
- * related to that method.
- *
- * @author Audrius Meskauskas, Lithuania (audriusa@Bioinformatics.org)
- */
-public class MethodGenerator implements AbstractMethodGenerator
-{
- /**
- * The method being defined.
- */
- Method method;
-
- /**
- * The parent code generator.
- */
- GiopRmicCompiler rmic;
-
- /**
- * The previous method in the list, null for the first element.
- * Used to avoid repretetive inclusion of the same hash code label.
- */
- MethodGenerator previous = null;
-
- /**
- * The hash character position.
- */
- int hashCharPosition;
-
- /**
- * Create the new method generator for the given method.
- *
- * @param aMethod
- * the related method.
- * @param aRmic
- * the Rmic generator instance, where more class - related
- * information is defined.
- */
- public MethodGenerator(Method aMethod, GiopRmicCompiler aRmic)
- {
- method = aMethod;
- rmic = aRmic;
- }
-
- /**
- * Get the method name.
- *
- * @return the name of the method.
- */
- public String getGiopMethodName()
- {
- String m = method.getName();
- if (m.startsWith("get"))
- return "_get_J" + m.substring("get".length());
- else if (m.startsWith("set"))
- return "_set_J" + m.substring("set".length());
- else
- return m;
- }
-
- /**
- * Get the method parameter declaration.
- *
- * @return the string - method parameter declaration.
- */
- public String getArgumentList()
- {
- StringBuffer b = new StringBuffer();
-
- Class[] args = method.getParameterTypes();
-
- for (int i = 0; i < args.length; i++)
- {
- b.append(rmic.name(args[i]));
- b.append(" p" + i);
- if (i < args.length - 1)
- b.append(", ");
- }
- return b.toString();
- }
-
- /**
- * Get the method parameter list only (no type declarations). This is used to
- * generate the method invocations statement.
- *
- * @return the string - method parameter list.
- */
- public String getArgumentNames()
- {
- StringBuffer b = new StringBuffer();
-
- Class[] args = method.getParameterTypes();
-
- for (int i = 0; i < args.length; i++)
- {
- b.append(" p" + i);
- if (i < args.length - 1)
- b.append(", ");
- }
- return b.toString();
- }
-
- /**
- * Get the list of exceptions, thrown by this method.
- *
- * @return the list of exceptions.
- */
- public String getThrows()
- {
- StringBuffer b = new StringBuffer();
-
- Class[] args = method.getExceptionTypes();
-
- for (int i = 0; i < args.length; i++)
- {
- b.append(rmic.name(args[i]));
- if (i < args.length - 1)
- b.append(", ");
- }
- return b.toString();
- }
-
- /**
- * Generate this method for the Stub class.
- *
- * @return the method body for the stub class.
- */
- public String generateStubMethod()
- {
- String templateName;
-
- Properties vars = new Properties(rmic.vars);
- vars.put("#return_type", rmic.name(method.getReturnType()));
- vars.put("#method_name", method.getName());
- vars.put("#giop_method_name", getGiopMethodName());
- vars.put("#argument_list", getArgumentList());
- vars.put("#argument_names", getArgumentNames());
-
- vars.put("#argument_write", getStubParaWriteStatement());
-
- if (method.getReturnType().equals(void.class))
- vars.put("#read_return", "return;");
- else
- vars.put("#read_return",
- "return "
- + GiopIo.getReadStatement(method.getReturnType(), rmic));
- String thr = getThrows();
- if (thr.length() > 0)
- vars.put("#throws", "\n throws " + thr);
- else
- vars.put("#throws", "");
-
- if (method.getReturnType().equals(void.class))
- templateName = "StubMethodVoid.jav";
- else
- {
- vars.put("#write_result",
- GiopIo.getWriteStatement(method.getReturnType(), "result",
- rmic));
- templateName = "StubMethod.jav";
- }
-
- String template = rmic.getResource(templateName);
- String generated = rmic.replaceAll(template, vars);
- return generated;
- }
-
- /**
- * Generate this method handling fragment for the Tie class.
- *
- * @return the fragment to handle this method for the Tie class.
- */
- public String generateTieMethod()
- {
- String templateName;
-
- Properties vars = new Properties(rmic.vars);
- vars.put("#return_type", rmic.name(method.getReturnType()));
- vars.put("#method_name", method.getName());
- vars.put("#giop_method_name", getGiopMethodName());
- vars.put("#argument_list", getArgumentList());
- vars.put("#argument_names", getArgumentNames());
-
- vars.put("#argument_write", getStubParaWriteStatement());
-
- if (previous == null || previous.getHashChar()!=getHashChar())
- vars.put("#hashCodeLabel"," case '"+getHashChar()+"':");
- else
- vars.put("#hashCodeLabel"," // also '"+getHashChar()+"':");
-
- if (method.getReturnType().equals(void.class))
- templateName = "TieMethodVoid.jav";
- else
- {
- vars.put("#write_result",
- GiopIo.getWriteStatement(method.getReturnType(), "result",
- rmic));
- templateName = "TieMethod.jav";
- }
- vars.put("#read_and_define_args", getRda());
-
- String template = rmic.getResource(templateName);
- String generated = rmic.replaceAll(template, vars);
- return generated;
- }
-
- /**
- * Generate sentences for Reading and Defining Arguments.
- *
- * @return the sequence of sentences for reading and defining arguments.
- */
- public String getRda()
- {
- StringBuffer b = new StringBuffer();
- Class[] args = method.getParameterTypes();
-
- for (int i = 0; i < args.length; i++)
- {
- b.append(" ");
- b.append(rmic.name(args[i]));
- b.append(" ");
- b.append("p"+i);
- b.append(" = ");
- b.append(GiopIo.getReadStatement(args[i], rmic));
- if (ithis, always.
- */
- public org.omg.CORBA.Object thisObject()
- {
- return this;
- }
-
- /**
- * Deactivates this object, disconnecting it from the orb.
- */
- public void deactivate()
- {
- _orb().disconnect(this);
- _set_delegate(null);
- target = null;
- }
-
- /**
- * Get the {@link ORB} where this {@link Servant} is connected.
- *
- * @return the ORB
- */
- public ORB orb()
- {
- return _orb();
- }
-
- /**
- * Connect this servant to the given ORB.
- */
- public void orb(ORB orb)
- {
- orb.connect(this);
- }
-
-/**
- * This method is invoked by ORB in response to the remote call. It redirects
- * the call to one of the methods in the target.
- *
- * @param method the name of the method to call.
- * @param parameter_stream the input stream, from where the parameters must be
- * read.
- * @param reply the response hander, providing methods to return the result.
- *
- * @return the output stream, created by the response handler
- *
- * @throws SystemException if one occurs during method invocation.
- */
- public OutputStream _invoke(String method,
- org.omg.CORBA.portable.InputStream parameter_stream,
- ResponseHandler reply)
- {
- try
- {
- InputStream in =(InputStream) parameter_stream;
-
-#tie_methods
-
- throw new BAD_OPERATION("No such method: '"+method+"'");
- }
- catch (SystemException ex)
- {
- throw ex;
- }
- catch (Throwable ex)
- {
- throw new UnknownException(ex);
- }
- }
-}
\ No newline at end of file
diff --git a/tools/gnu/classpath/tools/giop/grmic/templates/Stub.jav b/tools/gnu/classpath/tools/giop/grmic/templates/Stub.jav
deleted file mode 100644
index 371e12d44..000000000
--- a/tools/gnu/classpath/tools/giop/grmic/templates/Stub.jav
+++ /dev/null
@@ -1,47 +0,0 @@
-package #package;
-
-#imports
-import java.rmi.UnexpectedException;
-
-import javax.rmi.CORBA.Stub;
-import javax.rmi.CORBA.Util;
-
-import org.omg.CORBA.SystemException;
-import org.omg.CORBA.portable.ApplicationException;
-import org.omg.CORBA.portable.InputStream;
-import org.omg.CORBA.portable.RemarshalException;
-
-import org.omg.CORBA_2_3.portable.OutputStream;
-
-/**
- * This class delegates its method calls to the remote GIOP object.
- * It is normally generated with grmic.
- */
-public class _#name_Stub extends Stub
- implements #interfaces
-{
- /**
- * Use serialVersionUID for interoperability.
- */
- private static final long serialVersionUID = 1;
-
- /**
- * The array of repository ids, supported by this GIOP Object
- */
- private static final String[] type_ids =
- {
-#idList
- };
-
- /**
- * Return the array of repository ids, supported by this GIOP Object.
- *
- * @return the array of Ids.
- */
- public String[] _ids()
- {
- return type_ids;
- }
-
-#stub_methods
-}
\ No newline at end of file
diff --git a/tools/gnu/classpath/tools/giop/grmic/templates/StubMethod.jav b/tools/gnu/classpath/tools/giop/grmic/templates/StubMethod.jav
deleted file mode 100644
index 17636deb6..000000000
--- a/tools/gnu/classpath/tools/giop/grmic/templates/StubMethod.jav
+++ /dev/null
@@ -1,33 +0,0 @@
- /** @inheritDoc */
- public #return_type #method_name(#argument_list) #throws
- {
- try
- {
- InputStream in = null;
- try
- {
- OutputStream out =
- (OutputStream) _request("#giop_method_name", true);
-#argument_write
- in = _invoke(out);
- #read_return
- }
- catch (ApplicationException ex)
- {
- in = ex.getInputStream();
- throw new UnexpectedException(in.read_string());
- }
- catch (RemarshalException ex)
- {
- return #method_name(#argument_names);
- }
- finally
- {
- _releaseReply(in);
- }
- }
- catch (SystemException ex)
- {
- throw Util.mapSystemException(ex);
- }
- }
diff --git a/tools/gnu/classpath/tools/giop/grmic/templates/StubMethodVoid.jav b/tools/gnu/classpath/tools/giop/grmic/templates/StubMethodVoid.jav
deleted file mode 100644
index 0125a02b0..000000000
--- a/tools/gnu/classpath/tools/giop/grmic/templates/StubMethodVoid.jav
+++ /dev/null
@@ -1,32 +0,0 @@
- /** @inheritDoc */
- public #return_type #method_name(#argument_list) #throws
- {
- try
- {
- InputStream in = null;
- try
- {
- OutputStream out =
- (OutputStream) _request("#giop_method_name", true);
-#argument_write
- in = _invoke(out);
- }
- catch (ApplicationException ex)
- {
- in = ex.getInputStream();
- throw new UnexpectedException(in.read_string());
- }
- catch (RemarshalException ex)
- {
- #method_name(#argument_names);
- }
- finally
- {
- _releaseReply(in);
- }
- }
- catch (SystemException ex)
- {
- throw Util.mapSystemException(ex);
- }
- }
diff --git a/tools/gnu/classpath/tools/giop/grmic/templates/Tie.jav b/tools/gnu/classpath/tools/giop/grmic/templates/Tie.jav
deleted file mode 100644
index 797ae1401..000000000
--- a/tools/gnu/classpath/tools/giop/grmic/templates/Tie.jav
+++ /dev/null
@@ -1,184 +0,0 @@
-package #package;
-
-#imports
-import java.rmi.Remote;
-import javax.rmi.PortableRemoteObject;
-import javax.rmi.CORBA.Tie;
-
-import org.omg.CORBA.BAD_OPERATION;
-import org.omg.CORBA.ORB;
-import org.omg.CORBA.SystemException;
-import org.omg.CORBA.portable.OutputStream;
-import org.omg.CORBA.portable.ResponseHandler;
-import org.omg.CORBA.portable.UnknownException;
-import org.omg.PortableServer.Servant;
-import org.omg.PortableServer.POA;
-import org.omg.PortableServer.POAPackage.WrongPolicy;
-import org.omg.PortableServer.POAPackage.ObjectNotActive;
-import org.omg.PortableServer.POAPackage.ServantNotActive;
-
-import org.omg.CORBA_2_3.portable.InputStream;
-
-/**
- * This class accepts remote calls to the served GIOP object and delegates them
- * to the enclosed implementing class. Being servant, it must be connected to
- * the ORB Poa.
- * It is normally generated with grmic -poa
- */
-public class _#nameImpl_Tie extends Servant implements Tie
-{
- /**
- * All decoded remote calls are forwarded to this target.
- */
- #implName target;
-
- /**
- * The array of repository ids, supported by this GIOP Object
- */
- private static final String[] type_ids =
- {
-#idList
- };
-
- /**
- * Get an array of all interfaces, supported by this
- * {@link Servant}.
- *
- * @param poa unused
- * @param objectId unused
- *
- * @return the array of Ids.
- */
- public String[] _all_interfaces(POA poa,
- byte[] objectId
- )
- {
- return type_ids;
- }
-
-
- /**
- * Set the invocation target, where all received calls are finally
- * forwarded.
- *
- * @param a_target the forwarding target
- *
- * @throws ClassCastException if the target is not an instance of
- * #implName
- */
- public void setTarget(Remote a_target)
- {
- this.target = (#implName) a_target;
- }
-
- /**
- * Get the invocation target, where all received calls are finally
- * forwarded.
- *
- * @return the target, an instance of
- * #implName
- */
- public Remote getTarget()
- {
- return target;
- }
-
- /**
- * Return the actual GIOP object that would handle this request.
- *
- * @return the GIOP object.
- */
- public org.omg.CORBA.Object thisObject()
- {
- return _this_object();
- }
-
- /**
- * Deactivate this {@link Servant}. The WrongPolicy, ObjectNotActive
- * and ServantNotActive exceptions, if thrown during deactivation, are
- * catched and silently ignored.
- */
- public void deactivate()
- {
- try
- {
- _poa().deactivate_object(_poa().servant_to_id(this));
- }
- catch (WrongPolicy exception)
- {
- }
- catch (ObjectNotActive exception)
- {
- }
- catch (ServantNotActive exception)
- {
- }
- }
-
- /**
- * Get the {@link ORB} where this {@link Servant} is connected.
- *
- * @return the ORB
- */
- public ORB orb()
- {
- return _orb();
- }
-
- /**
- * Connect this servant to the given ORB. It is recommended to connect
- * servant to the ORBs root or other POA rather than using this method.
- */
- public void orb(ORB orb)
- {
- try
- {
- ((org.omg.CORBA_2_3.ORB) orb).set_delegate(this);
- }
- catch (ClassCastException e)
- {
- throw new org.omg.CORBA.BAD_PARAM(
- "POA Servant requires an instance of org.omg.CORBA_2_3.ORB"
- );
- }
- }
-
-/**
- * This method is invoked by ORB in response to the remote call. It redirects
- * the call to one of the methods in the target.
- *
- * @param method the name of the method to call.
- * @param parameter_stream the input stream, from where the parameters must be
- * read.
- * @param reply the response hander, providing methods to return the result.
- *
- * @return the output stream, created by the response handler
- *
- * @throws SystemException if one occurs during method invocation.
- */
- public OutputStream _invoke(String method,
- org.omg.CORBA.portable.InputStream parameter_stream,
- ResponseHandler reply
- ) throws SystemException
- {
- try
- {
- InputStream in =(InputStream) parameter_stream;
- switch (method.charAt(#hashCharPos))
- {
-#tie_methods
- default: break;
- }
-
- throw new BAD_OPERATION("No such method: '"+method+"'");
- }
- catch (SystemException ex)
- {
- throw ex;
- }
- catch (Throwable ex)
- {
- throw new UnknownException(ex);
- }
- }
-}
\ No newline at end of file
diff --git a/tools/gnu/classpath/tools/giop/grmic/templates/TieMethod.jav b/tools/gnu/classpath/tools/giop/grmic/templates/TieMethod.jav
deleted file mode 100644
index 493f0009b..000000000
--- a/tools/gnu/classpath/tools/giop/grmic/templates/TieMethod.jav
+++ /dev/null
@@ -1,11 +0,0 @@
- #hashCodeLabel
- // #method_name
- if (method.equals("#giop_method_name"))
- {
-#read_and_define_args
- OutputStream out = reply.createReply();
- #return_type result =
- target.#method_name(#argument_names);
- #write_result
- return out;
- }
diff --git a/tools/gnu/classpath/tools/giop/grmic/templates/TieMethodVoid.jav b/tools/gnu/classpath/tools/giop/grmic/templates/TieMethodVoid.jav
deleted file mode 100644
index 3db17da7c..000000000
--- a/tools/gnu/classpath/tools/giop/grmic/templates/TieMethodVoid.jav
+++ /dev/null
@@ -1,9 +0,0 @@
- #hashCodeLabel
- // #method_name
- if (method.equals("#giop_method_name"))
- {
-#read_and_define_args
- OutputStream out = reply.createReply();
- target.#method_name(#argument_names);
- return out;
- }
diff --git a/tools/gnu/classpath/tools/giop/nameservice/PersistentContext.java b/tools/gnu/classpath/tools/giop/nameservice/PersistentContext.java
deleted file mode 100644
index 9f0903f0a..000000000
--- a/tools/gnu/classpath/tools/giop/nameservice/PersistentContext.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/* PersistentContext.java -- The persistent naming context.
- Copyright (C) 2006 Free Software Foundation, Inc.
-
- This file is part of GNU Classpath.
-
- GNU Classpath is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- GNU Classpath is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNU Classpath; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301 USA.
-
- Linking this library statically or dynamically with other modules is
- making a combined work based on this library. Thus, the terms and
- conditions of the GNU General Public License cover the whole
- combination.
-
- As a special exception, the copyright holders of this library give you
- permission to link this library with independent modules to produce an
- executable, regardless of the license terms of these independent
- modules, and to copy and distribute the resulting executable under
- terms of your choice, provided that you also meet, for each linked
- independent module, the terms and conditions of the license of that
- module. An independent module is a module which is not derived from
- or based on this library. If you modify this library, you may extend
- this exception to your version of the library, but you are not
- obligated to do so. If you do not wish to do so, delete this
- exception statement from your version. */
-
-
-package gnu.classpath.tools.giop.nameservice;
-
-import gnu.CORBA.NamingService.NameTransformer;
-import gnu.CORBA.NamingService.TransientContext;
-
-import java.io.File;
-
-import org.omg.CORBA.ORB;
-import org.omg.CosNaming.NameComponent;
-import org.omg.CosNaming.NamingContext;
-import org.omg.CosNaming.NamingContextPackage.AlreadyBound;
-import org.omg.CosNaming.NamingContextPackage.CannotProceed;
-import org.omg.CosNaming.NamingContextPackage.InvalidName;
-import org.omg.CosNaming.NamingContextPackage.NotFound;
-
-/**
- * This class implements the persistent naming service, defined by
- * {@link NamingContext}. The 'persistent' means that the service remembers the
- * mappings, stored between restarts.
- *
- * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
- */
-public class PersistentContext
- extends TransientContext
-{
- /**
- * Use serial version UID for interoperability.
- */
- private static final long serialVersionUID = 2;
-
- /**
- * The folder, where the persistent context information is stored.
- */
- File contextFolder;
-
- /**
- * The uinque context identifier.
- */
- static long num = System.currentTimeMillis();
-
- /**
- * The naming service orb.
- */
- ORB orb;
-
- /**
- * Create the persistent naming context that will store the files in the given
- * folder of the local file system. This method also connects object to the
- * passed ORB.
- *
- * @param an_orb the naming service ORB, used to obtain and produce the object
- * stringified references.
- * @param folder the folder, where the persistent information is stored.
- * @param reset if true, the previous naming data are discarded. If false
- * (normally expected), they are loaded from the persistent memory to
- * provide the persistence.
- */
- public PersistentContext(ORB an_orb, File folder, boolean reset)
- {
- super(
- new PersistentContextMap(an_orb, new File(folder, "contexts.txt"), reset),
- new PersistentMap(an_orb, new File(folder, "objects.txt"), reset));
- contextFolder = folder;
- folder.mkdirs();
- orb = an_orb;
- orb.connect(this);
- }
-
- /**
- * Get the unique context number;
- *
- * @return the context number
- */
- static synchronized String getNum()
- {
- return Long.toHexString(num++);
- }
-
- /**
- * Create new persistent context.
- */
- public NamingContext new_context()
- {
- File ctxFolder = new File(contextFolder, "ctx_"+getNum());
- return new PersistentContext(orb, ctxFolder, true);
- }
-
- /**
- * Create a new context and give it a given name (bound it) in the current
- * context. The method benefits from passing the better readable context name.
- *
- * @param a_name the name being given to the new context.
- * @return the newly created context.
- * @throws AlreadyBound if the name is already in use.
- * @throws InvalidName if the name has zero length or otherwise invalid.
- */
- public NamingContext bind_new_context(NameComponent[] a_name)
- throws NotFound, AlreadyBound, CannotProceed, InvalidName
- {
- if (named_contexts.containsKey(a_name[0])
- || named_objects.containsKey(a_name[0]))
- throw new AlreadyBound();
-
- NameTransformer transformer = new NameTransformer();
-
- File ctxFolder = new File(contextFolder,
- transformer.toString(a_name).replace('/', '.')
- + ".v" + getNum());
-
- NamingContext child = new PersistentContext(orb, ctxFolder, true);
- bind_context(a_name, child);
- return child;
- }
-}
diff --git a/tools/gnu/classpath/tools/giop/nameservice/PersistentContextMap.java b/tools/gnu/classpath/tools/giop/nameservice/PersistentContextMap.java
deleted file mode 100644
index ce0188cf2..000000000
--- a/tools/gnu/classpath/tools/giop/nameservice/PersistentContextMap.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/* PersistentContextMap.java -- The persistent context naming map
- Copyright (C) 2006 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package gnu.classpath.tools.giop.nameservice;
-
-import java.io.File;
-
-import org.omg.CORBA.ORB;
-import org.omg.CORBA.Object;
-
-/**
- * The persistent context naming map for the persistent naming service.
- *
- * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
- */
-public class PersistentContextMap extends PersistentMap
-{
- /**
- * Create the persistent context map that stores information in the given
- * file.
- *
- * @param an_orb the naming service ORB, used to obtain and produce the object
- * stringified references.
- * @param mapFile the file, where the persistent information is stored.
- * @param reset if true, the previous naming data are discarded. If false
- * (normally expected), they are loaded from the persistent memory to
- * provide the persistence.
- */
- public PersistentContextMap(ORB an_orb, File mapFile, boolean reset)
- {
- super(an_orb, mapFile, reset);
- }
-
- /**
- * This method expects the PersistentContext as its parameter. The returned
- * description line is the name of the context parent folder.
- */
- protected String object_to_string(Object object)
- {
- PersistentContext pc = (PersistentContext) object;
- return pc.contextFolder.getAbsolutePath();
- }
-
- /**
- * This method restores the PersistenContext. The description line is
- * interpreted as the folder name, absolute path.
- */
- protected Object string_to_object(String description)
- {
- return new PersistentContext(orb, new File(description), reset);
- }
-}
diff --git a/tools/gnu/classpath/tools/giop/nameservice/PersistentMap.java b/tools/gnu/classpath/tools/giop/nameservice/PersistentMap.java
deleted file mode 100644
index 6939ede17..000000000
--- a/tools/gnu/classpath/tools/giop/nameservice/PersistentMap.java
+++ /dev/null
@@ -1,454 +0,0 @@
-/* PersistentMap.java -- The persistent object naming map
- Copyright (C) 2006 Free Software Foundation, Inc.
-
- This file is part of GNU Classpath.
-
- GNU Classpath is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- GNU Classpath is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNU Classpath; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301 USA.
-
- Linking this library statically or dynamically with other modules is
- making a combined work based on this library. Thus, the terms and
- conditions of the GNU General Public License cover the whole
- combination.
-
- As a special exception, the copyright holders of this library give you
- permission to link this library with independent modules to produce an
- executable, regardless of the license terms of these independent
- modules, and to copy and distribute the resulting executable under
- terms of your choice, provided that you also meet, for each linked
- independent module, the terms and conditions of the license of that
- module. An independent module is a module which is not derived from
- or based on this library. If you modify this library, you may extend
- this exception to your version of the library, but you are not
- obligated to do so. If you do not wish to do so, delete this
- exception statement from your version. */
-
-
-package gnu.classpath.tools.giop.nameservice;
-
-import gnu.CORBA.NamingService.NamingMap;
-
-import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.omg.CORBA.ORB;
-import org.omg.CosNaming.NameComponent;
-import org.omg.CosNaming.NamingContextPackage.AlreadyBound;
-import org.omg.CosNaming.NamingContextPackage.InvalidName;
-
-/**
- * The persistent object naming map for the persistent naming service. The
- * inherited (super.) naming map implementation is transient and is used as a
- * cache. During the normal work, the naming map does not read from the disk,
- * just stores the changes there. Map only reads from the disk when it starts.
- *
- * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
- */
-public class PersistentMap
- extends NamingMap
-{
- /**
- * The data entry.
- */
- public static class Entry
- {
- String id;
-
- String kind;
-
- String ior;
-
- /**
- * Get the name component node.
- */
- public NameComponent getComponent()
- {
- return new NameComponent(id, kind);
- }
-
- /**
- * Write the naming map entry to the output stream.
- */
- public void write(OutputStream out) throws IOException
- {
- // Format: id.kind ior
- out.write(getKey(id, kind).getBytes());
- out.write('\n');
- out.write(ior.getBytes());
- out.write('\n');
- out.close();
- }
-
- /**
- * Read the name component from the input stream
- */
- public boolean read(BufferedReader in) throws IOException
- {
- String key = in.readLine();
- String xior = in.readLine();
-
- if (key != null && xior != null)
- {
- if (key.length() < 2)
- {
- // A single char key cannot have the kind part.
- id = key;
- kind = "";
- }
- else
- {
- // Search for the id/kind splitter, dot:
- int iks = - 1;
- for (int i = 1; i < key.length(); i++)
- {
- if (key.charAt(i) == '.')
- // The id is separated from kind by dot, unless preceeded by
- // the
- // escape character, \.
- if (key.charAt(i - 1) != '\\')
- {
- iks = i;
- break;
- }
- }
-
- // May also end by dot, if the kind field is missing.
- if (iks < 0)
- {
- id = key;
- kind = "";
- }
- else if (iks == key.length() - 1)
- {
- id = key.substring(0, key.length() - 1);
- kind = "";
- }
- else
- {
- id = key.substring(0, iks);
- kind = key.substring(iks + 1);
- }
- }
- ior = xior;
- return true;
- }
- else
- return false;
- }
-
- /**
- * Get the key value from the name component.
- *
- * @param id the component id
- * @param kind the component kind
- * @return the key value
- */
- public String getKey(String id, String kind)
- {
- StringBuffer b = new StringBuffer(id.length() + 8);
- appEscaping(b, id);
- b.append('.');
- if (kind != null && kind.length() > 0)
- appEscaping(b, kind);
- return b.toString();
- }
-
- /**
- * Append the contents of the string to this string buffer, inserting the
- * escape sequences, where required.
- *
- * @param b a buffer to append the contents to.
- * @param s a string to append.
- */
- void appEscaping(StringBuffer b, String s)
- {
- char c;
- for (int i = 0; i < s.length(); i++)
- {
- c = s.charAt(i);
- switch (c)
- {
- case '.':
- case '/':
- case '\\':
- b.append('\\');
- b.append(c);
- break;
-
- default:
- b.append(c);
- break;
- }
- }
- }
- }
-
- /**
- * The file, where the persistent naming map stores the information. The
- * format of this file is n*(id LF kind LF ior LFLF).
- */
- public final File file;
-
- /**
- * The naming service ORB, used to obtain and produce the object stringified
- * references.
- */
- ORB orb;
-
- /**
- * If true, all existing data on the file system are discarded.
- */
- boolean reset;
-
- /**
- * Create the persistent map that stores information in the given file.
- *
- * @param an_orb the naming service ORB, used to obtain and produce the object
- * stringified references.
- * @param mapFile the file, where the persistent information is stored.
- * @param a_reset if true, the previous naming data are discarded. If false
- * (normally expected), they are loaded from the persistent memory to
- * provide the persistence.
- */
- public PersistentMap(ORB an_orb, File mapFile, boolean a_reset)
- {
- super();
- orb = an_orb;
- file = mapFile;
- reset = a_reset;
-
- // Initialise the persistent map with existing data.
- if (file.exists() && ! reset)
- {
-
- BufferedReader in;
- try
- {
- FileInputStream fin = new FileInputStream(file);
- in = new BufferedReader(new InputStreamReader(fin));
- Entry e = new Entry();
- boolean ok;
-
- while (e.read(in))
- {
- org.omg.CORBA .Object object = string_to_object(e.ior);
- orb.connect(object);
- map.put(e.getComponent(), object);
- }
- }
- catch (Exception ex)
- {
- InternalError ierr = new InternalError(file.getAbsolutePath());
- ierr.initCause(ex);
- throw ierr;
- }
- }
- }
-
- /**
- * Restore object from its string description.
- *
- * @param description the string, describing the object
- *
- * @return the object.
- */
- protected org.omg.CORBA.Object string_to_object(String description)
- {
- return orb.string_to_object(description);
- }
-
- /**
- * Convert the object to its string description
- *
- * @param object the object to convert
- * @return the string description of the object
- */
- protected String object_to_string(org.omg.CORBA .Object object)
- {
- return orb.object_to_string(object);
- }
-
- /**
- * Put the given GIOP object, specifying the given name as a key. If the entry
- * with the given name already exists, or if the given object is already
- * mapped under another name, the {@link AlreadyBound} exception will be
- * thrown.
- *
- * @param name the name
- * @param object the object
- */
- public void bind(NameComponent name, org.omg.CORBA.Object object)
- throws AlreadyBound, InvalidName
- {
- if (!containsKey(name))
- {
- super.bind(name, object);
- register(name, object);
- }
- else
- throw new AlreadyBound(name.id + "." + name.kind);
- }
-
- /**
- * Put the given CORBA object, specifying the given name as a key. Remove all
- * pre - existing mappings for the given name and object.
- *
- * @param name the name.
- * @param object the object
- */
- public void rebind(NameComponent name, org.omg.CORBA.Object object)
- throws InvalidName
- {
- if (containsKey(name))
- {
- org.omg.CORBA.Object existing = get(name);
- String ior = object_to_string(object);
- String xior = object_to_string(existing);
-
- // Same name and same ior - nothing to do.
- if (ior.equals(xior))
- return;
- else
- remove(name);
- }
-
- Iterator iter = entries().iterator();
- Map.Entry item;
-
- // Remove the existing mapping for the given object, if present.
- while (iter.hasNext())
- {
- item = (Map.Entry) iter.next();
- if (item.getValue().equals(object))
- iter.remove();
- }
-
- map.put(name, object);
- register(name, object);
- }
-
- /**
- * Removes the given name, if present.
- *
- * @param name a name to remove.
- */
- public void remove(NameComponent name)
- {
- super.remove(name);
- unregister(name);
- }
-
- /**
- * Register this name - object pair in the persistent storage.
- *
- * @param name the name.
- * @param object the object
- */
- public void register(NameComponent name, org.omg.CORBA.Object object)
- {
- // If this key is already known, and this is the same object,
- // then return without action.
- String ior = object_to_string(object);
-
- synchronized (file)
- {
- try
- {
- FileOutputStream fou;
-
- if (! file.exists())
- fou = new FileOutputStream(file);
- else
- fou = new FileOutputStream(file, true);
-
- Entry e = new Entry();
- e.id = name.id;
- e.kind = name.kind;
- e.ior = ior;
- e.write(fou);
- fou.close();
- }
- catch (Exception e)
- {
- InternalError ierr = new InternalError(file.getAbsolutePath());
- ierr.initCause(e);
- throw ierr;
- }
- }
- }
-
- /**
- * Remove this name from the persistent storage.
- *
- * @param name the name to remove
- */
- public void unregister(NameComponent name)
- {
- synchronized (file)
- {
- try
- {
- File nf = new File(file.getParent(), file.getName() + "_t");
- FileInputStream fin = new FileInputStream(file);
- FileOutputStream fou = new FileOutputStream(nf);
- BufferedOutputStream ou = new BufferedOutputStream(fou);
-
- BufferedReader in = new BufferedReader(new InputStreamReader(fin));
- String s;
- String nk = name.kind;
- if (nk == null)
- nk = "";
-
- Entry e = new Entry();
-
- while (e.read(in))
- {
- if (e.id.equals(name.id) && e.kind.equals(nk))
- {
- // Do nothing - skip.
- }
- else
- {
- e.write(ou);
- }
- }
-
- File deleteIt = new File(file.getParent(), file.getName() + "_d");
- if (deleteIt.exists())
- deleteIt.delete();
-
- if (! file.renameTo(deleteIt))
- throw new IOException(file.getAbsolutePath() + " rename failed");
-
- if (! nf.renameTo(file))
- throw new IOException(file.getAbsolutePath() + " rename failed");
- }
- catch (Exception e)
- {
- InternalError ierr = new InternalError(file.getAbsolutePath());
- ierr.initCause(e);
- throw ierr;
- }
- }
- }
-}
diff --git a/tools/gnu/classpath/tools/jar/Main.java b/tools/gnu/classpath/tools/jar/Main.java
index 8ea770bb6..34f637204 100644
--- a/tools/gnu/classpath/tools/jar/Main.java
+++ b/tools/gnu/classpath/tools/jar/Main.java
@@ -38,7 +38,7 @@
package gnu.classpath.tools.jar;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.FileArgumentCallback;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
diff --git a/tools/gnu/classpath/tools/jarsigner/Main.java b/tools/gnu/classpath/tools/jarsigner/Main.java
index b6b50e741..0cff2fd85 100644
--- a/tools/gnu/classpath/tools/jarsigner/Main.java
+++ b/tools/gnu/classpath/tools/jarsigner/Main.java
@@ -41,8 +41,8 @@ package gnu.classpath.tools.jarsigner;
import gnu.classpath.Configuration;
import gnu.classpath.SystemProperties;
import gnu.classpath.tools.common.CallbackUtil;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.common.ProviderUtil;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
import gnu.classpath.tools.getopt.FileArgumentCallback;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
diff --git a/tools/gnu/classpath/tools/javah/CniIncludePrinter.java b/tools/gnu/classpath/tools/javah/CniIncludePrinter.java
index 6561169bb..fb007b131 100644
--- a/tools/gnu/classpath/tools/javah/CniIncludePrinter.java
+++ b/tools/gnu/classpath/tools/javah/CniIncludePrinter.java
@@ -46,24 +46,35 @@ import java.io.PrintStream;
public class CniIncludePrinter
extends Printer
{
+ protected CniIncludePrinter(Main classpath, File outFile, boolean isDir,
+ boolean force)
+ {
+ super(classpath, outFile, isDir, force);
+ }
- protected CniIncludePrinter(Main classpath)
+ protected void writePreambleImpl(PrintStream ps)
{
- super(classpath);
+ // does nothing
}
- public void printClass(File outputDir, ClassWrapper klass) throws IOException
+ protected PrintStream getPrintStreamImpl(FileOutputStream fos,
+ ClassWrapper klass)
+ {
+ return new PrintStream(fos);
+ }
+
+ public void printClass(ClassWrapper klass) throws IOException
{
// Never write Object or Class. This is a hack, maybe
// the user would like to see what they look like...
if (klass.name.equals("java/lang/Object")
|| klass.name.equals("java/lang/Class"))
return;
- File klassFile = new File(outputDir, klass.name + ".h");
- klassFile.getParentFile().mkdirs();
- PrintStream ps = new PrintStream(new FileOutputStream(klassFile));
+ PrintStream ps = getPrintStream(klass.name + ".h", klass);
+ if (ps == null)
+ return;
+ ps.println();
klass.printFully(ps);
ps.close();
}
-
}
diff --git a/tools/gnu/classpath/tools/javah/CniStubPrinter.java b/tools/gnu/classpath/tools/javah/CniStubPrinter.java
index 9732e2941..d91f367c4 100644
--- a/tools/gnu/classpath/tools/javah/CniStubPrinter.java
+++ b/tools/gnu/classpath/tools/javah/CniStubPrinter.java
@@ -41,6 +41,7 @@ package gnu.classpath.tools.javah;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.PrintStream;
import java.lang.reflect.Modifier;
import java.util.Iterator;
@@ -50,10 +51,10 @@ import org.objectweb.asm.tree.MethodNode;
public class CniStubPrinter
extends Printer
{
-
- protected CniStubPrinter(Main classpath)
+ protected CniStubPrinter(Main classpath, File outFile, boolean isDir,
+ boolean force)
{
- super(classpath);
+ super(classpath, outFile, isDir, force);
}
private void printDecl(CniPrintStream out, String className, MethodNode method)
@@ -72,24 +73,34 @@ public class CniStubPrinter
out.print(")");
}
- public void printClass(File outputDir, ClassWrapper klass) throws IOException
+ protected void writePreambleImpl(PrintStream out)
{
- if (! klass.hasNativeMethod())
- return;
- File klassFile = new File(outputDir, klass.name + ".cc");
- klassFile.getParentFile().mkdirs();
- String className = klass.name.replaceAll("/", "::");
-
- CniPrintStream out = new CniPrintStream(new FileOutputStream(klassFile));
out.println("// This file is intended to give you a head start on implementing native");
out.println("// methods using CNI.");
out.println("// Be aware: running 'gcjh -stubs' once more for this class may");
out.println("// overwrite any edits you have made to this file.");
out.println();
-
- out.println("#include <" + klass.name + ".h>");
out.println("#include ");
out.println("#include ");
+ }
+
+ protected PrintStream getPrintStreamImpl(FileOutputStream fos,
+ ClassWrapper klass)
+ {
+ return new CniPrintStream(fos);
+ }
+
+ public void printClass(ClassWrapper klass) throws IOException
+ {
+ if (! klass.hasNativeMethod())
+ return;
+ String className = klass.name.replaceAll("/", "::");
+ CniPrintStream out = (CniPrintStream) getPrintStream(klass.name + ".cc",
+ klass);
+ if (out == null)
+ return;
+ out.println();
+ out.println("#include <" + klass.name + ".h>");
out.println();
Iterator i = klass.methods.iterator();
@@ -115,5 +126,4 @@ public class CniStubPrinter
}
out.close();
}
-
}
diff --git a/tools/gnu/classpath/tools/javah/FieldHelper.java b/tools/gnu/classpath/tools/javah/FieldHelper.java
index ecc82e3c1..a9385e04d 100644
--- a/tools/gnu/classpath/tools/javah/FieldHelper.java
+++ b/tools/gnu/classpath/tools/javah/FieldHelper.java
@@ -52,6 +52,8 @@ public class FieldHelper
out.print(" ");
if (Modifier.isStatic(field.access))
out.print("static ");
+ if (Modifier.isVolatile(field.access))
+ out.print("volatile ");
if ((field.value instanceof Integer) || (field.value instanceof Long))
out.print("const ");
out.print(Type.getType(field.desc));
diff --git a/tools/gnu/classpath/tools/javah/JniIncludePrinter.java b/tools/gnu/classpath/tools/javah/JniIncludePrinter.java
index c01634007..3d88650c1 100644
--- a/tools/gnu/classpath/tools/javah/JniIncludePrinter.java
+++ b/tools/gnu/classpath/tools/javah/JniIncludePrinter.java
@@ -41,6 +41,7 @@ package gnu.classpath.tools.javah;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.PrintStream;
import java.lang.reflect.Modifier;
import java.util.Iterator;
@@ -51,10 +52,10 @@ import org.objectweb.asm.tree.MethodNode;
public class JniIncludePrinter
extends Printer
{
-
- protected JniIncludePrinter(Main classpath)
+ protected JniIncludePrinter(Main classpath, File outFile, boolean isDir,
+ boolean force)
{
- super(classpath);
+ super(classpath, outFile, isDir, force);
}
private void writeFields(ClassWrapper klass, JniPrintStream out)
@@ -93,17 +94,27 @@ public class JniIncludePrinter
out.println();
}
- public void printClass(File outputDir, ClassWrapper klass) throws IOException
+ protected void writePreambleImpl(PrintStream out)
+ {
+ out.println("/* DO NOT EDIT THIS FILE - it is machine generated */");
+ out.println();
+ out.println("#include ");
+ }
+
+ protected PrintStream getPrintStreamImpl(FileOutputStream fos,
+ ClassWrapper klass)
+ {
+ return new JniPrintStream(classpath, fos, klass);
+ }
+
+ public void printClass(ClassWrapper klass) throws IOException
{
if (! klass.hasNativeMethod())
return;
String xname = JniHelper.mangle(klass.name);
- File outFile = new File(outputDir, xname + ".h");
-
- JniPrintStream out = new JniPrintStream(classpath,
- new FileOutputStream(outFile),
- klass);
- out.println("/* DO NOT EDIT THIS FILE - it is machine generated */");
+ JniPrintStream out = (JniPrintStream) getPrintStream(xname + ".h", klass);
+ if (out == null)
+ return;
out.println();
out.print("#ifndef __");
out.print(xname);
@@ -112,8 +123,6 @@ public class JniIncludePrinter
out.print(xname);
out.println("__");
out.println();
- out.println("#include ");
- out.println();
out.println("#ifdef __cplusplus");
out.println("extern \"C\"");
out.println("{");
@@ -144,8 +153,6 @@ public class JniIncludePrinter
out.print("#endif /* __");
out.print(xname);
out.println("__ */");
-
out.close();
}
-
}
diff --git a/tools/gnu/classpath/tools/javah/JniStubPrinter.java b/tools/gnu/classpath/tools/javah/JniStubPrinter.java
index d590a5cd1..0bc11873f 100644
--- a/tools/gnu/classpath/tools/javah/JniStubPrinter.java
+++ b/tools/gnu/classpath/tools/javah/JniStubPrinter.java
@@ -41,6 +41,7 @@ package gnu.classpath.tools.javah;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.PrintStream;
import java.lang.reflect.Modifier;
import java.util.Iterator;
@@ -50,26 +51,34 @@ import org.objectweb.asm.tree.MethodNode;
public class JniStubPrinter
extends Printer
{
+ protected JniStubPrinter(Main classpath, File outFile, boolean isDir,
+ boolean force)
+ {
+ super(classpath, outFile, isDir, force);
+ }
+
+ protected void writePreambleImpl(PrintStream out)
+ {
+ out.println("/* This file is intended to give you a head start on implementing native");
+ out.println(" methods using JNI.");
+ out.println(" Be aware: running gcjh or compatible tool with '-stubs' option once more");
+ out.println(" for the same input may overwrite any edits you have made to this file. */");
+ }
- protected JniStubPrinter(Main classpath)
+ protected PrintStream getPrintStreamImpl(FileOutputStream fos,
+ ClassWrapper klass)
{
- super(classpath);
+ return new JniPrintStream(classpath, fos, klass);
}
- public void printClass(File outputDir, ClassWrapper klass) throws IOException
+ public void printClass(ClassWrapper klass) throws IOException
{
if (! klass.hasNativeMethod())
return;
String xname = JniHelper.mangle(klass.name);
- File outFile = new File(outputDir, xname + ".c");
-
- JniPrintStream out = new JniPrintStream(classpath,
- new FileOutputStream(outFile),
- klass);
- out.println("/* This file is intended to give you a head start on implementing native");
- out.println(" methods using CNI.");
- out.println(" Be aware: running 'gcjh -stubs' once more for this class may");
- out.println(" overwrite any edits you have made to this file. */");
+ JniPrintStream out = (JniPrintStream) getPrintStream(xname + ".c", klass);
+ if (out == null)
+ return;
out.println();
out.print("#include <");
out.print(xname);
@@ -94,5 +103,4 @@ public class JniStubPrinter
}
out.close();
}
-
}
diff --git a/tools/gnu/classpath/tools/javah/Main.java b/tools/gnu/classpath/tools/javah/Main.java
index f342d4ae1..2cddbaae7 100644
--- a/tools/gnu/classpath/tools/javah/Main.java
+++ b/tools/gnu/classpath/tools/javah/Main.java
@@ -38,7 +38,7 @@
package gnu.classpath.tools.javah;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.Parser;
@@ -70,6 +70,9 @@ public class Main
// The output directory.
String outputDir;
+ // The output file name used if/when -o option is used.
+ String outFileName;
+
// The loader that we use to load class files.
URLClassLoader loader;
@@ -85,6 +88,9 @@ public class Main
// True if we're emitting CNI code.
boolean cni;
+ // True if output files should always be written.
+ boolean force;
+
// Map class names to class wrappers.
HashMap classMap = new HashMap();
@@ -184,9 +190,24 @@ public class Main
{
if (outputDir != null)
throw new OptionException("-d already seen");
+ if (outFileName != null)
+ throw new OptionException("only one of -d or -o may be used");
outputDir = dir;
}
});
+ result.add(new Option('o',
+ "Set output file (only one of -d or -o may be used)",
+ "FILE")
+ {
+ public void parsed(String fileName) throws OptionException
+ {
+ if (outFileName != null)
+ throw new OptionException("-o already seen");
+ if (outputDir != null)
+ throw new OptionException("only one of -d or -o may be used");
+ outFileName = fileName;
+ }
+ });
result.add(new Option("cmdfile", "Read command file", "FILE")
{
public void parsed(String file) throws OptionException
@@ -212,6 +233,15 @@ public class Main
stubs = true;
}
});
+ result.add(new Option("jni", "Emit JNI stubs or header (default)")
+ {
+ public void parsed(String arg0) throws OptionException
+ {
+ if (cni)
+ throw new OptionException("only one of -jni or -cni may be used");
+ cni = false;
+ }
+ });
result.add(new Option("cni", "Emit CNI stubs or header (default JNI)")
{
public void parsed(String arg0) throws OptionException
@@ -226,6 +256,13 @@ public class Main
verbose = true;
}
});
+ result.add(new Option("force", "Output files should always be written")
+ {
+ public void parsed(String arg0) throws OptionException
+ {
+ force = true;
+ }
+ });
return result;
}
@@ -235,15 +272,40 @@ public class Main
if (outputDir == null)
outputFile = new File(".");
else
+ outputFile = new File(outputDir);
+ return outputFile;
+ }
+
+ /**
+ * @return The {@link File} object where the generated code will be written.
+ * Returns null
if the option -force
was
+ * specified on the command line and the designated file already
+ * exists.
+ * @throws IOException if outFileName
is not a writable file.
+ */
+ private File makeOutputFile() throws IOException
+ {
+ File result = new File(outFileName);
+ if (result.exists())
{
- outputFile = new File(outputDir);
- outputFile.mkdirs();
+ if (! result.isFile())
+ throw new IOException("'" + outFileName + "' is not a file");
+ if (! force)
+ {
+ if (verbose)
+ System.err.println("["+ outFileName
+ + " already exists. Use -force to overwrite]");
+ return null;
+ }
+ if (! result.delete())
+ throw new IOException("Was unable to delete existing file: "
+ + outFileName);
}
- return outputFile;
+ return result;
}
- private void writeHeaders(ArrayList klasses, Printer printer,
- File outputDirFile) throws IOException
+ private void writeHeaders(ArrayList klasses, Printer printer)
+ throws IOException
{
Iterator i = klasses.iterator();
while (i.hasNext())
@@ -251,7 +313,7 @@ public class Main
ClassWrapper klass = (ClassWrapper) i.next();
if (verbose)
System.err.println("[writing " + klass + "]");
- printer.printClass(outputDirFile, klass);
+ printer.printClass(klass);
}
}
@@ -261,21 +323,25 @@ public class Main
String[] classNames = p.parse(args);
loader = classpath.getLoader();
- File outputFile = makeOutputDirectory();
+ boolean isDirectory = outFileName == null;
+ File outputFile = isDirectory ? makeOutputDirectory() : makeOutputFile();
+ if (outputFile == null)
+ return;
+
Printer printer;
if (! cni)
{
if (stubs)
- printer = new JniStubPrinter(this);
+ printer = new JniStubPrinter(this, outputFile, isDirectory, force);
else
- printer = new JniIncludePrinter(this);
+ printer = new JniIncludePrinter(this, outputFile, isDirectory, force);
}
else
{
if (stubs)
- printer = new CniStubPrinter(this);
+ printer = new CniStubPrinter(this, outputFile, isDirectory, force);
else
- printer = new CniIncludePrinter(this);
+ printer = new CniIncludePrinter(this, outputFile, isDirectory, force);
}
// First we load all of the files. That way if
@@ -324,7 +390,7 @@ public class Main
results.add(klass);
}
- writeHeaders(results, printer, outputFile);
+ writeHeaders(results, printer);
}
public ArrayList getClassTextList(String name)
diff --git a/tools/gnu/classpath/tools/javah/PathOptionGroup.java b/tools/gnu/classpath/tools/javah/PathOptionGroup.java
index f11077fa0..4287354ae 100644
--- a/tools/gnu/classpath/tools/javah/PathOptionGroup.java
+++ b/tools/gnu/classpath/tools/javah/PathOptionGroup.java
@@ -96,7 +96,7 @@ public class PathOptionGroup
setPath(classpath, path);
}
});
- add(new Option('I', "Add directory to class path", "DIR")
+ add(new Option('I', "Add directory to class path", "DIR", true)
{
public void parsed(String path) throws OptionException
{
diff --git a/tools/gnu/classpath/tools/javah/Printer.java b/tools/gnu/classpath/tools/javah/Printer.java
index 0c25934e2..9c4b48d2e 100644
--- a/tools/gnu/classpath/tools/javah/Printer.java
+++ b/tools/gnu/classpath/tools/javah/Printer.java
@@ -39,17 +39,100 @@
package gnu.classpath.tools.javah;
import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.PrintStream;
public abstract class Printer
{
protected Main classpath;
- protected Printer(Main classpath)
+ /**
+ * The {@link File} object that denotes either a directory (when the
+ * -d
option was used), or a file (when the -o
+ * option was used) on the command line.
+ */
+ protected File outputFileObject;
+
+ /**
+ * Set to true
if the field outputFileObject
denotes
+ * a directory; i.e. for each input class file, one JNI header file will be
+ * generated in that directory.
+ *
+ * Set to false
if the field outputFileObject
+ * denotes a file; i.e. all generated headers will be written to that file.
+ */
+ protected boolean isDirectory;
+
+ /**
+ * Set to true
if the output file(s) should always be written.
+ *
+ * When set to false
, the contents of the header/stub are only
+ * written to the file if it does not already exist.
+ */
+ protected boolean force;
+
+ /**
+ * Set to true
if all output is directed to one file, and the
+ * common preamble text has already been generated.
+ */
+ protected boolean wrotePreamble;
+
+ protected Printer(Main classpath, File outFile, boolean isDir, boolean force)
{
this.classpath = classpath;
+ if (outFile == null)
+ throw new IllegalArgumentException("File argument MUST NOT be null");
+ outputFileObject = outFile;
+ isDirectory = isDir;
+ if (! isDirectory)
+ {
+ File parent = outputFileObject.getParentFile();
+ if (parent != null)
+ parent.mkdirs();
+ }
+ this.force = force;
+ }
+
+ public abstract void printClass(ClassWrapper klass) throws IOException;
+
+ protected abstract void writePreambleImpl(PrintStream ps);
+
+ protected abstract PrintStream getPrintStreamImpl(FileOutputStream fos,
+ ClassWrapper klass);
+
+ protected PrintStream getPrintStream(String fullName, ClassWrapper klass)
+ throws FileNotFoundException
+ {
+ PrintStream result;
+ FileOutputStream fos;
+ if (isDirectory)
+ {
+ File outFile = new File(outputFileObject, fullName);
+ if (outFile.exists() && ! force)
+ return null;
+ File parent = outFile.getParentFile();
+ if (parent != null)
+ parent.mkdirs();
+ fos = new FileOutputStream(outFile);
+ result = getPrintStreamImpl(fos, klass);
+ writePreamble(result);
+ }
+ else
+ {
+ // the first time we open this file, wrotePreamble is false
+ fos = new FileOutputStream(outputFileObject, wrotePreamble);
+ result = getPrintStreamImpl(fos, klass);
+ if (! wrotePreamble)
+ writePreamble(result);
+ }
+ return result;
}
- public abstract void printClass(File outputDir, ClassWrapper klass)
- throws IOException;
+ protected void writePreamble(PrintStream out)
+ {
+ writePreambleImpl(out);
+ wrotePreamble = true;
+ }
}
diff --git a/tools/gnu/classpath/tools/keytool/CACertCmd.java b/tools/gnu/classpath/tools/keytool/CACertCmd.java
index 2bf832bee..a53a8b21a 100644
--- a/tools/gnu/classpath/tools/keytool/CACertCmd.java
+++ b/tools/gnu/classpath/tools/keytool/CACertCmd.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/keytool/CertReqCmd.java b/tools/gnu/classpath/tools/keytool/CertReqCmd.java
index 692b1f690..bdf3aac8f 100644
--- a/tools/gnu/classpath/tools/keytool/CertReqCmd.java
+++ b/tools/gnu/classpath/tools/keytool/CertReqCmd.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/keytool/DeleteCmd.java b/tools/gnu/classpath/tools/keytool/DeleteCmd.java
index 8107055d0..53611b21c 100644
--- a/tools/gnu/classpath/tools/keytool/DeleteCmd.java
+++ b/tools/gnu/classpath/tools/keytool/DeleteCmd.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/keytool/ExportCmd.java b/tools/gnu/classpath/tools/keytool/ExportCmd.java
index 75f71801c..a07edc631 100644
--- a/tools/gnu/classpath/tools/keytool/ExportCmd.java
+++ b/tools/gnu/classpath/tools/keytool/ExportCmd.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/keytool/GenKeyCmd.java b/tools/gnu/classpath/tools/keytool/GenKeyCmd.java
index e2048b223..79d3824af 100644
--- a/tools/gnu/classpath/tools/keytool/GenKeyCmd.java
+++ b/tools/gnu/classpath/tools/keytool/GenKeyCmd.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java b/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java
index d0de589d9..ac0ee1329 100644
--- a/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java
+++ b/tools/gnu/classpath/tools/keytool/IdentityDBCmd.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/keytool/ImportCmd.java b/tools/gnu/classpath/tools/keytool/ImportCmd.java
index 1eaf6b337..18a21aa68 100644
--- a/tools/gnu/classpath/tools/keytool/ImportCmd.java
+++ b/tools/gnu/classpath/tools/keytool/ImportCmd.java
@@ -40,7 +40,7 @@ package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
import gnu.classpath.SystemProperties;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java b/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java
index 81549864b..973ed46ce 100644
--- a/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java
+++ b/tools/gnu/classpath/tools/keytool/KeyCloneCmd.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java b/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java
index 89e6daa02..5f91becd9 100644
--- a/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java
+++ b/tools/gnu/classpath/tools/keytool/KeyPasswdCmd.java
@@ -40,7 +40,7 @@ package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
import gnu.classpath.SystemProperties;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/keytool/ListCmd.java b/tools/gnu/classpath/tools/keytool/ListCmd.java
index 61cec01a4..7579c3f85 100644
--- a/tools/gnu/classpath/tools/keytool/ListCmd.java
+++ b/tools/gnu/classpath/tools/keytool/ListCmd.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/keytool/Main.java b/tools/gnu/classpath/tools/keytool/Main.java
index 7c3ebd053..2d5234ad0 100644
--- a/tools/gnu/classpath/tools/keytool/Main.java
+++ b/tools/gnu/classpath/tools/keytool/Main.java
@@ -39,8 +39,8 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.common.ProviderUtil;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/keytool/PrintCertCmd.java b/tools/gnu/classpath/tools/keytool/PrintCertCmd.java
index 2c5461b36..2100a6026 100644
--- a/tools/gnu/classpath/tools/keytool/PrintCertCmd.java
+++ b/tools/gnu/classpath/tools/keytool/PrintCertCmd.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/keytool/SelfCertCmd.java b/tools/gnu/classpath/tools/keytool/SelfCertCmd.java
index 75f1e8299..f297046c7 100644
--- a/tools/gnu/classpath/tools/keytool/SelfCertCmd.java
+++ b/tools/gnu/classpath/tools/keytool/SelfCertCmd.java
@@ -39,7 +39,7 @@ exception statement from your version. */
package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java b/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java
index 1313ec6ab..489ecccb0 100644
--- a/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java
+++ b/tools/gnu/classpath/tools/keytool/StorePasswdCmd.java
@@ -40,7 +40,7 @@ package gnu.classpath.tools.keytool;
import gnu.classpath.Configuration;
import gnu.classpath.SystemProperties;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
import gnu.classpath.tools.getopt.OptionGroup;
diff --git a/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java b/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java
index 9508c103e..622de6056 100644
--- a/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java
+++ b/tools/gnu/classpath/tools/native2ascii/Native2ASCII.java
@@ -38,7 +38,7 @@
package gnu.classpath.tools.native2ascii;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.FileArgumentCallback;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
diff --git a/tools/gnu/classpath/tools/orbd/Main.java b/tools/gnu/classpath/tools/orbd/Main.java
new file mode 100644
index 000000000..91c50d7f8
--- /dev/null
+++ b/tools/gnu/classpath/tools/orbd/Main.java
@@ -0,0 +1,228 @@
+/* NamingServicePersistent.java -- The persistent naming service.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.orbd;
+
+import gnu.CORBA.OrbFunctional;
+import gnu.CORBA.IOR;
+import gnu.CORBA.NamingService.Ext;
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.FileArgumentCallback;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+
+import org.omg.CosNaming.NamingContextExt;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileNotFoundException;
+import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * The server for the GNU Classpath persistent naming service.
+ *
+ * GNU Classpath currently works with this naming service and is also
+ * interoperable with the Sun Microsystems naming services from releases 1.3 and
+ * 1.4, both transient tnameserv and persistent orbd.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class Main
+{
+ /**
+ * The default port (900), on that the naming service starts if no
+ * -ORBInitialPort is specified in the command line.
+ */
+ public static final int PORT = 900;
+
+ private int port = PORT;
+ private String iorf;
+ private boolean cold;
+ private String directory = "";
+
+ /**
+ * Get the object key for the naming service. The default key is the string
+ * "NameService" in ASCII.
+ *
+ * @return the byte array.
+ */
+ public static byte[] getDefaultKey()
+ {
+ try
+ { // NameService
+ return "NameService".getBytes("UTF-8");
+ }
+ catch (UnsupportedEncodingException ex)
+ {
+ throw new InternalError("UTF-8 unsupported");
+ }
+ }
+
+ private Parser initializeParser()
+ {
+ Parser parser = new ClasspathToolParser("orbd", true); //$NON-NLS-1$
+ parser.setHeader(Messages.getString("Main.Usage")); //$NON-NLS-1$
+
+ parser.add(new Option("ORBInitialPort", //$NON-NLS-1$
+ Messages.getString("Main.ORBInitialPort"), //$NON-NLS-1$
+ Messages.getString("Main.Port")) //$NON-NLS-1$
+ {
+ public void parsed(String portArgument) throws OptionException
+ {
+ port = Integer.parseInt(portArgument);
+ }
+ });
+
+ parser.add(new Option("ior", //$NON-NLS-1$
+ Messages.getString("Main.IOR"), //$NON-NLS-1$
+ Messages.getString("Main.IORFile")) //$NON-NLS-1$
+ {
+ public void parsed(String fileArgument) throws OptionException
+ {
+ iorf = fileArgument;
+ }
+ });
+ parser.add(new Option("directory", //$NON-NLS-1$
+ Messages.getString("Main.Directory"), //$NON-NLS-1$
+ Messages.getString("Main.DirectoryArgument")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ directory = argument;
+ }
+ });
+ parser.add(new Option("restart", //$NON-NLS-1$
+ Messages.getString("Main.Restart")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ cold = true;
+ }
+ });
+
+ return parser;
+ }
+
+ private void run(String[] args)
+ {
+ Parser parser = initializeParser();
+ parser.parse(args);
+
+ try
+ {
+ // Create and initialize the ORB
+ final OrbFunctional orb = new OrbFunctional();
+ OrbFunctional.setPort(port);
+
+ // Create the servant and register it with the ORB
+ File dataDirectory = new File(directory);
+ System.out.println("Persistent data stored at "
+ + dataDirectory.getAbsolutePath());
+ dataDirectory.mkdirs();
+
+ // / TODO support more starting modes.
+ NamingContextExt namer = new Ext(
+ new PersistentContext(
+ orb,
+ dataDirectory,
+ cold));
+
+ // Case with the key "NameService".
+ orb.connect(namer, "NameService".getBytes());
+
+ // Storing the IOR reference.
+ String ior = orb.object_to_string(namer);
+ IOR iorr = IOR.parse(ior);
+ if (iorf != null)
+ {
+ FileOutputStream f = new FileOutputStream(iorf);
+ PrintStream p = new PrintStream(f);
+ p.print(ior);
+ p.close();
+ }
+
+ System.out.println("GNU Classpath persistent naming service "
+ + "started at " + iorr.Internet.host + ":"
+ + iorr.Internet.port + " key 'NameService'.\n\n"
+ + "Copyright (C) 2006 Free Software Foundation\n"
+ + "This tool comes with ABSOLUTELY NO WARRANTY. "
+ + "This is free software, and you are\nwelcome to "
+ + "redistribute it under conditions, defined in "
+ + "GNU Classpath license.\n\n" + ior);
+
+ new Thread()
+ {
+ public void run()
+ {
+ // Wait for invocations from clients.
+ orb.run();
+ }
+ }.start();
+ }
+ catch (FileNotFoundException e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ // Restore the default value for allocating ports for the subsequent
+ // objects.
+ OrbFunctional.setPort(OrbFunctional.DEFAULT_INITIAL_PORT);
+ }
+ }
+
+ /**
+ * The persistent naming service entry point.
+ */
+ public static void main(String[] args)
+ {
+ Main orbdprogram = new Main();
+ try
+ {
+ orbdprogram.run(args);
+ }
+ catch (Exception e)
+ {
+ System.err.println(Messages.getString("Main.InternalError")); //$NON-NLS-1$
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+ }
+}
diff --git a/tools/gnu/classpath/tools/orbd/Messages.java b/tools/gnu/classpath/tools/orbd/Messages.java
new file mode 100644
index 000000000..c9bb371ad
--- /dev/null
+++ b/tools/gnu/classpath/tools/orbd/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- localization support for orbd
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.orbd;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+ private static final String BUNDLE_NAME
+ = "gnu.classpath.tools.orbd.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE
+ = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages()
+ {
+ }
+
+ public static String getString(String key)
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString(key);
+ }
+ catch (MissingResourceException e)
+ {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/tools/gnu/classpath/tools/orbd/PersistentContext.java b/tools/gnu/classpath/tools/orbd/PersistentContext.java
new file mode 100644
index 000000000..9b4f27a3d
--- /dev/null
+++ b/tools/gnu/classpath/tools/orbd/PersistentContext.java
@@ -0,0 +1,152 @@
+/* PersistentContext.java -- The persistent naming context.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.orbd;
+
+import gnu.CORBA.NamingService.NameTransformer;
+import gnu.CORBA.NamingService.TransientContext;
+
+import java.io.File;
+
+import org.omg.CORBA.ORB;
+import org.omg.CosNaming.NameComponent;
+import org.omg.CosNaming.NamingContext;
+import org.omg.CosNaming.NamingContextPackage.AlreadyBound;
+import org.omg.CosNaming.NamingContextPackage.CannotProceed;
+import org.omg.CosNaming.NamingContextPackage.InvalidName;
+import org.omg.CosNaming.NamingContextPackage.NotFound;
+
+/**
+ * This class implements the persistent naming service, defined by
+ * {@link NamingContext}. The 'persistent' means that the service remembers the
+ * mappings, stored between restarts.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class PersistentContext
+ extends TransientContext
+{
+ /**
+ * Use serial version UID for interoperability.
+ */
+ private static final long serialVersionUID = 2;
+
+ /**
+ * The folder, where the persistent context information is stored.
+ */
+ File contextFolder;
+
+ /**
+ * The uinque context identifier.
+ */
+ static long num = System.currentTimeMillis();
+
+ /**
+ * The naming service orb.
+ */
+ ORB orb;
+
+ /**
+ * Create the persistent naming context that will store the files in the given
+ * folder of the local file system. This method also connects object to the
+ * passed ORB.
+ *
+ * @param an_orb the naming service ORB, used to obtain and produce the object
+ * stringified references.
+ * @param folder the folder, where the persistent information is stored.
+ * @param reset if true, the previous naming data are discarded. If false
+ * (normally expected), they are loaded from the persistent memory to
+ * provide the persistence.
+ */
+ public PersistentContext(ORB an_orb, File folder, boolean reset)
+ {
+ super(
+ new PersistentContextMap(an_orb, new File(folder, "contexts.txt"), reset),
+ new PersistentMap(an_orb, new File(folder, "objects.txt"), reset));
+ contextFolder = folder;
+ folder.mkdirs();
+ orb = an_orb;
+ orb.connect(this);
+ }
+
+ /**
+ * Get the unique context number;
+ *
+ * @return the context number
+ */
+ static synchronized String getNum()
+ {
+ return Long.toHexString(num++);
+ }
+
+ /**
+ * Create new persistent context.
+ */
+ public NamingContext new_context()
+ {
+ File ctxFolder = new File(contextFolder, "ctx_"+getNum());
+ return new PersistentContext(orb, ctxFolder, true);
+ }
+
+ /**
+ * Create a new context and give it a given name (bound it) in the current
+ * context. The method benefits from passing the better readable context name.
+ *
+ * @param a_name the name being given to the new context.
+ * @return the newly created context.
+ * @throws AlreadyBound if the name is already in use.
+ * @throws InvalidName if the name has zero length or otherwise invalid.
+ */
+ public NamingContext bind_new_context(NameComponent[] a_name)
+ throws NotFound, AlreadyBound, CannotProceed, InvalidName
+ {
+ if (named_contexts.containsKey(a_name[0])
+ || named_objects.containsKey(a_name[0]))
+ throw new AlreadyBound();
+
+ NameTransformer transformer = new NameTransformer();
+
+ File ctxFolder = new File(contextFolder,
+ transformer.toString(a_name).replace('/', '.')
+ + ".v" + getNum());
+
+ NamingContext child = new PersistentContext(orb, ctxFolder, true);
+ bind_context(a_name, child);
+ return child;
+ }
+}
diff --git a/tools/gnu/classpath/tools/orbd/PersistentContextMap.java b/tools/gnu/classpath/tools/orbd/PersistentContextMap.java
new file mode 100644
index 000000000..e983ef30f
--- /dev/null
+++ b/tools/gnu/classpath/tools/orbd/PersistentContextMap.java
@@ -0,0 +1,87 @@
+/* PersistentContextMap.java -- The persistent context naming map
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.orbd;
+
+import java.io.File;
+
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.Object;
+
+/**
+ * The persistent context naming map for the persistent naming service.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class PersistentContextMap extends PersistentMap
+{
+ /**
+ * Create the persistent context map that stores information in the given
+ * file.
+ *
+ * @param an_orb the naming service ORB, used to obtain and produce the object
+ * stringified references.
+ * @param mapFile the file, where the persistent information is stored.
+ * @param reset if true, the previous naming data are discarded. If false
+ * (normally expected), they are loaded from the persistent memory to
+ * provide the persistence.
+ */
+ public PersistentContextMap(ORB an_orb, File mapFile, boolean reset)
+ {
+ super(an_orb, mapFile, reset);
+ }
+
+ /**
+ * This method expects the PersistentContext as its parameter. The returned
+ * description line is the name of the context parent folder.
+ */
+ protected String object_to_string(Object object)
+ {
+ PersistentContext pc = (PersistentContext) object;
+ return pc.contextFolder.getAbsolutePath();
+ }
+
+ /**
+ * This method restores the PersistenContext. The description line is
+ * interpreted as the folder name, absolute path.
+ */
+ protected Object string_to_object(String description)
+ {
+ return new PersistentContext(orb, new File(description), reset);
+ }
+}
diff --git a/tools/gnu/classpath/tools/orbd/PersistentMap.java b/tools/gnu/classpath/tools/orbd/PersistentMap.java
new file mode 100644
index 000000000..6c6164d21
--- /dev/null
+++ b/tools/gnu/classpath/tools/orbd/PersistentMap.java
@@ -0,0 +1,454 @@
+/* PersistentMap.java -- The persistent object naming map
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.orbd;
+
+import gnu.CORBA.NamingService.NamingMap;
+
+import java.io.BufferedOutputStream;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.omg.CORBA.ORB;
+import org.omg.CosNaming.NameComponent;
+import org.omg.CosNaming.NamingContextPackage.AlreadyBound;
+import org.omg.CosNaming.NamingContextPackage.InvalidName;
+
+/**
+ * The persistent object naming map for the persistent naming service. The
+ * inherited (super.) naming map implementation is transient and is used as a
+ * cache. During the normal work, the naming map does not read from the disk,
+ * just stores the changes there. Map only reads from the disk when it starts.
+ *
+ * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org)
+ */
+public class PersistentMap
+ extends NamingMap
+{
+ /**
+ * The data entry.
+ */
+ public static class Entry
+ {
+ String id;
+
+ String kind;
+
+ String ior;
+
+ /**
+ * Get the name component node.
+ */
+ public NameComponent getComponent()
+ {
+ return new NameComponent(id, kind);
+ }
+
+ /**
+ * Write the naming map entry to the output stream.
+ */
+ public void write(OutputStream out) throws IOException
+ {
+ // Format: id.kind ior
+ out.write(getKey(id, kind).getBytes());
+ out.write('\n');
+ out.write(ior.getBytes());
+ out.write('\n');
+ out.close();
+ }
+
+ /**
+ * Read the name component from the input stream
+ */
+ public boolean read(BufferedReader in) throws IOException
+ {
+ String key = in.readLine();
+ String xior = in.readLine();
+
+ if (key != null && xior != null)
+ {
+ if (key.length() < 2)
+ {
+ // A single char key cannot have the kind part.
+ id = key;
+ kind = "";
+ }
+ else
+ {
+ // Search for the id/kind splitter, dot:
+ int iks = - 1;
+ for (int i = 1; i < key.length(); i++)
+ {
+ if (key.charAt(i) == '.')
+ // The id is separated from kind by dot, unless preceeded by
+ // the
+ // escape character, \.
+ if (key.charAt(i - 1) != '\\')
+ {
+ iks = i;
+ break;
+ }
+ }
+
+ // May also end by dot, if the kind field is missing.
+ if (iks < 0)
+ {
+ id = key;
+ kind = "";
+ }
+ else if (iks == key.length() - 1)
+ {
+ id = key.substring(0, key.length() - 1);
+ kind = "";
+ }
+ else
+ {
+ id = key.substring(0, iks);
+ kind = key.substring(iks + 1);
+ }
+ }
+ ior = xior;
+ return true;
+ }
+ else
+ return false;
+ }
+
+ /**
+ * Get the key value from the name component.
+ *
+ * @param id the component id
+ * @param kind the component kind
+ * @return the key value
+ */
+ public String getKey(String id, String kind)
+ {
+ StringBuffer b = new StringBuffer(id.length() + 8);
+ appEscaping(b, id);
+ b.append('.');
+ if (kind != null && kind.length() > 0)
+ appEscaping(b, kind);
+ return b.toString();
+ }
+
+ /**
+ * Append the contents of the string to this string buffer, inserting the
+ * escape sequences, where required.
+ *
+ * @param b a buffer to append the contents to.
+ * @param s a string to append.
+ */
+ void appEscaping(StringBuffer b, String s)
+ {
+ char c;
+ for (int i = 0; i < s.length(); i++)
+ {
+ c = s.charAt(i);
+ switch (c)
+ {
+ case '.':
+ case '/':
+ case '\\':
+ b.append('\\');
+ b.append(c);
+ break;
+
+ default:
+ b.append(c);
+ break;
+ }
+ }
+ }
+ }
+
+ /**
+ * The file, where the persistent naming map stores the information. The
+ * format of this file is n*(id LF kind LF ior LFLF).
+ */
+ public final File file;
+
+ /**
+ * The naming service ORB, used to obtain and produce the object stringified
+ * references.
+ */
+ ORB orb;
+
+ /**
+ * If true, all existing data on the file system are discarded.
+ */
+ boolean reset;
+
+ /**
+ * Create the persistent map that stores information in the given file.
+ *
+ * @param an_orb the naming service ORB, used to obtain and produce the object
+ * stringified references.
+ * @param mapFile the file, where the persistent information is stored.
+ * @param a_reset if true, the previous naming data are discarded. If false
+ * (normally expected), they are loaded from the persistent memory to
+ * provide the persistence.
+ */
+ public PersistentMap(ORB an_orb, File mapFile, boolean a_reset)
+ {
+ super();
+ orb = an_orb;
+ file = mapFile;
+ reset = a_reset;
+
+ // Initialise the persistent map with existing data.
+ if (file.exists() && ! reset)
+ {
+
+ BufferedReader in;
+ try
+ {
+ FileInputStream fin = new FileInputStream(file);
+ in = new BufferedReader(new InputStreamReader(fin));
+ Entry e = new Entry();
+ boolean ok;
+
+ while (e.read(in))
+ {
+ org.omg.CORBA .Object object = string_to_object(e.ior);
+ orb.connect(object);
+ map.put(e.getComponent(), object);
+ }
+ }
+ catch (Exception ex)
+ {
+ InternalError ierr = new InternalError(file.getAbsolutePath());
+ ierr.initCause(ex);
+ throw ierr;
+ }
+ }
+ }
+
+ /**
+ * Restore object from its string description.
+ *
+ * @param description the string, describing the object
+ *
+ * @return the object.
+ */
+ protected org.omg.CORBA.Object string_to_object(String description)
+ {
+ return orb.string_to_object(description);
+ }
+
+ /**
+ * Convert the object to its string description
+ *
+ * @param object the object to convert
+ * @return the string description of the object
+ */
+ protected String object_to_string(org.omg.CORBA .Object object)
+ {
+ return orb.object_to_string(object);
+ }
+
+ /**
+ * Put the given GIOP object, specifying the given name as a key. If the entry
+ * with the given name already exists, or if the given object is already
+ * mapped under another name, the {@link AlreadyBound} exception will be
+ * thrown.
+ *
+ * @param name the name
+ * @param object the object
+ */
+ public void bind(NameComponent name, org.omg.CORBA.Object object)
+ throws AlreadyBound, InvalidName
+ {
+ if (!containsKey(name))
+ {
+ super.bind(name, object);
+ register(name, object);
+ }
+ else
+ throw new AlreadyBound(name.id + "." + name.kind);
+ }
+
+ /**
+ * Put the given CORBA object, specifying the given name as a key. Remove all
+ * pre - existing mappings for the given name and object.
+ *
+ * @param name the name.
+ * @param object the object
+ */
+ public void rebind(NameComponent name, org.omg.CORBA.Object object)
+ throws InvalidName
+ {
+ if (containsKey(name))
+ {
+ org.omg.CORBA.Object existing = get(name);
+ String ior = object_to_string(object);
+ String xior = object_to_string(existing);
+
+ // Same name and same ior - nothing to do.
+ if (ior.equals(xior))
+ return;
+ else
+ remove(name);
+ }
+
+ Iterator iter = entries().iterator();
+ Map.Entry item;
+
+ // Remove the existing mapping for the given object, if present.
+ while (iter.hasNext())
+ {
+ item = (Map.Entry) iter.next();
+ if (item.getValue().equals(object))
+ iter.remove();
+ }
+
+ map.put(name, object);
+ register(name, object);
+ }
+
+ /**
+ * Removes the given name, if present.
+ *
+ * @param name a name to remove.
+ */
+ public void remove(NameComponent name)
+ {
+ super.remove(name);
+ unregister(name);
+ }
+
+ /**
+ * Register this name - object pair in the persistent storage.
+ *
+ * @param name the name.
+ * @param object the object
+ */
+ public void register(NameComponent name, org.omg.CORBA.Object object)
+ {
+ // If this key is already known, and this is the same object,
+ // then return without action.
+ String ior = object_to_string(object);
+
+ synchronized (file)
+ {
+ try
+ {
+ FileOutputStream fou;
+
+ if (! file.exists())
+ fou = new FileOutputStream(file);
+ else
+ fou = new FileOutputStream(file, true);
+
+ Entry e = new Entry();
+ e.id = name.id;
+ e.kind = name.kind;
+ e.ior = ior;
+ e.write(fou);
+ fou.close();
+ }
+ catch (Exception e)
+ {
+ InternalError ierr = new InternalError(file.getAbsolutePath());
+ ierr.initCause(e);
+ throw ierr;
+ }
+ }
+ }
+
+ /**
+ * Remove this name from the persistent storage.
+ *
+ * @param name the name to remove
+ */
+ public void unregister(NameComponent name)
+ {
+ synchronized (file)
+ {
+ try
+ {
+ File nf = new File(file.getParent(), file.getName() + "_t");
+ FileInputStream fin = new FileInputStream(file);
+ FileOutputStream fou = new FileOutputStream(nf);
+ BufferedOutputStream ou = new BufferedOutputStream(fou);
+
+ BufferedReader in = new BufferedReader(new InputStreamReader(fin));
+ String s;
+ String nk = name.kind;
+ if (nk == null)
+ nk = "";
+
+ Entry e = new Entry();
+
+ while (e.read(in))
+ {
+ if (e.id.equals(name.id) && e.kind.equals(nk))
+ {
+ // Do nothing - skip.
+ }
+ else
+ {
+ e.write(ou);
+ }
+ }
+
+ File deleteIt = new File(file.getParent(), file.getName() + "_d");
+ if (deleteIt.exists())
+ deleteIt.delete();
+
+ if (! file.renameTo(deleteIt))
+ throw new IOException(file.getAbsolutePath() + " rename failed");
+
+ if (! nf.renameTo(file))
+ throw new IOException(file.getAbsolutePath() + " rename failed");
+ }
+ catch (Exception e)
+ {
+ InternalError ierr = new InternalError(file.getAbsolutePath());
+ ierr.initCause(e);
+ throw ierr;
+ }
+ }
+ }
+}
diff --git a/tools/gnu/classpath/tools/rmi/Persistent.java b/tools/gnu/classpath/tools/rmi/Persistent.java
deleted file mode 100644
index 5cd1efe91..000000000
--- a/tools/gnu/classpath/tools/rmi/Persistent.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/* PersistentBidiHasthable.java -- Constants for the persistent tables.
- Copyright (C) 2006 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath.tools.rmi;
-
-import java.util.Timer;
-import java.util.TimerTask;
-
-/**
- * The static fields, shared by the multiple classes, implementing the
- * persistent work.
- *
- * @author Audrius Meskauskas (audriusa@bioinformatics.org)
- */
-public interface Persistent
-{
- /**
- * Sheduled termination task.
- */
- static class ExitTask extends TimerTask
- {
- public void run()
- {
- System.exit(0);
- }
- }
-
- /**
- * The timer, sheduling all disk database update events, shared by all
- * instances.
- */
- static Timer timer = new Timer(true);
-
- /**
- * The longest time, in ms, after that the database content on the disk must
- * be updated. The algorithm is written to avoid the very frequent writings to
- * the disk.
- */
- static long SAVE_AT_MOST_AFTER = 5000;
-
- /**
- * States how long the database may stay not updated during the intensive
- * operations, in ms. Otherwise the intensively used structure may never
- * be stored to the disk.
- */
- static long ALWAYS_UPDATE = 300000;
-
- /**
- * Write the database content to the disk.
- */
- void writeContent();
-
-}
diff --git a/tools/gnu/classpath/tools/rmi/PersistentBidiHashTable.java b/tools/gnu/classpath/tools/rmi/PersistentBidiHashTable.java
deleted file mode 100644
index 94b5bcbee..000000000
--- a/tools/gnu/classpath/tools/rmi/PersistentBidiHashTable.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/* PersistentBidiHasthable.java -- Bidirectional persistent hash table.
- Copyright (C) 2006 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath.tools.rmi;
-
-import gnu.classpath.tools.rmi.rmid.ActivationSystemImpl;
-import gnu.java.rmi.activation.BidiTable;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TimerTask;
-
-/**
- * The persistent bidirectional hash table, maps both a to b and b to a. The
- * changes are written to dist after SAVE_AT_MOST_AFTER time from the latest
- * database change or at most after ALWAYS_UPDATE, if the database is updated
- * very frequently. To ensure that no information is lost, the shutdown method
- * must be called before exit.
- *
- * @author Audrius Meskauskas (audriusa@bioinformatics.org)
- */
-public class PersistentBidiHashTable extends BidiTable implements
- Persistent
-{
- class WriteToDiskTask extends TimerTask
- {
- /**
- * Save the database.
- */
- public void run()
- {
- writeContent();
- sheduled = null;
- }
- }
-
- /**
- * Replaces instances of ActivationSystemImpl into the currently active
- * instance of the ActivationSystemImpl
- */
- class AdaptedReader extends ObjectInputStream
- {
- AdaptedReader(InputStream in) throws IOException
- {
- super(in);
- enableResolveObject(true);
- }
-
- protected Object resolveObject(Object obj) throws IOException
- {
- if (obj instanceof ActivationSystemImpl)
- return ActivationSystemImpl.singleton2;
- else
- return obj;
- }
- }
-
- /**
- * The database file.
- */
- File database;
-
- /**
- * The currently sheduled write to disk task, null if none.
- */
- WriteToDiskTask sheduled = null;
-
- /**
- * The time, when the disk database was last updated.
- */
- long lastUpdated;
-
- /**
- * Create the unitialised instance that must be initalised when
- * ActivationSystemImpl.singleton2 is assigned.
- */
- public PersistentBidiHashTable()
- {
- // Do not initalise the table fields - the initalise method must be
- // called later.
- super(0);
- }
-
- /**
- * Create a new persistent table that stores its information into the given
- * file. The ActivationSystemImpl.singleton2 must be assigned.
- *
- * @param file
- * the file, where the table stores its information.
- * @param coldStart
- * if true, the existing file with this name will be erased and
- * ignored. Otherwise, it will be assumed that the file contains the
- * persistent table information.
- */
- public void init(File file, boolean coldStart)
- {
- try
- {
- database = file;
- if (database.exists())
- {
- if (coldStart)
- {
- k2v = new Hashtable();
- v2k = new Hashtable();
- database.delete();
- }
- else
- {
- FileInputStream fi = new FileInputStream(file);
- BufferedInputStream b = new BufferedInputStream(fi);
- ObjectInputStream oin = new AdaptedReader(b);
-
- k2v = (Map) oin.readObject();
- oin.close();
-
- v2k = new Hashtable(k2v.size());
-
- // Reguild v2k from k2v:
- Iterator en = k2v.keySet().iterator();
- Object key;
- while (en.hasNext())
- {
- key = en.next();
- v2k.put(k2v.get(key), key);
- }
- }
- }
- else
- {
- k2v = new Hashtable();
- v2k = new Hashtable();
- }
- }
- catch (Exception ioex)
- {
- InternalError ierr = new InternalError("Unable to intialize with file "
- + file);
- ierr.initCause(ioex);
- throw ierr;
- }
- }
-
- /**
- * Write the database content to the disk.
- */
- public synchronized void writeContent()
- {
- try
- {
- FileOutputStream fou = new FileOutputStream(database);
- BufferedOutputStream b = new BufferedOutputStream(fou);
- ObjectOutputStream oout = new ObjectOutputStream(b);
- oout.writeObject(k2v);
- oout.close();
- }
- catch (Exception ioex)
- {
- InternalError ierr = new InternalError(
- "Failed to write database to disk: "
- + database);
- ierr.initCause(ioex);
- throw ierr;
- }
- }
-
- /**
- * Mark the modified database as modified. The database will be written after
- * several seconds, unless another modification occurs.
- */
- public void markDirty()
- {
- if (System.currentTimeMillis() - lastUpdated > ALWAYS_UPDATE)
- {
- // Force storing to disk under intensive operation.
- writeContent();
- lastUpdated = System.currentTimeMillis();
- if (sheduled != null)
- {
- sheduled.cancel();
- sheduled = null;
- }
- }
- else
- {
- // Otherwise coalesce the disk database copy update events.
- if (sheduled != null)
- sheduled.cancel();
- sheduled = new WriteToDiskTask();
- timer.schedule(sheduled, SAVE_AT_MOST_AFTER);
- }
- }
-
- /**
- * Save the current database state to the disk before exit.
- */
- public void shutdown()
- {
- if (sheduled != null)
- {
- writeContent();
- sheduled = null;
- }
- }
-
- /**
- * Update the memory maps and mark as should be written to the disk.
- */
- public void put(Object key, Object value)
- {
- super.put(key, value);
- markDirty();
- }
-
- /**
- * Update the memory maps and mark as should be written to the disk.
- */
- public void removeKey(Object key)
- {
- super.removeKey(key);
- markDirty();
- }
-
-}
diff --git a/tools/gnu/classpath/tools/rmi/PersistentHashTable.java b/tools/gnu/classpath/tools/rmi/PersistentHashTable.java
deleted file mode 100644
index 925e829ff..000000000
--- a/tools/gnu/classpath/tools/rmi/PersistentHashTable.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/* PersistentHasthable.java -- Persistent hash table.
- Copyright (C) 2006 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath.tools.rmi;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.TimerTask;
-
-/**
- * The persistent hash table. The changes are written to dist after
- * SAVE_AT_MOST_AFTER time from the latest database change or at most after
- * ALWAYS_UPDATE, if the database is updated very frequently. To ensure that no
- * information is lost, the shutdown method must be called before exit.
- *
- * @author Audrius Meskauskas (audriusa@bioinformatics.org)
- */
-public class PersistentHashTable
- extends Hashtable
- implements Serializable, Persistent
-{
-
- /**
- * Use serialVersionUID for interoperability
- */
- private static final long serialVersionUID = 1;
-
- class WriteToDiskTask extends TimerTask
- {
- /**
- * Save the database.
- */
- public void run()
- {
- writeContent();
- sheduled = null;
- }
- }
-
- /**
- * The database file.
- */
- File database;
-
- /**
- * The currently sheduled write to disk task, null if none.
- */
- WriteToDiskTask sheduled = null;
-
- /**
- * The time, when the disk database was last updated.
- */
- long lastUpdated;
-
- /**
- * Setting to false prevents the automated disk update.
- * The initial value is true to prevent writing while reading and is set
- * to false in createInstance.
- */
- transient boolean ready;
-
- /**
- * Use static method to obtain the instance.
- */
- private PersistentHashTable(File file)
- {
- if (file == null)
- throw new NullPointerException("Null file provided");
- database = file;
- }
-
- /**
- * Create a new persistent table that stores its information into the given
- * file.
- *
- * @param file
- * the file, where the table stores its information.
- * @param coldStart
- * if true, the existing file with this name will be erased and
- * ignored. Otherwise, it will be assumed that the file contains the
- * persistent table information.
- */
- public static Map createInstance(File file, boolean coldStart)
- {
- try
- {
- PersistentHashTable k2v;
- if (file.exists())
- {
- if (coldStart)
- {
- file.delete();
- k2v = new PersistentHashTable(file);
- }
- else
- {
- FileInputStream fi = new FileInputStream(file);
- BufferedInputStream b = new BufferedInputStream(fi);
- ObjectInputStream oin = new ObjectInputStream(b);
-
- k2v = (PersistentHashTable) oin.readObject();
- oin.close();
- }
- }
- else
- k2v = new PersistentHashTable(file);
-
- k2v.ready = true;
- return k2v;
- }
- catch (Exception ioex)
- {
- InternalError ierr = new InternalError("Unable to intialize with file "
- + file);
- ierr.initCause(ioex);
- throw ierr;
- }
- }
-
-
- /**
- * Write the database content to the disk.
- */
- public synchronized void writeContent()
- {
- try
- {
- FileOutputStream fou = new FileOutputStream(database);
- BufferedOutputStream b = new BufferedOutputStream(fou);
- ObjectOutputStream oout = new ObjectOutputStream(b);
- oout.writeObject(this);
- oout.close();
- }
- catch (Exception ioex)
- {
- InternalError ierr = new InternalError(
- "Failed to write database to disk: "+ database);
- ierr.initCause(ioex);
- throw ierr;
- }
- }
-
- /**
- * Mark the modified database as modified. The database will be written after
- * several seconds, unless another modification occurs.
- */
- public void markDirty()
- {
- if (System.currentTimeMillis() - lastUpdated > ALWAYS_UPDATE)
- {
- // Force storing to disk under intensive operation.
- writeContent();
- lastUpdated = System.currentTimeMillis();
- if (sheduled != null)
- {
- sheduled.cancel();
- sheduled = null;
- }
- }
- else
- {
- // Otherwise coalesce the disk database copy update events.
- if (sheduled != null)
- sheduled.cancel();
- sheduled = new WriteToDiskTask();
- timer.schedule(sheduled, SAVE_AT_MOST_AFTER);
- }
- }
-
- /**
- * Save the current database state to the disk before exit.
- */
- public void shutdown()
- {
- if (sheduled != null)
- {
- writeContent();
- sheduled = null;
- }
- }
-
- /**
- * Update the memory maps and mark as should be written to the disk.
- */
- public Object put(Object key, Object value)
- {
- super.put(key, value);
- if (ready)
- markDirty();
- return value;
- }
-
- /**
- * Update the memory maps and mark as should be written to the disk.
- */
- public Object remove(Object key)
- {
- Object removed = super.remove(key);
- if (ready)
- markDirty();
- return removed;
- }
-
-}
diff --git a/tools/gnu/classpath/tools/rmi/REGISTRY.java b/tools/gnu/classpath/tools/rmi/REGISTRY.java
deleted file mode 100644
index 63f633f99..000000000
--- a/tools/gnu/classpath/tools/rmi/REGISTRY.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/* REGISTY.java -- RMI registry starter.
- Copyright (C) 2006 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package gnu.classpath.tools.rmi;
-
-import gnu.classpath.tools.HelpPrinter;
-import gnu.classpath.tools.rmi.registry.RegistryImpl;
-import gnu.java.rmi.server.UnicastServerRef;
-
-import java.io.File;
-import java.rmi.NotBoundException;
-import java.rmi.RemoteException;
-import java.rmi.registry.LocateRegistry;
-import java.rmi.registry.Registry;
-import java.rmi.server.ObjID;
-import java.rmi.server.RMIServerSocketFactory;
-import java.util.Hashtable;
-import java.util.Map;
-
-/**
- * The optionally persistent RMI registry implementation.
- *
- * @author Audrius Meskauskas (audriusa@bioinformatics.org)
- */
-public class REGISTRY
-{
- /**
- * The stop command.
- */
- public static String STOP = "gnu.classpath.tools.rmi.registry.command.STOP";
-
- /**
- * If true, the registry prints registration events to console.
- */
- public static boolean verbose = false;
-
- /**
- * The RMI registry implementation entry point.
- */
- public static void main(String[] args)
- {
- String HelpPath = "rmi/REGISTRY.txt";
- HelpPrinter.checkHelpKey(args, HelpPath);
-
- // Parse parameters:
- String folder = ".";
- boolean cold = false;
- boolean trans = false;
- boolean stop = false;
-
- int port = Registry.REGISTRY_PORT;
- RMIServerSocketFactory ssf = null;
-
- for (int i = 0; i < args.length; i++)
- {
- String a = args[i];
- if (a.equals("-restart"))
- cold = true;
- else if (a.equals("-transient"))
- trans = true;
- else if (a.equals("-verbose"))
- verbose = true;
- else if (a.equals("-stop"))
- stop = true;
- else if (i < args.length - 1)
- {
- // The additional key parameter is possible.
- if (a.equals("-port"))
- port = Integer.parseInt(args[++i]);
- else if (a.equals("-folder"))
- folder = args[++i];
- }
- }
-
- if (!stop)
- {
- Map table;
- if (trans)
- table = new Hashtable();
- else
- {
- // Start the system.
- File dataFolder = new File(folder);
- if (!dataFolder.exists())
- dataFolder.mkdirs();
- table = PersistentHashTable.createInstance(
- new File(dataFolder, "rmiregistry.data"), cold);
- }
-
- RegistryImpl system = new RegistryImpl(table);
-
- // We must export with the specific activation id that is only
- // possible when going into the gnu.java.rmi
- try
- {
- UnicastServerRef sref = new UnicastServerRef(
- new ObjID(ObjID.REGISTRY_ID), port, ssf);
-
- sref.exportObject(system);
- System.out.println("The RMI naming service is listening at " + port);
- }
- catch (Exception ex)
- {
- System.out.println("Failed to start RMI naming service at " + port);
- }
- }
- else
- {
- // Stop the naming service.
- try
- {
- Registry r = LocateRegistry.getRegistry(port);
- // Search for this specific line will command to stop the registry.
-
- // Our service returns null, but any other service will thrown
- // NotBoundException.
- r.unbind(STOP);
- }
- catch (RemoteException e)
- {
- System.out.println("Failed to stop RMI naming service at " + port);
- }
- catch (NotBoundException e)
- {
- System.out.println("The naming service at port "+port+" is not a "+
- REGISTRY.class.getName());
- }
- }
- }
-}
diff --git a/tools/gnu/classpath/tools/rmi/REGISTRY.txt b/tools/gnu/classpath/tools/rmi/REGISTRY.txt
deleted file mode 100644
index 7d8e19232..000000000
--- a/tools/gnu/classpath/tools/rmi/REGISTRY.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-The persistent RMI naming service, required for the remote method invocations
-(packages java.rmi.*, java.rmi.Registry.*).
-
-Copyright 2006 Free Software Foundation, Inc.
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-Please report bugs at http://www.gnu.org/software/classpath/bugs.html
-
-Usage: rmiregistry
-
- where includes:
- -port N Start the registry on the given local port. If this key
- is not specified, the service starts on the port 1099.
- -verbose Log binding events to stdout.
- -stop Stop the running naming service at the given port.
-
- -transient Start transient registry service that does not write any
- data to the disk. Such service looses the stored bindings if
- restarted. If this key is not specified, the
- persistent naming service is started.
- -restart "Cold start:, clear the persistent naming database, if any.
- -folder Folder Store the persistent binding file in the given folder. If this
- key is not specified, the file with persistent bindings is
- stored into the current folder.
-
-
-
diff --git a/tools/gnu/classpath/tools/rmi/RMIC.java b/tools/gnu/classpath/tools/rmi/RMIC.java
deleted file mode 100644
index fa4d87c17..000000000
--- a/tools/gnu/classpath/tools/rmi/RMIC.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/* RMIC.java -- RMI stub generator.
- Copyright (C) 2006 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-*/
-
-
-package gnu.classpath.tools.rmi;
-
-import gnu.classpath.tools.HelpPrinter;
-import gnu.classpath.tools.giop.GRMIC;
-import gnu.classpath.tools.rmi.rmic.RmicCompiler;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * Generates the ordinary stubs (not GIOP based) for java.rmi.* package.
- *
- * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
- */
-public class RMIC
-{
- /**
- * The version of the compiler.
- */
- public static String VERSION = "0.01 alpha pre";
-
- /**
- * The GRMIC compiler methods
- *
- * @param args the compiler parameters.
- */
- public static void main(String[] args)
- {
- // Check for the -iiop or -giop keys. If one of these keys is present,
- // forward all call to GRMIC.
- for (int i = 0; i < args.length; i++)
- {
- if (args[i].equals("-giop") || args[i].equals("-iiop"))
- {
- GRMIC.main(args);
- return;
- }
- }
-
- boolean noWrite = false;
- boolean verbose = false;
-
- String HelpPath = "rmi/RMIC.txt";
-
- HelpPrinter.checkHelpKey(args, HelpPath);
-
- File output = new File(".");
-
- if (args.length == 0)
- {
- HelpPrinter.printHelpAndExit(HelpPath);
- }
- else
- {
- RmicCompiler compiler = new RmicCompiler();
-
- int cl = - 1;
-
- Options: for (int i = 0; i < args.length; i++)
- {
- String c = args[i];
- if (c.equals("-v"))
- {
- printVersion();
- System.exit(0);
- }
- else if (c.equals("-nowrite"))
- noWrite = true;
- else if (c.equals("-nowarn"))
- compiler.setWarnings(false);
- else if (c.equals("-verbose"))
- {
- verbose = true;
- compiler.setVerbose(true);
- }
- else if (c.equals("-force"))
- {
- compiler.setForce(true);
- }
- else if (c.equals("-d"))
- {
- int f = i + 1;
- if (f < args.length)
- {
- output = new File(args[f]);
- i++;
- }
- else
- HelpPrinter.printHelpAndExit(HelpPath);
- }
- else if (c.equals("-classpath"))
- {
- int f = i + 1;
- if (f < args.length)
- {
- compiler.setClassPath(args[f]);
- i++;
- }
- else
- HelpPrinter.printHelpAndExit(HelpPath);
- }
- else if (c.charAt(0) != '-')
- // No more options - start of class list.
- {
- cl = i;
- break Options;
- }
- }
-
- if (cl < 0)
- HelpPrinter.printHelpAndExit(HelpPath);
-
- if (verbose)
- System.out.println("Compiling to " + output.getAbsolutePath());
-
- // Compile classes
- Compile: for (int i = cl; i < args.length; i++)
- {
- if (args[i].charAt(0) != '-')
- {
- compiler.reset();
- Class c = compiler.loadClass(args[i]);
-
- compiler.compile(c);
- String packag = compiler.getPackageName().replace('.', '/');
- File fw = new File(output, packag);
-
- // Generate stub.
- String stub = compiler.generateStub();
- String subName = compiler.getStubName() + "_Stub.java";
-
- if (noWrite)
- continue Compile;
-
- try
- {
- fw.mkdirs();
- OutputStream out = new FileOutputStream(new File(fw,
- subName));
- out.write(stub.getBytes());
- out.close();
- }
- catch (IOException ioex)
- {
- System.err.println("Output path not accessible");
- ioex.printStackTrace();
- System.exit(1);
- }
- }
- }
- }
- }
-
- /**
- * Print the version information.
- */
- public static void printVersion()
- {
- System.out.println
- ("rmic v "+VERSION+" - RMI stub generator for java.rmi.* ");
- }
-}
diff --git a/tools/gnu/classpath/tools/rmi/RMIC.txt b/tools/gnu/classpath/tools/rmi/RMIC.txt
deleted file mode 100644
index 882cca553..000000000
--- a/tools/gnu/classpath/tools/rmi/RMIC.txt
+++ /dev/null
@@ -1,45 +0,0 @@
-RMI stub and tie source code generator for java.rmi.*, javax.rmi.*
-
-Copyright 2006 Free Software Foundation, Inc.
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-Please report bugs at http://www.gnu.org/software/classpath/bugs.html
-
-Usage: rmic
-
- where includes:
- -nowarn Show no warnings
- -nowrite Do not write any files (check for errors only)
- -d Place generated files into the given folder
- -classpath Specifies the path, where to find the classes being
- compiled
-
- -help Print this help text
- -v Print version
- -verbose Verbose output
- -force Try to generate code even if the input classes seem not
- consistent with RMI specification.
-
- -1.2 Generate v 1.2 stubs (default)*
-
- -iiop Generate stubs and ties for the GIOP based RMI package
- extension, javax.rmi. With this key, the two additional
- keys are accepted:
- -poa Generate the Servant based ties (default)
- -impl Generate the obsoleted ObjectImpl based ties
- (for backward compatibility)
- -help Show more details on the giop stub and tie generator
- options.
- -giop Same as -iiop*
-
-
- and can include one or more non abstract classes that implement
- Remote and are accessible via current class path.
-
-* This tool generates the source code that must be compiled with java compiler.
-* The deprecated 1.1 version stubs are currently not supported (the v 1.2
- style stubs are always generated).
-* -iiop is a standard key for this tool, but it is also a registered OMG mark
- when giop is not.
-
diff --git a/tools/gnu/classpath/tools/rmi/RMID.java b/tools/gnu/classpath/tools/rmi/RMID.java
deleted file mode 100644
index 81d09671a..000000000
--- a/tools/gnu/classpath/tools/rmi/RMID.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/* RMID.java -- the RMI activation daemon.
- Copyright (c) 2006 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath.tools.rmi;
-
-import gnu.classpath.tools.HelpPrinter;
-import gnu.classpath.tools.rmi.rmid.ActivationSystemImpl;
-import gnu.java.rmi.activation.ActivationSystemTransient;
-import gnu.java.rmi.server.UnicastServerRef;
-
-import java.io.File;
-import java.net.InetAddress;
-import java.rmi.Remote;
-import java.rmi.activation.ActivationSystem;
-import java.rmi.registry.LocateRegistry;
-import java.rmi.registry.Registry;
-import java.rmi.server.ObjID;
-import java.rmi.server.RMIServerSocketFactory;
-
-
-/**
- * The persistent RMI activation daemon.
- *
- * @author Audrius Meskauskas (audriusa@bioinformatics.org)
- */
-public class RMID
-{
- /**
- * The RMI server socket factory.
- */
- static RMIServerSocketFactory ACTIVATION_REGISTY_SOCKET_FACTORY = null;
-
- /**
- * The activation registry port.
- */
- static int ACTIVATION_REGISTRY_PORT = ActivationSystem.SYSTEM_PORT;
-
- /**
- * The activation system name.
- */
- static String ACTIVATION_SYSTEM_NAME = "java.rmi.activation.ActivationSystem";
-
- /**
- * The RMI activation daemon entry point.
- */
- public static void main(String[] args)
- {
- String HelpPath = "rmi/RMID.txt";
- HelpPrinter.checkHelpKey(args, HelpPath);
-
- // Parse parameters:
- boolean stop = false;
- String folder = ".";
- boolean cold = false;
- boolean trans = false;
-
- for (int i = 0; i < args.length; i++)
- {
- String a = args[i];
- if (a.equals("-verbose"))
- ActivationSystemTransient.debug = true;
- else if (a.equals("-stop"))
- stop = true;
- else if (a.equals("-restart"))
- cold = true;
- else if (a.equals("-transient"))
- trans = true;
- else if (i < args.length - 1)
- {
- // The additional key parameter is possible.
- if (a.equals("-port"))
- ACTIVATION_REGISTRY_PORT = Integer.parseInt(args[++i]);
- else if (a.equals("-folder"))
- folder = args[++i];
- }
- }
-
- try
- {
- if (!stop)
- {
- // Start the system.
- File dataFolder = new File(folder);
- if (!dataFolder.exists())
- dataFolder.mkdirs();
- ActivationSystem system;
-
- if (trans)
- system = ActivationSystemTransient.getInstance();
- else
- system = ActivationSystemImpl.getInstance(dataFolder, cold);
-
- // We must export with the specific activation id that is only
- // possible when going into the gnu.java.rmi.activation.
- UnicastServerRef sref = new UnicastServerRef(
- new ObjID(ObjID.ACTIVATOR_ID), ACTIVATION_REGISTRY_PORT,
- ACTIVATION_REGISTY_SOCKET_FACTORY);
- Remote systemStub = sref.exportObject(system);
-
- // Start the naming system on the activation system port
- // (if not already running).
-
- Registry r;
- try
- {
- // Expect the naming service running first.
- // The local host may want to use the shared registry
- r = LocateRegistry.getRegistry(ACTIVATION_REGISTRY_PORT);
- r.rebind(ACTIVATION_SYSTEM_NAME, systemStub);
- }
- catch (Exception ex)
- {
- // The naming service is not running. Start it.
- r = LocateRegistry.createRegistry(ACTIVATION_REGISTRY_PORT);
- r.rebind(ACTIVATION_SYSTEM_NAME, systemStub);
- }
- String host = InetAddress.getLocalHost().getCanonicalHostName();
- System.out.println("The RMI daemon is listening on " + host +
- " (port "
- + ACTIVATION_REGISTRY_PORT + ")");
-
- }
- else
- {
- // Stop the activation system.
- Registry r;
- try
- {
- System.out.print("Stopping RMI daemon at "
- + ACTIVATION_REGISTRY_PORT+" ... ");
- // Expect the naming service running first.
- // The local host may want to use the shared registry
- r = LocateRegistry.getRegistry(ACTIVATION_REGISTRY_PORT);
- ActivationSystem asys =
- (ActivationSystem) r.lookup(ACTIVATION_SYSTEM_NAME);
- asys.shutdown();
- System.out.println("OK.");
- }
- catch (Exception ex)
- {
- System.out.println("The RMI daemon seems not running at "
- + ACTIVATION_REGISTRY_PORT);
- if (ActivationSystemTransient.debug)
- ex.printStackTrace();
- }
- }
- }
- catch (Exception e)
- {
- System.out.println("Failed to start the RMI daemon.");
- if (ActivationSystemTransient.debug)
- e.printStackTrace();
- }
- }
-}
diff --git a/tools/gnu/classpath/tools/rmi/RMID.txt b/tools/gnu/classpath/tools/rmi/RMID.txt
deleted file mode 100644
index a62613fd4..000000000
--- a/tools/gnu/classpath/tools/rmi/RMID.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-The persistent RMI activation daemon, support RMI object activation
-(package java.rmi.activation.*).
-
-Copyright 2006 Free Software Foundation, Inc.
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-Please report bugs at http://www.gnu.org/software/classpath/bugs.html
-
-Usage: rmid
-
- where includes:
- -port N Start the service on the given local port. If this key
- is not specified, the service starts on the port 1098.
- -verbose Log registration events to stdout.
- -stop Stop the running activation service at the given port.
-
- -transient Start transient activation service that does not write any
- data to the disk. Such service looses the stored activation
- descriptors, if restarted. If this key is not specified, the
- persistent naming service is started.
- -restart "Cold start:, clear the activation descriptor database, if any.
- -folder Folder Store the persistent descriptor file in the given folder. If this
- key is not specified, the file with persistent activation
- information is stored into the current folder.
-
-All activation groups are activated on the same virtual machine, where the
-daemon is running. For security reasons, all the classes, required for
-activation, must be available in the classpath of that machine.
-
\ No newline at end of file
diff --git a/tools/gnu/classpath/tools/rmi/registry/RegistryImpl.java b/tools/gnu/classpath/tools/rmi/registry/RegistryImpl.java
deleted file mode 100644
index 90bd3a6bd..000000000
--- a/tools/gnu/classpath/tools/rmi/registry/RegistryImpl.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/* RegistryImpl.java -- the RMI registry implementation
- Copyright (c) 1996, 1997, 1998, 1999, 2002, 2005, 2006
- Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath.tools.rmi.registry;
-
-import gnu.classpath.tools.rmi.Persistent;
-import gnu.classpath.tools.rmi.REGISTRY;
-
-import java.rmi.AccessException;
-import java.rmi.AlreadyBoundException;
-import java.rmi.NotBoundException;
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-import java.rmi.registry.Registry;
-import java.util.ArrayList;
-import java.util.Map;
-
-/**
- * The optionally persistent registry implementation.
- *
- * @author Audrius Meskauskas (audriusa@bioinformatics.org)
- */
-public class RegistryImpl implements Registry
-{
- /**
- * The binding table.
- */
- Map bindings;
-
- /**
- * Create the registry implementation that uses the given bidirectinal
- * table to keep the data.
- */
- public RegistryImpl(Map aTable)
- {
- bindings = aTable;
- }
-
- /** @inheritDoc */
- public Remote lookup(String name) throws RemoteException, NotBoundException,
- AccessException
- {
- Object obj = bindings.get(name);
- if (obj == null)
- throw new NotBoundException(name);
- return ((Remote) obj);
- }
-
- /** @inheritDoc */
- public void bind(String name, Remote obj) throws RemoteException,
- AlreadyBoundException, AccessException
- {
- if (REGISTRY.verbose)
- System.out.println("Bind "+name);
- if (bindings.containsKey(name))
- throw new AlreadyBoundException(name);
- bindings.put(name, obj);
- }
-
- /** @inheritDoc */
- public void unbind(String name) throws RemoteException, NotBoundException,
- AccessException
- {
- if (name.equals(REGISTRY.STOP))
- {
- if (bindings instanceof Persistent)
- ((Persistent) bindings).writeContent();
- // Terminate in 10 seconds.
- System.out.println("Shutdown command received. Will terminate in 10 s");
- Persistent.timer.schedule(new Persistent.ExitTask(), 10000);
- }
- else
- {
- if (REGISTRY.verbose)
- System.out.println("Unbind "+name);
-
- if (!bindings.containsKey(name))
- throw new NotBoundException(name);
- else
- bindings.remove(name);
- }
- }
-
- /** @inheritDoc */
- public void rebind(String name, Remote obj) throws RemoteException,
- AccessException
- {
- if (REGISTRY.verbose)
- System.out.println("Rebind "+name);
- bindings.put(name, obj);
- }
-
- /** @inheritDoc */
- public String[] list() throws RemoteException, AccessException
- {
- // Create a separated array to prevent race conditions.
- ArrayList keys = new ArrayList(bindings.keySet());
- int n = keys.size();
- String[] rt = new String[n];
- for (int i = 0; i < n; i++)
- rt[i] = (String) keys.get(i);
- return rt;
- }
-}
diff --git a/tools/gnu/classpath/tools/rmi/registry/RegistryImpl_Skel.java b/tools/gnu/classpath/tools/rmi/registry/RegistryImpl_Skel.java
deleted file mode 100644
index 36b7d94a5..000000000
--- a/tools/gnu/classpath/tools/rmi/registry/RegistryImpl_Skel.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/* RegistryImpl_Skel.java
- Copyright (C) 2002, 2006 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package gnu.classpath.tools.rmi.registry;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.rmi.MarshalException;
-import java.rmi.Remote;
-import java.rmi.UnmarshalException;
-import java.rmi.server.Operation;
-import java.rmi.server.RemoteCall;
-import java.rmi.server.SkeletonMismatchException;
-
-/**
- * This skeleton supports unlikely cases when the naming service is
- * contacted from other interoperable java implementation that still uses
- * the old style skeleton-dependent invocations.
- */
-public final class RegistryImpl_Skel
- implements java.rmi.server.Skeleton
-{
- private static final long interfaceHash = 4905912898345647071L;
-
- /**
- * Repeated multiple times.
- */
- static final String EUM = "error unmarshalling arguments for Registry";
-
- /**
- * Repeated multiple times.
- */
- static final String EMR = "error marshalling return from Registry";
-
- private static final Operation[] operations =
- {
- new Operation("void bind(java.lang.String, Remote"),
- new Operation("java.lang.String[] list("),
- new Operation("Remote lookup(java.lang.String"),
- new Operation("void rebind(java.lang.String, Remote"),
- new Operation("void unbind(java.lang.String")
- };
-
- public Operation[] getOperations()
- {
- return ((Operation[]) operations.clone());
- }
-
- public void dispatch(Remote obj, RemoteCall call,
- int opnum, long hash) throws java.lang.Exception
- {
- if (opnum < 0)
- {
- if (hash == 7583982177005850366L)
- opnum = 0;
- else if (hash == 2571371476350237748L)
- opnum = 1;
- else if (hash == -7538657168040752697L)
- opnum = 2;
- else if (hash == -8381844669958460146L)
- opnum = 3;
- else if (hash == 7305022919901907578L)
- opnum = 4;
- else
- throw new SkeletonMismatchException("interface hash mismatch");
- }
- else if (hash != interfaceHash)
- throw new SkeletonMismatchException("interface hash mismatch");
-
- RegistryImpl server = (RegistryImpl) obj;
- switch (opnum)
- {
- case 0:
- {
- java.lang.String $param_0;
- Remote $param_1;
- try
- {
- ObjectInput in = call.getInputStream();
- $param_0 = (java.lang.String) in.readObject();
- $param_1 = (Remote) in.readObject();
-
- }
- catch (IOException e)
- {
- throw new UnmarshalException(EUM, e);
- }
- catch (java.lang.ClassCastException e)
- {
- throw new UnmarshalException(EUM, e);
- }
- finally
- {
- call.releaseInputStream();
- }
- server.bind($param_0, $param_1);
- try
- {
- ObjectOutput out = call.getResultStream(true);
- }
- catch (IOException e)
- {
- throw new MarshalException(EMR, e);
- }
- break;
- }
-
- case 1:
- {
- try
- {
- ObjectInput in = call.getInputStream();
-
- }
- catch (IOException e)
- {
- throw new UnmarshalException(EUM, e);
- }
- finally
- {
- call.releaseInputStream();
- }
- java.lang.String[] $result = server.list();
- try
- {
- ObjectOutput out = call.getResultStream(true);
- out.writeObject($result);
- }
- catch (IOException e)
- {
- throw new MarshalException(EMR, e);
- }
- break;
- }
-
- case 2:
- {
- java.lang.String $param_0;
- try
- {
- ObjectInput in = call.getInputStream();
- $param_0 = (java.lang.String) in.readObject();
-
- }
- catch (IOException e)
- {
- throw new UnmarshalException(EUM, e);
- }
- catch (java.lang.ClassCastException e)
- {
- throw new UnmarshalException(EUM, e);
- }
- finally
- {
- call.releaseInputStream();
- }
- Remote $result = server.lookup($param_0);
- try
- {
- ObjectOutput out = call.getResultStream(true);
- out.writeObject($result);
- }
- catch (IOException e)
- {
- throw new MarshalException(EMR, e);
- }
- break;
- }
-
- case 3:
- {
- java.lang.String $param_0;
- Remote $param_1;
- try
- {
- ObjectInput in = call.getInputStream();
- $param_0 = (java.lang.String) in.readObject();
- $param_1 = (Remote) in.readObject();
-
- }
- catch (IOException e)
- {
- throw new UnmarshalException(EUM, e);
- }
- catch (java.lang.ClassCastException e)
- {
- throw new UnmarshalException(EUM, e);
- }
- finally
- {
- call.releaseInputStream();
- }
- server.rebind($param_0, $param_1);
- try
- {
- ObjectOutput out = call.getResultStream(true);
- }
- catch (IOException e)
- {
- throw new MarshalException(EMR, e);
- }
- break;
- }
-
- case 4:
- {
- java.lang.String $param_0;
- try
- {
- ObjectInput in = call.getInputStream();
- $param_0 = (java.lang.String) in.readObject();
-
- }
- catch (IOException e)
- {
- throw new UnmarshalException(EUM, e);
- }
- catch (java.lang.ClassCastException e)
- {
- throw new UnmarshalException(EUM, e);
- }
- finally
- {
- call.releaseInputStream();
- }
- server.unbind($param_0);
- try
- {
- ObjectOutput out = call.getResultStream(true);
- }
- catch (IOException e)
- {
- throw new MarshalException(EMR, e);
- }
- break;
- }
-
- default:
- throw new UnmarshalException("invalid method number");
- }
- }
-}
diff --git a/tools/gnu/classpath/tools/rmi/registry/RegistryImpl_Stub.java b/tools/gnu/classpath/tools/rmi/registry/RegistryImpl_Stub.java
deleted file mode 100644
index d8cac5bfc..000000000
--- a/tools/gnu/classpath/tools/rmi/registry/RegistryImpl_Stub.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/* RegistryImpl_Stub.java -- Registry stub.
- Copyright (c) 2006 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING. If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library. Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module. An independent module is a module which is not derived from
-or based on this library. If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so. If you do not wish to do so, delete this
-exception statement from your version. */
-
-package gnu.classpath.tools.rmi.registry;
-
-import java.rmi.AccessException;
-import java.rmi.AlreadyBoundException;
-import java.rmi.NotBoundException;
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-import java.rmi.registry.Registry;
-
-import java.lang.reflect.Method;
-import java.rmi.server.RemoteRef;
-import java.rmi.server.RemoteStub;
-import java.rmi.UnexpectedException;
-
-/**
- * This class delegates its method calls to the remote RMI object, referenced
- * by {@link RemoteRef}.
- *
- * It is normally generated with rmic.
- */
-public final class RegistryImpl_Stub
- extends RemoteStub
- implements Registry
-{
- /**
- * Use serialVersionUID for interoperability
- */
- private static final long serialVersionUID = 3;
-
- /**
- * The explaining message for {@ling UnexpectedException}.
- */
- private static final String exception_message =
- "undeclared checked exception";
-
- /* All remote methods, invoked by this stub: */
- private static final Method met_list;
- private static final Method met_rebind;
- private static final Method met_unbind;
- private static final Method met_lookup;
- private static final Method met_bind;
- private static final Object[] NO_ARGS = new Object[0];
- static
- {
- final Class[] NO_ARGSc = new Class[0];
- try
- {
- met_list =
- Registry.class.getMethod("list", NO_ARGSc);
- met_rebind =
- Registry.class.getMethod("rebind", new Class[]
- {
- String.class, Remote.class
- });
- met_unbind =
- Registry.class.getMethod("unbind", new Class[]
- {
- String.class
- });
- met_lookup =
- Registry.class.getMethod("lookup", new Class[]
- {
- String.class
- });
- met_bind =
- Registry.class.getMethod("bind", new Class[]
- {
- String.class, Remote.class
- });
-
- }
- catch (NoSuchMethodException nex)
- {
- NoSuchMethodError err = new NoSuchMethodError(
- "RegistryImpl_Stub class initialization failed");
- err.initCause(nex);
- throw err;
- }
- }
-
- /**
- * Create the instance for _RegistryImpl_Stub that forwards method calls to the
- * remote object.
- *
- * @para the reference to the remote object.
- */
- public RegistryImpl_Stub(RemoteRef reference)
- {
- super(reference);
- }
-
- /* Methods */
- /** @inheritDoc */
- public String [] list()
- throws RemoteException, AccessException
- {
- try
- {
- Object result = ref.invoke(this, met_list,
- NO_ARGS,
- 2571371476350237748L);
- return (String []) result;
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- catch (RemoteException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- UnexpectedException uex = new UnexpectedException(exception_message);
- uex.detail = e;
- throw uex;
- }
- }
-
- /** @inheritDoc */
- public void rebind(String p0, Remote p1)
- throws RemoteException, AccessException
- {
- try
- {
- ref.invoke(this, met_rebind,
- new Object[] {p0, p1},
- -8381844669958460146L);
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- catch (RemoteException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- UnexpectedException uex = new UnexpectedException(exception_message);
- uex.detail = e;
- throw uex;
- }
- }
-
- /** @inheritDoc */
- public void unbind(String p0)
- throws RemoteException, NotBoundException, AccessException
- {
- try
- {
- ref.invoke(this, met_unbind,
- new Object[] {p0},
- 7305022919901907578L);
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- catch (RemoteException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- UnexpectedException uex = new UnexpectedException(exception_message);
- uex.detail = e;
- throw uex;
- }
- }
-
- /** @inheritDoc */
- public Remote lookup(String p0)
- throws RemoteException, NotBoundException, AccessException
- {
- try
- {
- Object result = ref.invoke(this, met_lookup,
- new Object[] {p0},
- -7538657168040752697L);
- return (Remote) result;
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- catch (RemoteException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- UnexpectedException uex = new UnexpectedException(exception_message);
- uex.detail = e;
- throw uex;
- }
- }
-
- /** @inheritDoc */
- public void bind(String p0, Remote p1)
- throws RemoteException, AlreadyBoundException, AccessException
- {
- try
- {
- ref.invoke(this, met_bind,
- new Object[] {p0, p1},
- 7583982177005850366L);
- }
- catch (RuntimeException e)
- {
- throw e;
- }
- catch (RemoteException e)
- {
- throw e;
- }
- catch (Exception e)
- {
- UnexpectedException uex = new UnexpectedException(exception_message);
- uex.detail = e;
- throw uex;
- }
- }
-
-
-}
diff --git a/tools/gnu/classpath/tools/rmi/registry/package.html b/tools/gnu/classpath/tools/rmi/registry/package.html
deleted file mode 100644
index 71df83b61..000000000
--- a/tools/gnu/classpath/tools/rmi/registry/package.html
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-GNU Classpath - gnu.classpath.tools.rmi.registry
-
-
-
-
-
-
diff --git a/tools/gnu/classpath/tools/rmi/rmic/RmiMethodGenerator.java b/tools/gnu/classpath/tools/rmi/rmic/RmiMethodGenerator.java
deleted file mode 100644
index 8da486571..000000000
--- a/tools/gnu/classpath/tools/rmi/rmic/RmiMethodGenerator.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/* MethodGenerator.java -- Generates methods for rmi compiler.
- Copyright (C) 2006 Free Software Foundation
-
- This file is part of GNU Classpath.
-
- GNU Classpath is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
- any later version.
-
- GNU Classpath is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with GNU Classpath; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301 USA.
-
- Linking this library statically or dynamically with other modules is
- making a combined work based on this library. Thus, the terms and
- conditions of the GNU General Public License cover the whole
- combination.
-*/
-
-
-package gnu.classpath.tools.rmi.rmic;
-
-import gnu.classpath.tools.AbstractMethodGenerator;
-import gnu.java.rmi.server.RMIHashes;
-
-import java.lang.reflect.Method;
-import java.util.Properties;
-
-/**
- * Keeps information about the single method and generates the code fragments,
- * related to that method.
- *
- * @author Audrius Meskauskas, Lithuania (audriusa@Bioinformatics.org)
- */
-public class RmiMethodGenerator
- implements AbstractMethodGenerator
-{
- /**
- * The method being defined.
- */
- Method method;
-
- /**
- * The parent code generator.
- */
- RmicCompiler rmic;
-
- /**
- * Create the new method generator for the given method.
- *
- * @param aMethod the related method.
- * @param aRmic the Rmic generator instance, where more class - related
- * information is defined.
- */
- public RmiMethodGenerator(Method aMethod, RmicCompiler aRmic)
- {
- method = aMethod;
- rmic = aRmic;
- if (method.getParameterTypes().length == 0)
- rmic.addZeroSizeObjecArray = true;
- }
-
- /**
- * Get the method parameter declaration.
- *
- * @return the string - method parameter declaration.
- */
- public String getArgumentList()
- {
- StringBuffer b = new StringBuffer();
-
- Class[] args = method.getParameterTypes();
-
- for (int i = 0; i < args.length; i++)
- {
- b.append(rmic.name(args[i]));
- b.append(" p" + i);
- if (i < args.length - 1)
- b.append(", ");
- }
- return b.toString();
- }
-
- /**
- * Get the method parameter list only (no type declarations). This is used to
- * generate the method invocations statement.
- *
- * @return the string - method parameter list.
- */
- public String getArgumentNames()
- {
- StringBuffer b = new StringBuffer();
-
- Class[] args = method.getParameterTypes();
-
- for (int i = 0; i < args.length; i++)
- {
- b.append(" p" + i);
- if (i < args.length - 1)
- b.append(", ");
- }
- return b.toString();
- }
-
- /**
- * Get the list of exceptions, thrown by this method.
- *
- * @return the list of exceptions.
- */
- public String getThrows()
- {
- StringBuffer b = new StringBuffer();
-
- Class[] args = method.getExceptionTypes();
-
- for (int i = 0; i < args.length; i++)
- {
- b.append(rmic.name(args[i]));
- if (i < args.length - 1)
- b.append(", ");
- }
- return b.toString();
- }
-
- /**
- * Generate this method for the Stub class.
- *
- * @return the method body for the stub class.
- */
- public String generateStubMethod()
- {
- String templateName;
-
- Properties vars = new Properties(rmic.vars);
- vars.put("#return_type", rmic.name(method.getReturnType()));
- vars.put("#method_name", method.getName());
- vars.put("#method_hash", getMethodHashCode());
- vars.put("#argument_list", getArgumentList());
- vars.put("#object_arg_list", getArgListAsObjectArray());
- vars.put("#declaring_class", rmic.name(method.getDeclaringClass()));
- vars.put("#class_arg_list", getArgListAsClassArray());
-
- String thr = getThrows();
- if (thr.length() > 0)
- vars.put("#throws", "\n throws " + thr);
- else
- vars.put("#throws", "");
-
- if (method.getReturnType().equals(void.class))
- templateName = "Stub_12MethodVoid.jav";
- else
- {
- templateName = "Stub_12Method.jav";
- vars.put("#return_statement", getReturnStatement());
- }
-
- String template = rmic.getResource(templateName);
- String generated = rmic.replaceAll(template, vars);
- return generated;
- }
-
- /**
- * Generate sentences for Reading and Defining Arguments.
- *
- * @return the sequence of sentences for reading and defining arguments.
- */
- public String getStaticMethodDeclarations()
- {
- StringBuffer b = new StringBuffer();
- Class[] args = method.getParameterTypes();
-
- for (int i = 0; i < args.length; i++)
- {
- b.append(" ");
- b.append(rmic.name(args[i]));
- b.append(" ");
- b.append("p" + i);
- b.append(" = ");
- if (i < args.length - 1)
- b.append("\n");
- }
- return b.toString();
- }
-
- /**
- * Get the write statement for writing parameters inside the stub.
- *
- * @return the write statement.
- */
- public String getArgListAsObjectArray()
- {
- Class[] args = method.getParameterTypes();
-
- if (args.length==0)
- return "NO_ARGS";
-
- StringBuffer b = new StringBuffer("new Object[] {");
-
- for (int i = 0; i < args.length; i++)
- {
- if (!args[i].isPrimitive())
- b.append("p"+i);
- else
- {
- b.append("new "+rmic.name(WrapUnWrapper.getWrappingClass(args[i])));
- b.append("(p"+i+")");
- }
- if (i= args.length)
+ return false;
+
+ for (int i = next; i < args.length; i++)
+ {
+ try
+ {
+ if (verbose)
+ System.out.println("[Processing class " + args[i] + ".class]");
+ processClass(args[i].replace(File.separatorChar, '.'));
+ }
+ catch (IOException e)
+ {
+ errors.add(e);
+ }
+ catch (RMICException e)
+ {
+ errors.add(e);
+ }
+ }
+ if (errors.size() > 0)
+ {
+ for (Iterator it = errors.iterator(); it.hasNext(); )
+ {
+ Exception ex = (Exception) it.next();
+ logError(ex);
+ }
+ }
+
+ return errorCount == 0;
+ }
+
+ private void processClass(String cls) throws IOException, RMICException
+ {
+ // reset class specific vars
+ clazz = null;
+ classname = null;
+ classInternalName = null;
+ fullclassname = null;
+ remotemethods = null;
+ stubname = null;
+ skelname = null;
+ mRemoteInterfaces = new ArrayList();
+
+ analyzeClass(cls);
+ generateStub();
+ if (need11Stubs)
+ generateSkel();
+ }
+
+ private void analyzeClass(String cname)
+ throws RMICException
+ {
+ if (verbose)
+ System.out.println("[analyze class " + cname + "]");
+ int p = cname.lastIndexOf('.');
+ if (p != -1)
+ classname = cname.substring(p + 1);
+ else
+ classname = cname;
+ fullclassname = cname;
+
+ findClass();
+ findRemoteMethods();
+ }
+
+ /**
+ * @deprecated
+ */
+ public Exception getException()
+ {
+ return errors.size() == 0 ? null : (Exception) errors.get(0);
+ }
+
+ private void findClass()
+ throws RMICException
+ {
+ ClassLoader cl = (loader == null
+ ? ClassLoader.getSystemClassLoader()
+ : loader);
+ try
+ {
+ clazz = Class.forName(fullclassname, false, cl);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ throw new RMICException
+ ("Class " + fullclassname + " not found in classpath", cnfe);
+ }
+
+ if (! Remote.class.isAssignableFrom(clazz))
+ {
+ throw new RMICException
+ ("Class " + clazz.getName()
+ + " does not implement a remote interface.");
+ }
+ }
+
+ private static Type[] typeArray(Class[] cls)
+ {
+ Type[] t = new Type[cls.length];
+ for (int i = 0; i < cls.length; i++)
+ {
+ t[i] = Type.getType(cls[i]);
+ }
+
+ return t;
+ }
+
+ private static String[] internalNameArray(Type[] t)
+ {
+ String[] s = new String[t.length];
+ for (int i = 0; i < t.length; i++)
+ {
+ s[i] = t[i].getInternalName();
+ }
+
+ return s;
+ }
+
+ private static String[] internalNameArray(Class[] c)
+ {
+ return internalNameArray(typeArray(c));
+ }
+
+ private static final String forName = "class$";
+
+ private static Object param(Method m, int argIndex)
+ {
+ List l = new ArrayList();
+ l.add(m);
+ l.add(new Integer(argIndex));
+ return l;
+ }
+
+ private static void generateClassForNamer(ClassVisitor cls)
+ {
+ MethodVisitor cv =
+ cls.visitMethod
+ (Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC + Opcodes.ACC_SYNTHETIC, forName,
+ Type.getMethodDescriptor
+ (Type.getType(Class.class), new Type[] { Type.getType(String.class) }),
+ null, null);
+
+ Label start = new Label();
+ cv.visitLabel(start);
+ cv.visitVarInsn(Opcodes.ALOAD, 0);
+ cv.visitMethodInsn
+ (Opcodes.INVOKESTATIC,
+ Type.getInternalName(Class.class),
+ "forName",
+ Type.getMethodDescriptor
+ (Type.getType(Class.class), new Type[] { Type.getType(String.class) }));
+ cv.visitInsn(Opcodes.ARETURN);
+
+ Label handler = new Label();
+ cv.visitLabel(handler);
+ cv.visitVarInsn(Opcodes.ASTORE, 1);
+ cv.visitTypeInsn(Opcodes.NEW, typeArg(NoClassDefFoundError.class));
+ cv.visitInsn(Opcodes.DUP);
+ cv.visitVarInsn(Opcodes.ALOAD, 1);
+ cv.visitMethodInsn
+ (Opcodes.INVOKEVIRTUAL,
+ Type.getInternalName(ClassNotFoundException.class),
+ "getMessage",
+ Type.getMethodDescriptor(Type.getType(String.class), new Type[] {}));
+ cv.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(NoClassDefFoundError.class),
+ "",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] { Type.getType(String.class) }));
+ cv.visitInsn(Opcodes.ATHROW);
+ cv.visitTryCatchBlock
+ (start, handler, handler,
+ Type.getInternalName(ClassNotFoundException.class));
+ cv.visitMaxs(-1, -1);
+ }
+
+ private void generateClassConstant(MethodVisitor cv, Class cls) {
+ if (cls.isPrimitive())
+ {
+ Class boxCls;
+ if (cls.equals(Boolean.TYPE))
+ boxCls = Boolean.class;
+ else if (cls.equals(Character.TYPE))
+ boxCls = Character.class;
+ else if (cls.equals(Byte.TYPE))
+ boxCls = Byte.class;
+ else if (cls.equals(Short.TYPE))
+ boxCls = Short.class;
+ else if (cls.equals(Integer.TYPE))
+ boxCls = Integer.class;
+ else if (cls.equals(Long.TYPE))
+ boxCls = Long.class;
+ else if (cls.equals(Float.TYPE))
+ boxCls = Float.class;
+ else if (cls.equals(Double.TYPE))
+ boxCls = Double.class;
+ else if (cls.equals(Void.TYPE))
+ boxCls = Void.class;
+ else
+ throw new IllegalArgumentException("unknown primitive type " + cls);
+
+ cv.visitFieldInsn
+ (Opcodes.GETSTATIC, Type.getInternalName(boxCls), "TYPE",
+ Type.getDescriptor(Class.class));
+ return;
+ }
+ cv.visitLdcInsn(cls.getName());
+ cv.visitMethodInsn
+ (Opcodes.INVOKESTATIC, classInternalName, forName,
+ Type.getMethodDescriptor
+ (Type.getType(Class.class),
+ new Type[] { Type.getType(String.class) }));
+ }
+
+ private void generateClassArray(MethodVisitor code, Class[] classes)
+ {
+ code.visitLdcInsn(new Integer(classes.length));
+ code.visitTypeInsn(Opcodes.ANEWARRAY, typeArg(Class.class));
+ for (int i = 0; i < classes.length; i++)
+ {
+ code.visitInsn(Opcodes.DUP);
+ code.visitLdcInsn(new Integer(i));
+ generateClassConstant(code, classes[i]);
+ code.visitInsn(Opcodes.AASTORE);
+ }
+ }
+
+ private void fillOperationArray(MethodVisitor clinit)
+ {
+ // Operations array
+ clinit.visitLdcInsn(new Integer(remotemethods.length));
+ clinit.visitTypeInsn(Opcodes.ANEWARRAY, typeArg(Operation.class));
+ clinit.visitFieldInsn
+ (Opcodes.PUTSTATIC, classInternalName, "operations",
+ Type.getDescriptor(Operation[].class));
+
+ for (int i = 0; i < remotemethods.length; i++)
+ {
+ Method m = remotemethods[i].meth;
+
+ StringBuffer desc = new StringBuffer();
+ desc.append(getPrettyName(m.getReturnType()) + " ");
+ desc.append(m.getName() + "(");
+
+ // signature
+ Class[] sig = m.getParameterTypes();
+ for (int j = 0; j < sig.length; j++)
+ {
+ desc.append(getPrettyName(sig[j]));
+ if (j + 1 < sig.length)
+ desc.append(", ");
+ }
+
+ // push operations array
+ clinit.visitFieldInsn
+ (Opcodes.GETSTATIC, classInternalName, "operations",
+ Type.getDescriptor(Operation[].class));
+
+ // push array index
+ clinit.visitLdcInsn(new Integer(i));
+
+ // instantiate operation and leave a copy on the stack
+ clinit.visitTypeInsn(Opcodes.NEW, typeArg(Operation.class));
+ clinit.visitInsn(Opcodes.DUP);
+ clinit.visitLdcInsn(desc.toString());
+ clinit.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(Operation.class),
+ "",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] { Type.getType(String.class) }));
+
+ // store in operations array
+ clinit.visitInsn(Opcodes.AASTORE);
+ }
+ }
+
+ private void generateStaticMethodObjs(MethodVisitor clinit)
+ {
+ for (int i = 0; i < remotemethods.length; i++)
+ {
+ Method m = remotemethods[i].meth;
+
+ /*
+ * $method_m.getName()_i =
+ * m.getDeclaringClass().class.getMethod
+ * (m.getName(), m.getParameterType())
+ */
+ String methodVar = "$method_" + m.getName() + "_" + i;
+ generateClassConstant(clinit, m.getDeclaringClass());
+ clinit.visitLdcInsn(m.getName());
+ generateClassArray(clinit, m.getParameterTypes());
+ clinit.visitMethodInsn
+ (Opcodes.INVOKEVIRTUAL,
+ Type.getInternalName(Class.class),
+ "getMethod",
+ Type.getMethodDescriptor
+ (Type.getType(Method.class),
+ new Type[] { Type.getType(String.class),
+ Type.getType(Class[].class) }));
+
+ clinit.visitFieldInsn
+ (Opcodes.PUTSTATIC, classInternalName, methodVar,
+ Type.getDescriptor(Method.class));
+ }
+ }
+
+ private void generateStub()
+ throws IOException
+ {
+ stubname = fullclassname + "_Stub";
+ String stubclassname = classname + "_Stub";
+ File file = new File((destination == null ? "." : destination)
+ + File.separator
+ + stubname.replace('.', File.separatorChar)
+ + ".class");
+
+ if (verbose)
+ System.out.println("[Generating class " + stubname + "]");
+
+ final ClassWriter stub = new ClassWriter(true);
+ classInternalName = stubname.replace('.', '/');
+ final String superInternalName =
+ Type.getType(RemoteStub.class).getInternalName();
+
+ String[] remoteInternalNames =
+ internalNameArray((Class[]) mRemoteInterfaces.toArray(new Class[] {}));
+ stub.visit
+ (Opcodes.V1_2, Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL, classInternalName,
+ null, superInternalName, remoteInternalNames);
+
+ if (need12Stubs)
+ {
+ stub.visitField
+ (Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC + Opcodes.ACC_FINAL, "serialVersionUID",
+ Type.LONG_TYPE.getDescriptor(), null, new Long(2L));
+ }
+
+ if (need11Stubs)
+ {
+ stub.visitField
+ (Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC + Opcodes.ACC_FINAL,
+ "interfaceHash", Type.LONG_TYPE.getDescriptor(), null,
+ new Long(RMIHashes.getInterfaceHash(clazz)));
+
+ if (need12Stubs)
+ {
+ stub.visitField
+ (Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC, "useNewInvoke",
+ Type.BOOLEAN_TYPE.getDescriptor(), null, null);
+ }
+
+ stub.visitField
+ (Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC + Opcodes.ACC_FINAL,
+ "operations", Type.getDescriptor(Operation[].class), null, null);
+ }
+
+ // Set of method references.
+ if (need12Stubs)
+ {
+ for (int i = 0; i < remotemethods.length; i++)
+ {
+ Method m = remotemethods[i].meth;
+ String slotName = "$method_" + m.getName() + "_" + i;
+ stub.visitField
+ (Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC, slotName,
+ Type.getDescriptor(Method.class), null, null);
+ }
+ }
+
+ MethodVisitor clinit = stub.visitMethod
+ (Opcodes.ACC_STATIC, "",
+ Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] {}), null, null);
+
+ if (need11Stubs)
+ {
+ fillOperationArray(clinit);
+ if (! need12Stubs)
+ clinit.visitInsn(Opcodes.RETURN);
+ }
+
+ if (need12Stubs)
+ {
+ // begin of try
+ Label begin = new Label();
+
+ // beginning of catch
+ Label handler = new Label();
+ clinit.visitLabel(begin);
+
+ // Initialize the methods references.
+ if (need11Stubs)
+ {
+ /*
+ * RemoteRef.class.getMethod("invoke", new Class[] {
+ * Remote.class, Method.class, Object[].class, long.class })
+ */
+ generateClassConstant(clinit, RemoteRef.class);
+ clinit.visitLdcInsn("invoke");
+ generateClassArray
+ (clinit, new Class[] { Remote.class, Method.class,
+ Object[].class, long.class });
+ clinit.visitMethodInsn
+ (Opcodes.INVOKEVIRTUAL,
+ Type.getInternalName(Class.class),
+ "getMethod",
+ Type.getMethodDescriptor
+ (Type.getType(Method.class),
+ new Type[] { Type.getType(String.class),
+ Type.getType(Class[].class) }));
+
+ // useNewInvoke = true
+ clinit.visitInsn(Opcodes.ICONST_1);
+ clinit.visitFieldInsn
+ (Opcodes.PUTSTATIC, classInternalName, "useNewInvoke",
+ Type.BOOLEAN_TYPE.getDescriptor());
+ }
+
+ generateStaticMethodObjs(clinit);
+
+ // jump past handler
+ clinit.visitInsn(Opcodes.RETURN);
+ clinit.visitLabel(handler);
+ if (need11Stubs)
+ {
+ // useNewInvoke = false
+ clinit.visitInsn(Opcodes.ICONST_0);
+ clinit.visitFieldInsn
+ (Opcodes.PUTSTATIC, classInternalName, "useNewInvoke",
+ Type.BOOLEAN_TYPE.getDescriptor());
+ clinit.visitInsn(Opcodes.RETURN);
+ }
+ else
+ {
+ // throw NoSuchMethodError
+ clinit.visitTypeInsn(Opcodes.NEW, typeArg(NoSuchMethodError.class));
+ clinit.visitInsn(Opcodes.DUP);
+ clinit.visitLdcInsn("stub class initialization failed");
+ clinit.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(NoSuchMethodError.class),
+ "",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type[] { Type.getType(String.class) }));
+ clinit.visitInsn(Opcodes.ATHROW);
+ }
+
+ clinit.visitTryCatchBlock
+ (begin, handler, handler,
+ Type.getInternalName(NoSuchMethodException.class));
+
+ }
+
+ clinit.visitMaxs(-1, -1);
+
+ generateClassForNamer(stub);
+
+ // Constructors
+ if (need11Stubs)
+ {
+ // no arg public constructor
+ MethodVisitor code = stub.visitMethod
+ (Opcodes.ACC_PUBLIC, "",
+ Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] {}),
+ null, null);
+ code.visitVarInsn(Opcodes.ALOAD, 0);
+ code.visitMethodInsn
+ (Opcodes.INVOKESPECIAL, superInternalName, "",
+ Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] {}));
+ code.visitInsn(Opcodes.RETURN);
+
+ code.visitMaxs(-1, -1);
+ }
+
+ // public RemoteRef constructor
+ MethodVisitor constructor = stub.visitMethod
+ (Opcodes.ACC_PUBLIC, "",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] {Type.getType(RemoteRef.class)}),
+ null, null);
+ constructor.visitVarInsn(Opcodes.ALOAD, 0);
+ constructor.visitVarInsn(Opcodes.ALOAD, 1);
+ constructor.visitMethodInsn
+ (Opcodes.INVOKESPECIAL, superInternalName, "",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] {Type.getType(RemoteRef.class)}));
+ constructor.visitInsn(Opcodes.RETURN);
+ constructor.visitMaxs(-1, -1);
+
+ // Method implementations
+ for (int i = 0; i < remotemethods.length; i++)
+ {
+ Method m = remotemethods[i].meth;
+ Class[] sig = m.getParameterTypes();
+ Class returntype = m.getReturnType();
+ Class[] except = sortExceptions
+ ((Class[]) remotemethods[i].exceptions.toArray(new Class[0]));
+
+ MethodVisitor code = stub.visitMethod
+ (Opcodes.ACC_PUBLIC,
+ m.getName(),
+ Type.getMethodDescriptor(Type.getType(returntype), typeArray(sig)),
+ null,
+ internalNameArray(typeArray(except)));
+
+ final Variables var = new Variables();
+
+ // this and parameters are the declared vars
+ var.declare("this");
+ for (int j = 0; j < sig.length; j++)
+ var.declare(param(m, j), size(sig[j]));
+
+ Label methodTryBegin = new Label();
+ code.visitLabel(methodTryBegin);
+
+ if (need12Stubs)
+ {
+ Label oldInvoke = new Label();
+ if (need11Stubs)
+ {
+ // if not useNewInvoke jump to old invoke
+ code.visitFieldInsn
+ (Opcodes.GETSTATIC, classInternalName, "useNewInvoke",
+ Type.getDescriptor(boolean.class));
+ code.visitJumpInsn(Opcodes.IFEQ, oldInvoke);
+ }
+
+ // this.ref
+ code.visitVarInsn(Opcodes.ALOAD, var.get("this"));
+ code.visitFieldInsn
+ (Opcodes.GETFIELD, Type.getInternalName(RemoteObject.class),
+ "ref", Type.getDescriptor(RemoteRef.class));
+
+ // "this" is first arg to invoke
+ code.visitVarInsn(Opcodes.ALOAD, var.get("this"));
+
+ // method object is second arg to invoke
+ String methName = "$method_" + m.getName() + "_" + i;
+ code.visitFieldInsn
+ (Opcodes.GETSTATIC, classInternalName, methName,
+ Type.getDescriptor(Method.class));
+
+ // args to remote method are third arg to invoke
+ if (sig.length == 0)
+ code.visitInsn(Opcodes.ACONST_NULL);
+ else
+ {
+ // create arg Object[] (with boxed primitives) and push it
+ code.visitLdcInsn(new Integer(sig.length));
+ code.visitTypeInsn(Opcodes.ANEWARRAY, typeArg(Object.class));
+
+ var.allocate("argArray");
+ code.visitVarInsn(Opcodes.ASTORE, var.get("argArray"));
+
+ for (int j = 0; j < sig.length; j++)
+ {
+ int size = size(sig[j]);
+ int insn = loadOpcode(sig[j]);
+ Class box = sig[j].isPrimitive() ? box(sig[j]) : null;
+
+ code.visitVarInsn(Opcodes.ALOAD, var.get("argArray"));
+ code.visitLdcInsn(new Integer(j));
+
+ // put argument on stack
+ if (box != null)
+ {
+ code.visitTypeInsn(Opcodes.NEW, typeArg(box));
+ code.visitInsn(Opcodes.DUP);
+ code.visitVarInsn(insn, var.get(param(m, j)));
+ code.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(box),
+ "",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type[] { Type.getType(sig[j]) }));
+ }
+ else
+ code.visitVarInsn(insn, var.get(param(m, j)));
+
+ code.visitInsn(Opcodes.AASTORE);
+ }
+
+ code.visitVarInsn(Opcodes.ALOAD, var.deallocate("argArray"));
+ }
+
+ // push remote operation opcode
+ code.visitLdcInsn(new Long(remotemethods[i].hash));
+ code.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteRef.class),
+ "invoke",
+ Type.getMethodDescriptor
+ (Type.getType(Object.class),
+ new Type[] { Type.getType(Remote.class),
+ Type.getType(Method.class),
+ Type.getType(Object[].class),
+ Type.LONG_TYPE }));
+
+ if (! returntype.equals(Void.TYPE))
+ {
+ int retcode = returnOpcode(returntype);
+ Class boxCls =
+ returntype.isPrimitive() ? box(returntype) : null;
+ code.visitTypeInsn
+ (Opcodes.CHECKCAST, typeArg(boxCls == null ? returntype : boxCls));
+ if (returntype.isPrimitive())
+ {
+ // unbox
+ code.visitMethodInsn
+ (Opcodes.INVOKEVIRTUAL,
+ Type.getType(boxCls).getInternalName(),
+ unboxMethod(returntype),
+ Type.getMethodDescriptor
+ (Type.getType(returntype), new Type[] {}));
+ }
+
+ code.visitInsn(retcode);
+ }
+ else
+ code.visitInsn(Opcodes.RETURN);
+
+
+ if (need11Stubs)
+ code.visitLabel(oldInvoke);
+ }
+
+ if (need11Stubs)
+ {
+
+ // this.ref.newCall(this, operations, index, interfaceHash)
+ code.visitVarInsn(Opcodes.ALOAD, var.get("this"));
+ code.visitFieldInsn
+ (Opcodes.GETFIELD,
+ Type.getInternalName(RemoteObject.class),
+ "ref",
+ Type.getDescriptor(RemoteRef.class));
+
+ // "this" is first arg to newCall
+ code.visitVarInsn(Opcodes.ALOAD, var.get("this"));
+
+ // operations is second arg to newCall
+ code.visitFieldInsn
+ (Opcodes.GETSTATIC, classInternalName, "operations",
+ Type.getDescriptor(Operation[].class));
+
+ // method index is third arg
+ code.visitLdcInsn(new Integer(i));
+
+ // interface hash is fourth arg
+ code.visitFieldInsn
+ (Opcodes.GETSTATIC, classInternalName, "interfaceHash",
+ Type.LONG_TYPE.getDescriptor());
+
+ code.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteRef.class),
+ "newCall",
+ Type.getMethodDescriptor
+ (Type.getType(RemoteCall.class),
+ new Type[] { Type.getType(RemoteObject.class),
+ Type.getType(Operation[].class),
+ Type.INT_TYPE,
+ Type.LONG_TYPE }));
+
+ // store call object on stack and leave copy on stack
+ var.allocate("call");
+ code.visitInsn(Opcodes.DUP);
+ code.visitVarInsn(Opcodes.ASTORE, var.get("call"));
+
+ Label beginArgumentTryBlock = new Label();
+ code.visitLabel(beginArgumentTryBlock);
+
+ // ObjectOutput out = call.getOutputStream();
+ code.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteCall.class),
+ "getOutputStream",
+ Type.getMethodDescriptor
+ (Type.getType(ObjectOutput.class), new Type[] {}));
+
+ for (int j = 0; j < sig.length; j++)
+ {
+ // dup the ObjectOutput
+ code.visitInsn(Opcodes.DUP);
+
+ // get j'th arg to remote method
+ code.visitVarInsn(loadOpcode(sig[j]), var.get(param(m, j)));
+
+ Class argCls =
+ sig[j].isPrimitive() ? sig[j] : Object.class;
+
+ // out.writeFoo
+ code.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(ObjectOutput.class),
+ writeMethod(sig[j]),
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type[] { Type.getType(argCls) }));
+ }
+
+ // pop ObjectOutput
+ code.visitInsn(Opcodes.POP);
+
+ Label iohandler = new Label();
+ Label endArgumentTryBlock = new Label();
+ code.visitJumpInsn(Opcodes.GOTO, endArgumentTryBlock);
+ code.visitLabel(iohandler);
+
+ // throw new MarshalException(msg, ioexception);
+ code.visitVarInsn(Opcodes.ASTORE, var.allocate("exception"));
+ code.visitTypeInsn(Opcodes.NEW, typeArg(MarshalException.class));
+ code.visitInsn(Opcodes.DUP);
+ code.visitLdcInsn("error marshalling arguments");
+ code.visitVarInsn(Opcodes.ALOAD, var.deallocate("exception"));
+ code.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(MarshalException.class),
+ "",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type[] { Type.getType(String.class),
+ Type.getType(Exception.class) }));
+ code.visitInsn(Opcodes.ATHROW);
+
+ code.visitLabel(endArgumentTryBlock);
+ code.visitTryCatchBlock
+ (beginArgumentTryBlock, iohandler, iohandler,
+ Type.getInternalName(IOException.class));
+
+ // this.ref.invoke(call)
+ code.visitVarInsn(Opcodes.ALOAD, var.get("this"));
+ code.visitFieldInsn
+ (Opcodes.GETFIELD, Type.getInternalName(RemoteObject.class),
+ "ref", Type.getDescriptor(RemoteRef.class));
+ code.visitVarInsn(Opcodes.ALOAD, var.get("call"));
+ code.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteRef.class),
+ "invoke",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type[] { Type.getType(RemoteCall.class) }));
+
+ // handle return value
+ boolean needcastcheck = false;
+
+ Label beginReturnTryCatch = new Label();
+ code.visitLabel(beginReturnTryCatch);
+
+ int returncode = returnOpcode(returntype);
+
+ if (! returntype.equals(Void.TYPE))
+ {
+ // call.getInputStream()
+ code.visitVarInsn(Opcodes.ALOAD, var.get("call"));
+ code.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteCall.class),
+ "getInputStream",
+ Type.getMethodDescriptor
+ (Type.getType(ObjectInput.class), new Type[] {}));
+
+ Class readCls =
+ returntype.isPrimitive() ? returntype : Object.class;
+ code.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(ObjectInput.class),
+ readMethod(returntype),
+ Type.getMethodDescriptor
+ (Type.getType(readCls), new Type[] {}));
+
+ boolean castresult = false;
+
+ if (! returntype.isPrimitive())
+ {
+ if (! returntype.equals(Object.class))
+ castresult = true;
+ else
+ needcastcheck = true;
+ }
+
+ if (castresult)
+ code.visitTypeInsn(Opcodes.CHECKCAST, typeArg(returntype));
+
+ // leave result on stack for return
+ }
+
+ // this.ref.done(call)
+ code.visitVarInsn(Opcodes.ALOAD, var.get("this"));
+ code.visitFieldInsn
+ (Opcodes.GETFIELD,
+ Type.getInternalName(RemoteObject.class),
+ "ref",
+ Type.getDescriptor(RemoteRef.class));
+ code.visitVarInsn(Opcodes.ALOAD, var.deallocate("call"));
+ code.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteRef.class),
+ "done",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type[] { Type.getType(RemoteCall.class) }));
+
+ // return; or return result;
+ code.visitInsn(returncode);
+
+ // exception handler
+ Label handler = new Label();
+ code.visitLabel(handler);
+ code.visitVarInsn(Opcodes.ASTORE, var.allocate("exception"));
+
+ // throw new UnmarshalException(msg, e)
+ code.visitTypeInsn(Opcodes.NEW, typeArg(UnmarshalException.class));
+ code.visitInsn(Opcodes.DUP);
+ code.visitLdcInsn("error unmarshalling return");
+ code.visitVarInsn(Opcodes.ALOAD, var.deallocate("exception"));
+ code.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(UnmarshalException.class),
+ "",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type[] { Type.getType(String.class),
+ Type.getType(Exception.class) }));
+ code.visitInsn(Opcodes.ATHROW);
+
+ Label endReturnTryCatch = new Label();
+
+ // catch IOException
+ code.visitTryCatchBlock
+ (beginReturnTryCatch, handler, handler,
+ Type.getInternalName(IOException.class));
+
+ if (needcastcheck)
+ {
+ // catch ClassNotFoundException
+ code.visitTryCatchBlock
+ (beginReturnTryCatch, handler, handler,
+ Type.getInternalName(ClassNotFoundException.class));
+ }
+ }
+
+ Label rethrowHandler = new Label();
+ code.visitLabel(rethrowHandler);
+ // rethrow declared exceptions
+ code.visitInsn(Opcodes.ATHROW);
+
+ boolean needgeneral = true;
+ for (int j = 0; j < except.length; j++)
+ {
+ if (except[j] == Exception.class)
+ needgeneral = false;
+ }
+
+ for (int j = 0; j < except.length; j++)
+ {
+ code.visitTryCatchBlock
+ (methodTryBegin, rethrowHandler, rethrowHandler,
+ Type.getInternalName(except[j]));
+ }
+
+ if (needgeneral)
+ {
+ // rethrow unchecked exceptions
+ code.visitTryCatchBlock
+ (methodTryBegin, rethrowHandler, rethrowHandler,
+ Type.getInternalName(RuntimeException.class));
+
+ Label generalHandler = new Label();
+ code.visitLabel(generalHandler);
+ String msg = "undeclared checked exception";
+
+ // throw new java.rmi.UnexpectedException(msg, e)
+ code.visitVarInsn(Opcodes.ASTORE, var.allocate("exception"));
+ code.visitTypeInsn(Opcodes.NEW, typeArg(UnexpectedException.class));
+ code.visitInsn(Opcodes.DUP);
+ code.visitLdcInsn(msg);
+ code.visitVarInsn(Opcodes.ALOAD, var.deallocate("exception"));
+ code.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(UnexpectedException.class),
+ "",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type [] { Type.getType(String.class),
+ Type.getType(Exception.class) }));
+ code.visitInsn(Opcodes.ATHROW);
+
+ code.visitTryCatchBlock
+ (methodTryBegin, rethrowHandler, generalHandler,
+ Type.getInternalName(Exception.class));
+ }
+
+ code.visitMaxs(-1, -1);
+ }
+
+ stub.visitEnd();
+ byte[] classData = stub.toByteArray();
+ if (!noWrite)
+ {
+ if (file.exists())
+ file.delete();
+ if (file.getParentFile() != null)
+ file.getParentFile().mkdirs();
+ FileOutputStream fos = new FileOutputStream(file);
+ fos.write(classData);
+ fos.flush();
+ fos.close();
+ }
+ }
+
+ private void generateSkel() throws IOException
+ {
+ skelname = fullclassname + "_Skel";
+ String skelclassname = classname + "_Skel";
+ File file = new File(destination == null ? "" : destination
+ + File.separator
+ + skelname.replace('.', File.separatorChar)
+ + ".class");
+ if (verbose)
+ System.out.println("[Generating class " + skelname + "]");
+
+ final ClassWriter skel = new ClassWriter(true);
+ classInternalName = skelname.replace('.', '/');
+ skel.visit
+ (Opcodes.V1_1, Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL,
+ classInternalName, Type.getInternalName(Object.class), null,
+ new String[] { Type.getType(Skeleton.class).getInternalName() });
+
+ skel.visitField
+ (Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC + Opcodes.ACC_FINAL, "interfaceHash",
+ Type.LONG_TYPE.getDescriptor(), null,
+ new Long(RMIHashes.getInterfaceHash(clazz)));
+
+ skel.visitField
+ (Opcodes.ACC_PRIVATE + Opcodes.ACC_STATIC + Opcodes.ACC_FINAL, "operations",
+ Type.getDescriptor(Operation[].class), null, null);
+
+ MethodVisitor clinit = skel.visitMethod
+ (Opcodes.ACC_STATIC, "",
+ Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] {}), null, null);
+
+ fillOperationArray(clinit);
+ clinit.visitInsn(Opcodes.RETURN);
+
+ clinit.visitMaxs(-1, -1);
+
+ // no arg public constructor
+ MethodVisitor init = skel.visitMethod
+ (Opcodes.ACC_PUBLIC, "",
+ Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] {}), null, null);
+ init.visitVarInsn(Opcodes.ALOAD, 0);
+ init.visitMethodInsn
+ (Opcodes.INVOKESPECIAL, Type.getInternalName(Object.class), "",
+ Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] {}));
+ init.visitInsn(Opcodes.RETURN);
+ init.visitMaxs(-1, -1);
+
+ /*
+ * public Operation[] getOperations()
+ * returns a clone of the operations array
+ */
+ MethodVisitor getOp = skel.visitMethod
+ (Opcodes.ACC_PUBLIC, "getOperations",
+ Type.getMethodDescriptor
+ (Type.getType(Operation[].class), new Type[] {}),
+ null, null);
+ getOp.visitFieldInsn
+ (Opcodes.GETSTATIC, classInternalName, "operations",
+ Type.getDescriptor(Operation[].class));
+ getOp.visitMethodInsn
+ (Opcodes.INVOKEVIRTUAL, Type.getInternalName(Object.class),
+ "clone", Type.getMethodDescriptor(Type.getType(Object.class),
+ new Type[] {}));
+ getOp.visitTypeInsn(Opcodes.CHECKCAST, typeArg(Operation[].class));
+ getOp.visitInsn(Opcodes.ARETURN);
+ getOp.visitMaxs(-1, -1);
+
+ // public void dispatch(Remote, RemoteCall, int opnum, long hash)
+ MethodVisitor dispatch = skel.visitMethod
+ (Opcodes.ACC_PUBLIC,
+ "dispatch",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE,
+ new Type[] { Type.getType(Remote.class),
+ Type.getType(RemoteCall.class),
+ Type.INT_TYPE, Type.LONG_TYPE }), null,
+ new String[] { Type.getInternalName(Exception.class) });
+
+ Variables var = new Variables();
+ var.declare("this");
+ var.declare("remoteobj");
+ var.declare("remotecall");
+ var.declare("opnum");
+ var.declareWide("hash");
+
+ /*
+ * if opnum >= 0
+ * XXX it is unclear why there is handling of negative opnums
+ */
+ dispatch.visitVarInsn(Opcodes.ILOAD, var.get("opnum"));
+ Label nonNegativeOpnum = new Label();
+ Label opnumSet = new Label();
+ dispatch.visitJumpInsn(Opcodes.IFGE, nonNegativeOpnum);
+
+ for (int i = 0; i < remotemethods.length; i++)
+ {
+ // assign opnum if hash matches supplied hash
+ dispatch.visitVarInsn(Opcodes.LLOAD, var.get("hash"));
+ dispatch.visitLdcInsn(new Long(remotemethods[i].hash));
+ Label notIt = new Label();
+ dispatch.visitInsn(Opcodes.LCMP);
+ dispatch.visitJumpInsn(Opcodes.IFNE, notIt);
+
+ // opnum =
+ dispatch.visitLdcInsn(new Integer(i));
+ dispatch.visitVarInsn(Opcodes.ISTORE, var.get("opnum"));
+ dispatch.visitJumpInsn(Opcodes.GOTO, opnumSet);
+ dispatch.visitLabel(notIt);
+ }
+
+ // throw new SkeletonMismatchException
+ Label mismatch = new Label();
+ dispatch.visitJumpInsn(Opcodes.GOTO, mismatch);
+
+ dispatch.visitLabel(nonNegativeOpnum);
+
+ // if opnum is already set, check that the hash matches the interface
+ dispatch.visitVarInsn(Opcodes.LLOAD, var.get("hash"));
+ dispatch.visitFieldInsn
+ (Opcodes.GETSTATIC, classInternalName,
+ "interfaceHash", Type.LONG_TYPE.getDescriptor());
+ dispatch.visitInsn(Opcodes.LCMP);
+ dispatch.visitJumpInsn(Opcodes.IFEQ, opnumSet);
+
+ dispatch.visitLabel(mismatch);
+ dispatch.visitTypeInsn
+ (Opcodes.NEW, typeArg(SkeletonMismatchException.class));
+ dispatch.visitInsn(Opcodes.DUP);
+ dispatch.visitLdcInsn("interface hash mismatch");
+ dispatch.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(SkeletonMismatchException.class),
+ "",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] { Type.getType(String.class) }));
+ dispatch.visitInsn(Opcodes.ATHROW);
+
+ // opnum has been set
+ dispatch.visitLabel(opnumSet);
+
+ dispatch.visitVarInsn(Opcodes.ALOAD, var.get("remoteobj"));
+ dispatch.visitTypeInsn(Opcodes.CHECKCAST, typeArg(clazz));
+ dispatch.visitVarInsn(Opcodes.ASTORE, var.get("remoteobj"));
+
+ Label deflt = new Label();
+ Label[] methLabels = new Label[remotemethods.length];
+ for (int i = 0; i < methLabels.length; i++)
+ methLabels[i] = new Label();
+
+ // switch on opnum
+ dispatch.visitVarInsn(Opcodes.ILOAD, var.get("opnum"));
+ dispatch.visitTableSwitchInsn
+ (0, remotemethods.length - 1, deflt, methLabels);
+
+ // Method dispatch
+ for (int i = 0; i < remotemethods.length; i++)
+ {
+ dispatch.visitLabel(methLabels[i]);
+ Method m = remotemethods[i].meth;
+ generateMethodSkel(dispatch, m, var);
+ }
+
+ dispatch.visitLabel(deflt);
+ dispatch.visitTypeInsn(Opcodes.NEW, typeArg(UnmarshalException.class));
+ dispatch.visitInsn(Opcodes.DUP);
+ dispatch.visitLdcInsn("invalid method number");
+ dispatch.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(UnmarshalException.class),
+ "",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] { Type.getType(String.class) }));
+ dispatch.visitInsn(Opcodes.ATHROW);
+
+ dispatch.visitMaxs(-1, -1);
+
+ skel.visitEnd();
+ byte[] classData = skel.toByteArray();
+ if (!noWrite)
+ {
+ if (file.exists())
+ file.delete();
+ if (file.getParentFile() != null)
+ file.getParentFile().mkdirs();
+ FileOutputStream fos = new FileOutputStream(file);
+ fos.write(classData);
+ fos.flush();
+ fos.close();
+ }
+ }
+
+ private void generateMethodSkel(MethodVisitor cv, Method m, Variables var)
+ {
+ Class[] sig = m.getParameterTypes();
+
+ Label readArgs = new Label();
+ cv.visitLabel(readArgs);
+
+ boolean needcastcheck = false;
+
+ // ObjectInput in = call.getInputStream();
+ cv.visitVarInsn(Opcodes.ALOAD, var.get("remotecall"));
+ cv.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteCall.class), "getInputStream",
+ Type.getMethodDescriptor
+ (Type.getType(ObjectInput.class), new Type[] {}));
+ cv.visitVarInsn(Opcodes.ASTORE, var.allocate("objectinput"));
+
+ for (int i = 0; i < sig.length; i++)
+ {
+ // dup input stream
+ cv.visitVarInsn(Opcodes.ALOAD, var.get("objectinput"));
+
+ Class readCls = sig[i].isPrimitive() ? sig[i] : Object.class;
+
+ // in.readFoo()
+ cv.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(ObjectInput.class),
+ readMethod(sig[i]),
+ Type.getMethodDescriptor
+ (Type.getType(readCls), new Type [] {}));
+
+ if (! sig[i].isPrimitive() && ! sig[i].equals(Object.class))
+ {
+ needcastcheck = true;
+ cv.visitTypeInsn(Opcodes.CHECKCAST, typeArg(sig[i]));
+ }
+
+ // store arg in variable
+ cv.visitVarInsn
+ (storeOpcode(sig[i]), var.allocate(param(m, i), size(sig[i])));
+ }
+
+ var.deallocate("objectinput");
+
+ Label doCall = new Label();
+ Label closeInput = new Label();
+
+ cv.visitJumpInsn(Opcodes.JSR, closeInput);
+ cv.visitJumpInsn(Opcodes.GOTO, doCall);
+
+ // throw new UnmarshalException
+ Label handler = new Label();
+ cv.visitLabel(handler);
+ cv.visitVarInsn(Opcodes.ASTORE, var.allocate("exception"));
+ cv.visitTypeInsn(Opcodes.NEW, typeArg(UnmarshalException.class));
+ cv.visitInsn(Opcodes.DUP);
+ cv.visitLdcInsn("error unmarshalling arguments");
+ cv.visitVarInsn(Opcodes.ALOAD, var.deallocate("exception"));
+ cv.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(UnmarshalException.class),
+ "",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] { Type.getType(String.class),
+ Type.getType(Exception.class) }));
+ cv.visitVarInsn(Opcodes.ASTORE, var.allocate("toThrow"));
+ cv.visitJumpInsn(Opcodes.JSR, closeInput);
+ cv.visitVarInsn(Opcodes.ALOAD, var.get("toThrow"));
+ cv.visitInsn(Opcodes.ATHROW);
+
+ cv.visitTryCatchBlock
+ (readArgs, handler, handler, Type.getInternalName(IOException.class));
+ if (needcastcheck)
+ {
+ cv.visitTryCatchBlock
+ (readArgs, handler, handler,
+ Type.getInternalName(ClassCastException.class));
+ }
+
+ // finally block
+ cv.visitLabel(closeInput);
+ cv.visitVarInsn(Opcodes.ASTORE, var.allocate("retAddress"));
+ cv.visitVarInsn(Opcodes.ALOAD, var.get("remotecall"));
+ cv.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteCall.class),
+ "releaseInputStream",
+ Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] {}));
+ cv.visitVarInsn(Opcodes.RET, var.deallocate("retAddress"));
+ var.deallocate("toThrow");
+
+ // do the call using args stored as variables
+ cv.visitLabel(doCall);
+ cv.visitVarInsn(Opcodes.ALOAD, var.get("remoteobj"));
+ for (int i = 0; i < sig.length; i++)
+ cv.visitVarInsn(loadOpcode(sig[i]), var.deallocate(param(m, i)));
+ cv.visitMethodInsn
+ (Opcodes.INVOKEVIRTUAL, Type.getInternalName(clazz), m.getName(),
+ Type.getMethodDescriptor(m));
+
+ Class returntype = m.getReturnType();
+ if (! returntype.equals(Void.TYPE))
+ {
+ cv.visitVarInsn
+ (storeOpcode(returntype), var.allocate("result", size(returntype)));
+ }
+
+ // write result to result stream
+ Label writeResult = new Label();
+ cv.visitLabel(writeResult);
+ cv.visitVarInsn(Opcodes.ALOAD, var.get("remotecall"));
+ cv.visitInsn(Opcodes.ICONST_1);
+ cv.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(RemoteCall.class),
+ "getResultStream",
+ Type.getMethodDescriptor
+ (Type.getType(ObjectOutput.class),
+ new Type[] { Type.BOOLEAN_TYPE }));
+
+ if (! returntype.equals(Void.TYPE))
+ {
+ // out.writeFoo(result)
+ cv.visitVarInsn(loadOpcode(returntype), var.deallocate("result"));
+ Class writeCls = returntype.isPrimitive() ? returntype : Object.class;
+ cv.visitMethodInsn
+ (Opcodes.INVOKEINTERFACE,
+ Type.getInternalName(ObjectOutput.class),
+ writeMethod(returntype),
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] { Type.getType(writeCls) }));
+ }
+
+ cv.visitInsn(Opcodes.RETURN);
+
+ // throw new MarshalException
+ Label marshalHandler = new Label();
+ cv.visitLabel(marshalHandler);
+ cv.visitVarInsn(Opcodes.ASTORE, var.allocate("exception"));
+ cv.visitTypeInsn(Opcodes.NEW, typeArg(MarshalException.class));
+ cv.visitInsn(Opcodes.DUP);
+ cv.visitLdcInsn("error marshalling return");
+ cv.visitVarInsn(Opcodes.ALOAD, var.deallocate("exception"));
+ cv.visitMethodInsn
+ (Opcodes.INVOKESPECIAL,
+ Type.getInternalName(MarshalException.class),
+ "",
+ Type.getMethodDescriptor
+ (Type.VOID_TYPE, new Type[] { Type.getType(String.class),
+ Type.getType(Exception.class) }));
+ cv.visitInsn(Opcodes.ATHROW);
+ cv.visitTryCatchBlock
+ (writeResult, marshalHandler, marshalHandler,
+ Type.getInternalName(IOException.class));
+ }
+
+ private static String typeArg(Class cls)
+ {
+ if (cls.isArray())
+ return Type.getDescriptor(cls);
+
+ return Type.getInternalName(cls);
+ }
+
+ private static String readMethod(Class cls)
+ {
+ if (cls.equals(Void.TYPE))
+ throw new IllegalArgumentException("can not read void");
+
+ String method;
+ if (cls.equals(Boolean.TYPE))
+ method = "readBoolean";
+ else if (cls.equals(Byte.TYPE))
+ method = "readByte";
+ else if (cls.equals(Character.TYPE))
+ method = "readChar";
+ else if (cls.equals(Short.TYPE))
+ method = "readShort";
+ else if (cls.equals(Integer.TYPE))
+ method = "readInt";
+ else if (cls.equals(Long.TYPE))
+ method = "readLong";
+ else if (cls.equals(Float.TYPE))
+ method = "readFloat";
+ else if (cls.equals(Double.TYPE))
+ method = "readDouble";
+ else
+ method = "readObject";
+
+ return method;
+ }
+
+ private static String writeMethod(Class cls)
+ {
+ if (cls.equals(Void.TYPE))
+ throw new IllegalArgumentException("can not read void");
+
+ String method;
+ if (cls.equals(Boolean.TYPE))
+ method = "writeBoolean";
+ else if (cls.equals(Byte.TYPE))
+ method = "writeByte";
+ else if (cls.equals(Character.TYPE))
+ method = "writeChar";
+ else if (cls.equals(Short.TYPE))
+ method = "writeShort";
+ else if (cls.equals(Integer.TYPE))
+ method = "writeInt";
+ else if (cls.equals(Long.TYPE))
+ method = "writeLong";
+ else if (cls.equals(Float.TYPE))
+ method = "writeFloat";
+ else if (cls.equals(Double.TYPE))
+ method = "writeDouble";
+ else
+ method = "writeObject";
+
+ return method;
+ }
+
+ private static int returnOpcode(Class cls)
+ {
+ int returncode;
+ if (cls.equals(Boolean.TYPE))
+ returncode = Opcodes.IRETURN;
+ else if (cls.equals(Byte.TYPE))
+ returncode = Opcodes.IRETURN;
+ else if (cls.equals(Character.TYPE))
+ returncode = Opcodes.IRETURN;
+ else if (cls.equals(Short.TYPE))
+ returncode = Opcodes.IRETURN;
+ else if (cls.equals(Integer.TYPE))
+ returncode = Opcodes.IRETURN;
+ else if (cls.equals(Long.TYPE))
+ returncode = Opcodes.LRETURN;
+ else if (cls.equals(Float.TYPE))
+ returncode = Opcodes.FRETURN;
+ else if (cls.equals(Double.TYPE))
+ returncode = Opcodes.DRETURN;
+ else if (cls.equals(Void.TYPE))
+ returncode = Opcodes.RETURN;
+ else
+ returncode = Opcodes.ARETURN;
+
+ return returncode;
+ }
+
+ private static int loadOpcode(Class cls)
+ {
+ if (cls.equals(Void.TYPE))
+ throw new IllegalArgumentException("can not load void");
+
+ int loadcode;
+ if (cls.equals(Boolean.TYPE))
+ loadcode = Opcodes.ILOAD;
+ else if (cls.equals(Byte.TYPE))
+ loadcode = Opcodes.ILOAD;
+ else if (cls.equals(Character.TYPE))
+ loadcode = Opcodes.ILOAD;
+ else if (cls.equals(Short.TYPE))
+ loadcode = Opcodes.ILOAD;
+ else if (cls.equals(Integer.TYPE))
+ loadcode = Opcodes.ILOAD;
+ else if (cls.equals(Long.TYPE))
+ loadcode = Opcodes.LLOAD;
+ else if (cls.equals(Float.TYPE))
+ loadcode = Opcodes.FLOAD;
+ else if (cls.equals(Double.TYPE))
+ loadcode = Opcodes.DLOAD;
+ else
+ loadcode = Opcodes.ALOAD;
+
+ return loadcode;
+ }
+
+ private static int storeOpcode(Class cls)
+ {
+ if (cls.equals(Void.TYPE))
+ throw new IllegalArgumentException("can not load void");
+
+ int storecode;
+ if (cls.equals(Boolean.TYPE))
+ storecode = Opcodes.ISTORE;
+ else if (cls.equals(Byte.TYPE))
+ storecode = Opcodes.ISTORE;
+ else if (cls.equals(Character.TYPE))
+ storecode = Opcodes.ISTORE;
+ else if (cls.equals(Short.TYPE))
+ storecode = Opcodes.ISTORE;
+ else if (cls.equals(Integer.TYPE))
+ storecode = Opcodes.ISTORE;
+ else if (cls.equals(Long.TYPE))
+ storecode = Opcodes.LSTORE;
+ else if (cls.equals(Float.TYPE))
+ storecode = Opcodes.FSTORE;
+ else if (cls.equals(Double.TYPE))
+ storecode = Opcodes.DSTORE;
+ else
+ storecode = Opcodes.ASTORE;
+
+ return storecode;
+ }
+
+ private static String unboxMethod(Class primitive)
+ {
+ if (! primitive.isPrimitive())
+ throw new IllegalArgumentException("can not unbox nonprimitive");
+
+ String method;
+ if (primitive.equals(Boolean.TYPE))
+ method = "booleanValue";
+ else if (primitive.equals(Byte.TYPE))
+ method = "byteValue";
+ else if (primitive.equals(Character.TYPE))
+ method = "charValue";
+ else if (primitive.equals(Short.TYPE))
+ method = "shortValue";
+ else if (primitive.equals(Integer.TYPE))
+ method = "intValue";
+ else if (primitive.equals(Long.TYPE))
+ method = "longValue";
+ else if (primitive.equals(Float.TYPE))
+ method = "floatValue";
+ else if (primitive.equals(Double.TYPE))
+ method = "doubleValue";
+ else
+ throw new IllegalStateException("unknown primitive class " + primitive);
+
+ return method;
+ }
+
+ public static Class box(Class cls)
+ {
+ if (! cls.isPrimitive())
+ throw new IllegalArgumentException("can only box primitive");
+
+ Class box;
+ if (cls.equals(Boolean.TYPE))
+ box = Boolean.class;
+ else if (cls.equals(Byte.TYPE))
+ box = Byte.class;
+ else if (cls.equals(Character.TYPE))
+ box = Character.class;
+ else if (cls.equals(Short.TYPE))
+ box = Short.class;
+ else if (cls.equals(Integer.TYPE))
+ box = Integer.class;
+ else if (cls.equals(Long.TYPE))
+ box = Long.class;
+ else if (cls.equals(Float.TYPE))
+ box = Float.class;
+ else if (cls.equals(Double.TYPE))
+ box = Double.class;
+ else
+ throw new IllegalStateException("unknown primitive type " + cls);
+
+ return box;
+ }
+
+ private static int size(Class cls) {
+ if (cls.equals(Long.TYPE) || cls.equals(Double.TYPE))
+ return 2;
+ else
+ return 1;
+ }
+
+ /**
+ * Sort exceptions so the most general go last.
+ */
+ private Class[] sortExceptions(Class[] except)
+ {
+ for (int i = 0; i < except.length; i++)
+ {
+ for (int j = i + 1; j < except.length; j++)
+ {
+ if (except[i].isAssignableFrom(except[j]))
+ {
+ Class tmp = except[i];
+ except[i] = except[j];
+ except[j] = tmp;
+ }
+ }
+ }
+ return (except);
+ }
+
+ public void setup(boolean keep, boolean need11Stubs, boolean need12Stubs,
+ boolean iiop, boolean poa, boolean debug, boolean warnings,
+ boolean noWrite, boolean verbose, boolean force, String classpath,
+ String bootclasspath, String extdirs, String outputDirectory)
+ {
+ this.keep = keep;
+ this.need11Stubs = need11Stubs;
+ this.need12Stubs = need12Stubs;
+ this.verbose = verbose;
+ this.noWrite = noWrite;
+
+ // Set up classpath.
+ this.classpath = classpath;
+ StringTokenizer st =
+ new StringTokenizer(classpath, File.pathSeparator);
+ URL[] u = new URL[st.countTokens()];
+ for (int i = 0; i < u.length; i++)
+ {
+ String path = st.nextToken();
+ File f = new File(path);
+ try
+ {
+ u[i] = f.toURL();
+ }
+ catch (java.net.MalformedURLException mue)
+ {
+ logError("malformed classpath component " + path);
+ return;
+ }
+ }
+ loader = new URLClassLoader(u);
+
+ destination = outputDirectory;
+ }
+
+ private void findRemoteMethods()
+ throws RMICException
+ {
+ List rmeths = new ArrayList();
+ for (Class cur = clazz; cur != null; cur = cur.getSuperclass())
+ {
+ Class[] interfaces = cur.getInterfaces();
+ for (int i = 0; i < interfaces.length; i++)
+ {
+ if (java.rmi.Remote.class.isAssignableFrom(interfaces[i]))
+ {
+ Class remoteInterface = interfaces[i];
+ if (verbose)
+ System.out.println
+ ("[implements " + remoteInterface.getName() + "]");
+
+ // check if the methods declare RemoteExceptions
+ Method[] meths = remoteInterface.getMethods();
+ for (int j = 0; j < meths.length; j++)
+ {
+ Method m = meths[j];
+ Class[] exs = m.getExceptionTypes();
+
+ boolean throwsRemote = false;
+ for (int k = 0; k < exs.length; k++)
+ {
+ if (exs[k].isAssignableFrom(RemoteException.class))
+ throwsRemote = true;
+ }
+
+ if (! throwsRemote)
+ {
+ throw new RMICException
+ ("Method " + m + " in interface " + remoteInterface
+ + " does not throw a RemoteException");
+ }
+
+ rmeths.add(m);
+ }
+
+ mRemoteInterfaces.add(remoteInterface);
+ }
+ }
+ }
+
+ // intersect exceptions for doubly inherited methods
+ boolean[] skip = new boolean[rmeths.size()];
+ for (int i = 0; i < skip.length; i++)
+ skip[i] = false;
+ List methrefs = new ArrayList();
+ for (int i = 0; i < rmeths.size(); i++)
+ {
+ if (skip[i]) continue;
+ Method current = (Method) rmeths.get(i);
+ MethodRef ref = new MethodRef(current);
+ for (int j = i+1; j < rmeths.size(); j++)
+ {
+ Method other = (Method) rmeths.get(j);
+ if (ref.isMatch(other))
+ {
+ ref.intersectExceptions(other);
+ skip[j] = true;
+ }
+ }
+ methrefs.add(ref);
+ }
+
+ // Convert into a MethodRef array and sort them
+ remotemethods = (MethodRef[])
+ methrefs.toArray(new MethodRef[methrefs.size()]);
+ Arrays.sort(remotemethods);
+ }
+
+ /**
+ * Prints an error to System.err and increases the error count.
+ */
+ private void logError(Exception theError)
+ {
+ logError(theError.getMessage());
+ if (verbose)
+ theError.printStackTrace(System.err);
+ }
+
+ /**
+ * Prints an error to System.err and increases the error count.
+ */
+ private void logError(String theError)
+ {
+ errorCount++;
+ System.err.println("error: " + theError);
+ }
+
+ private static String getPrettyName(Class cls)
+ {
+ StringBuffer str = new StringBuffer();
+ for (int count = 0;; count++)
+ {
+ if (! cls.isArray())
+ {
+ str.append(cls.getName());
+ for (; count > 0; count--)
+ str.append("[]");
+ return (str.toString());
+ }
+ cls = cls.getComponentType();
+ }
+ }
+
+ private static class MethodRef
+ implements Comparable
+ {
+ Method meth;
+ long hash;
+ List exceptions;
+ private String sig;
+
+ MethodRef(Method m) {
+ meth = m;
+ sig = Type.getMethodDescriptor(meth);
+ hash = RMIHashes.getMethodHash(m);
+ // add exceptions removing subclasses
+ exceptions = removeSubclasses(m.getExceptionTypes());
+ }
+
+ public int compareTo(Object obj) {
+ MethodRef that = (MethodRef) obj;
+ int name = this.meth.getName().compareTo(that.meth.getName());
+ if (name == 0) {
+ return this.sig.compareTo(that.sig);
+ }
+ return name;
+ }
+
+ public boolean isMatch(Method m)
+ {
+ if (!meth.getName().equals(m.getName()))
+ return false;
+
+ Class[] params1 = meth.getParameterTypes();
+ Class[] params2 = m.getParameterTypes();
+ if (params1.length != params2.length)
+ return false;
+
+ for (int i = 0; i < params1.length; i++)
+ if (!params1[i].equals(params2[i])) return false;
+
+ return true;
+ }
+
+ private static List removeSubclasses(Class[] classes)
+ {
+ List list = new ArrayList();
+ for (int i = 0; i < classes.length; i++)
+ {
+ Class candidate = classes[i];
+ boolean add = true;
+ for (int j = 0; j < classes.length; j++)
+ {
+ if (classes[j].equals(candidate))
+ continue;
+ else if (classes[j].isAssignableFrom(candidate))
+ add = false;
+ }
+ if (add) list.add(candidate);
+ }
+
+ return list;
+ }
+
+ public void intersectExceptions(Method m)
+ {
+ List incoming = removeSubclasses(m.getExceptionTypes());
+
+ List updated = new ArrayList();
+
+ for (int i = 0; i < exceptions.size(); i++)
+ {
+ Class outer = (Class) exceptions.get(i);
+ boolean addOuter = false;
+ for (int j = 0; j < incoming.size(); j++)
+ {
+ Class inner = (Class) incoming.get(j);
+
+ if (inner.equals(outer) || inner.isAssignableFrom(outer))
+ addOuter = true;
+ else if (outer.isAssignableFrom(inner))
+ updated.add(inner);
+ }
+
+ if (addOuter)
+ updated.add(outer);
+ }
+
+ exceptions = updated;
+ }
+ }
+}
diff --git a/tools/gnu/classpath/tools/rmic/CompilationError.java b/tools/gnu/classpath/tools/rmic/CompilationError.java
new file mode 100644
index 000000000..176a09598
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmic/CompilationError.java
@@ -0,0 +1,52 @@
+/* CompilationError.java -- Thrown on compilation error.
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+package gnu.classpath.tools.rmic;
+
+/**
+ * This error is thrown when the target being compiled has illegal
+ * strutures.
+ *
+ * @author Audrius Meskauskas, Lithuania (audriusa@Bioinformatics.org)
+ */
+public class CompilationError extends Error
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * Create error with explaining message and cause.
+ */
+ public CompilationError(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ /**
+ * Create error with explaining message
+ */
+ public CompilationError(String message)
+ {
+ super(message);
+ }
+}
diff --git a/tools/gnu/classpath/tools/rmic/Generator.java b/tools/gnu/classpath/tools/rmic/Generator.java
new file mode 100644
index 000000000..64eb2eaf6
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmic/Generator.java
@@ -0,0 +1,128 @@
+/* Generator.java -- Generic code generator.
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+package gnu.classpath.tools.rmic;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * Contains basic methods, used in code generation.
+ *
+ * @author Audrius Meskauskas, Lithuania (audriusa@Bioinformatics.org)
+ */
+public class Generator
+{
+ /**
+ * Get resource with the given name, as string.
+ *
+ * @param name the resource name
+ * @return the resourse string (in subfolder /templates).
+ */
+ public String getResource(String name)
+ {
+ String resourcePath = "templates/" + name;
+ InputStream in = getClass().getResourceAsStream(resourcePath);
+
+ if (in == null)
+ throw new InternalError(getClass().getName() + ": no resource "
+ + resourcePath);
+
+ BufferedReader r = new BufferedReader(new InputStreamReader(in));
+ StringBuffer b = new StringBuffer();
+
+ String s;
+ try
+ {
+ while ((s = r.readLine()) != null)
+ {
+ b.append(s);
+ b.append('\n');
+ }
+ r.close();
+ }
+ catch (IOException e)
+ {
+ InternalError ierr = new InternalError("No expected resource " + name);
+ ierr.initCause(e);
+ throw ierr;
+ }
+
+ return b.toString();
+ }
+
+ /**
+ * Replace the variable references (starting from #) in the template string by
+ * the values, present in the given map. The strings, not present in the
+ * variable map, are ignored.
+ *
+ * @param template
+ * the template string
+ * @param variables
+ * the map of variables (name to value) to replace.
+ * @return the string with replaced values.
+ */
+ public String replaceAll(String template, Map variables)
+ {
+ BufferedReader r = new BufferedReader(new StringReader(template));
+ String s;
+ StringBuffer b = new StringBuffer(template.length());
+ try
+ {
+ Iterator iter;
+ Collection vars = variables.keySet();
+ while ((s = r.readLine()) != null)
+ {
+ // At least one variable must appear in the string to make
+ // the string scan sensible.
+ if (s.indexOf('#') >= 0)
+ {
+ iter = vars.iterator();
+ String variable;
+ while (iter.hasNext())
+ {
+ variable = (String) iter.next();
+ if (s.indexOf(variable) >= 0)
+ s = s.replaceAll(variable,
+ (String) variables.get(variable));
+ }
+ }
+ b.append(s);
+ b.append('\n');
+ }
+ r.close();
+ }
+ catch (IOException e)
+ {
+ // This should never happen.
+ InternalError ierr = new InternalError("");
+ ierr.initCause(e);
+ throw ierr;
+ }
+ return b.toString();
+ }
+}
diff --git a/tools/gnu/classpath/tools/rmic/GiopIo.java b/tools/gnu/classpath/tools/rmic/GiopIo.java
new file mode 100644
index 000000000..0d77d1a78
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmic/GiopIo.java
@@ -0,0 +1,112 @@
+/* GiopIo.java -- Generates GIOP input/output statements.
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+package gnu.classpath.tools.rmic;
+
+import java.rmi.Remote;
+
+import org.omg.CORBA.portable.ObjectImpl;
+
+/**
+ * Generates the code for reading and writing data over GIOP stream.
+ *
+ * @author Audrius Meskauskas, Lithuania (audriusa@Bioinformatics.org)
+ */
+public class GiopIo
+{
+ /**
+ * Get the statement for writing the variable of the given type to the GIOP ({@link org.omg.CORBA_2_3.portable.OutputStream) stream. The
+ * stream is always named "out".
+ *
+ * @param c
+ * the class of the object being written
+ * @param variable
+ * the variable, where the object value is stored
+ * @param r
+ * the parent generator, used to name the class
+ * @return the write statement.
+ */
+ public static String getWriteStatement(Class c, String variable, SourceGiopRmicCompiler r)
+ {
+ if (c.equals(boolean.class))
+ return "out.write_boolean(" + variable + ");";
+ if (c.equals(byte.class))
+ return "out.write_octet(" + variable + ");";
+ else if (c.equals(short.class))
+ return "out.write_int(" + variable + ");";
+ else if (c.equals(int.class))
+ return "out.write_long(" + variable + ");";
+ else if (c.equals(long.class))
+ return "out.write_long_long(" + variable + ");";
+ else if (c.equals(double.class))
+ return "out.write_double(" + variable + ");";
+ else if (c.equals(float.class))
+ return "out.write_float(" + variable + ");";
+ else if (c.equals(char.class))
+ return "out.write_char(" + variable + ");";
+ else if (Remote.class.isAssignableFrom(c))
+ return "Util.writeRemoteObject(out, " + variable + ");";
+ else if (ObjectImpl.class.isAssignableFrom(c))
+ return "out.write_Object(" + variable + ");";
+ else
+ return "out.write_value(" + variable + ", " + r.name(c) + ".class);";
+ }
+
+ /**
+ * Get the statement for reading the value of the given type from to the GIOP ({@link org.omg.CORBA_2_3.portable.InputStream) stream. The
+ * stream is always named "in".
+ *
+ * @param c
+ * the class of the object being written
+ * @param r
+ * the parent generator, used to name the class
+ * @return the right side of the read statement.
+ */
+ public static String getReadStatement(Class c, SourceGiopRmicCompiler r)
+ {
+ if (c.equals(boolean.class))
+ return "in.read_boolean();";
+ else if (c.equals(byte.class))
+ return "in.read_octet();";
+ else if (c.equals(short.class))
+ return "in.read_int();";
+ else if (c.equals(int.class))
+ return "in.read_long();";
+ else if (c.equals(long.class))
+ return "in.read_long_long();";
+ else if (c.equals(double.class))
+ return "in.read_double();";
+ else if (c.equals(float.class))
+ return "in.read_float();";
+ else if (c.equals(char.class))
+ return "in.read_char();";
+ else if (Remote.class.isAssignableFrom(c))
+ return "(" + r.name(c)
+ + ") PortableRemoteObject.narrow(in.read_Object()," + r.name(c)
+ + ".class);";
+ else if (ObjectImpl.class.isAssignableFrom(c))
+ return "in.read_Object();";
+ else
+ return "(" + r.name(c)
+ + ") in.read_value(" + r.name(c) + ".class);";
+ }
+
+}
diff --git a/tools/gnu/classpath/tools/rmic/HashFinder.java b/tools/gnu/classpath/tools/rmic/HashFinder.java
new file mode 100644
index 000000000..cf4d67f0c
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmic/HashFinder.java
@@ -0,0 +1,84 @@
+/* HashFinder.java -- finds the hash character.
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+
+package gnu.classpath.tools.rmic;
+
+import java.util.HashSet;
+
+/**
+ * This class finds the hash character (the most different character in
+ * the passed array of strings). This character is used to accelerate the
+ * method invocation by name.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class HashFinder
+{
+ /**
+ * Find the hash char position in the given collection of strings.
+ *
+ * @param strings the string collection
+ *
+ * @return the optimal hash character position, always less then the
+ * length of the shortest string.
+ */
+ public int findHashCharPosition(String[] strings)
+ {
+ // Find the length of the shortest string:
+
+ int l = strings[0].length();
+ for (int i = 1; i < strings.length; i++)
+ {
+ if (strings[i].length() < l)
+ l = strings[i].length();
+ }
+
+ // Find the position with the smallest number of the matching characters:
+ HashSet[] charLists = new HashSet[l];
+
+ for (int i = 0; i < charLists.length; i++)
+ {
+ charLists[i] = new HashSet(strings.length);
+ }
+
+ for (int i = 0; i < strings.length; i++)
+ for (int p = 0; p < l; p++)
+ {
+ charLists[p].add(new Integer(strings[i].charAt(p)));
+ }
+
+ int m = 0;
+ int v = charLists[0].size();
+
+ for (int i = 1; i < charLists.length; i++)
+ {
+ // Replace on equality also, seeking the hash char closer to the end
+ // of line.
+ if (charLists[i].size()>=v)
+ {
+ m = i;
+ v = charLists[i].size();
+ }
+ }
+ return m;
+ }
+}
diff --git a/tools/gnu/classpath/tools/rmic/Main.java b/tools/gnu/classpath/tools/rmic/Main.java
new file mode 100644
index 000000000..12d1fa20e
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmic/Main.java
@@ -0,0 +1,282 @@
+/* Main.java -- RMI stub generator.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+package gnu.classpath.tools.rmic;
+
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.FileArgumentCallback;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+
+/**
+ * Generates the ordinary stubs (not GIOP based) for java.rmi.* package.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class Main
+{
+ private boolean noWrite;
+ private boolean warnings = true;
+ private boolean verbose;
+ private boolean force;
+ private String classpath = ".";
+ private String outputDirectory = ".";
+ private boolean poa;
+ private boolean need11Stubs = false;
+ private boolean need12Stubs = true;
+ private boolean keep;
+ private boolean iiop;
+ /**
+ * Specifies whether or not JRMP mode was explicitly requested.
+ */
+ private boolean jrmp;
+
+ private Parser initializeParser()
+ {
+ Parser parser = new ClasspathToolParser("rmic", true); //$NON-NLS-1$
+ parser.setHeader(Messages.getString("Main.Usage")); //$NON-NLS-1$
+
+ parser.add(new Option("nowarn", //$NON-NLS-1$
+ Messages.getString("Main.NoWarn")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ warnings = false;
+ }
+ });
+ parser.add(new Option("nowrite", //$NON-NLS-1$
+ Messages.getString("Main.NoWrite")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ noWrite = true;
+ }
+ });
+ parser.add(new Option("verbose", //$NON-NLS-1$
+ Messages.getString("Main.Verbose")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ verbose = true;
+ }
+ });
+ parser.add(new Option("d", //$NON-NLS-1$
+ Messages.getString("Main.DirOpt"), //$NON-NLS-1$
+ Messages.getString("Main.DirArg")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ outputDirectory = argument;
+ }
+ });
+ parser.add(new Option("classpath", //$NON-NLS-1$
+ Messages.getString("Main.ClasspathOpt"), //$NON-NLS-1$
+ Messages.getString("Main.ClasspathArg")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ classpath = argument;
+ }
+ });
+ parser.add(new Option("bootclasspath", //$NON-NLS-1$
+ Messages.getString("Main.BootclasspathOpt"), //$NON-NLS-1$
+ Messages.getString("Main.BootclasspathArg")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ }
+ });
+ parser.add(new Option("extdirs", //$NON-NLS-1$
+ Messages.getString("Main.ExtdirsOpt"), //$NON-NLS-1$
+ Messages.getString("Main.ExtdirsArg")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ }
+ });
+ parser.add(new Option("iiop", //$NON-NLS-1$
+ Messages.getString("Main.IIOP")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ iiop = true;
+ }
+ });
+ parser.add(new Option("always", //$NON-NLS-1$
+ Messages.getString("Main.Always")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ force = true;
+ }
+ });
+ parser.add(new Option("alwaysgenerate", //$NON-NLS-1$
+ Messages.getString("Main.AlwaysGenerate")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ force = true;
+ }
+ });
+ parser.add(new Option("nolocalstubs", //$NON-NLS-1$
+ Messages.getString("Main.NoLocalStubs")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ }
+ });
+ parser.add(new Option("poa", //$NON-NLS-1$
+ Messages.getString("Main.POA")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ poa = true;
+ }
+ });
+ parser.add(new Option("keep", //$NON-NLS-1$
+ Messages.getString("Main.Keep")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ keep = true;
+ }
+ });
+ parser.add(new Option("keepgenerated", //$NON-NLS-1$
+ Messages.getString("Main.KeepGenerated")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ keep = true;
+ }
+ });
+ parser.add(new Option("v1.1", //$NON-NLS-1$
+ Messages.getString("Main.v11")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ need11Stubs = true;
+ need12Stubs = false;
+ jrmp = true;
+ }
+ });
+ parser.add(new Option("v1.2", //$NON-NLS-1$
+ Messages.getString("Main.v12")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ jrmp = true;
+ }
+ });
+ parser.add(new Option("vcompat", //$NON-NLS-1$
+ Messages.getString("Main.vcompat")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ need11Stubs = true;
+ need12Stubs = true;
+ jrmp = true;
+ }
+ });
+ parser.add(new Option("g", //$NON-NLS-1$
+ Messages.getString("Main.DebugInfo")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ }
+ });
+
+ return parser;
+ }
+
+ private void run(String[] args)
+ {
+ Parser p = initializeParser();
+ String[] files = p.parse(args);
+
+ if (files.length == 0)
+ {
+ p.printHelp();
+ System.exit(1);
+ }
+
+ ArrayList backends = new ArrayList();
+
+ // FIXME: need an IDL RmicBackend
+ // FIXME: need a ClassGiopRmicCompiler RmicBackend
+ if (iiop)
+ {
+ backends.add(new SourceGiopRmicCompiler());
+
+ if (jrmp)
+ {
+ // Both IIOP and JRMP stubs were requested.
+ backends.add(new ClassRmicCompiler());
+ // FIXME: SourceRmicCompiler should support v1.1
+ if (keep)
+ backends.add(new SourceRmicCompiler());
+ }
+ }
+ else
+ {
+ backends.add(new ClassRmicCompiler());
+ if (keep)
+ backends.add(new SourceRmicCompiler());
+ }
+
+ for (int i = 0; i < backends.size(); i++)
+ {
+ RmicBackend b = (RmicBackend) backends.get(i);
+ b.setup(keep, need11Stubs, need12Stubs,
+ iiop, poa, false, warnings,
+ noWrite, verbose, force, classpath,
+ null, null, outputDirectory);
+ if (!b.run(files))
+ System.exit(1);
+ }
+ }
+
+ /**
+ * The RMI compiler entry point.
+ */
+ public static void main(String[] args)
+ {
+ Main rmicprogram = new Main();
+ try
+ {
+ rmicprogram.run(args);
+ }
+ catch (Exception e)
+ {
+ System.err.println(Messages.getString("Main.InternalError")); //$NON-NLS-1$
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+ }
+
+}
diff --git a/tools/gnu/classpath/tools/rmic/Messages.java b/tools/gnu/classpath/tools/rmic/Messages.java
new file mode 100644
index 000000000..5e67dd163
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmic/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- localization support for rmic
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.rmic;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+ private static final String BUNDLE_NAME
+ = "gnu.classpath.tools.rmic.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE
+ = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages()
+ {
+ }
+
+ public static String getString(String key)
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString(key);
+ }
+ catch (MissingResourceException e)
+ {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/tools/gnu/classpath/tools/rmic/MethodGenerator.java b/tools/gnu/classpath/tools/rmic/MethodGenerator.java
new file mode 100644
index 000000000..335a0a65c
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmic/MethodGenerator.java
@@ -0,0 +1,285 @@
+/* MethodGenerator.java -- Generates methods for GIOP rmic compiler.
+ Copyright (C) 2006 Free Software Foundation
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+package gnu.classpath.tools.rmic;
+
+import gnu.classpath.tools.rmic.AbstractMethodGenerator;
+
+import java.lang.reflect.Method;
+import java.util.Properties;
+
+/**
+ * Keeps information about the single method and generates the code fragments,
+ * related to that method.
+ *
+ * @author Audrius Meskauskas, Lithuania (audriusa@Bioinformatics.org)
+ */
+public class MethodGenerator implements AbstractMethodGenerator
+{
+ /**
+ * The method being defined.
+ */
+ Method method;
+
+ /**
+ * The parent code generator.
+ */
+ SourceGiopRmicCompiler rmic;
+
+ /**
+ * The previous method in the list, null for the first element.
+ * Used to avoid repretetive inclusion of the same hash code label.
+ */
+ MethodGenerator previous = null;
+
+ /**
+ * The hash character position.
+ */
+ int hashCharPosition;
+
+ /**
+ * Create the new method generator for the given method.
+ *
+ * @param aMethod
+ * the related method.
+ * @param aRmic
+ * the Rmic generator instance, where more class - related
+ * information is defined.
+ */
+ public MethodGenerator(Method aMethod, SourceGiopRmicCompiler aRmic)
+ {
+ method = aMethod;
+ rmic = aRmic;
+ }
+
+ /**
+ * Get the method name.
+ *
+ * @return the name of the method.
+ */
+ public String getGiopMethodName()
+ {
+ String m = method.getName();
+ if (m.startsWith("get"))
+ return "_get_J" + m.substring("get".length());
+ else if (m.startsWith("set"))
+ return "_set_J" + m.substring("set".length());
+ else
+ return m;
+ }
+
+ /**
+ * Get the method parameter declaration.
+ *
+ * @return the string - method parameter declaration.
+ */
+ public String getArgumentList()
+ {
+ StringBuffer b = new StringBuffer();
+
+ Class[] args = method.getParameterTypes();
+
+ for (int i = 0; i < args.length; i++)
+ {
+ b.append(rmic.name(args[i]));
+ b.append(" p" + i);
+ if (i < args.length - 1)
+ b.append(", ");
+ }
+ return b.toString();
+ }
+
+ /**
+ * Get the method parameter list only (no type declarations). This is used to
+ * generate the method invocations statement.
+ *
+ * @return the string - method parameter list.
+ */
+ public String getArgumentNames()
+ {
+ StringBuffer b = new StringBuffer();
+
+ Class[] args = method.getParameterTypes();
+
+ for (int i = 0; i < args.length; i++)
+ {
+ b.append(" p" + i);
+ if (i < args.length - 1)
+ b.append(", ");
+ }
+ return b.toString();
+ }
+
+ /**
+ * Get the list of exceptions, thrown by this method.
+ *
+ * @return the list of exceptions.
+ */
+ public String getThrows()
+ {
+ StringBuffer b = new StringBuffer();
+
+ Class[] args = method.getExceptionTypes();
+
+ for (int i = 0; i < args.length; i++)
+ {
+ b.append(rmic.name(args[i]));
+ if (i < args.length - 1)
+ b.append(", ");
+ }
+ return b.toString();
+ }
+
+ /**
+ * Generate this method for the Stub class.
+ *
+ * @return the method body for the stub class.
+ */
+ public String generateStubMethod()
+ {
+ String templateName;
+
+ Properties vars = new Properties(rmic.vars);
+ vars.put("#return_type", rmic.name(method.getReturnType()));
+ vars.put("#method_name", method.getName());
+ vars.put("#giop_method_name", getGiopMethodName());
+ vars.put("#argument_list", getArgumentList());
+ vars.put("#argument_names", getArgumentNames());
+
+ vars.put("#argument_write", getStubParaWriteStatement());
+
+ if (method.getReturnType().equals(void.class))
+ vars.put("#read_return", "return;");
+ else
+ vars.put("#read_return",
+ "return "
+ + GiopIo.getReadStatement(method.getReturnType(), rmic));
+ String thr = getThrows();
+ if (thr.length() > 0)
+ vars.put("#throws", "\n throws " + thr);
+ else
+ vars.put("#throws", "");
+
+ if (method.getReturnType().equals(void.class))
+ templateName = "StubMethodVoid.jav";
+ else
+ {
+ vars.put("#write_result",
+ GiopIo.getWriteStatement(method.getReturnType(), "result",
+ rmic));
+ templateName = "StubMethod.jav";
+ }
+
+ String template = rmic.getResource(templateName);
+ String generated = rmic.replaceAll(template, vars);
+ return generated;
+ }
+
+ /**
+ * Generate this method handling fragment for the Tie class.
+ *
+ * @return the fragment to handle this method for the Tie class.
+ */
+ public String generateTieMethod()
+ {
+ String templateName;
+
+ Properties vars = new Properties(rmic.vars);
+ vars.put("#return_type", rmic.name(method.getReturnType()));
+ vars.put("#method_name", method.getName());
+ vars.put("#giop_method_name", getGiopMethodName());
+ vars.put("#argument_list", getArgumentList());
+ vars.put("#argument_names", getArgumentNames());
+
+ vars.put("#argument_write", getStubParaWriteStatement());
+
+ if (previous == null || previous.getHashChar()!=getHashChar())
+ vars.put("#hashCodeLabel"," case '"+getHashChar()+"':");
+ else
+ vars.put("#hashCodeLabel"," // also '"+getHashChar()+"':");
+
+ if (method.getReturnType().equals(void.class))
+ templateName = "TieMethodVoid.jav";
+ else
+ {
+ vars.put("#write_result",
+ GiopIo.getWriteStatement(method.getReturnType(), "result",
+ rmic));
+ templateName = "TieMethod.jav";
+ }
+ vars.put("#read_and_define_args", getRda());
+
+ String template = rmic.getResource(templateName);
+ String generated = rmic.replaceAll(template, vars);
+ return generated;
+ }
+
+ /**
+ * Generate sentences for Reading and Defining Arguments.
+ *
+ * @return the sequence of sentences for reading and defining arguments.
+ */
+ public String getRda()
+ {
+ StringBuffer b = new StringBuffer();
+ Class[] args = method.getParameterTypes();
+
+ for (int i = 0; i < args.length; i++)
+ {
+ b.append(" ");
+ b.append(rmic.name(args[i]));
+ b.append(" ");
+ b.append("p"+i);
+ b.append(" = ");
+ b.append(GiopIo.getReadStatement(args[i], rmic));
+ if (i
+ */
+
+public class RMICException extends Exception {
+ /**
+ * Create an exception with a message. The cause remains uninitialized.
+ *
+ * @param s the message string
+ * @see #initCause(Throwable)
+ */
+ public RMICException(String message) {
+ super(message);
+ }
+
+ /**
+ * Create an exception with a message and a cause.
+ *
+ * @param s the message string
+ * @param cause the cause of this exception
+ */
+ public RMICException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/tools/gnu/classpath/tools/rmic/RmiMethodGenerator.java b/tools/gnu/classpath/tools/rmic/RmiMethodGenerator.java
new file mode 100644
index 000000000..48abb8fad
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmic/RmiMethodGenerator.java
@@ -0,0 +1,287 @@
+/* MethodGenerator.java -- Generates methods for rmi compiler.
+ Copyright (C) 2006 Free Software Foundation
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+*/
+
+
+package gnu.classpath.tools.rmic;
+
+import gnu.classpath.tools.rmic.AbstractMethodGenerator;
+import gnu.java.rmi.server.RMIHashes;
+
+import java.lang.reflect.Method;
+import java.util.Properties;
+
+/**
+ * Keeps information about the single method and generates the code fragments,
+ * related to that method.
+ *
+ * @author Audrius Meskauskas, Lithuania (audriusa@Bioinformatics.org)
+ */
+public class RmiMethodGenerator
+ implements AbstractMethodGenerator
+{
+ /**
+ * The method being defined.
+ */
+ Method method;
+
+ /**
+ * The parent code generator.
+ */
+ SourceRmicCompiler rmic;
+
+ /**
+ * Create the new method generator for the given method.
+ *
+ * @param aMethod the related method.
+ * @param aRmic the Rmic generator instance, where more class - related
+ * information is defined.
+ */
+ public RmiMethodGenerator(Method aMethod, SourceRmicCompiler aRmic)
+ {
+ method = aMethod;
+ rmic = aRmic;
+ if (method.getParameterTypes().length == 0)
+ rmic.addZeroSizeObjecArray = true;
+ }
+
+ /**
+ * Get the method parameter declaration.
+ *
+ * @return the string - method parameter declaration.
+ */
+ public String getArgumentList()
+ {
+ StringBuffer b = new StringBuffer();
+
+ Class[] args = method.getParameterTypes();
+
+ for (int i = 0; i < args.length; i++)
+ {
+ b.append(rmic.name(args[i]));
+ b.append(" p" + i);
+ if (i < args.length - 1)
+ b.append(", ");
+ }
+ return b.toString();
+ }
+
+ /**
+ * Get the method parameter list only (no type declarations). This is used to
+ * generate the method invocations statement.
+ *
+ * @return the string - method parameter list.
+ */
+ public String getArgumentNames()
+ {
+ StringBuffer b = new StringBuffer();
+
+ Class[] args = method.getParameterTypes();
+
+ for (int i = 0; i < args.length; i++)
+ {
+ b.append(" p" + i);
+ if (i < args.length - 1)
+ b.append(", ");
+ }
+ return b.toString();
+ }
+
+ /**
+ * Get the list of exceptions, thrown by this method.
+ *
+ * @return the list of exceptions.
+ */
+ public String getThrows()
+ {
+ StringBuffer b = new StringBuffer();
+
+ Class[] args = method.getExceptionTypes();
+
+ for (int i = 0; i < args.length; i++)
+ {
+ b.append(rmic.name(args[i]));
+ if (i < args.length - 1)
+ b.append(", ");
+ }
+ return b.toString();
+ }
+
+ /**
+ * Generate this method for the Stub class.
+ *
+ * @return the method body for the stub class.
+ */
+ public String generateStubMethod()
+ {
+ String templateName;
+
+ Properties vars = new Properties(rmic.vars);
+ vars.put("#return_type", rmic.name(method.getReturnType()));
+ vars.put("#method_name", method.getName());
+ vars.put("#method_hash", getMethodHashCode());
+ vars.put("#argument_list", getArgumentList());
+ vars.put("#object_arg_list", getArgListAsObjectArray());
+ vars.put("#declaring_class", rmic.name(method.getDeclaringClass()));
+ vars.put("#class_arg_list", getArgListAsClassArray());
+
+ String thr = getThrows();
+ if (thr.length() > 0)
+ vars.put("#throws", "\n throws " + thr);
+ else
+ vars.put("#throws", "");
+
+ if (method.getReturnType().equals(void.class))
+ templateName = "Stub_12MethodVoid.jav";
+ else
+ {
+ templateName = "Stub_12Method.jav";
+ vars.put("#return_statement", getReturnStatement());
+ }
+
+ String template = rmic.getResource(templateName);
+ String generated = rmic.replaceAll(template, vars);
+ return generated;
+ }
+
+ /**
+ * Generate sentences for Reading and Defining Arguments.
+ *
+ * @return the sequence of sentences for reading and defining arguments.
+ */
+ public String getStaticMethodDeclarations()
+ {
+ StringBuffer b = new StringBuffer();
+ Class[] args = method.getParameterTypes();
+
+ for (int i = 0; i < args.length; i++)
+ {
+ b.append(" ");
+ b.append(rmic.name(args[i]));
+ b.append(" ");
+ b.append("p" + i);
+ b.append(" = ");
+ if (i < args.length - 1)
+ b.append("\n");
+ }
+ return b.toString();
+ }
+
+ /**
+ * Get the write statement for writing parameters inside the stub.
+ *
+ * @return the write statement.
+ */
+ public String getArgListAsObjectArray()
+ {
+ Class[] args = method.getParameterTypes();
+
+ if (args.length==0)
+ return "NO_ARGS";
+
+ StringBuffer b = new StringBuffer("new Object[] {");
+
+ for (int i = 0; i < args.length; i++)
+ {
+ if (!args[i].isPrimitive())
+ b.append("p"+i);
+ else
+ {
+ b.append("new "+rmic.name(WrapUnWrapper.getWrappingClass(args[i])));
+ b.append("(p"+i+")");
+ }
+ if (i 0)
+ {
+ Integer i = (Integer) free.iterator().next();
+ free.remove(i);
+ names.put(name, i);
+ return i.intValue();
+ }
+
+ return allocateNew(name, size);
+ }
+
+ public int deallocate(Object name)
+ {
+ if (! names.containsKey(name))
+ throw new IllegalArgumentException("no variable " + name);
+
+ if (declared.contains(name))
+ throw new IllegalStateException(name + " can't be deallocated");
+
+ Integer i = (Integer) names.get(name);
+ names.remove(name);
+ free.add(i);
+ if (wides.remove(name))
+ free.add(new Integer(i.intValue() + 1));
+ return i.intValue();
+ }
+
+ public int get(Object name)
+ {
+ if (! names.containsKey(name))
+ throw new IllegalArgumentException("no variable " + name);
+
+ return ((Integer) names.get(name)).intValue();
+ }
+}
diff --git a/tools/gnu/classpath/tools/rmic/WrapUnWrapper.java b/tools/gnu/classpath/tools/rmic/WrapUnWrapper.java
new file mode 100644
index 000000000..c51925fa6
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmic/WrapUnWrapper.java
@@ -0,0 +1,83 @@
+/* WrapUnWrapper.java -- Wrapper and unwrapper for primitive types.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+*/
+
+
+package gnu.classpath.tools.rmic;
+
+
+public class WrapUnWrapper
+{
+ /**
+ * Get the wrapper class for the primitive type
+ *
+ * @param primitive the class of the primitive type
+ *
+ * @return the wrapper class
+ */
+ public static Class getWrappingClass(Class primitive)
+ {
+ if (primitive.equals(byte.class))
+ return Byte.class;
+ if (primitive.equals(int.class))
+ return Integer.class;
+ if (primitive.equals(long.class))
+ return Long.class;
+ if (primitive.equals(boolean.class))
+ return Boolean.class;
+ if (primitive.equals(double.class))
+ return Double.class;
+ if (primitive.equals(float.class))
+ return Float.class;
+ if (primitive.equals(char.class))
+ return Character.class;
+ else
+ return null;
+ }
+
+ /**
+ * Get the method, invocation of that would return the wrapped value.
+ *
+ * @param primitive the class of the primitive type.
+ *
+ * @return the wrapper method that unwraps the value to the primitive type.
+ */
+ public static String getUnwrappingMethod(Class primitive)
+ {
+ if (primitive.equals(byte.class))
+ return "byteValue()";
+ if (primitive.equals(int.class))
+ return "intValue()";
+ if (primitive.equals(long.class))
+ return "longValue()";
+ if (primitive.equals(boolean.class))
+ return "booleanValue()";
+ if (primitive.equals(double.class))
+ return "doubleValue()";
+ if (primitive.equals(float.class))
+ return "floatValue()";
+ if (primitive.equals(char.class))
+ return "charValue()";
+ else
+ return null;
+ }
+
+
+}
diff --git a/tools/gnu/classpath/tools/rmic/templates/ImplTie.jav b/tools/gnu/classpath/tools/rmic/templates/ImplTie.jav
new file mode 100644
index 000000000..aff606b90
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmic/templates/ImplTie.jav
@@ -0,0 +1,152 @@
+package #package;
+
+#imports
+import java.rmi.Remote;
+import javax.rmi.PortableRemoteObject;
+import javax.rmi.CORBA.Tie;
+
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.ResponseHandler;
+import org.omg.CORBA.portable.UnknownException;
+import org.omg.PortableServer.Servant;
+
+import org.omg.CORBA_2_3.portable.ObjectImpl;
+import org.omg.CORBA_2_3.portable.InputStream;
+
+// This Tie type is obsolete. Use the POA - based tie (key -poa).
+
+/**
+ * This class accepts remote calls to the served GIOP object and delegates them
+ * to the enclosed implementing class. Being derived from the ObjectImpl,
+ * it directly implements the GIOP Object.
+ *
+ * It is normally generated with grmic -impl
+ */
+public class _#nameImpl_Tie extends ObjectImpl implements Tie
+{
+ /**
+ * All decoded remote calls are forwarded to this target.
+ */
+ #implName target;
+
+ /**
+ * The array of repository ids, supported by this GIOP Object
+ */
+ private static final String[] type_ids =
+ {
+#idList
+ };
+
+ /**
+ * Get an array of all interfaces (repository ids),
+ * supported by this Object.
+ *
+ * @return the array of Ids.
+ */
+ public String[] _ids()
+ {
+ return type_ids;
+ }
+
+ /**
+ * Set the invocation target, where all received calls are finally
+ * forwarded.
+ *
+ * @param a_target the forwarding target
+ *
+ * @throws ClassCastException if the target is not an instance of
+ * #implName
+ */
+ public void setTarget(Remote a_target)
+ {
+ this.target = (#implName) a_target;
+ }
+
+ /**
+ * Get the invocation target, where all received calls are finally
+ * forwarded.
+ *
+ * @return the target, an instance of
+ * #implName
+ */
+ public Remote getTarget()
+ {
+ return target;
+ }
+
+ /**
+ * Return the actual GIOP object that would handle this request.
+ *
+ * @return this
, always.
+ */
+ public org.omg.CORBA.Object thisObject()
+ {
+ return this;
+ }
+
+ /**
+ * Deactivates this object, disconnecting it from the orb.
+ */
+ public void deactivate()
+ {
+ _orb().disconnect(this);
+ _set_delegate(null);
+ target = null;
+ }
+
+ /**
+ * Get the {@link ORB} where this {@link Servant} is connected.
+ *
+ * @return the ORB
+ */
+ public ORB orb()
+ {
+ return _orb();
+ }
+
+ /**
+ * Connect this servant to the given ORB.
+ */
+ public void orb(ORB orb)
+ {
+ orb.connect(this);
+ }
+
+/**
+ * This method is invoked by ORB in response to the remote call. It redirects
+ * the call to one of the methods in the target.
+ *
+ * @param method the name of the method to call.
+ * @param parameter_stream the input stream, from where the parameters must be
+ * read.
+ * @param reply the response hander, providing methods to return the result.
+ *
+ * @return the output stream, created by the response handler
+ *
+ * @throws SystemException if one occurs during method invocation.
+ */
+ public OutputStream _invoke(String method,
+ org.omg.CORBA.portable.InputStream parameter_stream,
+ ResponseHandler reply)
+ {
+ try
+ {
+ InputStream in =(InputStream) parameter_stream;
+
+#tie_methods
+
+ throw new BAD_OPERATION("No such method: '"+method+"'");
+ }
+ catch (SystemException ex)
+ {
+ throw ex;
+ }
+ catch (Throwable ex)
+ {
+ throw new UnknownException(ex);
+ }
+ }
+}
\ No newline at end of file
diff --git a/tools/gnu/classpath/tools/rmic/templates/Stub.jav b/tools/gnu/classpath/tools/rmic/templates/Stub.jav
new file mode 100644
index 000000000..371e12d44
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmic/templates/Stub.jav
@@ -0,0 +1,47 @@
+package #package;
+
+#imports
+import java.rmi.UnexpectedException;
+
+import javax.rmi.CORBA.Stub;
+import javax.rmi.CORBA.Util;
+
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.portable.ApplicationException;
+import org.omg.CORBA.portable.InputStream;
+import org.omg.CORBA.portable.RemarshalException;
+
+import org.omg.CORBA_2_3.portable.OutputStream;
+
+/**
+ * This class delegates its method calls to the remote GIOP object.
+ * It is normally generated with grmic.
+ */
+public class _#name_Stub extends Stub
+ implements #interfaces
+{
+ /**
+ * Use serialVersionUID for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The array of repository ids, supported by this GIOP Object
+ */
+ private static final String[] type_ids =
+ {
+#idList
+ };
+
+ /**
+ * Return the array of repository ids, supported by this GIOP Object.
+ *
+ * @return the array of Ids.
+ */
+ public String[] _ids()
+ {
+ return type_ids;
+ }
+
+#stub_methods
+}
\ No newline at end of file
diff --git a/tools/gnu/classpath/tools/rmic/templates/StubMethod.jav b/tools/gnu/classpath/tools/rmic/templates/StubMethod.jav
new file mode 100644
index 000000000..17636deb6
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmic/templates/StubMethod.jav
@@ -0,0 +1,33 @@
+ /** @inheritDoc */
+ public #return_type #method_name(#argument_list) #throws
+ {
+ try
+ {
+ InputStream in = null;
+ try
+ {
+ OutputStream out =
+ (OutputStream) _request("#giop_method_name", true);
+#argument_write
+ in = _invoke(out);
+ #read_return
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+ throw new UnexpectedException(in.read_string());
+ }
+ catch (RemarshalException ex)
+ {
+ return #method_name(#argument_names);
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+ catch (SystemException ex)
+ {
+ throw Util.mapSystemException(ex);
+ }
+ }
diff --git a/tools/gnu/classpath/tools/rmic/templates/StubMethodVoid.jav b/tools/gnu/classpath/tools/rmic/templates/StubMethodVoid.jav
new file mode 100644
index 000000000..0125a02b0
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmic/templates/StubMethodVoid.jav
@@ -0,0 +1,32 @@
+ /** @inheritDoc */
+ public #return_type #method_name(#argument_list) #throws
+ {
+ try
+ {
+ InputStream in = null;
+ try
+ {
+ OutputStream out =
+ (OutputStream) _request("#giop_method_name", true);
+#argument_write
+ in = _invoke(out);
+ }
+ catch (ApplicationException ex)
+ {
+ in = ex.getInputStream();
+ throw new UnexpectedException(in.read_string());
+ }
+ catch (RemarshalException ex)
+ {
+ #method_name(#argument_names);
+ }
+ finally
+ {
+ _releaseReply(in);
+ }
+ }
+ catch (SystemException ex)
+ {
+ throw Util.mapSystemException(ex);
+ }
+ }
diff --git a/tools/gnu/classpath/tools/rmic/templates/Stub_12.jav b/tools/gnu/classpath/tools/rmic/templates/Stub_12.jav
new file mode 100644
index 000000000..1c55a0597
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmic/templates/Stub_12.jav
@@ -0,0 +1,62 @@
+package #package;
+
+#imports
+import java.lang.reflect.Method;
+import java.rmi.server.RemoteRef;
+import java.rmi.server.RemoteStub;
+import java.rmi.UnexpectedException;
+
+/**
+ * This class delegates its method calls to the remote RMI object, referenced
+ * by {@link RemoteRef}.
+ *
+ * It is normally generated with rmic.
+ */
+public final class #name_Stub
+ extends RemoteStub
+ implements #interfaces
+{
+ /**
+ * Use serialVersionUID for interoperability
+ */
+ private static final long serialVersionUID = 2;
+
+ /**
+ * The explaining message for {@ling UnexpectedException}.
+ */
+ private static final String exception_message =
+ "undeclared checked exception";
+
+ /* All remote methods, invoked by this stub: */
+#stub_method_declarations
+ #zeroSizeObjecArray
+ static
+ {
+ #zeroSizeClassArray
+ try
+ {
+#stub_method_initializations
+ }
+ catch (NoSuchMethodException nex)
+ {
+ NoSuchMethodError err = new NoSuchMethodError(
+ "#name_Stub class initialization failed");
+ err.initCause(nex);
+ throw err;
+ }
+ }
+
+ /**
+ * Create the instance for _#name_Stub that forwards method calls to the
+ * remote object.
+ *
+ * @para the reference to the remote object.
+ */
+ public #name_Stub(RemoteRef reference)
+ {
+ super(reference);
+ }
+
+ /* Methods */
+#stub_methods
+}
diff --git a/tools/gnu/classpath/tools/rmic/templates/Stub_12Method.jav b/tools/gnu/classpath/tools/rmic/templates/Stub_12Method.jav
new file mode 100644
index 000000000..9aaf8f5ad
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmic/templates/Stub_12Method.jav
@@ -0,0 +1,26 @@
+ /** @inheritDoc */
+ public #return_type #method_name(#argument_list) #throws
+ {
+ try
+ {
+ Object result = ref.invoke(this, met_#method_name,
+ #object_arg_list,
+ #method_hash);
+ #return_statement
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
\ No newline at end of file
diff --git a/tools/gnu/classpath/tools/rmic/templates/Stub_12MethodVoid.jav b/tools/gnu/classpath/tools/rmic/templates/Stub_12MethodVoid.jav
new file mode 100644
index 000000000..860a93c84
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmic/templates/Stub_12MethodVoid.jav
@@ -0,0 +1,25 @@
+ /** @inheritDoc */
+ public void #method_name(#argument_list) #throws
+ {
+ try
+ {
+ ref.invoke(this, met_#method_name,
+ #object_arg_list,
+ #method_hash);
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
\ No newline at end of file
diff --git a/tools/gnu/classpath/tools/rmic/templates/Tie.jav b/tools/gnu/classpath/tools/rmic/templates/Tie.jav
new file mode 100644
index 000000000..797ae1401
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmic/templates/Tie.jav
@@ -0,0 +1,184 @@
+package #package;
+
+#imports
+import java.rmi.Remote;
+import javax.rmi.PortableRemoteObject;
+import javax.rmi.CORBA.Tie;
+
+import org.omg.CORBA.BAD_OPERATION;
+import org.omg.CORBA.ORB;
+import org.omg.CORBA.SystemException;
+import org.omg.CORBA.portable.OutputStream;
+import org.omg.CORBA.portable.ResponseHandler;
+import org.omg.CORBA.portable.UnknownException;
+import org.omg.PortableServer.Servant;
+import org.omg.PortableServer.POA;
+import org.omg.PortableServer.POAPackage.WrongPolicy;
+import org.omg.PortableServer.POAPackage.ObjectNotActive;
+import org.omg.PortableServer.POAPackage.ServantNotActive;
+
+import org.omg.CORBA_2_3.portable.InputStream;
+
+/**
+ * This class accepts remote calls to the served GIOP object and delegates them
+ * to the enclosed implementing class. Being servant, it must be connected to
+ * the ORB Poa.
+ * It is normally generated with grmic -poa
+ */
+public class _#nameImpl_Tie extends Servant implements Tie
+{
+ /**
+ * All decoded remote calls are forwarded to this target.
+ */
+ #implName target;
+
+ /**
+ * The array of repository ids, supported by this GIOP Object
+ */
+ private static final String[] type_ids =
+ {
+#idList
+ };
+
+ /**
+ * Get an array of all interfaces, supported by this
+ * {@link Servant}.
+ *
+ * @param poa unused
+ * @param objectId unused
+ *
+ * @return the array of Ids.
+ */
+ public String[] _all_interfaces(POA poa,
+ byte[] objectId
+ )
+ {
+ return type_ids;
+ }
+
+
+ /**
+ * Set the invocation target, where all received calls are finally
+ * forwarded.
+ *
+ * @param a_target the forwarding target
+ *
+ * @throws ClassCastException if the target is not an instance of
+ * #implName
+ */
+ public void setTarget(Remote a_target)
+ {
+ this.target = (#implName) a_target;
+ }
+
+ /**
+ * Get the invocation target, where all received calls are finally
+ * forwarded.
+ *
+ * @return the target, an instance of
+ * #implName
+ */
+ public Remote getTarget()
+ {
+ return target;
+ }
+
+ /**
+ * Return the actual GIOP object that would handle this request.
+ *
+ * @return the GIOP object.
+ */
+ public org.omg.CORBA.Object thisObject()
+ {
+ return _this_object();
+ }
+
+ /**
+ * Deactivate this {@link Servant}. The WrongPolicy, ObjectNotActive
+ * and ServantNotActive exceptions, if thrown during deactivation, are
+ * catched and silently ignored.
+ */
+ public void deactivate()
+ {
+ try
+ {
+ _poa().deactivate_object(_poa().servant_to_id(this));
+ }
+ catch (WrongPolicy exception)
+ {
+ }
+ catch (ObjectNotActive exception)
+ {
+ }
+ catch (ServantNotActive exception)
+ {
+ }
+ }
+
+ /**
+ * Get the {@link ORB} where this {@link Servant} is connected.
+ *
+ * @return the ORB
+ */
+ public ORB orb()
+ {
+ return _orb();
+ }
+
+ /**
+ * Connect this servant to the given ORB. It is recommended to connect
+ * servant to the ORBs root or other POA rather than using this method.
+ */
+ public void orb(ORB orb)
+ {
+ try
+ {
+ ((org.omg.CORBA_2_3.ORB) orb).set_delegate(this);
+ }
+ catch (ClassCastException e)
+ {
+ throw new org.omg.CORBA.BAD_PARAM(
+ "POA Servant requires an instance of org.omg.CORBA_2_3.ORB"
+ );
+ }
+ }
+
+/**
+ * This method is invoked by ORB in response to the remote call. It redirects
+ * the call to one of the methods in the target.
+ *
+ * @param method the name of the method to call.
+ * @param parameter_stream the input stream, from where the parameters must be
+ * read.
+ * @param reply the response hander, providing methods to return the result.
+ *
+ * @return the output stream, created by the response handler
+ *
+ * @throws SystemException if one occurs during method invocation.
+ */
+ public OutputStream _invoke(String method,
+ org.omg.CORBA.portable.InputStream parameter_stream,
+ ResponseHandler reply
+ ) throws SystemException
+ {
+ try
+ {
+ InputStream in =(InputStream) parameter_stream;
+ switch (method.charAt(#hashCharPos))
+ {
+#tie_methods
+ default: break;
+ }
+
+ throw new BAD_OPERATION("No such method: '"+method+"'");
+ }
+ catch (SystemException ex)
+ {
+ throw ex;
+ }
+ catch (Throwable ex)
+ {
+ throw new UnknownException(ex);
+ }
+ }
+}
\ No newline at end of file
diff --git a/tools/gnu/classpath/tools/rmic/templates/TieMethod.jav b/tools/gnu/classpath/tools/rmic/templates/TieMethod.jav
new file mode 100644
index 000000000..493f0009b
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmic/templates/TieMethod.jav
@@ -0,0 +1,11 @@
+ #hashCodeLabel
+ // #method_name
+ if (method.equals("#giop_method_name"))
+ {
+#read_and_define_args
+ OutputStream out = reply.createReply();
+ #return_type result =
+ target.#method_name(#argument_names);
+ #write_result
+ return out;
+ }
diff --git a/tools/gnu/classpath/tools/rmic/templates/TieMethodVoid.jav b/tools/gnu/classpath/tools/rmic/templates/TieMethodVoid.jav
new file mode 100644
index 000000000..3db17da7c
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmic/templates/TieMethodVoid.jav
@@ -0,0 +1,9 @@
+ #hashCodeLabel
+ // #method_name
+ if (method.equals("#giop_method_name"))
+ {
+#read_and_define_args
+ OutputStream out = reply.createReply();
+ target.#method_name(#argument_names);
+ return out;
+ }
diff --git a/tools/gnu/classpath/tools/rmid/ActivationSystemImpl.java b/tools/gnu/classpath/tools/rmid/ActivationSystemImpl.java
new file mode 100644
index 000000000..390117a05
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmid/ActivationSystemImpl.java
@@ -0,0 +1,243 @@
+/* ActivationSystemImpl.java -- implementation of the activation system.
+ Copyright (c) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.rmid;
+
+import gnu.classpath.tools.common.Persistent;
+import gnu.java.rmi.activation.ActivationSystemTransient;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.rmi.MarshalledObject;
+import java.rmi.RemoteException;
+import java.rmi.activation.ActivationDesc;
+import java.rmi.activation.ActivationException;
+import java.rmi.activation.ActivationGroupDesc;
+import java.rmi.activation.ActivationGroupID;
+import java.rmi.activation.ActivationID;
+import java.rmi.activation.ActivationInstantiator;
+import java.rmi.activation.ActivationMonitor;
+import java.rmi.activation.ActivationSystem;
+import java.rmi.activation.Activator;
+import java.rmi.activation.UnknownGroupException;
+import java.rmi.activation.UnknownObjectException;
+
+/**
+ * Implements the rmid activation system.
+ *
+ * @author Audrius Meskauskas (audriusa@bioinformatics.org)
+ */
+public class ActivationSystemImpl extends ActivationSystemTransient implements
+ ActivationSystem, Activator, ActivationMonitor, Serializable
+{
+ /**
+ * Use for interoperability.
+ */
+ private static final long serialVersionUID = 1;
+
+ /**
+ * The singleton instance of this class.
+ */
+ public static ActivationSystemImpl singleton2;
+
+ /**
+ * Obtain the singleton instance of this class.
+ *
+ * @param folder the folder, where the activation system will keep its files.
+ * @param cold do the cold start if true, hot (usual) if false.
+ */
+ public static ActivationSystem getInstance(File folder, boolean cold)
+ {
+ if (singleton2 == null)
+ singleton2 = new ActivationSystemImpl(folder, cold);
+ return singleton2;
+ }
+
+ /**
+ * Creates the group with transient maps.
+ *
+ * @param folder
+ * the folder, where the activation system will keep its files.
+ * @param cold
+ * do the cold start if true, hot (usual) if false.
+ */
+ protected ActivationSystemImpl(File folder, boolean cold)
+ {
+ super(new PersistentBidiHashTable(), new PersistentBidiHashTable());
+ singleton2 = this;
+ ((PersistentBidiHashTable) groupDescs).init(
+ new File(folder, "asi_objects.data"), cold);
+ ((PersistentBidiHashTable) descriptions).init(
+ new File(folder, "asi_groups.data"), cold);
+ }
+
+ /** @inheritDoc */
+ public MarshalledObject activate(ActivationID id, boolean force)
+ throws ActivationException, UnknownObjectException, RemoteException
+ {
+ return super.activate(id, force);
+ }
+
+ /** @inheritDoc */
+ public ActivationMonitor activeGroup(ActivationGroupID id,
+ ActivationInstantiator group,
+ long incarnation)
+ throws UnknownGroupException, ActivationException, RemoteException
+ {
+ return super.activeGroup(id, group, incarnation);
+ }
+
+ /** @inheritDoc */
+ public void activeObject(ActivationID id, MarshalledObject obj)
+ throws UnknownObjectException, RemoteException
+ {
+ super.activeObject(id, obj);
+ }
+
+ /** @inheritDoc */
+ public ActivationDesc getActivationDesc(ActivationID id)
+ throws ActivationException, UnknownObjectException, RemoteException
+ {
+ return super.getActivationDesc(id);
+ }
+
+ public ActivationGroupDesc getActivationGroupDesc(ActivationGroupID groupId)
+ throws ActivationException, UnknownGroupException, RemoteException
+ {
+ return super.getActivationGroupDesc(groupId);
+ }
+
+ /** @inheritDoc */
+ public void inactiveGroup(ActivationGroupID groupId, long incarnation)
+ throws UnknownGroupException, RemoteException
+ {
+ super.inactiveGroup(groupId, incarnation);
+ }
+
+ /** @inheritDoc */
+ public void inactiveObject(ActivationID id) throws UnknownObjectException,
+ RemoteException
+ {
+ super.inactiveObject(id);
+ }
+
+ /** @inheritDoc */
+ public ActivationGroupID registerGroup(ActivationGroupDesc groupDesc)
+ throws ActivationException, RemoteException
+ {
+ return super.registerGroup(groupDesc);
+ }
+
+ /** @inheritDoc */
+ public ActivationID registerObject(ActivationDesc desc)
+ throws ActivationException, UnknownGroupException, RemoteException
+ {
+ return super.registerObject(desc);
+ }
+
+ /** @inheritDoc */
+ public ActivationDesc setActivationDesc(ActivationID id, ActivationDesc desc)
+ throws ActivationException, UnknownObjectException,
+ UnknownGroupException, RemoteException
+ {
+ return super.setActivationDesc(id, desc);
+ }
+
+ /** @inheritDoc */
+ public ActivationGroupDesc setActivationGroupDesc(
+ ActivationGroupID groupId, ActivationGroupDesc groupDesc)
+ throws ActivationException, UnknownGroupException, RemoteException
+ {
+ return super.setActivationGroupDesc(groupId, groupDesc);
+ }
+
+ /**
+ * This method saves the state of the activation system and then
+ * terminates in 10 seconds.
+ */
+ public void shutdown() throws RemoteException
+ {
+ super.shutdown();
+ System.out.println("Shutdown command received. Will terminate in 10 s");
+ Persistent.timer.schedule(new Persistent.ExitTask(), 10000);
+ }
+
+ /** @inheritDoc */
+ public void unregisterGroup(ActivationGroupID groupId)
+ throws ActivationException, UnknownGroupException, RemoteException
+ {
+ super.unregisterGroup(groupId);
+ }
+
+ /** @inheritDoc */
+ public void unregisterObject(ActivationID id) throws ActivationException,
+ UnknownObjectException, RemoteException
+ {
+ super.unregisterObject(id);
+ }
+
+ /**
+ * Read the object from the input stream.
+ *
+ * @param in the stream to read from
+ *
+ * @throws IOException if thrown by the stream
+ * @throws ClassNotFoundException
+ */
+ private void readObject(ObjectInputStream in) throws IOException,
+ ClassNotFoundException
+ {
+ // Read no fields.
+ }
+
+ /**
+ * Write the object to the output stream.
+ *
+ * @param out the stream to write int
+ * @throws IOException if thrown by the stream
+ * @throws ClassNotFoundException
+ */
+ private void writeObject(ObjectOutputStream out) throws IOException,
+ ClassNotFoundException
+ {
+ // Write no fields.
+ };
+
+}
diff --git a/tools/gnu/classpath/tools/rmid/ActivationSystemImpl_Stub.java b/tools/gnu/classpath/tools/rmid/ActivationSystemImpl_Stub.java
new file mode 100644
index 000000000..535f8ab92
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmid/ActivationSystemImpl_Stub.java
@@ -0,0 +1,556 @@
+/* ActivationSystemImpl.java -- implementation of the activation system.
+ Copyright (c) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.rmid;
+
+import java.rmi.MarshalledObject;
+import java.rmi.RemoteException;
+import java.rmi.activation.ActivationDesc;
+import java.rmi.activation.ActivationException;
+import java.rmi.activation.ActivationGroupDesc;
+import java.rmi.activation.ActivationGroupID;
+import java.rmi.activation.ActivationID;
+import java.rmi.activation.ActivationInstantiator;
+import java.rmi.activation.ActivationMonitor;
+import java.rmi.activation.ActivationSystem;
+import java.rmi.activation.Activator;
+import java.rmi.activation.UnknownGroupException;
+import java.rmi.activation.UnknownObjectException;
+
+import java.lang.reflect.Method;
+import java.rmi.server.RemoteRef;
+import java.rmi.server.RemoteStub;
+import java.rmi.UnexpectedException;
+
+/**
+ * This class delegates its method calls to the remote RMI object, referenced
+ * by {@link RemoteRef}.
+ *
+ * It is normally generated with rmic.
+ */
+public final class ActivationSystemImpl_Stub
+ extends RemoteStub
+ implements ActivationMonitor, Activator, ActivationSystem
+{
+ /**
+ * Use serialVersionUID for interoperability
+ */
+ private static final long serialVersionUID = 2;
+
+ /**
+ * The explaining message for {@ling UnexpectedException}.
+ */
+ private static final String exception_message =
+ "undeclared checked exception";
+
+ /* All remote methods, invoked by this stub: */
+ private static final Method met_setActivationGroupDesc;
+ private static final Method met_inactiveGroup;
+ private static final Method met_unregisterObject;
+ private static final Method met_getActivationDesc;
+ private static final Method met_setActivationDesc;
+ private static final Method met_shutdown;
+ private static final Method met_activate;
+ private static final Method met_activeGroup;
+ private static final Method met_registerGroup;
+ private static final Method met_getActivationGroupDesc;
+ private static final Method met_activeObject;
+ private static final Method met_registerObject;
+ private static final Method met_inactiveObject;
+ private static final Method met_unregisterGroup;
+ private static final Object[] NO_ARGS = new Object[0];
+ static
+ {
+ final Class[] NO_ARGSc = new Class[0];
+ try
+ {
+ met_setActivationGroupDesc =
+ ActivationSystem.class.getMethod("setActivationGroupDesc", new Class[]
+ {
+ ActivationGroupID.class, ActivationGroupDesc.class
+ });
+ met_inactiveGroup =
+ ActivationMonitor.class.getMethod("inactiveGroup", new Class[]
+ {
+ ActivationGroupID.class, long.class
+ });
+ met_unregisterObject =
+ ActivationSystem.class.getMethod("unregisterObject", new Class[]
+ {
+ ActivationID.class
+ });
+ met_getActivationDesc =
+ ActivationSystem.class.getMethod("getActivationDesc", new Class[]
+ {
+ ActivationID.class
+ });
+ met_setActivationDesc =
+ ActivationSystem.class.getMethod("setActivationDesc", new Class[]
+ {
+ ActivationID.class, ActivationDesc.class
+ });
+ met_shutdown =
+ ActivationSystem.class.getMethod("shutdown", NO_ARGSc);
+ met_activate =
+ Activator.class.getMethod("activate", new Class[]
+ {
+ ActivationID.class, boolean.class
+ });
+ met_activeGroup =
+ ActivationSystem.class.getMethod("activeGroup", new Class[]
+ {
+ ActivationGroupID.class, ActivationInstantiator.class, long.class
+ });
+ met_registerGroup =
+ ActivationSystem.class.getMethod("registerGroup", new Class[]
+ {
+ ActivationGroupDesc.class
+ });
+ met_getActivationGroupDesc =
+ ActivationSystem.class.getMethod("getActivationGroupDesc", new Class[]
+ {
+ ActivationGroupID.class
+ });
+ met_activeObject =
+ ActivationMonitor.class.getMethod("activeObject", new Class[]
+ {
+ ActivationID.class, MarshalledObject.class
+ });
+ met_registerObject =
+ ActivationSystem.class.getMethod("registerObject", new Class[]
+ {
+ ActivationDesc.class
+ });
+ met_inactiveObject =
+ ActivationMonitor.class.getMethod("inactiveObject", new Class[]
+ {
+ ActivationID.class
+ });
+ met_unregisterGroup =
+ ActivationSystem.class.getMethod("unregisterGroup", new Class[]
+ {
+ ActivationGroupID.class
+ });
+
+ }
+ catch (NoSuchMethodException nex)
+ {
+ NoSuchMethodError err = new NoSuchMethodError(
+ "ActivationSystemImpl_Stub class initialization failed");
+ err.initCause(nex);
+ throw err;
+ }
+ }
+
+ /**
+ * Create the instance for _ActivationSystemImpl_Stub that forwards method calls to the
+ * remote object.
+ *
+ * @para the reference to the remote object.
+ */
+ public ActivationSystemImpl_Stub(RemoteRef reference)
+ {
+ super(reference);
+ }
+
+ /* Methods */
+ /** @inheritDoc */
+ public ActivationGroupDesc setActivationGroupDesc(ActivationGroupID p0,
+ ActivationGroupDesc p1)
+ throws ActivationException, UnknownGroupException, RemoteException
+ {
+ try
+ {
+ Object result = ref.invoke(this, met_setActivationGroupDesc,
+ new Object[] { p0, p1 },
+ 1213918527826541191L);
+ return (ActivationGroupDesc) result;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public void inactiveGroup(ActivationGroupID p0, long p1)
+ throws UnknownGroupException, RemoteException
+ {
+ try
+ {
+ ref.invoke(this, met_inactiveGroup, new Object[] { p0, new Long(p1) },
+ -399287892768650944L);
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public void unregisterObject(ActivationID p0) throws ActivationException,
+ UnknownObjectException, RemoteException
+ {
+ try
+ {
+ ref.invoke(this, met_unregisterObject, new Object[] { p0 },
+ -6843850585331411084L);
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public ActivationDesc getActivationDesc(ActivationID p0)
+ throws ActivationException, UnknownObjectException, RemoteException
+ {
+ try
+ {
+ Object result = ref.invoke(this, met_getActivationDesc,
+ new Object[] { p0 }, 4830055440982622087L);
+ return (ActivationDesc) result;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public ActivationDesc setActivationDesc(ActivationID p0, ActivationDesc p1)
+ throws ActivationException, UnknownObjectException,
+ UnknownGroupException, RemoteException
+ {
+ try
+ {
+ Object result = ref.invoke(this, met_setActivationDesc,
+ new Object[] { p0, p1 },
+ 7128043237057180796L);
+ return (ActivationDesc) result;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public void shutdown() throws RemoteException
+ {
+ try
+ {
+ ref.invoke(this, met_shutdown, NO_ARGS, -7207851917985848402L);
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public MarshalledObject activate(ActivationID p0, boolean p1)
+ throws ActivationException, UnknownObjectException, RemoteException
+ {
+ try
+ {
+ Object result = ref.invoke(this, met_activate,
+ new Object[] { p0, new Boolean(p1) },
+ -8767355154875805558L);
+ return (MarshalledObject) result;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public ActivationMonitor activeGroup(ActivationGroupID p0,
+ ActivationInstantiator p1, long p2)
+ throws UnknownGroupException, ActivationException, RemoteException
+ {
+ try
+ {
+ Object result = ref.invoke(this, met_activeGroup,
+ new Object[] { p0, p1, new Long(p2) },
+ -4575843150759415294L);
+ return (ActivationMonitor) result;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public ActivationGroupID registerGroup(ActivationGroupDesc p0)
+ throws ActivationException, RemoteException
+ {
+ try
+ {
+ Object result = ref.invoke(this, met_registerGroup,
+ new Object[] { p0 }, 6921515268192657754L);
+ return (ActivationGroupID) result;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public ActivationGroupDesc getActivationGroupDesc(ActivationGroupID p0)
+ throws ActivationException, UnknownGroupException, RemoteException
+ {
+ try
+ {
+ Object result = ref.invoke(this, met_getActivationGroupDesc,
+ new Object[] { p0 }, -8701843806548736528L);
+ return (ActivationGroupDesc) result;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public void activeObject(ActivationID p0, MarshalledObject p1)
+ throws UnknownObjectException, RemoteException
+ {
+ try
+ {
+ ref.invoke(this, met_activeObject, new Object[] { p0, p1 },
+ 2543984342209939736L);
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public ActivationID registerObject(ActivationDesc p0)
+ throws ActivationException, UnknownGroupException, RemoteException
+ {
+ try
+ {
+ Object result = ref.invoke(this, met_registerObject,
+ new Object[] { p0 }, -3006759798994351347L);
+ return (ActivationID) result;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public void inactiveObject(ActivationID p0) throws UnknownObjectException,
+ RemoteException
+ {
+ try
+ {
+ ref.invoke(this, met_inactiveObject, new Object[] { p0 },
+ -4165404120701281807L);
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public void unregisterGroup(ActivationGroupID p0) throws ActivationException,
+ UnknownGroupException, RemoteException
+ {
+ try
+ {
+ ref.invoke(this, met_unregisterGroup, new Object[] { p0 },
+ 3768097077835970701L);
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+
+}
diff --git a/tools/gnu/classpath/tools/rmid/Main.java b/tools/gnu/classpath/tools/rmid/Main.java
new file mode 100644
index 000000000..d601b13f1
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmid/Main.java
@@ -0,0 +1,259 @@
+/* Main.java -- the RMI activation daemon.
+ Copyright (c) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.rmid;
+
+import gnu.classpath.tools.rmid.ActivationSystemImpl;
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.FileArgumentCallback;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+import gnu.java.rmi.activation.ActivationSystemTransient;
+import gnu.java.rmi.server.UnicastServerRef;
+
+import java.io.File;
+import java.net.InetAddress;
+import java.rmi.Remote;
+import java.rmi.activation.ActivationSystem;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.rmi.server.ObjID;
+import java.rmi.server.RMIServerSocketFactory;
+
+
+/**
+ * The persistent RMI activation daemon.
+ *
+ * @author Audrius Meskauskas (audriusa@bioinformatics.org)
+ */
+public class Main
+{
+ /**
+ * The RMI server socket factory.
+ */
+ static RMIServerSocketFactory ACTIVATION_REGISTY_SOCKET_FACTORY = null;
+
+ /**
+ * The activation registry port.
+ */
+ static int ACTIVATION_REGISTRY_PORT = ActivationSystem.SYSTEM_PORT;
+
+ /**
+ * The activation system name.
+ */
+ static String ACTIVATION_SYSTEM_NAME = "java.rmi.activation.ActivationSystem";
+
+ // Parse parameters:
+ private boolean stop = false;
+ private String directory = ".";
+ private boolean cold = false;
+ private boolean persistent = false;
+
+ private Parser initializeParser()
+ {
+ Parser parser = new ClasspathToolParser("rmiregistry", true); //$NON-NLS-1$
+ parser.setHeader(Messages.getString("Main.Usage")); //$NON-NLS-1$
+
+
+ OptionGroup controlGroup
+ = new OptionGroup(Messages.getString("Main.ControlGroup")); //$NON-NLS-1$
+ controlGroup.add(new Option("port", //$NON-NLS-1$
+ Messages.getString("Main.PortOption"), //$NON-NLS-1$
+ Messages.getString("Main.Port")) //$NON-NLS-1$
+ {
+ public void parsed(String portArgument) throws OptionException
+ {
+ ACTIVATION_REGISTRY_PORT = Integer.parseInt(portArgument);
+ }
+ });
+ controlGroup.add(new Option("restart", //$NON-NLS-1$
+ Messages.getString("Main.Restart")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ cold = true;
+ }
+ });
+ controlGroup.add(new Option("stop", //$NON-NLS-1$
+ Messages.getString("Main.Stop")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ stop = true;
+ }
+ });
+ parser.add(controlGroup);
+
+ OptionGroup persistenceGroup
+ = new OptionGroup(Messages.getString("Main.PersistenceGroup")); //$NON-NLS-1$
+ persistenceGroup.add(new Option("persistent", //$NON-NLS-1$
+ Messages.getString("Main.Persistent")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ persistent = true;
+ }
+ });
+ persistenceGroup.add(new Option("directory", //$NON-NLS-1$
+ Messages.getString("Main.Directory"), //$NON-NLS-1$
+ Messages.getString("Main.DirectoryArgument")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ directory = argument;
+ }
+ });
+ parser.add(persistenceGroup);
+
+ OptionGroup debuggingGroup
+ = new OptionGroup(Messages.getString("Main.DebugGroup")); //$NON-NLS-1$
+ debuggingGroup.add(new Option("verbose", //$NON-NLS-1$
+ Messages.getString ("Main.Verbose")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ ActivationSystemTransient.debug = true;
+ }
+ });
+ parser.add(debuggingGroup);
+
+ return parser;
+ }
+
+ private void run(String[] args)
+ {
+ Parser p = initializeParser();
+ p.parse(args);
+
+ try
+ {
+ if (!stop)
+ {
+ // Start the system.
+ File dataDirectory = new File(directory);
+ if (!dataDirectory.exists())
+ dataDirectory.mkdirs();
+ ActivationSystem system;
+
+ if (!persistent)
+ system = ActivationSystemTransient.getInstance();
+ else
+ system = ActivationSystemImpl.getInstance(dataDirectory, cold);
+
+ // We must export with the specific activation id that is only
+ // possible when going into the gnu.java.rmi.activation.
+ UnicastServerRef sref = new UnicastServerRef(
+ new ObjID(ObjID.ACTIVATOR_ID), ACTIVATION_REGISTRY_PORT,
+ ACTIVATION_REGISTY_SOCKET_FACTORY);
+ Remote systemStub = sref.exportObject(system);
+
+ // Start the naming system on the activation system port
+ // (if not already running).
+
+ Registry r;
+ try
+ {
+ // Expect the naming service running first.
+ // The local host may want to use the shared registry
+ r = LocateRegistry.getRegistry(ACTIVATION_REGISTRY_PORT);
+ r.rebind(ACTIVATION_SYSTEM_NAME, systemStub);
+ }
+ catch (Exception ex)
+ {
+ // The naming service is not running. Start it.
+ r = LocateRegistry.createRegistry(ACTIVATION_REGISTRY_PORT);
+ r.rebind(ACTIVATION_SYSTEM_NAME, systemStub);
+ }
+ String host = InetAddress.getLocalHost().getCanonicalHostName();
+ System.out.println("The RMI daemon is listening on " + host +
+ " (port "
+ + ACTIVATION_REGISTRY_PORT + ")");
+
+ }
+ else
+ {
+ // Stop the activation system.
+ Registry r;
+ try
+ {
+ System.out.print("Stopping RMI daemon at "
+ + ACTIVATION_REGISTRY_PORT+" ... ");
+ // Expect the naming service running first.
+ // The local host may want to use the shared registry
+ r = LocateRegistry.getRegistry(ACTIVATION_REGISTRY_PORT);
+ ActivationSystem asys =
+ (ActivationSystem) r.lookup(ACTIVATION_SYSTEM_NAME);
+ asys.shutdown();
+ System.out.println("OK.");
+ }
+ catch (Exception ex)
+ {
+ System.out.println("The RMI daemon seems not running at "
+ + ACTIVATION_REGISTRY_PORT);
+ if (ActivationSystemTransient.debug)
+ ex.printStackTrace();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ System.out.println("Failed to start the RMI daemon.");
+ if (ActivationSystemTransient.debug)
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * The activation system entry point.
+ */
+ public static void main(String[] args)
+ {
+ Main rmidprogram = new Main();
+ try
+ {
+ rmidprogram.run(args);
+ }
+ catch (Exception e)
+ {
+ System.err.println(Messages.getString("Main.InternalError")); //$NON-NLS-1$
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+ }
+}
diff --git a/tools/gnu/classpath/tools/rmid/Messages.java b/tools/gnu/classpath/tools/rmid/Messages.java
new file mode 100644
index 000000000..4365c6de7
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmid/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- localization support for rmid
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.rmid;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+ private static final String BUNDLE_NAME
+ = "gnu.classpath.tools.rmid.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE
+ = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages()
+ {
+ }
+
+ public static String getString(String key)
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString(key);
+ }
+ catch (MissingResourceException e)
+ {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/tools/gnu/classpath/tools/rmid/PersistentBidiHashTable.java b/tools/gnu/classpath/tools/rmid/PersistentBidiHashTable.java
new file mode 100644
index 000000000..d213373d5
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmid/PersistentBidiHashTable.java
@@ -0,0 +1,269 @@
+/* PersistentBidiHasthable.java -- Bidirectional persistent hash table.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.rmid;
+
+import gnu.classpath.tools.common.Persistent;
+import gnu.classpath.tools.rmid.ActivationSystemImpl;
+import gnu.java.rmi.activation.BidiTable;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TimerTask;
+
+/**
+ * The persistent bidirectional hash table, maps both a to b and b to a. The
+ * changes are written to dist after SAVE_AT_MOST_AFTER time from the latest
+ * database change or at most after ALWAYS_UPDATE, if the database is updated
+ * very frequently. To ensure that no information is lost, the shutdown method
+ * must be called before exit.
+ *
+ * @author Audrius Meskauskas (audriusa@bioinformatics.org)
+ */
+public class PersistentBidiHashTable extends BidiTable implements
+ Persistent
+{
+ class WriteToDiskTask extends TimerTask
+ {
+ /**
+ * Save the database.
+ */
+ public void run()
+ {
+ writeContent();
+ sheduled = null;
+ }
+ }
+
+ /**
+ * Replaces instances of ActivationSystemImpl into the currently active
+ * instance of the ActivationSystemImpl
+ */
+ class AdaptedReader extends ObjectInputStream
+ {
+ AdaptedReader(InputStream in) throws IOException
+ {
+ super(in);
+ enableResolveObject(true);
+ }
+
+ protected Object resolveObject(Object obj) throws IOException
+ {
+ if (obj instanceof ActivationSystemImpl)
+ return ActivationSystemImpl.singleton2;
+ else
+ return obj;
+ }
+ }
+
+ /**
+ * The database file.
+ */
+ File database;
+
+ /**
+ * The currently sheduled write to disk task, null if none.
+ */
+ WriteToDiskTask sheduled = null;
+
+ /**
+ * The time, when the disk database was last updated.
+ */
+ long lastUpdated;
+
+ /**
+ * Create the unitialised instance that must be initalised when
+ * ActivationSystemImpl.singleton2 is assigned.
+ */
+ public PersistentBidiHashTable()
+ {
+ // Do not initalise the table fields - the initalise method must be
+ // called later.
+ super(0);
+ }
+
+ /**
+ * Create a new persistent table that stores its information into the given
+ * file. The ActivationSystemImpl.singleton2 must be assigned.
+ *
+ * @param file
+ * the file, where the table stores its information.
+ * @param coldStart
+ * if true, the existing file with this name will be erased and
+ * ignored. Otherwise, it will be assumed that the file contains the
+ * persistent table information.
+ */
+ public void init(File file, boolean coldStart)
+ {
+ try
+ {
+ database = file;
+ if (database.exists())
+ {
+ if (coldStart)
+ {
+ k2v = new Hashtable();
+ v2k = new Hashtable();
+ database.delete();
+ }
+ else
+ {
+ FileInputStream fi = new FileInputStream(file);
+ BufferedInputStream b = new BufferedInputStream(fi);
+ ObjectInputStream oin = new AdaptedReader(b);
+
+ k2v = (Map) oin.readObject();
+ oin.close();
+
+ v2k = new Hashtable(k2v.size());
+
+ // Reguild v2k from k2v:
+ Iterator en = k2v.keySet().iterator();
+ Object key;
+ while (en.hasNext())
+ {
+ key = en.next();
+ v2k.put(k2v.get(key), key);
+ }
+ }
+ }
+ else
+ {
+ k2v = new Hashtable();
+ v2k = new Hashtable();
+ }
+ }
+ catch (Exception ioex)
+ {
+ InternalError ierr = new InternalError("Unable to intialize with file "
+ + file);
+ ierr.initCause(ioex);
+ throw ierr;
+ }
+ }
+
+ /**
+ * Write the database content to the disk.
+ */
+ public synchronized void writeContent()
+ {
+ try
+ {
+ FileOutputStream fou = new FileOutputStream(database);
+ BufferedOutputStream b = new BufferedOutputStream(fou);
+ ObjectOutputStream oout = new ObjectOutputStream(b);
+ oout.writeObject(k2v);
+ oout.close();
+ }
+ catch (Exception ioex)
+ {
+ InternalError ierr = new InternalError(
+ "Failed to write database to disk: "
+ + database);
+ ierr.initCause(ioex);
+ throw ierr;
+ }
+ }
+
+ /**
+ * Mark the modified database as modified. The database will be written after
+ * several seconds, unless another modification occurs.
+ */
+ public void markDirty()
+ {
+ if (System.currentTimeMillis() - lastUpdated > ALWAYS_UPDATE)
+ {
+ // Force storing to disk under intensive operation.
+ writeContent();
+ lastUpdated = System.currentTimeMillis();
+ if (sheduled != null)
+ {
+ sheduled.cancel();
+ sheduled = null;
+ }
+ }
+ else
+ {
+ // Otherwise coalesce the disk database copy update events.
+ if (sheduled != null)
+ sheduled.cancel();
+ sheduled = new WriteToDiskTask();
+ timer.schedule(sheduled, SAVE_AT_MOST_AFTER);
+ }
+ }
+
+ /**
+ * Save the current database state to the disk before exit.
+ */
+ public void shutdown()
+ {
+ if (sheduled != null)
+ {
+ writeContent();
+ sheduled = null;
+ }
+ }
+
+ /**
+ * Update the memory maps and mark as should be written to the disk.
+ */
+ public void put(Object key, Object value)
+ {
+ super.put(key, value);
+ markDirty();
+ }
+
+ /**
+ * Update the memory maps and mark as should be written to the disk.
+ */
+ public void removeKey(Object key)
+ {
+ super.removeKey(key);
+ markDirty();
+ }
+
+}
diff --git a/tools/gnu/classpath/tools/rmiregistry/Main.java b/tools/gnu/classpath/tools/rmiregistry/Main.java
new file mode 100644
index 000000000..e5c41930d
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmiregistry/Main.java
@@ -0,0 +1,232 @@
+/* Main.java -- RMI registry starter.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.rmiregistry;
+
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.FileArgumentCallback;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+import gnu.classpath.tools.rmiregistry.RegistryImpl;
+import gnu.java.rmi.server.UnicastServerRef;
+
+import java.io.File;
+import java.rmi.NotBoundException;
+import java.rmi.RemoteException;
+import java.rmi.registry.LocateRegistry;
+import java.rmi.registry.Registry;
+import java.rmi.server.ObjID;
+import java.rmi.server.RMIServerSocketFactory;
+import java.util.Hashtable;
+import java.util.Map;
+
+/**
+ * The optionally persistent RMI registry implementation.
+ *
+ * @author Audrius Meskauskas (audriusa@bioinformatics.org)
+ */
+public class Main
+{
+ /**
+ * The stop command.
+ */
+ public static String STOP = "gnu.classpath.tools.rmi.registry.command.STOP";
+
+ /**
+ * If true, the registry prints registration events to console.
+ */
+ public static boolean verbose = false;
+
+ /**
+ * Parsed parameters.
+ */
+ private String directory = ".";
+ private boolean cold = false;
+ private boolean persistent = false;
+ private boolean stop = false;
+ private int port = Registry.REGISTRY_PORT;
+ private RMIServerSocketFactory ssf = null;
+
+ private Parser initializeParser()
+ {
+ Parser parser = new ClasspathToolParser("rmiregistry", true); //$NON-NLS-1$
+ parser.setHeader(Messages.getString("Main.Usage")); //$NON-NLS-1$
+
+ OptionGroup controlGroup
+ = new OptionGroup(Messages.getString("Main.ControlGroup")); //$NON-NLS-1$
+ controlGroup.add(new Option("restart", //$NON-NLS-1$
+ Messages.getString("Main.Restart")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ cold = true;
+ }
+ });
+ controlGroup.add(new Option("stop", //$NON-NLS-1$
+ Messages.getString("Main.Stop")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ stop = true;
+ }
+ });
+ parser.add(controlGroup);
+
+ OptionGroup persistenceGroup
+ = new OptionGroup(Messages.getString("Main.PersistenceGroup")); //$NON-NLS-1$
+ persistenceGroup.add(new Option("persistent", //$NON-NLS-1$
+ Messages.getString("Main.Persistent")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ persistent = true;
+ }
+ });
+ persistenceGroup.add(new Option("directory", //$NON-NLS-1$
+ Messages.getString("Main.Directory"), //$NON-NLS-1$
+ Messages.getString("Main.DirectoryArgument")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ directory = argument;
+ }
+ });
+ parser.add(persistenceGroup);
+
+ OptionGroup debuggingGroup
+ = new OptionGroup(Messages.getString("Main.DebugGroup")); //$NON-NLS-1$
+ debuggingGroup.add(new Option("verbose", //$NON-NLS-1$
+ Messages.getString ("Main.Verbose")) //$NON-NLS-1$
+ {
+ public void parsed(String argument) throws OptionException
+ {
+ verbose = true;
+ }
+ });
+ parser.add(debuggingGroup);
+
+ return parser;
+ }
+
+ private void run(String[] args)
+ {
+ Parser p = initializeParser();
+ p.parse(args, new FileArgumentCallback()
+ {
+ public void notifyFile(String portArgument)
+ {
+ port = Integer.parseInt(portArgument);
+ }
+ });
+
+ if (!stop)
+ {
+ Map table;
+ if (!persistent)
+ table = new Hashtable();
+ else
+ {
+ // Start the system.
+ File dataDirectory = new File(directory);
+ if (!dataDirectory.exists())
+ dataDirectory.mkdirs();
+ table = PersistentHashTable.createInstance(
+ new File(dataDirectory, "rmiregistry.data"), cold);
+ }
+
+ RegistryImpl system = new RegistryImpl(table);
+
+ // We must export with the specific activation id that is only
+ // possible when going into the gnu.java.rmi
+ try
+ {
+ UnicastServerRef sref = new UnicastServerRef(
+ new ObjID(ObjID.REGISTRY_ID), port, ssf);
+
+ sref.exportObject(system);
+ System.out.println("The RMI naming service is listening at " + port);
+ }
+ catch (Exception ex)
+ {
+ System.out.println("Failed to start RMI naming service at " + port);
+ }
+ }
+ else
+ {
+ // Stop the naming service.
+ try
+ {
+ Registry r = LocateRegistry.getRegistry(port);
+ // Search for this specific line will command to stop the registry.
+
+ // Our service returns null, but any other service will thrown
+ // NotBoundException.
+ r.unbind(STOP);
+ }
+ catch (RemoteException e)
+ {
+ System.out.println("Failed to stop RMI naming service at " + port);
+ }
+ catch (NotBoundException e)
+ {
+ System.out.println("The naming service at port " + port + " is not a "
+ + Main.class.getName());
+ }
+ }
+ }
+
+ /**
+ * The RMI registry implementation entry point.
+ */
+ public static void main(String[] args)
+ {
+ Main rmiregistryprogram = new Main();
+ try
+ {
+ rmiregistryprogram.run(args);
+ }
+ catch (Exception e)
+ {
+ System.err.println(Messages.getString("Main.InternalError")); //$NON-NLS-1$
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+ }
+}
diff --git a/tools/gnu/classpath/tools/rmiregistry/Messages.java b/tools/gnu/classpath/tools/rmiregistry/Messages.java
new file mode 100644
index 000000000..05bfcf62d
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmiregistry/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- localization support for rmiregistry
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.rmiregistry;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+ private static final String BUNDLE_NAME
+ = "gnu.classpath.tools.rmiregistry.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE
+ = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages()
+ {
+ }
+
+ public static String getString(String key)
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString(key);
+ }
+ catch (MissingResourceException e)
+ {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/tools/gnu/classpath/tools/rmiregistry/PersistentHashTable.java b/tools/gnu/classpath/tools/rmiregistry/PersistentHashTable.java
new file mode 100644
index 000000000..89d66ce4a
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmiregistry/PersistentHashTable.java
@@ -0,0 +1,262 @@
+/* PersistentHasthable.java -- Persistent hash table.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.rmiregistry;
+
+import gnu.classpath.tools.common.Persistent;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.TimerTask;
+
+/**
+ * The persistent hash table. The changes are written to dist after
+ * SAVE_AT_MOST_AFTER time from the latest database change or at most after
+ * ALWAYS_UPDATE, if the database is updated very frequently. To ensure that no
+ * information is lost, the shutdown method must be called before exit.
+ *
+ * @author Audrius Meskauskas (audriusa@bioinformatics.org)
+ */
+public class PersistentHashTable
+ extends Hashtable
+ implements Serializable, Persistent
+{
+
+ /**
+ * Use serialVersionUID for interoperability
+ */
+ private static final long serialVersionUID = 1;
+
+ class WriteToDiskTask extends TimerTask
+ {
+ /**
+ * Save the database.
+ */
+ public void run()
+ {
+ writeContent();
+ sheduled = null;
+ }
+ }
+
+ /**
+ * The database file.
+ */
+ File database;
+
+ /**
+ * The currently sheduled write to disk task, null if none.
+ */
+ WriteToDiskTask sheduled = null;
+
+ /**
+ * The time, when the disk database was last updated.
+ */
+ long lastUpdated;
+
+ /**
+ * Setting to false prevents the automated disk update.
+ * The initial value is true to prevent writing while reading and is set
+ * to false in createInstance.
+ */
+ transient boolean ready;
+
+ /**
+ * Use static method to obtain the instance.
+ */
+ private PersistentHashTable(File file)
+ {
+ if (file == null)
+ throw new NullPointerException("Null file provided");
+ database = file;
+ }
+
+ /**
+ * Create a new persistent table that stores its information into the given
+ * file.
+ *
+ * @param file
+ * the file, where the table stores its information.
+ * @param coldStart
+ * if true, the existing file with this name will be erased and
+ * ignored. Otherwise, it will be assumed that the file contains the
+ * persistent table information.
+ */
+ public static Map createInstance(File file, boolean coldStart)
+ {
+ try
+ {
+ PersistentHashTable k2v;
+ System.out.println ("Here1");
+ if (file.exists())
+ {
+ System.out.println ("Here2");
+ if (coldStart)
+ {
+ System.out.println ("Here2.5");
+ file.delete();
+ k2v = new PersistentHashTable(file);
+ }
+ else
+ {
+ System.out.println ("Here3");
+ FileInputStream fi = new FileInputStream(file);
+ System.out.println ("Here3.1");
+ BufferedInputStream b = new BufferedInputStream(fi);
+ System.out.println ("Here3.2");
+ ObjectInputStream oin = new ObjectInputStream(b);
+ System.out.println ("Here3.3");
+
+ System.out.println ("Here4");
+ k2v = (PersistentHashTable) oin.readObject();
+ oin.close();
+ System.out.println ("Here5");
+ }
+ }
+ else
+ {
+ System.out.println ("Here6");
+ k2v = new PersistentHashTable(file);
+ System.out.println ("Here7");
+ }
+
+ System.out.println ("Here8");
+ k2v.ready = true;
+ return k2v;
+ }
+ catch (Exception ioex)
+ {
+ InternalError ierr = new InternalError("Unable to intialize with file "
+ + file);
+ ierr.initCause(ioex);
+ throw ierr;
+ }
+ }
+
+
+ /**
+ * Write the database content to the disk.
+ */
+ public synchronized void writeContent()
+ {
+ try
+ {
+ FileOutputStream fou = new FileOutputStream(database);
+ BufferedOutputStream b = new BufferedOutputStream(fou);
+ ObjectOutputStream oout = new ObjectOutputStream(b);
+ oout.writeObject(this);
+ oout.close();
+ }
+ catch (Exception ioex)
+ {
+ InternalError ierr = new InternalError(
+ "Failed to write database to disk: "+ database);
+ ierr.initCause(ioex);
+ throw ierr;
+ }
+ }
+
+ /**
+ * Mark the modified database as modified. The database will be written after
+ * several seconds, unless another modification occurs.
+ */
+ public void markDirty()
+ {
+ if (System.currentTimeMillis() - lastUpdated > ALWAYS_UPDATE)
+ {
+ // Force storing to disk under intensive operation.
+ writeContent();
+ lastUpdated = System.currentTimeMillis();
+ if (sheduled != null)
+ {
+ sheduled.cancel();
+ sheduled = null;
+ }
+ }
+ else
+ {
+ // Otherwise coalesce the disk database copy update events.
+ if (sheduled != null)
+ sheduled.cancel();
+ sheduled = new WriteToDiskTask();
+ timer.schedule(sheduled, SAVE_AT_MOST_AFTER);
+ }
+ }
+
+ /**
+ * Save the current database state to the disk before exit.
+ */
+ public void shutdown()
+ {
+ if (sheduled != null)
+ {
+ writeContent();
+ sheduled = null;
+ }
+ }
+
+ /**
+ * Update the memory maps and mark as should be written to the disk.
+ */
+ public Object put(Object key, Object value)
+ {
+ super.put(key, value);
+ if (ready)
+ markDirty();
+ return value;
+ }
+
+ /**
+ * Update the memory maps and mark as should be written to the disk.
+ */
+ public Object remove(Object key)
+ {
+ Object removed = super.remove(key);
+ if (ready)
+ markDirty();
+ return removed;
+ }
+
+}
diff --git a/tools/gnu/classpath/tools/rmiregistry/RegistryImpl.java b/tools/gnu/classpath/tools/rmiregistry/RegistryImpl.java
new file mode 100644
index 000000000..b93d3c116
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmiregistry/RegistryImpl.java
@@ -0,0 +1,138 @@
+/* RegistryImpl.java -- the RMI registry implementation
+ Copyright (c) 1996, 1997, 1998, 1999, 2002, 2005, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.rmiregistry;
+
+import gnu.classpath.tools.common.Persistent;
+
+import java.rmi.AccessException;
+import java.rmi.AlreadyBoundException;
+import java.rmi.NotBoundException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.registry.Registry;
+import java.util.ArrayList;
+import java.util.Map;
+
+/**
+ * The optionally persistent registry implementation.
+ *
+ * @author Audrius Meskauskas (audriusa@bioinformatics.org)
+ */
+public class RegistryImpl implements Registry
+{
+ /**
+ * The binding table.
+ */
+ Map bindings;
+
+ /**
+ * Create the registry implementation that uses the given bidirectinal
+ * table to keep the data.
+ */
+ public RegistryImpl(Map aTable)
+ {
+ bindings = aTable;
+ }
+
+ /** @inheritDoc */
+ public Remote lookup(String name) throws RemoteException, NotBoundException,
+ AccessException
+ {
+ Object obj = bindings.get(name);
+ if (obj == null)
+ throw new NotBoundException(name);
+ return ((Remote) obj);
+ }
+
+ /** @inheritDoc */
+ public void bind(String name, Remote obj) throws RemoteException,
+ AlreadyBoundException, AccessException
+ {
+ if (Main.verbose)
+ System.out.println("Bind "+name);
+ if (bindings.containsKey(name))
+ throw new AlreadyBoundException(name);
+ bindings.put(name, obj);
+ }
+
+ /** @inheritDoc */
+ public void unbind(String name) throws RemoteException, NotBoundException,
+ AccessException
+ {
+ if (name.equals(Main.STOP))
+ {
+ if (bindings instanceof Persistent)
+ ((Persistent) bindings).writeContent();
+ // Terminate in 10 seconds.
+ System.out.println("Shutdown command received. Will terminate in 10 s");
+ Persistent.timer.schedule(new Persistent.ExitTask(), 10000);
+ }
+ else
+ {
+ if (Main.verbose)
+ System.out.println("Unbind "+name);
+
+ if (!bindings.containsKey(name))
+ throw new NotBoundException(name);
+ else
+ bindings.remove(name);
+ }
+ }
+
+ /** @inheritDoc */
+ public void rebind(String name, Remote obj) throws RemoteException,
+ AccessException
+ {
+ if (Main.verbose)
+ System.out.println("Rebind "+name);
+ bindings.put(name, obj);
+ }
+
+ /** @inheritDoc */
+ public String[] list() throws RemoteException, AccessException
+ {
+ // Create a separated array to prevent race conditions.
+ ArrayList keys = new ArrayList(bindings.keySet());
+ int n = keys.size();
+ String[] rt = new String[n];
+ for (int i = 0; i < n; i++)
+ rt[i] = (String) keys.get(i);
+ return rt;
+ }
+}
diff --git a/tools/gnu/classpath/tools/rmiregistry/RegistryImpl_Skel.java b/tools/gnu/classpath/tools/rmiregistry/RegistryImpl_Skel.java
new file mode 100644
index 000000000..5150debd1
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmiregistry/RegistryImpl_Skel.java
@@ -0,0 +1,278 @@
+/* RegistryImpl_Skel.java
+ Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.classpath.tools.rmiregistry;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.rmi.MarshalException;
+import java.rmi.Remote;
+import java.rmi.UnmarshalException;
+import java.rmi.server.Operation;
+import java.rmi.server.RemoteCall;
+import java.rmi.server.SkeletonMismatchException;
+
+/**
+ * This skeleton supports unlikely cases when the naming service is
+ * contacted from other interoperable java implementation that still uses
+ * the old style skeleton-dependent invocations.
+ */
+public final class RegistryImpl_Skel
+ implements java.rmi.server.Skeleton
+{
+ private static final long interfaceHash = 4905912898345647071L;
+
+ /**
+ * Repeated multiple times.
+ */
+ static final String EUM = "error unmarshalling arguments for Registry";
+
+ /**
+ * Repeated multiple times.
+ */
+ static final String EMR = "error marshalling return from Registry";
+
+ private static final Operation[] operations =
+ {
+ new Operation("void bind(java.lang.String, Remote"),
+ new Operation("java.lang.String[] list("),
+ new Operation("Remote lookup(java.lang.String"),
+ new Operation("void rebind(java.lang.String, Remote"),
+ new Operation("void unbind(java.lang.String")
+ };
+
+ public Operation[] getOperations()
+ {
+ return ((Operation[]) operations.clone());
+ }
+
+ public void dispatch(Remote obj, RemoteCall call,
+ int opnum, long hash) throws java.lang.Exception
+ {
+ if (opnum < 0)
+ {
+ if (hash == 7583982177005850366L)
+ opnum = 0;
+ else if (hash == 2571371476350237748L)
+ opnum = 1;
+ else if (hash == -7538657168040752697L)
+ opnum = 2;
+ else if (hash == -8381844669958460146L)
+ opnum = 3;
+ else if (hash == 7305022919901907578L)
+ opnum = 4;
+ else
+ throw new SkeletonMismatchException("interface hash mismatch");
+ }
+ else if (hash != interfaceHash)
+ throw new SkeletonMismatchException("interface hash mismatch");
+
+ RegistryImpl server = (RegistryImpl) obj;
+ switch (opnum)
+ {
+ case 0:
+ {
+ java.lang.String $param_0;
+ Remote $param_1;
+ try
+ {
+ ObjectInput in = call.getInputStream();
+ $param_0 = (java.lang.String) in.readObject();
+ $param_1 = (Remote) in.readObject();
+
+ }
+ catch (IOException e)
+ {
+ throw new UnmarshalException(EUM, e);
+ }
+ catch (java.lang.ClassCastException e)
+ {
+ throw new UnmarshalException(EUM, e);
+ }
+ finally
+ {
+ call.releaseInputStream();
+ }
+ server.bind($param_0, $param_1);
+ try
+ {
+ ObjectOutput out = call.getResultStream(true);
+ }
+ catch (IOException e)
+ {
+ throw new MarshalException(EMR, e);
+ }
+ break;
+ }
+
+ case 1:
+ {
+ try
+ {
+ ObjectInput in = call.getInputStream();
+
+ }
+ catch (IOException e)
+ {
+ throw new UnmarshalException(EUM, e);
+ }
+ finally
+ {
+ call.releaseInputStream();
+ }
+ java.lang.String[] $result = server.list();
+ try
+ {
+ ObjectOutput out = call.getResultStream(true);
+ out.writeObject($result);
+ }
+ catch (IOException e)
+ {
+ throw new MarshalException(EMR, e);
+ }
+ break;
+ }
+
+ case 2:
+ {
+ java.lang.String $param_0;
+ try
+ {
+ ObjectInput in = call.getInputStream();
+ $param_0 = (java.lang.String) in.readObject();
+
+ }
+ catch (IOException e)
+ {
+ throw new UnmarshalException(EUM, e);
+ }
+ catch (java.lang.ClassCastException e)
+ {
+ throw new UnmarshalException(EUM, e);
+ }
+ finally
+ {
+ call.releaseInputStream();
+ }
+ Remote $result = server.lookup($param_0);
+ try
+ {
+ ObjectOutput out = call.getResultStream(true);
+ out.writeObject($result);
+ }
+ catch (IOException e)
+ {
+ throw new MarshalException(EMR, e);
+ }
+ break;
+ }
+
+ case 3:
+ {
+ java.lang.String $param_0;
+ Remote $param_1;
+ try
+ {
+ ObjectInput in = call.getInputStream();
+ $param_0 = (java.lang.String) in.readObject();
+ $param_1 = (Remote) in.readObject();
+
+ }
+ catch (IOException e)
+ {
+ throw new UnmarshalException(EUM, e);
+ }
+ catch (java.lang.ClassCastException e)
+ {
+ throw new UnmarshalException(EUM, e);
+ }
+ finally
+ {
+ call.releaseInputStream();
+ }
+ server.rebind($param_0, $param_1);
+ try
+ {
+ ObjectOutput out = call.getResultStream(true);
+ }
+ catch (IOException e)
+ {
+ throw new MarshalException(EMR, e);
+ }
+ break;
+ }
+
+ case 4:
+ {
+ java.lang.String $param_0;
+ try
+ {
+ ObjectInput in = call.getInputStream();
+ $param_0 = (java.lang.String) in.readObject();
+
+ }
+ catch (IOException e)
+ {
+ throw new UnmarshalException(EUM, e);
+ }
+ catch (java.lang.ClassCastException e)
+ {
+ throw new UnmarshalException(EUM, e);
+ }
+ finally
+ {
+ call.releaseInputStream();
+ }
+ server.unbind($param_0);
+ try
+ {
+ ObjectOutput out = call.getResultStream(true);
+ }
+ catch (IOException e)
+ {
+ throw new MarshalException(EMR, e);
+ }
+ break;
+ }
+
+ default:
+ throw new UnmarshalException("invalid method number");
+ }
+ }
+}
diff --git a/tools/gnu/classpath/tools/rmiregistry/RegistryImpl_Stub.java b/tools/gnu/classpath/tools/rmiregistry/RegistryImpl_Stub.java
new file mode 100644
index 000000000..94d35e92f
--- /dev/null
+++ b/tools/gnu/classpath/tools/rmiregistry/RegistryImpl_Stub.java
@@ -0,0 +1,263 @@
+/* RegistryImpl_Stub.java -- Registry stub.
+ Copyright (c) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.rmiregistry;
+
+import java.rmi.AccessException;
+import java.rmi.AlreadyBoundException;
+import java.rmi.NotBoundException;
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.rmi.registry.Registry;
+
+import java.lang.reflect.Method;
+import java.rmi.server.RemoteRef;
+import java.rmi.server.RemoteStub;
+import java.rmi.UnexpectedException;
+
+/**
+ * This class delegates its method calls to the remote RMI object, referenced
+ * by {@link RemoteRef}.
+ *
+ * It is normally generated with rmic.
+ */
+public final class RegistryImpl_Stub
+ extends RemoteStub
+ implements Registry
+{
+ /**
+ * Use serialVersionUID for interoperability
+ */
+ private static final long serialVersionUID = 3;
+
+ /**
+ * The explaining message for {@ling UnexpectedException}.
+ */
+ private static final String exception_message =
+ "undeclared checked exception";
+
+ /* All remote methods, invoked by this stub: */
+ private static final Method met_list;
+ private static final Method met_rebind;
+ private static final Method met_unbind;
+ private static final Method met_lookup;
+ private static final Method met_bind;
+ private static final Object[] NO_ARGS = new Object[0];
+ static
+ {
+ final Class[] NO_ARGSc = new Class[0];
+ try
+ {
+ met_list =
+ Registry.class.getMethod("list", NO_ARGSc);
+ met_rebind =
+ Registry.class.getMethod("rebind", new Class[]
+ {
+ String.class, Remote.class
+ });
+ met_unbind =
+ Registry.class.getMethod("unbind", new Class[]
+ {
+ String.class
+ });
+ met_lookup =
+ Registry.class.getMethod("lookup", new Class[]
+ {
+ String.class
+ });
+ met_bind =
+ Registry.class.getMethod("bind", new Class[]
+ {
+ String.class, Remote.class
+ });
+
+ }
+ catch (NoSuchMethodException nex)
+ {
+ NoSuchMethodError err = new NoSuchMethodError(
+ "RegistryImpl_Stub class initialization failed");
+ err.initCause(nex);
+ throw err;
+ }
+ }
+
+ /**
+ * Create the instance for _RegistryImpl_Stub that forwards method calls to the
+ * remote object.
+ *
+ * @para the reference to the remote object.
+ */
+ public RegistryImpl_Stub(RemoteRef reference)
+ {
+ super(reference);
+ }
+
+ /* Methods */
+ /** @inheritDoc */
+ public String [] list()
+ throws RemoteException, AccessException
+ {
+ try
+ {
+ Object result = ref.invoke(this, met_list,
+ NO_ARGS,
+ 2571371476350237748L);
+ return (String []) result;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public void rebind(String p0, Remote p1)
+ throws RemoteException, AccessException
+ {
+ try
+ {
+ ref.invoke(this, met_rebind,
+ new Object[] {p0, p1},
+ -8381844669958460146L);
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public void unbind(String p0)
+ throws RemoteException, NotBoundException, AccessException
+ {
+ try
+ {
+ ref.invoke(this, met_unbind,
+ new Object[] {p0},
+ 7305022919901907578L);
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public Remote lookup(String p0)
+ throws RemoteException, NotBoundException, AccessException
+ {
+ try
+ {
+ Object result = ref.invoke(this, met_lookup,
+ new Object[] {p0},
+ -7538657168040752697L);
+ return (Remote) result;
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+ /** @inheritDoc */
+ public void bind(String p0, Remote p1)
+ throws RemoteException, AlreadyBoundException, AccessException
+ {
+ try
+ {
+ ref.invoke(this, met_bind,
+ new Object[] {p0, p1},
+ 7583982177005850366L);
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (RemoteException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ UnexpectedException uex = new UnexpectedException(exception_message);
+ uex.detail = e;
+ throw uex;
+ }
+ }
+
+
+}
diff --git a/tools/gnu/classpath/tools/serialver/SerialVer.java b/tools/gnu/classpath/tools/serialver/SerialVer.java
index b5a12ec92..21e0a805a 100644
--- a/tools/gnu/classpath/tools/serialver/SerialVer.java
+++ b/tools/gnu/classpath/tools/serialver/SerialVer.java
@@ -21,7 +21,7 @@
package gnu.classpath.tools.serialver;
-import gnu.classpath.tools.getopt.ClasspathToolParser;
+import gnu.classpath.tools.common.ClasspathToolParser;
import gnu.classpath.tools.getopt.FileArgumentCallback;
import gnu.classpath.tools.getopt.Option;
import gnu.classpath.tools.getopt.OptionException;
diff --git a/tools/gnu/classpath/tools/tnameserv/Main.java b/tools/gnu/classpath/tools/tnameserv/Main.java
new file mode 100644
index 000000000..460b78185
--- /dev/null
+++ b/tools/gnu/classpath/tools/tnameserv/Main.java
@@ -0,0 +1,117 @@
+/* Main.java -- Transient GIOP naming service.
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+package gnu.classpath.tools.tnameserv;
+
+import gnu.CORBA.NamingService.NamingServiceTransient;
+import gnu.classpath.tools.common.ClasspathToolParser;
+import gnu.classpath.tools.getopt.FileArgumentCallback;
+import gnu.classpath.tools.getopt.Option;
+import gnu.classpath.tools.getopt.OptionException;
+import gnu.classpath.tools.getopt.OptionGroup;
+import gnu.classpath.tools.getopt.Parser;
+
+/**
+ * The implementation of the transient naming service. The naming service
+ * is a kind of the network server that registers local and remote objects
+ * by name, and later can provide the object reference in response to the
+ * given name.
+ *
+ * GNU Classpath currently works with this naming service and is also
+ * interoperable with the Sun Microsystems naming services from releases 1.3 and
+ * 1.4, both transient tnameserv and persistent orbd.
+ *
+ * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
+ */
+public class Main
+{
+ private int port = -1;
+ private String iorf;
+
+ private Parser initializeParser()
+ {
+ Parser parser = new ClasspathToolParser("tnameserv", true); //$NON-NLS-1$
+ parser.setHeader(Messages.getString("Main.Usage")); //$NON-NLS-1$
+
+ parser.add(new Option("ORBInitialPort", //$NON-NLS-1$
+ Messages.getString("Main.ORBInitialPort"), //$NON-NLS-1$
+ Messages.getString("Main.Port")) //$NON-NLS-1$
+ {
+ public void parsed(String portArgument) throws OptionException
+ {
+ port = Integer.parseInt(portArgument);
+ }
+ });
+
+ parser.add(new Option("ior", //$NON-NLS-1$
+ Messages.getString("Main.IOR"), //$NON-NLS-1$
+ Messages.getString("Main.IORFile")) //$NON-NLS-1$
+ {
+ public void parsed(String fileArgument) throws OptionException
+ {
+ iorf = fileArgument;
+ }
+ });
+
+ return parser;
+ }
+
+ private void run(String[] args)
+ {
+ Parser p = initializeParser();
+ p.parse(args);
+ NamingServiceTransient.start(port, iorf);
+ }
+
+ /**
+ * The naming service entry point.
+ */
+ public static void main(String[] args)
+ {
+ Main tnameservprogram = new Main();
+ try
+ {
+ tnameservprogram.run(args);
+ }
+ catch (Exception e)
+ {
+ System.err.println(Messages.getString("Main.InternalError")); //$NON-NLS-1$
+ e.printStackTrace(System.err);
+ System.exit(1);
+ }
+ }
+}
diff --git a/tools/gnu/classpath/tools/tnameserv/Messages.java b/tools/gnu/classpath/tools/tnameserv/Messages.java
new file mode 100644
index 000000000..505397302
--- /dev/null
+++ b/tools/gnu/classpath/tools/tnameserv/Messages.java
@@ -0,0 +1,67 @@
+/* Messages.java -- localization support for tnameserv
+ Copyright (C) 2006 Free Software Foundation, Inc.
+
+ This file is part of GNU Classpath.
+
+ GNU Classpath is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ GNU Classpath is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Classpath; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301 USA.
+
+ Linking this library statically or dynamically with other modules is
+ making a combined work based on this library. Thus, the terms and
+ conditions of the GNU General Public License cover the whole
+ combination.
+
+ As a special exception, the copyright holders of this library give you
+ permission to link this library with independent modules to produce an
+ executable, regardless of the license terms of these independent
+ modules, and to copy and distribute the resulting executable under
+ terms of your choice, provided that you also meet, for each linked
+ independent module, the terms and conditions of the license of that
+ module. An independent module is a module which is not derived from
+ or based on this library. If you modify this library, you may extend
+ this exception to your version of the library, but you are not
+ obligated to do so. If you do not wish to do so, delete this
+ exception statement from your version. */
+
+
+package gnu.classpath.tools.tnameserv;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages
+{
+ private static final String BUNDLE_NAME
+ = "gnu.classpath.tools.tnameserv.messages"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE
+ = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ private Messages()
+ {
+ }
+
+ public static String getString(String key)
+ {
+ try
+ {
+ return RESOURCE_BUNDLE.getString(key);
+ }
+ catch (MissingResourceException e)
+ {
+ return '!' + key + '!';
+ }
+ }
+}
diff --git a/tools/gorbd.in b/tools/gorbd.in
new file mode 100644
index 000000000..ab1a19a86
--- /dev/null
+++ b/tools/gorbd.in
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath orbd tool.
+##
+
+prefix=@prefix@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.orbd.Main "$@"
diff --git a/tools/grmic.in b/tools/grmic.in
new file mode 100644
index 000000000..2bb29a721
--- /dev/null
+++ b/tools/grmic.in
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath rmic tool.
+##
+
+prefix=@prefix@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip:@PATH_TO_ASM@
+
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.rmic.Main "$@"
diff --git a/tools/grmid.in b/tools/grmid.in
new file mode 100644
index 000000000..aa4e1432a
--- /dev/null
+++ b/tools/grmid.in
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath rmid tool.
+##
+
+prefix=@prefix@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.rmid.Main "$@"
diff --git a/tools/grmiregistry.in b/tools/grmiregistry.in
new file mode 100644
index 000000000..5e2798fd3
--- /dev/null
+++ b/tools/grmiregistry.in
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath rmiregistry tool.
+##
+
+prefix=@prefix@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.rmiregistry.Main "$@"
diff --git a/tools/gtnameserv.in b/tools/gtnameserv.in
new file mode 100644
index 000000000..c8e7484f6
--- /dev/null
+++ b/tools/gtnameserv.in
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+## Copyright (C) 2006 Free Software Foundation, Inc.
+##
+## This file is a part of GNU Classpath.
+##
+## GNU Classpath is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or (at
+## your option) any later version.
+##
+## GNU Classpath is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with GNU Classpath; if not, write to the Free Software
+## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
+## USA.
+##
+## Linking this library statically or dynamically with other modules is
+## making a combined work based on this library. Thus, the terms and
+## conditions of the GNU General Public License cover the whole
+## combination.
+##
+## As a special exception, the copyright holders of this library give you
+## permission to link this library with independent modules to produce an
+## executable, regardless of the license terms of these independent
+## modules, and to copy and distribute the resulting executable under
+## terms of your choice, provided that you also meet, for each linked
+## independent module, the terms and conditions of the license of that
+## module. An independent module is a module which is not derived from
+## or based on this library. If you modify this library, you may extend
+## this exception to your version of the library, but you are not
+## obligated to do so. If you do not wish to do so, delete this
+## exception statement from your version.
+##
+##
+## A simple shell script to launch the GNU Classpath tnameserv tool.
+##
+
+prefix=@prefix@
+tools_dir=@datadir@/@PACKAGE@
+tools_cp=${tools_dir}/tools.zip
+
+exec @VM_BINARY@ -Xbootclasspath/p:"${tools_cp}" gnu.classpath.tools.tnameserv.Main "$@"
diff --git a/vm/reference/gnu/java/net/VMPlainSocketImpl.java b/vm/reference/gnu/java/net/VMPlainSocketImpl.java
index 76be558dc..126294c7f 100644
--- a/vm/reference/gnu/java/net/VMPlainSocketImpl.java
+++ b/vm/reference/gnu/java/net/VMPlainSocketImpl.java
@@ -38,8 +38,11 @@ exception statement from your version. */
package gnu.java.net;
import java.io.IOException;
+import java.net.Inet4Address;
+import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.InetSocketAddress;
+import java.net.NetworkInterface;
import java.net.SocketAddress;
import java.net.SocketException;
import java.net.SocketImpl;
@@ -47,6 +50,8 @@ import java.net.SocketOptions;
import java.net.UnknownHostException;
import gnu.classpath.Configuration;
+import gnu.java.nio.VMChannel;
+import gnu.java.nio.VMChannel.State;
/**
* The VM interface for {@link gnu.java.net.PlainSocketImpl}.
@@ -56,6 +61,8 @@ import gnu.classpath.Configuration;
*/
public final class VMPlainSocketImpl
{
+ private final State nfd;
+
/**
* Static initializer to load native library.
*/
@@ -66,249 +73,333 @@ public final class VMPlainSocketImpl
System.loadLibrary("javanet");
}
}
+
+ public VMPlainSocketImpl()
+ {
+ // XXX consider adding security check here.
+ nfd = new State();
+ }
+
+ public VMPlainSocketImpl(VMChannel channel) throws IOException
+ {
+ this();
+ nfd.setChannelFD(channel.getState());
+ }
+
+ public State getState()
+ {
+ return nfd;
+ }
- /**
- * Sets the specified option on a socket to the passed in object.
- * The optionId parameter is one of the defined constants in
- * the SocketImpl interface.
- *
- * @param socket the socket object
- * @param optionId the identifier of the option
- * @param value the value to set the option to
- *
- * @throws SocketException if an error occurs
- */
- static native void setOption(PlainSocketImpl socket, int optionId, Object value)
- throws SocketException;
-
- /**
- * Returns the current setting of the specified option. The optionId
- * is one of the defined constants in this interface.
- *
- * @param socket the socket object
- * @param optionId the option identifier
- *
- * @return the current value of the option
- *
- * @throws SocketException ff an error occurs
- */
- static native Object getOption(PlainSocketImpl socket, int optionId)
+ public void setOption(int optionId, Object optionValue)
+ throws SocketException
+ {
+ int value;
+ if (optionValue instanceof Integer)
+ value = ((Integer) optionValue).intValue();
+ else if (optionValue instanceof Boolean)
+ value = ((Boolean) optionValue).booleanValue() ? 1 : 0;
+ else
+ throw new IllegalArgumentException("option value type "
+ + optionValue.getClass().getName());
+
+ try
+ {
+ setOption(nfd.getNativeFD(), optionId, value);
+ }
+ catch (IOException ioe)
+ {
+ SocketException se = new SocketException();
+ se.initCause(ioe);
+ throw se;
+ }
+ }
+
+ private static native void setOption(int fd, int id, int value)
throws SocketException;
/**
- * Creates a new socket that is not bound to any local address/port and
- * is not connected to any remote address/port.
- *
- * @param socket the socket object
- *
- * @throws IOException if something goes wrong while creating the socket
+ * Get a socket option. This implementation is only required to support
+ * socket options that are boolean values, which include:
+ *
+ * SocketOptions.IP_MULTICAST_LOOP
+ * SocketOptions.SO_BROADCAST
+ * SocketOptions.SO_KEEPALIVE
+ * SocketOptions.SO_OOBINLINE
+ * SocketOptions.TCP_NODELAY
+ *
+ * and socket options that are integer values, which include:
+ *
+ * SocketOptions.IP_TOS
+ * SocketOptions.SO_LINGER
+ * SocketOptions.SO_RCVBUF
+ * SocketOptions.SO_SNDBUF
+ * SocketOptions.SO_TIMEOUT
+ *
+ * @param optionId The option ID to fetch.
+ * @return A {@link Boolean} or {@link Integer} containing the socket
+ * option.
+ * @throws SocketException
*/
- static native void create(PlainSocketImpl socket) throws IOException;
-
+ public Object getOption(int optionId) throws SocketException
+ {
+ int value;
+ try
+ {
+ value = getOption(nfd.getNativeFD(), optionId);
+ }
+ catch (IOException ioe)
+ {
+ SocketException se = new SocketException();
+ se.initCause(ioe);
+ throw se;
+ }
+
+ switch (optionId)
+ {
+ case SocketOptions.IP_MULTICAST_LOOP:
+ case SocketOptions.SO_BROADCAST:
+ case SocketOptions.SO_KEEPALIVE:
+ case SocketOptions.SO_OOBINLINE:
+ case SocketOptions.TCP_NODELAY:
+ return Boolean.valueOf(value != 0);
+
+ case SocketOptions.IP_TOS:
+ case SocketOptions.SO_LINGER:
+ case SocketOptions.SO_RCVBUF:
+ case SocketOptions.SO_SNDBUF:
+ case SocketOptions.SO_TIMEOUT:
+ return new Integer(value);
+
+ default:
+ throw new SocketException("getting option " + optionId +
+ " not supported here");
+ }
+ }
+
+ private static native int getOption(int fd, int id) throws SocketException;
+
/**
- * Connects to the remote address and port specified as arguments.
+ * Binds this socket to the given local address and port.
*
- * @param socket the socket object
- * @param addr the remote address to connect to
- * @param port the remote port to connect to
- *
- * @throws IOException if an error occurs
+ * @param address The address to bind to; the InetAddress is either
+ * an IPv4 or IPv6 address.
+ * @throws IOException If binding fails; for example, if the port
+ * in the given InetSocketAddress is privileged, and the current
+ * process has insufficient privileges.
*/
- static native void connect(PlainSocketImpl socket, InetAddress addr,
- int port) throws IOException;
-
+ public void bind(InetSocketAddress address) throws IOException
+ {
+ InetAddress addr = address.getAddress();
+ if (addr instanceof Inet4Address)
+ {
+ bind (nfd.getNativeFD(), addr.getAddress(), address.getPort());
+ }
+ else if (addr instanceof Inet6Address)
+ bind6 (nfd.getNativeFD(), addr.getAddress(), address.getPort());
+ else
+ throw new SocketException ("unsupported address type");
+ }
+
/**
- * Binds to the specified port on the specified addr. Note that this addr
- * must represent a local IP address. **** How bind to INADDR_ANY? ****
- *
- * @param socket the socket object
- * @param addr the address to bind to
- * @param port the port number to bind to
+ * Native bind function for IPv4 addresses. The addr array must be
+ * exactly four bytes long.
+ *
+ * VMs without native support need not implement this.
*
- * @exception IOException If an error occurs
+ * @param fd The native file descriptor integer.
+ * @param addr The IPv4 address, in network byte order.
+ * @param port The port to bind to.
+ * @throws IOException
*/
- static native void bind(PlainSocketImpl socket, InetAddress addr, int port)
+ private static native void bind(int fd, byte[] addr, int port)
throws IOException;
-
+
/**
- * Starts listening for connections on a socket. The queueLen parameter
- * is how many pending connections will queue up waiting to be serviced
- * before being accepted. If the queue of pending requests exceeds this
- * number, additional connections will be refused.
- *
- * @param socket the socket object
- * @param queueLen the length of the pending connection queue
+ * Native bind function for IPv6 addresses. The addr array must be
+ * exactly sixteen bytes long.
*
- * @exception IOException if an error occurs
- */
- static native void listen(PlainSocketImpl socket, int queueLen)
- throws IOException;
-
- /**
- * Accepts a new connection on this socket.
+ * VMs without native support need not implement this.
*
- * @param socket the socket object
- * @param impl the socket object to accept this connection.
+ * @param fd The native file descriptor integer.
+ * @param addr The IPv6 address, in network byte order.
+ * @param port The port to bind to.
+ * @throws IOException
*/
- static native void accept(PlainSocketImpl socket, SocketImpl impl)
+ private static native void bind6(int fd, byte[] addr, int port)
throws IOException;
/**
- * Returns the number of bytes that the caller can read from this socket
- * without blocking.
- *
- * @param socket the socket object
- *
- * @return the number of readable bytes before blocking
- *
- * @throws IOException If an error occurs
- */
- static native int available(PlainSocketImpl socket) throws IOException;
-
- /**
- * Closes the socket. This will cause any InputStream or OutputStream
- * objects for this Socket to be closed as well.
- *
- *
- * Note that if the SO_LINGER option is set on this socket, then the
- * operation could block.
- *
- *
- * @param socket the socket object
+ * Listen on this socket for incoming connections.
*
- * @throws IOException if an error occurs
+ * @param backlog The backlog of connections.
+ * @throws IOException If listening fails.
+ * @see gnu.java.nio.VMChannel#accept()
*/
- static native void close(PlainSocketImpl socket) throws IOException;
-
+ public void listen(int backlog) throws IOException
+ {
+ listen(nfd.getNativeFD(), backlog);
+ }
+
/**
- * Internal method used by SocketInputStream for reading data from
- * the connection. Reads up to len bytes of data into the buffer
- * buf starting at offset bytes into the buffer.
- *
- * @param socket the socket object
+ * Native listen function. VMs without native support need not implement
+ * this.
*
- * @return the actual number of bytes read or -1 if end of stream.
- *
- * @throws IOException if an error occurs
+ * @param fd The file descriptor integer.
+ * @param backlog The listen backlog size.
+ * @throws IOException
*/
- static native int read(PlainSocketImpl socket, byte[] buf, int offset,
- int len) throws IOException;
+ private static native void listen(int fd, int backlog) throws IOException;
- /**
- * Internal method used by SocketInputStream for reading data from
- * the connection. Reads and returns one byte of data.
- *
- * @param socket the socket object
- *
- * @return read byte or -1 if end of stream.
- *
- * @throws IOException if an error occurs
- */
- static int read(PlainSocketImpl socket) throws IOException
+ public void join(InetAddress group) throws IOException
{
- byte[] buf = new byte[1];
- if (read(socket, buf, 0, 1) > 0)
- return buf[0] & 0xFF;
+ if (group instanceof Inet4Address)
+ join(nfd.getNativeFD(), group.getAddress());
+ else if (group instanceof Inet6Address)
+ join6(nfd.getNativeFD(), group.getAddress());
else
- return -1;
+ throw new IllegalArgumentException("unknown address type");
}
+
+ private static native void join(int fd, byte[] addr) throws IOException;
+
+ private static native void join6(int fd, byte[] addr) throws IOException;
+
+ public void leave(InetAddress group) throws IOException
+ {
+ if (group instanceof Inet4Address)
+ leave(nfd.getNativeFD(), group.getAddress());
+ else if (group instanceof Inet6Address)
+ leave6(nfd.getNativeFD(), group.getAddress());
+ else
+ throw new IllegalArgumentException("unknown address type");
+ }
+
+ private static native void leave(int fd, byte[] addr) throws IOException;
+
+ private static native void leave6(int fd, byte[] addr) throws IOException;
- /**
- * Internal method used by SocketOuputStream for writing data to
- * the connection. Writes up to len bytes of data from the buffer
- * buf
starting at offset bytes into the buffer.
- *
- * @param socket the socket object
- * @param buf the buffer to write to the stream
- * @param offset the start offset in the buffer
- * @param len the number of bytes to write
- *
- * @throws IOException if an error occurs
- */
- static native void write(PlainSocketImpl socket, byte[] buf, int offset,
- int len) throws IOException;
-
- /**
- * Internal method used by SocketOuputStream for writing data to
- * the connection. Writes exactly one byte to the socket.
- *
- * @param socket the socket object
- * @param data the byte to write to the socket
- *
- * @throws IOException if an error occurs
- */
- static void write(PlainSocketImpl socket, int data)
+ public void joinGroup(InetSocketAddress addr, NetworkInterface netif)
throws IOException
{
- write(socket, new byte[]{ (byte) data }, 0, 1);
+ InetAddress address = addr.getAddress();
+
+ if (address instanceof Inet4Address)
+ joinGroup(nfd.getNativeFD(), address.getAddress(),
+ netif != null ? netif.getName() : null);
+ else if (address instanceof Inet6Address)
+ joinGroup6(nfd.getNativeFD(), address.getAddress(),
+ netif != null ? netif.getName() : null);
+ else
+ throw new IllegalArgumentException("unknown address type");
}
-
- /**
- * Sets the input stream for this socket to the end of the stream. Any
- * attempts to read more bytes from the stream will return an EOF.
- *
- * @param socket the socket object
- *
- * @throws IOException if I/O errors occur
- */
- static native void shutdownInput(PlainSocketImpl socket) throws IOException;
-
- /**
- * Disables the output stream for this socket. Any attempt to write more
- * data to the socket will throw an IOException.
- *
- * @param socket the socket object
- *
- * @throws IOException if I/O errors occur
- */
- static native void shutdownOutput(PlainSocketImpl socket) throws IOException;
-
- /**
- * Connects to the remote socket address with a specified timeout.
- *
- * @param socket the socket object
- * @param address the remote address to connect to
- * @param timeout the timeout to use for this connect, 0 means infinite.
- *
- * @throws IOException if an error occurs
- */
- static synchronized void connect(PlainSocketImpl socket,
- SocketAddress address, int timeout)
+
+ private static native void joinGroup(int fd, byte[] addr, String ifname)
+ throws IOException;
+
+ private static native void joinGroup6(int fd, byte[] addr, String ifname)
+ throws IOException;
+
+ public void leaveGroup(InetSocketAddress addr, NetworkInterface netif)
throws IOException
{
- InetSocketAddress sockAddr = (InetSocketAddress) address;
- InetAddress addr = sockAddr.getAddress();
-
- if (addr == null)
- throw new UnknownHostException(sockAddr.getHostName());
-
- int port = sockAddr.getPort();
-
- if (timeout < 0)
- throw new IllegalArgumentException("negative timeout");
-
- Object oldTimeoutObj = null;
- try
- {
- oldTimeoutObj = getOption(socket, SocketOptions.SO_TIMEOUT);
- setOption(socket, SocketOptions.SO_TIMEOUT, new Integer(timeout));
- connect(socket, addr, port);
- }
- finally
- {
- if (oldTimeoutObj != null)
- setOption(socket, SocketOptions.SO_TIMEOUT, oldTimeoutObj);
- }
+ InetAddress address = addr.getAddress();
+ if (address instanceof Inet4Address)
+ leaveGroup(nfd.getNativeFD(), address.getAddress(),
+ netif != null ? netif.getName() : null);
+ else if (address instanceof Inet6Address)
+ leaveGroup6(nfd.getNativeFD(), address.getAddress(),
+ netif != null ? netif.getName() : null);
+ else
+ throw new IllegalArgumentException("unknown address type");
}
-
+
+ private static native void leaveGroup(int fd, byte[] addr, String ifname)
+ throws IOException;
+
+ private static native void leaveGroup6(int fd, byte[] addr, String ifname)
+ throws IOException;
+
+
+ public void shutdownInput() throws IOException
+ {
+ shutdownInput(nfd.getNativeFD());
+ }
+
+ private static native void shutdownInput(int native_fd) throws IOException;
+
+ public void shutdownOutput() throws IOException
+ {
+ shutdownOutput(nfd.getNativeFD());
+ }
+
+ private static native void shutdownOutput(int native_fd) throws IOException;
+
+ public void sendUrgentData(int data) throws IOException
+ {
+ sendUrgentData(nfd.getNativeFD(), data);
+ }
+
+ private static native void sendUrgentData(int natfive_fd, int data) throws IOException;
+
+ public void close() throws IOException
+ {
+ nfd.close();
+ }
+
+ // Inner classes.
+
/**
- * Send one byte of urgent data over the socket.
- *
- * @param socket the socket object
- * @param data the byte to send
+ * Our wrapper for the native file descriptor. In this implementation,
+ * it is a simple wrapper around {@link VMChannel.State}, to simplify
+ * management of the native state.
*/
- static void sendUrgendData(PlainSocketImpl socket, int data)
+ public final class State
{
- throw new InternalError ("PlainSocketImpl::sendUrgentData not implemented");
+ private VMChannel.State channelFd;
+
+ State()
+ {
+ channelFd = null;
+ }
+
+ public boolean isValid()
+ {
+ if (channelFd != null)
+ return channelFd.isValid();
+ return false;
+ }
+
+ public int getNativeFD() throws IOException
+ {
+ return channelFd.getNativeFD();
+ }
+
+ public void setChannelFD(final VMChannel.State nfd) throws IOException
+ {
+ if (this.channelFd != null && this.channelFd.isValid())
+ throw new IOException("file descriptor already initialized");
+ this.channelFd = nfd;
+ }
+
+ public void close() throws IOException
+ {
+ if (channelFd == null)
+ throw new IOException("invalid file descriptor");
+ channelFd.close();
+ }
+
+ protected void finalize() throws Throwable
+ {
+ try
+ {
+ if (isValid())
+ close();
+ }
+ finally
+ {
+ super.finalize();
+ }
+ }
}
-}
+}
\ No newline at end of file
diff --git a/vm/reference/gnu/java/nio/VMChannel.java b/vm/reference/gnu/java/nio/VMChannel.java
index fdea8ff62..688a94ac4 100644
--- a/vm/reference/gnu/java/nio/VMChannel.java
+++ b/vm/reference/gnu/java/nio/VMChannel.java
@@ -39,13 +39,17 @@ exception statement from your version. */
package gnu.java.nio;
import gnu.classpath.Configuration;
-import gnu.java.net.PlainSocketImpl;
-import gnu.java.nio.PipeImpl.SinkChannelImpl;
-import gnu.java.nio.PipeImpl.SourceChannelImpl;
-import gnu.java.nio.channels.FileChannelImpl;
+import gnu.classpath.jdwp.exception.NotImplementedException;
import java.io.IOException;
+import java.net.Inet4Address;
+import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.net.SocketException;
import java.nio.ByteBuffer;
+import java.nio.MappedByteBuffer;
/**
* Native interface to support configuring of channel to run in a non-blocking
@@ -54,33 +58,43 @@ import java.nio.ByteBuffer;
* @author Michael Barker
*
*/
-public class VMChannel
+public final class VMChannel
{
- private final int fd;
-
- private VMChannel(int fd)
- {
- this.fd = fd;
- }
+ /**
+ * Our reference implementation uses an integer to store the native
+ * file descriptor. Implementations without such support
+ */
+ private final State nfd;
- public static VMChannel getVMChannel(PlainSocketImpl socket)
- {
- return new VMChannel(socket.getNativeFD());
- }
+ private Kind kind;
- public static VMChannel getVMChannel(SourceChannelImpl source)
+ public VMChannel()
{
- return new VMChannel(source.getNativeFD());
+ // XXX consider adding security check here, so only Classpath
+ // code may create instances.
+ this.nfd = new State();
+ kind = Kind.OTHER;
}
- public static VMChannel getVMChannel(SinkChannelImpl sink)
+ /**
+ * This constructor is used by the POSIX reference implementation;
+ * other virtual machines need not support it.
+ *
+ * Important: do not call this in library code that is
+ * not specific to Classpath's reference implementation.
+ *
+ * @param native_fd The native file descriptor integer.
+ * @throws IOException
+ */
+ VMChannel(final int native_fd) throws IOException
{
- return new VMChannel(sink.getNativeFD());
+ this();
+ this.nfd.setNativeFD(native_fd);
}
- public static VMChannel getVMChannel(FileChannelImpl file)
+ public State getState()
{
- return new VMChannel(file.getNativeFD());
+ return nfd;
}
static
@@ -93,81 +107,151 @@ public class VMChannel
initIDs();
}
+ public static VMChannel getStdin() throws IOException
+ {
+ return new VMChannel(stdin_fd());
+ }
+
+ public static VMChannel getStdout() throws IOException
+ {
+ return new VMChannel(stdout_fd());
+ }
+
+ public static VMChannel getStderr() throws IOException
+ {
+ return new VMChannel(stderr_fd());
+ }
+
+ private static native int stdin_fd();
+ private static native int stdout_fd();
+ private static native int stderr_fd();
+
/**
* Set the file descriptor to have the required blocking
* setting.
*
- * @param fd
- * @param blocking
+ * @param blocking The blocking flag to set.
*/
- public native void setBlocking(int fd, boolean blocking);
+ public void setBlocking(boolean blocking) throws IOException
+ {
+ setBlocking(nfd.getNativeFD(), blocking);
+ }
+
+ private static native void setBlocking(int fd, boolean blocking)
+ throws IOException;
- public void setBlocking(boolean blocking)
+ public int available() throws IOException
{
- setBlocking(fd, blocking);
+ return available(nfd.getNativeFD());
}
+ private static native int available(int native_fd) throws IOException;
/**
* Reads a byte buffer directly using the supplied file descriptor.
- * Assumes that the buffer is a DirectBuffer.
*
- * @param fd Native file descriptor to read from.
* @param dst Direct Byte Buffer to read to.
* @return Number of bytes read.
* @throws IOException If an error occurs or dst is not a direct buffers.
*/
- native int read(int fd, ByteBuffer dst)
- throws IOException;
-
public int read(ByteBuffer dst)
throws IOException
{
- return read(fd, dst);
+ return read(nfd.getNativeFD(), dst);
}
+ private static native int read(int fd, ByteBuffer dst) throws IOException;
+
+ /**
+ * Read a single byte.
+ *
+ * @return The byte read, or -1 on end of file.
+ * @throws IOException
+ */
+ public int read() throws IOException
+ {
+ return read(nfd.getNativeFD());
+ }
+
+ private static native int read(int fd) throws IOException;
+
/**
* Reads into byte buffers directly using the supplied file descriptor.
* Assumes that the buffer list contains DirectBuffers. Will perform a
* scattering read.
*
- * @param fd Native file descriptor to read from.
* @param dsts An array direct byte buffers.
* @param offset Index of the first buffer to read to.
* @param length The number of buffers to read to.
* @return Number of bytes read.
* @throws IOException If an error occurs or the dsts are not direct buffers.
*/
- native long readScattering(int fd, ByteBuffer[] dsts, int offset, int length)
- throws IOException;
-
public long readScattering(ByteBuffer[] dsts, int offset, int length)
throws IOException
{
if (offset + length > dsts.length)
throw new IndexOutOfBoundsException("offset + length > dsts.length");
+
+ return readScattering(nfd.getNativeFD(), dsts, offset, length);
+ }
+
+ private static native long readScattering(int fd, ByteBuffer[] dsts,
+ int offset, int length)
+ throws IOException;
+
+ /**
+ * Receive a datagram on this channel, returning the host address
+ * that sent the datagram.
+ *
+ * @param dst Where to store the datagram.
+ * @return The host address that sent the datagram.
+ * @throws IOException
+ */
+ public SocketAddress receive(ByteBuffer dst) throws IOException
+ {
+ if (kind != Kind.SOCK_DGRAM)
+ throw new SocketException("not a datagram socket");
+ ByteBuffer hostPort = ByteBuffer.allocateDirect(18);
+ int hostlen = receive(nfd.getNativeFD(), dst, hostPort);
+ if (hostlen == 0)
+ return null;
+ if (hostlen == 4) // IPv4
+ {
+ byte[] addr = new byte[4];
+ hostPort.get(addr);
+ int port = hostPort.getShort() & 0xFFFF;
+ return new InetSocketAddress(Inet4Address.getByAddress(addr), port);
+ }
+ if (hostlen == 16) // IPv6
+ {
+ byte[] addr = new byte[16];
+ hostPort.get(addr);
+ int port = hostPort.getShort() & 0xFFFF;
+ return new InetSocketAddress(Inet6Address.getByAddress(addr), port);
+ }
- return readScattering(fd, dsts, offset, length);
+ throw new SocketException("host address received with invalid length: "
+ + hostlen);
}
+ private static native int receive (int fd, ByteBuffer dst, ByteBuffer address)
+ throws IOException;
+
/**
* Writes from a direct byte bufer using the supplied file descriptor.
* Assumes the buffer is a DirectBuffer.
*
- * @param fd
- * @param src
+ * @param src The source buffer.
* @return Number of bytes written.
* @throws IOException
*/
- native int write(int fd, ByteBuffer src)
- throws IOException;
-
- public int write(ByteBuffer src)
- throws IOException
+ public int write(ByteBuffer src) throws IOException
{
- return write(fd, src);
+ return write(nfd.getNativeFD(), src);
}
+ private native int write(int fd, ByteBuffer src) throws IOException;
+
/**
* Writes from byte buffers directly using the supplied file descriptor.
* Assumes the that buffer list constains DirectBuffers. Will perform
@@ -180,18 +264,463 @@ public class VMChannel
* @return Number of bytes written.
* @throws IOException
*/
- native long writeGathering(int fd, ByteBuffer[] srcs, int offset, int length)
- throws IOException;
-
public long writeGathering(ByteBuffer[] srcs, int offset, int length)
throws IOException
{
if (offset + length > srcs.length)
throw new IndexOutOfBoundsException("offset + length > srcs.length");
- return writeGathering(fd, srcs, offset, length);
+ // A gathering write is limited to 16 buffers; when writing, ensure
+ // that we have at least one buffer with something in it in the 16
+ // buffer window starting at offset.
+ while (!srcs[offset].hasRemaining() && offset < srcs.length)
+ offset++;
+
+ // There are no buffers with anything to write.
+ if (offset == srcs.length)
+ return 0;
+
+ // If we advanced `offset' so far that we don't have `length'
+ // buffers left, reset length to only the remaining buffers.
+ if (length > srcs.length - offset)
+ length = srcs.length - offset;
+
+ return writeGathering(nfd.getNativeFD(), srcs, offset, length);
}
+ private native long writeGathering(int fd, ByteBuffer[] srcs,
+ int offset, int length)
+ throws IOException;
+
+ /**
+ * Send a datagram to the given address.
+ *
+ * @param src The source buffer.
+ * @param dst The destination address.
+ * @return The number of bytes written.
+ * @throws IOException
+ */
+ public int send(ByteBuffer src, InetSocketAddress dst)
+ throws IOException
+ {
+ InetAddress addr = dst.getAddress();
+ if (addr == null)
+ throw new NullPointerException();
+ if (addr instanceof Inet4Address)
+ return send(nfd.getNativeFD(), src, addr.getAddress(), dst.getPort());
+ else if (addr instanceof Inet6Address)
+ return send6(nfd.getNativeFD(), src, addr.getAddress(), dst.getPort());
+ else
+ throw new SocketException("unrecognized inet address type");
+ }
+
+ // Send to an IPv4 address.
+ private static native int send(int fd, ByteBuffer src, byte[] addr, int port)
+ throws IOException;
+
+ // Send to an IPv6 address.
+ private static native int send6(int fd, ByteBuffer src, byte[] addr, int port)
+ throws IOException;
+
+ /**
+ * Write a single byte.
+ *
+ * @param b The byte to write.
+ * @throws IOException
+ */
+ public void write(int b) throws IOException
+ {
+ write(nfd.getNativeFD(), b);
+ }
+
+ private static native void write(int fd, int b) throws IOException;
+
private native static void initIDs();
+ // Network (socket) specific methods.
+
+ /**
+ * Create a new socket. This method will initialize the native file
+ * descriptor state of this instance.
+ *
+ * @param stream Whether or not to create a streaming socket, or a datagram
+ * socket.
+ * @throws IOException If creating a new socket fails, or if this
+ * channel already has its native descriptor initialized.
+ */
+ public void initSocket(boolean stream) throws IOException
+ {
+ if (nfd.isValid())
+ throw new IOException("native FD already initialized");
+ if (stream)
+ kind = Kind.SOCK_STREAM;
+ else
+ kind = Kind.SOCK_DGRAM;
+ nfd.setNativeFD(socket(stream));
+ }
+
+ /**
+ * Create a new socket, returning the native file descriptor.
+ *
+ * @param stream Set to true for streaming sockets; false for datagrams.
+ * @return The native file descriptor.
+ * @throws IOException If creating the socket fails.
+ */
+ private static native int socket(boolean stream) throws IOException;
+
+ /**
+ * Connect the underlying socket file descriptor to the remote host.
+ *
+ * @param saddr The address to connect to.
+ * @param timeout The connect timeout to use for blocking connects.
+ * @return True if the connection succeeded; false if the file descriptor
+ * is in non-blocking mode and the connection did not immediately
+ * succeed.
+ * @throws IOException If an error occurs while connecting.
+ */
+ public boolean connect(InetSocketAddress saddr, int timeout)
+ throws IOException
+ {
+ InetAddress addr = saddr.getAddress();
+ if (addr instanceof Inet4Address)
+ return connect(nfd.getNativeFD(), addr.getAddress(), saddr.getPort(),
+ timeout);
+ if (addr instanceof Inet6Address)
+ return connect6(nfd.getNativeFD(), addr.getAddress(), saddr.getPort(),
+ timeout);
+ throw new IOException("unsupported internet address");
+ }
+
+ private static native boolean connect(int fd, byte[] addr, int port, int timeout)
+ throws IOException;
+
+ private static native boolean connect6(int fd, byte[] addr, int port, int timeout)
+ throws IOException;
+
+ /**
+ * Disconnect this channel, if it is a datagram socket. Disconnecting
+ * a datagram channel will disassociate it from any address, so the
+ * socket will remain open, but can send and receive datagrams from
+ * any address.
+ *
+ * @throws IOException If disconnecting this channel fails, or if this
+ * channel is not a datagram channel.
+ */
+ public void disconnect() throws IOException
+ {
+ if (kind != Kind.SOCK_DGRAM)
+ throw new IOException("can only disconnect datagram channels");
+ disconnect(nfd.getNativeFD());
+ }
+
+ private static native void disconnect(int fd) throws IOException;
+
+ public InetSocketAddress getLocalAddress() throws IOException
+ {
+ if (!nfd.isValid())
+ return null;
+ ByteBuffer name = ByteBuffer.allocateDirect(18);
+ int namelen = getsockname(nfd.getNativeFD(), name);
+ if (namelen == 0) // not bound
+ return null; // XXX return some wildcard?
+ if (namelen == 4)
+ {
+ byte[] addr = new byte[4];
+ name.get(addr);
+ int port = name.getShort() & 0xFFFF;
+ return new InetSocketAddress(Inet4Address.getByAddress(addr), port);
+ }
+ if (namelen == 16)
+ {
+ byte[] addr = new byte[16];
+ name.get(addr);
+ int port = name.getShort() & 0xFFFF;
+ return new InetSocketAddress(Inet6Address.getByAddress(addr), port);
+ }
+ throw new SocketException("invalid address length");
+ }
+
+ private static native int getsockname(int fd, ByteBuffer name)
+ throws IOException;
+
+ /**
+ * Returns the socket address of the remote peer this channel is connected
+ * to, or null if this channel is not yet connected.
+ *
+ * @return The peer address.
+ * @throws IOException
+ */
+ public InetSocketAddress getPeerAddress() throws IOException
+ {
+ if (!nfd.isValid())
+ return null;
+ ByteBuffer name = ByteBuffer.allocateDirect(18);
+ int namelen = getpeername (nfd.getNativeFD(), name);
+ if (namelen == 0) // not connected yet
+ return null;
+ if (namelen == 4) // IPv4
+ {
+ byte[] addr = new byte[4];
+ name.get(addr);
+ int port = name.getShort() & 0xFFFF;
+ return new InetSocketAddress(Inet4Address.getByAddress(addr), port);
+ }
+ else if (namelen == 16) // IPv6
+ {
+ byte[] addr = new byte[16];
+ name.get(addr);
+ int port = name.getShort() & 0xFFFF;
+ return new InetSocketAddress(Inet6Address.getByAddress(addr), port);
+ }
+ throw new SocketException("invalid address length");
+ }
+
+ /*
+ * The format here is the peer address, followed by the port number.
+ * The returned value is the length of the peer address; thus, there
+ * will be LEN + 2 valid bytes put into NAME.
+ */
+ private static native int getpeername(int fd, ByteBuffer name)
+ throws IOException;
+
+ /**
+ * Accept an incoming connection, returning a new VMChannel, or null
+ * if the channel is nonblocking and no connection is pending.
+ *
+ * @return The accepted connection, or null.
+ * @throws IOException If an IO error occurs.
+ */
+ public VMChannel accept() throws IOException
+ {
+ int new_fd = accept(nfd.getNativeFD());
+ if (new_fd == -1) // non-blocking accept had no pending connection
+ return null;
+ return new VMChannel(new_fd);
+ }
+
+ private static native int accept(int native_fd) throws IOException;
+
+ // File-specific methods.
+
+ /**
+ * Open a file at PATH, initializing the native state to operate on
+ * that open file.
+ *
+ * @param path The absolute file path.
+ * @throws IOException If the file cannot be opened, or if this
+ * channel was previously initialized.
+ */
+ public void openFile(String path, int mode) throws IOException
+ {
+ if (nfd.isValid() || nfd.isClosed())
+ throw new IOException("can't reinitialize this channel");
+ int fd = open(path, mode);
+ nfd.setNativeFD(fd);
+ kind = Kind.FILE;
+ }
+
+ private static native int open(String path, int mode) throws IOException;
+
+ public long position() throws IOException
+ {
+ if (kind != Kind.FILE)
+ throw new IOException("not a file");
+ return position(nfd.getNativeFD());
+ }
+
+ private static native long position(int fd) throws IOException;
+
+ public void seek(long pos) throws IOException
+ {
+ if (kind != Kind.FILE)
+ throw new IOException("not a file");
+ seek(nfd.getNativeFD(), pos);
+ }
+
+ private static native void seek(int fd, long pos) throws IOException;
+
+ public void truncate(long length) throws IOException
+ {
+ if (kind != Kind.FILE)
+ throw new IOException("not a file");
+ truncate(nfd.getNativeFD(), length);
+ }
+
+ private static native void truncate(int fd, long len) throws IOException;
+
+ public boolean lock(long pos, long len, boolean shared, boolean wait)
+ throws IOException
+ {
+ if (kind != Kind.FILE)
+ throw new IOException("not a file");
+ return lock(nfd.getNativeFD(), pos, len, shared, wait);
+ }
+
+ private static native boolean lock(int fd, long pos, long len,
+ boolean shared, boolean wait)
+ throws IOException;
+
+ public void unlock(long pos, long len) throws IOException
+ {
+ if (kind != Kind.FILE)
+ throw new IOException("not a file");
+ unlock(nfd.getNativeFD(), pos, len);
+ }
+
+ private static native void unlock(int fd, long pos, long len) throws IOException;
+
+ public long size() throws IOException
+ {
+ if (kind != Kind.FILE)
+ throw new IOException("not a file");
+ return size(nfd.getNativeFD());
+ }
+
+ private static native long size(int fd) throws IOException;
+
+ public MappedByteBuffer map(char mode, long position, int size)
+ throws IOException
+ {
+ if (kind != Kind.FILE)
+ throw new IOException("not a file");
+ return map(nfd.getNativeFD(), mode, position, size);
+ }
+
+ private static native MappedByteBuffer map(int fd, char mode,
+ long position, int size)
+ throws IOException;
+
+ public boolean flush(boolean metadata) throws IOException
+ {
+ if (kind != Kind.FILE)
+ throw new IOException("not a file");
+ return flush(nfd.getNativeFD(), metadata);
+ }
+
+ private static native boolean flush(int fd, boolean metadata) throws IOException;
+
+ // Close.
+
+ /**
+ * Close this socket. The socket is also automatically closed when this
+ * object is finalized.
+ *
+ * @throws IOException If closing the socket fails, or if this object has
+ * no open socket.
+ */
+ public void close() throws IOException
+ {
+ nfd.close();
+ }
+
+ static native void close(int native_fd) throws IOException;
+
+ // Inner classes.
+
+ /**
+ * A wrapper for a native file descriptor integer. This tracks the state
+ * of an open file descriptor, and ensures that
+ *
+ * This class need not be fully supported by virtual machines; if a
+ * virtual machine does not use integer file descriptors, or does and
+ * wishes to hide that, then the methods of this class may be stubbed out.
+ *
+ * System-specific classes that depend on access to native file descriptor
+ * integers SHOULD declare this fact.
+ */
+ public final class State
+ {
+ private int native_fd;
+ private boolean valid;
+ private boolean closed;
+
+ State()
+ {
+ native_fd = -1;
+ valid = false;
+ closed = false;
+ }
+
+ public boolean isValid()
+ {
+ return valid;
+ }
+
+ public boolean isClosed()
+ {
+ return closed;
+ }
+
+ public int getNativeFD() throws IOException
+ {
+ if (!valid)
+ throw new IOException("invalid file descriptor");
+ return native_fd;
+ }
+
+ void setNativeFD(final int native_fd) throws IOException
+ {
+ if (valid)
+ throw new IOException("file descriptor already initialized");
+ this.native_fd = native_fd;
+ valid = true;
+ }
+
+ public void close() throws IOException
+ {
+ if (!valid)
+ throw new IOException("invalid file descriptor");
+ try
+ {
+ VMChannel.close(native_fd);
+ }
+ finally
+ {
+ valid = false;
+ closed = true;
+ }
+ }
+
+ public String toString()
+ {
+ if (closed)
+ return "<>";
+ if (!valid)
+ return "<>";
+ return String.valueOf(native_fd);
+ }
+
+ protected void finalize() throws Throwable
+ {
+ try
+ {
+ if (valid)
+ close();
+ }
+ finally
+ {
+ super.finalize();
+ }
+ }
+ }
+
+ /**
+ * An enumeration of possible kinds of channel.
+ */
+ static class Kind // XXX enum
+ {
+ /** A streaming (TCP) socket. */
+ static final Kind SOCK_STREAM = new Kind();
+
+ /** A datagram (UDP) socket. */
+ static final Kind SOCK_DGRAM = new Kind();
+
+ /** A file. */
+ static final Kind FILE = new Kind();
+
+ /** Something else; not a socket or file. */
+ static final Kind OTHER = new Kind();
+
+ private Kind() { }
+ }
}
diff --git a/vm/reference/gnu/java/nio/VMPipe.java b/vm/reference/gnu/java/nio/VMPipe.java
index 11dd2aa7b..e5257c1cf 100644
--- a/vm/reference/gnu/java/nio/VMPipe.java
+++ b/vm/reference/gnu/java/nio/VMPipe.java
@@ -38,7 +38,6 @@ exception statement from your version. */
package gnu.java.nio;
import java.io.IOException;
-import java.nio.channels.spi.SelectorProvider;
import gnu.classpath.Configuration;
/**
@@ -58,7 +57,24 @@ final class VMPipe
System.loadLibrary ("javanio");
}
}
-
- static native void init(PipeImpl self, SelectorProvider provider)
- throws IOException;
+
+ /**
+ * Create a pipe, consisting of a readable VMChannel and a writable
+ * VMChannel. The readable channel is returned is the first element
+ * of the array, and the writable in the second.
+ *
+ * @return A pair of VMChannels; the first readable, the second
+ * writable.
+ * @throws IOException If the pipe cannot be created.
+ */
+ static VMChannel[] pipe() throws IOException
+ {
+ VMChannel[] pipe = new VMChannel[2];
+ int[] fds = pipe0();
+ pipe[0] = new VMChannel(fds[0]);
+ pipe[1] = new VMChannel(fds[1]);
+ return pipe;
+ }
+
+ private static native int[] pipe0() throws IOException;
}
diff --git a/vm/reference/java/net/VMInetAddress.java b/vm/reference/java/net/VMInetAddress.java
index 19f5d7d34..a99c216b9 100644
--- a/vm/reference/java/net/VMInetAddress.java
+++ b/vm/reference/java/net/VMInetAddress.java
@@ -84,4 +84,14 @@ class VMInetAddress implements Serializable
*/
public static native byte[][] getHostByName(String hostname)
throws UnknownHostException;
+
+ /**
+ * Return the IP address represented by a literal address.
+ * Will return null if the literal address is not valid.
+ *
+ * @param address the name of the host
+ *
+ * @return The IP address as a byte array
+ */
+ public static native byte[] aton(String address);
}
diff --git a/vm/reference/java/net/VMNetworkInterface.java b/vm/reference/java/net/VMNetworkInterface.java
index 47f803246..7a29f4ee3 100644
--- a/vm/reference/java/net/VMNetworkInterface.java
+++ b/vm/reference/java/net/VMNetworkInterface.java
@@ -40,6 +40,9 @@ package java.net;
import gnu.classpath.Configuration;
+import java.nio.ByteBuffer;
+import java.util.HashSet;
+import java.util.Set;
import java.util.Vector;
/**
@@ -54,22 +57,50 @@ import java.util.Vector;
*/
final class VMNetworkInterface
{
+ String name;
+ Set addresses;
+
+ VMNetworkInterface(String name)
+ {
+ this.name = name;
+ addresses = new HashSet();
+ }
+
static
- {
- if (Configuration.INIT_LOAD_LIBRARY)
- System.loadLibrary("javanet");
- }
+ {
+ if (Configuration.INIT_LOAD_LIBRARY)
+ System.loadLibrary("javanet");
+
+ initIds();
+ }
+
+ private static native void initIds();
/**
- * Returns a Vector of InetAddresses. The returned value will be
- * 'condensed', meaning that all elements with the same interface
- * name will be collapesed into one InetAddress for that name
- * containing all addresses before the returning the result to the
- * user. This means the native method can be implemented in a naive
- * way mapping each address/interface to a name even if that means
- * that the Vector contains multiple InetAddresses with the same
- * interface name.
+ * Return a list of VM network interface objects.
+ *
+ * @return The list of network interfaces.
+ * @throws SocketException
*/
- public static native Vector getInterfaces()
+ public static native VMNetworkInterface[] getVMInterfaces()
throws SocketException;
+
+ private void addAddress(ByteBuffer addr)
+ throws SocketException, UnknownHostException
+ {
+ if (addr.remaining() == 4)
+ {
+ byte[] ipv4 = new byte[4];
+ addr.get(ipv4);
+ addresses.add(Inet4Address.getByAddress(ipv4));
+ }
+ else if (addr.remaining() == 16)
+ {
+ byte[] ipv6 = new byte[16];
+ addr.get(ipv6);
+ addresses.add(Inet6Address.getByAddress(ipv6));
+ }
+ else
+ throw new SocketException("invalid interface address");
+ }
}
diff --git a/vm/reference/java/nio/channels/VMChannels.java b/vm/reference/java/nio/channels/VMChannels.java
index e58d7fbf9..c833b6eec 100644
--- a/vm/reference/java/nio/channels/VMChannels.java
+++ b/vm/reference/java/nio/channels/VMChannels.java
@@ -40,7 +40,7 @@ package java.nio.channels;
import gnu.java.nio.ChannelInputStream;
import gnu.java.nio.ChannelOutputStream;
-import gnu.java.nio.channels.FileChannelImpl;
+import gnu.java.nio.FileChannelImpl;
import java.io.FileInputStream;
import java.io.FileOutputStream;
--
cgit v1.2.1