This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 186000
Collapse All | Expand All

(-)a/o.n.bootstrap/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.bootstrap/1
2
OpenIDE-Module: org.netbeans.bootstrap/1
3
OpenIDE-Module-Specification-Version: 2.32
3
OpenIDE-Module-Specification-Version: 2.33
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/Bundle.properties
5
OpenIDE-Module-Recommends: org.netbeans.NetigsoFramework
5
OpenIDE-Module-Recommends: org.netbeans.NetigsoFramework
6
6
(-)a/o.n.bootstrap/src/org/netbeans/StandardModule.java (-9 / +23 lines)
Lines 1-7 Link Here
1
/*
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
3
 *
4
 * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved.
4
 * Copyright 1997-2010 Sun Microsystems, Inc. All rights reserved.
5
 *
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
7
 * General Public License Version 2 only ("GPL") or the Common
Lines 674-680 Link Here
674
    /** Class loader to load a single module.
674
    /** Class loader to load a single module.
675
     * Auto-localizing, multi-parented, permission-granting, the works.
675
     * Auto-localizing, multi-parented, permission-granting, the works.
676
     */
676
     */
677
    private class OneModuleClassLoader extends JarClassLoader implements Util.ModuleProvider {
677
    class OneModuleClassLoader extends JarClassLoader implements Util.ModuleProvider {
678
        private int rc;
678
        private int rc;
679
        /** Create a new loader for a module.
679
        /** Create a new loader for a module.
680
         * @param classp the List of all module jars of code directories;
680
         * @param classp the List of all module jars of code directories;
Lines 700-714 Link Here
700
            return getAllPermission();
700
            return getAllPermission();
701
        }
701
        }
702
        
702
        
703
        /** look for JNI libraries also in modules/bin/ */
703
        /**
704
         * Look up a native library as described in modules documentation.
705
         * @see http://bits.netbeans.org/dev/javadoc/org-openide-modules/org/openide/modules/doc-files/api.html#jni
706
         */
704
        protected @Override String findLibrary(String libname) {
707
        protected @Override String findLibrary(String libname) {
708
            String arch = System.getProperty("os.arch"); // NOI18N
709
            String system = System.getProperty("os.name").toLowerCase(); // NOI18N
705
            String mapped = System.mapLibraryName(libname);
710
            String mapped = System.mapLibraryName(libname);
706
            File lib = new File(new File(jar.getParentFile(), "lib"), mapped); // NOI18N
711
707
            if (lib.isFile()) {
712
            File base = new File(jar.getParentFile(), "lib"); // NOI18N
708
                return lib.getAbsolutePath();
713
            File archFile = new File(base, arch);
709
            } else {
714
            File systemFile = new File(archFile, system);
710
                return null;
715
711
            }
716
            File lib = new File(systemFile, mapped);
717
            if (lib.isFile()) return lib.getAbsolutePath();
718
719
            lib = new File(archFile, mapped);
720
            if (lib.isFile()) return lib.getAbsolutePath();
721
722
            lib = new File(base, mapped);
723
            if (lib.isFile()) return lib.getAbsolutePath();
724
725
            return null;
712
        }
726
        }
713
727
714
        protected @Override boolean shouldDelegateResource(String pkg, ClassLoader parent) {
728
        protected @Override boolean shouldDelegateResource(String pkg, ClassLoader parent) {
(-)87162b13ea2c (+147 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 * 
4
 * Copyright 1997-2010 Sun Microsystems, Inc. All rights reserved.
5
 * 
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 * 
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 * 
35
 * Contributor(s):
36
 * 
37
 * Portions Copyrighted 2010 Sun Microsystems, Inc.
38
 */
39
40
package org.netbeans;
41
42
import java.io.File;
43
import java.io.IOException;
44
import java.util.HashMap;
45
import java.util.Map;
46
import org.netbeans.junit.NbTestCase;
47
48
/**
49
 * A test covering native library lookup mechanism.
50
 * @see http://bits.netbeans.org/dev/javadoc/org-openide-modules/org/openide/modules/doc-files/api.html#jni
51
 *
52
 * @author Petr Nejedly <pnejedly@netbeans.org>
53
 */
54
public class NativeLibraryTest extends NbTestCase {
55
    private File userdir;
56
    private File ide;
57
    private File platform;
58
    private File install;
59
60
    private File jar;
61
    private Module module;
62
63
    File fullLib;
64
    File archLib;
65
    File commonLib;
66
    
67
    public NativeLibraryTest(String testName) {
68
        super(testName);
69
    }            
70
71
    @Override
72
    protected void setUp() throws Exception {
73
        clearWorkDir();
74
75
        String arch = System.getProperty("os.arch"); // NOI18N
76
        String system = System.getProperty("os.name").toLowerCase(); // NOI18N
77
78
        install = new File(getWorkDir(), "install");
79
        platform = new File(install, "platform");
80
        ide = new File(install, "ide");
81
        userdir = new File(getWorkDir(), "tmp");
82
        
83
        System.setProperty("netbeans.home", platform.getPath());
84
        System.setProperty("netbeans.dirs", ide.getPath());
85
        System.setProperty("netbeans.user", userdir.getPath());
86
        
87
        jar = createModule("org.openide.sample", platform,
88
            "OpenIDE-Module-Public-Packages", "-",
89
            "OpenIDE-Module", "org.openide.sample"
90
        );
91
92
        // now create 3 libraries, full, arch and common
93
        fullLib = createFakeLibrary(jar, arch, system, System.mapLibraryName("full"));
94
        archLib = createFakeLibrary(jar, arch, System.mapLibraryName("arch"));
95
        commonLib = createFakeLibrary(jar, arch, System.mapLibraryName("common"));
96
97
        MockModuleInstaller installer = new MockModuleInstaller();
98
        MockEvents ev = new MockEvents();
99
        ModuleManager mgr = new ModuleManager(installer, ev);
100
        mgr.mutexPrivileged().enterWriteAccess();
101
        module = mgr.create(jar, null, false, false, false);
102
        mgr.enable(module);
103
        mgr.mutexPrivileged().exitWriteAccess();
104
105
    }
106
    
107
    public void testLocateLibrary() {
108
        // testing 
109
        StandardModule.OneModuleClassLoader ldr = (StandardModule.OneModuleClassLoader)module.getClassLoader();
110
        assertEquals(fullLib.getAbsolutePath(), ldr.findLibrary("full"));
111
        assertEquals(archLib.getAbsolutePath(), ldr.findLibrary("arch"));
112
        assertEquals(commonLib.getAbsolutePath(), ldr.findLibrary("common"));
113
        assertNull(ldr.findLibrary("none"));
114
    }
115
116
    private File createFakeLibrary(File jar, String... path) throws IOException {
117
        File out = new File(jar.getParentFile(), "lib");
118
        for(String component : path) out = new File(out, component);
119
120
        // prepare the path
121
        out.getParentFile().mkdirs();
122
123
        out.createNewFile();
124
        return out;
125
    }
126
127
128
    private File createModule(String cnb, File cluster, String... attr) throws IOException {
129
        String dashes = cnb.replace('.', '-');
130
        
131
        File tmp = new File(new File(cluster, "modules"), dashes + ".jar");
132
133
        Map<String,String> attribs = new HashMap<String, String>();
134
        for (int i = 0; i < attr.length; i += 2) {
135
            attribs.put(attr[i], attr[i + 1]);
136
        }
137
138
        Map<String,String> files = new HashMap<String, String>();
139
        files.put("fake/" + cnb, cnb);
140
141
        tmp.getParentFile().mkdirs();
142
        SetupHid.createJar(tmp, files, attribs);
143
144
        return tmp;
145
    }
146
147
}

Return to bug 186000