Index: modules/jndi/src/main/java/javax/naming/CompoundName.java =================================================================== --- modules/jndi/src/main/java/javax/naming/CompoundName.java (revision 490073) +++ modules/jndi/src/main/java/javax/naming/CompoundName.java (working copy) @@ -641,6 +641,10 @@ public Name add(String element) throws InvalidNameException { if (element == null) { + // jndi.8C=component must not be null + throw new IllegalArgumentException(Messages.getString("jndi.8C")); //$NON-NLS-1$ + } + if ((size() > 0) && (FLAT.equals(direction))) { // jndi.0A=A flat name can only have a single component throw new InvalidNameException(Messages.getString("jndi.0A")); //$NON-NLS-1$ } @@ -662,9 +666,13 @@ */ public Name add(int index, String element) throws InvalidNameException { if (element == null) { - // jndi.0B=A flat name can only zero or one component - throw new InvalidNameException(Messages.getString("jndi.0B")); //$NON-NLS-1$ + // jndi.8C=component must not be null + throw new IllegalArgumentException(Messages.getString("jndi.8C")); //$NON-NLS-1$ } + if ((size() > 0) && (FLAT.equals(direction))) { + // jndi.0A=A flat name can only have a single component + throw new InvalidNameException(Messages.getString("jndi.0A")); //$NON-NLS-1$ + } validateIndex(index, true); elem.add(index, element); return this; Index: modules/jndi/src/main/java/org/apache/harmony/jndi/internal/nls/messages.properties =================================================================== --- modules/jndi/src/main/java/org/apache/harmony/jndi/internal/nls/messages.properties (revision 490073) +++ modules/jndi/src/main/java/org/apache/harmony/jndi/internal/nls/messages.properties (working copy) @@ -154,5 +154,7 @@ jndi.88=Interface hash mismatch, expected: {0}, received: {1} jndi.89=Error marshalling return jndi.8A=Invalid method number: {0} +jndi.8B=attrs must not be null +jndi.8C=component must not be null jndi.err.00=. The stack trace of the root exception is: