Examples of ClassFile


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

* @param typeDeclaration org.aspectj.org.eclipse.jdt.internal.compiler.ast.TypeDeclaration
* @param unitResult org.aspectj.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.isNestedType()) {
    classFile.recordInnerClasses(typeBinding);
  }

  // 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;
        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 {
          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

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

    String sig = typeX.getSignature();
    return sig.substring(1, sig.length()-1).toCharArray();
  }

  public void generateClass(CompilationResult result, ClassFile enclosingClassFile) {
    ClassFile classFile = new ClassFile(this);
    classFile.initialize(this, enclosingClassFile, false);
    classFile.recordInnerClasses(this);

    //classFile.addFieldInfos();
    classFile.contents[classFile.contentsOffset++] = (byte) 0;
    classFile.contents[classFile.contentsOffset++] = (byte) 0;
   
    classFile.setForMethodInfos();
    for (Iterator i = methods.iterator(); i.hasNext(); ) {
      MethodBinding b = (MethodBinding)i.next();
      generateMethod(classFile, b);
    }

    classFile.addAttributes();
     
    result.record(this.constantPoolName(), classFile);
  }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.core.ClassFile

protected BinaryTypeBinding cacheBinaryType(IType type, IBinaryType binaryType) throws JavaModelException {
  IType enclosingType = type.getDeclaringType();
  if (enclosingType != null)
    cacheBinaryType(enclosingType, null); // cache enclosing types first, so that binary type can be found in lookup enviroment
  if (binaryType == null) {
    ClassFile classFile = (ClassFile) type.getClassFile();
    try {
      binaryType = getBinaryInfo(classFile, classFile.getResource());
    } catch (CoreException e) {
      if (e instanceof JavaModelException) {
        throw (JavaModelException) e;
      } else {
        throw new JavaModelException(e);
View Full Code Here

Examples of org.codehaus.janino.util.ClassFile

            id.interfaces[i] = this.getType(id.extendedTypes[i]);
            interfaceDescriptors[i] = id.interfaces[i].getDescriptor();
        }

        // Create "ClassFile" object.
        ClassFile cf = new ClassFile(
            (short) (                         // accessFlags
                id.getModifiers() |
                Mod.SUPER |
                Mod.INTERFACE |
                Mod.ABSTRACT
            ),
            iClass.getDescriptor(),           // thisClassFD
            Descriptor.OBJECT,                // superClassFD
            interfaceDescriptors              // interfaceFDs
        );

        // Set "SourceFile" attribute.
        if (this.debugSource) {
            String sourceFileName;
            {
                String s = id.getLocation().getFileName();
                if (s != null) {
                    sourceFileName = new File(s).getName();
                } else {
                    sourceFileName = id.getName() + ".java";
                }
            }
            cf.addSourceFileAttribute(sourceFileName);
        }

        // Add "Deprecated" attribute (JVMS 4.7.10)
        if (id.hasDeprecatedDocTag()) cf.addDeprecatedAttribute();

        // Interface initialization method.
        if (!id.constantDeclarations.isEmpty()) {
            List statements = new ArrayList(); // BlockStatements
            statements.addAll(id.constantDeclarations);
View Full Code Here

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

                    }
                }
            }
            ClassFile[] classFiles = result.getClassFiles();
            for (int i = 0; i < classFiles.length; i++) {
                ClassFile classFile = classFiles[i];
                String className = CharOperation.toString(classFile.getCompoundName());
                try {
                    this.write(className, classFile.getBytes());
                } catch (IOException e) {
                    this.errorHandler.onError("Unable to write class file: " + e.getMessage(), className, 0, 0);
                }
            }
        }
View Full Code Here

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

                }
              }
            }else if(packInstance instanceof PackageFragment){
              //Current custom component is in jar files
              for(Object packo : ((PackageFragment) packInstance).getChildrenOfType(IJavaElement.CLASS_FILE)){
                ClassFile packi = (ClassFile) packo;
                String className = packi.getElementName().substring(0, packi.getElementName().indexOf('.'));
                if(className.indexOf('$') < 0 && (prefix + ":" + className.toLowerCase()).equals(nodeName)){
                  TapestryCoreComponents component = null;
                  try {
                    component = tapestryClassLoader.loadComponentAttributesFromClassFile(root, prefix, packi);
                  } catch (ClassFormatException e) {
View Full Code Here

Examples of org.gjt.jclasslib.structures.ClassFile

     * @return the created internal frame
     */
    public BrowserInternalFrame openClassFromFile(File file) {

        BrowserInternalFrame frame = new BrowserInternalFrame(desktopManager, new WindowState(file.getPath()));
        ClassFile classFile = frame.getClassFile();

        if (classFile != null) {
            try {
                String className = classFile.getThisClassName();
                String[] pathComponents = className.split("/");
                File currentDirectory = file.getParentFile();
                boolean validClasspathEntry = true;
                for (int i = pathComponents.length - 2; i >= 0; i--) {
                    String pathComponent = pathComponents[i];
View Full Code Here

Examples of org.hotswap.agent.javassist.bytecode.ClassFile

            throws ClassNotFoundException, RuntimeException {
        String classname = annotation.getTypeName();
        if (pool != null) {
            try {
                org.hotswap.agent.javassist.CtClass cc = pool.get(classname);
                ClassFile cf = cc.getClassFile2();
                org.hotswap.agent.javassist.bytecode.MethodInfo minfo = cf.getMethod(name);
                if (minfo != null) {
                    AnnotationDefaultAttribute ainfo
                            = (AnnotationDefaultAttribute)
                            minfo.getAttribute(AnnotationDefaultAttribute.tag);
                    if (ainfo != null) {
View Full Code Here

Examples of org.jboss.classfilewriter.ClassFile

        this.constructorDescriptor = constructorDescriptor;
    }

    public byte[] createTokenizer(final String existingClassName, final String[] httpVerbs, String[] httpVersions, String[] standardHeaders) {
        final String className = existingClassName + CLASS_NAME_SUFFIX;
        final ClassFile file = new ClassFile(className, existingClassName);


        final ClassMethod ctor = file.addMethod(AccessFlag.PUBLIC, "<init>", "V", DescriptorUtils.parameterDescriptors(constructorDescriptor));
        ctor.getCodeAttribute().aload(0);
        ctor.getCodeAttribute().loadMethodParameters();
        ctor.getCodeAttribute().invokespecial(existingClassName, "<init>", constructorDescriptor);
        ctor.getCodeAttribute().returnInstruction();


        final ClassMethod sctor = file.addMethod(AccessFlag.PUBLIC | AccessFlag.STATIC, "<clinit>", "V");
        final AtomicInteger fieldCounter = new AtomicInteger(1);
        sctor.getCodeAttribute().invokestatic(existingClassName, "httpStrings", "()" + DescriptorUtils.makeDescriptor(Map.class));
        sctor.getCodeAttribute().astore(CONSTRUCTOR_HTTP_STRING_MAP_VAR);

        createStateMachines(httpVerbs, httpVersions, standardHeaders, className, file, sctor, fieldCounter);

        sctor.getCodeAttribute().returnInstruction();
        return file.toBytecode();
    }
View Full Code Here

Examples of org.jboss.forge.furnace.proxy.javassist.bytecode.ClassFile

     * Returns the source file containing the expression.
     *
     * @return null if this information is not available.
     */
    public String getFileName() {
        ClassFile cf = thisClass.getClassFile2();
        if (cf == null)
            return null;
        else
            return cf.getSourceFile();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.