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

org.zodiac.script.engine.java.ClassFileManager Maven / Gradle / Ivy

package org.zodiac.script.engine.java;

import java.io.IOException;

import javax.tools.FileObject;
import javax.tools.ForwardingJavaFileManager;
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;

/**
 * 类文件管理器 用于JavaCompiler将编译好后的class,保存到jclassObject中。
 */
public class ClassFileManager extends ForwardingJavaFileManager {

    /**
     * 保存编译后Class文件的对象
     */
    private JavaClassObject jclassObject;

    public ClassFileManager(StandardJavaFileManager standardManager) {
        super(standardManager);
    }

    /**
     * 将JavaFileObject对象的引用交给JavaCompiler,让它将编译好后的Class文件装载进来
     * 
     * @param location 路径
     * @param className 类名
     * @param kind 对象类型
     * @param sibling 稳健对象
     * @return 结果
     * @throws IOException IOException
     */
    @Override
    public JavaFileObject getJavaFileForOutput(Location location, String className, JavaFileObject.Kind kind,
            FileObject sibling) throws IOException {
        if (jclassObject == null) {
            jclassObject = new JavaClassObject(className, kind);
        }
        return jclassObject;
    }

    public JavaClassObject getJavaClassObject() {
        return jclassObject;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy