Is it allowed to extend the class of a class?

I wrote a system in which at runtime it generates some patterns, and then generates some objects based on these patterns. I had the idea that templates could be extensions of the Class class, but this led to some great bugs:

VerifyError: Error #1107: The ABC data is corrupt, attempt to read out of bounds.

What interests me is if a subclass class is possible at all, if there is, perhaps, some case where it will be appropriate, and not just a gross abuse of OOP. I believe this should be possible, since ActionScript allows you to create variables of type Class. This usage is described in the LiveDocs entry for the class , but I have not seen references to the subclass class.

Here is an example of pseudo code:

class Foo extends Class

var A:Foo = new Foo(); // A is a class
trace(A is Class); // true, right?
var b = new A(); // b is an instance of class A

I don't know what the type will be b. This will?

trace(b is A); // true?

b A, var b:A = new A();, A ? , , A , , .

, , , .

: ? , Class?

+5
2

:

Class , , . , , , , Object.

, , , . , ActionScript (int, uint, Number, String, Boolean ..), :

1016: Base class is final.

, , :

Package       Top Level
Class         public final class Boolean
Inheritance   Boolean -> Object

, , , , final. Function. . , , Function ? :

class MyFunction extends Function { /*...*/ }

.. :

VerifyError: Error #1103: Class ::MyFunction cannot extend final base class.

. , . Function , - , , .

: . Function, . , , .

: Function , , , , ECMAscript. (, ), , , .

, , , . , , - , . , , .

, , , - . , - , . Class. :

// the definition causes no errors on its own, even though the compiler "sees" it
class MyClass extends Class { /*...*/ }

/* elsewhere */

MyClass; // the only mention of MyClass beyond the definition

.. :

verify global$init()
                    stack:
                    scope: 
                     locals: global 

/* snip about 120 lines */

   46:getlex 34
                    stack: global Class$?
                    scope: global Object$ Class$ 
                     locals: global 
   48:newclass MyClass$cinit()
VerifyError: Error #1107: The ABC data is corrupt, attempt to read out of bounds.

    at global$init()

! VerifyError SWF. , , , "" Flash Player . ActionScript.

, , , .

VerifyError: Error #1107: The ABC data is corrupt, attempt to read out of bounds.

I ( , . ) , "ABC" , , , , . , MyClass. , , MyClass, MyClass.

, , -, , , , Object. new Class(); , , .constructor . , .

, VerifyError. , , ActionScript, , . , Flash Player , , ( , , ABC, , , ), VerifyError.

, Class . , Class , Object, .

, . , ActionScript. , , , , .

+1

liveoc Every Class object is an instance of the Class class. , , .

a system that generates some templates, and then generates some objects based on those templates. , .

, . , . :

public interface Foo {
    function bar:void;
}

, , , .

public class MyClass implements Foo {
    function bar:void {
        ..... implementation goes here .....
    }
}

, .

, , , , , , , , .

, .

+5

All Articles