1153 checkRtype(returnType);
1154 checkPtypes(parameterArray);
1155
1156 parameterArray = parameterArray.clone(); // make sure it is unshared
1157 MethodType_init(returnType, parameterArray);
1158 }
1159
1160 /**
1161 * For serialization only.
1162 * Sets the final fields to null, pending {@code Unsafe.putObject}.
1163 */
1164 private MethodType() {
1165 this.rtype = null;
1166 this.ptypes = null;
1167 }
1168 private void MethodType_init(Class<?> rtype, Class<?>[] ptypes) {
1169 // In order to communicate these values to readResolve, we must
1170 // store them into the implementation-specific final fields.
1171 checkRtype(rtype);
1172 checkPtypes(ptypes);
1173 UNSAFE.putObject(this, rtypeOffset, rtype);
1174 UNSAFE.putObject(this, ptypesOffset, ptypes);
1175 }
1176
1177 // Support for resetting final fields while deserializing
1178 private static final long rtypeOffset, ptypesOffset;
1179 static {
1180 try {
1181 rtypeOffset = UNSAFE.objectFieldOffset
1182 (MethodType.class.getDeclaredField("rtype"));
1183 ptypesOffset = UNSAFE.objectFieldOffset
1184 (MethodType.class.getDeclaredField("ptypes"));
1185 } catch (Exception ex) {
1186 throw new Error(ex);
1187 }
1188 }
1189
1190 /**
1191 * Resolves and initializes a {@code MethodType} object
1192 * after serialization.
1193 * @return the fully initialized {@code MethodType} object
1194 */
1195 private Object readResolve() {
1196 // Do not use a trusted path for deserialization:
1197 //return makeImpl(rtype, ptypes, true);
1198 // Verify all operands, and make sure ptypes is unshared:
1199 return methodType(rtype, ptypes);
1200 }
1201
1202 /**
1203 * Simple implementation of weak concurrent intern set.
1204 *
1205 * @param <T> interned type
1206 */
|
1153 checkRtype(returnType);
1154 checkPtypes(parameterArray);
1155
1156 parameterArray = parameterArray.clone(); // make sure it is unshared
1157 MethodType_init(returnType, parameterArray);
1158 }
1159
1160 /**
1161 * For serialization only.
1162 * Sets the final fields to null, pending {@code Unsafe.putObject}.
1163 */
1164 private MethodType() {
1165 this.rtype = null;
1166 this.ptypes = null;
1167 }
1168 private void MethodType_init(Class<?> rtype, Class<?>[] ptypes) {
1169 // In order to communicate these values to readResolve, we must
1170 // store them into the implementation-specific final fields.
1171 checkRtype(rtype);
1172 checkPtypes(ptypes);
1173 UNSAFE.putObject(this, OffsetHolder.rtypeOffset, rtype);
1174 UNSAFE.putObject(this, OffsetHolder.ptypesOffset, ptypes);
1175 }
1176
1177 // Support for resetting final fields while deserializing. Implement Holder
1178 // pattern to make the rarely needed offset calculation lazy.
1179 private static class OffsetHolder {
1180 private static final long rtypeOffset, ptypesOffset;
1181 static {
1182 try {
1183 rtypeOffset = UNSAFE.objectFieldOffset
1184 (MethodType.class.getDeclaredField("rtype"));
1185 ptypesOffset = UNSAFE.objectFieldOffset
1186 (MethodType.class.getDeclaredField("ptypes"));
1187 } catch (Exception ex) {
1188 throw new Error(ex);
1189 }
1190 }
1191 }
1192
1193 /**
1194 * Resolves and initializes a {@code MethodType} object
1195 * after serialization.
1196 * @return the fully initialized {@code MethodType} object
1197 */
1198 private Object readResolve() {
1199 // Do not use a trusted path for deserialization:
1200 //return makeImpl(rtype, ptypes, true);
1201 // Verify all operands, and make sure ptypes is unshared:
1202 return methodType(rtype, ptypes);
1203 }
1204
1205 /**
1206 * Simple implementation of weak concurrent intern set.
1207 *
1208 * @param <T> interned type
1209 */
|