• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Changing Core System Library Classes

 
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to temporarily change the code to say, java.lang.Class for debugging/monitoring. I know the java.exe has a -Xbootclasspath/p:path option allowing us to prepend our own version of the core api classes to the classpath and override those found in JRE's rt.jar. Furthermore, the source code for the core api classes are provided by the jdk. But the problem is it seems that the javac compiler does not accept a class name in the java.* package and I was not able to recompile from the modified source code directly. As a work around, I used byte code instrumentation tools like Javassist/BCEL to inject code to existing system classes and saved it into the rt.jar of the JRE. But is it possible to modify the source code directly and recompile them without having to use byte code instrumenation?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JRE license prohibits patching the class libraries, so there are probably no tools that support it. Javassist/BCEL may be your best option, or you could check out AspectJ for something a bit less hackish.
 
Alec Lee
Ranch Hand
Posts: 569
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just wondering why, then, they provide the -XBootclasspath/p: option and the source code for the core system library but just disable the compiler.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That mechanism can be used to replace libraries that ship with the JRE (like JAXB and JAX-WS) with newer versions.

The source code is still useful to have for learning how particular classes/methods work.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic