• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Is it possible to extend a final class? (With byte code engineering or whatever)

 
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible in any way to extend a final class? Is there anything i can do to either extend it, or at least mask this?
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at the following link:
class file format
and pay special attention to the access_flags member of the class description structure. If you'd mask (i.e. 'nand') away the ACC_FINAL (0x0010) bit, the class is assumed not to be final. If you 'or' in the ACC_PUBLIC (0x0001) bit, you've automagically turned it into a public class also.
Don't tell anyone I told you, because I don't hack never.
kind regards
 
Robert Paris
Ranch Hand
Posts: 585
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, but how would this work at runtime? I don't want to change the rt.jat classes before runtime, because I want this to work with any VM and by just running my app (i.e. java myApp). So I can do runtime byte-code engineering, but if System's already defined by the bootstrap loader, can I grab that class def, "nand" the modifier, create a new class extending that, and actually have the VM accept that new class' definition?
 
When all four tires fall off your canoe, how many tiny ads does it take to build a doghouse?
create, convert, edit or print DOC and DOCX in Java
https://products.aspose.com/words/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!