Native method in local class

Hi there,
this is a repost of my question but now in the right forum.
I have a problem with a native method of a local class that hides a member class:
public class SomeClass
     class MemberClass
          public native void bla();
          public void out()
               System.out.println("A");
     public void foo()
          class MemberClass
               public native void bla();
               public void out()
                    System.out.println("B");
          MemberClass myClass = new MemberClass();
          myClass.out();
     public static void main(String[] args)
          SomeClass someClass = new SomeClass();
          someClass.foo();
}The class MemberClass exist in two different ways. Every class has it's own out() method. The local class just hides the member class. Now I want to implement the native methods bla() of the two classes.
If I call
javac SomeClass.hI get
SomeClass.class
SomeClass$MemberClass.class
SomeClass$1MemberClass.classwhich makes sense to me. We have one class file for the member class and one for the local class.
If I use
javah SomeClassthen I get
JNIEXPORT void JNICALL Java_SomeClass_00024MemberClass_bla(JNIEnv *, jobject);in the header file for the member class. No header file for the local class was created.
Therefore I call
javah SomeClass$1MemberClassand I get another header file which is for the local class. But this header file declares the same native method:
JNIEXPORT void JNICALL Java_SomeClass_00024MemberClass_bla(JNIEnv *, jobject);This is ambiguous... If I would implement the native method, then I couldn't even say for which one of the native methods it will be used. Maybe for both.. which wouldn't make any sense too.
What is wrong here?
Thank you for your thoughts :-)

