author | ksrini |
Fri, 01 Feb 2013 22:12:52 -0800 | |
changeset 15526 | 84de8685a2d0 |
parent 14774 | 4e298ffae1c7 |
child 22046 | b7163958d6d9 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
15526
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
14774
diff
changeset
|
2 |
* Copyright (c) 2003, 2013, 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.java.util.jar.pack; |
|
27 |
||
7192
445c518364c4
7003227: (pack200) intermittent failures compiling pack200
ksrini
parents:
6322
diff
changeset
|
28 |
import java.io.IOException; |
445c518364c4
7003227: (pack200) intermittent failures compiling pack200
ksrini
parents:
6322
diff
changeset
|
29 |
import java.io.InputStream; |
445c518364c4
7003227: (pack200) intermittent failures compiling pack200
ksrini
parents:
6322
diff
changeset
|
30 |
import java.io.PrintStream; |
445c518364c4
7003227: (pack200) intermittent failures compiling pack200
ksrini
parents:
6322
diff
changeset
|
31 |
import java.io.PrintWriter; |
445c518364c4
7003227: (pack200) intermittent failures compiling pack200
ksrini
parents:
6322
diff
changeset
|
32 |
import java.util.ArrayList; |
445c518364c4
7003227: (pack200) intermittent failures compiling pack200
ksrini
parents:
6322
diff
changeset
|
33 |
import java.util.Collection; |
7795
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
34 |
import java.util.Comparator; |
7192
445c518364c4
7003227: (pack200) intermittent failures compiling pack200
ksrini
parents:
6322
diff
changeset
|
35 |
import java.util.HashMap; |
445c518364c4
7003227: (pack200) intermittent failures compiling pack200
ksrini
parents:
6322
diff
changeset
|
36 |
import java.util.List; |
445c518364c4
7003227: (pack200) intermittent failures compiling pack200
ksrini
parents:
6322
diff
changeset
|
37 |
import java.util.Map; |
445c518364c4
7003227: (pack200) intermittent failures compiling pack200
ksrini
parents:
6322
diff
changeset
|
38 |
import java.util.Properties; |
445c518364c4
7003227: (pack200) intermittent failures compiling pack200
ksrini
parents:
6322
diff
changeset
|
39 |
import java.util.Set; |
445c518364c4
7003227: (pack200) intermittent failures compiling pack200
ksrini
parents:
6322
diff
changeset
|
40 |
import java.util.SortedMap; |
445c518364c4
7003227: (pack200) intermittent failures compiling pack200
ksrini
parents:
6322
diff
changeset
|
41 |
import java.util.TreeMap; |
445c518364c4
7003227: (pack200) intermittent failures compiling pack200
ksrini
parents:
6322
diff
changeset
|
42 |
import java.util.jar.Pack200; |
14774
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
43 |
import java.lang.reflect.Constructor; |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
44 |
import java.lang.reflect.InvocationTargetException; |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
45 |
import java.lang.reflect.Method; |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
46 |
|
2 | 47 |
/** |
48 |
* Control block for publishing Pack200 options to the other classes. |
|
49 |
*/ |
|
7795
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
50 |
|
10115 | 51 |
final class PropMap implements SortedMap<String, String> { |
52 |
private final TreeMap<String, String> theMap = new TreeMap<>();; |
|
2 | 53 |
|
14774
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
54 |
// type is erased, elements are of type java.beans.PropertyChangeListener |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
55 |
private final List<Object> listenerList = new ArrayList<>(1); |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
56 |
|
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
57 |
void addListener(Object listener) { |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
58 |
assert Beans.isPropertyChangeListener(listener); |
7795
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
59 |
listenerList.add(listener); |
2 | 60 |
} |
61 |
||
14774
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
62 |
void removeListener(Object listener) { |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
63 |
assert Beans.isPropertyChangeListener(listener); |
7795
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
64 |
listenerList.remove(listener); |
2 | 65 |
} |
66 |
||
67 |
// Override: |
|
10115 | 68 |
public String put(String key, String value) { |
69 |
String oldValue = theMap.put(key, value); |
|
7795
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
70 |
if (value != oldValue && !listenerList.isEmpty()) { |
14774
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
71 |
assert Beans.isBeansPresent(); |
2 | 72 |
// Post the property change event. |
14774
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
73 |
Object event = Beans.newPropertyChangeEvent(this, key, oldValue, value); |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
74 |
for (Object listener : listenerList) { |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
75 |
Beans.invokePropertyChange(listener, event); |
2 | 76 |
} |
77 |
} |
|
78 |
return oldValue; |
|
79 |
} |
|
80 |
||
81 |
// All this other stuff is private to the current package. |
|
82 |
// Outide clients of Pack200 do not need to use it; they can |
|
83 |
// get by with generic SortedMap functionality. |
|
10115 | 84 |
private static Map<String, String> defaultProps; |
2 | 85 |
static { |
86 |
Properties props = new Properties(); |
|
87 |
||
88 |
// Allow implementation selected via -Dpack.disable.native=true |
|
89 |
props.put(Utils.DEBUG_DISABLE_NATIVE, |
|
90 |
String.valueOf(Boolean.getBoolean(Utils.DEBUG_DISABLE_NATIVE))); |
|
91 |
||
92 |
// Set the DEBUG_VERBOSE from system |
|
93 |
props.put(Utils.DEBUG_VERBOSE, |
|
94 |
String.valueOf(Integer.getInteger(Utils.DEBUG_VERBOSE,0))); |
|
95 |
||
96 |
// Set the PACK_TIMEZONE_NO_UTC |
|
97 |
props.put(Utils.PACK_DEFAULT_TIMEZONE, |
|
98 |
String.valueOf(Boolean.getBoolean(Utils.PACK_DEFAULT_TIMEZONE))); |
|
99 |
||
5799
e0089b2436a4
6575373: Error verifying signatures of pack200 files in some cases
ksrini
parents:
5506
diff
changeset
|
100 |
// The segment size is unlimited |
6322
0a20892f9af6
6969063: (pack200) The default value of Pack200.Packer.SEGMENT_LIMIT property is empty string instead of -1
ksrini
parents:
5799
diff
changeset
|
101 |
props.put(Pack200.Packer.SEGMENT_LIMIT, "-1"); |
2 | 102 |
|
103 |
// Preserve file ordering by default. |
|
104 |
props.put(Pack200.Packer.KEEP_FILE_ORDER, Pack200.Packer.TRUE); |
|
105 |
||
106 |
// Preserve all modification times by default. |
|
107 |
props.put(Pack200.Packer.MODIFICATION_TIME, Pack200.Packer.KEEP); |
|
108 |
||
109 |
// Preserve deflation hints by default. |
|
110 |
props.put(Pack200.Packer.DEFLATE_HINT, Pack200.Packer.KEEP); |
|
111 |
||
112 |
// Pass through files with unrecognized attributes by default. |
|
113 |
props.put(Pack200.Packer.UNKNOWN_ATTRIBUTE, Pack200.Packer.PASS); |
|
114 |
||
15526
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
14774
diff
changeset
|
115 |
// Pass through files with unrecognized format by default, also |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
14774
diff
changeset
|
116 |
// allow system property to be set |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
14774
diff
changeset
|
117 |
props.put(Utils.CLASS_FORMAT_ERROR, |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
14774
diff
changeset
|
118 |
System.getProperty(Utils.CLASS_FORMAT_ERROR, Pack200.Packer.PASS)); |
84de8685a2d0
8003549: (pack200) assertion errors when processing lambda class files with IMethods
ksrini
parents:
14774
diff
changeset
|
119 |
|
2 | 120 |
// Default effort is 5, midway between 1 and 9. |
121 |
props.put(Pack200.Packer.EFFORT, "5"); |
|
122 |
||
123 |
// Define certain attribute layouts by default. |
|
124 |
// Do this after the previous props are put in place, |
|
125 |
// to allow override if necessary. |
|
8803
b3f57bfca459
7022382: convert pack200 library code to use try-with-resources
smarks
parents:
7795
diff
changeset
|
126 |
String propFile = "intrinsic.properties"; |
b3f57bfca459
7022382: convert pack200 library code to use try-with-resources
smarks
parents:
7795
diff
changeset
|
127 |
|
b3f57bfca459
7022382: convert pack200 library code to use try-with-resources
smarks
parents:
7795
diff
changeset
|
128 |
try (InputStream propStr = PackerImpl.class.getResourceAsStream(propFile)) { |
b3f57bfca459
7022382: convert pack200 library code to use try-with-resources
smarks
parents:
7795
diff
changeset
|
129 |
if (propStr == null) { |
b3f57bfca459
7022382: convert pack200 library code to use try-with-resources
smarks
parents:
7795
diff
changeset
|
130 |
throw new RuntimeException(propFile + " cannot be loaded"); |
2 | 131 |
} |
8803
b3f57bfca459
7022382: convert pack200 library code to use try-with-resources
smarks
parents:
7795
diff
changeset
|
132 |
props.load(propStr); |
2 | 133 |
} catch (IOException ee) { |
134 |
throw new RuntimeException(ee); |
|
8803
b3f57bfca459
7022382: convert pack200 library code to use try-with-resources
smarks
parents:
7795
diff
changeset
|
135 |
} |
b3f57bfca459
7022382: convert pack200 library code to use try-with-resources
smarks
parents:
7795
diff
changeset
|
136 |
|
b3f57bfca459
7022382: convert pack200 library code to use try-with-resources
smarks
parents:
7795
diff
changeset
|
137 |
for (Map.Entry<Object, Object> e : props.entrySet()) { |
b3f57bfca459
7022382: convert pack200 library code to use try-with-resources
smarks
parents:
7795
diff
changeset
|
138 |
String key = (String) e.getKey(); |
b3f57bfca459
7022382: convert pack200 library code to use try-with-resources
smarks
parents:
7795
diff
changeset
|
139 |
String val = (String) e.getValue(); |
b3f57bfca459
7022382: convert pack200 library code to use try-with-resources
smarks
parents:
7795
diff
changeset
|
140 |
if (key.startsWith("attribute.")) { |
b3f57bfca459
7022382: convert pack200 library code to use try-with-resources
smarks
parents:
7795
diff
changeset
|
141 |
e.setValue(Attribute.normalizeLayoutString(val)); |
b3f57bfca459
7022382: convert pack200 library code to use try-with-resources
smarks
parents:
7795
diff
changeset
|
142 |
} |
2 | 143 |
} |
144 |
||
10115 | 145 |
@SuppressWarnings({"unchecked", "rawtypes"}) |
146 |
HashMap<String, String> temp = new HashMap(props); // shrink to fit |
|
147 |
defaultProps = temp; |
|
2 | 148 |
} |
149 |
||
150 |
PropMap() { |
|
7795
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
151 |
theMap.putAll(defaultProps); |
2 | 152 |
} |
153 |
||
154 |
// Return a view of this map which includes only properties |
|
155 |
// that begin with the given prefix. This is easy because |
|
156 |
// the map is sorted, and has a subMap accessor. |
|
10115 | 157 |
SortedMap<String, String> prefixMap(String prefix) { |
2 | 158 |
int len = prefix.length(); |
159 |
if (len == 0) |
|
160 |
return this; |
|
161 |
char nextch = (char)(prefix.charAt(len-1) + 1); |
|
162 |
String limit = prefix.substring(0, len-1)+nextch; |
|
163 |
//System.out.println(prefix+" => "+subMap(prefix, limit)); |
|
164 |
return subMap(prefix, limit); |
|
165 |
} |
|
166 |
||
167 |
String getProperty(String s) { |
|
10115 | 168 |
return get(s); |
2 | 169 |
} |
170 |
String getProperty(String s, String defaultVal) { |
|
171 |
String val = getProperty(s); |
|
172 |
if (val == null) |
|
173 |
return defaultVal; |
|
174 |
return val; |
|
175 |
} |
|
176 |
String setProperty(String s, String val) { |
|
10115 | 177 |
return put(s, val); |
2 | 178 |
} |
179 |
||
180 |
// Get sequence of props for "prefix", and "prefix.*". |
|
10115 | 181 |
List<String> getProperties(String prefix) { |
182 |
Collection<String> values = prefixMap(prefix).values(); |
|
183 |
List<String> res = new ArrayList<>(values.size()); |
|
2 | 184 |
res.addAll(values); |
185 |
while (res.remove(null)); |
|
186 |
return res; |
|
187 |
} |
|
188 |
||
189 |
private boolean toBoolean(String val) { |
|
190 |
return Boolean.valueOf(val).booleanValue(); |
|
191 |
} |
|
192 |
boolean getBoolean(String s) { |
|
193 |
return toBoolean(getProperty(s)); |
|
194 |
} |
|
195 |
boolean setBoolean(String s, boolean val) { |
|
196 |
return toBoolean(setProperty(s, String.valueOf(val))); |
|
197 |
} |
|
198 |
int toInteger(String val) { |
|
12857
0a5f341c2a28
7168401: pack200 does not produce a compatible pack file for JDK7 classes if indy is not present
ksrini
parents:
10115
diff
changeset
|
199 |
return toInteger(val, 0); |
0a5f341c2a28
7168401: pack200 does not produce a compatible pack file for JDK7 classes if indy is not present
ksrini
parents:
10115
diff
changeset
|
200 |
} |
0a5f341c2a28
7168401: pack200 does not produce a compatible pack file for JDK7 classes if indy is not present
ksrini
parents:
10115
diff
changeset
|
201 |
int toInteger(String val, int def) { |
0a5f341c2a28
7168401: pack200 does not produce a compatible pack file for JDK7 classes if indy is not present
ksrini
parents:
10115
diff
changeset
|
202 |
if (val == null) return def; |
2 | 203 |
if (Pack200.Packer.TRUE.equals(val)) return 1; |
204 |
if (Pack200.Packer.FALSE.equals(val)) return 0; |
|
205 |
return Integer.parseInt(val); |
|
206 |
} |
|
12857
0a5f341c2a28
7168401: pack200 does not produce a compatible pack file for JDK7 classes if indy is not present
ksrini
parents:
10115
diff
changeset
|
207 |
int getInteger(String s, int def) { |
0a5f341c2a28
7168401: pack200 does not produce a compatible pack file for JDK7 classes if indy is not present
ksrini
parents:
10115
diff
changeset
|
208 |
return toInteger(getProperty(s), def); |
0a5f341c2a28
7168401: pack200 does not produce a compatible pack file for JDK7 classes if indy is not present
ksrini
parents:
10115
diff
changeset
|
209 |
} |
2 | 210 |
int getInteger(String s) { |
211 |
return toInteger(getProperty(s)); |
|
212 |
} |
|
213 |
int setInteger(String s, int val) { |
|
214 |
return toInteger(setProperty(s, String.valueOf(val))); |
|
215 |
} |
|
216 |
||
217 |
long toLong(String val) { |
|
218 |
try { |
|
219 |
return val == null ? 0 : Long.parseLong(val); |
|
220 |
} catch (java.lang.NumberFormatException nfe) { |
|
221 |
throw new IllegalArgumentException("Invalid value"); |
|
222 |
} |
|
223 |
} |
|
224 |
long getLong(String s) { |
|
225 |
return toLong(getProperty(s)); |
|
226 |
} |
|
227 |
long setLong(String s, long val) { |
|
228 |
return toLong(setProperty(s, String.valueOf(val))); |
|
229 |
} |
|
230 |
||
231 |
int getTime(String s) { |
|
232 |
String sval = getProperty(s, "0"); |
|
233 |
if (Utils.NOW.equals(sval)) { |
|
234 |
return (int)((System.currentTimeMillis()+500)/1000); |
|
235 |
} |
|
236 |
long lval = toLong(sval); |
|
237 |
final long recentSecondCount = 1000000000; |
|
238 |
||
239 |
if (lval < recentSecondCount*10 && !"0".equals(sval)) |
|
240 |
Utils.log.warning("Supplied modtime appears to be seconds rather than milliseconds: "+sval); |
|
241 |
||
242 |
return (int)((lval+500)/1000); |
|
243 |
} |
|
244 |
||
245 |
void list(PrintStream out) { |
|
246 |
PrintWriter outw = new PrintWriter(out); |
|
247 |
list(outw); |
|
248 |
outw.flush(); |
|
249 |
} |
|
250 |
void list(PrintWriter out) { |
|
251 |
out.println("#"+Utils.PACK_ZIP_ARCHIVE_MARKER_COMMENT+"["); |
|
10115 | 252 |
Set<Map.Entry<String, String>> defaults = defaultProps.entrySet(); |
253 |
for (Map.Entry<String, String> e : theMap.entrySet()) { |
|
2 | 254 |
if (defaults.contains(e)) continue; |
255 |
out.println(" " + e.getKey() + " = " + e.getValue()); |
|
256 |
} |
|
257 |
out.println("#]"); |
|
258 |
} |
|
7795
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
259 |
|
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
260 |
@Override |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
261 |
public int size() { |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
262 |
return theMap.size(); |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
263 |
} |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
264 |
|
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
265 |
@Override |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
266 |
public boolean isEmpty() { |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
267 |
return theMap.isEmpty(); |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
268 |
} |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
269 |
|
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
270 |
@Override |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
271 |
public boolean containsKey(Object key) { |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
272 |
return theMap.containsKey(key); |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
273 |
} |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
274 |
|
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
275 |
@Override |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
276 |
public boolean containsValue(Object value) { |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
277 |
return theMap.containsValue(value); |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
278 |
} |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
279 |
|
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
280 |
@Override |
10115 | 281 |
public String get(Object key) { |
7795
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
282 |
return theMap.get(key); |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
283 |
} |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
284 |
|
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
285 |
@Override |
10115 | 286 |
public String remove(Object key) { |
7795
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
287 |
return theMap.remove(key); |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
288 |
} |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
289 |
|
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
290 |
@Override |
10115 | 291 |
public void putAll(Map<? extends String, ? extends String> m) { |
7795
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
292 |
theMap.putAll(m); |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
293 |
} |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
294 |
|
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
295 |
@Override |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
296 |
public void clear() { |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
297 |
theMap.clear(); |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
298 |
} |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
299 |
|
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
300 |
@Override |
10115 | 301 |
public Set<String> keySet() { |
7795
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
302 |
return theMap.keySet(); |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
303 |
} |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
304 |
|
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
305 |
@Override |
10115 | 306 |
public Collection<String> values() { |
7795
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
307 |
return theMap.values(); |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
308 |
} |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
309 |
|
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
310 |
@Override |
10115 | 311 |
public Set<Map.Entry<String, String>> entrySet() { |
7795
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
312 |
return theMap.entrySet(); |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
313 |
} |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
314 |
|
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
315 |
@Override |
10115 | 316 |
public Comparator<? super String> comparator() { |
317 |
return theMap.comparator(); |
|
7795
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
318 |
} |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
319 |
|
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
320 |
@Override |
10115 | 321 |
public SortedMap<String, String> subMap(String fromKey, String toKey) { |
7795
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
322 |
return theMap.subMap(fromKey, toKey); |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
323 |
} |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
324 |
|
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
325 |
@Override |
10115 | 326 |
public SortedMap<String, String> headMap(String toKey) { |
7795
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
327 |
return theMap.headMap(toKey); |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
328 |
} |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
329 |
|
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
330 |
@Override |
10115 | 331 |
public SortedMap<String, String> tailMap(String fromKey) { |
7795
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
332 |
return theMap.tailMap(fromKey); |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
333 |
} |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
334 |
|
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
335 |
@Override |
10115 | 336 |
public String firstKey() { |
7795
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
337 |
return theMap.firstKey(); |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
338 |
} |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
339 |
|
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
340 |
@Override |
10115 | 341 |
public String lastKey() { |
7795
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
342 |
return theMap.lastKey(); |
98021fc612af
6990106: FindBugs scan - Malicious code vulnerability Warnings in com.sun.java.util.jar.pack.*
ksrini
parents:
7192
diff
changeset
|
343 |
} |
14774
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
344 |
|
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
345 |
/** |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
346 |
* A class that provides access to the java.beans.PropertyChangeListener |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
347 |
* and java.beans.PropertyChangeEvent without creating a static dependency |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
348 |
* on java.beans. This class can be removed once the addPropertyChangeListener |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
349 |
* and removePropertyChangeListener methods are removed from Packer and |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
350 |
* Unpacker. |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
351 |
*/ |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
352 |
private static class Beans { |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
353 |
private static final Class<?> propertyChangeListenerClass = |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
354 |
getClass("java.beans.PropertyChangeListener"); |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
355 |
|
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
356 |
private static final Class<?> propertyChangeEventClass = |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
357 |
getClass("java.beans.PropertyChangeEvent"); |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
358 |
|
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
359 |
private static final Method propertyChangeMethod = |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
360 |
getMethod(propertyChangeListenerClass, |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
361 |
"propertyChange", |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
362 |
propertyChangeEventClass); |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
363 |
|
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
364 |
private static final Constructor<?> propertyEventCtor = |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
365 |
getConstructor(propertyChangeEventClass, |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
366 |
Object.class, |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
367 |
String.class, |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
368 |
Object.class, |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
369 |
Object.class); |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
370 |
|
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
371 |
private static Class<?> getClass(String name) { |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
372 |
try { |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
373 |
return Class.forName(name, true, Beans.class.getClassLoader()); |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
374 |
} catch (ClassNotFoundException e) { |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
375 |
return null; |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
376 |
} |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
377 |
} |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
378 |
private static Constructor<?> getConstructor(Class<?> c, Class<?>... types) { |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
379 |
try { |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
380 |
return (c == null) ? null : c.getDeclaredConstructor(types); |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
381 |
} catch (NoSuchMethodException x) { |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
382 |
throw new AssertionError(x); |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
383 |
} |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
384 |
} |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
385 |
|
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
386 |
private static Method getMethod(Class<?> c, String name, Class<?>... types) { |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
387 |
try { |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
388 |
return (c == null) ? null : c.getMethod(name, types); |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
389 |
} catch (NoSuchMethodException e) { |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
390 |
throw new AssertionError(e); |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
391 |
} |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
392 |
} |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
393 |
|
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
394 |
/** |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
395 |
* Returns {@code true} if java.beans is present. |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
396 |
*/ |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
397 |
static boolean isBeansPresent() { |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
398 |
return propertyChangeListenerClass != null && |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
399 |
propertyChangeEventClass != null; |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
400 |
} |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
401 |
|
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
402 |
/** |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
403 |
* Returns {@code true} if the given object is a PropertyChangeListener |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
404 |
*/ |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
405 |
static boolean isPropertyChangeListener(Object obj) { |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
406 |
if (propertyChangeListenerClass == null) { |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
407 |
return false; |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
408 |
} else { |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
409 |
return propertyChangeListenerClass.isInstance(obj); |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
410 |
} |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
411 |
} |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
412 |
|
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
413 |
/** |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
414 |
* Returns a new PropertyChangeEvent with the given source, property |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
415 |
* name, old and new values. |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
416 |
*/ |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
417 |
static Object newPropertyChangeEvent(Object source, String prop, |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
418 |
Object oldValue, Object newValue) |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
419 |
{ |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
420 |
try { |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
421 |
return propertyEventCtor.newInstance(source, prop, oldValue, newValue); |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
422 |
} catch (InstantiationException | IllegalAccessException x) { |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
423 |
throw new AssertionError(x); |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
424 |
} catch (InvocationTargetException x) { |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
425 |
Throwable cause = x.getCause(); |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
426 |
if (cause instanceof Error) |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
427 |
throw (Error)cause; |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
428 |
if (cause instanceof RuntimeException) |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
429 |
throw (RuntimeException)cause; |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
430 |
throw new AssertionError(x); |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
431 |
} |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
432 |
} |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
433 |
|
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
434 |
/** |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
435 |
* Invokes the given PropertyChangeListener's propertyChange method |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
436 |
* with the given event. |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
437 |
*/ |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
438 |
static void invokePropertyChange(Object listener, Object ev) { |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
439 |
try { |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
440 |
propertyChangeMethod.invoke(listener, ev); |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
441 |
} catch (IllegalAccessException x) { |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
442 |
throw new AssertionError(x); |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
443 |
} catch (InvocationTargetException x) { |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
444 |
Throwable cause = x.getCause(); |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
445 |
if (cause instanceof Error) |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
446 |
throw (Error)cause; |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
447 |
if (cause instanceof RuntimeException) |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
448 |
throw (RuntimeException)cause; |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
449 |
throw new AssertionError(x); |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
450 |
} |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
451 |
} |
4e298ffae1c7
8004874: Reduce dependency on java.beans to only add/removePropertyChangeListener
alanb
parents:
12857
diff
changeset
|
452 |
} |
2 | 453 |
} |