Package com.google.gwt.dev.javac.asm

Examples of com.google.gwt.dev.javac.asm.CollectClassData


    Event visitClassFileEvent = SpeedTracerLogger.start(
        CompilerEventType.TYPE_ORACLE_UPDATER, "phase", "Visit Class Files");
    TypeOracleBuildContext context = getContext(argsLookup);

    for (TypeData typeData : typeDataList) {
      CollectClassData classData = typeData.getCollectClassData();
      // skip any classes that can't be referenced by name outside of
      // their local scope, such as anonymous classes and method-local classes
      if (classData.hasNoExternalName()) {
        continue;
      }
      // skip classes that have been previously added
      if (typesByInternalName.containsKey(classData.getInternalName())) {
        continue;
      }
      context.classDataByInternalName.put(typeData.internalName, classData);
    }
    visitClassFileEvent.end();

    Event identityEvent = SpeedTracerLogger.start(
        CompilerEventType.TYPE_ORACLE_UPDATER, "phase", "Establish Identity");
    // Perform a shallow pass to establish identity for new and old types.
    Set<JRealClassType> unresolvedTypes = new LinkedHashSet<JRealClassType>();
    for (TypeData typeData : typeDataList) {
      CollectClassData classData = context.classDataByInternalName.get(typeData.internalName);
      if (classData == null) {
        // ignore classes that were skipped earlier
        continue;
      }
      if (typesByInternalName.containsKey(classData.getInternalName())) {
        // skip classes that have been previously added
        continue;
      }
      JRealClassType type = createType(typeData, unresolvedTypes, context);
      if (type != null) {
View Full Code Here


  /**
   * Doesn't retain a reference to the TypeData.
   */
  private JRealClassType createType(
      TypeData typeData, Set<JRealClassType> unresolvedTypes, TypeOracleBuildContext context) {
    CollectClassData classData = context.classDataByInternalName.get(typeData.internalName);
    String enclosingClassInternalName = classData.getEnclosingInternalName();
    CollectClassData enclosingClassData = null;
    if (enclosingClassInternalName != null) {
      enclosingClassData = context.classDataByInternalName.get(enclosingClassInternalName);
      if (enclosingClassData == null) {
        // if our enclosing class was skipped, skip this one too
        return null;
View Full Code Here

    // Build a search list for type parameters to find their definition,
    // resolving enclosing classes as we go up.
    TypeParameterLookup typeParamLookup = new TypeParameterLookup();
    typeParamLookup.pushEnclosingScopes(unresolvedType);

    CollectClassData classData = context.classDataByType.get(unresolvedType);
    assert classData != null;
    int access = classData.getAccess();

    assert (!classData.getClassType().hasNoExternalName());

    logger = logger.branch(
        TreeLogger.SPAM, "Found type '" + unresolvedType.getQualifiedSourceName() + "'", null);

    // Handle package-info classes.
    if (isPackageInfoTypeName(unresolvedType.getSimpleSourceName())) {
      return resolvePackage(logger, unresolvedType, classData.getAnnotations());
    }

    // Resolve annotations
    Map<Class<? extends Annotation>, Annotation> declaredAnnotations =
        new HashMap<Class<? extends Annotation>, Annotation>();
    resolveAnnotations(logger, classData.getAnnotations(), declaredAnnotations);
    addAnnotations(unresolvedType, declaredAnnotations);

    String signature = classData.getSignature();

    /*
     * Note: Byte code from the OpenJDK compiler doesn't contain a type signature for non-static
     * inner classes of parameterized types that do not contain new parameters (but JDT compiled
     * byte code does). That can cause some differences in the way generic types are represented in
     * the type oracle.
     *
     * These differences also show up when using java.lang.reflect to look at types.
     */
    if (signature != null) {
      // If we have a signature, use it for superclass and interfaces
      SignatureReader reader = new SignatureReader(signature);
      ResolveClassSignature classResolver = new ResolveClassSignature(
          context.resolver, logger, unresolvedType, typeParamLookup);
      reader.accept(classResolver);
      classResolver.finish();

      if (unresolvedType.getSuperclass() != null
          && !resolveClass(logger, unresolvedType.getSuperclass(), context)) {
        logger.log(TreeLogger.WARN,
            "Unable to resolve supertype " + unresolvedType.getSuperclass().getName());
        return false;
      }
    } else {
      // Set the super type for non-interfaces
      if ((access & Opcodes.ACC_INTERFACE) == 0) {
        String superInternalName = classData.getSuperInternalName();
        assert Name.isInternalName(superInternalName);
        if (superInternalName != null) {
          JClassType superType = findByInternalName(superInternalName);
          if (superType == null || !resolveClass(logger, superType, context)) {
            logger.log(TreeLogger.WARN, "Unable to resolve supertype " + superInternalName);
            return false;
          }
          setSuperClass(unresolvedType, (JClassType) possiblySubstituteRawType(superType));
        }
      }

      // Set interfaces
      for (String interfaceInternalName : classData.getInterfaceInternalNames()) {
        JClassType interfaceType = findByInternalName(interfaceInternalName);
        if (interfaceType == null || !resolveClass(logger, interfaceType, context)) {
          logger.log(TreeLogger.WARN, "Unable to resolve interface " + interfaceInternalName);
          return false;
        }
        addImplementedInterface(
            unresolvedType, (JClassType) possiblySubstituteRawType(interfaceType));
      }
    }
    if (((access & Opcodes.ACC_INTERFACE) == 0) && unresolvedType.getSuperclass() == null) {
      // Only Object or interfaces should not have a superclass
      assert "java/lang/Object".equals(classData.getInternalName());
    }

    // Process methods
    for (CollectMethodData method : classData.getMethods()) {
      TreeLogger branch = logger.branch(TreeLogger.SPAM, "Resolving method " + method.getName());
      if (!resolveMethod(branch, unresolvedType, method, typeParamLookup, context)) {
        // Already logged.
        return false;
      }
    }

    // Process fields
    // Track the next enum ordinal across resolveField calls.
    int[] nextEnumOrdinal = new int[] {0};
    for (CollectFieldData field : classData.getFields()) {
      TreeLogger branch = logger.branch(TreeLogger.SPAM, "Resolving field " + field.getName());
      if (!resolveField(branch, unresolvedType, field, typeParamLookup, nextEnumOrdinal, context)) {
        // Already logged.
        return false;
      }
View Full Code Here

    if (unresolvedType.getEnclosingType() != null) {
      return true;
    }

    // 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());
View Full Code Here

     * JRealClassType/JGenericType objects.
     */
    synchronized CollectClassData getCollectClassData() {
      if (classData == null) {
        ClassReader reader = new ClassReader(byteCode);
        classData = new CollectClassData();
        ClassVisitor classVisitor = classData;
        if (TRACE_CLASSES) {
          classVisitor = new TraceClassVisitor(classVisitor, new PrintWriter(System.out));
        }
        reader.accept(classVisitor, 0);
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.javac.asm.CollectClassData

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.