defineClass method in class ClassLoader

Discussions

General J2EE: defineClass method in class ClassLoader

  1. defineClass method in class ClassLoader (2 messages)

    Hi,

    Can anybody tell me what is significance of defineClass method. What are the scenarios where we can we use this method practically.

    protected final Class defineClass(byte[] b,
                                      int off,
                                      int len)
                               throws ClassFormatError

    Threaded Messages (2)

  2. Loading a class from network.
    Loading a class out side your classpath.
    Loading an encrypted class.

    The simple example is JSP. How JSP is compiled and class file is generated and loaded into memory.
    RMI all use this basic concepts
  3. obvious from docs![ Go to top ]

    from sun's documentation of ClassLoader class:
     
    However, some classes may not originate from a file; they may originate from other sources, such as the network, or they could be constructed by an application. The method defineClass converts an array of bytes into an instance of class Class.
    The network class loader subclass must define the methods findClass and loadClassData to load a class from the network. Once it has downloaded the bytes that make up the class, it should use the method defineClass to create a class instance.

    quite obvious i must say!