-
Type:
Enhancement
-
Resolution: Duplicate
-
Priority:
P4
-
None
-
Affects Version/s: 1.2.0
-
Component/s: specification
-
generic
-
generic
Name: vi73552 Date: 04/12/99
I realize that there will be a lot of resistance to adding a new
byte-code instruction to the JVM spec, but I hope that you consider
this proposal if you ever decide to make changes at the VM level
in the future.
My suggestion deals with how the compiler implements expressions
like "MyClass.class". My understanding is that the current Java
compiler creates a new static field in the referencing class's
definition and initializes the field using Class.forName(String).
Each occurrence of "MyClass.class" then becomes a "getstatic"
instruction which references the automatically created field.
While this mechanism is more efficient than calling Class.forName()
over and over, its not as elegant or as compact as I would like.
I suggest adding a new instruction called "class" (or whatever
other mnemonic seems reasonable). The new instruction will take
a single argument which is an index into the constant-pool. The
value at that index must be a CONSTANT_Class structure. The result
of executing the instruction would be for the VM to push onto
the stack the Class object that represents the given class. Of
course the usual dynamic loading behaviour for classes would apply,
so that if the requested class is not already loaded, it will be
loaded dynamically using the current class-loader.
(Review ID: 56861)
======================================================================
- duplicates
-
JDK-4662563 Please allow ldc to load a class literal
-
- Closed
-