Closed roipoussiere closed 8 years ago
I believe the current behavior is more correct in this case. The Java Language Specification states that classes without a package declaration are placed in an unnamed packaged, rather than a default package. Additionally, the current behavior mirrors Class#getPackage()
which returns null
for classes in an unnamed package.
Would you mind opening an issue against Javasphinx instead? I think it would be better to have it handle the unnamed packages explicitly.
Ok.
If a file doesn't contain package declaration, a package is actually created, with the name
default package
.The problem initially comes from here : I wanted to parse the test directory of a project but my test files didn't have package declaration, resulting a value Error.
I decided to PR on Javalang because in my opinion, set package to
None
is wrong, since every Java class have actually a package, although it can be unnamed.Note: after merging this PR and release a new version, this test should be deleted on Javasphinx.