()
| 360 | } |
| 361 | |
| 362 | private ClassDesc classDesc() throws ClassNotFoundException, IOException { |
| 363 | ClassDesc result = new ClassDesc(); |
| 364 | String className = rawString(); |
| 365 | ClassLoader loader = Thread.currentThread().getContextClassLoader(); |
| 366 | result.clazz = loader.loadClass(className); |
| 367 | long serialVersionUID = rawLong(); |
| 368 | try { |
| 369 | Field field = result.clazz.getField("serialVersionUID"); |
| 370 | long expected = field.getLong(null); |
| 371 | if (expected != serialVersionUID) { |
| 372 | throw new IOException("Incompatible serial version UID: 0x" |
| 373 | + Long.toHexString(serialVersionUID) + " != 0x" |
| 374 | + Long.toHexString(expected)); |
| 375 | } |
| 376 | } catch (Exception ignored) { } |
| 377 | references.add(result); |
| 378 | |
| 379 | result.flags = rawByte(); |
| 380 | if ((result.flags & ~(SC_SERIALIZABLE | SC_WRITE_METHOD)) != 0) { |
| 381 | throw new UnsupportedOperationException("Cannot handle flags: 0x" |
| 382 | + Integer.toHexString(result.flags)); |
| 383 | } |
| 384 | |
| 385 | int fieldCount = rawShort(); |
| 386 | result.fields = new Field[fieldCount]; |
| 387 | for (int i = 0; i < result.fields.length; i++) { |
| 388 | int typeChar = rawByte(); |
| 389 | String fieldName = rawString(); |
| 390 | try { |
| 391 | result.fields[i] = result.clazz.getDeclaredField(fieldName); |
| 392 | } catch (Exception e) { |
| 393 | throw new IOException(e); |
| 394 | } |
| 395 | Class type; |
| 396 | if (typeChar == '[' || typeChar == 'L') { |
| 397 | String typeName = (String)readObject(); |
| 398 | if (typeName.startsWith("L") && typeName.endsWith(";")) { |
| 399 | typeName = typeName.substring(1, typeName.length() - 1) |
| 400 | .replace('/', '.'); |
| 401 | } |
| 402 | type = loader.loadClass(typeName); |
| 403 | } else { |
| 404 | type = charToPrimitiveType(typeChar); |
| 405 | } |
| 406 | if (result.fields[i].getType() != type) { |
| 407 | throw new IOException("Unexpected type of field " + fieldName |
| 408 | + ": expected " + result.fields[i].getType() + " but got " + type); |
| 409 | } |
| 410 | } |
| 411 | expectToken(TC_ENDBLOCKDATA); |
| 412 | int c = rawByte(); |
| 413 | if (c == TC_CLASSDESC) { |
| 414 | result.superClassDesc = classDesc(); |
| 415 | } else if (c != TC_NULL) { |
| 416 | throw new UnsupportedOperationException("Unexpected token: 0x" |
| 417 | + Integer.toHexString(c)); |
| 418 | } |
| 419 |
no test coverage detected