39 lines
997 B
Plaintext
39 lines
997 B
Plaintext
/* NetRexx */
|
|
options replace format comments java crossref savelog symbols binary
|
|
|
|
-- -----------------------------------------------------------------------------
|
|
class RCPolymorphicCopy public
|
|
|
|
method copier(x = T) public static returns T
|
|
return x.copy
|
|
|
|
method main(args = String[]) public constant
|
|
obj1 = T()
|
|
obj2 = S()
|
|
System.out.println(copier(obj1).name) -- prints "T"
|
|
System.out.println(copier(obj2).name) -- prints "S"
|
|
return
|
|
|
|
-- -----------------------------------------------------------------------------
|
|
class RCPolymorphicCopy.T public implements Cloneable
|
|
|
|
method name returns String
|
|
return T.class.getSimpleName
|
|
|
|
method copy public returns T
|
|
dup = T
|
|
|
|
do
|
|
dup = T super.clone
|
|
catch ex = CloneNotSupportedException
|
|
ex.printStackTrace
|
|
end
|
|
|
|
return dup
|
|
|
|
-- -----------------------------------------------------------------------------
|
|
class RCPolymorphicCopy.S public extends RCPolymorphicCopy.T
|
|
|
|
method name returns String
|
|
return S.class.getSimpleName
|