Lines 17-24
Link Here
|
17 |
import java.io.FileInputStream; |
17 |
import java.io.FileInputStream; |
18 |
import java.io.FileOutputStream; |
18 |
import java.io.FileOutputStream; |
19 |
import java.io.IOException; |
19 |
import java.io.IOException; |
|
|
20 |
import java.io.InvalidClassException; |
20 |
import java.io.ObjectInputStream; |
21 |
import java.io.ObjectInputStream; |
21 |
import java.io.ObjectOutputStream; |
22 |
import java.io.ObjectOutputStream; |
|
|
23 |
import java.io.ObjectStreamClass; |
22 |
import java.util.ArrayList; |
24 |
import java.util.ArrayList; |
23 |
import java.util.Arrays; |
25 |
import java.util.Arrays; |
24 |
import java.util.Collection; |
26 |
import java.util.Collection; |
Lines 102-108
Link Here
|
102 |
File indexFile = new File(prefix + "index"); //$NON-NLS-1$ |
104 |
File indexFile = new File(prefix + "index"); //$NON-NLS-1$ |
103 |
fis = new FileInputStream(indexFile); |
105 |
fis = new FileInputStream(indexFile); |
104 |
listener.worked(1); |
106 |
listener.worked(1); |
105 |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(fis)); |
107 |
/** |
|
|
108 |
* Classes deserialized: |
109 |
* org.eclipse.mat.parser.model.XSnapshotInfo |
110 |
* org.eclipse.mat.parser.model.AbstractObjectImpl |
111 |
* org.eclipse.mat.parser.model.XGCRootInfo |
112 |
* org.eclipse.mat.parser.model.ClassImpl |
113 |
* [Lorg.eclipse.mat.parser.model.XGCRootInfo |
114 |
* org.eclipse.mat.parser.model.XGCRootInfo |
115 |
* |
116 |
* org.eclipse.mat.snapshot.SnapshotInfo |
117 |
* org.eclipse.mat.snapshot.UnreachableObjectsHistogram |
118 |
* |
119 |
* org.eclipse.mat.snapshot.model.GCRootInfo |
120 |
* org.eclipse.mat.snapshot.model.FieldDescriptor |
121 |
* org.eclipse.mat.snapshot.model.Field |
122 |
* [Lorg.eclipse.mat.snapshot.model.FieldDescriptor |
123 |
* [Lorg.eclipse.mat.snapshot.model.Field |
124 |
* org.eclipse.mat.snapshot.model.ObjectReference |
125 |
* |
126 |
* org.eclipse.mat.collect.HashMapIntObject |
127 |
* org.eclipse.mat.collect.BitField |
128 |
* |
129 |
* java.util.ArrayList: |
130 |
* java.util.Date |
131 |
* java.util.HashMap |
132 |
* |
133 |
* java.lang.Boolean |
134 |
* java.lang.Long |
135 |
* java.lang.Number |
136 |
* java.lang.Byte |
137 |
* java.lang.Short |
138 |
* java.lang.Character |
139 |
* java.lang.Double |
140 |
* java.lang.Float |
141 |
* [I |
142 |
* |
143 |
*/ |
144 |
ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(fis)) { |
145 |
@Override |
146 |
protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { |
147 |
// similar to system property jdk.serialFilter |
148 |
String match="java.lang.*;java.util.*;org.eclipse.mat.parser.model.*;org.eclipse.mat.snapshot.*;org.eclipse.mat.snapshot.model.*;org.eclipse.mat.collect.*;!*"; //$NON-NLS-1$ |
149 |
String nm = desc.getName(); |
150 |
if (!nm.startsWith("[")) //$NON-NLS-1$ |
151 |
{ |
152 |
for (String pt : match.split(";")) //$NON-NLS-1$ |
153 |
{ |
154 |
boolean not = pt.startsWith("!"); //$NON-NLS-1$ |
155 |
if (not) |
156 |
pt = pt.substring(1); |
157 |
boolean m; |
158 |
if (pt.endsWith(".**")) //$NON-NLS-1$ |
159 |
m = nm.startsWith(pt.substring(0, pt.length() - 2)); |
160 |
else if (pt.endsWith(".*")) //$NON-NLS-1$ |
161 |
m = nm.startsWith(pt.substring(0, pt.length() - 1)) |
162 |
&& !nm.substring(pt.length() - 1).contains("."); //$NON-NLS-1$ |
163 |
else if (pt.endsWith("*")) //$NON-NLS-1$ |
164 |
m = nm.startsWith(pt.substring(0, pt.length() - 1)); |
165 |
else |
166 |
m = nm.equals(pt); |
167 |
if (not && m) |
168 |
throw new InvalidClassException(nm, match); |
169 |
if (m) |
170 |
break; |
171 |
} |
172 |
} |
173 |
return super.resolveClass(desc); |
174 |
} |
175 |
}; |
106 |
|
176 |
|
107 |
String version = in.readUTF(); |
177 |
String version = in.readUTF(); |
108 |
if (!VERSION.equals(version)) |
178 |
if (!VERSION.equals(version)) |
Lines 155-166
Link Here
|
155 |
} |
225 |
} |
156 |
|
226 |
|
157 |
IndexManager indexManager = new IndexManager(); |
227 |
IndexManager indexManager = new IndexManager(); |
158 |
indexManager.init(prefix); |
228 |
boolean done = false; |
|
|
229 |
try |
230 |
{ |
231 |
indexManager.init(prefix); |
159 |
|
232 |
|
160 |
SnapshotImpl ret = new SnapshotImpl(snapshotInfo, heapObjectReader, classCache, roots, rootsPerThread, loaderLabels, |
233 |
SnapshotImpl ret = new SnapshotImpl(snapshotInfo, heapObjectReader, classCache, roots, rootsPerThread, loaderLabels, |
161 |
arrayObjects, indexManager); |
234 |
arrayObjects, indexManager); |
162 |
listener.worked(3); |
235 |
listener.worked(3); |
163 |
return ret; |
236 |
done = true; |
|
|
237 |
|
238 |
return ret; |
239 |
} |
240 |
finally |
241 |
{ |
242 |
if (!done) |
243 |
{ |
244 |
// Close files on error to allow delete |
245 |
indexManager.close(); |
246 |
} |
247 |
} |
164 |
} |
248 |
} |
165 |
catch (ClassNotFoundException e) |
249 |
catch (ClassNotFoundException e) |
166 |
{ |
250 |
{ |