うまくコメントが書けないのでトラックバックを打とう。

# freebeans さんの日記にコメントを書こうとしたが、うまくコメントが書けないのでトラックバックを打とう。


CONSTANT_Classを渡しても良い、というように仕様が拡張されているようだ。
Java5対応を行うためには、もう一度VMの仕様書を読み直す必要がありそうだ。
しかし、上記ファイルはドラフト版だ。どこかに正式版があるのだろうか・・・?

正式版のありかは知らないのですが、Java5 の ldc 仕様にはびみょ〜な間違いがあり、Java6 以降のための JSR-202 の修正で訂正されました。


「The operand of each ldc instruction must be a valid index into the constant_pool table. The operands of each ldc_w instruction must represent a valid index into the constant_pool table. In both cases the constant pool entry referenced by that index must be of type CONSTANT_Class, CONSTANT_Integer, CONSTANT_Float, or CONSTANT_String if the class file version number is less than 49.0 If the class file version is 49.0 or above, then the constant pool entry referenced by the enty must be of type CONSTANT_Class, CONSTANT_Integer, CONSTANT_Float, or CONSTANT_String or CONSTANT_Class.


The operand of each ldc instruction must be a valid index into the constant_pool table. The operands of each ldc_w instruction must represent a valid index into the constant_pool table. In both cases the constant pool entry referenced by that index must be of type CONSTANT_Integer, CONSTANT_Float, or CONSTANT_String if the class file version number is less than 49.0. If the class file version is 49.0 or above, then the constant pool entry referenced by the enty must be of type CONSTANT_Integer, CONSTANT_Float, CONSTANT_String or CONSTANT_Class.

要は J2SE 5.0 でも version 49.0 未満のクラスファイル中の ldc/ldc_w は CONSTANT_Class を認めないということになります。