@Test public void testPackageName() { assertEquals("my.package", ClassManager.getPackageName("my.package.Class")); try { ClassManager.getPackageName("teststring"); fail("IllegalArgumentException should have been thrown"); } catch (IllegalArgumentException e) { } }
public static final String getPackageName(String className) { if (className.indexOf('.') < 0) { throw new IllegalArgumentException("this class is not contained in a package!"); } return className.substring(0, className.lastIndexOf('.')); }
ClassManager { public static final String getPackageName(String className) { if (className.indexOf('.') < 0) { throw new IllegalArgumentException("this class is not contained in a package!"); } return className.substring(0, className.lastIndexOf('.')); } }
ClassManager { public static final String getPackageName(String className) { if (className.indexOf('.') < 0) { throw new IllegalArgumentException("this class is not contained in a package!"); } return className.substring(0, className.lastIndexOf('.')); } ClassManager(Repository repository, ClassLoader platformLoader, ClassLoaderPolicy policy);  ClassManager(Repository[] repositories, ClassLoader platformLoader, ClassLoaderPolicy policy);  ClassManager(List<Repository> repositories, ClassLoader platformLoader, ClassLoaderPolicy policy); }
ClassManager { public static final String getPackageName(String className) { if (className.indexOf('.') < 0) { throw new IllegalArgumentException("this class is not contained in a package!"); } return className.substring(0, className.lastIndexOf('.')); } ClassManager(Repository repository, ClassLoader platformLoader, ClassLoaderPolicy policy);  ClassManager(Repository[] repositories, ClassLoader platformLoader, ClassLoaderPolicy policy);  ClassManager(List<Repository> repositories, ClassLoader platformLoader, ClassLoaderPolicy policy); void registerService(ServiceNameVersion serviceIdentifier); void unregisterService(ServiceNameVersion service); Class<?> getServiceClass(ServiceNameVersion service); static final String getPackageName(String className); void addRepository(Repository repository); }
ClassManager { public static final String getPackageName(String className) { if (className.indexOf('.') < 0) { throw new IllegalArgumentException("this class is not contained in a package!"); } return className.substring(0, className.lastIndexOf('.')); } ClassManager(Repository repository, ClassLoader platformLoader, ClassLoaderPolicy policy);  ClassManager(Repository[] repositories, ClassLoader platformLoader, ClassLoaderPolicy policy);  ClassManager(List<Repository> repositories, ClassLoader platformLoader, ClassLoaderPolicy policy); void registerService(ServiceNameVersion serviceIdentifier); void unregisterService(ServiceNameVersion service); Class<?> getServiceClass(ServiceNameVersion service); static final String getPackageName(String className); void addRepository(Repository repository);  }