equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
22 * or visit www.oracle.com if you need additional information or have any |
22 * or visit www.oracle.com if you need additional information or have any |
23 * questions. |
23 * questions. |
24 */ |
24 */ |
25 |
25 |
26 package com.sun.tools.javac.util; |
26 package com.sun.tools.javac.util; |
27 |
|
28 |
27 |
29 /** |
28 /** |
30 * Simple facility for unconditional assertions. |
29 * Simple facility for unconditional assertions. |
31 * The methods in this class are described in terms of equivalent assert |
30 * The methods in this class are described in terms of equivalent assert |
32 * statements, assuming that assertions have been enabled. |
31 * statements, assuming that assertions have been enabled. |
85 if (!cond) |
84 if (!cond) |
86 error(String.valueOf(value)); |
85 error(String.valueOf(value)); |
87 } |
86 } |
88 |
87 |
89 /** Equivalent to |
88 /** Equivalent to |
90 * assert cond : value; |
89 * assert cond : msg; |
91 */ |
90 */ |
92 public static void check(boolean cond, String msg) { |
91 public static void check(boolean cond, String msg) { |
93 if (!cond) |
92 if (!cond) |
94 error(msg); |
93 error(msg); |
95 } |
94 } |
101 if (o != null) |
100 if (o != null) |
102 error(String.valueOf(value)); |
101 error(String.valueOf(value)); |
103 } |
102 } |
104 |
103 |
105 /** Equivalent to |
104 /** Equivalent to |
106 * assert (o == null) : value; |
105 * assert (o == null) : msg; |
107 */ |
106 */ |
108 public static void checkNull(Object o, String msg) { |
107 public static void checkNull(Object o, String msg) { |
109 if (o != null) |
108 if (o != null) |
110 error(msg); |
109 error(msg); |
111 } |
110 } |
112 |
111 |
113 /** Equivalent to |
112 /** Equivalent to |
114 * assert (o != null) : value; |
113 * assert (o != null) : msg; |
115 */ |
114 */ |
116 public static <T> T checkNonNull(T t, String msg) { |
115 public static <T> T checkNonNull(T t, String msg) { |
117 if (t == null) |
116 if (t == null) |
118 error(msg); |
117 error(msg); |
119 return t; |
118 return t; |