Bug 11196 - ClassLoader does not produce an appropriate package name
Summary: ClassLoader does not produce an appropriate package name
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: 1.5
Hardware: Sun Solaris
: P3 normal with 1 vote (vote)
Target Milestone: 1.6
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-07-26 07:24 UTC by ariel backenroth
Modified: 2008-02-22 12:18 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ariel backenroth 2002-07-26 07:24:06 UTC
it seems the AntClassLoader does not correctly resolve the package name for a
class not loaded via the bootclasspath.

the particular case i am running involes a JUnit test case which attempts to
strip off the package name by doing:

Class oink = moo.cow.Piggy.class;
String oinkClassName = oink.getName();
String oinkPackageName = oink.getPackage().getName(); 
String classNameNoPackage = oinkClassName.substring(oinkPackageName + 1);

oink.getPackage() will return null.

the workaround is to have junit fork the jvm.  the forked jvm will return an
appropriate package name.

the JVM i'm running is JDK 1.3.1 (build 1.3.1-b24) on solaris 2.8
Comment 1 Conor MacNeill 2003-01-24 14:19:45 UTC
Fixed - the package information should now be available for non-forked <java> usage.