Can somebody tell me under which conditions a non-final class
(compile-time) can become final in runtime?
Thanks
Jan Thomä - 16 Nov 2006 15:58 GMT
Hi,
as far as I know the answer is: under no conditions. You need to declare it
final at compile time.
Best regards,
Jan
> Can somebody tell me under which conditions a non-final class
> (compile-time) can become final in runtime?
> Thanks

Signature
__________________________________________________________
insOMnia - We never sleep...
http://www.insomnia-hq.de
Oliver Wong - 16 Nov 2006 16:36 GMT
> Can somebody tell me under which conditions a non-final class
> (compile-time) can become final in runtime?
Perhaps you could do some magic with a custom class loader and/or
reflection.
- Oliver
Thomas Hawtin - 16 Nov 2006 17:20 GMT
>> Can somebody tell me under which conditions a non-final class
>> (compile-time) can become final in runtime?
>
> Perhaps you could do some magic with a custom class loader and/or
> reflection.
Custom class loader: Well you could load different bytes, but then that
would be a different class.
Reflection: I think setAccessible is the only point of mutation, and
that only affects the reflection object, not the reflectee.
I guess the instrumentation API might work. Or a debugging interface.
Tom Hawtin
Adam Maass - 16 Nov 2006 19:51 GMT
> Can somebody tell me under which conditions a non-final class
> (compile-time) can become final in runtime?
> Thanks
It's a multistep process:
1. Compile all sources;
2. Copy all resulting .class files;
3. Modify the source of the code such that a non-final class is now final;
4. Recompile;
5. Replace the old .class file for the modified class with the new .class
file.
I assume that you're referring to some of the oddities in the spec... this
is the kind of situation that those oddities are intended to address.
-- Adam Maass
Chris Uppal - 17 Nov 2006 12:30 GMT
> Can somebody tell me under which conditions a non-final class
> (compile-time) can become final in runtime?
It would be interesting to hear how you come to be in this situation, and how
you can tell it's happening. E.g. are you using reflection to discover what
the attributes of the class are, or are you getting runtime errors when you try
to load a sub-class of a supposedly non-final class, or what ?
Or is it, perhaps, something that you are trying to /achieve/ ? (But why ??)
-- chris