On 31.08.21 04:58, OCsite wrote:
[...]>> ...
Of course you can also redefine the class on loading, then you can
basically do whatever.
redefine is the wrong word here I guess...
Yup, I guess conceptually, there is not much difference between
(a) creating a subclass containing methods I need
Jochen,
thanks a lot!
> On 29 Aug 2021, at 19:22, Jochen Theodorou wrote:
> On 28.08.21 14:46, OCsite wrote:
>> Pity not even today's Java supports something like Objective-C runtime
>> support for managing the methods in a class :(
>>
>> Anyway, I might try to create my (sub)classes
On 28.08.21 14:46, OCsite wrote:
Rachel, Paul,
thanks a lot!
Pity not even today's Java supports something like Objective-C runtime
support for managing the methods in a class :(
Anyway, I might try to create my (sub)classes dynamically at runtime —
this is an idea which did not occur to me
Rachel, Paul,
thanks a lot!
Pity not even today's Java supports something like Objective-C runtime support
for managing the methods in a class :(
Anyway, I might try to create my (sub)classes dynamically at runtime — this is
an idea which did not occur to me before; and although I can see
As Rachel said, methods/properties added via runtime metaprogramming will
only be visible to Groovy's reflection capabilities. Some frameworks have
moved to using compile-time metaprogramming (AST transforms, macros/macros
methods) or traits so that added features will be visible also to Java.
i think the only thing anything like it is the only way to add methods to a
class in java: extend it (as in subclass it). Send an object to your library
code that it's going to do getClass().getMethods() to, effectively. You can do
that from groovy (the subclass for instance can be written in
Rachel,
yes, I use the metaclass stuff heavily; but I am often bumping into problems
with library code which accesses attributes of my classes through reflexion
(and due to that, does not see my dynamically installed accessors etc).
I know the Javas of old did not support that; but I sort of
Through java.lang.reflect? I'd guess not as that would involve actually
changing the bytecode of a loaded class at runtime to add methods... It's just
not a JVM thing, I think - if it was, at least by any official means, Groovy
would probably have been written to use it instead of all the stuff
Hi there,
the subject says it all. I've asked this long time ago (and got a negative
answer then), but meantime there's Groovy 3.
Is there now a way to do that?
Most important it would be with my own class (subclass of a library class), if
it helps to find a solution.
Thanks,
OC