Martin's Tex-Blog

Posts on programming and generally technical topics

Archive for the ‘Java’ Category

Classes from unnamed (default) package is not visible from class in named package

leave a comment »


Well, this is a well known fact for around 10 years now, but I got trapped into compilation error involving this “feature” recently. Here is more detailed explanation:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4361575

to make this story short – always remember to put your classes into packages, and never try to use class from unnamed package from within named package class, compiler will not give you meaningful error notice.

This is only valid for compilers from 1.4 and up. If you have some older class files which were in unnamed package then they are no longer usable – unless you have sources.  Well – actually there is a method, use reflection API.

Advertisement

Written by Marcin

April 10, 2010 at 10:16 pm

Posted in Java, SCJP