70 lines
3.3 KiB
HTML
70 lines
3.3 KiB
HTML
|
<?xml version="1.0" encoding="UTF-8"?>
|
||
|
<!DOCTYPE html
|
||
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
<html lang="en-us" xml:lang="en-us">
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
|
<meta name="security" content="public" />
|
||
|
<meta name="Robots" content="index,follow" />
|
||
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
||
|
<meta name="DC.Type" content="reference" />
|
||
|
<meta name="DC.Title" content="Example: PaseExample1.c" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="codedisclaimer.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="rzahapaseexmpls.htm" />
|
||
|
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
|
||
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
|
||
|
<meta name="DC.Format" content="XHTML" />
|
||
|
<meta name="DC.Identifier" content="rzahapasec" />
|
||
|
<meta name="DC.Language" content="en-us" />
|
||
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
||
|
<!-- US Government Users Restricted Rights -->
|
||
|
<!-- Use, duplication or disclosure restricted by -->
|
||
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
||
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
||
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
||
|
<title>Example: PaseExample1.c</title>
|
||
|
</head>
|
||
|
<body id="rzahapasec"><a name="rzahapasec"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">Example: PaseExample1.c</h1>
|
||
|
<div><div class="section"><p><strong>Note:</strong> Read the <a href="codedisclaimer.htm">Code example disclaimer</a>
|
||
|
for important legal information.</p>
|
||
|
<pre>/*
|
||
|
*
|
||
|
|
||
|
* This native method implements the getStringNative method of class
|
||
|
* PaseExample1. It uses the JNI function CallObjectMethod to call
|
||
|
* back to the getStringCallback method of class PaseExample1.
|
||
|
*
|
||
|
* Compile this code in AIX to create module 'libPaseExample1.so'.
|
||
|
*
|
||
|
*/
|
||
|
|
||
|
#include "PaseExample1.h"
|
||
|
#include <stdlib.h>
|
||
|
|
||
|
/*
|
||
|
* Class: PaseExample1
|
||
|
* Method: getStringNative
|
||
|
* Signature: ()Ljava/lang/String;
|
||
|
*/
|
||
|
JNIEXPORT jstring JNICALL Java_PaseExample1_getStringNative(JNIEnv* env, jobject obj) {
|
||
|
char* methodName = "getStringCallback";
|
||
|
char* methodSig = "()Ljava/lang/String;";
|
||
|
jclass clazz = (*env)->GetObjectClass(env, obj);
|
||
|
jmethodID methodID = (*env)->GetMethodID(env, clazz, methodName, methodSig);
|
||
|
return (*env)->CallObjectMethod(env, obj, methodID);
|
||
|
}</pre>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div>
|
||
|
<div class="familylinks">
|
||
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rzahapaseexmpls.htm" title="The IBM i5/OS PASE native method for Java example calls an instance of a native C method that then uses Java Native Interface (JNI) to call back into Java code. Rather than accessing the string directly from Java code, the example calls a native method that then calls back into Java through JNI to get the string value.">Example: IBM i5/OS PASE native method for Java</a></div>
|
||
|
</div>
|
||
|
|
||
|
<div class="linklist"><strong>Collected links</strong><br />
|
||
|
|
||
|
<div><a href="codedisclaimer.htm">Code example disclaimer</a></div></div>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|