https://issues.apache.org/bugzilla/show_bug.cgi?id=52096

Jesse Glick <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #8 from Jesse Glick <[email protected]> 2011-10-28 14:39:55 UTC 
---
A fix for the originally stated problem would be for lookForPackageInfos to
read the actual "package com.apache.test1;" line in package-info.java, as javac
itself would. One reason the code does not already do this is out of concern
over handling of non-ASCII characters in the package name and potential
interaction with the filesystem. But I suppose it would work to just read
package-info.java using the same encoding being passed to javac.

Additionally, it is just easier to strip off a path prefix than to parse a
general source file including comments, annotations, and/or import statements.
In practice, it is overwhelmingly likely that the package statement is on a
line by itself, and that there is not something that looks like a package
statement inside a block comment. There must be exactly one package statement
in a package-info.java, so it would almost always suffice to look for lines of
the form

^\s*package\s+(\p{javaJavaIdentifierStart}\p{javaJavaIdentifierPart}*(?:[.]\p{javaJavaIdentifierStart}\p{javaJavaIdentifierPart}*)*)\s*;\s*$

and use \1 if exactly one such is found, falling back to the current logic
otherwise. This would only be fooled by pathological cases such as

/*
package fake;
*/
package
real;

or the use of \uXXXX escapes.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

Reply via email to