author | jbachorik |
Tue, 29 Apr 2014 11:15:21 +0200 | |
changeset 24125 | b85eeaae56c7 |
parent 14342 | 8435a30053c1 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
14342
8435a30053c1
7197491: update copyright year to match last edit in jdk8 jdk repository
alanb
parents:
11277
diff
changeset
|
2 |
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package com.sun.tools.jdi; |
|
27 |
||
28 |
import com.sun.jdi.*; |
|
29 |
import java.util.Collection; |
|
30 |
import java.util.Iterator; |
|
31 |
||
32 |
abstract class MirrorImpl extends Object implements Mirror { |
|
33 |
||
34 |
protected VirtualMachineImpl vm; |
|
35 |
||
36 |
MirrorImpl(VirtualMachine aVm) { |
|
37 |
super(); |
|
38 |
||
39 |
// Yes, its a bit of a hack. But by doing it this |
|
40 |
// way, this is the only place we have to change |
|
41 |
// typing to substitute a new impl. |
|
42 |
vm = (VirtualMachineImpl)aVm; |
|
43 |
} |
|
44 |
||
45 |
public VirtualMachine virtualMachine() { |
|
46 |
return vm; |
|
47 |
} |
|
48 |
||
49 |
public boolean equals(Object obj) { |
|
50 |
if ((obj != null) && (obj instanceof Mirror)) { |
|
51 |
Mirror other = (Mirror)obj; |
|
52 |
return vm.equals(other.virtualMachine()); |
|
53 |
} else { |
|
54 |
return false; |
|
55 |
} |
|
56 |
} |
|
57 |
||
58 |
public int hashCode() { |
|
59 |
return vm.hashCode(); |
|
60 |
} |
|
61 |
||
62 |
/** |
|
63 |
* Throw NullPointerException on null mirror. |
|
64 |
* Throw VMMismatchException on wrong VM. |
|
65 |
*/ |
|
66 |
void validateMirror(Mirror mirror) { |
|
67 |
if (!vm.equals(mirror.virtualMachine())) { |
|
68 |
throw new VMMismatchException(mirror.toString()); |
|
69 |
} |
|
70 |
} |
|
71 |
||
72 |
/** |
|
73 |
* Allow null mirror. |
|
74 |
* Throw VMMismatchException on wrong VM. |
|
75 |
*/ |
|
76 |
void validateMirrorOrNull(Mirror mirror) { |
|
77 |
if ((mirror != null) && !vm.equals(mirror.virtualMachine())) { |
|
78 |
throw new VMMismatchException(mirror.toString()); |
|
79 |
} |
|
80 |
} |
|
81 |
||
82 |
/** |
|
83 |
* Throw NullPointerException on null mirrors. |
|
84 |
* Throw VMMismatchException on wrong VM. |
|
85 |
*/ |
|
11277 | 86 |
void validateMirrors(Collection<? extends Mirror> mirrors) { |
87 |
Iterator<? extends Mirror> iter = mirrors.iterator(); |
|
2 | 88 |
while (iter.hasNext()) { |
89 |
MirrorImpl mirror = (MirrorImpl)iter.next(); |
|
90 |
if (!vm.equals(mirror.vm)) { |
|
91 |
throw new VMMismatchException(mirror.toString()); |
|
92 |
} |
|
93 |
} |
|
94 |
} |
|
95 |
/** |
|
96 |
* Allow null mirrors. |
|
97 |
* Throw VMMismatchException on wrong VM. |
|
98 |
*/ |
|
11277 | 99 |
void validateMirrorsOrNulls(Collection<? extends Mirror> mirrors) { |
100 |
Iterator<? extends Mirror> iter = mirrors.iterator(); |
|
2 | 101 |
while (iter.hasNext()) { |
102 |
MirrorImpl mirror = (MirrorImpl)iter.next(); |
|
103 |
if ((mirror != null) && !vm.equals(mirror.vm)) { |
|
104 |
throw new VMMismatchException(mirror.toString()); |
|
105 |
} |
|
106 |
} |
|
107 |
} |
|
108 |
} |