xp-framework/rfc — Issue #5: Ability to define classes
Author: thekid
Created: 2011-10-17 14:49:38+00:00
State: closed
Labels: framework, implemented

Scope of Change
====
There will be a new method in the default classloader, called defineClass().

Rationale
====
In situations where serialized objects are passed to another system some
of the classes might not be defined. There should be an ability to catch
these errors graceously and define classes as needed.

Functionality
====
The defineClass() method defines a class and returns a lang.XPClass object
on success. On this object, one can invoke the method newInstance() to
instanciate an object of this class.

```php
defineClass('IRCUser', $bytes);
} if(catch('FormatException', $e)) {
$e->printStackTrace();
exit(-1);
}

// Instanciate it
$instance= &$class->newInstance();
?>
```

Dependencies
====
Changes to lang.ClassLoader

Related documents
====
http://java.sun.com/j2se/1.3/docs/api/java/lang/ClassLoader.html#defineClass(java.lang.String,%20byte[],%20int,%20int)
XP-xp-framework/rfc #4