1.1 --- a/netbinox/manifest.mf Wed Mar 09 16:13:17 2011 +0100
1.2 +++ b/netbinox/manifest.mf Wed Apr 06 11:32:27 2011 +0200
1.3 @@ -1,7 +1,7 @@
1.4 Manifest-Version: 1.0
1.5 OpenIDE-Module: org.apidesign.netbinox
1.6 OpenIDE-Module-Localizing-Bundle: org/apidesign/netbinox/Bundle.properties
1.7 -OpenIDE-Module-Specification-Version: 1.20
1.8 +OpenIDE-Module-Specification-Version: 1.21
1.9 OpenIDE-Module-Provides: org.osgi.framework.launch.FrameworkFactory
1.10 OpenIDE-Module-Hide-Classpath-Packages: org.eclipse.core.runtime.**,org.eclipse.osgi.**
1.11 Covered-Packages: META-INF,,org.apidesign.netbinox,
2.1 --- a/netbinox/src/org/apidesign/netbinox/NetbinoxHooks.java Wed Mar 09 16:13:17 2011 +0100
2.2 +++ b/netbinox/src/org/apidesign/netbinox/NetbinoxHooks.java Wed Apr 06 11:32:27 2011 +0200
2.3 @@ -43,7 +43,6 @@
2.4 import org.eclipse.osgi.baseadaptor.loader.BaseClassLoader;
2.5 import org.eclipse.osgi.baseadaptor.loader.ClasspathEntry;
2.6 import org.eclipse.osgi.baseadaptor.loader.ClasspathManager;
2.7 -import org.eclipse.osgi.framework.adaptor.BundleClassLoader;
2.8 import org.eclipse.osgi.framework.adaptor.BundleData;
2.9 import org.eclipse.osgi.framework.adaptor.BundleProtectionDomain;
2.10 import org.eclipse.osgi.framework.adaptor.ClassLoaderDelegate;
2.11 @@ -95,7 +94,7 @@
2.12 }
2.13
2.14 public String findLibrary(BaseData bd, String string) {
2.15 - return string;
2.16 + return null;
2.17 }
2.18
2.19 public ClassLoader getBundleClassLoaderParent() {
3.1 --- a/netbinox/test/unit/data/jars/activate/org/activate/Main.java Wed Mar 09 16:13:17 2011 +0100
3.2 +++ b/netbinox/test/unit/data/jars/activate/org/activate/Main.java Wed Apr 06 11:32:27 2011 +0200
3.3 @@ -32,6 +32,17 @@
3.4 throw new IllegalStateException(t);
3.5 }
3.6 LOG.info("start finished");
3.7 +
3.8 + String lib = System.getProperty("activated.library");
3.9 + if (lib != null) {
3.10 + try {
3.11 + System.loadLibrary(lib);
3.12 + throw new IllegalStateException("Library " + lib + " should not be available");
3.13 + } catch (UnsatisfiedLinkError ex) {
3.14 + System.setProperty("activated.library", ex.getMessage());
3.15 + }
3.16 + }
3.17 +
3.18
3.19 String seekFor = System.getProperty("activated.checkentries");
3.20 if (seekFor != null) {
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/netbinox/test/unit/src/org/apidesign/netbinox/NetbinoxLibraryTest.java Wed Apr 06 11:32:27 2011 +0200
4.3 @@ -0,0 +1,121 @@
4.4 +/*
4.5 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4.6 + *
4.7 + * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
4.8 + *
4.9 + * The contents of this file are subject to the terms of either the GNU
4.10 + * General Public License Version 2 only ("GPL") or the Common
4.11 + * Development and Distribution License("CDDL") (collectively, the
4.12 + * "License"). You may not use this file except in compliance with the
4.13 + * License. You can obtain a copy of the License at
4.14 + * http://www.netbeans.org/cddl-gplv2.html
4.15 + * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
4.16 + * specific language governing permissions and limitations under the
4.17 + * License. When distributing the software, include this License Header
4.18 + * Notice in each file and include the License file at
4.19 + * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
4.20 + * particular file as subject to the "Classpath" exception as provided
4.21 + * by Sun in the GPL Version 2 section of the License file that
4.22 + * accompanied this code. If applicable, add the following below the
4.23 + * License Header, with the fields enclosed by brackets [] replaced by
4.24 + * your own identifying information:
4.25 + * "Portions Copyrighted [year] [name of copyright owner]"
4.26 + *
4.27 + * Contributor(s):
4.28 + *
4.29 + * The Original Software is NetBeans. The Initial Developer of the Original
4.30 + * Software is Sun Microsystems, Inc. Portions Copyright 1997-2008 Sun
4.31 + * Microsystems, Inc. All Rights Reserved.
4.32 + *
4.33 + * If you wish your version of this file to be governed by only the CDDL
4.34 + * or only the GPL Version 2, indicate your decision by adding
4.35 + * "[Contributor] elects to include this software in this distribution
4.36 + * under the [CDDL or GPL Version 2] license." If you do not indicate a
4.37 + * single choice of license, a recipient has the option to distribute
4.38 + * your version of this file under either the CDDL, the GPL Version 2 or
4.39 + * to extend the choice of license to its licensees as provided above.
4.40 + * However, if you add GPL Version 2 code and therefore, elected the GPL
4.41 + * Version 2 license, then the option applies only if the new code is
4.42 + * made subject to such option by the copyright holder.
4.43 + */
4.44 +
4.45 +package org.apidesign.netbinox;
4.46 +
4.47 +import java.util.Enumeration;
4.48 +import org.eclipse.osgi.baseadaptor.bundlefile.BundleEntry;
4.49 +import org.eclipse.osgi.baseadaptor.bundlefile.BundleFile;
4.50 +import org.netbeans.core.startup.*;
4.51 +import java.io.File;
4.52 +import java.io.IOException;
4.53 +import java.net.URL;
4.54 +import java.util.Locale;
4.55 +import org.eclipse.osgi.baseadaptor.BaseData;
4.56 +import org.eclipse.osgi.framework.adaptor.BundleData;
4.57 +import org.eclipse.osgi.framework.internal.core.AbstractBundle;
4.58 +import org.netbeans.Module;
4.59 +import org.netbeans.ModuleManager;
4.60 +import org.netbeans.SetupHid;
4.61 +import org.osgi.framework.Bundle;
4.62 +import org.osgi.framework.BundleContext;
4.63 +
4.64 +/**
4.65 + * Is loading of libraries OK?
4.66 + *
4.67 + * @author Jaroslav Tulach
4.68 + */
4.69 +public class NetbinoxLibraryTest extends SetupHid {
4.70 + private static Module m1;
4.71 + private static ModuleManager mgr;
4.72 +
4.73 + public NetbinoxLibraryTest(String name) {
4.74 + super(name);
4.75 + }
4.76 +
4.77 + protected @Override void setUp() throws Exception {
4.78 + Locale.setDefault(Locale.US);
4.79 + clearWorkDir();
4.80 + File ud = new File(getWorkDir(), "ud");
4.81 + ud.mkdirs();
4.82 + System.setProperty("netbeans.user", ud.getPath());
4.83 +
4.84 + data = new File(getDataDir(), "jars");
4.85 + jars = new File(getWorkDir(), "space in path");
4.86 + jars.mkdirs();
4.87 + File simpleModule = createTestJAR("activate", null);
4.88 + }
4.89 +
4.90 + public void testActivation() throws Exception {
4.91 + ModuleSystem ms = Main.getModuleSystem();
4.92 + mgr = ms.getManager();
4.93 + mgr.mutexPrivileged().enterWriteAccess();
4.94 + Enumeration en;
4.95 + int checks = 0;
4.96 + try {
4.97 + System.setProperty("activated.library", "does.not.exist");
4.98 +
4.99 + File simpleModule = new File(jars, "activate.jar");
4.100 + m1 = mgr.create(simpleModule, null, false, false, false);
4.101 + mgr.enable(m1);
4.102 +
4.103 + Class<?> main = m1.getClassLoader().loadClass("org.activate.Main");
4.104 + Object s = main.getField("start").get(null);
4.105 + assertNotNull("Bundle started, its context provided", s);
4.106 +
4.107 + String err = System.getProperty("activated.library");
4.108 + // the error is taken from ClassLoader.loadLibrary
4.109 + if (err == null || err.indexOf("in java.library.path") == -1) {
4.110 + fail("The make sure the ClassLoader.findLibrary returns null: " + err);
4.111 + }
4.112 +
4.113 + mgr.disable(m1);
4.114 +
4.115 + Object e = main.getField("stop").get(null);
4.116 + assertNotNull("Bundle stopped, its context provided", e);
4.117 + } finally {
4.118 + mgr.mutexPrivileged().exitWriteAccess();
4.119 + }
4.120 + }
4.121 + private File createTestJAR(String name, String srcdir, File... classpath) throws IOException {
4.122 + return createTestJAR(data, jars, name, srcdir, classpath);
4.123 + }
4.124 +}