Examples of ClassFile


Examples of net.janino.util.ClassFile

     * @throws TunnelException wraps a {@link IOException}
     */
    protected Class findClass(String name) throws ClassNotFoundException {

        // Check precompiled classes (classes that were parsed and compiled, but were not yet needed).
        ClassFile cf = (ClassFile) this.precompiledClasses.get(name);

        if (cf == null) {

            // Check parsed, but uncompiled compilation units.
            Java.CompilationUnit compilationUnitToCompile = null;
            for (Iterator i = this.uncompiledCompilationUnits.iterator(); i.hasNext();) {
                Java.CompilationUnit cu = (Java.CompilationUnit) i.next();
                if (cu.findClass(name) != null) {
                    compilationUnitToCompile = cu;
                    break;
                }
            }

            // Find and parse the right compilation unit.
            if (compilationUnitToCompile == null) {

                // Find and parse the right compilation unit, and add it to
                // "this.uncompiledCompilationUnits".
                if (this.iClassLoader.loadIClass(Descriptor.fromClassName(name)) == null) throw new ClassNotFoundException(name);

                for (Iterator i = this.uncompiledCompilationUnits.iterator(); i.hasNext();) {
                    Java.CompilationUnit cu = (Java.CompilationUnit) i.next();
                    if (cu.findClass(name) != null) {
                        compilationUnitToCompile = cu;
                        break;
                    }
                }
                if (compilationUnitToCompile == null) throw new RuntimeException(); // SNO: Loading IClass does not parse the CU that defines the IClass.
            }

            // Compile the compilation unit.
            ClassFile[] cfs;
            try {
                cfs = compilationUnitToCompile.compile(this.iClassLoader, this.debuggingInformation);
            } catch (Java.CompileException e) {
                throw new TunnelException(e);
            }

            // Now that the CU is compiled, remove it from the set of uncompiled CUs.
            this.uncompiledCompilationUnits.remove(compilationUnitToCompile);

            // Get the generated class file.
            for (int i = 0; i < cfs.length; ++i) {
                if (cfs[i].getThisClassName().equals(name)) {
                    if (cf != null) throw new RuntimeException(); // SNO: Multiple CFs with the same name.
                    cf = cfs[i];
                } else {
                    if (this.precompiledClasses.containsKey(cfs[i].getThisClassName())) throw new TunnelException(new Java.CompileException("Class or interface \"" + name + "\" is defined in more than one compilation unit", null));
                    this.precompiledClasses.put(cfs[i].getThisClassName(), cfs[i]);
                }
            }
            if (cf == null) throw new RuntimeException(); // SNO: Compilation of CU does not generate CF with requested name.
        }

        if (cf == null) throw new ClassNotFoundException(name);

        // Store the class file's byte code into a byte array.
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        try {
            cf.store(bos);
        } catch (IOException ex) {
            throw new RuntimeException(); // SNO: ByteArrayOutputStream thows IOException,
        }
        byte[] ba = bos.toByteArray();

View Full Code Here

Examples of net.sf.rej.java.ClassFile

            if (!this.project.isModified(targetFile)) {
              // is the file in question is not modified yet, group the new action
              // with an action that changes the status of the file.
                GroupAction ga = new GroupAction();
                ga.add(action);
              ClassFile cf = getClassFile(targetFile);
                ga.add(new MarkClassFileModifiedAction(this.project, targetFile, cf));
                um.add(ga);
                ga.execute();
            } else {
              um.add(action);
View Full Code Here

Examples of org.apache.harmony.pack200.bytecode.ClassFile

    private BcBands bcBands;

    private FileBands fileBands;

  private ClassFile buildClassFile(int classNum) throws Pack200Exception {
    ClassFile classFile = new ClassFile();
    classFile.major = header.getDefaultClassMajorVersion(); // TODO If
    // classVersionMajor[] use
    // that instead
    classFile.minor = header.getDefaultClassMinorVersion(); // TODO if
    // classVersionMinor[] use
View Full Code Here

Examples of org.apache.harmony.unpack200.bytecode.ClassFile

    private boolean[] fileIsClass;

    private InputStream internalBuffer;

    private ClassFile buildClassFile(int classNum) throws Pack200Exception {
        ClassFile classFile = new ClassFile();
        int[] major = classBands.getClassVersionMajor();
        int[] minor = classBands.getClassVersionMinor();
        if(major != null) {
            classFile.major = major[classNum];
            classFile.minor = minor[classNum];
View Full Code Here

Examples of org.apache.jdo.impl.enhancer.classfile.ClassFile

                dis = new DataInputStream(openClassInputStream(className));
            } else {
                dis = new DataInputStream(openFileInputStream(classFileName));
            }
            final boolean allowJDK12ClassFiles = true;
            classFile = new ClassFile(dis, allowJDK12ClassFiles);

            // check user class name from ClassFile
            final String userClassName
                = classFile.className().asString().replace('/', '.');
            //^olsen: better throw user exception or error
View Full Code Here

Examples of org.apache.tools.ant.taskdefs.optional.sitraka.bytecode.ClassFile

    public void testVector() throws IOException {
        String classname = ClassTest.class.getName().replace('.', '/') + ".class";
        InputStream is = getClass().getClassLoader().getResourceAsStream(classname);
    assertNotNull("Unable to find resource " + classname + "in caller classloader");
        ClassFile clazzfile = new ClassFile(is);
        assertEquals("ClassTest", clazzfile.getName());
        assertEquals("ClassFileTest.java", clazzfile.getSourceFile());
        MethodInfo[] methods = clazzfile.getMethods();
        assertEquals(3, methods.length);
        assertHasMethod("void <init>()", 2, methods);
        assertHasMethod("void testTwoLines()", 2, methods);
        assertHasMethod("void testOneLine()",
                        // in JDK 1.4 we get four lines
View Full Code Here

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

    ClassFile[] cfs = result.getClassFiles();
    UnwovenClassFile[] ret = new UnwovenClassFile[result.compiledTypes.size()];
    int i=0;
    for (Iterator iterator = result.compiledTypes.keySet().iterator(); iterator.hasNext();) {
      char[] className = (char[])iterator.next();
      ClassFile cf = (ClassFile)result.compiledTypes.get(className);
      // OPTIMIZE use char[] for classname
      ClassFileBasedByteCodeProvider p = new ClassFileBasedByteCodeProvider(cf);
      String fileName = nameProvider.getOutputClassFileName(cf.fileName(), result);
      ret[i++] = new UnwovenClassFileWithThirdPartyManagedBytecode(fileName,new String(className).replace('/','.'),p);
    }
    return ret;
  }
View Full Code Here

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

    CodeSnippetClassFile.createProblemType(this, this.scope.referenceCompilationUnit().compilationResult);
    return;
  }
  try {
    // create the result for a compiled type
    ClassFile classFile = new CodeSnippetClassFile(this.binding, enclosingClassFile, false);
    // generate all fiels
    classFile.addFieldInfos();
    if (this.binding.isMemberType()) {
      classFile.recordInnerClasses(this.binding);
    } else if (this.binding.isLocalType()) {
      enclosingClassFile.recordInnerClasses(this.binding);
      classFile.recordInnerClasses(this.binding);
    }

    if (this.memberTypes != null) {
      for (int i = 0, max = this.memberTypes.length; i < max; i++) {
        TypeDeclaration memberType = this.memberTypes[i];
        classFile.recordInnerClasses(memberType.binding);
        memberType.generateCode(this.scope, classFile);
      }
    }
    // generate all methods
    classFile.setForMethodInfos();
    if (this.methods != null) {
      for (int i = 0, max = this.methods.length; i < max; i++) {
        this.methods[i].generateCode(this.scope, classFile);
      }
    }
   
    // generate all methods
    classFile.addSpecialMethods();

    if (this.ignoreFurtherInvestigation){ // trigger problem type generation for code gen errors
      throw new AbortType(this.scope.referenceCompilationUnit().compilationResult, null);
    }

    // finalize the compiled type result
    classFile.addAttributes();
    this.scope.referenceCompilationUnit().compilationResult.record(this.binding.constantPoolName(), classFile);
  } catch (AbortType e) {
    if (this.binding == null)
      return;
    CodeSnippetClassFile.createProblemType(this, this.scope.referenceCompilationUnit().compilationResult);
View Full Code Here

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

      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

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

      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
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.