Comments from r723.

This commit is contained in:
Joel Leitch 2011-02-14 22:26:17 +00:00
parent 69661216a3
commit 4c41b11fce

View File

@ -40,20 +40,7 @@ import java.util.logging.Logger;
*/
final class MappedObjectConstructor implements ObjectConstructor {
private static final Logger log = Logger.getLogger(MappedObjectConstructor.class.getName());
private static final Unsafe THE_UNSAFE = AccessController.doPrivileged(
new PrivilegedAction<Unsafe>() {
public Unsafe run() {
try {
Field f = Unsafe.class.getDeclaredField("theUnsafe");
f.setAccessible(true);
return (Unsafe) f.get(null);
} catch (NoSuchFieldException e) {
throw new Error();
} catch (IllegalAccessException e) {
throw new Error();
}
}
});
private static final Unsafe THE_UNSAFE = getUnsafe();
private final ParameterizedTypeHandlerMap<InstanceCreator<?>> instanceCreatorMap;
@ -70,6 +57,18 @@ final class MappedObjectConstructor implements ObjectConstructor {
}
return (T) constructWithNoArgConstructor(typeOfT);
}
private static Unsafe getUnsafe() {
try {
Field f = Unsafe.class.getDeclaredField("theUnsafe");
f.setAccessible(true);
return (Unsafe) f.get(null);
} catch (NoSuchFieldException e) {
throw new Error();
} catch (IllegalAccessException e) {
throw new Error();
}
}
public Object constructArray(Type type, int length) {
return Array.newInstance(Types.getRawType(type), length);