OBEROn SDK

com.oberon.util
Class ClassScope

java.lang.Object
  extended by com.oberon.util.ClassScope

public class ClassScope
extends java.lang.Object

A simple static API for listing classes loaded in a JVM. Based on


Field Summary
static java.lang.String[] filterPackages
           
 
Method Summary
static java.util.List<java.io.File> getAllFilesInDirEndingWithIgnoreCases(java.io.File dir, java.lang.String endLow)
           
static java.lang.ClassLoader[] getCallerClassLoaderTree()
          Returns the class loader set "relevant" to the calling class, as described in the article.
static java.net.URL getClassLocation(java.lang.Class<?> cls)
          Given a Class
static java.util.List<java.lang.String> getClassNamesInPackage(java.lang.String jarName, java.lang.String packageName)
           
static java.lang.String[] getClassPathClasses(java.lang.String[] filterclasses)
           
 java.util.List<java.io.File> getJavaAPISources()
           
static java.lang.Class<?>[] getLoadedClasses(java.lang.ClassLoader[] loaders, java.lang.String[] filterclasses)
          A convenience multi-loader version of getLoadedClasses(ClassLoader,String[]).
static java.lang.Class<?>[] getLoadedClasses(java.lang.ClassLoader loader, java.lang.String[] filterclasses)
          Given a class loader instance, returns all classes currently loaded by that class loader.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filterPackages

public static final java.lang.String[] filterPackages
Method Detail

getLoadedClasses

public static java.lang.Class<?>[] getLoadedClasses(java.lang.ClassLoader loader,
                                                    java.lang.String[] filterclasses)
Given a class loader instance, returns all classes currently loaded by that class loader.

Parameters:
loader - defining class loader to inspect [may not be null]
Returns:
Class array such that every Class has 'loader' as its defining class loader [never null, may be empty]
Throws:
java.lang.RuntimeException - if the "classes" field hack is not possible in this JRE

getClassPathClasses

public static java.lang.String[] getClassPathClasses(java.lang.String[] filterclasses)

getLoadedClasses

public static java.lang.Class<?>[] getLoadedClasses(java.lang.ClassLoader[] loaders,
                                                    java.lang.String[] filterclasses)
A convenience multi-loader version of getLoadedClasses(ClassLoader,String[]).

Parameters:
loaders - an array of defining class loaders to inspect [may not be null]
Returns:
Class array [never null, may be empty]
Throws:
java.lang.RuntimeException - if the "classes" field hack is not possible in this JRE

getCallerClassLoaderTree

public static java.lang.ClassLoader[] getCallerClassLoaderTree()
Returns the class loader set "relevant" to the calling class, as described in the article. Starting with the class that is the caller of this method, it collects all class loaders that are loaders for all classes on the call stack and their respective parent loaders.

Returns:
ClassLoader array [never null]
Throws:
java.lang.RuntimeException - if the caller context resolver could not be instantiated

getClassLocation

public static java.net.URL getClassLocation(java.lang.Class<?> cls)
Given a Class object, attempts to find its .class location [returns null if no such definiton could be found].

Returns:
URL that points to the class definition [null if not found]

getJavaAPISources

public java.util.List<java.io.File> getJavaAPISources()

getAllFilesInDirEndingWithIgnoreCases

public static java.util.List<java.io.File> getAllFilesInDirEndingWithIgnoreCases(java.io.File dir,
                                                                                 java.lang.String endLow)

getClassNamesInPackage

public static java.util.List<java.lang.String> getClassNamesInPackage(java.lang.String jarName,
                                                                      java.lang.String packageName)

OBEROn SDK

Copyright © 2008-2014 Mirko Solazzi. All Rights Reserved.