Overriding single classes from rt.jar

前端 未结 4 1442
无人共我
无人共我 2021-01-03 06:55

I\'m looking for a neat way to override a class from the bootstrap class path, rt.jar. The reason is OpenJDK7 bug http://bugs.sun.com/bugdatabase/view_bug.do?bu

相关标签:
4条回答
  • 2021-01-03 06:59

    I believe the only supported way of doing this is to "patch" rt.jar by replacing the desired *.class file. 7-Zip can help you easily do this.

    This is exactly how Oracle supplied their double-parsing bug fix with their FPUpdater tool, which was essentially a script that did just this. (Some history.)

    0 讨论(0)
  • 2021-01-03 07:03

    I think @ziesemer is correct, but you may be able to use the classloader to replace the offending class when your app is bootstrapping. This may be cleaner if you don't want to worry about the JDK updating underneath you, though you'd have to stick this bootstrapping classloader code into every app you are working on.

    0 讨论(0)
  • 2021-01-03 07:04

    You can use the VM parameter -Xbootclasspath/p to prepend your own JAR file with the patched class to the boot class path.

    0 讨论(0)
  • 2021-01-03 07:08

    I think you can try to use javaagent You must intercept event, when JVM loads system class and swap it to yours

    0 讨论(0)
提交回复
热议问题