}, as per Section 3.9 of The Java Virtual
* Machine Specification.
*
* @return the name of the method containing the execution point
@@ -138,7 +135,7 @@
* Returns true if the method containing the execution point
* represented by this stack trace element is a native method.
*
- * @return true if the method containing the execution point
+ * @return {@code true} if the method containing the execution point
* represented by this stack trace element is a native method.
*/
public boolean isNativeMethod() {
@@ -151,21 +148,21 @@
* examples may be regarded as typical:
*
* -
- * "MyClass.mash(MyClass.java:9)" - Here, "MyClass"
+ * {@code "MyClass.mash(MyClass.java:9)"} - Here, {@code "MyClass"}
* is the fully-qualified name of the class containing the
* execution point represented by this stack trace element,
- * "mash" is the name of the method containing the execution
- * point, "MyClass.java" is the source file containing the
- * execution point, and "9" is the line number of the source
+ * {@code "mash"} is the name of the method containing the execution
+ * point, {@code "MyClass.java"} is the source file containing the
+ * execution point, and {@code "9"} is the line number of the source
* line containing the execution point.
*
-
- * "MyClass.mash(MyClass.java)" - As above, but the line
+ * {@code "MyClass.mash(MyClass.java)"} - As above, but the line
* number is unavailable.
*
-
- * "MyClass.mash(Unknown Source)" - As above, but neither
+ * {@code "MyClass.mash(Unknown Source)"} - As above, but neither
* the file name nor the line number are available.
*
-
- * "MyClass.mash(Native Method)" - As above, but neither
+ * {@code "MyClass.mash(Native Method)"} - As above, but neither
* the file name nor the line number are available, and the method
* containing the execution point is known to be a native method.
*
@@ -181,25 +178,21 @@
/**
* Returns true if the specified object is another
- * StackTraceElement instance representing the same execution
- * point as this instance. Two stack trace elements a and
- * b are equal if and only if:
+ * {@code StackTraceElement} instance representing the same execution
+ * point as this instance. Two stack trace elements {@code a} and
+ * {@code b} are equal if and only if:
*
* equals(a.getFileName(), b.getFileName()) &&
* a.getLineNumber() == b.getLineNumber()) &&
* equals(a.getClassName(), b.getClassName()) &&
* equals(a.getMethodName(), b.getMethodName())
*
- * where equals is defined as:
- *
- * static boolean equals(Object a, Object b) {
- * return a==b || (a != null && a.equals(b));
- * }
- *
+ * where {@code equals} has the semantics of {@link
+ * java.util.Objects#equals(Object, Object) Objects.equals}.
*
* @param obj the object to be compared with this stack trace element.
* @return true if the specified object is another
- * StackTraceElement instance representing the same
+ * {@code StackTraceElement} instance representing the same
* execution point as this instance.
*/
public boolean equals(Object obj) {
@@ -208,12 +201,10 @@
if (!(obj instanceof StackTraceElement))
return false;
StackTraceElement e = (StackTraceElement)obj;
- return e.declaringClass.equals(declaringClass) && e.lineNumber == lineNumber
- && eq(methodName, e.methodName) && eq(fileName, e.fileName);
- }
-
- private static boolean eq(Object a, Object b) {
- return a==b || (a != null && a.equals(b));
+ return e.declaringClass.equals(declaringClass) &&
+ e.lineNumber == lineNumber &&
+ Objects.equals(methodName, e.methodName) &&
+ Objects.equals(fileName, e.fileName);
}
/**
@@ -221,7 +212,7 @@
*/
public int hashCode() {
int result = 31*declaringClass.hashCode() + methodName.hashCode();
- result = 31*result + (fileName == null ? 0 : fileName.hashCode());
+ result = 31*result + Objects.hashCode(fileName);
result = 31*result + lineNumber;
return result;
}