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 (-24 / +6 lines)
Lines 51-56 Link Here
51
import java.util.Map;
51
import java.util.Map;
52
import java.util.Set;
52
import java.util.Set;
53
import java.util.StringTokenizer;
53
import java.util.StringTokenizer;
54
import java.util.regex.Pattern;
54
import org.openide.util.Utilities;
55
import org.openide.util.Utilities;
55
56
56
/** A dependency a module can have. Since version 7.10 this class is
57
/** A dependency a module can have. Since version 7.10 this class is
Lines 196-227 Link Here
196
        }
197
        }
197
198
198
        // Now check that the rest is a valid package.
199
        // Now check that the rest is a valid package.
199
        StringTokenizer tok = new StringTokenizer(base, ".", true); // NOI18N
200
        if (!FQN.matcher(base).matches()) {
200
201
            throw new IllegalArgumentException("Malformed dot-separated identifier: " + base);
201
        if ((tok.countTokens() % 2) == 0) {
202
            throw new NumberFormatException("Even number of pieces: " + base); // NOI18N
203
        }
204
205
        boolean expectingPath = true;
206
207
        while (tok.hasMoreTokens()) {
208
            if (expectingPath) {
209
                expectingPath = false;
210
211
                String nt = tok.nextToken();
212
                if (!Utilities.isJavaIdentifier(nt) &&  !"enum".equals (nt)) { // NOI18N
213
                    throw new IllegalArgumentException("Bad package component in " + base); // NOI18N
214
                }
215
            } else {
216
                if (!".".equals(tok.nextToken())) { // NOI18N
217
                    throw new NumberFormatException("Expected dot in code name: " + base); // NOI18N
218
                }
219
220
                expectingPath = true;
221
            }
222
        }
202
        }
223
    }
203
    }
224
204
    private static final String IDENTIFIER = "(?:\\p{javaJavaIdentifierStart}\\p{javaJavaIdentifierPart}*)"; // NOI18N
205
    private static final Pattern FQN = Pattern.compile(IDENTIFIER + "(?:[.]" + IDENTIFIER + ")*"); // NOI18N
206
    
225
    /** Parse dependencies from tags.
207
    /** Parse dependencies from tags.
226
    * @param type like Dependency.type
208
    * @param type like Dependency.type
227
    * @param body actual text of tag body; if <code>null</code>, returns nothing
209
    * @param body actual text of tag body; if <code>null</code>, returns nothing
(-)a/openide.modules/test/unit/src/org/openide/modules/DependencyTest.java (+10 lines)
Lines 137-142 Link Here
137
        assertEquals(Dependency.COMPARE_ANY, d2.getComparison());
137
        assertEquals(Dependency.COMPARE_ANY, d2.getComparison());
138
    }
138
    }
139
    
139
    
140
    public void testAllowJavaIdentifiers() throws Exception {
141
        Set<Dependency> single = Dependency.create(Dependency.TYPE_MODULE, "acme.j2ee.webapp.import");
142
        assertEquals("One item created: " + single, 1, single.size());
143
    }
144
140
    private void misparse(int type, String s) {
145
    private void misparse(int type, String s) {
141
        try {
146
        try {
142
            Dependency.create(type, s);
147
            Dependency.create(type, s);
Lines 222-227 Link Here
222
        misparse(Dependency.TYPE_JAVA, "Java > 1.4.0, Java = 1.4.0_01");
227
        misparse(Dependency.TYPE_JAVA, "Java > 1.4.0, Java = 1.4.0_01");
223
    }
228
    }
224
    
229
    
230
    public void testMisparseNumbers() throws Exception {
231
        misparse(Dependency.TYPE_MODULE, "acme.2.webapp.importing");
232
        misparse(Dependency.TYPE_MODULE, "acme.2xyz.webapp.importing");
233
    }
234
    
225
    public void testConstants() throws Exception {
235
    public void testConstants() throws Exception {
226
        assertEquals("Java", Dependency.JAVA_NAME);
236
        assertEquals("Java", Dependency.JAVA_NAME);
227
        assertNotNull(Dependency.JAVA_SPEC);
237
        assertNotNull(Dependency.JAVA_SPEC);

Return to bug 188686