Search in sources :

Example 1 with ClassGenerationException

use of io.micronaut.inject.writer.ClassGenerationException in project micronaut-core by micronaut-projects.

the class IntrospectedTypeElementVisitor method finish.

@Override
public void finish(VisitorContext visitorContext) {
    try {
        for (AbstractIntrospection abstractIntrospection : abstractIntrospections) {
            final Collection<? extends PropertyElement> properties = abstractIntrospection.properties.values();
            if (CollectionUtils.isNotEmpty(properties)) {
                processBeanProperties(abstractIntrospection.writer, properties, abstractIntrospection.includes, abstractIntrospection.excludes, abstractIntrospection.ignored, abstractIntrospection.indexedAnnotations, abstractIntrospection.metadata);
                writers.put(abstractIntrospection.writer.getBeanType().getClassName(), abstractIntrospection.writer);
            }
        }
        if (!writers.isEmpty()) {
            for (BeanIntrospectionWriter writer : writers.values()) {
                try {
                    writer.accept(visitorContext);
                } catch (IOException e) {
                    throw new ClassGenerationException("I/O error occurred during class generation: " + e.getMessage(), e);
                }
            }
        }
    } finally {
        abstractIntrospections.clear();
        writers.clear();
    }
}
Also used : ClassGenerationException(io.micronaut.inject.writer.ClassGenerationException) IOException(java.io.IOException)

Example 2 with ClassGenerationException

use of io.micronaut.inject.writer.ClassGenerationException in project micronaut-core by micronaut-projects.

the class AnnotationMetadataWriter method writeTo.

/**
 * Write the class to the output stream, such a JavaFileObject created from a java annotation processor Filer object.
 *
 * @param outputStream the output stream pointing to the target class file
 */
public void writeTo(OutputStream outputStream) {
    try {
        ClassWriter classWriter = generateClassBytes();
        writeClassToDisk(outputStream, classWriter);
    } catch (Throwable e) {
        throw new ClassGenerationException("Error generating annotation metadata: " + e.getMessage(), e);
    }
}
Also used : ClassGenerationException(io.micronaut.inject.writer.ClassGenerationException) ClassWriter(org.objectweb.asm.ClassWriter)

Aggregations

ClassGenerationException (io.micronaut.inject.writer.ClassGenerationException)2 IOException (java.io.IOException)1 ClassWriter (org.objectweb.asm.ClassWriter)1