Package com.google.gwt.dev.javac.typemodel

Examples of com.google.gwt.dev.javac.typemodel.JRealClassType


  private JRealClassType createUnresolvedClass(Class<?> clazz,
      JRealClassType enclosingType) {
    String pkgName = clazz.getPackage().getName();
    JPackage pkg = oracle.getOrCreatePackage(pkgName);
    TypeVariable<?>[] typeParams = clazz.getTypeParameters();
    JRealClassType type;
    int n = typeParams.length;
    String enclosingTypeName = null;
    if (enclosingType != null) {
      enclosingTypeName = enclosingType.getName();
    }
View Full Code Here


  @Override
  public void visitClassType(String internalName) {
    assert Name.isInternalName(internalName);
    outerClass = enclosingClass;
    JRealClassType classType = resolver.findByInternalName(internalName);
    if (classType == null) {
      logger.log(TreeLogger.ERROR, "Unable to find class " + internalName);
      // Replace bound with Object if we can't find the class.
      returnTypeRef[0] = resolver.getTypeOracle().getJavaLangObject();
      return;
View Full Code Here

      }
      if (typesByInternalName.containsKey(classData.getInternalName())) {
        // skip classes that have been previously added
        continue;
      }
      JRealClassType type = createType(typeData, unresolvedTypes, context);
      if (type != null) {
        assert Name.isInternalName(typeData.internalName);
        typesByInternalName.put(typeData.internalName, type);
        context.classDataByType.put(type, classData);
      }
    }
    identityEvent.end();

    Event resolveEnclosingEvent = SpeedTracerLogger.start(
        CompilerEventType.TYPE_ORACLE_UPDATER, "phase", "Resolve Enclosing Classes");
    // Hook up enclosing types
    TreeLogger branch = logger.branch(TreeLogger.SPAM, "Resolving enclosing classes");
    for (Iterator<JRealClassType> unresolvedTypesIterator = unresolvedTypes.iterator();
        unresolvedTypesIterator.hasNext();) {
      JRealClassType unresolvedType = unresolvedTypesIterator.next();
      if (!resolveEnclosingClass(branch, unresolvedType, context)) {
        // already logged why it failed, don't try and use it further
        unresolvedTypesIterator.remove();
      }
    }
    resolveEnclosingEvent.end();

    Event resolveUnresolvedEvent = SpeedTracerLogger.start(
        CompilerEventType.TYPE_ORACLE_UPDATER, "phase", "Resolve Unresolved Types");
    // Resolve unresolved types.
    for (JRealClassType unresolvedType : unresolvedTypes) {
      branch =
          logger.branch(TreeLogger.SPAM, "Resolving " + unresolvedType.getQualifiedSourceName());
      if (!resolveClass(branch, unresolvedType, context)) {
        // already logged why it failed.
        // TODO: should we do anything else here?
      }
    }
View Full Code Here

   */
  private JRealClassType createType(
      TypeData typeData, CollectClassData collectClassData, CollectClassData enclosingClassData) {
    int access = collectClassData.getAccess();
    String simpleName = Shared.getShortName(typeData.sourceName);
    JRealClassType type = null;
    String packageName = typeData.packageName;
    JPackage pkg = typeOracle.getOrCreatePackage(packageName);
    boolean isInterface = (access & Opcodes.ACC_INTERFACE) != 0;
    assert !collectClassData.hasNoExternalName();
    String enclosingSimpleName = null;
    if (enclosingClassData != null) {
      enclosingSimpleName = enclosingClassData.getNestedSourceName();
    }
    if ((access & Opcodes.ACC_ANNOTATION) != 0) {
      type = newAnnotationType(pkg, enclosingSimpleName, simpleName);
    } else if ((access & Opcodes.ACC_ENUM) != 0) {
      type = newEnumType(pkg, enclosingSimpleName, simpleName);
    } else {
      JTypeParameter[] typeParams = getTypeParametersForClass(collectClassData);
      if ((typeParams != null && typeParams.length > 0)
          || nonStaticInsideGeneric(collectClassData, enclosingClassData)) {
        type = new JGenericType(
            typeOracle, pkg, enclosingSimpleName, simpleName, isInterface, typeParams);
      } else {
        type = newRealClassType(pkg, enclosingSimpleName, simpleName, isInterface);
      }
    }

    type.addModifierBits(mapBits(ASM_TO_SHARED_MODIFIERS, access));
    if (isInterface) {
      // Always add implicit modifiers on interfaces.
      type.addModifierBits(Shared.MOD_STATIC | Shared.MOD_ABSTRACT);
    }
    type.addLastModifiedTime(typeData.lastModifiedTime);

    return type;
  }
View Full Code Here

      if (enclosingClassData == null) {
        // if our enclosing class was skipped, skip this one too
        return null;
      }
    }
    JRealClassType realClassType = createType(typeData, classData, enclosingClassData);
    unresolvedTypes.add(realClassType);
    return realClassType;
  }
