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 188686
Collapse All | Expand All

(-)a/openide.modules/apichanges.xml (+17 lines)
Lines 50-55 Link Here
50
  	<apidef name="modules">Modules API</apidef>
50
  	<apidef name="modules">Modules API</apidef>
51
  </apidefs>
51
  </apidefs>
52
<changes>
52
<changes>
53
    <change id="Allow.Keywords">
54
        <api name="modules"/>
55
        <summary>Module names can contain java keywords</summary>
56
        <version major="7" minor="19"/>
57
        <date day="23" month="7" year="2010"/>
58
        <author login="jtulach"/>
59
        <compatibility semantic="compatible" modification="yes"/>
60
        <description>
61
            <p>
62
                Naming rules for module code name bases are now relaxed.
63
                The name of a module can contain a Java keyword like 
64
                <code>org.mysite.import.something</code>, etc.
65
            </p>
66
        </description>
67
        <class package="org.openide.modules" name="Dependency"/>
68
        <issue number="188686"/>
69
    </change>
53
    <change id="ClassLoader.findLibrary">
70
    <change id="ClassLoader.findLibrary">
54
        <api name="modules"/>
71
        <api name="modules"/>
55
        <summary>New native library lookup mechanism</summary>
72
        <summary>New native library lookup mechanism</summary>
(-)a/openide.modules/manifest.mf (-1 / +1 lines)
Lines 1-5 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.openide.modules
2
OpenIDE-Module: org.openide.modules
3
OpenIDE-Module-Localizing-Bundle: org/openide/modules/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/openide/modules/Bundle.properties
4
OpenIDE-Module-Specification-Version: 7.18
4
OpenIDE-Module-Specification-Version: 7.19
5
5
(-)a/openide.modules/src/org/openide/modules/Dependency.java (-2 / +22 lines)
Lines 203-215 Link Here
203
        }
203
        }
204
204
205
        boolean expectingPath = true;
205
        boolean expectingPath = true;
206
207
        while (tok.hasMoreTokens()) {
206
        while (tok.hasMoreTokens()) {
208
            if (expectingPath) {
207
            if (expectingPath) {
209
                expectingPath = false;
208
                expectingPath = false;
210
209
211
                String nt = tok.nextToken();
210
                String nt = tok.nextToken();
212
                if (!Utilities.isJavaIdentifier(nt) &&  !"enum".equals (nt)) { // NOI18N
211
                if (!isJavaIdentifierOrNumber(nt, true)) {
213
                    throw new IllegalArgumentException("Bad package component in " + base); // NOI18N
212
                    throw new IllegalArgumentException("Bad package component in " + base); // NOI18N
214
                }
213
                }
215
            } else {
214
            } else {
Lines 221-227 Link Here
221
            }
220
            }
222
        }
221
        }
223
    }
222
    }
223
    
224
    private static boolean isJavaIdentifierOrNumber(String id, boolean requireLetter) {
225
        if (id == null) {
226
            return false;
227
        }
224
228
229
        if (id.equals("")) {
230
            return false;
231
        }
232
        if (requireLetter) {
233
            if (!(java.lang.Character.isJavaIdentifierStart(id.charAt(0)))) {
234
                return false;
235
            }
236
        }
237
        for (int i = 0; i < id.length(); i++) {
238
            if (!(java.lang.Character.isJavaIdentifierPart(id.charAt(i)))) {
239
                return false;
240
            }
241
        }
242
        return true;
243
    }
244
    
225
    /** Parse dependencies from tags.
245
    /** Parse dependencies from tags.
226
    * @param type like Dependency.type
246
    * @param type like Dependency.type
227
    * @param body actual text of tag body; if <code>null</code>, returns nothing
247
    * @param body actual text of tag body; if <code>null</code>, returns nothing
(-)a/openide.modules/test/unit/src/org/openide/modules/DependencyTest.java (+22 lines)
Lines 58-63 Link Here
58
        super(name);
58
        super(name);
59
    }
59
    }
60
60
61
    public void testAllowJavaKeywordsInModuleNames() throws Exception {
62
        Set<Dependency> single = Dependency.create(Dependency.TYPE_MODULE, "acme.j2ee.webapp.import");
63
        assertEquals("One item created: " + single, 1, single.size());
64
    }
65
66
    public void testForNumbersInModuleNamesAreDisallowed() throws Exception {
67
        try {
68
            Set<Dependency> single = Dependency.create(Dependency.TYPE_MODULE, "acme.2.webapp.importing");
69
            fail("Shall throw an exception: " + single);
70
        } catch (IllegalArgumentException ex) {
71
            // fine
72
        }
73
    }
74
    public void testForNumbersInModuleNamesAreDisallowed2() throws Exception {
75
        try {
76
            Set<Dependency> single = Dependency.create(Dependency.TYPE_MODULE, "acme.2xyz.webapp.importing");
77
            fail("Shall throw an exception: " + single);
78
        } catch (IllegalArgumentException ex) {
79
            // fine
80
        }
81
    }
82
    
61
    public void testParseModule() throws Exception {
83
    public void testParseModule() throws Exception {
62
        Set singleton = Dependency.create(Dependency.TYPE_MODULE, "org.foo.bar/1 > 1.1");
84
        Set singleton = Dependency.create(Dependency.TYPE_MODULE, "org.foo.bar/1 > 1.1");
63
        assertTrue(singleton.size() == 1);
85
        assertTrue(singleton.size() == 1);

Return to bug 188686