# HG changeset patch # User sspitsyn # Date 1516659266 28800 # Node ID 6738bf66931485b3f01099cd379d9b5def07132b # Parent cc7ae802c53759820f88605cf2a8ddb7d4da3e30 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 diff -r cc7ae802c537 -r 6738bf669314 src/jdk.jdi/share/classes/com/sun/tools/jdi/LocationImpl.java --- 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(); diff -r cc7ae802c537 -r 6738bf669314 src/jdk.jdi/share/classes/com/sun/tools/jdi/MirrorImpl.java --- 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 mirrors) { - Iterator 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 mirrors) { - Iterator 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); } } }