Package org.codehaus.commons.compiler

Examples of org.codehaus.commons.compiler.CompileException


            this.optionalCompileErrorHandler != null
            ? this.optionalCompileErrorHandler
            : new UnitCompiler.ErrorHandler() {
                int compileErrorCount = 0;
                public void handleError(String message, Location optionalLocation) throws CompileException {
                    CompileException ex = new CompileException(message, optionalLocation);
                    if (++this.compileErrorCount >= 20) throw ex;
                    System.err.println(ex.getMessage());
                }
            }
        );

        this.benchmark.beginReporting();
View Full Code Here


    public final IClass getSuperclass() throws CompileException {
        if (!this.superclassIsCached) {
            this.superclass = this.getSuperclass2();
            this.superclassIsCached = true;
            if (this.superclass != null && this.superclass.isSubclassOf(this)) {
                throw new CompileException(
                    "Class circularity detected for \"" + Descriptor.toClassName(this.getDescriptor()) + "\"",
                    null
                );
            }
        }
View Full Code Here

    public final IClass[] getInterfaces() throws CompileException {
        if (this.interfaces == null) {
            this.interfaces = this.getInterfaces2();
            for (int i = 0; i < this.interfaces.length; ++i) {
                if (this.interfaces[i].implementsInterface(this)) {
                    throw new CompileException(
                        "Interface circularity detected for \"" + Descriptor.toClassName(this.getDescriptor()) + "\"",
                        null
                    );
                }
            }
View Full Code Here

        for (Iterator it = this.compilationUnit.packageMemberTypeDeclarations.iterator(); it.hasNext();) {
            UnitCompiler.this.compile((Java.PackageMemberTypeDeclaration) it.next());
        }

        if (this.compileErrorCount > 0) {
            throw new CompileException((
                this.compileErrorCount
                + " error(s) while compiling unit \""
                + this.compilationUnit.optionalFileName
                + "\""
            ), null);
View Full Code Here

        if (res != null) return res;
        try {
            return this.iClassLoader.loadIClass(Descriptor.fromClassName(className));
        } catch (ClassNotFoundException ex) {
            if (ex.getException() instanceof CompileException) throw (CompileException) ex.getException();
            throw new CompileException(className, location, ex);
        }
    }
View Full Code Here

            IClass result;
            try {
                result = this.iClassLoader.loadIClass(sb.toString());
            } catch (ClassNotFoundException ex) {
                if (ex.getException() instanceof CompileException) throw (CompileException) ex.getException();
                throw new CompileException(sb.toString(), null, ex);
            }
            if (result != null) return result;
            if (j < 0) break;
            sb.setCharAt(slashes[j], '$');
        }
View Full Code Here

        IClass[] ifs = iClass.getInterfaces();
        for (int i = 0; i < ifs.length; ++i) {
            IClass.IField f2 = this.findIField(ifs[i], name, location);
            if (f2 != null) {
                if (f != null) {
                    throw new CompileException((
                        "Access to field \""
                        + name
                        + "\" is ambiguous - both \""
                        + f.getDeclaringIClass()
                        + "\" and \""
View Full Code Here

    private void compileError(String message, Location optionalLocation) throws CompileException {
        ++this.compileErrorCount;
        if (this.optionalCompileErrorHandler != null) {
            this.optionalCompileErrorHandler.handleError(message, optionalLocation);
        } else {
            throw new CompileException(message, optionalLocation);
        }
    }
View Full Code Here

          (short) diagnostic.getLineNumber(), //
          (short) diagnostic.getColumnNumber() //
      );
      // Wrap the exception in a RuntimeException, because "report()"
      // does not declare checked exceptions.
      throw new RuntimeException(new CompileException(message, loc));
    } else if (logger.isTraceEnabled()) {
      logger.trace(diagnostic.toString() + " (" + diagnostic.getCode() + ")");
    }
  }
View Full Code Here

      CompilationTask task = compiler.getTask(null, fileManager, listener, compilerOptions, null, Collections.singleton(compilationUnit));

      // Run the compiler.
      if(!task.call()) {
        throw new CompileException("Compilation failed", null);
      } else if (!compilationUnit.isCompiled()) {
        throw new ClassNotFoundException(className + ": Class file not created by compilation.");
      }
      // all good
      return compilationUnit.getByteCode();
View Full Code Here

TOP

Related Classes of org.codehaus.commons.compiler.CompileException

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.