@article{oai:ipsj.ixsq.nii.ac.jp:00174600, author = {福室, 嶺 and 千葉, 滋 and Ryo, Fukumuro and Shigeru, Chiba}, issue = {4}, journal = {情報処理学会論文誌プログラミング(PRO)}, month = {Sep}, note = {本論文では,有効範囲を既知のコールパス上に限定することで安全に利用できるクラス拡張method sealsを提案する.クラス拡張は既存のクラスを拡張するための言語機構であり,RubyやAspectJ,C#など様々な言語に取り入れられている.クラス拡張を用いることで,既存のクラスに対してソースコードを書き換えることなくメソッドの追加や再定義を行える.しかし,クラス拡張はモジュラリティの向上に寄与する一方で,誤動作を引き起こしやすい.これはクラス拡張どうしの衝突や,クラス拡張が想定外の領域で有効になることが主な要因である.こうした問題を解決するために,プログラマのコードに対する理解度に応じてその有効範囲を段階的に拡張できるように設計されたクラス拡張method sealsを提案する.本機構では,プログラマにとって未知のパッケージのコードはブラックボックス内にあると見なし,クラス拡張が無効になる.また,ブラックボックス内から発するコールパス上ではそれ以外のコードも一時的にブラックボックス内にあるものと見なす.これにより,クラス拡張がブラックボックス内のコードに対して予期せぬ影響を与え,ひいてはプログラム全体の誤動作を引き起こすことを防げる.本研究ではRuby処理系上にmethod sealsを実装し,いくつかの条件下でその実行性能を評価した., We propose method seals, a safe class extension limiting its scope to known call paths. Class extensions allow us to extend an existing class to add or modify a method without rewriting its code, and they are supported by various languages including Ruby, AspectJ, and C#. They are easy to cause unintended behavior due to collision among multiple extensions or being enabled in an unexpected domain while they contribute to improvement modularity. To address such a problem, we propose method seals designed to allow class extensions control their effective range depending on the degree of understanding about a code base of programmers. Method seals regard code in an unknown package as a black box and disable class extensions there. Furthermore, they also temporarily regard callees of such a package as being in a black box. This prevents class extensions from giving an unexpected impact on codes in black boxes and causing an unintended behavior of a whole program. We implement method seals on Ruby interpreter and evaluates its performance under several conditions.}, pages = {16--26}, title = {有効範囲を既知のコールパスに限定するRuby向けの安全なクラス拡張Method seals}, volume = {9}, year = {2016} }