Skip to content
Permalink
Browse files
8239055: Wrong implementation of VMState.hasListener
Correct the VMState.hasListener implementation to return WeakReference<VMListener> type

Reviewed-by: sspitsyn, poonam
  • Loading branch information
Fairoz Matte committed Feb 28, 2020
1 parent 3ca275f commit ea55699f34e0685e06f114fbe7cf12ff77742dc3
Showing with 9 additions and 2 deletions.
  1. +9 −2 src/jdk.jdi/share/classes/com/sun/tools/jdi/VMState.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 2020, 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
@@ -174,7 +174,14 @@ synchronized void addListener(VMListener listener) {
}

synchronized boolean hasListener(VMListener listener) {
return listeners.contains(listener);
Iterator<WeakReference<VMListener>> iter = listeners.iterator();
while (iter.hasNext()) {
WeakReference<VMListener> ref = iter.next();
if (listener.equals(ref.get())) {
return true;
}
}
return false;
}

synchronized void removeListener(VMListener listener) {

0 comments on commit ea55699

Please sign in to comment.