All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.youthlin.debug.compiler.JavaClassFileObject Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
package com.youthlin.debug.compiler;

import javax.tools.SimpleJavaFileObject;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URI;

/**
 * 创建: youthlin.chen
 * 时间: 2018-03-13 19:33
 */
public class JavaClassFileObject extends SimpleJavaFileObject {
    private ByteArrayOutputStream outputStream;

    public JavaClassFileObject(String className, Kind kind) {
        super(URI.create("mem:///" + className.replace(".", "/") + kind.extension), kind);
        outputStream = new ByteArrayOutputStream();
    }

    @Override
    public OutputStream openOutputStream() throws IOException {
        return outputStream;
    }

    public byte[] getClassBytes() {
        return outputStream.toByteArray();
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy