8194143: remove unneeded casts in LocationImpl and MirrorImpl classes
Summary: remove unneeded casts in LocationImpl and MirrorImpl classes
Reviewed-by: sspitsyn, dholmes
Contributed-by: egor.ushakov@jetbrains.com
--- a/src/jdk.jdi/share/classes/com/sun/tools/jdi/LocationImpl.java Mon Jan 22 15:29:59 2018 -0500
+++ b/src/jdk.jdi/share/classes/com/sun/tools/jdi/LocationImpl.java Mon Jan 22 14:14:26 2018 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -79,8 +79,7 @@
return method().hashCode() + (int)codeIndex();
}
- public int compareTo(Location object) {
- LocationImpl other = (LocationImpl)object;
+ public int compareTo(Location other) {
int rc = method().compareTo(other.method());
if (rc == 0) {
long diff = codeIndex() - other.codeIndex();
--- a/src/jdk.jdi/share/classes/com/sun/tools/jdi/MirrorImpl.java Mon Jan 22 15:29:59 2018 -0500
+++ b/src/jdk.jdi/share/classes/com/sun/tools/jdi/MirrorImpl.java Mon Jan 22 14:14:26 2018 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -26,7 +26,6 @@
package com.sun.tools.jdi;
import java.util.Collection;
-import java.util.Iterator;
import com.sun.jdi.Mirror;
import com.sun.jdi.VMMismatchException;
@@ -87,12 +86,8 @@
* Throw VMMismatchException on wrong VM.
*/
void validateMirrors(Collection<? extends Mirror> mirrors) {
- Iterator<? extends Mirror> iter = mirrors.iterator();
- while (iter.hasNext()) {
- MirrorImpl mirror = (MirrorImpl)iter.next();
- if (!vm.equals(mirror.vm)) {
- throw new VMMismatchException(mirror.toString());
- }
+ for (Mirror mirror : mirrors) {
+ validateMirror(mirror);
}
}
@@ -101,12 +96,8 @@
* Throw VMMismatchException on wrong VM.
*/
void validateMirrorsOrNulls(Collection<? extends Mirror> mirrors) {
- Iterator<? extends Mirror> iter = mirrors.iterator();
- while (iter.hasNext()) {
- MirrorImpl mirror = (MirrorImpl)iter.next();
- if ((mirror != null) && !vm.equals(mirror.vm)) {
- throw new VMMismatchException(mirror.toString());
- }
+ for (Mirror mirror : mirrors) {
+ validateMirrorOrNull(mirror);
}
}
}