View Full Code Here

    // Find our enclosing class and set it
    CollectClassData classData = context.classDataByType.get(unresolvedType);
    assert classData != null;
    String enclosingClassInternalName = classData.getEnclosingInternalName();
    JRealClassType enclosingType = null;
    if (enclosingClassInternalName != null) {
      enclosingType = findByInternalName(enclosingClassInternalName);
      // Ensure enclosing classes are resolved
      if (enclosingType != null) {
        if (!resolveEnclosingClass(logger, enclosingType, context)) {
          return false;
        }
        if (enclosingType.isGenericType() != null
            && (classData.getAccess() & (Opcodes.ACC_STATIC | Opcodes.ACC_INTERFACE)) != 0) {
          // If the inner class doesn't have access to it's enclosing type's
          // type variables, the enclosing type must be the raw type instead
          // of the generic type.
          JGenericType genericType = enclosingType.isGenericType();
          setEnclosingType(unresolvedType, genericType.getRawType());
        } else {
          setEnclosingType(unresolvedType, enclosingType);
        }
      }
View Full Code Here

  private JRealClassType resolveObject(Type type) {
    assert type.getSort() == Type.OBJECT;
    String internalName = type.getInternalName();
    assert Name.isInternalName(internalName);
    JRealClassType classType = findByInternalName(internalName);
    return classType;
  }
View Full Code Here

      case Type.VOID:
        return JPrimitiveType.VOID;
      case Type.ARRAY:
        return resolveArray(type);
      case Type.OBJECT:
        JRealClassType resolvedType = resolveObject(type);
        return possiblySubstituteRawType(resolvedType);
      default:
        assert false : "Unexpected type " + type;
        return null;
    }
View Full Code Here

      CollectClassData cv = context.classMap.get(typeData.internalName);
      if (cv == null) {
        // ignore classes that were skipped earlier
        continue;
      }
      JRealClassType type = createType(typeData, unresolvedTypes, context);
      if (type != null) {
        binaryMapper.put(typeData.internalName, type);
        context.classMapType.put(type, cv);
      }
    }
    identityEvent.end();

    Event resolveEnclosingEvent = SpeedTracerLogger.start(
        CompilerEventType.TYPE_ORACLE_MEDIATOR, "phase",
        "Resolve Enclosing Classes");
    // Hook up enclosing types
    TreeLogger branch = logger.branch(TreeLogger.SPAM,
        "Resolving enclosing classes");
    for (Iterator<JRealClassType> it = unresolvedTypes.iterator(); it.hasNext();) {
      JRealClassType type = it.next();
      if (!resolveEnclosingClass(branch, type, context)) {
        // already logged why it failed, don't try and use it further
        it.remove();
      }
    }
    resolveEnclosingEvent.end();

    Event resolveUnresolvedEvent = SpeedTracerLogger.start(
        CompilerEventType.TYPE_ORACLE_MEDIATOR, "phase",
        "Resolve Unresolved Types");
    // Resolve unresolved types.
    for (JRealClassType type : unresolvedTypes) {
      branch = logger.branch(TreeLogger.SPAM, "Resolving "
          + type.getQualifiedSourceName());
      if (!resolveClass(branch, type, context)) {
        // already logged why it failed.
        // TODO: should we do anything else here?
      }
    }
View Full Code Here

  private JRealClassType createType(TypeData typeData,
      CollectClassData collectClassData, CollectClassData enclosingClassData) {
    int access = collectClassData.getAccess();
    String qualifiedSourceName = typeData.sourceName;
    String className = Shared.getShortName(qualifiedSourceName);
    JRealClassType resultType = null;
    String jpkgName = typeData.packageName;
    JPackage pkg = typeOracle.getOrCreatePackage(jpkgName);
    boolean isIntf = (access & Opcodes.ACC_INTERFACE) != 0;
    assert !collectClassData.hasNoExternalName();
    String enclosingTypeName = null;
    if (enclosingClassData != null) {
      enclosingTypeName = InternalName.toSourceName(InternalName.getClassName(enclosingClassData.getName()));
    }
    if ((access & Opcodes.ACC_ANNOTATION) != 0) {
      resultType = newAnnotationType(pkg, enclosingTypeName, className);
    } else if ((access & Opcodes.ACC_ENUM) != 0) {
      resultType = newEnumType(pkg, enclosingTypeName, className);
    } else {
      JTypeParameter[] typeParams = getTypeParametersForClass(collectClassData);
      if ((typeParams != null && typeParams.length > 0)
          || nonStaticInsideGeneric(collectClassData, enclosingClassData)) {
        resultType = new JGenericType(typeOracle, pkg, enclosingTypeName,
            className, isIntf, typeParams);
      } else {
        resultType = newRealClassType(pkg, enclosingTypeName, className, isIntf);
      }
    }

    /*
     * Add modifiers since these are needed for
     * TypeOracle.getParameterizedType's error checking code.
     */
    resultType.addModifierBits(mapBits(ASM_TO_SHARED_MODIFIERS, access));
    if (isIntf) {
      // Always add implicit modifiers on interfaces.
      resultType.addModifierBits(Shared.MOD_STATIC | Shared.MOD_ABSTRACT);
    }
   
    /*
     * Add a reference to the byteCode
     */
    resultType.addByteCode(typeData.byteCode);

    return resultType;
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.javac.typemodel.JRealClassType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.