MCPcopy Create free account
hub / github.com/ReadyTalk/avian / field

Method field

classpath/java/io/ObjectOutputStream.java:231–269  ·  view source on GitHub ↗
(Object o, Field field)

Source from the content-addressed store, hash-verified

229 }
230
231 private void field(Object o, Field field) throws IOException {
232 try {
233 field.setAccessible(true);
234 Class type = field.getType();
235 if (!type.isPrimitive()) {
236 writeObject(field.get(o));
237 } else if (type == Byte.TYPE) {
238 rawByte(field.getByte(o));
239 } else if (type == Character.TYPE) {
240 char c = field.getChar(o);
241 rawShort((short)c);
242 } else if (type == Double.TYPE) {
243 double d = field.getDouble(o);
244 rawLong(Double.doubleToLongBits(d));
245 } else if (type == Float.TYPE) {
246 float f = field.getFloat(o);
247 rawInt(Float.floatToIntBits(f));
248 } else if (type == Integer.TYPE) {
249 int i = field.getInt(o);
250 rawInt(i);
251 } else if (type == Long.TYPE) {
252 long l = field.getLong(o);
253 rawLong(l);
254 } else if (type == Short.TYPE) {
255 short s = field.getShort(o);
256 rawShort(s);
257 } else if (type == Boolean.TYPE) {
258 boolean b = field.getBoolean(o);
259 rawByte(b ? 1 : 0);
260 } else {
261 throw new UnsupportedOperationException("Field '" + field.getName()
262 + "' has unsupported type: " + type);
263 }
264 } catch (IOException e) {
265 throw e;
266 } catch (Exception e) {
267 throw new IOException(e);
268 }
269 }
270
271 private static Field[] getFields(Class clazz) {
272 ArrayList<Field> list = new ArrayList<Field>();

Callers 1

defaultWriteObjectMethod · 0.95

Calls 15

isPrimitiveMethod · 0.95
writeObjectMethod · 0.95
rawByteMethod · 0.95
rawShortMethod · 0.95
rawLongMethod · 0.95
doubleToLongBitsMethod · 0.95
rawIntMethod · 0.95
floatToIntBitsMethod · 0.95
getTypeMethod · 0.80
getMethod · 0.65
getNameMethod · 0.65
setAccessibleMethod · 0.45

Tested by

no test coverage detected