JDK-4993813 : (reflect) Need a way to force a class to be initialized.
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.lang:reflect
  • Affected Version: 5.0
  • Priority: P3
  • Status: Open
  • Resolution: Unresolved
  • OS: solaris_8,windows_xp
  • CPU: generic,x86
  • Submitted: 2004-02-12
  • Updated: 2013-04-11
Related Reports
Duplicate :  
Relates :  
Description
There is no direct way to force a class to be initialized.  Now that class
literals do not do that, it would be extremely helpful for there to be a
direct way to force the initialization.  Please add a method

	public Class<T> Class.initialize();

to force the class to be initialized.  That would allow the idiom

	X.class.initialize()

to be used as a class literal for an initialized class.

Comments
SUGGESTED FIX public class Class { ... /** Forces the class to be initialized. */ public Class<T> initialize() { forName(getName(), true, getClassLoader()); return this; } }
2004-06-11