Package com.google.gwt.dev.javac

Examples of com.google.gwt.dev.javac.CompiledClass


         }
      } catch (NotFoundException e) {
         // Try and load the class from the compilation state. The generator
         // will need to have already been run on the class for this to work.
         String internalName = Name.BinaryName.toInternalName(className);
         CompiledClass compiledClass = compilationState.getClassFileMap().get(internalName);

         if (compiledClass != null) {
            addCompiledClass(compiledClass);
            try {
               return applyPatchers(className);
View Full Code Here


      }
      return GwtReflectionUtils.instantiateClass(c);
   }

   public Class<?> generate(Class<?> classLiteral) throws UnableToCompleteException {
      CompiledClass compiledClass = compile(classLiteral.getCanonicalName());
      if (compiledClass == null) {
         return classLiteral;
      }

      try {
         return GwtFactory.get().getClassLoader().loadClass(compiledClass.getSourceName());
      } catch (ClassNotFoundException e) {
         throw new RuntimeException(e);
      }
   }
View Full Code Here

      return propertyOracle;
   }

   private CompiledClass compile(String literalName) throws UnableToCompleteException {
      CompiledClass compiledClass = compiledClassMap.get(literalName);
      if (compiledClass != null) {
         logger.log(Type.INFO, "Using cached resource for " + literalName);
         return compiledClass;
      }
View Full Code Here


    // A JSO impl class needs the class bytes for the original class.
    String lookupClassName = canonicalizeClassName(className);

    CompiledClass compiledClass = compilationState.getClassFileMap().get(
        lookupClassName);

    if (classRewriter != null && classRewriter.isJsoIntf(className)) {
      // Generate a synthetic JSO interface class.
      byte[] newBytes = classRewriter.writeJsoIntf(className, compiledClass != null ?
        compiledClass.getBytes() : null);
      if (CLASS_DUMP) {
        classDump(className, newBytes);
      }
      return newBytes;
    }

    CompilationUnit unit = (compiledClass == null)
        ? getUnitForClassName(lookupClassName) : compiledClass.getUnit();
    if (emmaAvailable) {
      /*
       * build the map for anonymous classes. Do so only if unit has anonymous
       * classes, jsni methods, is not super-source and the map has not been
       * built before.
       */
      List<JsniMethod> jsniMethods = (unit == null) ? null
          : unit.getJsniMethods();
      if (unit != null && !unit.isSuperSource() && !unit.isGenerated()
          && unit.hasAnonymousClasses() && jsniMethods != null
          && jsniMethods.size() > 0 && !unit.createdClassMapping()) {
        if (!unit.constructAnonymousClassMappings(logger)) {
          logger.log(TreeLogger.ERROR,
              "Our heuristic for mapping anonymous classes between compilers "
                  + "failed. Unsafe to continue because the wrong jsni code "
                  + "could end up running. className = " + className);
          return null;
        }
      }
    }

    byte classBytes[] = null;
    if (compiledClass != null) {
      classBytes = compiledClass.getBytes();
      if (!compiledClass.getUnit().isSuperSource()) {
        classBytes = emmaStrategy.getEmmaClassBytes(classBytes,
            lookupClassName, compiledClass.getUnit().getLastModified());
      } else {
        if (logger.isLoggable(TreeLogger.SPAM)) {
          logger.log(TreeLogger.SPAM, "no emma instrumentation for "
              + lookupClassName + " because it is from super-source");
        }
View Full Code Here

   * Since a file might have several top-level types, search using classFileMap.
   */
  private CompilationUnit getUnitForClassName(String className) {
    String mainTypeName = className;
    int index = mainTypeName.length();
    CompiledClass cc = null;
    while (cc == null && index != -1) {
      mainTypeName = mainTypeName.substring(0, index);
      cc = compilationState.getClassFileMap().get(mainTypeName);
      index = mainTypeName.lastIndexOf('$');
    }
    return cc == null ? null : cc.getUnit();
  }
View Full Code Here

      Map<String, CompiledClass> compiledClassesBySourceName =
          rpo.getCompilationState().getClassFileMapBySource();
      // If the type is available as compiled source.
      if (compiledClassesBySourceName.containsKey(sourceTypeName)) {
        // Get and return it.
        CompiledClass compiledClass = compiledClassesBySourceName.get(sourceTypeName);
        return findType(compiledClass.getUnit().getTypes(), sourceTypeName);
      }
      // Otherwise if the type is available in a loaded library.
      CompilationUnit compilationUnit =
          compilerContext.getLibraryGroup().getCompilationUnitByTypeSourceName(sourceTypeName);
      if (compilationUnit != null) {
View Full Code Here

    }

    // A JSO impl class needs the class bytes for the original class.
    String lookupClassName = canonicalizeClassName(className);

    CompiledClass compiledClass = compilationState.getClassFileMap().get(
        lookupClassName);

    CompilationUnit unit = (compiledClass == null)
        ? getUnitForClassName(lookupClassName) : compiledClass.getUnit();
    if (emmaAvailable) {
      /*
       * build the map for anonymous classes. Do so only if unit has anonymous
       * classes, jsni methods, is not super-source and the map has not been
       * built before.
       */
      List<JsniMethod> jsniMethods = (unit == null) ? null
          : unit.getJsniMethods();
      if (unit != null && !unit.isSuperSource() && !unit.isGenerated()
          && unit.hasAnonymousClasses() && jsniMethods != null
          && jsniMethods.size() > 0 && !unit.createdClassMapping()) {
        if (!unit.constructAnonymousClassMappings(logger)) {
          logger.log(TreeLogger.ERROR,
              "Our heuristic for mapping anonymous classes between compilers "
                  + "failed. Unsafe to continue because the wrong jsni code "
                  + "could end up running. className = " + className);
          return null;
        }
      }
    }

    byte classBytes[] = null;
    if (compiledClass != null) {
      classBytes = compiledClass.getBytes();
      if (!compiledClass.getUnit().isSuperSource()) {
        classBytes = emmaStrategy.getEmmaClassBytes(classBytes,
            lookupClassName, compiledClass.getUnit().getLastModified());
      } else {
        logger.log(TreeLogger.SPAM, "no emma instrumentation for "
            + lookupClassName + " because it is from super-source");
      }
    } else if (emmaAvailable) {
View Full Code Here

   * Since a file might have several top-level types, search using classFileMap.
   */
  private CompilationUnit getUnitForClassName(String className) {
    String mainTypeName = className;
    int index = mainTypeName.length();
    CompiledClass cc = null;
    while (cc == null && index != -1) {
      mainTypeName = mainTypeName.substring(0, index);
      cc = compilationState.getClassFileMap().get(mainTypeName);
      index = mainTypeName.lastIndexOf('$');
    }
    return cc == null ? null : cc.getUnit();
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.javac.CompiledClass

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.