rt/launcher/src/main/java/org/apidesign/bck2brwsr/launcher/impl/JVMBridge.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Thu, 14 Mar 2013 09:22:28 +0100
branchfx
changeset 845 859804c78010
child 1004 04efef2a9c1e
permissions -rw-r--r--
Hacky way (relies on singleton) to get FX working. Can attach @On(event=CLICK) and show alert in FX WebView now
jaroslav@845
     1
/**
jaroslav@845
     2
 * Back 2 Browser Bytecode Translator
jaroslav@845
     3
 * Copyright (C) 2012 Jaroslav Tulach <jaroslav.tulach@apidesign.org>
jaroslav@845
     4
 *
jaroslav@845
     5
 * This program is free software: you can redistribute it and/or modify
jaroslav@845
     6
 * it under the terms of the GNU General Public License as published by
jaroslav@845
     7
 * the Free Software Foundation, version 2 of the License.
jaroslav@845
     8
 *
jaroslav@845
     9
 * This program is distributed in the hope that it will be useful,
jaroslav@845
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
jaroslav@845
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
jaroslav@845
    12
 * GNU General Public License for more details.
jaroslav@845
    13
 *
jaroslav@845
    14
 * You should have received a copy of the GNU General Public License
jaroslav@845
    15
 * along with this program. Look for COPYING file in the top folder.
jaroslav@845
    16
 * If not, see http://opensource.org/licenses/GPL-2.0.
jaroslav@845
    17
 */
jaroslav@845
    18
package org.apidesign.bck2brwsr.launcher.impl;
jaroslav@845
    19
jaroslav@845
    20
/**
jaroslav@845
    21
 *
jaroslav@845
    22
 * @author Jaroslav Tulach <jtulach@netbeans.org>
jaroslav@845
    23
 */
jaroslav@845
    24
public final class JVMBridge {
jaroslav@845
    25
    private static ClassLoader[] ldrs;
jaroslav@845
    26
        
jaroslav@845
    27
    public static void registerClassLoaders(ClassLoader[] loaders) {
jaroslav@845
    28
        ldrs = loaders.clone();
jaroslav@845
    29
    }
jaroslav@845
    30
    
jaroslav@845
    31
    public Class<?> loadClass(String name) throws ClassNotFoundException {
jaroslav@845
    32
        System.err.println("trying to load " + name);
jaroslav@845
    33
        ClassNotFoundException ex = null;
jaroslav@845
    34
        if (ldrs != null) for (ClassLoader l : ldrs) {
jaroslav@845
    35
            try {
jaroslav@845
    36
                return Class.forName(name, true, l);
jaroslav@845
    37
            } catch (ClassNotFoundException ex2) {
jaroslav@845
    38
                ex = ex2;
jaroslav@845
    39
            }
jaroslav@845
    40
        }
jaroslav@845
    41
        if (ex == null) {
jaroslav@845
    42
            ex = new ClassNotFoundException("No loaders");
jaroslav@845
    43
        }
jaroslav@845
    44
        throw ex;
jaroslav@845
    45
    }
jaroslav@845
    46
}