170 |
* Returns a new reference type id for the given class |
* Returns a new reference type id for the given class |
171 |
* |
* |
172 |
* @param clazz the <code>Class</code> for which an id is desired |
* @param clazz the <code>Class</code> for which an id is desired |
173 |
* @returns a suitable reference type id or <code>null</code> |
* @returns a suitable reference type id or null when the |
174 |
|
* reference is cleared. |
175 |
*/ |
*/ |
176 |
public static ReferenceTypeId newReferenceTypeId (SoftReference ref) |
public static ReferenceTypeId newReferenceTypeId (SoftReference ref) |
177 |
{ |
{ |
178 |
ReferenceTypeId id = null; |
ReferenceTypeId id; |
179 |
Class clazz = (Class) ref.get (); |
Class clazz = (Class) ref.get (); |
180 |
|
if (clazz == null) |
181 |
|
return null; |
182 |
|
|
183 |
try |
if (clazz.isArray ()) |
184 |
|
id = new ArrayReferenceTypeId (); |
185 |
|
else if (clazz.isInterface ()) |
186 |
|
id = new InterfaceReferenceTypeId (); |
187 |
|
else |
188 |
|
id = new ClassReferenceTypeId (); |
189 |
|
synchronized (_ridLock) |
190 |
{ |
{ |
191 |
if (clazz.isArray ()) |
id.setId (++_lastRid); |
|
id = new ArrayReferenceTypeId (); |
|
|
else if (clazz.isInterface ()) |
|
|
id = new InterfaceReferenceTypeId (); |
|
|
else |
|
|
id = new ClassReferenceTypeId (); |
|
|
synchronized (_ridLock) |
|
|
{ |
|
|
id.setId (++_lastRid); |
|
|
} |
|
|
return id; |
|
|
} |
|
|
catch (InstantiationException ie) |
|
|
{ |
|
|
return null; |
|
|
} |
|
|
catch (IllegalAccessException iae) |
|
|
{ |
|
|
return null; |
|
192 |
} |
} |
193 |
|
return id; |
194 |
} |
} |
195 |
} |
} |
196 |
|
|