As mentioned in other answers, you could in theory, of course, unzip your rt.jar JVM file and replace the file with a compatible version with error correction.
Any Java class library classes, such as Swing, are loaded by the bootstrap class loader, which looks for its classes from this rt.jar. You can usually not add classes to this class path without adding them to this file. There is a (non-standard) VM option
-Xbootclasspath/jarWithPatchedClass.jar:path
where you added a jar file that includes a patched version, but this does not necessarily work on any Java virtual machine. It is also illegal to deploy an application that modifies this behavior. As stated in the official documentation :
Do not deploy applications that use this parameter to override the class in rt.jar, as this violates the binary code of the Java Runtime Environment license.
If you add a class to the bootstrap class loader (which is possible without using non-standard APIs using the toolkit API), the runtime will still load the source class as the bootloader class bootloader, in this case it searches for rt.jar first. Therefore, it is impossible to “obscure” a broken class without modifying this file.
Finally, it is always illegal to distribute a virtual machine with a fixed file , i.e. put it in the production system for the client. The license agreement clearly states what you need
[...] distribute [Java runtime] fully and unmodified and only bundled with your applets and applications
Therefore, modifying the VM that you distribute is not recommended as you may face legal consequences when it is ever revealed.
Of course, you can theoretically build your own version of OpenJDK, but you can no longer invoke binary Java when you distribute it, and I assume that your client would not allow this by what you offer in your answer. From experience, many secure environments compute hashes of binary files before execution, to prohibit both approaches to setting up a running virtual machine.
The easiest solution for you is probably to create
The javadoc java.lang.instrumentation offers a detailed description of how to create and implement a Java agent. Using this approach, you can use a fixed version of the class in question without violating the license agreement .
From experience, Java agents are a great way to fix temporary errors in third-party libraries and in the Java class library without having to deploy code changes or even deploy a new version for the client. This is actually a typical example of using a Java agent.