harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r550106 [16/16] - in /harmony/enhanced/classlib/branches/java6/modules: beans/src/main/java/java/beans/ jndi/META-INF/ jndi/src/main/java/javax/naming/ jndi/src/main/java/javax/naming/directory/ jndi/src/main/java/javax/naming/event/ jndi/s...
Date Sat, 23 Jun 2007 20:53:48 GMT
Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RegistryContext.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RegistryContext.java?view=diff&rev=550106&r1=550105&r2=550106
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RegistryContext.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RegistryContext.java Sat Jun 23 13:53:42 2007
@@ -20,6 +20,7 @@
  * @author  Vasily Zakharov
  * @version $Revision: 1.1.2.4 $
  */
+
 package org.apache.harmony.jndi.provider.rmi.registry;
 
 import java.rmi.AccessException;
@@ -67,12 +68,8 @@
 
 import org.apache.harmony.jndi.internal.nls.Messages;
 
-
 /**
  * RMI Registry context implementation.
- *
- * @author  Vasily Zakharov
- * @version $Revision: 1.1.2.4 $
  */
 public class RegistryContext implements Context, Referenceable {
 
@@ -80,15 +77,13 @@
      * System property used to state whether the RMI security manager should be
      * installed.
      */
-    public static final String SECURITY_MANAGER = 
-            "java.naming.rmi.security.manager"; //$NON-NLS-1$
+    public static final String SECURITY_MANAGER = "java.naming.rmi.security.manager"; //$NON-NLS-1$
 
     /**
      * System property used to supply the name of the
      * {@link RMIClientSocketFactory} to use.
      */
-    public static final String CLIENT_SOCKET_FACTORY =
-            "org.apache.harmony.jndi.provider.rmi.registry.clientSocketFactory"; //$NON-NLS-1$
+    public static final String CLIENT_SOCKET_FACTORY = "org.apache.harmony.jndi.provider.rmi.registry.clientSocketFactory"; //$NON-NLS-1$
 
     /**
      * Prefix for RMI URLs.
@@ -137,62 +132,63 @@
     protected Reference reference;
 
     /**
-     * Creates RMI registry context bound to RMI Registry
-     * operating on the specified host and port.
-     *
-     * @param   host
-     *          Host. If <code>null</code>, localhost is assumed.
-     *
-     * @param   port
-     *          Port. If <code>0</code>, default registry port
-     *          (<code>1099</code>) is assumed.
-     *
-     * @param   environment
-     *          Context environment, may be <code>null</code>
-     *          which denotes empty environment.
-     *
-     * @throws  NamingException
-     *          If some naming error occurs.
+     * Creates RMI registry context bound to RMI Registry operating on the
+     * specified host and port.
+     * 
+     * @param host
+     *            Host. If <code>null</code>, localhost is assumed.
+     * 
+     * @param port
+     *            Port. If <code>0</code>, default registry port (<code>1099</code>)
+     *            is assumed.
+     * 
+     * @param environment
+     *            Context environment, may be <code>null</code> which denotes
+     *            empty environment.
+     * 
+     * @throws NamingException
+     *             If some naming error occurs.
      */
-    @SuppressWarnings("unchecked") //$NON-NLS-1$
+    @SuppressWarnings("unchecked")
     public RegistryContext(String host, int port, Hashtable<?, ?> environment)
             throws NamingException {
         this.host = host;
         this.port = port;
 
-        this.environment = ((environment != null)
-                ? (Hashtable<Object, Object>) environment.clone()
+        this.environment = ((environment != null) ? (Hashtable<Object, Object>) environment
+                .clone()
                 : new Hashtable<Object, Object>());
 
         if (this.environment.get(SECURITY_MANAGER) != null) {
             installSecurityManager();
         }
 
-        String clientSocketFactoryName = (String)
-                this.environment.get(CLIENT_SOCKET_FACTORY);
+        String clientSocketFactoryName = (String) this.environment
+                .get(CLIENT_SOCKET_FACTORY);
 
         if (clientSocketFactoryName == null) {
             csf = null;
         } else {
             try {
                 csf = (RMIClientSocketFactory) Class.forName(
-                        clientSocketFactoryName, true, Thread.currentThread()
-                                .getContextClassLoader()).newInstance();
+                        clientSocketFactoryName, true,
+                        Thread.currentThread().getContextClassLoader())
+                        .newInstance();
             } catch (ClassNotFoundException e) {
                 // jndi.79=RMI Client Socket Factory cannot be instantiated
                 throw (ConfigurationException) new ConfigurationException(
                         Messages.getString("jndi.79")) //$NON-NLS-1$
-                                .initCause(e);
+                        .initCause(e);
             } catch (InstantiationException e) {
                 // jndi.79=RMI Client Socket Factory cannot be instantiated
                 throw (ConfigurationException) new ConfigurationException(
                         Messages.getString("jndi.79")) //$NON-NLS-1$
-                                .initCause(e);
+                        .initCause(e);
             } catch (IllegalAccessException e) {
                 // jndi.79=RMI Client Socket Factory cannot be instantiated
                 throw (NoPermissionException) new NoPermissionException(
                         Messages.getString("jndi.79")) //$NON-NLS-1$
-                                .initCause(e);
+                        .initCause(e);
             }
         }
         registry = getRegistry(host, port, csf);
@@ -201,11 +197,11 @@
 
     /**
      * Creates RMI registry context by copying the specified context.
-     *
-     * @param   context
-     *          Context to copy.
+     * 
+     * @param context
+     *            Context to copy.
      */
-    @SuppressWarnings("unchecked") //$NON-NLS-1$
+    @SuppressWarnings("unchecked")
     protected RegistryContext(RegistryContext context) {
         host = context.host;
         port = context.port;
@@ -228,8 +224,8 @@
             return getObjectInstance(stringName, registry.lookup(stringName));
         } catch (NotBoundException e) {
             // jndi.7A=Name is not bound: {0}
-            throw (NameNotFoundException) new NameNotFoundException(
-                    Messages.getString("jndi.7A", stringName)).initCause(e); //$NON-NLS-1$
+            throw (NameNotFoundException) new NameNotFoundException(Messages
+                    .getString("jndi.7A", stringName)).initCause(e); //$NON-NLS-1$
         } catch (RemoteException e) {
             throw (NamingException) newNamingException(e).fillInStackTrace();
         }
@@ -339,7 +335,8 @@
      */
     public Context createSubcontext(Name name)
             throws OperationNotSupportedException {
-        // jndi.7F=RMI Registry is a flat context and doesn't support subcontexts
+        // jndi.7F=RMI Registry is a flat context and doesn't support
+        // subcontexts
         throw new OperationNotSupportedException(Messages.getString("jndi.7F")); //$NON-NLS-1$
     }
 
@@ -355,7 +352,8 @@
      */
     public void destroySubcontext(Name name)
             throws OperationNotSupportedException {
-        // jndi.7F=RMI Registry is a flat context and doesn't support subcontexts
+        // jndi.7F=RMI Registry is a flat context and doesn't support
+        // subcontexts
         throw new OperationNotSupportedException(Messages.getString("jndi.7F")); //$NON-NLS-1$
     }
 
@@ -384,13 +382,14 @@
     /**
      * {@inheritDoc}
      */
-    public NamingEnumeration<NameClassPair> list(Name name) throws NamingException {
+    public NamingEnumeration<NameClassPair> list(Name name)
+            throws NamingException {
         if (name.isEmpty()) {
             try {
                 return new NameClassPairEnumeration(registry.list());
             } catch (RemoteException e) {
-                throw (NamingException)
-                        newNamingException(e).fillInStackTrace();
+                throw (NamingException) newNamingException(e)
+                        .fillInStackTrace();
             }
         }
         Object obj = lookup(name);
@@ -403,27 +402,28 @@
             }
         }
         // jndi.80=Name specifies an object that is not a context: {0}
-        throw new NotContextException(
-                Messages.getString("jndi.80", name)); //$NON-NLS-1$
+        throw new NotContextException(Messages.getString("jndi.80", name)); //$NON-NLS-1$
     }
 
     /**
      * {@inheritDoc}
      */
-    public NamingEnumeration<NameClassPair> list(String name) throws NamingException {
+    public NamingEnumeration<NameClassPair> list(String name)
+            throws NamingException {
         return list(new CompositeName(name));
     }
 
     /**
      * {@inheritDoc}
      */
-    public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
+    public NamingEnumeration<Binding> listBindings(Name name)
+            throws NamingException {
         if (name.isEmpty()) {
             try {
                 return new BindingEnumeration(registry.list(), this);
             } catch (RemoteException e) {
-                throw (NamingException)
-                        newNamingException(e).fillInStackTrace();
+                throw (NamingException) newNamingException(e)
+                        .fillInStackTrace();
             }
         }
         Object obj = lookup(name);
@@ -436,14 +436,14 @@
             }
         }
         // jndi.80=Name specifies an object that is not a context: {0}
-        throw new NotContextException(
-                Messages.getString("jndi.80", name)); //$NON-NLS-1$
+        throw new NotContextException(Messages.getString("jndi.80", name)); //$NON-NLS-1$
     }
 
     /**
      * {@inheritDoc}
      */
