JP2004288076A - Method of access to native library - Google Patents

Method of access to native library Download PDF

Info

Publication number
JP2004288076A
JP2004288076A JP2003081693A JP2003081693A JP2004288076A JP 2004288076 A JP2004288076 A JP 2004288076A JP 2003081693 A JP2003081693 A JP 2003081693A JP 2003081693 A JP2003081693 A JP 2003081693A JP 2004288076 A JP2004288076 A JP 2004288076A
Authority
JP
Japan
Prior art keywords
language
library
access
java
file
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Withdrawn
Application number
JP2003081693A
Other languages
Japanese (ja)
Inventor
Yukio Okuya
行央 奥谷
Hiroaki Kiyoubayashi
弘晃 京林
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hitachi Information Systems Ltd
Original Assignee
Hitachi Information Systems Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hitachi Information Systems Ltd filed Critical Hitachi Information Systems Ltd
Priority to JP2003081693A priority Critical patent/JP2004288076A/en
Publication of JP2004288076A publication Critical patent/JP2004288076A/en
Withdrawn legal-status Critical Current

Links

Images

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

<P>PROBLEM TO BE SOLVED: To provide a method for making an easy access to a native library which stores files written in C language, from Java (R) language. <P>SOLUTION: The method comprises a data-type mapping information defining file 17 describing data-type information to become an argument and return value of a library function; a memory allocating action defining file 16 describing memory allocating action; a program 15 which automatically creates a source code of a Java (R) language class corresponding to a data type of C language from files stored in native libraries 21 to 23; an access library 18 having stored therein programs for access to the library function in the native library; and an access right setting file 13 setting the access right. A source code converted from Java (R) language to C language is created by the program 15, and accesses to the libraries 21 to 23 are made using the source code. <P>COPYRIGHT: (C)2005,JPO&NCIPI

Description

