読書会(Java仮想マシン仕様)第2回議事録

[ 戻る ]


「Java仮想マシン仕様」を読む会 第2回議事録

1999年10月30日(土) 10−16時
Javaカンファレンス会議室

出席

 1.えんどう やすゆき yasuyuki@timedia.co.jp             書記
 2.高橋   徹   さん  torutk@alles.or.jp
 3.橋本   孝博 さん  takahiro@fantasia.ml.toyota.co.jp
 4.布留川 英一 さん  npaka@m9.people.or.jp
 5.天野   正浩 さん  masaa825@mb.mailbank.ne.jp
 6.波多   浩昭 さん  hata@sphere.ad.jp
 7.前橋   和弥 さん  maebashi@cse.co.jp
 8.宮崎   靖士 さん  soara@msd.biglobe.ne.jp
 9.Nobuo Yamashita さん nobsun@nyd.inzai.chiba.jp        読み手
10.石黒   尚久 さん  ti-stone@kt.rim.or.jp


2.16 実行
2.16.1 Virtual Machine Start-up

・Terminator クラスを使って説明

 (前回、"Hasta la vista Baby" とは何かの疑問あり。映画「ターミネーター2」のセリフで
 あることが判明)

2.16.2 ロード (Loading)

 ClassCircularityError:
 ClassFormatError:
 NoClassDefFoundError:

・ClassCircularityError は実際に発生するのか?
・バイナリーエディターで書き換えないとできないのでは?

 # JDK 1.1 で動くアプリケーションが 1.2 で NoClassDefFoundError?
 #>1.1 のクラスパスが残っている?

