public static URL [] getUserClassPathComponents() throws ClassPathException { if ( userClassPathComp != null ) return userClassPathComp; String cp=System.getProperty("java.class.path"); String [] paths = cp.split(File.pathSeparator); URL [] urls = new URL[ paths.length ]; try { for ( int i=0; i<paths.length; i++) // We take care to get the canonical path first. // Java deals with relative paths for it's bootstrap loader // but JARClassLoader doesn't. urls[i] = new File( new File(paths[i]).getCanonicalPath() ).toURI().toURL(); } catch ( IOException e ) { throw new ClassPathException("can't parse class path: "+e, e); } userClassPathComp = urls; return urls; }
public static URL [] getUserClassPathComponents() throws ClassPathException { if ( userClassPathComp != null ) return userClassPathComp; String cp=System.getProperty("java.class.path"); String [] paths=StringUtil.split(cp, File.pathSeparator); URL [] urls = new URL[ paths.length ]; try { for ( int i=0; i<paths.length; i++) // We take care to get the canonical path first. // Java deals with relative paths for it's bootstrap loader // but JARClassLoader doesn't. urls[i] = new File( new File(paths[i]).getCanonicalPath() ).toURL(); } catch ( IOException e ) { throw new ClassPathException("can't parse class path: "+e); } userClassPathComp = urls; return urls; }
/** Get the boot path including the lib/rt.jar if possible. */ public static BshClassPath getBootClassPath() throws ClassPathException { if ( bootClassPath == null ) { try { //String rtjar = System.getProperty("java.home")+"/lib/rt.jar"; String rtjar = getRTJarPath(); URL url = new File( rtjar ).toURL(); bootClassPath = new BshClassPath( "Boot Class Path", new URL[] { url } ); } catch ( MalformedURLException e ) { throw new ClassPathException(" can't find boot jar: "+e); } } return bootClassPath; }
/** Get the boot path including the lib/rt.jar if possible. */ public static BshClassPath getBootClassPath() throws ClassPathException { if ( bootClassPath == null ) { try { bootClassPath = new BshClassPath( "Boot Class Path", new URL[] { getRTJarPath() } ); } catch ( MalformedURLException e ) { throw new ClassPathException(" can't find boot jar: "+e, e); } } return bootClassPath; }
/** Reload all classes in the specified package: e.g. "com.sun.tools" The special package name "<unpackaged>" can be used to refer to unpackaged classes. */ @Override public void reloadPackage( String pack ) throws ClassPathException { Collection classes = baseClassPath.getClassesForPackage( pack ); if ( classes == null ) classes = BshClassPath.getUserClassPath().getClassesForPackage( pack ); // no point in checking boot class path, can't reload those if ( classes == null ) throw new ClassPathException("No classes found for package: "+pack); reloadClasses( (String[])classes.toArray( new String[0] ) ); }
/** Reload all classes in the specified package: e.g. "com.sun.tools" The special package name "<unpackaged>" can be used to refer to unpackaged classes. */ @Override public void reloadPackage( String pack ) throws ClassPathException { Collection classes = baseClassPath.getClassesForPackage( pack ); if ( classes == null ) classes = BshClassPath.getUserClassPath().getClassesForPackage( pack ); // no point in checking boot class path, can't reload those if ( classes == null ) throw new ClassPathException("No classes found for package: "+pack); reloadClasses( (String[])classes.toArray( new String[0] ) ); }
/** Support for super import "*"; Get the full name associated with the unqualified name in this classpath. Returns either the String name or an AmbiguousName object encapsulating the various names. */ public String getClassNameByUnqName( String name ) throws ClassPathException { insureInitialized(); UnqualifiedNameTable unqNameTable = getUnqualifiedNameTable(); Object obj = unqNameTable.get( name ); if ( obj instanceof AmbiguousName ) throw new ClassPathException("Ambigous class names: "+ ((AmbiguousName)obj).get() ); return (String)obj; }
/** Support for super import "*"; Get the full name associated with the unqualified name in this classpath. Returns either the String name or an AmbiguousName object encapsulating the various names. */ public String getClassNameByUnqName( String name ) throws ClassPathException { insureInitialized(); UnqualifiedNameTable unqNameTable = getUnqualifiedNameTable(); Object obj = unqNameTable.get( name ); if ( obj instanceof AmbiguousName ) throw new ClassPathException("Ambigous class names: "+ ((AmbiguousName)obj).get() ); return (String)obj; }
throw new ClassPathException("Nothing known about class: " +name ); throw new ClassPathException("Cannot reload class: "+name+ " from source: "+ classSource );
throw new ClassPathException("Nothing known about class: " +name ); throw new ClassPathException("Cannot reload class: "+name+ " from source: "+ classSource );