private JType resolveType(final JType type) {
    JType ret = type;
    JParameterizedType pt = type.isParameterized();

    if (pt != null) {
      ret = pt.getRawType();
    }

    JTypeParameter tp = ret.isTypeParameter();

    if (tp != null) {
      ret = tp.getBaseType();
    }

    return ret;
  }
  /*
   * Create a field serializer for a type if it does not have a custom
   * serializer.
   */
  private void createFieldSerializer(TreeLogger logger, GeneratorContextExt ctx, JType type) {
    Event event = SpeedTracerLogger.start(CompilerEventType.GENERATOR_RPC_FIELD_SERIALIZER);
    try {
      assert (type != null);
      assert (serializationOracle.isSerializable(type)
          || deserializationOracle.isSerializable(type));

      JParameterizedType parameterizedType = type.isParameterized();
      if (parameterizedType != null) {
        createFieldSerializer(logger, ctx, parameterizedType.getRawType());
        return;
      }

      /*
       * Only a JClassType can reach this point in the code. JPrimitives have been
       * removed because their serialization is built in, interfaces have been
       * removed because they are not an instantiable type and parameterized types
       * have been broken down into their raw types.
       */
      assert (type.isClass() != null || type.isArray() != null);

      if (findCacheableFieldSerializerAndMarkForReuseIfAvailable(ctx, type)) {
        // skip generation of field serializer
        return;
      }

      JClassType customFieldSerializer =
          SerializableTypeOracleBuilder.findCustomFieldSerializer(typeOracle, type);
      FieldSerializerCreator creator =
          new FieldSerializerCreator(
              context,
              serializationOracle,
              deserializationOracle,
              (JClassType) type,
              customFieldSerializer);
      creator.realize(logger, ctx);
    } finally {
      event.end();
    }
  }
Example #3
0
 @Override
 public MetaType getRawType() {
   return GWTClass.newInstance(oracle, parameterizedType.getRawType());
 }