2.16.3 リンク (Linking: Verification, Preparation, and Resolution

・JavaHouse-Brewers の話題で、既存のクラスのダミーを作って public メソッドを置き、
  コンパイルしたクラスから本当のクラスの private (フィールド?) にアクセスできた
  ことから、IllegalAccessError をちゃんと実装していない VM もあるようだ。

・VerifyError (Link) はどんなときに発生するのか?
  ClassFormatError (Load) が発生するので発生しないのでは?
  −>解釈? (話が追い切れなかったのでフォロー求む>各位)

2.16.4 Initialization

・Active use <-> Passive use の違いとは?

・定数値は「インライン展開」のように展開してしまう?

  public class T {
    public final int C = 5;

  }

  とあったときに、

  public class U {
    :
    :
    public void method() {
      if (T.C == nnn) {
        :
        :
      }
    }
  }

  の T.C は 5 に展開されるのか?−> JDK 1.0 ではそうだったが、1.1 以降は違うのでは?

  import java.util.Vector;

  public interface test {
    public static final Vector v = new Vector();
  }

  上記のようなものは許されるのか?

2.16.5 Detailed Initialization Procedure

・宮崎さんによるまとめ (ホワイトボードを見て入力)

  ・オブジェクトに対するロック確保できるまで待機
  ↓
  1.初期化される Class オブジェクトの同期             ←------------------+
  ↓  2.他のスレッドで初期化処理中ならば                                  |
  ↓      1.の Class は wait 状態 → wait から起きたとき2.を繰り返す    |
  3.Class 初期化中に再帰的に初期化処理                                    |
      終ったら Class のロック開放 → 正常終了                               |
                                                                            |
      4.すでに初期化済みならロック開放+正常終了。                        |
      5.Class がエラー状態なら初期化失敗                                  |
                        +                                                  |
          ロック開放と NoClassDefFoundEx                                    |
  6.4、5、以外のときは「初期化中」であることを記録                      |
  ↓                                                                        |
  7.Class != interface                                                    |
            and                                                             |
      ・直接のスーパークラスが未初期化                                      |
        →再帰処理 ---------------------------------------------------------+
      ・直接のスーパークラスが突然終了(=例外発生)
        → Class ロック取得
           エラーの印づけ
           全スレッドに通知
           ロック開放
           スーパークラスと同じ例外発生
           →異常終了

      8.クラス変数イニシャライザ
      |         ・
   +--+   final static ..                            の実行
   |            ・
   |      インターフェースのフィールド・イニシャライザ
   |
   |  +- 9.イニシャライザ実行終了(正常)のとき
   |  |      →Classオブジェクトのロック
   +→|        「初期化済み」と印づけ
      |        すべてのスレッドに通知←待機中のスレッド
      |        ロック開放→手続き終了
      +-10.イニシャライザ実行終了(異常)のとき
         →例外が Error オブジェクトではない
           →ExceptionInInitializerError インスタンス生成
             →作れないとき OutOfMemoryError
            11.Classオブジェクトのロック
                  「エラー発生」と印づけ
                  ロック開放 ← 待機中のスレッド
                  ロック開放
                   Eによって失敗したと手続きを異常終了

・ここでの Class object とは、java.lang.Class クラスのインスタンスという意味か?

・1, 2, 3, 4, 5, のケースがあり、それ以外が 6 なのか?

・6はカレントスレッド以外のスレッドで初期化中だったというケースなのか?

・6の CurrentTread とは自分自身のことか?

・static 初期化ブロックは複数持てるのか?

・10. の "Otherwise" とは「正常終了しなかったとき」という意味か?

・複数クラスローダーがあったら、同じクラスも別個にロードされるのか?

2.16.6 Creation of New Class Instances

・最後の 「C++ とは違って」の部分はどういうい意味か?

  サブクラスのコンストラクター実行中に、
  super() でスーパークラスのコンストラクターを実行したときに、
  スーパークラスのコンストラクター内でスーパークラスのメソッドが呼ばれていたとき、
  サブクラスでそのメソッドをオーバーライドしているとサブクラスのメソッドが
  呼ばれる?

2.16.7 Finalization of Class Instances

・finallize の中で、static 変数に this を保存したら GC されるのか?

2.16.8 Finalization and Unloading of Classes and Interfaces

・インスタンスではなく、クラスの finallizer

2.16.9 Virtual Machine Exit
2.17 Threads

・daemon thread の説明 −> java.lang.Thread#setDaemon() メソッド

・daemon thread は何に使うのか? GC ?

・non daemon thread は各クラスの main() から呼び出されたもの。

・HotJava がアプレットを動かすときは daemon として動かすのか?

昼食:喜多方ラーメン。次回はベトナム料理に決定。

3 Structure of the Java Virtual Machine
3.1 Data Types
3.2 Primitive Types and Values
3.2.1 Integral Types and Values
3.2.2 Floating-Point Types and Values
3.2.3 The returnAddress Type and Values
3.2.4 There Is No boolean Type

・VM には boolean 型は無く、コンパイル時に解決される。−> VMSpec2 では boolean がある

3.3 Reference Types and Values
3.4 Words

・native pointer とは ?

・第2版ではこの "Words" という節は無い

3.5 Runtime Data Areas
3.5.1 The pc Register
3.5.2 Java Stack

・ "-oss" flag.

3.5.3 Heap

・ "-ms" and "-mx" flags

3.5.4 Method Area
3.5.5 Constant Pool
3.5.6 Native Method Stacks

・ "-ss" flag.

・日本語版のミス−>
  p.49 「Javaスタックでは」とあるが、「Native Method Stackでは」の誤り。

3.6 Frames
3.6.1 Local Variables

・第2版では "Words" の節が削除されているので、Word という単語は使われていない。

3.6.2 Operand Stacks

・第2版には Word のサイズや、
  double などが Word より大きくて分割したときどうするかについての記述は無い。

・64ビットの実装系ではどうなる?
  wide 命令とは?
                                −>議論 (追い切れなかったのでフォロー求む>各位)

3.6.3 Dynamic Linking
3.6.4 Normal Method Completion
3.6.5 Abnormal Method Completion
3.6.6 Additional Information
3.7 Representation of Objects

・handle とは何なのか?

・第2版では次の1行で終っている。

  > The Java virtual machine does not mandate any particular internal structure for objects.8

・注8はこうである。

  > 8 In some of Sun's implementations of the Java virtual machine,
  >  a reference to a class instance is a pointer to a handle
  > that is itself a pair of pointers:
  > one to a table containing the methods of the object and a pointer
  > to the Class object that represents the type of the object,
  > and the other to the memory allocated from the heap for the object data.

3.8 Special Initialization Methods
3.9 Exceptions
3.10 The class File Format
3.11 Instruction Set Summary
3.11.1 Types and the Java Virtual Machine
3.11.1 Types and the Java Virtual Machine

・char 型はどのようなときに使うのか?(そもそも使うことがあるのか?)

3.11.2 Load and Store Instructions
3.11.3 Arithmetic Instructions
3.11.4 Type Conversion Instructions
3.11.5 Object Creation and Manipulation
3.11.6 Operand Stack Management Instructions
3.11.7 Control Transfer Instructions
3.11.8 Method Invocation and Return Instructions
3.11.9 Throwing and Handling Exceptions
3.11.10 Implementing finally
3.11.11 Synchronization
3.12 Public Design, Private Implementation

・註:
  デバッガーの仕様はどうなっているのか? −> JVMDI (JDK 1.2)

・JVMPI (プロファイラー) もある (JDK 1.2)

  商品版: Optimize it, Jprobe --> JavaReport に広告

・invokeinterfce が VM レベルでサポートされている意味?

・intsanceof はコストが高いのか?

・refrection は遅いが、動的にロードするときは楽。
  ネットワーク経由でロードするときなどはネットワーク転送が遅いので
  refrection が遅くても意識されない。

次回日程:

  12月4日(土)
  12月5日(日) などが上る。

日曜開催の例はないが、日曜でもかまわないかどうか、という議題が出た。
日曜ではダメという理由は特に出なかった。

以上。

# 終了後に翔泳社の1階にあるにんにく料理の店に行ったのですが、
# 17時30分から、と言われ四谷三丁目方向に歩き
# インド料理店で乾杯しました。

---
ENDO Yasuyuki 
http://web.archive.org/web/20010604214833/http://www.javaopen.org/jfriends/index.html (Japanese Only)


[ 戻る ]