diff options
Diffstat (limited to 'libjava/classpath/org/omg/CosNaming/NamingContextHelper.java')
-rw-r--r-- | libjava/classpath/org/omg/CosNaming/NamingContextHelper.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/libjava/classpath/org/omg/CosNaming/NamingContextHelper.java b/libjava/classpath/org/omg/CosNaming/NamingContextHelper.java index 3a60d9cb4de..fb9b091a6a0 100644 --- a/libjava/classpath/org/omg/CosNaming/NamingContextHelper.java +++ b/libjava/classpath/org/omg/CosNaming/NamingContextHelper.java @@ -38,6 +38,8 @@ exception statement from your version. */ package org.omg.CosNaming; +import gnu.CORBA.Minor; + import org.omg.CORBA.Any; import org.omg.CORBA.BAD_OPERATION; import org.omg.CORBA.BAD_PARAM; @@ -78,6 +80,7 @@ public abstract class NamingContextHelper { BAD_OPERATION bad = new BAD_OPERATION("Naming context expected"); bad.initCause(ex); + bad.minor = Minor.Any; throw bad; } } @@ -130,6 +133,35 @@ public abstract class NamingContextHelper else throw new BAD_PARAM(); } + + /** + * Narrow the given object to the NamingContext. No type-checking is performed + * to verify that the object actually supports the requested type. The + * {@link BAD_OPERATION} will be thrown if unsupported operations are invoked + * on the new returned reference, but no failure is expected at the time of + * the unchecked_narrow. + * + * @param obj the object to cast. + * + * @return the casted NamingContext. + * + * @since 1.5 + * + * @see OMG issue 4158. + */ + public static NamingContext unchecked_narrow(org.omg.CORBA.Object obj) + { + if (obj == null) + return null; + else if (obj instanceof NamingContext) + return (NamingContext) obj; + else + { + // Do not call the _is_a(..). + Delegate delegate = ((ObjectImpl) obj)._get_delegate(); + return new _NamingContextStub(delegate); + } + } /** * Read the naming context from the given CDR input stream. |