List of usage examples for java.lang ClassLoader toString
public String toString()
From source file:com.cloudera.sqoop.util.ClassLoaderStack.java
/** * Sets the classloader for the current thread. *///w ww. ja v a 2s . co m public static void setCurrentClassLoader(ClassLoader cl) { LOG.debug("Restoring classloader: " + cl.toString()); Thread.currentThread().setContextClassLoader(cl); }
From source file:com.npower.dm.util.DMUtil.java
public static void print(ClassLoader loader) { System.out.println("Dump classload: " + loader.toString()); URL[] urls = getClassLoaderURLs(loader); for (int i = 0; urls != null && i < urls.length; i++) { System.out.println(urls[i].toString()); }//w ww . j a v a 2 s. c om System.out.println("End of classload: " + loader.toString()); }
From source file:org.jfan.an.utils.VersionInfo.java
/** * Instantiates version information from properties. * * @param pckg the package for the version information * @param info the map from string keys to string values, * for example {@link java.util.Properties} * @param clsldr the classloader, or <code>null</code> * * @return the version information//from w ww. jav a2s. c om */ protected static VersionInfo fromMap(final String pckg, final Map<?, ?> info, final ClassLoader clsldr) { Args.notNull(pckg, "Package identifier"); String module = null; String release = null; String timestamp = null; if (info != null) { module = (String) info.get(PROPERTY_MODULE); if ((module != null) && (module.length() < 1)) { module = null; } release = (String) info.get(PROPERTY_RELEASE); if ((release != null) && ((release.length() < 1) || (release.equals("${pom.version}")))) { release = null; } timestamp = (String) info.get(PROPERTY_TIMESTAMP); if ((timestamp != null) && ((timestamp.length() < 1) || (timestamp.equals("${mvn.timestamp}")))) { timestamp = null; } } // if info String clsldrstr = null; if (clsldr != null) { clsldrstr = clsldr.toString(); } return new VersionInfo(pckg, module, release, timestamp, clsldrstr); }
From source file:com.github.drochetti.javassist.maven.ClassTransformer.java
private void debugClassLoader(final ClassPool classPool) { if (!logger.isDebugEnabled()) { return;/*from w ww. j a va 2 s. c om*/ } logger.debug(" - classPool: " + classPool.toString()); ClassLoader classLoader = classPool.getClassLoader(); while (classLoader != null) { logger.debug(" -- " + classLoader.getClass().getName() + ": " + classLoader.toString()); if (classLoader instanceof URLClassLoader) { logger.debug(" --- urls: " + Arrays.deepToString(((URLClassLoader) classLoader).getURLs())); } classLoader = classLoader.getParent(); } }
From source file:edu.umich.flowfence.sandbox.SandboxService.java
@Override public IBinder onBind(Intent i) { if (localLOGD) { Log.d(TAG, "Bound"); }//w ww . j a v a2s. c o m Bundle extras = i.getExtras(); if (extras == null) { throw new IllegalArgumentException("No extras"); } IBinder api = extras.getBinder(EXTRA_TRUSTED_API); if (api == null) { throw new IllegalArgumentException("Trusted API not found in extras"); } IBinder root = extras.getBinder(EXTRA_ROOT_SERVICE); if (root == null) { throw new IllegalArgumentException("FlowfenceService not found in extras"); } mTrustedAPI = ITrustedAPI.Stub.asInterface(api); mRootService = IFlowfenceService.Stub.asInterface(root); mID = extras.getInt(EXTRA_SANDBOX_ID, -1); if (localLOGV) { ClassLoader cl = getClassLoader(); Log.v(TAG, "ClassLoader chain:"); while (cl != null) { Log.v(TAG, cl.toString()); cl = cl.getParent(); } Log.v(TAG, "<end of chain>"); } final String[] packagesToLoad = extras.getStringArray(EXTRA_KNOWN_PACKAGES); getBackgroundHandler().post(new Runnable() { @Override public void run() { if (localLOGD) { Log.d(TAG, "Preloading resolve code"); } // Run through a fake transaction, to preload the appropriate classes. QMDescriptor preloadDesc = QMDescriptor.forStatic(SandboxService.this, SandboxService.class, "resolveStub"); Binder testBinder = new Binder() { @Override protected boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { return mBinder.onTransact(code, data, reply, flags); } }; testBinder.attachInterface(null, ""); ISandboxService proxy = ISandboxService.Stub.asInterface(testBinder); try { proxy.resolveQM(preloadDesc, false, null); } catch (Exception e) { Log.w(TAG, "Couldn't preload resolve", e); } if (localLOGD) { Log.d(TAG, "Preloading packages"); } // Load up packages the trusted service tells us we might need. for (String packageName : ArrayUtils.nullToEmpty(packagesToLoad)) { try { if (localLOGD) { Log.d(TAG, "Preloading " + packageName); } getContextForPackage(packageName); } catch (PackageManager.NameNotFoundException e) { Log.w(TAG, "Can't preload package", e); } } Log.i(TAG, "Sandbox #" + mID + ": preload complete"); } }); return mBinder; }
From source file:edu.umich.oasis.sandbox.SandboxService.java
@Override public IBinder onBind(Intent i) { if (localLOGD) { Log.d(TAG, "Bound"); }// ww w.ja va2 s.c o m Bundle extras = i.getExtras(); if (extras == null) { throw new IllegalArgumentException("No extras"); } IBinder api = extras.getBinder(EXTRA_TRUSTED_API); if (api == null) { throw new IllegalArgumentException("Trusted API not found in extras"); } IBinder root = extras.getBinder(EXTRA_ROOT_SERVICE); if (root == null) { throw new IllegalArgumentException("OASISService not found in extras"); } mTrustedAPI = ITrustedAPI.Stub.asInterface(api); mRootService = IOASISService.Stub.asInterface(root); mID = extras.getInt(EXTRA_SANDBOX_ID, -1); if (localLOGV) { ClassLoader cl = getClassLoader(); Log.v(TAG, "ClassLoader chain:"); while (cl != null) { Log.v(TAG, cl.toString()); cl = cl.getParent(); } Log.v(TAG, "<end of chain>"); } final String[] packagesToLoad = extras.getStringArray(EXTRA_KNOWN_PACKAGES); getBackgroundHandler().post(new Runnable() { @Override public void run() { if (localLOGD) { Log.d(TAG, "Preloading resolve code"); } // Run through a fake transaction, to preload the appropriate classes. SodaDescriptor preloadDesc = SodaDescriptor.forStatic(SandboxService.this, SandboxService.class, "resolveStub"); Binder testBinder = new Binder() { @Override protected boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException { return mBinder.onTransact(code, data, reply, flags); } }; testBinder.attachInterface(null, ""); ISandboxService proxy = ISandboxService.Stub.asInterface(testBinder); try { proxy.resolveSoda(preloadDesc, false, null); } catch (Exception e) { Log.w(TAG, "Couldn't preload resolve", e); } if (localLOGD) { Log.d(TAG, "Preloading packages"); } // Load up packages the trusted service tells us we might need. for (String packageName : ArrayUtils.nullToEmpty(packagesToLoad)) { try { if (localLOGD) { Log.d(TAG, "Preloading " + packageName); } getContextForPackage(packageName); } catch (PackageManager.NameNotFoundException e) { Log.w(TAG, "Can't preload package", e); } } Log.i(TAG, "Sandbox #" + mID + ": preload complete"); } }); return mBinder; }
From source file:de.icongmbh.oss.maven.plugin.javassist.JavassistTransformerExecutor.java
private void debugClassLoader(final ClassPool classPool) { if (!LOGGER.isDebugEnabled()) { return;//from w ww . j av a2 s .c o m } LOGGER.debug(" - classPool: {}", classPool.toString()); ClassLoader classLoader = classPool.getClassLoader(); while (classLoader != null) { LOGGER.debug(" -- {}: {}", classLoader.getClass().getName(), classLoader.toString()); if (classLoader instanceof URLClassLoader) { LOGGER.debug(" --- urls: {}", Arrays.deepToString(((URLClassLoader) classLoader).getURLs())); } classLoader = classLoader.getParent(); } }
From source file:com.opensymphony.xwork2.util.DefaultLocalizedTextProvider.java
/** * Add's the bundle to the internal list of default bundles. * <p>/*from w w w .j av a 2 s .c o m*/ * If the bundle already exists in the list it will be readded. * </p> * * @param resourceBundleName the name of the bundle to add. */ @Override public void addDefaultResourceBundle(String resourceBundleName) { //make sure this doesn't get added more than once final ClassLoader ccl = getCurrentThreadContextClassLoader(); synchronized (XWORK_MESSAGES_BUNDLE) { List<String> bundles = classLoaderMap.get(ccl.hashCode()); if (bundles == null) { bundles = new CopyOnWriteArrayList<>(); classLoaderMap.put(ccl.hashCode(), bundles); } bundles.remove(resourceBundleName); bundles.add(0, resourceBundleName); } if (LOG.isDebugEnabled()) { LOG.debug( "Added default resource bundle '{}' to default resource bundles for the following classloader '{}'", resourceBundleName, ccl.toString()); } }
From source file:no.sr.ringo.persistence.jdbc.RingoDataSourceFactoryDbcpImpl.java
private static Driver getJdbcDriver(ClassLoader classLoader, String className) { Class<?> aClass;//from w w w . j a v a 2 s . c o m try { aClass = Class.forName(className, true, classLoader); } catch (ClassNotFoundException e) { throw new IllegalStateException( "Unable to locate class " + className + " using " + classLoader.toString()); } Driver driver; try { driver = (Driver) aClass.newInstance(); } catch (InstantiationException e) { throw new IllegalStateException("Unable to instantiate driver from class " + className, e); } catch (IllegalAccessException e) { throw new IllegalStateException("Unable to access driver class " + className + "; " + e, e); } return driver; }
From source file:org.apache.axis2.client.Options.java
/** * Debug for for property key and value. * @param key// w ww.j ava2 s.co m * @param value */ private void debugPropertySet(String key, Object value) { if (DEBUG_PROPERTY_SET) { String className = (value == null) ? "null" : value.getClass().getName(); String classloader = "null"; if (value != null) { ClassLoader cl = Utils.getObjectClassLoader(value); if (cl != null) { classloader = cl.toString(); } } String valueText = (value instanceof String) ? value.toString() : null; String identity = getClass().getName() + '@' + Integer.toHexString(System.identityHashCode(this)); log.debug("=================="); log.debug(" Property set on object " + identity); log.debug(" Key =" + key); if (valueText != null) { log.debug(" Value =" + valueText); } log.debug(" Value Class = " + className); log.debug(" Value Classloader = " + classloader); log.debug("Call Stack = " + JavaUtils.callStackToString()); log.debug("=================="); } }