(Class clazz, int scFlags)
| 194 | } |
| 195 | |
| 196 | private void classDesc(Class clazz, int scFlags) throws IOException { |
| 197 | rawByte(TC_CLASSDESC); |
| 198 | |
| 199 | // class name |
| 200 | string(clazz.getName()); |
| 201 | |
| 202 | // serial version UID |
| 203 | long serialVersionUID = 1l; |
| 204 | try { |
| 205 | Field field = clazz.getField("serialVersionUID"); |
| 206 | serialVersionUID = field.getLong(null); |
| 207 | } catch (Exception ignored) {} |
| 208 | rawLong(serialVersionUID); |
| 209 | |
| 210 | // handle |
| 211 | rawByte(SC_SERIALIZABLE | scFlags); |
| 212 | |
| 213 | Field[] fields = getFields(clazz); |
| 214 | rawShort(fields.length); |
| 215 | for (Field field : fields) { |
| 216 | Class fieldType = field.getType(); |
| 217 | if (fieldType.isPrimitive()) { |
| 218 | rawByte(primitiveTypeChar(fieldType)); |
| 219 | string(field.getName()); |
| 220 | } else { |
| 221 | rawByte(fieldType.isArray() ? '[' : 'L'); |
| 222 | string(field.getName()); |
| 223 | rawByte(TC_STRING); |
| 224 | string("L" + fieldType.getName().replace('.', '/') + ";"); |
| 225 | } |
| 226 | } |
| 227 | rawByte(TC_ENDBLOCKDATA); // TODO: write annotation |
| 228 | rawByte(TC_NULL); // super class desc |
| 229 | } |
| 230 | |
| 231 | private void field(Object o, Field field) throws IOException { |
| 232 | try { |
no test coverage detected