Custom Java Core Class

I'm interested in patching the core Java classes. Things like datatypes as String, Graphics (Swing) and classes from lib/rt.jar in general.

So the way I see it, there are a couple of methods to do that:

  1. create a custom classes and include them in JVM, then run the jvm with the -Xbootclasspath
  2. write a new bootstrap loader who will instrument Java code into the custom classes
  3. use agents and instrument bytecode on loading (not too familiar with this one)

I would like to hear your advice / opinions regarding the methods, maybe Im missing something out?

Upvotes: 2

Views: 330

Answers (2)

Stephen C
Stephen C

Reputation: 718718

Another option is to download / checkout the OpenJDK source code and build it for yourself with your modifications included.

But don't call it Java. What you are doing most likely will cause it to be incompatible with the real thing.

sometimes "A Man's Gotta Do what A Man's Gotta Do" ;)

Quoting John Wayne doesn't make what you are proposing a wise move.


no , no , no. I want it to be compatible with HotSpot.

Compatibility with HotSpot is not sufficient. There are strict rules governing the use of the Java trademark on a "java" implementation. You are only allowed to call your implementation Java if it has passed the Java STK tests.

And "I want it to be compatible" means something different to "is compatible", and that's ignoring the question of what you mean by compatible.

Upvotes: 1

Peter Lawrey
Peter Lawrey

Reputation: 533472

Changing such classes using the boot class path could be in violation of your license agreement. (If that concerns you) Changing the byte code appears to be allowed.

Another way to change system classes is to add jars to the jre/lib/endorsed directory (which you have to create) It will load anything here in preference to other jars.

Changing the String class could confuse the -XX:UseCompressedStrings option. You might like to test what happens for you with any changes.

I have done this in testing to get additional analsis from the system. I haven't tried changing these classes for production use.

I suspect whatever you are trying to do might be done another way, but without more details its impossible to say.

Upvotes: 3

Related Questions