【0001】
【産業上の利用分野】
本発明は、C言語で書かれたライブラリに対してJava(登録商標)言語を用いてアクセスするためのネイティブライブラリへのアクセス方法に関する。
【0002】
【従来の技術】
コンピュータシステムにおけるプログラム言語は、C言語と呼ばれるOS(オペレーションシステム)などの制御プログラムを記述するのに適した言語が使用されているが、近年、インターネット技術の発展によってHTML言語の機能を補う中間コードコンパイラであるJava(登録商標)言語と呼ばれるプラットホームを選ばない言語が使用されてきている。
【0003】
このJava(登録商標)言語を用いてC言語によって作成されたライブリ(ネイティブライブラリと呼ぶ)へデータのアクセスを行うためには、Java(登録商標)言語からネイティブライブラリへアクセスする場合、JNI(Java(登録商標) Native Interface)と呼ばれる機構を利用する必要がある。しかし、このJNI機構を利用するためにはアクセスしたいライブラリの関数単位でC言語によるプログラミングが必要となり、Java(登録商標)プログラマにはC言語のメモリアロケート(メモリの確保)管理などの深い知識も必要とされる。またJava(登録商標)言語にはライブラリおよび関数単位でのアクセス権制御も存在しないため、セキュリティのためのアクセス権の管理を一元化できないものであった。
【0004】
尚、前記Java(登録商標)言語を用いた技術及びアクセス権限の設定に関する技術が記載された文献としては、例えば、特開2000−57113号公報及び特開平5−94357号公報が挙げられる。
【0005】
【発明が解決しようとする課題】
従来技術によるJava(登録商標)言語を用いてC言語によって作成されたネイティブライブラリへのアクセス手法は、前述のように操作者にC言語によるプログラミング能力やメモリアロケート管理能力が必要とされ、Java(登録商標)プログラマにとってはC言語で記載されたライブラリへアクセスすることが困難であり、C言語を習得する必要があるため開発工数を余分に必要とし、更にデータ型変換やメモリアロケート管理を行うためバグが発生し易いと共に、ライブラリに対するアクセス権の設定が煩雑であると言う不具合があった。
【0006】
本発明の目的は、前述の従来技術による不具合を除去することであり、C言語の深い知識を必要とせずに既存ネイティブライブラリへのアクセスを行うことができるネイティブライブラリへのアクセス方法を提供することである。
【0007】
【課題を解決するための手段】
前記目的を達成するために本発明は、Java(登録商標)言語からC言語で書かれたファイルを格納するネイティブライブラリへアクセスするアクセス方法i6ew、ネイティブライブラリ関数の引数と戻り値となるデータ型情報を記述したデータ型マッピング情報定義ファイルと、メモリアロケート動作を記述したメモリアロケート動作定義ファイルと、ネイティブライブラリに格納されたファイルからC言語のデータ型と対応するJava(登録商標)言語クラスのソースコードを自動生成するクラスタ生成プログラムと、ネイティブライブラリのライブラリ関数へアクセスするプログラムを格納するアクセス用ライブラリと、アクセス権を設定するアクセス権設定ファイルとを設け、前記データ型マッピング情報定義ファイルに記述されたネイティブライブラリ関数の引数及び戻り値と、前記メモリアロケート動作定義ファイルに記述したメモリアロケート動作と、アクセス権設定ファイルに設定したアクセス権とを用い、前記プログラムによりJava(登録商標)言語をC言語に変換したソースコードを生成し、該ソースコードによりネイティブライブラリをアクセスすることを特徴とする。
【0008】
【発明の実施の形態】
以下、本発明の一実施形態によるネイティブライブラリへのアクセス方法を図面を参照して詳細に説明する。図1は、本実施形態によるJava(登録商標)プログラムからネイティブライブラリへアクセスするためのアクセス方法を適用したシステムの全体構成を示す図、図2は本実施形態によるJava(登録商標)側での呼び出しメソッドを説明するため図、図3は本実施形態によるデータ型マッピング情報定義ファイルを説明するための図、図4はメモリアロケート動作定義ファイル及びアクセス権設定ファイルを説明するための図、図5〜図7は本実施形態によるJava(登録商標)側での呼び出しメソッドの複数動作例を説明するための図である。
【0009】
まず本発明によるネイティブライブラリへのアクセス方法を適用したアクセスシステムは、図1に示す如く、C言語で生成された複数のネイティブライブラリ21〜23及び該ライブラリ21〜23のデータ型の定義を格納するデータ型定義ファイル24とを格納するネイティブライブラリ群200に対して設けられたアクセス構成100を成し、このアクセス構成100は、ネイティブライブラリを呼び出すための呼び出し用メソッド12を含むJava(登録商標)プログラム11と、前記呼び出し用メソッド12を用いて前記ネイティブライブラリ21〜23のファイルからデータを呼び出すためのアクセス用ライブラリ18と、前記データ型定義ファイル24に格納したライブラリ毎のデータ型定義を入力とし、データ型マッピング情報を格納するデータ型マッピング情報定義ファイル17と、C言語のメモリロケート動作の定義を格納したメモリロケート動作定義ファイル16と、前記データ型マッピング情報定義ファイル17に格納したデータ型マッピング情報定義とメモリロケート動作定義ファイル16に格納したメモリロレート動作定義とを用いてクラスタを生成するクラスタ生成プログラム15と、操作者に応じた各ライブラり21〜23に対するアクセス権が設定されたアクセス権設定ファイル13とを備える。
【0010】
前記呼び出し用メソッド12は、図2下段に示す如く、引数名/データ型/内容を格納したものであり、例えば図2上段に示す如く、アクセス対象のライブラリ名及びデータ型が「String Libname」、アクセスしたい関数名及びデータ型が「String funcname」、アクセス対象の関数への引数リストが「Vevter arge」、アクセス対象の関数からの戻り値が「Vecter results」の如く設定されているものである。即ち、呼び出し用メソッド12は、呼び出し対象となるネイティブライブラリの名前/関数名/引数リスト/戻り値格納領域を格納している。
【0011】
ここで本実施形態によるライブラリ名及び関数名が、図3(a)に示す如く、ライブラリ名として「sample_library.dll」、関数名として各々「long sample_function1(long p1, long p2)」/「long sample_function1(long p1, long p2)」/「long sample_function3(char p1[], long p2)」/「long sample_function4(long p)」である場合、データ型マピング情報定義ファイル17は、図3(b)に示す如く定義される。この図3(b)に示すデータ型マピング情報定義ファイル17は、簡単に説明すると、左側のコマンド欄がJava(登録商標)言語とC言語との対応を示し、右側の内容欄が、そのコマンドの内容を示している。即ち本実施形態によるデータ型マピング情報定義ファイル17は、Java(登録商標)言語で使用される型とC言語で使用される型のマッピングの記述と、当該データのメモリ領域がどのように扱われるか,またはどちら向きのデータなのかも指定している。尚、ここで指定するキーワードはメモリアロケート動作定義ファイル16にて定義されたキーワードである。
【0012】
前記メモリアロケート動作定義ファイル16は、図4(a)に示す如く、データ型マピング情報定義ファイル同様に、左側のコマンド欄がJava(登録商標)言語とC言語との対応を示し、右側の内容欄が、そのコマンドの内容を示している。即ちメモリアロケート動作定義ファイル16は、あるデータがネイティブライブラリへの入力データなのか,出力データなのか,または両方なのかをioに指定し、またそのデータの領域はネイティブライブラリ関数内でアロケートされるものなのか、そうでないのかをメモリに指定するものである。
【0013】
また前記アクセス権設定ファイル13は、図4(b)に示す如く、「sample_library」に対して、各々「sample_function1」(レベル1)、「sample_function2」(レベル2)、「sample_function3」(レベル3)、の如く、段階的なアクセス権が設定されている。即ち、該アクセス権設定ファイル13は、ネイティブライブラリの名前及び関数名単位にgrant指定することによりアクセス許可を表す様に設定されている。
【0014】
さて、この様に構成されたネイティブライブラリへのアクセス方法を適用したアクセスシステムは、ネイティブライブラリ関数の引数/戻り値となるデータ型情報を記述したデータ型マッピング情報定義ファイル17と、メモリアロケート動作を記述したメモリアロケート動作定義ファイル16と、そのファイルからC言語のデータ型と対応するJava(登録商標)言語クラスのソースコードを自動生成するプログラム15と、ネイティブライブラリ21〜23に格納されたファイルのライブラリ関数へアクセスするプログラムを格納するアクセス用ライブラリ18と、アクセス権制御を設定するアクセス権設定ファイル(ポリシーファイル)13とを設け、前記データ型マッピング情報定義ファイル17に記述されたネイティブライブラリ関数の引数及び戻り値と、前記メモリアロケート動作定義ファイル16に記述したメモリアロケート動作と、アクセス権設定ファイル13に設定したアクセス権とを用い、前記プログラム15によりJava(登録商標)言語をC言語に変換し且つアクセス権を設定したソースコードを生成し、該ソースコードによりネイティブライブラリをアクセスすることによって、Java(登録商標)プログラム11からネイティブライブラリ21〜23へデータを権限付きでアクセスすることができる。
【0015】
<例1>
この動作は、例えばJavaからライブラリsample_library.dllの関数sample_function1を呼びたい場合,Java(登録商標)側で図5(a)に示すライブラリ名51/関数名52/第1引数53/第2引数54を含むメソッドを読み出すことにより、データマッピング型定義ファイル17に格納した定義ファイルを元にC言語側で図5(b)に示すコードを実行する。このコードは、メモリアロケート動作定義ファイル16に格納した情報を元にJava(登録商標)言語をC言語に変換することを示し、図示の例では整数値のコピーを実行することを意味している。この関数実行結果rtnは、Intergre型に変換され、resultsへ格納される。
【0016】
<例2>
この動作は、例えばJavaからライブラリsample_library.dllの関数sample_function2を呼びたい場合、Java(登録商標)側で図6(a)に示すライブラリ名61/関数名62/第1引数63を含むメソッドを読み出すことにより、データマッピング型定義ファイル17に格納した定義ファイルを元にC言語側で図6(b)に示すコードを実行する。このコードは、メモリアロケート動作定義ファイル16に格納した情報を元にJava(登録商標)言語をC言語に変換することを示し、図示の例では戻り値64とargesから値を取得し、関数の呼び出し66を実行することによりString型からCの文字列へ変換を実行することを意味している。この関数実行結果rtnは、Intergre型に変換され、resultsへ格納される。
【0017】
<例3>
この動作は、例えばJava(登録商標)からライブラリsample_library.dllの関数sample_function3を呼びたい場合、Java(登録商標)側で図7(a)に示すライブラリ名71/関数名72/第1引数73/第2引数74を含むメソッドを読み出すことにより、データマッピング型定義ファイル17に格納した定義ファイルを元にC言語側で図7(b)に示すコードを実行する。このコードは、メモリアロケート動作定義ファイル16に格納した情報を元にJava(登録商標)言語をC言語に変換することを示し、図示の例ではString型からCの文字列へ変換を実行することを意味している。この関数実行結果rtnは、Intergre型に変換され、resultsへ格納される。
【0018】
この本実施形態によるネイティブライブラリへのアクセス方法を適用したアクセスシステムは、ネイティブライブラリ関数の引数/戻り値となるデータ型情報を記述したデータ型マッピング情報定義ファイル17と、メモリアロケート動作を記述したメモリアロケート動作定義ファイル16と、そのファイルからC言語のデータ型と対応するJava(登録商標)言語クラスのソースコードを自動生成するプログラム15と、実際にライブラリ関数へアクセスするプログラムを格納するアクセス用ライブラリ18と、アクセス権制御を設定するアクセス権設定ファイル(ポリシーファイル)13とを設け、前述のファイルに基づいてプログラムを実装し、Java(登録商標)プログラム11からネイティブライブラリ21〜23へアクセスする場合,予め定義された呼び出し用メソッド12を呼び出すことにより、メモリアロケート動作定義ファイル16に格納した情報を元にJava(登録商標)言語をC言語に変換し、この変換後のC言語を実行した得た結果をJava(登録商標)言語形式で戻すことよって、C言語の深い知識及びプログラミング能力を必要とせずにプログラマがJava(登録商標)言語を用いてC言語のライブラリにアクセスすることができる。
【0019】
また本実施形態によればプリミティブ型やその配列といったデータ型は組み込み済みのため、単純な引数を持つネイティブライブラリ関数の呼び出しも容易に行うことができる。更にライブラリおよび関数単位のアクセス権の制御を可能とするので不必要なライブラリへのアクセスを容易に防止できる。
【0020】
また、前記Java(登録商標)言語をC言語に変換する際にアクセス用ライブラリ18がアクセス権設定ファイル13に格納したアクセス権を設定することによって、C言語の深い知識及びプログラミング能力を必要とせずにライブラリに対するアクセス権を容易に設定することができる。
【0021】
【発明の効果】
以上説明したように本発明によるネイティブライブラリへのアクセス方法を適用したアクセスシステムは、ネイティブライブラリ関数の引数/戻り値となるデータ型情報を記述したデータ型マッピング情報定義ファイルと、メモリアロケート動作を記述したメモリアロケート動作定義ファイルと、そのファイルからC言語のデータ型と対応するJava(登録商標)言語クラスのソースコードを自動生成するプログラムと、実際にライブラリ関数へアクセスするプログラムを格納するアクセス用ライブラリと、アクセス権制御を設定するアクセス権設定ファイルとを設けることによって、C言語の深い知識を必要とせずに既存ネイティブライブラリへのアクセスを行うことができる。
【図面の簡単な説明】
【図1】本発明の一実施形態によるJava(登録商標)プログラムからネイティブライブラリへアクセスするためのアクセスシステムの全体構成を示す図。
【図2】本実施形態によるJava(登録商標)側での呼び出しメソッドを説明するため図。
【図3】本実施形態によるデータ型マッピング情報定義ファイルを説明するための図。
【図4】本実施形態によるメモリアロケート動作定義ファイル及びアクセス権設定ファイルを説明するための図。
【図5】本実施形態によるJava(登録商標)側での呼び出しメソッドの動作例1を説明するための図。
【図6】本実施形態によるJava(登録商標)側での呼び出しメソッドの動作例2を説明するための図。
【図7】本実施形態によるJava(登録商標)側での呼び出しメソッドの動作例3を説明するための図。
【符号の説明】
100:アクセス構成、11:Java(登録商標)プログラム、12:呼び出しメソッド、13:アクセス権設定ファイル、14:データ型変換用クラス、15:クラスタ生成プログラム、16:メモリロケート動作定義ファイル、17:データ型ビットマップ情報定義ファイル、21〜23:ライブラリ、24:データ型定義ファイル。
[0001]
[Industrial applications]
The present invention relates to a method for accessing a native library for accessing a library written in the C language using the Java (registered trademark) language.
[0002]
[Prior art]
As a program language in a computer system, a language called C language suitable for describing a control program such as an OS (operation system) is used. In recent years, an intermediate code that supplements the function of the HTML language due to the development of Internet technology. A platform-independent language called the Java language, which is a compiler, has been used.
[0003]
In order to access data to a library (called a native library) created in C language using the Java (registered trademark) language, when accessing the native library from the Java (registered trademark) language, JNI (Java) is used. It is necessary to use a mechanism called (registered trademark) Native Interface. However, in order to use this JNI mechanism, it is necessary to perform programming in C language for each function of a library to be accessed, and a Java (registered trademark) programmer needs deep knowledge of C language memory allocation (memory allocation) management and the like. Needed. Further, in the Java (registered trademark) language, there is no access right control for each library and function, so that access right management for security cannot be unified.
[0004]
References describing technologies using the Java (registered trademark) language and technologies relating to setting of access authority include, for example, JP-A-2000-57113 and JP-A-5-94357.
[0005]
[Problems to be solved by the invention]
According to the conventional technique for accessing a native library created in C language using Java (registered trademark) language, as described above, an operator needs programming ability in C language and memory allocating management ability, and Java ( (Registered trademark) It is difficult for a programmer to access a library written in C language, and it is necessary to learn C language, which requires extra development man-hours, and further performs data type conversion and memory allocation management. There was a problem that a bug was easily generated and that setting access rights to the library was complicated.
[0006]
SUMMARY OF THE INVENTION It is an object of the present invention to provide a method for accessing a native library capable of accessing an existing native library without requiring a deep knowledge of the C language, in order to eliminate the above-mentioned disadvantages of the prior art. It is.
[0007]
[Means for Solving the Problems]
In order to achieve the above object, the present invention provides an access method i6ew for accessing a native library for storing a file written in C language from Java (registered trademark), and data type information as arguments and return values of a native library function Data type mapping information definition file describing the memory allocation operation definition file describing the memory allocation operation, and the source code of the Java (registered trademark) language class corresponding to the data type of the C language from the file stored in the native library A program for automatically generating a file, an access library for storing a program for accessing a library function of a native library, and an access right setting file for setting an access right, which are described in the data type mapping information definition file. Using the arguments and return values of the specified native library function, the memory allocating operation described in the memory allocating operation definition file, and the access right set in the access right setting file, the Java (registered trademark) language is converted to C by the program. It is characterized in that a source code converted into a language is generated, and a native library is accessed by the source code.
[0008]
BEST MODE FOR CARRYING OUT THE INVENTION
Hereinafter, a method for accessing a native library according to an embodiment of the present invention will be described in detail with reference to the drawings. FIG. 1 is a diagram showing an overall configuration of a system to which an access method for accessing a native library from a Java (registered trademark) program according to the present embodiment, and FIG. 2 is a diagram showing a configuration on the Java (registered trademark) side according to the present embodiment. FIG. 3 is a diagram for explaining a calling method, FIG. 3 is a diagram for explaining a data type mapping information definition file according to the present embodiment, FIG. 4 is a diagram for explaining a memory allocate operation definition file and an access right setting file, and FIG. 7 are diagrams for explaining a plurality of operation examples of the calling method on the Java (registered trademark) side according to the present embodiment.
[0009]
First, as shown in FIG. 1, an access system to which a method for accessing a native library according to the present invention stores a plurality of native libraries 21 to 23 generated in C language and data type definitions of the libraries 21 to 23. An access configuration 100 is provided for a native library group 200 that stores the data type definition file 24. The access configuration 100 is a Java (registered trademark) program including a calling method 12 for calling a native library. 11; an access library 18 for calling data from the files of the native libraries 21 to 23 using the calling method 12; and a data type definition for each library stored in the data type definition file 24. Data type mapping , A memory location operation definition file 16 storing a memory location operation definition in C language, and a data type mapping information definition and memory stored in the data type mapping information definition file 17. A cluster generation program 15 for generating a cluster using the memory roll-rate operation definition stored in the locate operation definition file 16, an access right setting file 13 in which access rights to the respective libraries 21 to 23 according to the operator are set. Is provided.
[0010]
The calling method 12 stores argument names / data types / contents as shown in the lower part of FIG. 2. For example, as shown in the upper part of FIG. 2, the library name and data type of the access target are “String Libname”, The function name and data type to be accessed are set such as "String function", the argument list to the function to be accessed is set to "Veter arge", and the return value from the function to be accessed is set to "Vector results". That is, the calling method 12 stores the name / function name / argument list / return value storage area of the native library to be called.
[0011]
Here, as shown in FIG. 3A, the library name and the function name according to the present embodiment are “sample_library.dll” as the library name and “long sample_function1 (long p1, long p2)” / “long sample_function1” as the function name, respectively. If (long p1, long p2) / "long sample_function3 (char p1 [], long p2)" / "long sample_function4 (long p)", the data type mapping information definition file 17 is shown in FIG. Defined as shown. In the data type mapping information definition file 17 shown in FIG. 3B, the command column on the left shows the correspondence between the Java (registered trademark) language and the C language, and the content column on the right shows the command Is shown. That is, the data type mapping information definition file 17 according to the present embodiment describes how to describe the mapping between the type used in the Java (registered trademark) language and the type used in the C language, and how the memory area of the data is treated. Or which direction the data is. Note that the keyword specified here is a keyword defined in the memory allocate operation definition file 16.
[0012]
As shown in FIG. 4A, in the memory allocate operation definition file 16, the command column on the left side shows the correspondence between the Java (registered trademark) language and the C language, and the contents on the right side as in the data type mapping information definition file. The column indicates the content of the command. That is, the memory allocation operation definition file 16 specifies io whether certain data is input data to the native library, output data, or both, and the area of the data is allocated in the native library function. This is to specify in the memory whether it is or not.
[0013]
In addition, as shown in FIG. 4 (b), the access right setting file 13 responds to “sample_library” with “sample_function1” (level 1), “sample_function2” (level 2), “sample_function3” (level 3), A stepwise access right is set. That is, the access right setting file 13 is set so as to represent the access permission by specifying grant for each native library name and function name.
[0014]
The access system to which the access method for the native library configured as described above is applied includes a data type mapping information definition file 17 describing data type information as arguments / return values of a native library function, and a memory allocating operation. The memory allocation operation definition file 16 described, a program 15 for automatically generating a Java (registered trademark) language class source code corresponding to a data type of C language from the file, and a file 15 stored in the native libraries 21 to 23 An access library 18 for storing a program for accessing a library function, and an access right setting file (policy file) 13 for setting access right control are provided, and a native library described in the data type mapping information definition file 17 is provided. Using the arguments and return values of the function, the memory allocating operation described in the memory allocating operation definition file 16, and the access right set in the access right setting file 13, the program 15 converts the Java (registered trademark) language into the C language. By generating a source code that has been converted into a file and setting an access right, and accessing the native library using the source code, it is possible to access data from the Java (registered trademark) program 11 to the native libraries 21 to 23 with authority. it can.
[0015]
<Example 1>
This operation is performed, for example, from the library sample_library. When the user wants to call the function sample_function1 of dll, the Java (registered trademark) side reads out a method including the library name 51 / function name 52 / first argument 53 / second argument 54 shown in FIG. The code shown in FIG. 5B is executed on the C language side based on the definition file stored in the type definition file 17. This code indicates that the Java (registered trademark) language is to be converted into the C language based on the information stored in the memory allocate operation definition file 16, and in the illustrated example, this means that the integer value is copied. . This function execution result rtn is converted into an Intergre type and stored in results.
[0016]
<Example 2>
This operation is performed, for example, from the library sample_library. When the user wants to call the function sample_function2 of dll, the Java (registered trademark) side reads out a method including the library name 61 / function name 62 / first argument 63 shown in FIG. The code shown in FIG. 6B is executed on the C language side based on the stored definition file. This code indicates that the Java (registered trademark) language is to be converted into the C language based on the information stored in the memory allocate operation definition file 16, and in the illustrated example, the value is obtained from the return value 64 and arges, and the function is obtained. Executing the call 66 means that the conversion from the String type to the character string of C is executed. This function execution result rtn is converted into an Intergre type and stored in results.
[0017]
<Example 3>
This operation is performed, for example, from Java (registered trademark) from the library sample_library. When it is desired to call the function "sample_function3" of the DLL, the Java (registered trademark) side reads out a method including the library name 71 / function name 72 / first argument 73 / second argument 74 shown in FIG. The code shown in FIG. 7B is executed on the C language side based on the definition file stored in the type definition file 17. This code indicates that the Java (registered trademark) language is to be converted into the C language based on the information stored in the memory allocate operation definition file 16, and in the illustrated example, the conversion from the String type to the C character string is performed. Means This function execution result rtn is converted into an Intergre type and stored in results.
[0018]
The access system to which the method for accessing the native library according to the present embodiment is applied includes a data type mapping information definition file 17 describing data type information as arguments / return values of a native library function, and a memory describing a memory allocation operation. An allocate operation definition file 16, a program 15 for automatically generating a source code of a Java (registered trademark) language class corresponding to a data type of C language from the file, and an access library for storing a program for actually accessing a library function 18 and an access right setting file (policy file) 13 for setting access right control, a program is implemented based on the file, and the Java (registered trademark) program 11 accesses the native libraries 21 to 23. In this case, the Java ™ language is converted into C language based on the information stored in the memory allocating operation definition file 16 by calling a predefined calling method 12, and the converted C language is executed. By returning the obtained result in Java (registered trademark) format, the programmer can access the C language library using Java (registered trademark) without requiring deep knowledge and programming ability of C language. it can.
[0019]
In addition, according to the present embodiment, since the data types such as the primitive type and the array thereof are already installed, it is possible to easily call a native library function having simple arguments. Furthermore, since the access right can be controlled for each library and each function, unnecessary access to the library can be easily prevented.
[0020]
In addition, by setting the access right stored in the access right setting file 13 by the access library 18 when converting the Java (registered trademark) language into the C language, deep knowledge and programming ability of the C language are not required. The access right to the library can be easily set.
[0021]
【The invention's effect】
As described above, the access system to which the method for accessing the native library according to the present invention is applied is a data type mapping information definition file in which data type information as arguments / return values of a native library function is described, and a memory allocation operation is described. Memory allocation operation definition file, a program for automatically generating a Java (registered trademark) language class source code corresponding to a data type of C language from the file, and an access library for storing a program for actually accessing a library function And an access right setting file for setting access right control, it is possible to access an existing native library without requiring deep knowledge of the C language.
[Brief description of the drawings]
FIG. 1 is a diagram showing an overall configuration of an access system for accessing a native library from a Java (registered trademark) program according to an embodiment of the present invention.
FIG. 2 is a view for explaining a call method on the Java (registered trademark) side according to the embodiment;
FIG. 3 is an exemplary view for explaining a data type mapping information definition file according to the embodiment;
FIG. 4 is an exemplary view for explaining a memory allocation operation definition file and an access right setting file according to the embodiment;
FIG. 5 is an exemplary view for explaining an operation example 1 of a call method on the Java (registered trademark) side according to the embodiment;
FIG. 6 is an exemplary view for explaining an operation example 2 of a calling method on the Java (registered trademark) side according to the embodiment;
FIG. 7 is an exemplary view for explaining an operation example 3 of a calling method on the Java (registered trademark) side according to the embodiment;
[Explanation of symbols]
100: access configuration, 11: Java (registered trademark) program, 12: calling method, 13: access right setting file, 14: data type conversion class, 15: cluster generation program, 16: memory locate operation definition file, 17: Data type bitmap information definition file, 21 to 23: library, 24: data type definition file.

Claims (1)

Java(登録商標)言語からC言語で書かれたファイルを格納するネイティブライブラリへアクセスするアクセス方法であって、ネイティブライブラリ関数の引数と戻り値となるデータ型情報を記述したデータ型マッピング情報定義ファイルと、メモリアロケート動作を記述したメモリアロケート動作定義ファイルと、ネイティブライブラリに格納されたファイルからC言語のデータ型と対応するJava(登録商標)言語クラスのソースコードを自動生成するクラスト生成プログラムと、ネイティブライブラリのライブラリ関数へアクセスするプログラムを格納するアクセス用ライブラリと、アクセス権を設定するアクセス権設定ファイルとを設け、前記データ型マッピング情報定義ファイルに記述されたネイティブライブラリ関数の引数及び戻り値と、前記メモリアロケート動作定義ファイルに記述したメモリアロケート動作と、アクセス権設定ファイルに設定したアクセス権とを用い、前記クラスタ生成プログラムによりJava(登録商標)言語をC言語に変換したソースコードを生成し、該ソースコードによりネイティブライブラリをアクセスすることを特徴とするネイティブライブラリへアクセスするアクセス方法。An access method for accessing a native library storing a file written in the C language from the Java (registered trademark) language, wherein a data type mapping information definition file describing data type information as arguments and return values of a native library function A memory allocating operation definition file describing a memory allocating operation, a crust generating program for automatically generating a Java (registered trademark) language class source code corresponding to a C language data type from a file stored in a native library, An access library for storing a program for accessing a library function of the native library and an access right setting file for setting access rights are provided, and a reference to the native library function described in the data type mapping information definition file is provided. And a return value, a memory allocating operation described in the memory allocating operation definition file, and an access right set in an access right setting file, and a source obtained by converting Java (registered trademark) language into C language by the cluster generation program. An access method for accessing a native library, comprising generating code and accessing the native library with the source code.
JP2003081693A 2003-03-25 2003-03-25 Method of access to native library Withdrawn JP2004288076A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2003081693A JP2004288076A (en) 2003-03-25 2003-03-25 Method of access to native library

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2003081693A JP2004288076A (en) 2003-03-25 2003-03-25 Method of access to native library

Publications (1)

Publication Number Publication Date
JP2004288076A true JP2004288076A (en) 2004-10-14

Family

ID=33295156

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2003081693A Withdrawn JP2004288076A (en) 2003-03-25 2003-03-25 Method of access to native library

Country Status (1)

Country Link
JP (1) JP2004288076A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102043653A (en) * 2010-12-23 2011-05-04 中国农业银行股份有限公司 Cache system and methods for modifying cache configuration and operating and querying cache data
JP2012173771A (en) * 2011-02-17 2012-09-10 Hitachi Solutions Ltd Library conversion method and program between programming languages
JP2013097745A (en) * 2011-11-05 2013-05-20 Kyocera Document Solutions Inc Software development kit, extended application for image forming apparatus created by using the same, and portable terminal device including the application
JP2013097747A (en) * 2011-11-05 2013-05-20 Kyocera Document Solutions Inc Software developing kit

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102043653A (en) * 2010-12-23 2011-05-04 中国农业银行股份有限公司 Cache system and methods for modifying cache configuration and operating and querying cache data
JP2012173771A (en) * 2011-02-17 2012-09-10 Hitachi Solutions Ltd Library conversion method and program between programming languages
JP2013097745A (en) * 2011-11-05 2013-05-20 Kyocera Document Solutions Inc Software development kit, extended application for image forming apparatus created by using the same, and portable terminal device including the application
JP2013097747A (en) * 2011-11-05 2013-05-20 Kyocera Document Solutions Inc Software developing kit

Similar Documents

Publication Publication Date Title
US7543309B2 (en) Efficient linking and loading for late binding and platform retargeting
US7143421B2 (en) Highly componentized system architecture with a demand-loading namespace and programming model
Robinson et al. Professional C# (2004 Ed.)(Wrox)
US8434099B2 (en) Efficient linking and loading for late binding and platform retargeting
JP5009299B2 (en) Separate extension and device driver configuration
US5247678A (en) Load time linker for software used with a multiprocessor system
US7565665B2 (en) Efficient linking and loading for late binding and platform retargeting
US6557168B1 (en) System and method for minimizing inter-application interference among static synchronized methods
US6108661A (en) System for instance customization
KR101795844B1 (en) Runtime system
US6526457B1 (en) Systems utility object interface for facilitating software portability
KR20060123513A (en) Method for configuring a computer program
US20090133042A1 (en) Efficient linking and loading for late binding and platform retargeting
US8200938B2 (en) Computer system and method providing a memory buffer for use with native and platform-independent software code
US7730465B2 (en) Mixed types
US7213098B2 (en) Computer system and method providing a memory buffer for use with native and platform-independent software code
US7159222B1 (en) Highly componentized system architecture with object mutation
JP4084956B2 (en) Object collection method and system
US8676842B2 (en) Creating multiple Mbeans from a factory Mbean
JP2004288076A (en) Method of access to native library
US20020073133A1 (en) Register allocation method and software development method for various execution environments and LSI for executing developed software
JP2003241967A (en) Program execution device, its method and program executed therein
Gallardo et al. Development and Use of Dynamic Link Libraries Generated Under Various Calling Conventions
US20080320034A1 (en) Method for client management of jmx mbean state
Ogel et al. Towards active applications: the virtual virtual machine approach

Legal Events

Date Code Title Description
A300 Withdrawal of application because of no request for examination

Free format text: JAPANESE INTERMEDIATE CODE: A300

Effective date: 20060606