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.

Bug 180646 - java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0 * ^
Summary: java.util.regex.PatternSyntaxException: Dangling meta character '*' near inde...
Status: RESOLVED FIXED
Alias: None
Product: apisupport
Classification: Unclassified
Component: Maven (show other bugs)
Version: 6.x
Hardware: All All
: P2 normal (vote)
Assignee: David Simonek
URL:
Keywords: NETFIX
Depends on:
Blocks:
 
Reported: 2010-02-12 01:28 UTC by Tomas Danek
Modified: 2010-05-13 05:07 UTC (History)
7 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 165175


Attachments
stacktrace (2.28 KB, text/plain)
2010-02-12 01:28 UTC, Tomas Danek
Details
stacktrace (2.28 KB, text/plain)
2010-02-12 06:17 UTC, Tomas Danek
Details
stacktrace (7.93 KB, text/plain)
2010-02-27 10:49 UTC, Michal Mocnak
Details
stacktrace (6.99 KB, text/plain)
2010-02-27 14:30 UTC, Michal Mocnak
Details
stacktrace (3.44 KB, text/plain)
2010-03-05 16:49 UTC, asmotrich
Details
stacktrace (6.99 KB, text/plain)
2010-03-27 01:39 UTC, Exceptions Reporter
Details
stacktrace (6.95 KB, text/plain)
2010-04-13 12:13 UTC, Tomas Danek
Details
<no description> (12.29 KB, patch)
2010-05-03 23:48 UTC, johnsonlau
Details | Diff
stacktrace (8.60 KB, text/plain)
2010-05-05 15:32 UTC, Kenneth Ganfield
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tomas Danek 2010-02-12 01:28:48 UTC
Build: NetBeans IDE Dev (Build 201002110200)
VM: Java HotSpot(TM) 64-Bit Server VM, 14.3-b01-101, Java(TM) SE Runtime Environment, 1.6.0_17-b04-248-10M3025
OS: Mac OS X

User Comments:
musilt2: created new class via popup on package




Stacktrace: 
java.util.regex.PatternSyntaxException: Dangling meta character '*' near index 0
*
^
   at java.util.regex.Pattern.error(Pattern.java:1713)
   at java.util.regex.Pattern.sequence(Pattern.java:1878)
   at java.util.regex.Pattern.expr(Pattern.java:1752)
   at java.util.regex.Pattern.compile(Pattern.java:1460)
   at java.util.regex.Pattern.<init>(Pattern.java:1133)
   at java.util.regex.Pattern.compile(Pattern.java:823)
Comment 1 Tomas Danek 2010-02-12 01:28:51 UTC
Created attachment 94108 [details]
stacktrace
Comment 2 Tomas Danek 2010-02-12 06:17:40 UTC
Created attachment 94116 [details]
stacktrace
Comment 3 Michal Mocnak 2010-02-27 10:49:05 UTC
Created attachment 94593 [details]
stacktrace

trying to refactor move class
Comment 4 Michal Mocnak 2010-02-27 14:30:10 UTC
Created attachment 94597 [details]
stacktrace
Comment 5 Exceptions Reporter 2010-03-05 16:42:27 UTC
This bug already has 5 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=165175
Comment 6 asmotrich 2010-03-05 16:49:27 UTC
Created attachment 94820 [details]
stacktrace
Comment 7 Exceptions Reporter 2010-03-27 01:39:33 UTC
Created attachment 96039 [details]
stacktrace
Comment 8 Tomas Danek 2010-04-13 12:13:39 UTC
Created attachment 97175 [details]
stacktrace

Tried to create class in newly created package. maven osgi bundle project.
Comment 9 Exceptions Reporter 2010-04-22 16:52:50 UTC
This bug already has 10 duplicates 
see http://statistics.netbeans.org/exceptions/detail.do?id=165175
Comment 10 johnsonlau 2010-05-03 23:47:54 UTC
The exception shows because of a wrong parsing on Export-Package and Import-Package.
There is no conversion from wildcard character to regular expression syntax for the only "*".
When you specify "*" in either Export-Package or Import-Package,
the RegExp doesn't accept "*" as an argument, and the exception shows.

I don't think it is a good reason to use regexp here,
since maven-bundle-plugin test the patterns with a very simply wildcard matching logic,
and several illegal syntax in regexp should be prevented or this exception could still pop-ups.

According to Bnd and maven-bundle-plugin documentation,
the settings of Export-Package may contains some directives or even quoted strings,
which will bring an extra "," in the directives (Suppose a org.netbeans.*:uses=("org.netbeans.A,org.netbeans.B"),
and certainly it would cause a wrong parse result.
Also, "!" is accpeted by Bnd to specificy an exclusion pattern (only if it matches to the pattern).

I changed the regexp based logic to use a startWith on recursive or equals call for pattern matching.
All directives would be omitted before the test.

Hope it will help.
Comment 11 johnsonlau 2010-05-03 23:48:03 UTC
Created attachment 98405 [details]
<no description>
Comment 12 Tomas Danek 2010-05-04 11:40:19 UTC
thanks for patch, reassigning to someone who can/will (hopefully) review.
Comment 13 Kenneth Ganfield 2010-05-05 15:32:25 UTC
Created attachment 98499 [details]
stacktrace

opening the new file wizard
Comment 14 Kenneth Ganfield 2010-05-06 08:29:23 UTC
for some reason this is causing errors when i deploy the bundle to glassfish.

If i create a bundle with an activator and use the Properties to set the Export Packages, the IDE adds the following to the pom

<Private-Package>*</Private-Package>

When i deploy the bundle i get an error

INFO: Error while starting bundle: file:/Applications/NetBeans/glassfish-3.0.1-b16/glassfish/modules/autostart/MavenHelloService-1.0-SNAPSHOT.jar: org.osgi.framework.BundleException: Activator start error in bundle com.mycompany.MavenHelloService [230].
INFO: org.osgi.framework.BundleException: Activator start error in bundle com.mycompany.MavenHelloService [230].

...

Caused by: java.lang.ClassCastException: com.mycompany.mavenhelloservice.Installer cannot be cast to org.osgi.framework.BundleActivator

If i comment out the Private-Package element the bundle deploys and starts without problem
Comment 15 David Simonek 2010-05-11 09:39:09 UTC
johnsonlau thanks a lot for the patch, reviewing...
Comment 16 David Simonek 2010-05-11 12:25:42 UTC
Reviewed, code seems OK to me and confirmed it works, exception is no more appearing. Integrated as change set df72495c7546, big thanks.
Comment 17 johnsonlau 2010-05-11 15:58:53 UTC
(In reply to comment #16)
> Reviewed, code seems OK to me and confirmed it works, exception is no more
> appearing. Integrated as change set df72495c7546, big thanks.

Just found some other things that might need to be fixed also.

FelixExportPersister does the same way parsing Bnd setting.
It might lead to an expected output of exported packages in the project properties window.
Should it be open as a new bug or just a further modification on this issue?
Comment 18 David Simonek 2010-05-11 16:58:23 UTC
As new bug, thanks.
Comment 19 Quality Engineering 2010-05-13 05:07:32 UTC
Integrated into 'main-golden', will be available in build *201005122200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/
User: 
Log: