Index: src/main/java/common/java/awt/Container.java =================================================================== --- src/main/java/common/java/awt/Container.java (revision 499702) +++ src/main/java/common/java/awt/Container.java (working copy) @@ -277,6 +277,10 @@ public void remove(Component comp) { toolkit.lockAWT(); try { + if (comp == null) { + throw new NullPointerException(); + } + try { remove(children.indexOf(comp)); } catch (ArrayIndexOutOfBoundsException e) { Index: src/test/api/java/common/java/awt/ContainerRTest.java =================================================================== --- src/test/api/java/common/java/awt/ContainerRTest.java (revision 499702) +++ src/test/api/java/common/java/awt/ContainerRTest.java (working copy) @@ -26,7 +26,20 @@ public class ContainerRTest extends TestCase { + public static void main(final String[] args) { + junit.textui.TestRunner.run(ContainerRTest.class); + } + public final void testRemoveComponent() { + // Regression test for HARMONY-1476 + try { + new Container().remove((Component) null); + fail("NPE was not thrown"); + } catch (NullPointerException ex) { + // passed + } + } + public final void testSetFocusTraversalKeys() { try { Button btn = new Button(); @@ -63,17 +76,4 @@ // PASSED } } - -// public final void testRemoveComponent() { -// Button b = new Button(); -// boolean npeThrown = false; -// Container c = new Container(); -// c.remove(b); // no exception is thrown -// try { -// c.remove(b = null); -// } catch (NullPointerException npe) { -// npeThrown = true; -// } -// assertTrue("remove(null) throws NPE", npeThrown); -// } }