diff options
author | michelou <michelou@epfl.ch> | 2007-06-11 12:09:35 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2007-06-11 12:09:35 +0000 |
commit | d2d5fb166c5c7294b0459732b3fa3815b8d82fda (patch) | |
tree | 04ed62066f0f8a45568f0f0b18762596a3ddd94e /test/files/jvm | |
parent | 908decebd0f890068221ff586ebd7b3492f37c0f (diff) | |
download | scala-d2d5fb166c5c7294b0459732b3fa3815b8d82fda.tar.gz scala-d2d5fb166c5c7294b0459732b3fa3815b8d82fda.tar.bz2 scala-d2d5fb166c5c7294b0459732b3fa3815b8d82fda.zip |
added test for @native attribute
Diffstat (limited to 'test/files/jvm')
-rwxr-xr-x | test/files/jvm/libnatives.so | bin | 0 -> 5359 bytes | |||
-rwxr-xr-x | test/files/jvm/mkLibNatives.sh | 23 | ||||
-rw-r--r-- | test/files/jvm/natives.c | 8 | ||||
-rw-r--r-- | test/files/jvm/natives.check | 1 | ||||
-rw-r--r-- | test/files/jvm/natives.h | 21 | ||||
-rw-r--r-- | test/files/jvm/natives.scala | 12 |
6 files changed, 65 insertions, 0 deletions
diff --git a/test/files/jvm/libnatives.so b/test/files/jvm/libnatives.so Binary files differnew file mode 100755 index 0000000000..ccbcdd646f --- /dev/null +++ b/test/files/jvm/libnatives.so diff --git a/test/files/jvm/mkLibNatives.sh b/test/files/jvm/mkLibNatives.sh new file mode 100755 index 0000000000..9d4ded597f --- /dev/null +++ b/test/files/jvm/mkLibNatives.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +CLASS_NAME=Test\$ +CLASS_DIR=natives-jvm + +OBJ_NAME=natives +LIB_NAME=libnatives + +JAVAH=javah +JAVAH_OPTIONS="-jni -force -classpath ${CLASS_DIR} -o ${OBJ_NAME}.h" + +CC=gcc +CC_OPTIONS=-c +CC_INCLUDES="-I${JAVA_HOME}/include -I${JAVA_HOME}/include/${OSTYPE}" + +#echo ${JAVAH} ${JAVAH_OPTIONS} ${CLASS_NAME} +#${JAVAH} ${JAVAH_OPTIONS} ${CLASS_NAME} + +#echo ${CC} ${CC_OPTIONS} ${CC_INCLUDES} -o ${OBJ_NAME}.o natives.c +${CC} ${CC_OPTIONS} ${CC_INCLUDES} -o ${OBJ_NAME}.o natives.c + +#echo ${CC} -shared -Wl,-soname,${LIB_NAME} -o ${LIB_NAME}.so ${OBJ_NAME}.o +${CC} -shared -Wl,-soname,${LIB_NAME} -o ${LIB_NAME}.so ${OBJ_NAME}.o diff --git a/test/files/jvm/natives.c b/test/files/jvm/natives.c new file mode 100644 index 0000000000..7b6d7b5ba5 --- /dev/null +++ b/test/files/jvm/natives.c @@ -0,0 +1,8 @@ +#include "natives.h" + +JNIEXPORT jstring JNICALL Java_Test_00024_sayHello + (JNIEnv *env, jobject thisobject, jstring js) + +{ + return js; +} diff --git a/test/files/jvm/natives.check b/test/files/jvm/natives.check new file mode 100644 index 0000000000..2265459198 --- /dev/null +++ b/test/files/jvm/natives.check @@ -0,0 +1 @@ +Invocation returned "Scala is great!" diff --git a/test/files/jvm/natives.h b/test/files/jvm/natives.h new file mode 100644 index 0000000000..0d360d3654 --- /dev/null +++ b/test/files/jvm/natives.h @@ -0,0 +1,21 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class Test__ */ + +#ifndef _Included_Test__ +#define _Included_Test__ +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: Test__ + * Method: sayHello + * Signature: (Ljava/lang/String;)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL Java_Test_00024_sayHello + (JNIEnv *, jobject, jstring); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/test/files/jvm/natives.scala b/test/files/jvm/natives.scala new file mode 100644 index 0000000000..d3cb24a9d9 --- /dev/null +++ b/test/files/jvm/natives.scala @@ -0,0 +1,12 @@ +object Test { + //println("java.library.path=" + System.getProperty("java.library.path")) + System.loadLibrary("natives") + + @native + def sayHello(s: String): String = null + + def main(args: Array[String]) { + val s = sayHello("Scala is great!") + println("Invocation returned \"" + s + "\"") + } +} |