JDK-6682571 : Access to class meta data at compile time
  • Type: Enhancement
  • Component: specification
  • Sub-Component: language
  • Affected Version: 7
  • Priority: P5
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_10
  • CPU: sparc
  • Submitted: 2008-04-01
  • Updated: 2011-02-16
  • Resolved: 2008-04-01
Related Reports
Duplicate :  
Description
A DESCRIPTION OF THE REQUEST :

Accessing class information through reflection is helpful, but it consists of methods that must be used at runtime.   Since the classes meta data is known at compile time, it should be accessible through the Java language.


JUSTIFICATION :

Currently, there is no way to access class meta data at compile time.  If a String is used to hold the name of a method to be called through reflection, and later the method is renamed, a runtime error will occur.  If the String was instantiated by the proposed method, the error will occur at compile time.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -

This would allow code to work like this:

String methodName = Dog.class.meta.woof.toString();
Class[] pTypes = Dog.class.meta.woof.types();