Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Non-final class at compile-time, final at runtime

Reply
Thread Tools

Non-final class at compile-time, final at runtime

 
 
pietdejong@gmail.com
Guest
Posts: n/a
 
      11-16-2006
Can somebody tell me under which conditions a non-final class
(compile-time) can become final in runtime?
Thanks

 
Reply With Quote
 
 
 
 
Jan =?ISO-8859-1?Q?Thom=E4?=
Guest
Posts: n/a
 
      11-16-2006
Hi,

as far as I know the answer is: under no conditions. You need to declare it
final at compile time.

Best regards,
Jan

http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> Can somebody tell me under which conditions a non-final class
> (compile-time) can become final in runtime?
> Thanks


--
__________________________________________________ ________
insOMnia - We never sleep...
http://www.insomnia-hq.de
 
Reply With Quote
 
 
 
 
Oliver Wong
Guest
Posts: n/a
 
      11-16-2006
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> 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


 
Reply With Quote
 
Thomas Hawtin
Guest
Posts: n/a
 
      11-16-2006
Oliver Wong wrote:
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) ups.com...
>> 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
 
Reply With Quote
 
Adam Maass
Guest
Posts: n/a
 
      11-16-2006

<(E-Mail Removed)> wrote:
> 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


 
Reply With Quote
 
Chris Uppal
Guest
Posts: n/a
 
      11-17-2006
(E-Mail Removed) wrote:

> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word open as Final, not Final Showing Markup Karl Engel Computer Support 4 12-19-2006 04:20 AM
Runtime.exec(String[]) Doesn't Always Work, bBut Runtime.exec(String) Does Hal Vaughan Java 11 05-22-2006 04:49 PM
what are the other ways to prevent a class from being subclassed. one way is to declare the class final. srinivas.veeranki@gmail.com Java 20 02-17-2006 12:21 AM
Difference between static final members and final static members(if any)? JFCM Java 4 02-07-2006 11:32 AM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM



Advertisments