Package org.eclipse.jdt.internal.compiler

Examples of org.eclipse.jdt.internal.compiler.ClassFile


private void deployCodeSnippetClassIfNeeded(IRequestor requestor) throws InstallException {
  if (this.codeSnippetBinary == null) {
    // Deploy CodeSnippet class (only once)
    if (!requestor.acceptClassFiles(
      new ClassFile[] {
        new ClassFile() {
          public byte[] getBytes() {
            return getCodeSnippetBytes();
          }
          public char[][] getCompoundName() {
            return EvaluationConstants.ROOT_COMPOUND_NAME;
View Full Code Here


      // otherwise an AbortCompilation is thrown in 1.5 mode since the enclosing type
      // is needed to resolve a nested type
      Util.sort(classes, new Util.Comparer() {
        public int compare(Object a, Object b) {
          if (a == b) return 0;
          ClassFile enclosing = ((ClassFile) a).enclosingClassFile;
          while (enclosing != null) {
            if (enclosing == b)
              return 1;
            enclosing = enclosing.enclosingClassFile;
          }
View Full Code Here

      engine.lookupEnvironment.cacheBinaryType(binaryType, null /*no access restriction*/);
    }

    ClassFile[] classFiles = this.installedVars.classFiles;
    for (int i = 0; i < classFiles.length; i++) {
      ClassFile classFile = classFiles[i];
      IBinaryType binary = null;
      try {
        binary = new ClassFileReader(classFile.getBytes(), null);
      } catch (ClassFormatException e) {
        e.printStackTrace(); // Should never happen since we compiled this type
      }
      engine.lookupEnvironment.cacheBinaryType(binary, null /*no access restriction*/);
    }
 
View Full Code Here

  this.compilationResult.recoveryScannerData = null; // recovery is already done

  ClassFile[] classFiles = this.compilationResult.getClassFiles();
  for (int i = 0, max = classFiles.length; i < max; i++) {
    // clear the classFile back pointer to the bindings
    ClassFile classFile = classFiles[i];
    // null out the classfile backpointer to a type binding
    classFile.referenceBinding = null;
    classFile.innerClassesBindings = null;
    classFile.missingTypes = null;
    classFile.visitedTypes = null;
View Full Code Here

* @param typeDeclaration org.eclipse.jdt.internal.compiler.ast.TypeDeclaration
* @param unitResult org.eclipse.jdt.internal.compiler.CompilationUnitResult
*/
public static void createProblemType(TypeDeclaration typeDeclaration, CompilationResult unitResult) {
  SourceTypeBinding typeBinding = typeDeclaration.binding;
  ClassFile classFile = new CodeSnippetClassFile(typeBinding, null, true);

  // inner attributes
  if (typeBinding.hasMemberTypes()) {
    // see bug 180109
    ReferenceBinding[] members = typeBinding.memberTypes;
    for (int i = 0, l = members.length; i < l; i++)
      classFile.recordInnerClasses(members[i]);
  }
  // TODO (olivier) handle cases where a field cannot be generated (name too long)
  // TODO (olivier) handle too many methods
  // inner attributes
  if (typeBinding.isNestedType()) {
    classFile.recordInnerClasses(typeBinding);
  }
  TypeVariableBinding[] typeVariables = typeBinding.typeVariables();
  for (int i = 0, max = typeVariables.length; i < max; i++) {
    TypeVariableBinding typeVariableBinding = typeVariables[i];
    if ((typeVariableBinding.tagBits & TagBits.ContainsNestedTypeReferences) != 0) {
      Util.recordNestedType(classFile, typeVariableBinding);
    }
  }

  // add its fields
  FieldBinding[] fields = typeBinding.fields();
  if ((fields != null) && (fields != Binding.NO_FIELDS)) {
    classFile.addFieldInfos();
  } else {
    // we have to set the number of fields to be equals to 0
    classFile.contents[classFile.contentsOffset++] = 0;
    classFile.contents[classFile.contentsOffset++] = 0;
  }
  // leave some space for the methodCount
  classFile.setForMethodInfos();
  // add its user defined methods
  int problemsLength;
  CategorizedProblem[] problems = unitResult.getErrors();
  if (problems == null) {
    problems = new CategorizedProblem[0];
  }
  CategorizedProblem[] problemsCopy = new CategorizedProblem[problemsLength = problems.length];
  System.arraycopy(problems, 0, problemsCopy, 0, problemsLength);
  AbstractMethodDeclaration[] methodDecls = typeDeclaration.methods;
  if (methodDecls != null) {
    if (typeBinding.isInterface()) {
      // we cannot create problem methods for an interface. So we have to generate a clinit
      // which should contain all the problem
      classFile.addProblemClinit(problemsCopy);
      for (int i = 0, length = methodDecls.length; i < length; i++) {
        AbstractMethodDeclaration methodDecl = methodDecls[i];
        MethodBinding method = methodDecl.binding;
        if (method == null || method.isConstructor()) continue;
        method.modifiers = ClassFileConstants.AccPublic | ClassFileConstants.AccAbstract;
        classFile.addAbstractMethod(methodDecl, method);
      }
    } else {
      for (int i = 0, length = methodDecls.length; i < length; i++) {
        AbstractMethodDeclaration methodDecl = methodDecls[i];
        MethodBinding method = methodDecl.binding;
        if (method == null) continue;
        if (method.isConstructor()) {
          classFile.addProblemConstructor(methodDecl, method, problemsCopy);
        } else if (method.isAbstract()) {
          classFile.addAbstractMethod(methodDecl, method);
        } else {
          classFile.addProblemMethod(methodDecl, method, problemsCopy);
        }
      }
    }
    // add abstract methods
    classFile.addDefaultAbstractMethods();
  }
  // propagate generation of (problem) member types
  if (typeDeclaration.memberTypes != null) {
    for (int i = 0, max = typeDeclaration.memberTypes.length; i < max; i++) {
      TypeDeclaration memberType = typeDeclaration.memberTypes[i];
      if (memberType.binding != null) {
        ClassFile.createProblemType(memberType, unitResult);
      }
    }
  }
  classFile.addAttributes();
  unitResult.record(typeBinding.constantPoolName(), classFile);
}
View Full Code Here

      if (result.hasErrors()) {
        this.hasErrors = true;
      } else {
        ClassFile[] classFiles = result.getClassFiles();
        for (int i = 0; i < classFiles.length; i++) {
          ClassFile classFile = classFiles[i];
/*

          char[] filename = classFile.fileName();
          int length = filename.length;
          char[] relativeName = new char[length + 6];
View Full Code Here

      if (result.hasErrors()) {
        this.hasErrors = true;
      } else {
        ClassFile[] classFiles = result.getClassFiles();
        for (int i = 0; i < classFiles.length; i++) {
          ClassFile classFile = classFiles[i];
/*

          char[] filename = classFile.fileName();
          int length = filename.length;
          char[] relativeName = new char[length + 6];
View Full Code Here

      generateClasspathStructure = true;
    } // else leave currentDestinationPath null
    if (currentDestinationPath != null) {
      for (int i = 0, fileCount = classFiles.length; i < fileCount; i++) {
        // retrieve the key and the corresponding classfile
        ClassFile classFile = classFiles[i];
        char[] filename = classFile.fileName();
        int length = filename.length;
        char[] relativeName = new char[length + 6];
        System.arraycopy(filename, 0, relativeName, 0, length);
        System.arraycopy(SuffixConstants.SUFFIX_class, 0, relativeName, length, 6);
        CharOperation.replace(relativeName, '/', File.separatorChar);
View Full Code Here

                    }
                }
                if (!pResult.hasErrors()) {
                    final ClassFile[] clazzFiles = pResult.getClassFiles();
                    for (int i = 0; i < clazzFiles.length; i++) {
                        final ClassFile clazzFile = clazzFiles[i];
                        final char[][] compoundName = clazzFile.getCompoundName();
                        final StringBuilder clazzName = new StringBuilder();
                        for (int j = 0; j < compoundName.length; j++) {
                            if (j != 0) {
                                clazzName.append('.');
                            }
                            clazzName.append(compoundName[j]);
                        }
                        pStore.write(clazzName.toString().replace('.', '/') + ".class", clazzFile.getBytes());
                    }
                }
            }
        };
View Full Code Here

                    }
                }
                if (!pResult.hasErrors()) {
                    final ClassFile[] clazzFiles = pResult.getClassFiles();
                    for (int i = 0; i < clazzFiles.length; i++) {
                        final ClassFile clazzFile = clazzFiles[i];
                        final char[][] compoundName = clazzFile.getCompoundName();
                        final StringBuilder clazzName = new StringBuilder();
                        for (int j = 0; j < compoundName.length; j++) {
                            if (j != 0) {
                                clazzName.append('.');
                            }
                            clazzName.append(compoundName[j]);
                        }
                        pStore.write(clazzName.toString().replace('.', '/') + ".class", clazzFile.getBytes());
                    }
                }
            }
        };
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.ClassFile

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.