jaroslav@1373: /** jaroslav@1373: * Back 2 Browser Bytecode Translator jaroslav@1373: * Copyright (C) 2012 Jaroslav Tulach jaroslav@1373: * jaroslav@1373: * This program is free software: you can redistribute it and/or modify jaroslav@1373: * it under the terms of the GNU General Public License as published by jaroslav@1373: * the Free Software Foundation, version 2 of the License. jaroslav@1373: * jaroslav@1373: * This program is distributed in the hope that it will be useful, jaroslav@1373: * but WITHOUT ANY WARRANTY; without even the implied warranty of jaroslav@1373: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the jaroslav@1373: * GNU General Public License for more details. jaroslav@1373: * jaroslav@1373: * You should have received a copy of the GNU General Public License jaroslav@1373: * along with this program. Look for COPYING file in the top folder. jaroslav@1373: * If not, see http://opensource.org/licenses/GPL-2.0. jaroslav@1373: */ jaroslav@1373: package org.apidesign.vm4brwsr.api; jaroslav@1373: jaroslav@1373: import java.io.IOException; jaroslav@1373: import org.apidesign.bck2brwsr.core.JavaScriptBody; jaroslav@1373: jaroslav@1373: /** Utility methods to talk to the Bck2Brwsr virtual machine. jaroslav@1373: * jaroslav@1373: * @author Jaroslav Tulach jaroslav@1373: * @since 0.9 jaroslav@1373: */ jaroslav@1373: public final class VM { jaroslav@1373: private VM() { jaroslav@1373: } jaroslav@1373: jaroslav@1373: /** Takes an existing class and replaces its existing byte code jaroslav@1373: * with new one. jaroslav@1373: * jaroslav@1373: * @param clazz existing class to reload jaroslav@1373: * @param byteCode new bytecode jaroslav@1373: * @throws IOException an exception is something goes wrong jaroslav@1373: */ jaroslav@1373: public static void reload(Class clazz, byte[] byteCode) throws IOException { jaroslav@1373: reloadImpl(clazz.getName(), byteCode); jaroslav@1373: } jaroslav@1373: jaroslav@1373: @JavaScriptBody(args = { "name", "byteCode" }, body = "vm._reload(name, byteCode);") jaroslav@1373: private static void reloadImpl(String name, byte[] byteCode) throws IOException { jaroslav@1373: throw new IOException(); jaroslav@1373: } jaroslav@1373: }