提交 ca66492f 编写于 作者: M mduigou

7029491: fix broken test file committed with CR 5045147.

Summary: an incorrect file was committed with CR 5045147. This commit corrects that error and also applies minor review suggestions.
Reviewed-by: alanb
上级 7ff04ffb
/* /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -33,17 +33,18 @@ import java.util.concurrent.*; ...@@ -33,17 +33,18 @@ import java.util.concurrent.*;
import java.util.concurrent.atomic.*; import java.util.concurrent.atomic.*;
import java.lang.reflect.*; import java.lang.reflect.*;
public class cr5045147 { public class EmptyMapAndNulls {
@SuppressWarnings("rawtypes")
static void realMain(String[] args) throws Throwable { static void realMain(String[] args) throws Throwable {
// No comparator // No comparator
Map<String,String> comparable = new TreeMap<>(); Map<String,String> comparable = new TreeMap<>();
// insert null into empty map (504517 failure) // insert null into empty map (5045147 failure)
try { try {
comparable.put(null, "anything"); comparable.put(null, "anything");
fail("null shouldn't be accepted"); fail("null shouldn't be accepted");
} catch(NullPointerExecption failed) { } catch (NullPointerException failed) {
pass(); pass();
} }
...@@ -51,7 +52,7 @@ public class cr5045147 { ...@@ -51,7 +52,7 @@ public class cr5045147 {
try { try {
comparable.put("test", "anything"); comparable.put("test", "anything");
pass(); pass();
} catch(NullPointerExecption failed) { } catch (NullPointerException failed) {
fail(); fail();
} }
...@@ -59,17 +60,18 @@ public class cr5045147 { ...@@ -59,17 +60,18 @@ public class cr5045147 {
try { try {
comparable.put(null, "anything"); comparable.put(null, "anything");
fail("null shouldn't be accepted"); fail("null shouldn't be accepted");
} catch(NullPointerExecption failed) { } catch (NullPointerException failed) {
pass(); pass();
} }
Map<String,String> comparator = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); // Comparator (String.CASE_INSENSITIVE_ORDER). Intentionally a raw type.
Map comparator = new TreeMap(String.CASE_INSENSITIVE_ORDER);
// insert null into empty map (504517 failure) // insert null into empty map (5045147 failure)
try { try {
comparator.put(null, "anything"); comparator.put(null, "anything");
fail("null shouldn't be accepted"); fail("null shouldn't be accepted");
} catch(NullPointerExecption failed) { } catch (NullPointerException failed) {
pass(); pass();
} }
...@@ -77,7 +79,7 @@ public class cr5045147 { ...@@ -77,7 +79,7 @@ public class cr5045147 {
try { try {
comparator.put("test", "anything"); comparator.put("test", "anything");
pass(); pass();
} catch(NullPointerExecption failed) { } catch (NullPointerException failed) {
fail(); fail();
} }
...@@ -85,17 +87,17 @@ public class cr5045147 { ...@@ -85,17 +87,17 @@ public class cr5045147 {
try { try {
comparator.put(null, "anything"); comparator.put(null, "anything");
fail("null shouldn't be accepted"); fail("null shouldn't be accepted");
} catch(NullPointerExecption failed) { } catch (NullPointerException failed) {
pass(); pass();
} }
comparator.clear(); comparator.clear();
// insert non-String into empty map (504517 failure) // insert non-String into empty map (5045147 failure)
try { try {
comparator.put(new Object(), "anything"); comparator.put(new Object(), "anything");
fail("Object shouldn't be accepted"); fail("Object shouldn't be accepted");
} catch(ClassCastExecption failed) { } catch (ClassCastException failed) {
pass(); pass();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册