序列化Java默认类?

时间:2014-05-31 09:17:51

标签: java serialization

我正在忙于为现有应用程序创建修改/插件,我的修改包括一个Rhino JavaScript脚本引擎,我唯一的问题是ScriptEngine和ScriptEngineManager是不可序列化的,这不会是&#39如果我能保存所有数据,那就成了问题。我怎么能这样做?

var vertices = RenderUtils.createSquareVertices(64);
var indices = RenderUtils.createSquareIndices();

var mesh = RenderUtils.newStaticMesh(vertices, indices, true);
var textureThingy = RenderUtils.newTexture("NULL.png", Sys.getAssetDir());
var materialThingy = RenderUtils.newMaterial(textureThingy, Math.newVector3f(1, 1, 1), 1, 1);
var renderMesh = RenderUtils.newMeshRenderer(mesh, materialThingy);
var rotationAngle = 0.0;

function update() {
    if(Mouse.isButtonDown(0)) rotationAngle=rotationAngle + 1.0;
    if(Mouse.isButtonDown(1)) rotationAngle=rotationAngle - 1.0;
}

function render() {
    renderMesh.getTransform().getPos().setVector(Sys.getWidth()/2, Sys.getHeight()/2, 0);
    renderMesh.getTransform().setRotation(Math.newVector3f(0, 0, 1), rotationAngle);
    renderMesh.render();
}

java方面:

public void start() {
    try {
        this.Script.eval(this.ApplicationCode);
    } catch(ScriptException e) {
        e.printStackTrace();
    }
}

public void update() {
    if(this.hasUpdateFunc) {
        try {
            if(this.Script != null) ((Invocable)this.Script).invokeFunction("update");
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (ScriptException e) {
            e.printStackTrace();
        }
    }
}

public void render() {
    if(this.hasRenderFunc) {
        try {
            if(this.Script != null) ((Invocable)this.Script).invokeFunction("render");
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (ScriptException e) {
            e.printStackTrace();
        }
    }
}

0 个答案:

没有答案