code: private synchronized void addToMap(Class clazz, byte id) {
      if (classToIdMap.containsKey(clazz)) {
        byte b = classToIdMap.get(clazz);
        if (b != id) {
          throw new IllegalArgumentException ("Class " + clazz.getName() +
            " already registered but maps to " + b + " and not " + id);
        }
      }
      if (idToClassMap.containsKey(id)) {
        Class c = idToClassMap.get(id);
        if (!c.equals(clazz)) {
          throw new IllegalArgumentException("Id " + id + " exists but maps to " +
              c.getName() + " and not " + clazz.getName());
        }
      }
      classToIdMap.put(clazz, id);
      idToClassMap.put(id, clazz);
    }
docs: Used to add "predefined" classes and by Writable to copy "new" classes.