JDK-4918153 : sun.tools.jar.CommandLine code duplication, exclude sun/tools/jar/ from rt.jar
  • Type: Bug
  • Component: tools
  • Sub-Component: jar
  • Affected Version: 5.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Not an Issue
  • OS: generic
  • CPU: generic
  • Submitted: 2003-09-05
  • Updated: 2020-11-05
  • Resolved: 2020-11-05
Related Reports
Relates :  
Relates :  
Description
Since the implementation of RFE 4633413 (removing the oldjavac implementation from sun.tools.*), the sun.tools.jar package now has its own copy of the utility class CommandLine, which is nearly identical to other CommandLine classes in the SDK, such as com.sun.tools.javac.main.CommandLine.  Ideally, there should be only one such CommandLine class that is shared by our SDK tools; this shared CommandLine class should probably be a member of a (new) package named com.sun.tools.util.

This ideal solution was not implemented along with the fix for 4633413, however, because of the complicating fact that the sun/tools/jar/ hierarchy is retained in rt.jar (thus loadable by the bootstrap class loader) by the release image build, while other SDK-tool-specific stuff including the com/sun/tools/ hierarchy is only put in tools.jar (loadable by the system class loader but not the bootstrap loader)-- therefore, a reference from sun.tools.jar.Main to com.sun.tools.util.CommandLine would cause a linkage error at runtime, when using a release image.

The presence of the sun/tools/jar/ hierarchy in both rt.jar and tools.jar causes minor bloat to the size of the SDK bundle and to the JRE bundle (in which it is not even needed, as far as I can tell).

It seems that the desired packaging solution is to have the release image build process exclude the sun/tools/jar hierarchy from rt.jar just like it excludes all other components of SDK tools that get put in tools.jar.

From a preliminary investigation (see Comments), it appears that the only current reference to sun.tools.jar from a class that would remain in rt.jar with this fix is a superfluous type-import-on-demand declaration for the sun.tools.jar package in src/share/classes/sun/applet/AppletViewerPanel.java, which appears to be safe to remove (and is only a compile-time dependency anyway).  It is not clear to me what reason there had been to retain sun/tools/jar/ in rt.jar in the past, but hopefully it is just a historical artifact now; comments in Release.gmk indicate that it was always meant to be cleaned up.

With sun.tools.jar's classes being defined by the loader that loads from tools.jar, then the duplicate CommandLine classes can be combined into one sharead com.sun.tools.util.CommandLine utility class for all SDK tools.

Comments
This is no longer an issue that needs to be addressed
05-11-2020

I assume this issue no longer exists and can be closed.
05-11-2020

EVALUATION The comments above mention that code in sun/applet references code in sun/tools/jar so if sun/applet is in rt.jar, then sun/tools/jar has to be in rt.jar also. sun/applet contains appletviewer which is in the jdk, not the jre. From this point of view, sun/applet should be in tools.jar and isn't needed in rt.jar. However a comment in jdk/make/common/Release.gmk implies that sun/applet has to also be in rt.jar for the pleasure of hotjava. Presuming that we no longer care about hotjava, it seems like both of these pkgs could be removed from rt.jar (by fixing Release.gmk.)
03-03-2011

EVALUATION A code duplication cleanup pass should be made for 1.5.1 ###@###.### 2003-10-30
30-10-2003