-    public NamingEnumeration<Binding> listBindings(String name) throws NamingException {
+    public NamingEnumeration<Binding> listBindings(String name)
+            throws NamingException {
         return listBindings(new CompositeName(name));
     }
 
@@ -473,8 +473,8 @@
      */
     public String composeName(String name, String prefix)
             throws NamingException {
-        return composeName(
-                new CompositeName(name), new CompositeName(prefix)).toString();
+        return composeName(new CompositeName(name), new CompositeName(prefix))
+                .toString();
     }
 
     /**
@@ -523,12 +523,11 @@
     public Reference getReference() throws NamingException {
         if (reference == null) {
             if ((host == null) || (host.equals("localhost"))) { //$NON-NLS-1$
-                // jndi.81=Cannot create reference for RMI registry that is being accessed using localhost
-                throw new ConfigurationException(
-                        Messages.getString("jndi.81")); //$NON-NLS-1$
+                // jndi.81=Cannot create reference for RMI registry that is
+                // being accessed using localhost
+                throw new ConfigurationException(Messages.getString("jndi.81")); //$NON-NLS-1$
             }
-            reference = new Reference(
-                    RegistryContext.class.getName(),
+            reference = new Reference(RegistryContext.class.getName(),
                     new StringRefAddr(ADDRESS_TYPE, RMI_URL_PREFIX + "//" //$NON-NLS-1$
                             + host + ((port > 0) ? (":" + port) : "")), //$NON-NLS-1$ //$NON-NLS-2$
                     RegistryContextFactory.class.getName(), null);
@@ -539,9 +538,9 @@
     /**
      * Initializes reference for this context instance. Called by
      * {@link RegistryContextFactory#getObjectInstance(Object, Name, Context, Hashtable)}.
-     *
-     * @param   reference
-     *          Reference for this context instance.
+     * 
+     * @param reference
+     *            Reference for this context instance.
      */
     protected void setReference(Reference reference) {
         this.reference = reference;
@@ -549,26 +548,26 @@
 
     /**
      * Returns a clone of this context.
-     *
-     * @return  Clone of this context.
+     * 
+     * @return Clone of this context.
      */
     protected RegistryContext cloneContext() {
         return new RegistryContext(this);
     }
 
     /**
-     * Verifies that the specified name is valid for this context
-     * and returns string representation of that name for this provider.
-     *
-     * Returns returns first component of a {@link CompositeName}
-     * or a string representation of a name otherwise.
-     *
-     * @param   name
-     *          Name to verify.
-     *
-     * @return  {@link CompositeName#get(int) CompositeName#get(0)}
-     *          if <code>name</code> is a {@link CompositeName},
-     *          {@link Object#toString() name.toString()} otherwise.
+     * Verifies that the specified name is valid for this context and returns
+     * string representation of that name for this provider.
+     * 
+     * Returns returns first component of a {@link CompositeName} or a string
+     * representation of a name otherwise.
+     * 
+     * @param name
+     *            Name to verify.
+     * 
+     * @return {@link CompositeName#get(int) CompositeName#get(0)} if
+     *         <code>name</code> is a {@link CompositeName},
+     *         {@link Object#toString() name.toString()} otherwise.
      */
     protected String getMyComponents(Name name) {
         if (name instanceof CompositeName) {
@@ -582,25 +581,25 @@
      * {@link NamingManager#getStateToBind(Object, Name, Context, Hashtable)}
      * and makes the resulting object {@link Remote} by wrapping it into
      * {@link RemoteReferenceWrapper}.
-     *
-     * @param   name
-     *          Object name.
-     *
-     * @param   obj
-     *          Object to prepare for binding.
-     *
-     * @return  Object ready for binding.
-     *
-     * @throws  NamingException
-     *          If some naming error occurs.
-     *
-     * @throws  RemoteException
-     *          If remote exception occurs.
+     * 
+     * @param name
+     *            Object name.
+     * 
+     * @param obj
+     *            Object to prepare for binding.
+     * 
+     * @return Object ready for binding.
+     * 
+     * @throws NamingException
+     *             If some naming error occurs.
+     * 
+     * @throws RemoteException
+     *             If remote exception occurs.
      */
     protected Remote getStateToBind(String name, Object obj)
             throws NamingException, RemoteException {
-        obj = NamingManager.getStateToBind(
-                obj, new CompositeName().add(name), this, environment);
+        obj = NamingManager.getStateToBind(obj, new CompositeName().add(name),
+                this, environment);
 
         if (obj instanceof Remote) {
             return (Remote) obj;
@@ -611,51 +610,51 @@
         }
 
         if (obj instanceof Referenceable) {
-            return new RemoteReferenceWrapper(
-                    ((Referenceable) obj).getReference());
+            return new RemoteReferenceWrapper(((Referenceable) obj)
+                    .getReference());
         }
-        // jndi.82=Cannot bind to RMI Registry object that is neither Remote nor Reference nor Referenceable
+        // jndi.82=Cannot bind to RMI Registry object that is neither Remote nor
+        // Reference nor Referenceable
         throw new IllegalArgumentException(Messages.getString("jndi.82")); //$NON-NLS-1$
     }
 
     /**
-     * Processes object returned from {@linkplain Registry RMI registry}.
-     * It unwraps {@link RemoteReference} if necessary and calls
+     * Processes object returned from {@linkplain Registry RMI registry}. It
+     * unwraps {@link RemoteReference} if necessary and calls
      * {@link NamingManager#getObjectInstance(Object, Name, Context, Hashtable)}.
-     *
-     * @param   name
-     *          Object name.
-     *
-     * @param   remote
-     *          Returned object.
-     *
-     * @return  Processed object.
-     *
-     * @throws  NamingException
-     *          If some naming error occurs.
-     *
-     * @throws  RemoteException
-     *          If remote exception occurs.
+     * 
+     * @param name
+     *            Object name.
+     * 
+     * @param remote
+     *            Returned object.
+     * 
+     * @return Processed object.
+     * 
+     * @throws NamingException
+     *             If some naming error occurs.
+     * 
+     * @throws RemoteException
+     *             If remote exception occurs.
      */
     protected Object getObjectInstance(String name, Remote remote)
             throws NamingException, RemoteException {
         Object obj;
 
-        obj = ((remote instanceof RemoteReference)
-                ? ((RemoteReference) remote).getReference()
-                : (Object) remote);
+        obj = ((remote instanceof RemoteReference) ? ((RemoteReference) remote)
+                .getReference() : (Object) remote);
 
         try {
-            return NamingManager.getObjectInstance(
-                    obj, new CompositeName().add(name), this, environment);
+            return NamingManager.getObjectInstance(obj, new CompositeName()
+                    .add(name), this, environment);
         } catch (NamingException e) {
             throw e;
         } catch (RemoteException e) {
             throw e;
         } catch (Exception e) {
             // jndi.83=NamingManager.getObjectInstance() failed
-            throw (NamingException) new NamingException(
-                    Messages.getString("jndi.83")).initCause(e); //$NON-NLS-1$
+            throw (NamingException) new NamingException(Messages
+                    .getString("jndi.83")).initCause(e); //$NON-NLS-1$
         }
     }
 
@@ -663,53 +662,48 @@
      * Prepares a new {@link NamingException} wrapping the specified
      * {@link RemoteException} source exception. Source exception becomes a
      * {@linkplain NamingException#getCause() cause} of the generated exception.
-     *
-     * The particular subclass of {@link NamingException} returned depends
-     * on the particular subclass of source {@link RemoteException}.
-     *
-     * If source exception is not of a specific class or is not
-     * a {@link RemoteException} or is <code>null</code>,
-     * then plain {@link NamingException} is returned.
-     *
+     * 
+     * The particular subclass of {@link NamingException} returned depends on
+     * the particular subclass of source {@link RemoteException}.
+     * 
+     * If source exception is not of a specific class or is not a
+     * {@link RemoteException} or is <code>null</code>, then plain
+     * {@link NamingException} is returned.
+     * 
      * Note: {@link Throwable#fillInStackTrace()} should be called before
-     * throwing the generated exception, to provide the proper
-     * (not including this method) stack trace for the exception.
-     *
+     * throwing the generated exception, to provide the proper (not including
+     * this method) stack trace for the exception.
+     * 
      * Example of use:
-     *
+     * 
      * <code>try {
      *     ...
      * } catch (RemoteException e) {
      *     throw (NamingException) newNamingException(e).fillInStackTrace();
      * }</code>
-     *
-     * @param   e
-     *          Source {@link RemoteException}.
-     *
-     * @return  Generated {@link NamingException} exception.
+     * 
+     * @param e
+     *            Source {@link RemoteException}.
+     * 
+     * @return Generated {@link NamingException} exception.
      */
-    @SuppressWarnings("deprecation") //$NON-NLS-1$
+    @SuppressWarnings("deprecation")
     protected NamingException newNamingException(Throwable e) {
-        NamingException ret =
-                  (e instanceof AccessException)
-                        ? new NoPermissionException()
-                : (e instanceof ConnectException)
-                        ? new ServiceUnavailableException()
-                : (e instanceof ConnectIOException)
-               || (e instanceof ExportException)
-               || (e instanceof MarshalException)
-               || (e instanceof UnmarshalException)
-                        ? new CommunicationException()
-                : (e instanceof ActivateFailedException)
-               || (e instanceof NoSuchObjectException)
-               || (e instanceof java.rmi.server.SkeletonMismatchException)
-               || (e instanceof java.rmi.server.SkeletonNotFoundException)
-               || (e instanceof StubNotFoundException)
-               || (e instanceof UnknownHostException)
-                        ? new ConfigurationException()
-                : (e instanceof ServerException)
-                        ? newNamingException(e.getCause())
-                        : new NamingException();
+        NamingException ret = (e instanceof AccessException) ? new NoPermissionException()
+                : (e instanceof ConnectException) ? new ServiceUnavailableException()
+                        : (e instanceof ConnectIOException)
+                                || (e instanceof ExportException)
+                                || (e instanceof MarshalException)
+                                || (e instanceof UnmarshalException) ? new CommunicationException()
+                                : (e instanceof ActivateFailedException)
+                                        || (e instanceof NoSuchObjectException)
+                                        || (e instanceof java.rmi.server.SkeletonMismatchException)
+                                        || (e instanceof java.rmi.server.SkeletonNotFoundException)
+                                        || (e instanceof StubNotFoundException)
+                                        || (e instanceof UnknownHostException) ? new ConfigurationException()
+                                        : (e instanceof ServerException) ? newNamingException(e
+                                                .getCause())
+                                                : new NamingException();
 
         if (ret.getCause() == null) {
             ret.initCause(e);
@@ -719,13 +713,13 @@
 
     /**
      * Installs {@link RMISecurityManager} if it is not already installed.
-     *
-     * @throws  NoPermissionException
-     *          If security manager other than {@link RMISecurityManager}
-     *          is installed and prohibits installing a new security manager.
+     * 
+     * @throws NoPermissionException
+     *             If security manager other than {@link RMISecurityManager} is
+     *             installed and prohibits installing a new security manager.
      */
     protected void installSecurityManager() throws NoPermissionException {
-        if (! (System.getSecurityManager() instanceof RMISecurityManager)) {
+        if (!(System.getSecurityManager() instanceof RMISecurityManager)) {
             try {
                 System.setSecurityManager(new RMISecurityManager());
             } catch (SecurityException e) {
@@ -737,42 +731,41 @@
     }
 
     /**
-     * Creates reference to the {@linkplain Registry RMI registry}
-     * located on the specified host and port.
-     *
-     * @param   host
-     *          Host. If <code>null</code>, localhost is assumed.
-     *          May not be <code>null</code>
-     *          if <code>csf</code> is not <code>null</code>.
-     *
-     * @param   port
-     *          Port. If <code>0</code>, default registry port
-     *          (<code>1099</code>) is assumed.
-     *          May not be <code>0</code>
-     *          if <code>csf</code> is not <code>null</code>.
-     *
-     * @param   csf
-     *          RMIClientSocketFactory that is used to create socket connections to the
-     *          registry. If <code>null</code>, default socket factory is used.
-     *          See
-     *          {@link LocateRegistry#getRegistry(String, int, RMIClientSocketFactory)}.
-     *
-     * @return  Registry reference.
-     *
-     * @throws  NamingException
-     *          If getting registry failed.
+     * Creates reference to the {@linkplain Registry RMI registry} located on
+     * the specified host and port.
+     * 
+     * @param host
+     *            Host. If <code>null</code>, localhost is assumed. May not
+     *            be <code>null</code> if <code>csf</code> is not
+     *            <code>null</code>.
+     * 
+     * @param port
+     *            Port. If <code>0</code>, default registry port (<code>1099</code>)
+     *            is assumed. May not be <code>0</code> if <code>csf</code>
+     *            is not <code>null</code>.
+     * 
+     * @param csf
+     *            RMIClientSocketFactory that is used to create socket
+     *            connections to the registry. If <code>null</code>, default
+     *            socket factory is used. See
+     *            {@link LocateRegistry#getRegistry(String, int, RMIClientSocketFactory)}.
+     * 
+     * @return Registry reference.
+     * 
+     * @throws NamingException
+     *             If getting registry failed.
      */
     protected Registry getRegistry(String host, int port,
             RMIClientSocketFactory csf) throws NamingException {
         try {
             return ((csf != null) ? LocateRegistry.getRegistry(host, port, csf)
-                    : ((host != null)
-                        ? ((port != 0) ? LocateRegistry.getRegistry(host, port)
-                                       : LocateRegistry.getRegistry(host))
-                        : ((port != 0) ? LocateRegistry.getRegistry(port)
-                                       : LocateRegistry.getRegistry())));
+                    : ((host != null) ? ((port != 0) ? LocateRegistry
+                            .getRegistry(host, port) : LocateRegistry
+                            .getRegistry(host)) : ((port != 0) ? LocateRegistry
+                            .getRegistry(port) : LocateRegistry.getRegistry())));
         } catch (RemoteException e) {
             throw (NamingException) new NamingException().initCause(e);
         }
     }
+
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RegistryContextFactory.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RegistryContextFactory.java?view=diff&rev=550106&r1=550105&r2=550106
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RegistryContextFactory.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RegistryContextFactory.java Sat Jun 23 13:53:42 2007
@@ -20,6 +20,7 @@
  * @author  Vasily Zakharov
  * @version $Revision: 1.1.2.3 $
  */
+
 package org.apache.harmony.jndi.provider.rmi.registry;
 
 import java.util.Enumeration;
@@ -40,20 +41,17 @@
 import org.apache.harmony.jndi.internal.nls.Messages;
 import org.apache.harmony.jndi.provider.rmi.rmiURLContextFactory;
 
-
 /**
  * Initial context and object factory for {@link RegistryContext}.
- *
- * @author  Vasily Zakharov
- * @version $Revision: 1.1.2.3 $
  */
-public class RegistryContextFactory
-        implements InitialContextFactory, ObjectFactory {
+public class RegistryContextFactory implements InitialContextFactory,
+        ObjectFactory {
 
     /**
      * Default constructor.
      */
-    public RegistryContextFactory() {}
+    public RegistryContextFactory() {
+    }
 
     /**
      * {@inheritDoc}
@@ -70,13 +68,14 @@
             url = RegistryContext.RMI_URL_PREFIX;
         }
 
-        Object obj = new rmiURLContextFactory().getObjectInstance(
-                url, null, null, environment);
+        Object obj = new rmiURLContextFactory().getObjectInstance(url, null,
+                null, environment);
 
         if (obj instanceof Context) {
             return (Context) obj;
         }
-        // jndi.76=Object instantiated using the URL specified in environment is not a context: {0}
+        // jndi.76=Object instantiated using the URL specified in environment is
+        // not a context: {0}
         throw new NotContextException(Messages.getString("jndi.76", url)); //$NON-NLS-1$
     }
 
@@ -90,8 +89,8 @@
         }
         Reference reference = (Reference) obj;
 
-        if (!reference.getFactoryClassName()
-                        .equals(RegistryContextFactory.class.getName())) {
+        if (!reference.getFactoryClassName().equals(
+                RegistryContextFactory.class.getName())) {
             return null;
         }
         int size = reference.size();
@@ -102,7 +101,7 @@
         }
         Vector<Object> urls = new Vector<Object>(size);
 
-        for (Enumeration<RefAddr> e = reference.getAll(); e.hasMoreElements(); ) {
+        for (Enumeration<RefAddr> e = reference.getAll(); e.hasMoreElements();) {
             RefAddr refAddr = e.nextElement();
 
             if ((refAddr instanceof StringRefAddr)
@@ -116,12 +115,13 @@
             // jndi.78=Reference contains no valid addresses
             throw new ConfigurationException(Messages.getString("jndi.78")); //$NON-NLS-1$
         }
-        Object ret = new rmiURLContextFactory().getObjectInstance(
-                urls.toArray(new String[size]), name, nameCtx, environment);
+        Object ret = new rmiURLContextFactory().getObjectInstance(urls
+                .toArray(new String[size]), name, nameCtx, environment);
 
         if (ret instanceof RegistryContext) {
             ((RegistryContext) ret).setReference(reference);
         }
         return ret;
     }
+
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RemoteReference.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RemoteReference.java?view=diff&rev=550106&r1=550105&r2=550106
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RemoteReference.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RemoteReference.java Sat Jun 23 13:53:42 2007
@@ -20,6 +20,7 @@
  * @author  Vasily Zakharov
  * @version $Revision: 1.1.2.2 $
  */
+
 package org.apache.harmony.jndi.provider.rmi.registry;
 
 import java.rmi.Remote;
@@ -28,25 +29,22 @@
 import javax.naming.NamingException;
 import javax.naming.Reference;
 
-
 /**
  * This interface provides access to a remote reference.
- *
- * @author  Vasily Zakharov
- * @version $Revision: 1.1.2.2 $
  */
 public interface RemoteReference extends Remote {
 
     /**
      * Returns the remote reference.
-     *
-     * @return  Remote reference.
-     *
-     * @throws  NamingException
-     *          If naming exception occurs.
-     *
-     * @throws  RemoteException
-     *          If RMI remote exception occurs.
+     * 
+     * @return Remote reference.
+     * 
+     * @throws NamingException
+     *             If naming exception occurs.
+     * 
+     * @throws RemoteException
+     *             If RMI remote exception occurs.
      */
     public Reference getReference() throws NamingException, RemoteException;
+
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RemoteReferenceWrapper.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RemoteReferenceWrapper.java?view=diff&rev=550106&r1=550105&r2=550106
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RemoteReferenceWrapper.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RemoteReferenceWrapper.java Sat Jun 23 13:53:42 2007
@@ -20,25 +20,21 @@
  * @author  Vasily Zakharov
  * @version $Revision: 1.1.2.2 $
  */
+
 package org.apache.harmony.jndi.provider.rmi.registry;
 
 import java.rmi.Remote;
 import java.rmi.RemoteException;
-
 import java.rmi.server.UnicastRemoteObject;
 
 import javax.naming.Reference;
 
-
 /**
- * This class stores a {@link Reference}
- * and provides {@link Remote} access to it.
- *
- * @author  Vasily Zakharov
- * @version $Revision: 1.1.2.2 $
+ * This class stores a {@link Reference} and provides {@link Remote} access to
+ * it.
  */
-public class RemoteReferenceWrapper extends UnicastRemoteObject
-        implements RemoteReference {
+public class RemoteReferenceWrapper extends UnicastRemoteObject implements
+        RemoteReference {
 
     /**
      * serialVersionUID
@@ -52,12 +48,12 @@
 
     /**
      * Creates wrapper for the specified reference.
-     *
-     * @param   reference
-     *          Reference to wrap.
-     *
-     * @throws  RemoteException
-     *          If object export failed.
+     * 
+     * @param reference
+     *            Reference to wrap.
+     * 
+     * @throws RemoteException
+     *             If object export failed.
      */
     public RemoteReferenceWrapper(Reference reference) throws RemoteException {
         this.reference = reference;
@@ -65,10 +61,11 @@
 
     /**
      * Returns the wrapped reference.
-     *
-     * @return  Wrapped reference.
+     * 
+     * @return Wrapped reference.
      */
     public Reference getReference() {
         return reference;
     }
+
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RemoteReferenceWrapper_Skel.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RemoteReferenceWrapper_Skel.java?view=diff&rev=550106&r1=550105&r2=550106
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RemoteReferenceWrapper_Skel.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RemoteReferenceWrapper_Skel.java Sat Jun 23 13:53:42 2007
@@ -26,36 +26,40 @@
  * DO NOT EDIT!!!
  * Contents subject to change without notice!
  */
+
 package org.apache.harmony.jndi.provider.rmi.registry;
 
 import org.apache.harmony.jndi.internal.nls.Messages;
 
-@SuppressWarnings("deprecation") //$NON-NLS-1$
-public final class RemoteReferenceWrapper_Skel implements java.rmi.server.Skeleton {
+@SuppressWarnings("deprecation")
+public final class RemoteReferenceWrapper_Skel implements
+        java.rmi.server.Skeleton {
 
     private static final long interfaceHash = 2534274963554139942L;
 
-    private static final java.rmi.server.Operation[] operations = {
-        new java.rmi.server.Operation("javax.naming.Reference getReference()") //$NON-NLS-1$
+    private static final java.rmi.server.Operation[] operations = { new java.rmi.server.Operation(
+            "javax.naming.Reference getReference()") //$NON-NLS-1$
     };
 
     public java.rmi.server.Operation[] getOperations() {
         return operations.clone();
     }
 
-    public void dispatch(java.rmi.Remote obj, java.rmi.server.RemoteCall call, int opnum, long hash) throws java.lang.Exception {
+    public void dispatch(java.rmi.Remote obj, java.rmi.server.RemoteCall call,
+            int opnum, long hash) throws java.lang.Exception {
         if (opnum < 0) {
             if (hash == 3529874867989176284L) {
                 opnum = 0;
             } else {
                 // jndi.87=Invalid method hash: {0}
-                throw new java.rmi.UnmarshalException(Messages.getString("jndi.87", hash)); //$NON-NLS-1$
+                throw new java.rmi.UnmarshalException(Messages.getString(
+                        "jndi.87", hash)); //$NON-NLS-1$
             }
         } else {
             if (hash != interfaceHash) {
                 // jndi.88=Interface hash mismatch, expected: {0}, received: {1}
-                throw new java.rmi.server.SkeletonMismatchException(
-                        Messages.getString("jndi.88", interfaceHash , hash)); //$NON-NLS-1$
+                throw new java.rmi.server.SkeletonMismatchException(Messages
+                        .getString("jndi.88", interfaceHash, hash)); //$NON-NLS-1$
             }
         }
 
@@ -63,26 +67,29 @@
 
         switch (opnum) {
 
-        case 0: {    // getReference()
+            case 0: { // getReference()
 
-            call.releaseInputStream();
+                call.releaseInputStream();
 
-            javax.naming.Reference $result = server.getReference();
+                javax.naming.Reference $result = server.getReference();
 
-            try {
-                java.io.ObjectOutput out = call.getResultStream(true);
-                out.writeObject($result);
-            } catch (java.io.IOException e) {
-                // jndi.89=Error marshalling return
-                throw new java.rmi.MarshalException(Messages.getString("jndi.89"), e); //$NON-NLS-1$
-            }
+                try {
+                    java.io.ObjectOutput out = call.getResultStream(true);
+                    out.writeObject($result);
+                } catch (java.io.IOException e) {
+                    // jndi.89=Error marshalling return
+                    throw new java.rmi.MarshalException(Messages
+                            .getString("jndi.89"), e); //$NON-NLS-1$
+                }
 
-            break;
-        }
+                break;
+            }
 
-        default:
-            // jndi.8A=Invalid method number: {0}
-            throw new java.rmi.UnmarshalException(Messages.getString("jndi.8A", opnum)); //$NON-NLS-1$
+            default:
+                // jndi.8A=Invalid method number: {0}
+                throw new java.rmi.UnmarshalException(Messages.getString(
+                        "jndi.8A", opnum)); //$NON-NLS-1$
         }
     }
+
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RemoteReferenceWrapper_Stub.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RemoteReferenceWrapper_Stub.java?view=diff&rev=550106&r1=550105&r2=550106
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RemoteReferenceWrapper_Stub.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/registry/RemoteReferenceWrapper_Stub.java Sat Jun 23 13:53:42 2007
@@ -26,13 +26,16 @@
  * DO NOT EDIT!!!
  * Contents subject to change without notice!
  */
+
 package org.apache.harmony.jndi.provider.rmi.registry;
 
 import org.apache.harmony.jndi.internal.nls.Messages;
 
-@SuppressWarnings("deprecation") //$NON-NLS-1$
-public final class RemoteReferenceWrapper_Stub extends java.rmi.server.RemoteStub
-        implements org.apache.harmony.jndi.provider.rmi.registry.RemoteReference, java.rmi.Remote {
+@SuppressWarnings("deprecation")
+public final class RemoteReferenceWrapper_Stub extends
+        java.rmi.server.RemoteStub implements
+        org.apache.harmony.jndi.provider.rmi.registry.RemoteReference,
+        java.rmi.Remote {
 
     private static final long serialVersionUID = 2;
 
@@ -40,17 +43,20 @@
 
     private static boolean useNewInvoke;
 
-    private static final java.rmi.server.Operation[] operations = {
-        new java.rmi.server.Operation("javax.naming.Reference getReference()") //$NON-NLS-1$
+    private static final java.rmi.server.Operation[] operations = { new java.rmi.server.Operation(
+            "javax.naming.Reference getReference()") //$NON-NLS-1$
     };
 
     private static java.lang.reflect.Method $method_getReference_0;
 
     static {
         try {
-            java.rmi.server.RemoteRef.class.getMethod("invoke", new java.lang.Class[] {java.rmi.Remote.class, java.lang.reflect.Method.class, java.lang.Object[].class, long.class}); //$NON-NLS-1$
+            java.rmi.server.RemoteRef.class
+                    .getMethod(
+                            "invoke", new java.lang.Class[] { java.rmi.Remote.class, java.lang.reflect.Method.class, java.lang.Object[].class, long.class }); //$NON-NLS-1$
 
-            $method_getReference_0 = org.apache.harmony.jndi.provider.rmi.registry.RemoteReference.class.getMethod("getReference", new java.lang.Class[] {}); //$NON-NLS-1$
+            $method_getReference_0 = org.apache.harmony.jndi.provider.rmi.registry.RemoteReference.class
+                    .getMethod("getReference", new java.lang.Class[] {}); //$NON-NLS-1$
 
             useNewInvoke = true;
         } catch (java.lang.NoSuchMethodException e) {
@@ -71,10 +77,12 @@
             throws javax.naming.NamingException, java.rmi.RemoteException {
         try {
             if (useNewInvoke) {
-                java.lang.Object $result = ref.invoke(this, $method_getReference_0, null, 3529874867989176284L);
+                java.lang.Object $result = ref.invoke(this,
+                        $method_getReference_0, null, 3529874867989176284L);
                 return ((javax.naming.Reference) $result);
             }
-            java.rmi.server.RemoteCall call = ref.newCall(this, operations, 0, interfaceHash);
+            java.rmi.server.RemoteCall call = ref.newCall(this, operations, 0,
+                    interfaceHash);
 
             ref.invoke(call);
 
@@ -85,10 +93,12 @@
                 $result = (javax.naming.Reference) in.readObject();
             } catch (java.io.IOException e) {
                 // jndi.85=Error unmarshalling return value
-                throw new java.rmi.UnmarshalException(Messages.getString("jndi.85"), e); //$NON-NLS-1$
+                throw new java.rmi.UnmarshalException(Messages
+                        .getString("jndi.85"), e); //$NON-NLS-1$
             } catch (java.lang.ClassNotFoundException e) {
                 // jndi.85=Error unmarshalling return value
-                throw new java.rmi.UnmarshalException(Messages.getString("jndi.85"), e); //$NON-NLS-1$
+                throw new java.rmi.UnmarshalException(Messages
+                        .getString("jndi.85"), e); //$NON-NLS-1$
             } finally {
                 ref.done(call);
             }
@@ -102,7 +112,9 @@
             throw e;
         } catch (java.lang.Exception e) {
             // jndi.86=Undeclared checked exception
-            throw new java.rmi.UnexpectedException(Messages.getString("jndi.86"), e); //$NON-NLS-1$
+            throw new java.rmi.UnexpectedException(Messages
+                    .getString("jndi.86"), e); //$NON-NLS-1$
         }
     }
+
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/rmiURLContext.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/rmiURLContext.java?view=diff&rev=550106&r1=550105&r2=550106
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/rmiURLContext.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/rmiURLContext.java Sat Jun 23 13:53:42 2007
@@ -20,6 +20,7 @@
  * @author  Vasily Zakharov
  * @version $Revision: 1.1.2.3 $
  */
+
 package org.apache.harmony.jndi.provider.rmi;
 
 import java.util.Hashtable;
@@ -34,12 +35,8 @@
 
 import org.apache.harmony.jndi.provider.rmi.registry.RegistryContext;
 
-
 /**
  * RMI URL context implementation.
- *
- * @author  Vasily Zakharov
- * @version $Revision: 1.1.2.3 $
  */
 public class rmiURLContext extends GenericURLContext {
 
@@ -52,38 +49,38 @@
 
     /**
      * Creates instance of this context with specified environment.
-     *
-     * @param   environment
-     *          Environment to copy.
+     * 
+     * @param environment
+     *            Environment to copy.
      */
     public rmiURLContext(Hashtable<?, ?> environment) {
         super(environment);
     }
 
     /**
-     * Determines the proper {@link RegistryContext} from the specified URL
-     * and returns the {@link ResolveResult} object with that context
-     * as resolved object and the rest of the URL as remaining name.
-     *
-     * @param   url
-     *          URL.
-     *
-     * @param   environment
-     *          Environment.
-     *
-     * @return  {@link ResolveResult} object with resolved context
-     *          as resolved object the rest of the URL as remaining name.
-     *
-     * @throws  NamingException
-     *          If some naming error occurs.
+     * Determines the proper {@link RegistryContext} from the specified URL and
+     * returns the {@link ResolveResult} object with that context as resolved
+     * object and the rest of the URL as remaining name.
+     * 
+     * @param url
+     *            URL.
+     * 
+     * @param environment
+     *            Environment.
+     * 
+     * @return {@link ResolveResult} object with resolved context as resolved
+     *         object the rest of the URL as remaining name.
+     * 
+     * @throws NamingException
+     *             If some naming error occurs.
      */
     @Override
-    protected ResolveResult getRootURLContext(
-            String url, Hashtable<?, ?> environment) throws NamingException {
+    protected ResolveResult getRootURLContext(String url,
+            Hashtable<?, ?> environment) throws NamingException {
         if (!url.startsWith(RegistryContext.RMI_URL_PREFIX)) {
             // jndi.74=Not an RMI URL, incorrect prefix: {0}
-            throw new IllegalArgumentException(
-                    Messages.getString("jndi.74", url)); //$NON-NLS-1$
+            throw new IllegalArgumentException(Messages.getString(
+                    "jndi.74", url)); //$NON-NLS-1$
         }
         int length = url.length();
         int start = RegistryContext.RMI_URL_PREFIX.length();
@@ -120,9 +117,9 @@
                         port = Integer.parseInt(url.substring(portStart, end));
                     } catch (NumberFormatException e) {
                         // jndi.75=Invalid port number in URL: {0}
-                        throw (IllegalArgumentException)
-                                new IllegalArgumentException(Messages.getString("jndi.75", //$NON-NLS-1$
-                                    url)).initCause(e);
+                        throw (IllegalArgumentException) new IllegalArgumentException(
+                                Messages.getString("jndi.75", //$NON-NLS-1$
+                                        url)).initCause(e);
                     }
                 }
 
@@ -137,7 +134,8 @@
             name.add(url.substring(start));
         }
 
-        return new ResolveResult(
-                new RegistryContext(hostName, port, environment), name);
+        return new ResolveResult(new RegistryContext(hostName, port,
+                environment), name);
     }
+
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/rmiURLContextFactory.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/rmiURLContextFactory.java?view=diff&rev=550106&r1=550105&r2=550106
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/rmiURLContextFactory.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/main/java/org/apache/harmony/jndi/provider/rmi/rmiURLContextFactory.java Sat Jun 23 13:53:42 2007
@@ -29,12 +29,8 @@
 
 import org.apache.harmony.jndi.provider.GenericURLContextFactory;
 
-
 /**
  * URL context factory for {@link rmiURLContext}.
- *
- * @author  Vasily Zakharov
- * @version $Revision: 1.1.2.2 $
  */
 public class rmiURLContextFactory extends GenericURLContextFactory {
 
@@ -48,14 +44,15 @@
     /**
      * Returns new {@link rmiURLContext}. Used by
      * {@link GenericURLContextFactory#getObjectInstance(Object, Name, Context, Hashtable)}.
-     *
-     * @param   environment
-     *          Environment.
-     *
-     * @return  New {@link rmiURLContext}.
+     * 
+     * @param environment
+     *            Environment.
+     * 
+     * @return New {@link rmiURLContext}.
      */
     @Override
     protected Context createURLContext(Hashtable<?, ?> environment) {
         return new rmiURLContext(environment);
     }
+
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectStreamField.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectStreamField.java?view=diff&rev=550106&r1=550105&r2=550106
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectStreamField.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/io/ObjectStreamField.java Sat Jun 23 13:53:42 2007
@@ -129,7 +129,7 @@
 
     @Override
     public boolean equals(Object arg0) {
-        return compareTo(arg0) == 0;
+        return (arg0 instanceof ObjectStreamField) && (compareTo(arg0) == 0);
     }
 
     @Override

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/ObjectStreamFieldTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/ObjectStreamFieldTest.java?view=diff&rev=550106&r1=550105&r2=550106
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/ObjectStreamFieldTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/test/api/common/tests/api/java/io/ObjectStreamFieldTest.java Sat Jun 23 13:53:42 2007
@@ -70,6 +70,14 @@
 		assertTrue("Used to test", true);
 	}
 
+	public void test_equalsLjava_lang_Object() {
+	    // Regression test for HARMONY-4273
+	    assertTrue(samField.equals(samField));
+	    assertFalse(samField.equals(hamField));
+	    assertFalse(samField.equals("fish"));
+	    assertFalse(samField.equals(null));
+    }
+
 	/**
 	 * @tests java.io.ObjectStreamField#compareTo(java.lang.Object)
 	 */

Modified: harmony/enhanced/classlib/branches/java6/modules/regex/src/main/java/java/util/regex/Pattern.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/regex/src/main/java/java/util/regex/Pattern.java?view=diff&rev=550106&r1=550105&r2=550106
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/regex/src/main/java/java/util/regex/Pattern.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/regex/src/main/java/java/util/regex/Pattern.java Sat Jun 23 13:53:42 2007
@@ -83,6 +83,17 @@
     public static final int CANON_EQ = 1 << 7;
     
     static final int BACK_REF_NUMBER = 10;
+    
+    /**
+     * Bit mask that includes all defined match flags
+     */
+    static final int flagsBitMask = Pattern.UNIX_LINES | 
+                                    Pattern.CASE_INSENSITIVE | 
+                                    Pattern.COMMENTS | 
+                                    Pattern.MULTILINE |  
+                                    Pattern.DOTALL | 
+                                    Pattern.UNICODE_CASE | 
+                                    Pattern.CANON_EQ;
 
     /**
      * Current <code>pattern</code> to be compiled;
@@ -259,6 +270,13 @@
 	 */
     public static Pattern compile(String regex, int flags)
             throws PatternSyntaxException {
+    	
+    	if ((flags != 0) &&
+    	   	((flags | flagsBitMask) != flagsBitMask)) {
+    	        	
+    	    throw new IllegalArgumentException(Messages.getString("regex.1C"));
+    	}
+    	
         AbstractSet.counter = 1;
 
         return new Pattern().compileImpl(regex, flags);

Modified: harmony/enhanced/classlib/branches/java6/modules/regex/src/main/java/org/apache/harmony/regex/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/regex/src/main/java/org/apache/harmony/regex/internal/nls/messages.properties?view=diff&rev=550106&r1=550105&r2=550106
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/regex/src/main/java/org/apache/harmony/regex/internal/nls/messages.properties (original)
+++ harmony/enhanced/classlib/branches/java6/modules/regex/src/main/java/org/apache/harmony/regex/internal/nls/messages.properties Sat Jun 23 13:53:42 2007
@@ -42,3 +42,4 @@
 regex.19=Invalid octal escape sequence
 regex.1A=Illegal inline construct
 regex.1B=Pattern cannot be null
+regex.1C=Invalid match flags value

Modified: harmony/enhanced/classlib/branches/java6/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/PatternErrorTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/PatternErrorTest.java?view=diff&rev=550106&r1=550105&r2=550106
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/PatternErrorTest.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/regex/src/test/java/org/apache/harmony/tests/java/util/regex/PatternErrorTest.java Sat Jun 23 13:53:42 2007
@@ -53,25 +53,14 @@
 		Pattern.compile("foo", flags);
 
 		// add invalid flags - should get IllegalArgumentException
-		/*
-		 * TODO: Inconsistency between the reference JDK behaviour and spec - exception is
-		 * not thrown
-		 */
-		/*
-		 * Valid test is:
-		 * flags |= 0xFFFFFFFF;
-		 * try {
-		 *   Pattern.compile("foo",flags);
-		 * } catch (IllegalArgumentException e) {
-		 *   // This is the expected exception
-		 * } catch (Exception e) {
-		 *   fail();
-		 * }
-		 */
-
-        /* Workaround test is: */
+        // regression test for HARMONY-4248
 		flags |= 0xFFFFFFFF;
-        // No exception expected to match incorrect the reference behaviour
-		Pattern.compile("foo", flags);
+		try {
+		    Pattern.compile("foo",flags);
+		} catch (IllegalArgumentException e) {
+		    // This is the expected exception
+		} catch (Exception e) {
+		    fail();
+		}
 	}
 }



Mime
View raw message