org.microemu.app.classloader
Class MIDletClassLoader

java.lang.Object
  extended by java.lang.ClassLoader
      extended by java.security.SecureClassLoader
          extended by java.net.URLClassLoader
              extended by org.microemu.app.classloader.MIDletClassLoader

public class MIDletClassLoader
extends java.net.URLClassLoader

Main features of this class loader Security aware - enables load and run app in Webstart. Proper class loading order. MIDlet classes loaded first then system and MicroEmulator classes Proper resource loading order. MIDlet resources only can be loaded. MIDlet Bytecode preprocessing/instrumentation

Author:
vlads

Field Summary
static boolean enhanceCatchBlock
           
static boolean instrumentMIDletClasses
           
static boolean traceClassLoading
           
static boolean traceSystemClassLoading
           
 
Constructor Summary
MIDletClassLoader(java.lang.ClassLoader parent)
           
 
Method Summary
 void addClassURL(java.lang.String className)
          Appends the Class Location URL to the list of URLs to search for classes and resources.
 void addURL(java.net.URL url)
           
 boolean classLoadByParent(java.lang.String className)
           
 void configure(MIDletClassLoaderConfig clConfig, boolean forJad)
           
 void disableClassPreporcessing(java.lang.Class klass)
          Special case for classes injected to MIDlet
 void disableClassPreporcessing(java.lang.String className)
           
protected  java.lang.Class findClass(java.lang.String name)
           
static java.lang.String getClassResourceName(java.lang.String className)
           
 java.net.URL getResource(java.lang.String name)
          Finds the resource with the given name.
 java.io.InputStream getResourceAsStream(java.lang.String name)
          Allow access to resources
protected  java.lang.Class loadClass(java.lang.String name, boolean resolve)
          Loads the class with the specified binary name.
 
Methods inherited from class java.net.URLClassLoader
definePackage, findResource, findResources, getPermissions, getURLs, newInstance, newInstance
 
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass
 
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findSystemClass, getPackage, getPackages, getParent, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instrumentMIDletClasses

public static boolean instrumentMIDletClasses

traceClassLoading

public static boolean traceClassLoading

traceSystemClassLoading

public static boolean traceSystemClassLoading

enhanceCatchBlock

public static boolean enhanceCatchBlock
Constructor Detail

MIDletClassLoader

public MIDletClassLoader(java.lang.ClassLoader parent)
Method Detail

configure

public void configure(MIDletClassLoaderConfig clConfig,
                      boolean forJad)
               throws java.net.MalformedURLException
Throws:
java.net.MalformedURLException

addClassURL

public void addClassURL(java.lang.String className)
                 throws java.net.MalformedURLException
Appends the Class Location URL to the list of URLs to search for classes and resources.

Parameters:
Class - Name
Throws:
java.net.MalformedURLException

addURL

public void addURL(java.net.URL url)
Overrides:
addURL in class java.net.URLClassLoader

loadClass

protected java.lang.Class loadClass(java.lang.String name,
                                    boolean resolve)
                             throws java.lang.ClassNotFoundException
Loads the class with the specified binary name.

Search order is reverse to standard implemenation

This implementation of this method searches for classes in the following order:

  1. Invoke ClassLoader.findLoadedClass(String) to check if the class has already been loaded.

  2. Invoke the findClass(String) method to find the class in this class loader URLs.

  3. Invoke the loadClass method on the parent class loader. If the parent is null the class loader built-in to the virtual machine is used, instead.

Overrides:
loadClass in class java.lang.ClassLoader
Throws:
java.lang.ClassNotFoundException

getResource

public java.net.URL getResource(java.lang.String name)
Finds the resource with the given name. A resource is some data (images, audio, text, etc) that can be accessed by class code in a way that is independent of the location of the code.

The name of a resource is a '/'-separated path name that identifies the resource.

Search order is reverse to standard implementation

This method will first use URLClassLoader.findResource(String) to find the resource. That failing, this method will NOT invoke the parent class loader if delegatingToParent=false.

Overrides:
getResource in class java.lang.ClassLoader
Parameters:
name - The resource name
Returns:
A URL object for reading the resource, or null if the resource could not be found or the invoker doesn't have adequate privileges to get the resource.

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String name)
Allow access to resources

Overrides:
getResourceAsStream in class java.lang.ClassLoader

classLoadByParent

public boolean classLoadByParent(java.lang.String className)

disableClassPreporcessing

public void disableClassPreporcessing(java.lang.Class klass)
Special case for classes injected to MIDlet

Parameters:
klass -

disableClassPreporcessing

public void disableClassPreporcessing(java.lang.String className)

getClassResourceName

public static java.lang.String getClassResourceName(java.lang.String className)

findClass

protected java.lang.Class findClass(java.lang.String name)
                             throws java.lang.ClassNotFoundException
Overrides:
findClass in class java.net.URLClassLoader
Throws:
java.lang.ClassNotFoundException


Copyright © 2001-2009 MicroEmulator Team. All Rights Reserved.