Interesting...From the JLS under "fully qualified name"
[http://java.sun.com/docs/books/jls/third_edition/html/names.html#71701]
"Every package, top level class, top level interface, and primitive type has a fully qualified name."
From the javah docs
javah [ options ] fully-qualified-classname
And note this under the JNI spec for "FindClass"
[http://java.sun.com/javase/6/docs/technotes/guides/jni/spec/functions.html#wp16027]
"The name argument is a fully-qualified class name or an array type signature "
Does that mean that you can't use JNI to access a local class? Seems like I have seen posts that said that was possible.

Similar Messages

  • Native methods inside C++ class

    Hey all,
    Tried posting this already but it didn't appear in the forums. So apologies if this appears twice on same forum :o)
    Want to wrap my native methods inside a C++ class but get UnsatisfiedLinkerError when I do. Is it possible to do this? Do I have to change some method signatures or what?
    I want something like :
    public class A
    native void doSomething();
    class B
    public:
    JNIEXPORT void JNI Java_A_doSomething() { ... } /* or whatever */
    It works ok outside of a C++ class but I'd prefer to contain my methods inside a class. Any help?
    Cheers,
    Conor

    Java needs to find your functions in the DLL or SO. But the names are "mangled" if you declare the function inside a class - even declaring the function "static" does not help. For instance, using the Microsoft C++ compiler:
    class B
    public:
    static JNIEXPORT void JNI Java_A_doSomething() { ... }
    };the name is mangled to ?Java_A_doSomething@B@@SAXXZ
    But Java tries to locate the entry _Java_A_doSomething@0 in the DLL.
    You can write the global functions as:
    JNIEXPORT void JNI Java_A_doSomething() {
        B::doSomething();
    }and implement your functions in the class B. The advantage of this approach is that you can write all bookkeeping work of converting Java data to C++ data in the global function, and leave the real work to the function declared in the C++ class.

  • Native method in object class........

    I would like to know that which method of object class is a native method..........

    flounder wrote:
    The natives are getting restless.
    What they do with him when he arrives, I don't know.This reminds me of one of my favorite entries in Ambrose Bierce's [Devil's Dictionary|http://en.wikipedia.org/wiki/Devil%27s_dictionary]
    h3. Aborigines
    Persons of little worth found cumbering the soil of a newly discovered country. They soon cease to cumber; they fertilize.

  • Calling native method

    Guys please help me with following error.
    I am running a simple JNI program,after creating and loading the dll i am getting following error.......
    Exception in thread "main" java.lang.UnsatisfiedLinkError: print
    "print" is the native method in java class Hello.java
    Hello.h has method declaration as :
    JNIEXPORT void JNICALL Java_Hello_print
    (JNIEnv *, jobject);
    and C++ file has method defined as :
    JNIEXPORT void JNICALL
    Java_Hello_print(JNIEnv *env, jobject obj)
    printf("Hello World!\n");
    return;
    please help me out...it has been 3 days banging against JNI ...

    Guys please help me with following error.
    I am running a simple JNI program,after creating and
    loading the dll i am getting following error.......
    Exception in thread "main"
    java.lang.UnsatisfiedLinkError: print
    "print" is the native method in java class
    Hello.java
    Hello.h has method declaration as :
    JNIEXPORT void JNICALL Java_Hello_print
    (JNIEnv *, jobject);
    and C++ file has method defined as :
    JNIEXPORT void JNICALL
    Java_Hello_print(JNIEnv *env, jobject obj)
    printf("Hello World!\n");
    return;
    please help me out...it has been 3 days banging
    against JNI ...If your Java code is in a package, then your native header file declaration is wrong. The javah tool expects the fully qualified class name. So, if your Hello class is in package com.foo.hello, you should generate the header file like this:
    javah com.foo.hello.HelloThen the native header declaration will look like this:
    JNIEXPORT void JNICALL Java_com_foo_hello_Hello_print
    (JNIEnv *, jobject);

  • What is native method?

    hi.. i have the following error msg on the java wireless toolkit..
    "ERROR: native methods should not appear
    Error preverifying class com.zucotto.io.serialcomm.COMInputStream
    Build failed"
    can anyone help?
    thanks

    You can't "un-native" a native method. The class library that you are using relies upon native code. It can not be used on the target platform. You would have to ask the vendor of that class library to update it to work on your target platform without the native code.
    God bless,
    -Toby Reyelts

  • Error calling native methods

    HI
    I declared a static native method in a class and using the System.loadLibrary() method i load the dll.
    Now if i want to call the method from another class using instance of that class where i declare the native method, it shows an error
    java.lang.SpecifiedPathLink error. I have put the dll outside the package in the same directory.
    can anyone help me regarding this problem

    it shows this exception
    Exception in thread "main" java.lang.UnsatisfiedLinkError: no PerfMonitor in jav
    a.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1491)
    at java.lang.Runtime.loadLibrary0(Runtime.java:788)
    at java.lang.System.loadLibrary(System.java:834)
    at C3.CPUMemoryUsage.<clinit>(CPUMemoryUsage.java:6)
    at C3.Node.main(Node.java:18)

  • Calling native methods in a package

    Hi!
    We have a problem when calling native methods in a class which is in a package. As you can see from the code below we have a class making an instance of a class<testBando> which makes a instance of another class<Bando> which contains the native methods. When running the program we get the error:
    Exception in thread "main" java.lang.UnsatisfiedLinkError: initialize
    at test2.Bando.initialize(Native Method)
    at test.testBando.<init>(testBando.java:10)
    at Main.main(Main.java:5)
    When we take the class that calls the native methods out of any package every thing works fine! Can you not call native methods inside a package or what are we doing wrong?
    // testBando.java
    package test;
    import test2.*;
    public class testBando {
    Bando b;
    public testBando() {
         b = new Bando();
         b.initialize();
    // Bando.java
    package test2;
    public class Bando {
    public native void initialize();
    static {
         System.loadLibrary("bando");
    // Main.java
    import test.*;
    public class Main {
    public static void main(String[] args) {
         new testBando();

    I suspect that your problem is that you have not
    regenerated the signature when you placed the native
    method's object in a package. Or same result but different sourc:
    -package name was changed and it wasn't regen'd
    -javah was run incorrectly (which gens the signatures with no package name.)

  • Native Method (Very Urgent).

    I am working on native methods. I followed the steps as defined by the sun:
    i- Create the Java Source File, containing the native method declaration:
    public class NativeCode
         public native void showString();
         static
              System.loadLibrary("DisplayText");
         public static void main(String [] args)
              NativeCode nc = new NativeCode();
         nc.showString();
    ii- Compile the Java Source File.
    iii- use javah -jni ClassName to create Header File.
    //The header file.
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class NativeCode */
    #ifndef IncludedNativeCode
    #define IncludedNativeCode
    #ifdef __cplusplus
    extern "C"
    #endif
    * Class: NativeCode
    * Method: showString
    * Signature: ()V
    JNIEXPORT void JNICALL Java_NativeCode_showString
    (JNIEnv *, jobject);
    #ifdef __cplusplus
    #endif
    #endif
    iv- Write the implementation of native method in "C Language", using the signature as in the Header file, generated by the javah -jni option.
    // The implementation of native method in "C Language".
    //NativeMethod.c
    #include <jni.h>
    #include "NativeCode.h"
    #include <stdio.h>
    JNIEXPORT void JNICALL Java_NativeCode_showString(JNIEnv *env, jobject obj)
         printf("Hello! World");
         return;
    The problem is that when I compile the NativeMethod.c, the compiler generated the following errors:
    i- Unable to Open include file "jni.h".
    ii- Unable to Open include file "NativeCode.h"
    iii- Declaration Syntax Error.
    What should I do? What is the solution of this problem?
    Where I have to put the "jni.h" and "NativeCode.h" files?
    Please assist me in solving this problem.
    Many Buckets full of thanks!

    Hi
    You should be able to find the jni.h in :
    For Windows:
    your <java_home>\include directory. jni.h also refers to jni_md.h
    that should be present in <java_home>\include\win32 directory.
    Copy both of them to your include path.
    For Solaris:
    you should find the jni.h in the same directory but jni_md.h
    will be in <java_home>/include/solaris directory.
    The pattern follows for other UNIX flavors too.
    Hope this helps.
    cheers
    projyal
    I am working on native methods. I followed the steps
    as defined by the sun:
    i- Create the Java Source File, containing the native
    method declaration:
    public class NativeCode
         public native void showString();
         static
              System.loadLibrary("DisplayText");
         public static void main(String [] args)
              NativeCode nc = new NativeCode();
         nc.showString();
    ii- Compile the Java Source File.
    iii- use javah -jni ClassName to create Header File.
    //The header file.
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class NativeCode */
    #ifndef IncludedNativeCode
    #define IncludedNativeCode
    #ifdef __cplusplus
    extern "C"
    #endif
    * Class: NativeCode
    * Method: showString
    * Signature: ()V
    JNIEXPORT void JNICALL Java_NativeCode_showString
    (JNIEnv *, jobject);
    #ifdef __cplusplus
    #endif
    #endif
    iv- Write the implementation of native method in "C
    Language", using the signature as in the Header file,
    generated by the javah -jni option.
    // The implementation of native method in "C
    Language".
    //NativeMethod.c
    #include <jni.h>
    #include "NativeCode.h"
    #include <stdio.h>
    JNIEXPORT void JNICALL
    Java_NativeCode_showString(JNIEnv *env, jobject obj)
         printf("Hello! World");
         return;
    The problem is that when I compile the
    NativeMethod.c, the compiler generated the following
    errors:
    i- Unable to Open include file "jni.h".
    ii- Unable to Open include file "NativeCode.h"
    iii- Declaration Syntax Error.
    What should I do? What is the solution of this
    problem?
    Where I have to put the "jni.h" and "NativeCode.h"
    files?
    Please assist me in solving this problem.
    Many
    Many Buckets
    Many Buckets full of thanks!

  • Class.forName1(Native Method)

    Hi all,
    We are experiencing an irregular memory issue and the Java stack trace is throwing a line:
    at java.lang.Class.forName1(Native Method)
    What does this line indicate? Is this a call into a Unix native library method...i.e a method that the JITC has compiled into native code?
    The stack trace is huge, but this line appears near the top, surrounded by Oracle JDBC traces:
    <snip>
    3XMTHREADINFO "ApplicationServerThread" (TID:0x7035FA20, sys_thread_t:0x3A2CFAA8, state:R, native ID:0x2499) prio=5
    4XESTACKTRACE at com.evermind.io.IOUtils._eu(.(Compiled Code))
    4XESTACKTRACE at com.evermind._ok._tw(.(Compiled Code))
    4XESTACKTRACE at com.evermind._ig.lookup(.(Compiled Code))
    4XESTACKTRACE at com.evermind._lv._ua(.(Compiled Code))
    4XESTACKTRACE at com.evermind.naming.archive.MemoryArchiveContext._tq(.(Compiled Code))
    4XESTACKTRACE at com.evermind.naming.archive.MemoryArchiveContext._gh(.(Compiled Code))
    4XESTACKTRACE at com.evermind.naming.archive.MemoryArchiveContext._ij(.(Compiled Code))
    4XESTACKTRACE at com.evermind._as.findClass(.(Compiled Code))
    4XESTACKTRACE at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
    4XESTACKTRACE at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code))
    4XESTACKTRACE at java.lang.Class.forName1(Native Method)
    4XESTACKTRACE at java.lang.Class.forName(Class.java(Compiled Code))
    4XESTACKTRACE at oracle.jdbc.ttc7.TTC7Protocol.safelyGetClassForName(TTC7Protocol.java:3664)
    4XESTACKTRACE at oracle.jdbc.driver.OracleConnection.safelyGetClassForName(OracleConnection.java(Compiled Code))
    4XESTACKTRACE at oracle.jdbc.driver.OracleConnection.addClassMapEntry(OracleConnection.java(Compiled Code))
    </snip>
    Our environment is as follows:
    - Unix 64 bit AIX 5.3
    - IBM 32 bit Java JDK, JITC Enabled
    - Oracle 10g
    - Oracle Type 4 Drivers
    Also, is there a website, book or any documentation that delves into these types of Java exceptions and how to interpret a stack trace?
    Any help would be greatly appreciated?
    tia,
    adym
    Message was edited by:
    adym-lincoln

    "scripts" are entirely different from GUI applications. What do you expect to happen when you run a Swing application through telnet on another machine? Do you expect the Swing UI to be magically transported to the local Windows machine?
    Not gonna happen. Yes, like ejp hinted, you could run an X-environment on your local machine and have the Swing UI tunnel its output there, but are you sure you want GUI apps to run on a remote machine like that? It's not gonna be fun to work with, I'll tell you that.
    Why not create a Java WebStart app (or perhaps even an applet) out of your application, so your users can run the application locally?

  • Accessing a native method from within a packaged class

    I have seen some very useful information from RPaul. However, I can not quite get it to work.
    I have a class "JNIGetUserId" that is in a package "com.services.localoptions". I am trying to call a native method from a dll. it works fine at the default package level. But not in the package. I have tried adding the "_" between each level of the directory in the h and c++ files. I also found that doing a javah at the top of the package structure it includes some information in the h file. A "_0005" shows up between each level.
    This is on Windows XP. I am also using VisualAge for Java. I also am using JDK 1.3.1.
    The source files:
    package com.services.localoptions;
    * This class provides the JNI Interface to call the
    * AD User Maintainence routines.
    * These routines are stored in the JNIGetUserIdLibrary.dll.
    * The routines are:
    * <ul>
    * <li>getUser - returns a string containing the User Id
    * <eul>
    * @author: Ray Rowehl
    * @date (10/15/2003 10:30:59 AM)
    public class JNIGetUserId
         // Load the library
         static
         try
              System.out.println("loading dll");
         System.loadLibrary("JNIGetUserIdLibrary");
         System.out.println("loaded dll");
         catch (UnsatisfiedLinkError ue)
              System.out.println("Link Error");
    * native C++ method to call getUserId routine
    public native String getUser() throws Exception;
    * This method allows us to test standalone..
    * Creation date: (10/16/2003 2:08:58 PM)
    * @param args java.lang.String[]
    public static void main(String[] args)
         try
              System.out.println("Trying method 3");
              JNIGetUserId lGUD = new JNIGetUserId();
              System.out.println(lGUD.getUser());
         catch (Exception e)
              System.out.println("Got an exception " + e);
              e.printStackTrace();
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class JNIGetUserId */
    #ifndef IncludedJNIGetUserId
    #define IncludedJNIGetUserId
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class: JNIGetUserId
    * Method: getUser
    * Signature: ()Ljava/lang/String;
    JNIEXPORT jstring JNICALL Java_com_localoptions_JNIGetUserId_getUser
    (JNIEnv *, jobject);
    #ifdef __cplusplus
    #endif
    #endif
    // Implements method to return a string to Java
    // C++ core header
    #include <iostream.h>
    // header from Java Interface
    #include "JNIGetUserId.h"
    #include "JNIGetUserId2.h"
    // returns a string back to Java for package structure
    JNIEXPORT jstring JNICALL Java_com_services_localoptions_JNIGetUserId_getUser
    ( JNIEnv * env, jobject thisObject )
         // set up constant user id for testing return
         char* userid = "RROWEHLP";
         // return userid to caller
         return env->NewStringUTF( userid );     
    // returns a string back to Java for flat structure
    JNIEXPORT jstring JNICALL Java_JNIGetUserId_getUser
    ( JNIEnv * env1, jobject thisObject1 )
         // set up constant user id for testing return
         char* userid1 = "RROWEHL1";
         // return userid to caller
         return env1->NewStringUTF( userid1 );     
    }

    Ok. A co-worker figured it out for me. The key thing is to do "javah com.services.localoptions.JNIGetUserId". Note the use of "." instead of "\". Running on windows, I was used to doing "\". That was part of the problem. Another key is doing the javah at the top of the package structure. This was mentioned in a post over at IBM.
    We got our JNI stuff working now. thanks, ray.

  • Getting cl_abap_structdescr for method parameters of LOCAL classes?

    Hi guys
    I have a bit of a of a problem with getting an instance of the cl_abap_structdescr class for a method parameter type of a local class. The RTTI structure abap_parmdescr can only be used to diffrentiate between the basic built-in ABAP types and whether types are structures, tables or references. The question now arrives that once you have diffentiated that the parameter is a structure how do you determine the actual structure TYPE name for local classes to create an instance of the cl_abap_structdescr to continue your run-time analysis. For dictionary classes the parameter type name can be retrieved from the seosubcodf table, to me it looks as if one would have to resort to scanning the source code of local classes to arrive at the actual  structure type name, but before I go to THAT kind of trouble I was wondering whether somebody out there might have a better solution for me. Your help would be grreatly appreciated and rewarded ;).
    Kind regards
    Ettienne Hugo

    Hello Uwe
    Thanks for your reply, I checked out the CL_OO_LOCAL_CLASSES class, unfortunately the class actually operates on the local classes declared for a dictionary class. I think to clarify my question I should point out that the parameters I'm trying to process are parameters that belong to classes that are defined and implemented using include programs, these include programs would then typically be used in Function Groups to construct applications so the classes that I refer to are actually not in any way related to dictionary classes. The cl_abap_classdescr class works fine on these types of classes when you refer to them using the "\PROGRAM=my_program\CLASS=my_class" format with the describe_by_name method, unfortunately the class just does not provide sufficient information for structure type parameters to actually construct them during run-time...
    Stay well
    Ettienne

  • Problem with local class, static private attribute and public method

    Hello SDN,
    Consider the following situation:
    1) I have defined a LOCAL class airplane.
    2) This class has a private static attribute "type table of ref to" airplane (array of airplanes)
    3) A public method should return the private static table attribute
    Problems:
    a) The table cannot be given as an EXPORTING parameter in the method because TYPE TABLE OF... is not supported and I get syntax errors. I also cannot define a dictionary table type because it is a local class.
    b) The table cannot be given as a TABLES parameter in the method because TABLES is not supported in the OO context.
    c) The table cannot be given as an EXPORTING parameter in the method defined as LIKE myStaticAttribute because my method is PUBLIC and my attribute is PRIVATE. ABAP syntax requires that all PUBLIC statements are defined before PRIVATE ones, therefore it cannot find the attribute to reference to with LIKE.
    I see only 2 solutions:
    a) Never ever use local classes and always use global classes so that I might define a dictionary table type of my class which I can then use in my class.
    b) Make the attribute public, but this goes against OO principles, and isn't really an option.
    Am I missing anything here, or is this simply overlooked so far?

    Hello Niels
    Since your class is local and, thus, only know to the "surrounding" application is does not really make sense to make it public to any other application.
    However, if you require to store instances of your local classes in internal tables simply use the most generic reference type possible, i.e. <b>OBJECT</b>.
    The following sample report shows how to do that. Furthermore, I believe it also shows that there are <u><b>no </b></u>serious inconsistency in the ABAP language.
    *& Report  ZUS_SDN_LOCAL_CLASS
    REPORT  zus_sdn_local_class.
    " NOTE: SWF_UTL_OBJECT_TAB is a table type having reference type OBJECT
    *       CLASS lcl_airplane DEFINITION
    CLASS lcl_airplane DEFINITION.
      PUBLIC SECTION.
        DATA:    md_counter(3)             TYPE n.
        METHODS: constructor,
                 get_instances
                   RETURNING
                     value(rt_instances)   TYPE swf_utl_object_tab.
      PRIVATE SECTION.
        CLASS-DATA: mt_instances    TYPE swf_utl_object_tab.
    ENDCLASS.                    "lcl_airplane DEFINITION
    *       CLASS lcl_airplane IMPLEMENTATION
    CLASS lcl_airplane IMPLEMENTATION.
      METHOD constructor.
        APPEND me TO mt_instances.
        DESCRIBE TABLE mt_instances.
        md_counter = syst-tfill.
      ENDMETHOD.                    "constructor
      METHOD get_instances.
        rt_instances = mt_instances.
      ENDMETHOD.                    "get_instance
    ENDCLASS.                    "lcl_airplane IMPLEMENTATION
    DATA:
      gt_instances      TYPE swf_utl_object_tab,
      go_object         TYPE REF TO object,
      go_airplane       TYPE REF TO lcl_airplane.
    START-OF-SELECTION.
      " Create a few airplane instance
      DO 5 TIMES.
        CREATE OBJECT go_airplane.
      ENDDO.
      gt_instances = go_airplane->get_instances( ).
      CLEAR: go_airplane.
      LOOP AT gt_instances INTO go_object.
        go_airplane ?= go_object.
        WRITE: / 'Airplane =', go_airplane->md_counter.
      ENDLOOP.
    END-OF-SELECTION.
    Regards
      Uwe<u></u>

  • How do I declare a native method outside of the main class?

    Hi
    This is a JNI particular question.
    I am having a problem with generating the header .h file after executing javah. The file is generated correctly but is empty under certain circumstances.
    This is the 'empty file:
    =================
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class gui_GuiMain */
    #ifndef Includedgui_GuiMain
    #define Includedgui_GuiMain
    #ifdef __cplusplus
    extern "C" {
    #endif
    #ifdef __cplusplus
    #endif
    #endif
    This is what it should look like:
    =========================
    /* DO NOT EDIT THIS FILE - it is machine generated */
    #include <jni.h>
    /* Header for class gui_GuiMain */
    #ifndef Includedgui_GuiMain
    #define Includedgui_GuiMain
    #ifdef __cplusplus
    extern "C" {
    #endif
    * Class: gui_GuiMain
    * Method: getValueOIDTestMIB
    * Signature: ()V
    JNIEXPORT void JNICALL Java_gui_GuiMain_getValueOIDTestMIB
    (JNIEnv *, jobject);
    #ifdef __cplusplus
    #endif
    #endif
    The header file becomes "empty" when the native function getValueOIDTestMIB is declared in a different class than what my main() function is declared in.
    For example something like this will work:
    class Main
    public native void getValueOIDTestMIB
    static {
    System.loadLibrary("libsnmp++");
    //............some more functions etc.............
    public static void main(String[] args)
    //............some more stuff...........................
    But when I declare this:
    public native void getValueOIDTestMIB
    static {
    System.loadLibrary("libsnmp++");
    outside the class, in another class within the same package, nothing happens.
    I am probabily doing something stupid. Can somebody help or give me some guidance to where I should look. I come from a C++ background, not a guru in Java.
    Thanks

    You need to run javah and give it as a parameter the full class name of the class which contains the native methods.
    For example (if your class is called A and its package is a.b.c)
    javah -jni a.b.c.A

  • Exception in Class class native method

    Hi Guys,
    I am getting an Exception in the Class class native method getMethod0. The Exception is java.lang.NoSuchMethodException. Can some put light on this, as to why is this coming???
    Here's the starckTrace........
    java.lang.NoSuchMethodException
         at java.lang.Class.getMethod0(Native Method)
         at java.lang.Class.getMethod(Class.java:888)
         at com.gepower.gees.vc.utility.VCComparator.compare(VCComparator.java:67)
         at java.util.Arrays.mergeSort(Arrays.java:1181)
         at java.util.Arrays.mergeSort(Arrays.java:1189)
         at java.util.Arrays.mergeSort(Arrays.java:1189)
         at java.util.Arrays.mergeSort(Arrays.java:1188)
         at java.util.Arrays.mergeSort(Arrays.java:1189)
         at java.util.Arrays.mergeSort(Arrays.java:1189)
         at java.util.Arrays.mergeSort(Arrays.java:1188)
         at java.util.Arrays.sort(Arrays.java:1128)
         at java.util.Collections.sort(Collections.java:121)
    Thanx,
    Chandan.

    Class.getMethod() throws that exception if the method that is being searched for does not exist.
    And VCComparator.compare() used Class.getMethod().
    So something is wrong in VCComparator.compare().

  • Testing ActionScript classes with native methods?

    Hi,
    I have an ActionScript class that I'm writing and would like to test using FlexUnit.
    The only issue is that the ActionScript class has a member in it that is a class with native methods.
    So, I get the following error when trying to run a test of that ActionScript class:
    VerifyError: Error #1079: Native methods are not allowed in loaded code.
    Does anyone know of a way to get around this?  FlexUnit seems not to like native methods being present.
    Thanks,
    Matt

    Hi casdvm,
    by definition, you only own objects that you created using one of the alloc* methods, copy: or new:. All other objects (IIRC with a few noted exceptions) are autoreleased.
    If you create convenience methods in your own class, you should follow the same rule. For example, if you have a class Pet and want to implement the method +petWithName, your code might look something like that:
    + petWithName: (NSString *)name
    return [[[Pet alloc] initWithName: name] autorelease];
    Alex

Maybe you are looking for