Passing enums as arguments within a jni function

I am trying to pass enum arguments from a Java/JNI function to a C function. For example,
public native void java_func(enum pname);
java_jni_func(JNIEnv * env, jobject panel, enum pname)
c_func(pname);
where
c_func(enum pname);
But I get the error message "illegal use of this type as an expression"
Any ideas on how I go about solving my problem.

Hi DavidBray,
Your task is very simple, you can pass enum value as argument ( do not pay attention to the message above ). You need only to get the name of an enum value in native method. I wrote you a simple example in MS Windows.
Here is the code in Java:
package test;
public class JEnumToJNI {
     static {
          System.loadLibrary("JNIJEnumToJNI");
     public enum JEnum {
         Ok,
         Cancel
     public static void main(String[] args) {
          PrintEnumValue(JEnum.Ok);
          PrintEnumValue(JEnum.Cancel);
     static native void PrintEnumValue(JEnum val);
}The native method extracts the name of enum value and prints it. This is code of JNI module:
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include <string>
#include "test_JEnumToJNI.h"
using namespace std;
// Converts jstring to string object
string jstring2string(JNIEnv *env, jstring js)
    string result;
    long len = env->GetStringUTFLength(js);
    char* p = (char*)malloc(len + 1);
    memset(p, 0, len + 1);
    if(len > 0)
        env->GetStringUTFRegion(js, 0, len, p);
    result = p;
    free(p);
    return result;
BOOL APIENTRY DllMain( HANDLE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
    return TRUE;
JNIEXPORT void JNICALL Java_test_JEnumToJNI_PrintEnumValue(JNIEnv* env, jclass, jobject enumVal)
    // Get enum class
    jclass jclassEnum = env->GetObjectClass(enumVal);
    if(jclassEnum != 0)
         //Get toString() method
        jmethodID toString_ID = env->GetMethodID(jclassEnum, "toString", "()Ljava/lang/String;");
        //Get enumVal name
        jstring jstrEnum = (jstring)env->CallObjectMethod(enumVal, toString_ID);
        fprintf(stdout, "enum value: %s\n", jstring2string(env, jstrEnum).c_str());
        // Delete local references created
        env->DeleteLocalRef(jstrEnum);
        env->DeleteLocalRef(jclassEnum);
    else
        // If jclassEnum == 0 clear Java Exception
        env->ExceptionClear();
}The header generated with javah.exe
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class test_JEnumToJNI */
#ifndef _Included_test_JEnumToJNI
#define _Included_test_JEnumToJNI
#ifdef __cplusplus
extern "C" {
#endif
* Class:     test_JEnumToJNI
* Method:    PrintEnumValue
* Signature: (Ltest/JEnumToJNI/JEnum;)V
JNIEXPORT void JNICALL Java_test_JEnumToJNI_PrintEnumValue
  (JNIEnv *, jclass, jobject);
#ifdef __cplusplus
#endif
#endifYour task is very simple and you need not to substitute enum values with numbers.

Similar Messages

  • Passing enums to functions without knowing the specific enum type

    My application needs the function invocation feature by using reflection mechanism. The function parameters are restricted to string, int, float and enums. I am facing problems with enums.
    Is there a way to invoke the function by passing specific enum type as parameter to the function.
    For eg:
    public void doProcess(int i, COLOR.RED){
    I should be able to invoke the above function using reflections. How dynamic casting to COLOR can be done is the question here?

    The application takes XML file as an input. This file has processing instructions. The processing instruction provides data about the class name, function name and parameters specifications like
    Classname_FunctionName("String param", 123, COLOR.RED)
    The application should invoke the corresponding library function by passing these parameters after assessing the correct types.

  • Passing arguments scope from one function to another

    Is it possible to pass the arguments structure from one
    function to another when it contains unnamed arguments? It doesn't
    throw an error but the values and indexes in the arguments scope
    get messed up. To see what I mean, compare the two cfdumps below.
    CODE
    <cfset myComponent = createObject("component",
    "MyComponent").init() />
    <cfset myComponent.get("TypeName", "KeyA", "ValueA",
    "KeyB", "ValueB") />
    <cfcomponent>
    <cffunction name="get" output="true">
    <cfargument name="type" type="string" required="yes"
    />
    <b>get() arguments</b><br />
    <cfdump var="#arguments#" />
    <cfset create(argumentCollection=arguments) />
    </cffunction>
    <cffunction name="create" output="true">
    <cfargument name="type" type="string" required="yes"
    />
    <b>create() arguments</b><br />
    <cfdump var="#arguments#" />
    </cffunction>
    </cfcomponent>
    CFDUMP OUTPUT
    get() arguments
    struct
    2 KeyA
    3 ValueA
    4 KeyB
    5 ValueB
    TYPE TypeName
    create() arguments
    struct
    2 [undefined struct element]
    3 TypeName
    4 KeyB
    5 ValueA
    TYPE TypeName

    rampalli_aravind wrote:
    Thanks a ton for the reply!
    Well,
    how do i pass the query Results?
    Actually i have a database in the server and i am the client.
    Client sends the id to the server. Server processes. finds the id and returns the name and other details using SQL statement:
    select * from table1 where id="abc";Server should return these details back to the client.
    IF no such id exists then server should send the client the following result:
    //print that the given id does not exist and these are the ids and names in table1
    select * from table1;How can i do it using jdbc odbc driver?
    Thank you in anticipation to your reply!
    Regardssee my reply to your other post.
    write a server side component that opens the connection to the database, loads the ResultSet into a data structure, closes the ResultSet, and returns the data structure to the client.
    the client should not be dealing directly with the database.
    %

  • Descriptio​n to pass 'enum' to a call library function node

    Hi,
    I'm looking for some description/help regarding how to pass 'enum' to a call library function node.
    The API documentation that I have states something like this:
    enum ibApi_DEVICETYPE_e {
    ibApi_DEVICETYPE_A = (1<<0),
    ibApi_DEVICETYPE_B = (1<<1),
    ibApi_DEVICETYPE_C = (1<<2),
    ibApi_DEVICETYPE_D = (1<<3),
    ibApi_DEVICETYPE_ANY = 0x3f /* used with filter */
    typedef ibApi_UINT32 ibApi_DEVICETYPE;
    The above is one of the input parameters to my call library function node. Hint to some documentation/example VI should be enough.

    An enum requires sequential values, so you wouldn't be able to enter an arbitrary value for each of the enumeration items. You can still use an enum, but you would need a small "accessor" VI that converts the enum to a number. I do this often, as I prefer enums. You can, however, use a ring constant which allows you to enter your own values for each of the labels. With a ring constant you can enter the value based on a format you've selected. By default the format is "Automatic", which means you enter a decimal value. If you right-click on the ring constant and select "Format & Precision" you can change it "Hexadecimal". Then, in the "Edit Items" tab you can enter a hex value in the "Values" column. So, you would have a row that has "ANY" in the "Items" column and "3F" in the "Values" column. This is only if you prefer to see the values in hex.
    Tip: You should make this into a typedef.
    Note: The values for each of the constants are not 0, 1, 3, but rather 1, 2, 4, 8, etc...

  • BD Adapter: Specify a dynamic amount of arguments within an "IN" block

    Hi everyone,
    Has anyone found a way to specify a dynamic amount of arguments within an "IN" block when using a custom SQL function with DB adapters?
    Like:
    SELECT Attr1 WHERE Attr2 IN #Arg1
    I don't want to use different DB adapters depending on the amount of arguments. I'd like to use the same one.
    I've tried to pass an Arg1 like this val1','val2 and it only works if Attr2 equals val1. I've also tried to enclose the #Arg1 within parenthesis but at that time the xsd seems not to know what type the #Arg1 variable should be.
    Any ideas would be great!
    Thank you,
    Guillaume

    With numbers:
    The input was "(123,1)"
    And I got this error:
    file:/c:/ora/as3/bpel/domains/processus/tmp/.bpel_PSU0101_TraiterCommunication_Enregistrement_MaJ_1.0_189aab1db75d9becb4c7f4e57a0d4352.tmp/DB_VOI1001_AGENDA_DOCUMENTS_EXPED_MaJ.wsdl [ DB_VOI1001_AGENDA_DOCUMENTS_EXPED_MaJ_ptt::DB_VOI1001_AGENDA_DOCUMENTS_EXPED_MaJ(DB_VOI1001_AGENDA_DOCUMENTS_EXPED_MaJInput_msg) ] - WSIF JCA Execute of operation 'DB_VOI1001_AGENDA_DOCUMENTS_EXPED_MaJ' failed due to: Exception Pure SQL.
    Echec de l'exécution Pure SQL de UPDATE CSST1.TOI1001_AGENDA_DOCUMENTS_EXPED SET COD_ETAT=?, DAH_ETAT=SYSDATE, COD_UTILISATEUR_MODIFICATION='SVC_INTEG', DAH_MODIFICATION=SYSDATE,NOM_CLASSEMENT_DOCUMENT=? WHERE IDE_DOCUMENT=? AND NBR_COPIES IN ?. Cause : java.sql.SQLException: ORA-01722: invalid number
    ; nested exception is:
         ORABPEL-11633
    Exception Pure SQL.
    Echec de l'exécution Pure SQL de UPDATE CSST1.TOI1001_AGENDA_DOCUMENTS_EXPED SET COD_ETAT=?, DAH_ETAT=SYSDATE, COD_UTILISATEUR_MODIFICATION='SVC_INTEG', DAH_MODIFICATION=SYSDATE,NOM_CLASSEMENT_DOCUMENT=? WHERE IDE_DOCUMENT=? AND NBR_COPIES IN ?. Cause : java.sql.SQLException: ORA-01722: invalid number
    Loption Pure SQL nest utilisée que pour les cas demploi problématiques et offre des fonctionnalités simples, mais minimes. Essayez éventuellement loption Exécuter une opération sur une table à la place.

  • Error: An insufficient number of arguments were supplied for function

    Hi ,
    I changed the data source for a data set on my report . The data source  is still pointing to same server and database but I am getting this error 
    "An error occurred during local report processing
    Query execution failed for data set 'Data Set Name'
    An insufficient number of arguments were supplied for function "
    I checked the function number of arguments again and it was correct and even executed the function in the dataset query designer and it works fine.
    any ideas for the reason for this error ?

    Without seeing the query you use or function its hard to suggest.
    See if parameter passed from SSRS has expected values. Is there some multivalued parameters involved?
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Local ref garbage collection within "nested" JNI calls

    I am using a JVM started in C++ to make calls to java classes. The C++ code makes JNI call into the JVM which instantiates a java class. The java class, in the course of execution, makes other JNI calls. All this happens on one thread of execution.
    What I am seeing is that local references from the native methods being called by the java class are not being released until the initial C++ native call exits. The JNI spec (text included below) seems to indicate there is registry of "nonmovable local references to Java objects" which "keeps the objects from being garbage collected". Is there only one such registry which does not get deleted until the initial C++ native call exits? If so, this would explain what I am seeing. How do I get around it?
    Thanks,
    Iztok
    From the JNI spec:
    "To implement local references, the Java VM creates a registry for each
    transition of control from Java to a native method. A registry maps nonmovable local references to Java objects, and keeps the objects from being garbage collected. All Java objects passed to the native method (including those that are returned as the results of JNI function calls) are automatically added to the registry. The registry is deleted after the native method returns, allowing all of its entries to be garbage collected."

    When I say "initial" I mean the initial C++ JNI call into a JVM running in a C++ process as shown in the pseudo code below. initNativeFunc() makes a call to Foo.doSomething() function which calls nativeFunc2 (another native function). Only a local reference to Retval was created in nativeFunct2, so when nativeFunct2 returns and the Retval is no longer used in Foo it should be a candidate for garbage collection. But this is not what happens. The Retval from nativeFunc2 is not being cleaned up until Foo.doSomething() returns. If I make the loop in Foo.doSomething() long enough, NewDoubleArray() returns a NULL when it runs out of memory.
    void initNativeFunc() {
    jclass clazz = env->FindClass("Foo");
    jmethodID mid = env->GetMethodID(clazz, "doSomething", "()V");
    env->CallVoidMethod(clazz, mid, ...);
    JNIEXPORT jobject JNICALL nativeFunc2() {
    jclass clazz = env->FindClass("Retval");
    jmethodID mid = env->GetMethodID("Retval, "<init>", "()V");
    jobject retval= env->NewObject(clazz, mid);
    jdoubleArray da = env->NewDoubleArray(100000);
    jfieldID fid = ...
    env->SetObjectField(retval, fid, da);
    return retval;
    public class Foo {
    public native void nativeFunc2();
    public void doSomething() {
    for (int i = 0; i < 100; i++) {
    Retval retval = nativeFunc2();
    }

  • I get EXCEPTION_ACCESS_VIOLATION by calling JNI function.

    Hello Everyone.
    I need someone's help that I have a problem with JNI.
    I got an error as below when a Java program calls JNI function that I created with VC++.
    JNI functions are called not once and got an error not first call.
    First of all, The JNI function is called at Main function.
    then, Main function create another thread.
    and next JNI function is called in another thread.
    when the JNI function is called first time is suceeded.
    but, second time is always failed.
    I wrote down some of detail in source code's comment.
    // ErrorLog is from here ------------------------------------------------------
    # An unexpected error has been detected by HotSpot Virtual Machine:
    # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d7c7c5f, pid=2460, tid=3144
    # Java VM: Java HotSpot(TM) Client VM (1.5.0_14-b03 mixed mode)
    # Problematic frame:
    # V [jvm.dll+0x87c5f]
    --------------- T H R E A D ---------------
    Current thread (0x00843650): JavaThread "Thread-0" [_thread_in_vm, id=3144]
    siginfo: ExceptionCode=0xc0000005, reading address 0x00000009
    Registers:
    EAX=0x00000001, EBX=0x06d77d40, ECX=0x00000008, EDX=0x00843710
    ESP=0x0afaf4a8, EBP=0x0afaf4d8, ESI=0x0afaf4ec, EDI=0x0afaf53c
    EIP=0x6d7c7c5f, EFLAGS=0x00010246
    Top of Stack: (sp=0x0afaf4a8)
    0x0afaf4a8: 0afaf4ec 06d77d40 6d7cfa7e 00000001
    0x0afaf4b8: 0afaf53c 0afaf4ec 06d77d40 00843070
    0x0afaf4c8: 00841a10 00841a18 00841e04 00843650
    0x0afaf4d8: 0afaf53c 100020a6 00843710 0082f3d0
    0x0afaf4e8: 0afaf5a0 0afaf5a4 06d77d40 06d77d40
    0x0afaf4f8: cccccccc cccccccc cccccccc cccccccc
    0x0afaf508: cccccccc cccccccc cccccccc cccccccc
    0x0afaf518: cccccccc cccccccc cccccccc cccccccc
    Instructions: (pc=0x6d7c7c5f)
    0x6d7c7c4f: 5f 5e 5b c3 8b 44 24 04 8b 0d 14 e2 8b 6d 53 56
    0x6d7c7c5f: 8b 34 01 8b 0d 10 e2 8b 6d 57 8b 3c 01 8b 0d 0c
    Stack: [0x0af70000,0x0afb0000), sp=0x0afaf4a8, free space=253k
    Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
    V [jvm.dll+0x87c5f]
    C [FilterDriver.dll+0x20a6]
    C [FilterDriver.dll+0x16c7]
    C [FilterDriver.dll+0x1c59]
    C [FilterDriver.dll+0x22b3]
    j xx.xx.xx.xx.xx.TestClass.get(Ljava/lang/String;)Z+0
    j xx.xx.xx.xx.xx.ClassExtendedThread.run()V+24
    v ~StubRoutines::call_stub
    V [jvm.dll+0x875dd]
    V [jvm.dll+0xdfd96]
    V [jvm.dll+0x874ae]
    V [jvm.dll+0x8720b]
    V [jvm.dll+0xa2089]
    V [jvm.dll+0x1112e8]
    V [jvm.dll+0x1112b6]
    C [MSVCRT.dll+0x2a3b0]
    C [kernel32.dll+0xb683]
    Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
    j xx.xx.xx.xx.xx.TestClass.get(Ljava/lang/String;)Z+0
    j xx.xx.xx.xx.xx.ClassExtendedThread.run()V+24
    v ~StubRoutines::call_stub
    --------------- P R O C E S S ---------------
    Java Threads: ( => current thread )
    0x008433b0 JavaThread "DestroyJavaVM" [_thread_blocked, id=2676]
    =>0x00843650 JavaThread "Thread-0" [_thread_in_vm, id=3144]
    0x0083d5f0 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=2024]
    0x0083c730 JavaThread "CompilerThread0" daemon [_thread_blocked, id=3444]
    0x0083b560 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=2784]
    0x00839970 JavaThread "JDWP Command Reader" daemon [_thread_in_native, id=2876]
    0x00838c60 JavaThread "JDWP Event Helper Thread" daemon [_thread_blocked, id=2980]
    0x00836250 JavaThread "JDWP Transport Listener: dt_socket" daemon [_thread_blocked, id=536]
    0x0082e410 JavaThread "Finalizer" daemon [_thread_blocked, id=2100]
    0x0082d190 JavaThread "Reference Handler" daemon [_thread_blocked, id=1968]
    Other Threads:
    0x0082c470 VMThread [id=296]
    0x0083fd50 WatcherThread [id=464]
    VM state:not at safepoint (normal execution)
    VM Mutex/Monitor currently owned by a thread: None
    Heap
    def new generation total 576K, used 300K [0x02bd0000, 0x02c70000, 0x030b0000)
    eden space 512K, 58% used [0x02bd0000, 0x02c1b200, 0x02c50000)
    from space 64K, 0% used [0x02c50000, 0x02c50000, 0x02c60000)
    to space 64K, 0% used [0x02c60000, 0x02c60000, 0x02c70000)
    tenured generation total 1408K, used 0K [0x030b0000, 0x03210000, 0x06bd0000)
    the space 1408K, 0% used [0x030b0000, 0x030b0000, 0x030b0200, 0x03210000)
    compacting perm gen total 8192K, used 1711K [0x06bd0000, 0x073d0000, 0x0abd0000)
    the space 8192K, 20% used [0x06bd0000, 0x06d7bf00, 0x06d7c000, 0x073d0000)
    No shared spaces configured.
    Dynamic libraries:
    0x00400000 - 0x0040d000      C:\Program Files\Java\jdk1.5.0_14\bin\javaw.exe
    0x7c940000 - 0x7c9dd000      C:\WINDOWS\system32\ntdll.dll
    0x7c800000 - 0x7c932000      C:\WINDOWS\system32\kernel32.dll
    0x77d80000 - 0x77e29000      C:\WINDOWS\system32\ADVAPI32.dll
    0x77e30000 - 0x77ec1000      C:\WINDOWS\system32\RPCRT4.dll
    0x77cf0000 - 0x77d7f000      C:\WINDOWS\system32\USER32.dll
    0x77ed0000 - 0x77f17000      C:\WINDOWS\system32\GDI32.dll
    0x77bc0000 - 0x77c18000      C:\WINDOWS\system32\MSVCRT.dll
    0x762e0000 - 0x762fd000      C:\WINDOWS\system32\IMM32.DLL
    0x60740000 - 0x60749000      C:\WINDOWS\system32\LPK.DLL
    0x73f80000 - 0x73feb000      C:\WINDOWS\system32\USP10.dll
    0x6d740000 - 0x6d8de000      C:\Program Files\Java\jdk1.5.0_14\jre\bin\client\jvm.dll
    0x76af0000 - 0x76b1b000      C:\WINDOWS\system32\WINMM.dll
    0x6d300000 - 0x6d308000      C:\Program Files\Java\jdk1.5.0_14\jre\bin\hpi.dll
    0x76ba0000 - 0x76bab000      C:\WINDOWS\system32\PSAPI.DLL
    0x6d400000 - 0x6d435000      C:\Program Files\Java\jdk1.5.0_14\jre\bin\jdwp.dll
    0x6d710000 - 0x6d71c000      C:\Program Files\Java\jdk1.5.0_14\jre\bin\verify.dll
    0x6d380000 - 0x6d39d000      C:\Program Files\Java\jdk1.5.0_14\jre\bin\java.dll
    0x6d730000 - 0x6d73f000      C:\Program Files\Java\jdk1.5.0_14\jre\bin\zip.dll
    0x6d290000 - 0x6d297000      C:\Program Files\Java\jdk1.5.0_14\jre\bin\dt_socket.dll
    0x719e0000 - 0x719f7000      C:\WINDOWS\system32\WS2_32.dll
    0x719d0000 - 0x719d8000      C:\WINDOWS\system32\WS2HELP.dll
    0x71980000 - 0x719bf000      C:\WINDOWS\System32\mswsock.dll
    0x76ed0000 - 0x76ef7000      C:\WINDOWS\system32\DNSAPI.dll
    0x76f60000 - 0x76f68000      C:\WINDOWS\System32\winrnr.dll
    0x76f10000 - 0x76f3c000      C:\WINDOWS\system32\WLDAP32.dll
    0x76f70000 - 0x76f76000      C:\WINDOWS\system32\rasadhlp.dll
    0x607c0000 - 0x60816000      C:\WINDOWS\system32\hnetcfg.dll
    0x719c0000 - 0x719c8000      C:\WINDOWS\System32\wshtcpip.dll
    0x10000000 - 0x10076000      C:\xx\whaticreated.dll
    0x71a50000 - 0x71a62000      C:\WINDOWS\system32\MPR.dll
    VM Arguments:
    jvm_args: -agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:1759
    java_command: xx.xx.xx.xx.xx.Sample start
    Launcher Type: SUN_STANDARD
    Environment Variables:
    JAVA_HOME=C:\Program Files\Java\jdk1.5.0_14
    PATH=C:\WINDOWS\system32;C:\WINDOWS;D:\tools\apache-ant-1.7.0\bin;C:\Program Files\Microsoft SQL Server\90\Tools\binn\;D:\PROGRA~1\ATT\Graphviz\bin;D:\Program Files\doxygen\bin;D:\Program Files\Microsoft SDK\Bin\.;D:\Program Files\Microsoft SDK\Bin\WinNT\.;C:\Program Files\Java\jdk1.5.0_14\bin;C:\Program Files\Microsoft Visual Studio\Common\Tools\WinNT;C:\Program Files\Microsoft Visual Studio\Common\MSDev98\Bin;C:\Program Files\Microsoft Visual Studio\Common\Tools;C:\Program Files\Microsoft Visual Studio\VC98\bin;D:\Program Files\Microsoft SDK\Bin\.;D:\Program Files\Microsoft SDK\Bin\WinNT\.
    USERNAME=xxx
    OS=Windows_NT
    PROCESSOR_IDENTIFIER=x86 Family 6 Model 15 Stepping 2, GenuineIntel
    --------------- S Y S T E M ---------------
    OS: Windows XP Build 2600 Service Pack 2
    CPU:total 2 (cores per cpu 2, threads per core 1) family 6 model 15 stepping 2, cmov, cx8, fxsr, mmx, sse, sse2
    Memory: 4k page, physical 1038124k(270512k free), swap 1711740k(953716k free)
    vm_info: Java HotSpot(TM) Client VM (1.5.0_14-b03) for windows-x86, built on Oct 5 2007 01:21:52 by "java_re" with MS VC++ 6.0
    // The end of ErrorLog --------------------------------------------------------
    and the codes are below.
    // TestClass.java
    public class TestClass {
         // Load native library
         static{
              System.loadLibrary("DLLName");
         public native int start(String str, int count);
         public native int end();
         public native boolean get(String str);
    // ClassExtendedThread.java
    public class ClassExtendedThread extends Thread {
         private TestClass tc;
         // Constructor
         public ClassExtendedThread(TestClass in_tc)
              ts = in_tc;
         // This will be executing in another thread
         public void run()
              while( true )
                   if( !false )
                        String str = new String();
                        // get function returns false means nothing to catch event.
                        if( false == ts.get( str ) ) // calling first time is suceed. but, I got an error second time.
                          // Set Interval for loop.
    // Sample.java
    public class Sample {
         public static void main(String[] args) {
              TestClass tc = null;
              ClassExtendedThread cet = null;
              tc = new TestClass();
              // Init something
              if(0 != TestClass.start(xxx, xxx)) // First JNI function suceeds.
                   System.out.println("start error.");
                   return;
              // Starting Thread
              cet = new ClassExtendedThread(tc);
              cet.start();
    }Have anyone got any idea to resolve this problem?
    Edited by: fc3srx7m on Apr 25, 2008 3:56 AM

    Hi Martin.
    Thank you for your advice.
    I thought the problem is in the FilterDriver.dll as well.
    I tried DebugBreak() into native code.
    but, I still can't find where the problem is.
    I'm trying to convert C structure to Java class like using structConverter which is tool of book for JNI.
    Here's some code including native code.
    // Java source codes //////////////////////////////////////////////////////////////////////////////////
    // Event.java ----------------------------------------------------------------------------------------------
    // This class for C structure Convert
    public class Event {
         private int     aaa;
         private long     bbb;
         private String     ccc;
            // Getter/Setter
         public int getAaa() {
              return aaa;
         public void setAaa(int aa) {
              aaa = aa;
         public long getBbb() {
              return bbb;
         public void setBbb(long cc) {
              bbb = bb;
         public String getCcc() {
              return ccc;
         public void setCcc(String cc) {
              ccc = cc;
            // Field Initialize
         private native static void initFIDs();
         static {
              initFIDs();
    // EventStruct,java --------------------------------------------------------------------------------------
    public class EventStruct extends Event {
         private void _init()
              setAaa(0);
              setBbb(0);
              setCcc(new String());
         // Constructor
         public LogEventStruct()
              _init();
              System.loadLibrary("FilterDriver");
    // EndOfJavaSource ////////////////////////////////////////////////////////////////////////////////////
    // Native source code /////////////////////////////////////////////////////////////////////////////////
    // Event.cpp ----------------------------------------------------------------------------------------------
    // FieldIDs
    static jfieldID Event_Aaa_FID;
    static jfieldID     Event_Bbb_FID;
    static jfieldID     Event_Ccc_FID;
    // Initialize Adapter
    static void initEventFieldIDs(JNIEnv* env, jclass clazz)
              Event_Aaa_FID     = env->GetFieldID(clazz, "aaa",     "I");
              Event_Bbb_FID     = env->GetFieldID(clazz, "bbb",      "J");
              Event_SFlNm_FID = env->GetFieldID(clazz, "ccc",      "Ljava/lang/String;");
    // Call from Java
    JNIEXPORT void JNICALL Java_Event_initFIDs(JNIEnv *env, jclass clazz)
              initEventFieldIDs(env, clazz);
    // Setter
    void jni_SetAaa_in_Event(EVENT* __EVENT_, JNIEnv *env, jobject thisaaa)
              env->SetIntField(thisaaa, Event_Aaa_FID, (jint)__EVENT_->aaa);
    // Getter
    void jni_GetAaa_from_Event(EVENT* __EVENT_, JNIEnv *env, jobject thisaaa)
              __EVENT_->aaa = (int)env->GetIntField(thisaaa, Event_Aaa_FID);
    // Setter
    void jni_SetBbb_in_Event(EVENT* __EVENT_, JNIEnv *env, jobject thisbbb)
              env->SetLongField(thisbbb, Event_Bbb_FID, __EVENT_->bbb);
    // Getter
    void jni_GetBbb_from_Event(EVENT* __EVENT_, JNIEnv *env, jobject thisbbb)
              __EVENT_->bbb = (unsigned int)env->GetLongField(thisbbb, Event_Bbb_FID);
    // Setter
    void jni_SetCcc_in_Event(EVENT* __EVENT_, JNIEnv *env, jobject thisccc)
              env->SetObjectField(thisccc, Event_Ccc_FID, env->NewStringUTF(__EVENT_->ccc));
    // Getter
    void jni_GetCcc_from_Event(EVENT* __EVENT_, JNIEnv *env, jobject thisccc)
              jboolean isCopy;
              const char *str = __EVENT_->ccc;
              jstring jstr = (jstring)env->GetObjectField(thisccc, Event_Ccc_FID);
              str = env->GetStringUTFChars(jstr, &isCopy);
              if(JNI_TRUE == isCopy)
                        env->ReleaseStringUTFChars(jstr, str);
    // Getting (Java Object to C Structure)
    void jni_SetAll_in_Event(EVENT *__EVENT_, JNIEnv *env, jobject thisEvent)
              jni_SetAaa_in_Event(__EVENT_, env, thisEvent);
              jni_SetBbb_in_Event(__EVENT_, env, thisEvent);
              jni_SetCcc_in_Event(__EVENT_, env, thisEvent);
    // Setting (C structure to Java Object)
    void jni_GetAll_in_Event(EVENT *__EVENT_, JNIEnv *env, jobject thisEvent)
              jni_GetAaa_from_Event(__EVENT_, env, thisEvent);
              jni_GetBbb_from_Event(__EVENT_, env, thisEvent);
              jni_GetCcc_from_Event(__EVENT_, env, thisEvent);
    // AnotherLib.h ------------------------------------------------------------------------------------
    // C Structure which I want to convert.
    typedef struct EVT {
         int                  aaa;
         unsigned int    bbb;
         char               ccc[256];
    } EVENT;
    // prototype
    BOOL GetEvent( EVENT* buf, char *name );
    // test.h -----------------------------------------------------------------------------------------------------
    #if !defined(AFX_TEST_H__F9A4A432_24D3_4DE4_89D7_A2009B8EC2AA__INCLUDED_)
    #define AFX_TEST_H__F9A4A432_24D3_4DE4_89D7_A2009B8EC2AA__INCLUDED_
    #if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000
    #include <windows.h>
    #include "AnotherLib.h"
    #include "Event.h" // output by javah command
    extern void jni_GetAll_in_Event(EVENT *__EVENT_, JNIEnv *env, jobject thisEvent);
    extern void jni_SetAll_in_Event(EVENT *__EVENT_, JNIEnv *env, jobject thisEvent);
    #endif // !defined(AFX_TEST_H__F9A4A432_24D3_4DE4_89D7_A2009B8EC2AA__INCLUDED_)
    // test.cpp --------------------------------------------------------------------------------------------------
    JNIEXPORT jboolean JNICALL Java_get(JNIEnv *env, jobject obj, jstring name)
              EVENT s_Event;
              char strName[_MAX_PATH];
    //DebugBreak();
              memset(&s_Event, 0x00, sizeof(EVENT));
              memset(strName, 0x00, _MAX_PATH);
              jni_SetAll_in_Event(&s_Event, env, obj);
              BOOL ret = GetEvent(&s_Event, strName);
              if(TRUE == ret)
                        jni_GetAll_in_Event(&s_Event, env, obj);
                        // convert char array to jstring
                        name = env->NewStringUTF(strName);
              return ret;
    // EndOfNativeSource ////////////////////////////////////////////////////////////////////////////////Edited by: fc3srx7m on Apr 27, 2008 10:05 PM

  • Pass a value from a PL/SQL function to a javascript (html header) ? ?

    Hey Guys,
    Have a question regarding how to pass a value from a PL/SQL function to a javascript in the HTML Header.
    I have created a PL/SQL function in my database, which does looping.
    The reason for this is:  On my apex page when the user selects a code, it should display(or highlight buttons) the different project id's present for that particular code.
    example= code 1
    has project id's = 5, 6, 7
    code 2
    has project id's = 7,8
    Thank you for your Help or Suggestions
    Jesh
    The PL/SQL function :
    CREATE OR REPLACE FUNCTION contact_details(ACT_CODE1 IN NUMBER) RETURN VARCHAR2 IS
    Project_codes varchar2(10);
    CURSOR contact_cur IS
    SELECT ACT_CODE,PROJECT_ID
    FROM ACTASQ.ASQ_CONTACT where ACT_CODE = ACT_CODE1;
    currec contact_cur%rowtype;
    NAME: contact_details
    PURPOSE:
    REVISIONS:
    Ver Date Author Description
    1.0 6/25/2009 1. Created this function.
    BEGIN
    FOR currec in contact_cur LOOP
         dbms_output.put_line(currec.PROJECT_ID || '|');
         Project_codes := currec.PROJECT_ID|| '|' ||Project_codes;
    END LOOP;
    RETURN Project_codes;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    -- Consider logging the error and then re-raise
    RAISE;
    END contact_details;
    /

    Jesh:
    I have made the following modifications to your app to get it to work as I thing you need it to.
    1) Changed the source for the HTML Buttons Region(note use of id vs name for the Buttons)
    <script>
    function hilitebtn(val) {
    //gray buttons
    $x('graduate').style.backgroundColor='gray'
    $x('distance').style.backgroundColor='gray'
    $x('career').style.backgroundColor='gray'
    $x('photo').style.backgroundColor='gray'
    //AJAX call to get project-ids
    var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=GETPROJECTS',0);
    get.addParam('x01',val)
    gReturn = get.get();
    var arr=gReturn.split(':');  //dump into array
    get = null;
    for (i=0;i<arr.length;i++) {
    // alert('val=' + arr);
    if ( arr[i]==5)
    $x('graduate').style.backgroundColor='red';
    if ( arr[i]==6)
    $x('distance').style.backgroundColor='red';
    if ( arr[i]==7)
    $x('career').style.backgroundColor='red';
    if ( arr[i]==8)
    $x('photo').style.backgroundColor='red';
    </script>
    <table cellpadding='0' cellspacing='0' border='0'>
    <tr><td>
    <input type='button' id='graduate' value='Graduate'>
    </td>
    <td>
    <input type='button' id='distance' value='Distance'>
    </td>
    <td>
    <input type='button' id='career' value='Career/Tech'>
    </td>
    <td>
    <input type='button' id='photo' value='Photos'>
    </td>
    </tr></table>
    2) Defined the application process  GETPROJECTS as DECLARE
    IDS varchar2(1000);
    l_act_code varchar2(100) :=4;
    begin
    IDS:='';
    l_act_code := wwv_flow.g_x01;
    for x in(
    SELECT ACT_CODE,PROJECT_ID
    FROM ASQ_CONTACT
    where ACT_CODE = l_act_code)
    LOOP
    IDS := IDS || X.PROJECT_ID|| ':' ;
    END LOOP;
    HTP.PRN(IDS);
    END;
    3) Changed the 'onchange' event-handler on p1_act_code to be 'onchange=hilitebtn(this.value)'
    4) Added the JS to the HTML Page Footer <script>
    hilitebtn($v('P1_ACT_CODE'));
    </SCRIPT>

  • Pass table name as a parameter to function

    Is there a way to pass table name as a parameter to functions? Then update the table in the function.
    Thanks a lot.
    Jiaxin

    Hi, Harm,
    Thank you very much for your suggestion and example. But to get my program work, i need to realise code like follows:
    CREATE OR REPLACE FUNCTION delstu_func(stuno char) RETURN NUMBER AS
    BEGIN
    EXECUTE IMMEDIATE 'DELETE FROM student s' ||
    'WHERE' || 's.student_number' || '=' || stuno;
    LOOP
    DBMS_OUTPUT.PUT_LINE('record deleted');
    END LOOP;
    END;
    SELECT delstu_func('s11') FROM STUDENT;
    The intention is to check if such a function can perform operations such as update, delete and insert on occurence of certain values. When executing the above statement, the system returns an error message:
    ERROR at line 1:
    ORA-00933: SQL command not properly ended
    ORA-06512: at "SCMJD1.DELSTU_FUNC", line 3
    Could you tell me where is wrong?
    Jiaxin

  • How to pass column name at run time in function.

    how to pass column name at run time in function as parameter.
    thank in advance
    pramod patel

    Hello,
    Using dynamic sql you can pass column name to function. well I am not getting what you really want to do ? Please write in more detail. By the way I am providing one example here. see it uses dynamic sql.
    Create or replace function fun_updtest (p_columnname_varchar2 in varchar2,
    p_value_number in number)
    return number is
    v_stmt varchar2(500);
    begin
    v_stmt := 'update emp
    set '||p_columnname_varchar2||' = '||to_char(p_value_number)||'
              where empno = 7369';
    execute immediate v_stmt;
    return 0;
    commit;
    end;
    call to this function can be like this..
    declare
    v_number               number;
    begin
    v_number := fun_updtest('SAL',5000);
    end;
    Adinath Kamode

  • Passing hard-coded string parameters into a FUNCTION

    I created a Function that accepts two INT and two VARCHAR2 parameters. I want to access it in a SELECT statement and manually pass in parameters to it.
    For example,
    SELECT FN_MYFUNC(10, 20, 'string1', 'string2') FROM DUAL;
    However, when I do this the hard-coded strings don't seem to be recognized by the Function. But, if I were to pass in a Fieldname from a TABLE then the above function works. Is there something extra I need to do to pass in hard-coded strings into a function?

    I have pasted the function where this problem is occuring below. If I use it in a SELECT, for example....
    SELECT fn_GetRegValueFromRegData(3, 3, 'REG', '119') FROM DUAL;
    .....it returns blank everytime when it should return a numeric value. However, this only occurs if I hard-code the parameter values (like above). However, if I pass in fieldnames from a TABLE, for example.....
    SELECT fn_GetRegValueFromRegData(RegLink, EeLink, ChqType, RegCode) FROM RegData;
    ......then I get data back! Any idea why data is returned when I pass in fieldnames but not when I pass in hard-coded parameter values?
    =================================================
    CREATE OR REPLACE FUNCTION fn_GetRegValueFromRegData
    (p_RegLink INT,
    p_EELink INT,
    p_ChequeType VARCHAR2,
    p_RegCode1 VARCHAR2,
    p_RegCode2 VARCHAR2 := '-1')
    RETURN NUMBER
    AS
    v_regvalue NUMBER(14,5);
    BEGIN
    BEGIN
    --retrieve data using the REGCODE1 value
    SELECT a.regvalue INTO v_regvalue
    FROM regdata a
    WHERE a.RegCode = p_RegCode1
    AND a.RegLink = p_RegLink
    AND a.eeLink = p_EELink
    AND a.ChqType = p_ChequeType
    AND a.EndDate IS NULL;
    EXCEPTION
    WHEN OTHERS
    THEN
    --retrieve data using the REGCODE2 value
    SELECT a.regvalue INTO v_regvalue
    FROM regdata a
    WHERE a.RegCode = p_RegCode2
    AND a.RegLink = p_RegLink
    AND a.eeLink = p_EELink
    AND a.ChqType = p_ChequeType
    AND a.EndDate IS NULL;
    END;
    RETURN v_regvalue;
    END;
    /

  • JNI function name length exceeds linker support size?

    hi,
    JNI function names are Java_Package_classname_functionname. But i have a package+classname itself crossing 32 characters. i need to have more than one native function in the same class. so linker cannot distinguish these names. any workarounds?
    thanx in advance

    Hi,
    I don't know of any way around JNI's name mangling rules, but pardon me for asking, the linker of what platform supports symbols with length <= 32 only these days?
    Kind Regards,
    Tobias

  • There is an invalid number of arguments found in the function '@PARENTVAL

    Hi
    In a prior version of Hyperion, we had a business rule which pushed values down to to a child member
    +Fix ( EE105, , @Children("FX entry"), &District, @UDA("Cost centre - primary", "DuplicateMbr"),C3090,[Opex_WriteScenario], [Opex_WriteVersion],&CurYear: &YearPlus6)+
    Month = @PARENTVAL("Cost Centre");
    Endfix;
    We are moving across to Calc Manager in version 11.1.2.1 and the problem is that I now get the following error message:
    An error occurred in: Calc Opex CC
    There is an invalid number of arguments found in the function '@PARENTVAL(Cost Centre)'. .
    Your assistance is appreciated.
    Cheers

    Check if you can validate this script again Essbase, I am sure you will be able to.
    If I remember correctly there were few functions missing in calc manager which were fixed in the patches released.
    Try it on the latest patch:
    Patch 14265667: Patch Set Update: 11.1.2.1.104 for Oracle Hyperion Calculation Manager
    Cheers..!!!
    Rahul S.

  • Pass XML in argument tag in JNLP file

    Is there a way to pass an xml string in the <argument> tag. I tried to do it but I get xml parsing error. It seems that the xml becomes the child node when I pass that to the arguments tag. the CDATA also does not work. Has anyone done this successfully. thanks
    I am trying to pass somthing like
    <argument><Settings><URL>http://xxx.com</URL></Settings></argument>
    this is just an example I have also tried
    <argument>"<Settings><URL>http://xxx.com</URL></Settings>"</argument>
    this also errors out.
    <argument><![CDATA[<Settings><URL>http://xxx.com</URL></Settings>]]</argument>
    that does not work too.
    Please let me know if there is anything else I can try

    I've successfully used CDATA to embed HTML in an argument, on JDK 1.5 at least (not tried on others yet).
    Your CDATA closing section should be: ]]> Yours is missing the end bracket - if that's not an error in your post it's probably the cause of the XML parsing error.

Maybe you are looking for