Logo Search packages:      
Sourcecode: jamvm version File versions

final synchronized Class java::lang::ClassLoader::defineClass ( String  name,
byte[]  data,
int  offset,
int  len,
ProtectionDomain  domain 
) throws ClassFormatError [inline, protected]

Helper to define a class using a string of bytes. Subclasses should call this method from their findClass() implementation. If the domain is null, the default of Policy.getPolicy().getPermissions(new CodeSource(null, null)) is used. Once a class has been defined in a package, all further classes in that package must have the same set of certificates or a SecurityException is thrown.

Parameters:
name the name to give the class. null if unknown
data the data representing the classfile, in classfile format
offset the offset into the data where the classfile starts
len the length of the classfile data in the array
domain the ProtectionDomain to give to the class, null for the default protection domain
Returns:
the class that was defined
Exceptions:
ClassFormatError if data is not in proper classfile format
IndexOutOfBoundsException if offset or len is negative, or offset + len exceeds data
SecurityException if name starts with "java.", or if certificates do not match up
Since:
1.2

Definition at line 421 of file ClassLoader.java.

References defaultProtectionDomain, and initialized.

  {
    if (domain == null)
      domain = defaultProtectionDomain;
    if (! initialized)
      throw new SecurityException("attempt to define class from uninitialized class loader");
    return VMClassLoader.defineClass(this, name, data, offset, len, domain);
  }


Generated by  Doxygen 1.6.0   Back to index