Use optional dependency on asm-5.0.jar, so we don't have to bundle it when the classes are post processed.
authorJaroslav Tulach <jtulach@netbeans.org>
Sat, 29 Nov 2014 22:25:40 +0100
changeset 884af690d50d7d6
parent 883 3299d5335b8f
child 885 6e20d36f1a13
Use optional dependency on asm-5.0.jar, so we don't have to bundle it when the classes are post processed.
boot-agent-test/pom.xml
boot-agent-test/src/test/java/org/netbeans/html/bootagent/DynamicClassLoaderTest.java
boot-agent-test/src/test/java/org/netbeans/html/bootagent/JavaScriptBodyTst.java
boot-agent-test/src/test/java/org/netbeans/html/bootagent/KOFx.java
boot-agent-test/src/test/resources/org/netbeans/html/bootagent/empty.html
boot-fx/src/test/java/org/netbeans/html/boot/fx/BootstrapTest.java
boot/pom.xml
boot/src/main/java/net/java/html/boot/BrowserBuilder.java
boot/src/main/java/net/java/html/js/package.html
boot/src/main/java/org/netbeans/html/boot/impl/FnContext.java
boot/src/main/java/org/netbeans/html/boot/impl/FnUtils.java
pom.xml
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/boot-agent-test/pom.xml	Sat Nov 29 22:25:40 2014 +0100
     1.3 @@ -0,0 +1,61 @@
     1.4 +<?xml version="1.0" encoding="UTF-8"?>
     1.5 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     1.6 +    <modelVersion>4.0.0</modelVersion>
     1.7 +    <parent>
     1.8 +        <groupId>org.netbeans.html</groupId>
     1.9 +        <artifactId>pom</artifactId>
    1.10 +        <version>2.0-SNAPSHOT</version>
    1.11 +    </parent>
    1.12 +    <artifactId>boot-agent-test</artifactId>
    1.13 +    <packaging>jar</packaging>
    1.14 +    <name>Dynamic Boot Test</name>
    1.15 +    <build>
    1.16 +        <plugins>
    1.17 +            <plugin>
    1.18 +                <groupId>org.apache.maven.plugins</groupId>
    1.19 +                <artifactId>maven-deploy-plugin</artifactId>
    1.20 +                <configuration>
    1.21 +                    <skip>true</skip>
    1.22 +                </configuration>
    1.23 +            </plugin>
    1.24 +        </plugins>
    1.25 +    </build>
    1.26 +    <dependencies>
    1.27 +        <dependency>
    1.28 +            <groupId>org.testng</groupId>
    1.29 +            <artifactId>testng</artifactId>
    1.30 +            <scope>test</scope>
    1.31 +        </dependency>
    1.32 +        <dependency>
    1.33 +            <groupId>org.netbeans.html</groupId>
    1.34 +            <artifactId>net.java.html</artifactId>
    1.35 +            <version>${project.version}</version>
    1.36 +            <scope>test</scope>
    1.37 +            <type>jar</type>
    1.38 +        </dependency>
    1.39 +        <dependency>
    1.40 +            <groupId>org.netbeans.html</groupId>
    1.41 +            <artifactId>net.java.html.boot</artifactId>
    1.42 +            <version>${project.version}</version>
    1.43 +            <scope>test</scope>
    1.44 +            <type>jar</type>
    1.45 +        </dependency>
    1.46 +        <dependency>
    1.47 +            <groupId>org.netbeans.api</groupId>
    1.48 +            <artifactId>org-openide-util-lookup</artifactId>
    1.49 +            <scope>test</scope>
    1.50 +            <type>jar</type>
    1.51 +        </dependency>
    1.52 +        <dependency>
    1.53 +            <groupId>${project.groupId}</groupId>
    1.54 +            <artifactId>net.java.html.boot.fx</artifactId>
    1.55 +            <version>${project.version}</version>
    1.56 +            <scope>test</scope>
    1.57 +        </dependency>
    1.58 +        <dependency>
    1.59 +            <groupId>org.ow2.asm</groupId>
    1.60 +            <artifactId>asm</artifactId>
    1.61 +            <scope>test</scope>
    1.62 +        </dependency>
    1.63 +    </dependencies>
    1.64 +</project>
    1.65 \ No newline at end of file
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/boot-agent-test/src/test/java/org/netbeans/html/bootagent/DynamicClassLoaderTest.java	Sat Nov 29 22:25:40 2014 +0100
     2.3 @@ -0,0 +1,126 @@
     2.4 +/**
     2.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     2.6 + *
     2.7 + * Copyright 2013-2014 Oracle and/or its affiliates. All rights reserved.
     2.8 + *
     2.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
    2.10 + * Other names may be trademarks of their respective owners.
    2.11 + *
    2.12 + * The contents of this file are subject to the terms of either the GNU
    2.13 + * General Public License Version 2 only ("GPL") or the Common
    2.14 + * Development and Distribution License("CDDL") (collectively, the
    2.15 + * "License"). You may not use this file except in compliance with the
    2.16 + * License. You can obtain a copy of the License at
    2.17 + * http://www.netbeans.org/cddl-gplv2.html
    2.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    2.19 + * specific language governing permissions and limitations under the
    2.20 + * License.  When distributing the software, include this License Header
    2.21 + * Notice in each file and include the License file at
    2.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
    2.23 + * particular file as subject to the "Classpath" exception as provided
    2.24 + * by Oracle in the GPL Version 2 section of the License file that
    2.25 + * accompanied this code. If applicable, add the following below the
    2.26 + * License Header, with the fields enclosed by brackets [] replaced by
    2.27 + * your own identifying information:
    2.28 + * "Portions Copyrighted [year] [name of copyright owner]"
    2.29 + *
    2.30 + * Contributor(s):
    2.31 + *
    2.32 + * The Original Software is NetBeans. The Initial Developer of the Original
    2.33 + * Software is Oracle. Portions Copyright 2013-2014 Oracle. All Rights Reserved.
    2.34 + *
    2.35 + * If you wish your version of this file to be governed by only the CDDL
    2.36 + * or only the GPL Version 2, indicate your decision by adding
    2.37 + * "[Contributor] elects to include this software in this distribution
    2.38 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
    2.39 + * single choice of license, a recipient has the option to distribute
    2.40 + * your version of this file under either the CDDL, the GPL Version 2 or
    2.41 + * to extend the choice of license to its licensees as provided above.
    2.42 + * However, if you add GPL Version 2 code and therefore, elected the GPL
    2.43 + * Version 2 license, then the option applies only if the new code is
    2.44 + * made subject to such option by the copyright holder.
    2.45 + */
    2.46 +package org.netbeans.html.bootagent;
    2.47 +
    2.48 +import java.lang.reflect.Field;
    2.49 +import java.lang.reflect.Method;
    2.50 +import java.lang.reflect.Modifier;
    2.51 +import java.util.ArrayList;
    2.52 +import java.util.List;
    2.53 +import java.util.concurrent.Executors;
    2.54 +import net.java.html.BrwsrCtx;
    2.55 +import net.java.html.boot.BrowserBuilder;
    2.56 +import org.netbeans.html.boot.spi.Fn;
    2.57 +import org.testng.Assert;
    2.58 +import static org.testng.Assert.assertNotSame;
    2.59 +import static org.testng.Assert.assertSame;
    2.60 +import org.testng.annotations.Factory;
    2.61 +
    2.62 +/**
    2.63 + *
    2.64 + * @author Jaroslav Tulach
    2.65 + */
    2.66 +public class DynamicClassLoaderTest {
    2.67 +    private static Class<?> browserClass;
    2.68 +    private static Fn.Presenter browserPresenter;
    2.69 +    
    2.70 +    public DynamicClassLoaderTest() {
    2.71 +    }
    2.72 +
    2.73 +    @Factory public static Object[] compatibilityTests() throws Exception {
    2.74 +        final BrowserBuilder bb = BrowserBuilder.newBrowser().loadClass(DynamicClassLoaderTest.class).
    2.75 +            loadPage("empty.html").
    2.76 +            invoke("initialized");
    2.77 +
    2.78 +        Executors.newSingleThreadExecutor().submit(new Runnable() {
    2.79 +            @Override
    2.80 +            public void run() {
    2.81 +                bb.showAndWait();
    2.82 +            }
    2.83 +        });
    2.84 +
    2.85 +        List<Object> res = new ArrayList<Object>();
    2.86 +
    2.87 +        Class[] arr = new Class[] { loadClass() };
    2.88 +        for (Class c : arr) {
    2.89 +            for (Method m : c.getDeclaredMethods()) {
    2.90 +                if ((m.getModifiers() & Modifier.PUBLIC) != 0) {
    2.91 +                    res.add(new KOFx(browserPresenter, m));
    2.92 +                }
    2.93 +            }
    2.94 +        }
    2.95 +        return res.toArray();
    2.96 +    }
    2.97 +
    2.98 +    static synchronized Class<?> loadClass() throws InterruptedException {
    2.99 +        while (browserClass == null) {
   2.100 +            DynamicClassLoaderTest.class.wait();
   2.101 +        }
   2.102 +        return browserClass;
   2.103 +    }
   2.104 +    
   2.105 +    public static void ready(Class<?> browserCls) throws Exception {
   2.106 +        Class<?> origClazz = ClassLoader.getSystemClassLoader().loadClass(DynamicClassLoaderTest.class.getName());
   2.107 +        final Field f1 = origClazz.getDeclaredField("browserClass");
   2.108 +        f1.setAccessible(true);
   2.109 +        f1.set(null, browserCls);
   2.110 +        final Field f2 = origClazz.getDeclaredField("browserPresenter");
   2.111 +        f2.setAccessible(true);
   2.112 +        f2.set(null, Fn.activePresenter());
   2.113 +        synchronized (origClazz) {
   2.114 +            origClazz.notifyAll();
   2.115 +        }
   2.116 +    }
   2.117 +    
   2.118 +    public static void initialized() throws Exception {
   2.119 +        BrwsrCtx b1 = BrwsrCtx.findDefault(DynamicClassLoaderTest.class);
   2.120 +        assertNotSame(b1, BrwsrCtx.EMPTY, "Browser context is not empty");
   2.121 +        BrwsrCtx b2 = BrwsrCtx.findDefault(DynamicClassLoaderTest.class);
   2.122 +        assertSame(b1, b2, "Browser context remains stable");
   2.123 +        Assert.assertNotSame(DynamicClassLoaderTest.class.getClassLoader(),
   2.124 +            ClassLoader.getSystemClassLoader(),
   2.125 +            "Should use special classloader, not system one"
   2.126 +        );
   2.127 +        DynamicClassLoaderTest.ready(JavaScriptBodyTst.class);
   2.128 +    }
   2.129 +}
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/boot-agent-test/src/test/java/org/netbeans/html/bootagent/JavaScriptBodyTst.java	Sat Nov 29 22:25:40 2014 +0100
     3.3 @@ -0,0 +1,63 @@
     3.4 +/**
     3.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     3.6 + *
     3.7 + * Copyright 2013-2014 Oracle and/or its affiliates. All rights reserved.
     3.8 + *
     3.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
    3.10 + * Other names may be trademarks of their respective owners.
    3.11 + *
    3.12 + * The contents of this file are subject to the terms of either the GNU
    3.13 + * General Public License Version 2 only ("GPL") or the Common
    3.14 + * Development and Distribution License("CDDL") (collectively, the
    3.15 + * "License"). You may not use this file except in compliance with the
    3.16 + * License. You can obtain a copy of the License at
    3.17 + * http://www.netbeans.org/cddl-gplv2.html
    3.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    3.19 + * specific language governing permissions and limitations under the
    3.20 + * License.  When distributing the software, include this License Header
    3.21 + * Notice in each file and include the License file at
    3.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
    3.23 + * particular file as subject to the "Classpath" exception as provided
    3.24 + * by Oracle in the GPL Version 2 section of the License file that
    3.25 + * accompanied this code. If applicable, add the following below the
    3.26 + * License Header, with the fields enclosed by brackets [] replaced by
    3.27 + * your own identifying information:
    3.28 + * "Portions Copyrighted [year] [name of copyright owner]"
    3.29 + *
    3.30 + * Contributor(s):
    3.31 + *
    3.32 + * The Original Software is NetBeans. The Initial Developer of the Original
    3.33 + * Software is Oracle. Portions Copyright 2013-2014 Oracle. All Rights Reserved.
    3.34 + *
    3.35 + * If you wish your version of this file to be governed by only the CDDL
    3.36 + * or only the GPL Version 2, indicate your decision by adding
    3.37 + * "[Contributor] elects to include this software in this distribution
    3.38 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
    3.39 + * single choice of license, a recipient has the option to distribute
    3.40 + * your version of this file under either the CDDL, the GPL Version 2 or
    3.41 + * to extend the choice of license to its licensees as provided above.
    3.42 + * However, if you add GPL Version 2 code and therefore, elected the GPL
    3.43 + * Version 2 license, then the option applies only if the new code is
    3.44 + * made subject to such option by the copyright holder.
    3.45 + */
    3.46 +package org.netbeans.html.bootagent;
    3.47 +
    3.48 +import net.java.html.js.JavaScriptBody;
    3.49 +
    3.50 +/**
    3.51 + *
    3.52 + * @author Jaroslav Tulach
    3.53 + */
    3.54 +public class JavaScriptBodyTst {
    3.55 +    
    3.56 +    public JavaScriptBodyTst() {
    3.57 +    }
    3.58 +
    3.59 +    public void assert42() {
    3.60 +        int v = mul(7, 6);
    3.61 +        assert v == 42 : "Really 42: " + v;
    3.62 +    }
    3.63 +    
    3.64 +    @JavaScriptBody(args = { "x", "y" }, body = "return x * y;")
    3.65 +    private static native int mul(int x, int y);
    3.66 +}
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/boot-agent-test/src/test/java/org/netbeans/html/bootagent/KOFx.java	Sat Nov 29 22:25:40 2014 +0100
     4.3 @@ -0,0 +1,125 @@
     4.4 +/**
     4.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     4.6 + *
     4.7 + * Copyright 2013-2014 Oracle and/or its affiliates. All rights reserved.
     4.8 + *
     4.9 + * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
    4.10 + * Other names may be trademarks of their respective owners.
    4.11 + *
    4.12 + * The contents of this file are subject to the terms of either the GNU
    4.13 + * General Public License Version 2 only ("GPL") or the Common
    4.14 + * Development and Distribution License("CDDL") (collectively, the
    4.15 + * "License"). You may not use this file except in compliance with the
    4.16 + * License. You can obtain a copy of the License at
    4.17 + * http://www.netbeans.org/cddl-gplv2.html
    4.18 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    4.19 + * specific language governing permissions and limitations under the
    4.20 + * License.  When distributing the software, include this License Header
    4.21 + * Notice in each file and include the License file at
    4.22 + * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
    4.23 + * particular file as subject to the "Classpath" exception as provided
    4.24 + * by Oracle in the GPL Version 2 section of the License file that
    4.25 + * accompanied this code. If applicable, add the following below the
    4.26 + * License Header, with the fields enclosed by brackets [] replaced by
    4.27 + * your own identifying information:
    4.28 + * "Portions Copyrighted [year] [name of copyright owner]"
    4.29 + *
    4.30 + * Contributor(s):
    4.31 + *
    4.32 + * The Original Software is NetBeans. The Initial Developer of the Original
    4.33 + * Software is Oracle. Portions Copyright 2013-2014 Oracle. All Rights Reserved.
    4.34 + *
    4.35 + * If you wish your version of this file to be governed by only the CDDL
    4.36 + * or only the GPL Version 2, indicate your decision by adding
    4.37 + * "[Contributor] elects to include this software in this distribution
    4.38 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
    4.39 + * single choice of license, a recipient has the option to distribute
    4.40 + * your version of this file under either the CDDL, the GPL Version 2 or
    4.41 + * to extend the choice of license to its licensees as provided above.
    4.42 + * However, if you add GPL Version 2 code and therefore, elected the GPL
    4.43 + * Version 2 license, then the option applies only if the new code is
    4.44 + * made subject to such option by the copyright holder.
    4.45 + */
    4.46 +package org.netbeans.html.bootagent;
    4.47 +
    4.48 +import java.lang.reflect.InvocationTargetException;
    4.49 +import java.lang.reflect.Method;
    4.50 +import javafx.application.Platform;
    4.51 +import org.netbeans.html.boot.impl.FnContext;
    4.52 +import org.netbeans.html.boot.spi.Fn;
    4.53 +import org.testng.IHookCallBack;
    4.54 +import org.testng.IHookable;
    4.55 +import org.testng.ITest;
    4.56 +import org.testng.ITestResult;
    4.57 +import org.testng.annotations.Test;
    4.58 +
    4.59 +/**
    4.60 + *
    4.61 + * @author Jaroslav Tulach
    4.62 + */
    4.63 +public final class KOFx implements ITest, IHookable, Runnable {
    4.64 +    private final Fn.Presenter p;
    4.65 +    private final Method m;
    4.66 +    private Object result;
    4.67 +    private Object inst;
    4.68 +
    4.69 +    KOFx(Fn.Presenter p, Method m) {
    4.70 +        this.p = p;
    4.71 +        this.m = m;
    4.72 +    }
    4.73 +
    4.74 +    @Override
    4.75 +    public String getTestName() {
    4.76 +        return m.getName();
    4.77 +    }
    4.78 +
    4.79 +    @Test
    4.80 +    public synchronized void executeTest() throws Exception {
    4.81 +        if (result == null) {
    4.82 +            Platform.runLater(this);
    4.83 +            wait();
    4.84 +        }
    4.85 +        if (result instanceof Exception) {
    4.86 +            throw (Exception)result;
    4.87 +        }
    4.88 +        if (result instanceof Error) {
    4.89 +            throw (Error)result;
    4.90 +        }
    4.91 +    }
    4.92 +
    4.93 +    @Override
    4.94 +    public synchronized void run() {
    4.95 +        boolean notify = true;
    4.96 +        try {
    4.97 +            FnContext.currentPresenter(p);
    4.98 +            if (inst == null) {
    4.99 +                inst = m.getDeclaringClass().newInstance();
   4.100 +            }
   4.101 +            result = m.invoke(inst);
   4.102 +            if (result == null) {
   4.103 +                result = this;
   4.104 +            }
   4.105 +        } catch (InvocationTargetException ex) {
   4.106 +            Throwable r = ex.getTargetException();
   4.107 +            if (r instanceof InterruptedException) {
   4.108 +                notify = false;
   4.109 +                Platform.runLater(this);
   4.110 +                return;
   4.111 +            }
   4.112 +            result = r;
   4.113 +        } catch (Exception ex) {
   4.114 +            result = ex;
   4.115 +        } finally {
   4.116 +            if (notify) {
   4.117 +                notifyAll();
   4.118 +            }
   4.119 +            FnContext.currentPresenter(null);
   4.120 +        }
   4.121 +    }
   4.122 +
   4.123 +    @Override
   4.124 +    public void run(IHookCallBack ihcb, ITestResult itr) {
   4.125 +        ihcb.runTestMethod(itr);
   4.126 +    }
   4.127 +    
   4.128 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/boot-agent-test/src/test/resources/org/netbeans/html/bootagent/empty.html	Sat Nov 29 22:25:40 2014 +0100
     5.3 @@ -0,0 +1,55 @@
     5.4 +<!--
     5.5 +
     5.6 +    DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     5.7 +
     5.8 +    Copyright 2013-2014 Oracle and/or its affiliates. All rights reserved.
     5.9 +
    5.10 +    Oracle and Java are registered trademarks of Oracle and/or its affiliates.
    5.11 +    Other names may be trademarks of their respective owners.
    5.12 +
    5.13 +    The contents of this file are subject to the terms of either the GNU
    5.14 +    General Public License Version 2 only ("GPL") or the Common
    5.15 +    Development and Distribution License("CDDL") (collectively, the
    5.16 +    "License"). You may not use this file except in compliance with the
    5.17 +    License. You can obtain a copy of the License at
    5.18 +    http://www.netbeans.org/cddl-gplv2.html
    5.19 +    or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    5.20 +    specific language governing permissions and limitations under the
    5.21 +    License.  When distributing the software, include this License Header
    5.22 +    Notice in each file and include the License file at
    5.23 +    nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
    5.24 +    particular file as subject to the "Classpath" exception as provided
    5.25 +    by Oracle in the GPL Version 2 section of the License file that
    5.26 +    accompanied this code. If applicable, add the following below the
    5.27 +    License Header, with the fields enclosed by brackets [] replaced by
    5.28 +    your own identifying information:
    5.29 +    "Portions Copyrighted [year] [name of copyright owner]"
    5.30 +
    5.31 +    Contributor(s):
    5.32 +
    5.33 +    The Original Software is NetBeans. The Initial Developer of the Original
    5.34 +    Software is Oracle. Portions Copyright 2013-2014 Oracle. All Rights Reserved.
    5.35 +
    5.36 +    If you wish your version of this file to be governed by only the CDDL
    5.37 +    or only the GPL Version 2, indicate your decision by adding
    5.38 +    "[Contributor] elects to include this software in this distribution
    5.39 +    under the [CDDL or GPL Version 2] license." If you do not indicate a
    5.40 +    single choice of license, a recipient has the option to distribute
    5.41 +    your version of this file under either the CDDL, the GPL Version 2 or
    5.42 +    to extend the choice of license to its licensees as provided above.
    5.43 +    However, if you add GPL Version 2 code and therefore, elected the GPL
    5.44 +    Version 2 license, then the option applies only if the new code is
    5.45 +    made subject to such option by the copyright holder.
    5.46 +
    5.47 +-->
    5.48 +<!DOCTYPE html>
    5.49 +<html>
    5.50 +    <head>
    5.51 +        <title>Bootstrap Dynamically</title>
    5.52 +        <meta charset="UTF-8">
    5.53 +        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    5.54 +    </head>
    5.55 +    <body>
    5.56 +        <div>Bootstrap Dynamically</div>
    5.57 +    </body>
    5.58 +</html>
     6.1 --- a/boot-fx/src/test/java/org/netbeans/html/boot/fx/BootstrapTest.java	Thu Nov 20 14:59:04 2014 +0100
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,127 +0,0 @@
     6.4 -/**
     6.5 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
     6.6 - *
     6.7 - * Copyright 2013-2014 Oracle and/or its affiliates. All rights reserved.
     6.8 - *
     6.9 - * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
    6.10 - * Other names may be trademarks of their respective owners.
    6.11 - *
    6.12 - * The contents of this file are subject to the terms of either the GNU
    6.13 - * General Public License Version 2 only ("GPL") or the Common
    6.14 - * Development and Distribution License("CDDL") (collectively, the
    6.15 - * "License"). You may not use this file except in compliance with the
    6.16 - * License. You can obtain a copy of the License at
    6.17 - * http://www.netbeans.org/cddl-gplv2.html
    6.18 - * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
    6.19 - * specific language governing permissions and limitations under the
    6.20 - * License.  When distributing the software, include this License Header
    6.21 - * Notice in each file and include the License file at
    6.22 - * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
    6.23 - * particular file as subject to the "Classpath" exception as provided
    6.24 - * by Oracle in the GPL Version 2 section of the License file that
    6.25 - * accompanied this code. If applicable, add the following below the
    6.26 - * License Header, with the fields enclosed by brackets [] replaced by
    6.27 - * your own identifying information:
    6.28 - * "Portions Copyrighted [year] [name of copyright owner]"
    6.29 - *
    6.30 - * Contributor(s):
    6.31 - *
    6.32 - * The Original Software is NetBeans. The Initial Developer of the Original
    6.33 - * Software is Oracle. Portions Copyright 2013-2014 Oracle. All Rights Reserved.
    6.34 - *
    6.35 - * If you wish your version of this file to be governed by only the CDDL
    6.36 - * or only the GPL Version 2, indicate your decision by adding
    6.37 - * "[Contributor] elects to include this software in this distribution
    6.38 - * under the [CDDL or GPL Version 2] license." If you do not indicate a
    6.39 - * single choice of license, a recipient has the option to distribute
    6.40 - * your version of this file under either the CDDL, the GPL Version 2 or
    6.41 - * to extend the choice of license to its licensees as provided above.
    6.42 - * However, if you add GPL Version 2 code and therefore, elected the GPL
    6.43 - * Version 2 license, then the option applies only if the new code is
    6.44 - * made subject to such option by the copyright holder.
    6.45 - */
    6.46 -package org.netbeans.html.boot.fx;
    6.47 -
    6.48 -import java.lang.annotation.Annotation;
    6.49 -import java.lang.reflect.Method;
    6.50 -import java.util.ArrayList;
    6.51 -import java.util.List;
    6.52 -import java.util.concurrent.Executors;
    6.53 -import net.java.html.BrwsrCtx;
    6.54 -import net.java.html.boot.BrowserBuilder;
    6.55 -import org.netbeans.html.boot.spi.Fn;
    6.56 -import org.netbeans.html.context.spi.Contexts;
    6.57 -import org.netbeans.html.json.tck.KOTest;
    6.58 -import org.openide.util.lookup.ServiceProvider;
    6.59 -import org.testng.Assert;
    6.60 -import static org.testng.Assert.assertNotSame;
    6.61 -import static org.testng.Assert.assertSame;
    6.62 -import static org.testng.Assert.assertTrue;
    6.63 -import org.testng.annotations.Factory;
    6.64 -
    6.65 -/**
    6.66 - *
    6.67 - * @author Jaroslav Tulach
    6.68 - */
    6.69 -public class BootstrapTest {
    6.70 -    private static Class<?> browserClass;
    6.71 -    private static Fn.Presenter browserPresenter;
    6.72 -    
    6.73 -    public BootstrapTest() {
    6.74 -    }
    6.75 -
    6.76 -    @Factory public static Object[] compatibilityTests() throws Exception {
    6.77 -        final BrowserBuilder bb = BrowserBuilder.newBrowser().loadClass(BootstrapTest.class).
    6.78 -            loadPage("empty.html").
    6.79 -            invoke("initialized");
    6.80 -
    6.81 -        Executors.newSingleThreadExecutor().submit(new Runnable() {
    6.82 -            @Override
    6.83 -            public void run() {
    6.84 -                bb.showAndWait();
    6.85 -            }
    6.86 -        });
    6.87 -
    6.88 -        List<Object> res = new ArrayList<Object>();
    6.89 -        Class<? extends Annotation> test = 
    6.90 -            loadClass().getClassLoader().loadClass(KOTest.class.getName()).
    6.91 -            asSubclass(Annotation.class);
    6.92 -
    6.93 -        Class[] arr = (Class[]) loadClass().getDeclaredMethod("tests").invoke(null);
    6.94 -        for (Class c : arr) {
    6.95 -            for (Method m : c.getMethods()) {
    6.96 -                if (m.getAnnotation(test) != null) {
    6.97 -                    res.add(new KOFx(browserPresenter, m));
    6.98 -                }
    6.99 -            }
   6.100 -        }
   6.101 -        return res.toArray();
   6.102 -    }
   6.103 -
   6.104 -    static synchronized Class<?> loadClass() throws InterruptedException {
   6.105 -        while (browserClass == null) {
   6.106 -            BootstrapTest.class.wait();
   6.107 -        }
   6.108 -        return browserClass;
   6.109 -    }
   6.110 -    
   6.111 -    public static synchronized void ready(Class<?> browserCls) throws Exception {
   6.112 -        browserClass = browserCls;
   6.113 -        browserPresenter = Fn.activePresenter();
   6.114 -        BootstrapTest.class.notifyAll();
   6.115 -    }
   6.116 -    
   6.117 -    public static void initialized() throws Exception {
   6.118 -        BrwsrCtx b1 = BrwsrCtx.findDefault(BootstrapTest.class);
   6.119 -        TestingProvider.assertCalled("Our context created");
   6.120 -        assertNotSame(b1, BrwsrCtx.EMPTY, "Browser context is not empty");
   6.121 -        BrwsrCtx b2 = BrwsrCtx.findDefault(BootstrapTest.class);
   6.122 -        assertSame(b1, b2, "Browser context remains stable");
   6.123 -        Assert.assertSame(
   6.124 -            BootstrapTest.class.getClassLoader(),
   6.125 -            ClassLoader.getSystemClassLoader(),
   6.126 -            "No special classloaders"
   6.127 -        );
   6.128 -        BootstrapTest.ready(FxJavaScriptTst.class);
   6.129 -    }
   6.130 -}
     7.1 --- a/boot/pom.xml	Thu Nov 20 14:59:04 2014 +0100
     7.2 +++ b/boot/pom.xml	Sat Nov 29 22:25:40 2014 +0100
     7.3 @@ -36,6 +36,8 @@
     7.4        <groupId>org.ow2.asm</groupId>
     7.5        <artifactId>asm</artifactId>
     7.6        <type>jar</type>
     7.7 +      <scope>provided</scope>
     7.8 +      <optional>true</optional>
     7.9      </dependency>
    7.10      <dependency>
    7.11        <groupId>org.testng</groupId>
     8.1 --- a/boot/src/main/java/net/java/html/boot/BrowserBuilder.java	Thu Nov 20 14:59:04 2014 +0100
     8.2 +++ b/boot/src/main/java/net/java/html/boot/BrowserBuilder.java	Sat Nov 29 22:25:40 2014 +0100
     8.3 @@ -273,13 +273,16 @@
     8.4          
     8.5          final ClassLoader activeLoader;
     8.6          if (loader != null) {
     8.7 -            if (!FnUtils.isJavaScriptCapable(loader)) {
     8.8 +            if (!FnContext.isJavaScriptCapable(loader)) {
     8.9                  throw new IllegalStateException("Loader cannot resolve @JavaScriptBody: " + loader);
    8.10              }
    8.11              activeLoader = loader;
    8.12 -        } else if (FnUtils.isJavaScriptCapable(myCls.getClassLoader())) {
    8.13 +        } else if (FnContext.isJavaScriptCapable(myCls.getClassLoader())) {
    8.14              activeLoader = myCls.getClassLoader();
    8.15          } else {
    8.16 +            if (!FnContext.isAsmPresent()) {
    8.17 +                throw new IllegalStateException("Cannot find asm-5.0.jar classes!");
    8.18 +            }
    8.19              FImpl impl = new FImpl(myCls.getClassLoader());
    8.20              activeLoader = FnUtils.newLoader(impl, dfnr, myCls.getClassLoader().getParent());
    8.21          }
     9.1 --- a/boot/src/main/java/net/java/html/js/package.html	Thu Nov 20 14:59:04 2014 +0100
     9.2 +++ b/boot/src/main/java/net/java/html/js/package.html	Sat Nov 29 22:25:40 2014 +0100
     9.3 @@ -231,6 +231,7 @@
     9.4          calls or changes on it.
     9.5          
     9.6          <h3>Post Process Classes</h3>
     9.7 +        <a name="post-process"></a>
     9.8  
     9.9          Classes with {@link net.java.html.js.JavaScriptBody} annotated methods need to
    9.10          be post processed before they can be used - e.g. their <code>native</code>
    9.11 @@ -290,7 +291,9 @@
    9.12          will create a special classloader to that does the processing before
    9.13          loading the bytecode into the virtual machine.
    9.14          <p></p>
    9.15 -        The options are rich, however to avoid any troubles, it is recommended
    9.16 +        The options are rich, however to avoid any troubles (as the runtime
    9.17 +        processing needs to also include <code>asm-5.0.jar</code> on application
    9.18 +        classpath), it is recommended
    9.19          to perform the <b>compile time</b> processing.
    9.20          
    9.21          <h3>Getting Started</h3>
    10.1 --- a/boot/src/main/java/org/netbeans/html/boot/impl/FnContext.java	Thu Nov 20 14:59:04 2014 +0100
    10.2 +++ b/boot/src/main/java/org/netbeans/html/boot/impl/FnContext.java	Sat Nov 29 22:25:40 2014 +0100
    10.3 @@ -45,8 +45,10 @@
    10.4  import java.io.Closeable;
    10.5  import java.io.Flushable;
    10.6  import java.io.IOException;
    10.7 +import java.util.logging.Level;
    10.8  import java.util.logging.Logger;
    10.9  import org.netbeans.html.boot.spi.Fn;
   10.10 +import org.objectweb.asm.Opcodes;
   10.11  
   10.12  /**
   10.13   *
   10.14 @@ -60,6 +62,33 @@
   10.15          DUMMY.prev = DUMMY;
   10.16      }
   10.17  
   10.18 +    public static boolean isJavaScriptCapable(ClassLoader l) {
   10.19 +        if (l instanceof JsClassLoader) {
   10.20 +            return true;
   10.21 +        }
   10.22 +        if (l.getResource("META-INF/net.java.html.js.classes") != null) {
   10.23 +            return false;
   10.24 +        }
   10.25 +        return true;
   10.26 +    }
   10.27 +
   10.28 +    public static boolean isAsmPresent() {
   10.29 +        Throwable t;
   10.30 +        try {
   10.31 +            Class.forName(Opcodes.class.getName());
   10.32 +            return true;
   10.33 +        } catch (LinkageError ex) {
   10.34 +            t = ex;
   10.35 +        } catch (ClassNotFoundException ex) {
   10.36 +            t = ex;
   10.37 +        }
   10.38 +        LOG.log(Level.SEVERE, "When using @JavaScriptBody methods, one needs to either:");
   10.39 +        LOG.log(Level.SEVERE, " - include asm-5.0.jar on runtime classpath");
   10.40 +        LOG.log(Level.SEVERE, " - post process classes, see http://bits.netbeans.org/html+java/dev/net/java/html/js/package-summary.html#post-process");
   10.41 +        LOG.log(Level.SEVERE, "Cannot initialize asm-5.0.jar!", t);
   10.42 +        return false;
   10.43 +    }
   10.44 +
   10.45      private Object prev;
   10.46      private final Fn.Presenter current;
   10.47      private FnContext(Fn.Presenter prevP, Fn.Presenter newP) {
    11.1 --- a/boot/src/main/java/org/netbeans/html/boot/impl/FnUtils.java	Thu Nov 20 14:59:04 2014 +0100
    11.2 +++ b/boot/src/main/java/org/netbeans/html/boot/impl/FnUtils.java	Sat Nov 29 22:25:40 2014 +0100
    11.3 @@ -108,16 +108,6 @@
    11.4          return bytecode;
    11.5      }
    11.6      
    11.7 -    public static boolean isJavaScriptCapable(ClassLoader l) {
    11.8 -        if (l instanceof JsClassLoader) {
    11.9 -            return true;
   11.10 -        }
   11.11 -        if (l.getResource("META-INF/net.java.html.js.classes") != null) {
   11.12 -            return false;
   11.13 -        }
   11.14 -        return true;
   11.15 -    }
   11.16 -    
   11.17      public static boolean isValid(Fn fn) {
   11.18          return fn != null && fn.isValid();
   11.19      }
    12.1 --- a/pom.xml	Thu Nov 20 14:59:04 2014 +0100
    12.2 +++ b/pom.xml	Sat Nov 29 22:25:40 2014 +0100
    12.3 @@ -34,6 +34,7 @@
    12.4      <module>ko-osgi-test</module>
    12.5      <module>equinox-agentclass-hook</module>
    12.6      <module>boot-script</module>
    12.7 +    <module>boot-agent-test</module>
    12.8    </modules>
    12.9    <licenses>
   12.10        <license>
   12.11 @@ -245,7 +246,7 @@
   12.12          <dependency>
   12.13              <groupId>org.ow2.asm</groupId>
   12.14              <artifactId>asm</artifactId>
   12.15 -            <version>4.1</version>
   12.16 +            <version>5.0</version>
   12.17          </dependency>
   12.18          <dependency>
   12.19            <groupId>org.netbeans.api</groupId>