Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
内部类中的Scala本机方法_Scala_Java Native Interface - Fatal编程技术网

内部类中的Scala本机方法

内部类中的Scala本机方法,scala,java-native-interface,Scala,Java Native Interface,我有: 前两个方法工作得很好,但是内部类上的本机方法给出了 class XCClass { @native protected def createWin(displayPtr: Long, width: Int, height: Int, backGroundColour: Int = white.value, borderColour: Int = darkblue.value, borderWidth: Int = 0, xPosn: Int = 0, yPosn: In

我有:

前两个方法工作得很好,但是内部类上的本机方法给出了

class XCClass
{   
  @native protected def createWin(displayPtr: Long, width: Int, height: Int, backGroundColour: Int = white.value,
    borderColour: Int = darkblue.value, borderWidth: Int = 0, xPosn: Int = 0, yPosn: Int = 0): Long
  @native protected def xOpen(): Long  
  System.load("/sdat/projects/prXCpp/Release/libprXCpp.so")  
//Code edited out

  class Window(width: Int, height: Int, backGroundColour: ColourInt = white, borderColour: ColourInt = darkblue,
    borderWidth: Int = 0, xPosn: Int = 0, yPosn: Int = 0)
  {
  val xWinPtr = createWin(xServPtr, width, height, backGroundColour.value, borderColour.value, borderWidth, xPosn, yPosn)
  @native def drawLine(x1: Int, y1: Int, x2: Int, y2: Int): Unit
  }
}
线程“main”java.lang.UnsatifiedLinkError中出现异常:pXClient.xClass$Window.drawLine(IIII)V

这里是C++签名

object XApp extends App
{
  val xc:XCClass = XCClass()  
  val win: xc.Window = xc.Window(800, 600)
  win.drawLine(20, 20, 40, 40)
  readLine()  
}
我尝试使用下划线而不是$符号,并且根本没有内部名称,但也失败了

Edit2:在看到Robin的答案之前,我设法让javah开始工作,它给出了答案

extern "C" JNIEXPORT void JNICALL Java_pXClient_XCClass$Window_drawLine(JNIEnv * env, jobject c1, Display *dpy,
    Window win, jint x1, jint y1, jint x2, jint y2)

Edit4:一旦我纠正了代码中的错误,它就工作得很好。只要名称正确,JVM就会导入带有错误参数签名的本机函数。

我刚刚用
.java
文件和
javah
进行了快速测试,
$
表示为
\u 00024

JNIEXPORT void JNICALL Java_pXClient_XCClass_00024Window_drawLine
  (JNIEnv *, jobject, jint, jint, jint, jint);