Defining inherited classes in JNI

I have to use JNI in order to inherit a concrete class from an abstract one (java.util.TimerTask) and, then, instantiate it.
I have to re-define the abstract method "run" of "TimerTask". In Java it's a trivial problem but I have to do it in C++!
I hope I explained my problem. How do I work this?

Well, it's not entirely clear. My assumption is that you want to derive a concrete class from an abstract class, and you want the concrete class to implemenet "run()").
1. Define your concrete class (in java). Give it a run method, but deine the run method as native.
2. Run jnih and generate a .h file (C header file) for the native method.
3. Write a library (dll on Windows) that implements the subroutine as declared in the .h file.

Similar Messages

  • Use CAST to check if an instance belongs to inherited classes.

    Dear all.
    I have got a method called GET_LINKS which is supposed to give back all references in an internal table which are of a given class or belong to classes being inherited.
    ( I do not have both - access to the internet and our R3 at once that is why I only provide pseudo code)
    Example:
    think of follwing structure:
      cl_object
         cl_class1
            cl_class11
         cl_class2
            cl_class21
            cl_class22
    so if check against cl_objets the method should give back all references .... if cl_class1 only those who belongs to cl_class1 or class11...you got the idea.
    so My method looks somewhat like following.
    method get_links.
    * changing  ch_instance type ref to object.
    * returnning re_links (table of instances)
    loop at ait_links into lwa_links.
      catch system-exception - move_cast_error
       ch_instance ?= lwa_links-instance.
      endcatch.
      if sy-subrc is initial.
        insert lwa_links into table re_links.  
      endif.
    endloop.
    endmethod.
    coding works fine so far - the only thing I do not like is that I have to provide a changing parameter for the cast. I would prefer a local copy of an importing parameter for the checks.
    But as soon as I use a very generic type declaration - like ref to object - no casting error will take place and I am not able to differentiate the groups down the inheritance.
    I tried to create a dynamic reference variable but failed. I guess I would need to create a type dynamically but this is not possible before 6.4 (and I am on 4.6c)
    Any suggestion for that?
    Thank you very much.
    Christian

    Hi, list my suggestion as following:
    'ch_instance type ref to object'
    As it is defined as an object type,
    'ch_instance ?= lwa_links-instance.' won't catch any error, because OBJECT is the root type of any object type, if you only need to compare them and differentiate the class and inherited class from others, you can do like this:
      catch system-exception - move_cast_error
       lwa_links-instance ?= ch_instance.
      endcatch.
    By the way, I don't know what's the definition of lwa_links-instance is. I wrote some sample code for you scenario, as list it as following:
    * I create two inherited class
    CLASS C1 DEFINITION INHERITING FROM CL_ABAP_TYPEDESCR.
      PUBLIC SECTION.
        DATA: C1  TYPE  C.
    ENDCLASS.
    CLASS C2 DEFINITION INHERITING FROM CL_GUI_CONTROL.
      PUBLIC SECTION.
        DATA: C2  TYPE  C.
        METHODS CONSTRUCTOR.
    ENDCLASS.
    CLASS C2 IMPLEMENTATION.
      METHOD CONSTRUCTOR.
        CALL METHOD SUPER->CONSTRUCTOR EXPORTING NAME = 'aaa'.
      ENDMETHOD.
    ENDCLASS.
    * assume that you have a class, using CL_ABAP_CLASSDESCR
    * we can get the name of it
    DATA:
    descr_ref TYPE ref to CL_ABAP_CLASSDESCR.
      descr_ref ?= cl_abap_typedescr=>DESCRIBE_BY_OBJECT_REF( CLass ).
    * then we can transfer the class name into the module get_links
    module XXXX.
      DATA: A  TYPE  REF TO C1,
            B  TYPE  REF TO C2,
            R  TYPE REF TO OBJECT.
      CREATE OBJECT A.
      CREATE OBJECT R TYPE ('C1').
    * here it goes well
    * as the A type is C1, and R is create as C1 too
      CATCH SYSTEM-EXCEPTIONS MOVE_CAST_ERROR = 1.
        A ?= R.
      ENDCATCH.
      CREATE OBJECT R TYPE ('C2').
    * here it can catch the error
    * as the A type is C1, and R is create as C2, C1 & C2 has
    * no relation like inherit
      CATCH SYSTEM-EXCEPTIONS MOVE_CAST_ERROR = 1.
        A ?= R.
      ENDCATCH.
    * XXXX is the class name which transfered into module
      CREATE OBJECT R TYPE ('XXXX'). 
    * then try to create the class according to class name
    * which is you want
      CATCH SYSTEM-EXCEPTIONS MOVE_CAST_ERROR = 1.
        A ?= R.
      ENDCATCH.
    Hope my reply can help you solve the problem
    By the way, the code cost me some time, so don't forget the reward points
    thanks a lot

  • Casting inheritance class in instance

    Hi All..
    my question is almost same as the question in this post:
    http://forum.java.sun.com/thread.jspa?threadID=545767&messageID=2655556
    in the post, charlie2086 ask how to access method in class ComputerPlayer when play declared as:
    Player play = new ComputerPlayer();jsalonen answer with 3 solutions:
    1) Declare the method in the Player class
    2) Declare play as ComputerPlayer rather than Player
    3) Cast play to ComputerPlayer before accessing the method. It is:
    ((ComputerPlayer)play).theMethod();But however, i would like to ask, is it possible to cast the inheritance class? what i mean is, play declared as:
    Player play = new ComputerPlayer();and apply a 1 time casting in the instance, so that each time will no need to apply:
    ((ComputerPlayer)play).theMethod();when access methods in class ComputerPlayer
    Thx or ur all helps..

    But however, i would like to ask, is it possible to
    cast the inheritance class? what i mean is, play
    declared as:
    Player play = new ComputerPlayer();
    and apply a 1 time casting in the instance, so that
    each time will no need to apply:
    ((ComputerPlayer)play).theMethod();when access methods in class ComputerPlayer
    Oh yes, you could do that, but you will have to it in a variable like this
              ComputerPlayer cPlayer = ((ComputerPlayer)play) ;
              //now use cPlayer variable to access methods in class ComputerPlayer
       play has been declared as type 'Player' . So if u want 2 use the 'play' variable, then ofcourse you will have 2 cast it each time.
    however, if u r class has been properly designed, u could, using play access all methods of ComputerPlayer (either inherited from Player or overridden in ComputerPlayer), except those methods defined exclusively by ComputerPlayer (i.e not inherited from Player).
    tx,
    ram.

  • Redefination of Method in Inherited Class

    dear Gurrus i am facing an issu.
    I have defined and implimented 2 classes A and B,
    B is inherited by A and B has also redefined an inherited method of A. at runtime i have created an  object of B and called a redifined method. and its working properly, but i have a requirment that i want to get result of the method orginally defined by class A and also at the same time i also want to see the result of redefined method by B.
    can i access the method of A class althoug i have redefiend the same method in B class using the object of B?
    Edited by: Shadab Ali on Jun 4, 2009 8:55 PM

    I spent a while looking into this after reading your question, and came to much the same conclusion you had. Here's the best I could come up with, but it suffers from all the flaws you mentioned:
         public static Type report(Method method, Class contextClass) {
              Type grt = method.getGenericReturnType();
              Class dc = method.getDeclaringClass();
              TypeVariable[] tva = dc.getTypeParameters();
              Class directDescendent = contextClass;
              while( !directDescendent.getSuperclass().equals(dc)) {
                   directDescendent = directDescendent.getSuperclass();
              Type t = directDescendent.getGenericSuperclass();
              if( t instanceof ParameterizedType ) {               
                   ParameterizedType pt = (ParameterizedType)t;
                   int index = 0;
                   for( Type ta : pt.getActualTypeArguments() ) {
                        if( tva[index++].equals(grt) ) return ta;
              return null;
         }Might be worth asking this again in the Generics forum.

  • Error while defining class: com.crystaldecisions.data.xml.CRDB_XMLImpl This error indicates that the class: OCA.OCAdbdll.DbDLLOperations could not be located while defining the class: com.crystaldecisions.data.xml.CR...

    Post Author: lkamesam
    CA Forum: Integrated Solutions
    Hi,
            I am running Crystal Reports version 10 from IBM Rational 6.0.1  build 20050725_1800 XML data source. When I try to run the report under WAS 6.0.1 I get the following error:
    Does any body have any clue how to resolve my problem? Thanks
    Error 500: Error while defining class: com.crystaldecisions.data.xml.CRDB_XMLImpl This error indicates that the class: OCA.OCAdbdll.DbDLLOperations could not be located while defining the class: com.crystaldecisions.data.xml.CRDB_XMLImpl This is often caused by having the class at a higher point in the classloader hierarchy Dumping the current context classloader hierarchy: ==> indicates defining classloader *** indicates classloader where the missing class could have been found ==>&#91;0&#93; com.ibm.ws.classloader.CompoundClassLoader@163dd786 Local ClassPath: C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\classes;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\bobj_platform_jsf.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\cecore.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\celib.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\ceplugins.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\cereports.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\cesession.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\clientlogic.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\Concurrent.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\CorbaIDL.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\CRDBXMLExternal.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\CRDBXMLServer.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\CrystalCharting.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\CrystalCommon.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\CrystalContentModels.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\CrystalExporters.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\CrystalExportingBase.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\CrystalFormulas.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\CrystalQueryEngine.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\CrystalReportEngine.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\CrystalReportingCommon.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\ebus405.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\icu4j.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\jrcerom.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\jsf_common.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\keycodeDecoder.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\log4j.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\MetafileRenderer.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\rasapp.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\rascore.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\rpoifs.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\serialization.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\URIUtil.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\webreporting-jsf.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\webreporting.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\xercesImpl.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent\WEB-INF\lib\xmlParserAPIs.jar;C:\Documents and Settings\Administrator\IBM\rationalsdp6.0\workspace\sample1\WebContent; Delegation Mode: PARENT_FIRST &#91;1&#93; com.ibm.ws.classloader.JarClassLoader@338761606 Local Classpath: Delegation mode: PARENT_FIRST &#91;2&#93; com.ibm.ws.classloader.ProtectionClassLoader@38e75786 &#91;3&#93; com.ibm.ws.bootstrap.ExtClassLoader@7e475784 &#91;4&#93; sun.misc.Launcher$AppClassLoader@7e5a5784 &#91;5&#93; sun.misc.Launcher$ExtClassLoader@7e565784 -Original exception- java.lang.NoClassDefFoundError: OCA/OCAdbdll/DbDLLOperations at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java(Compiled Code)) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java(Compiled Code)) at com.ibm.ws.classloader.CompoundClassLoader._defineClass(CompoundClassLoader.java:576) at com.ibm.ws.classloader.CompoundClassLoader.findClass(CompoundClassLoader.java(Compiled Code)) at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java(Compiled Code)) at java.lang.ClassLoader.loadClass(ClassLoader.java(Compiled Code)) at com.crystaldecisions.reports.queryengine.driver.i.<init>(Unknown Source) at com.crystaldecisions.reports.queryengine.driver.i.case(Unknown Source) at com.crystaldecisions.reports.queryengine.av.ak(Unknown Source) at com.crystaldecisions.reports.queryengine.av.else(Unknown Source) at com.crystaldecisions.reports.queryengine.av.byte(Unknown Source) at com.crystaldecisions.reports.queryengine.av.do(Unknown Source) at com.crystaldecisions.reports.queryengine.as.new(Unknown Source) at com.crystaldecisions.reports.queryengine.at.long(Unknown Source) at com.crystaldecisions.reports.reportdefinition.datainterface.j.a(Unknown Source) at com.crystaldecisions.reports.reportdefinition.datainterface.j.a(Unknown Source) at com.crystaldecisions.reports.reportdefinition.datainterface.j.a(Unknown Source) at com.crystaldecisions.reports.reportdefinition.cy.b(Unknown Source) at com.crystaldecisions.reports.reportdefinition.cy.long(Unknown Source) at com.crystaldecisions.reports.reportdefinition.a1.o(Unknown Source) at com.crystaldecisions.reports.reportdefinition.a1.a(Unknown Source) at com.crystaldecisions.reports.common.ab.a(Unknown Source) at com.crystaldecisions.reports.common.ab.if(Unknown Source) at com.crystaldecisions.reports.reportdefinition.a1.if(Unknown Source) at com.crystaldecisions.reports.reportdefinition.a1.o(Unknown Source) at com.crystaldecisions.reports.reportengineinterface.a.a(Unknown Source) at com.crystaldecisions.reports.reportengineinterface.JPEReportSource.a(Unknown Source) at com.crystaldecisions.reports.reportengineinterface.JPEReportSourceFactory.createReportSource(Unknown Source) at com.crystaldecisions.report.web.a.a.K(Unknown Source) at com.crystaldecisions.report.web.event.aa.a(Unknown Source) at com.crystaldecisions.report.web.event.aa.a(Unknown Source) at com.crystaldecisions.report.web.event.bx.a(Unknown Source) at com.crystaldecisions.report.web.event.b1.broadcast(Unknown Source) at com.crystaldecisions.report.web.event.as.a(Unknown Source) at com.crystaldecisions.report.web.WorkflowController.if(Unknown Source) at com.crystaldecisions.report.web.WorkflowController.doLifecycle(Unknown Source) at com.crystaldecisions.report.web.ServerControl.a(Unknown Source) at com.crystaldecisions.report.web.ServerControl.processHttpRequest(Unknown Source) at com.crystaldecisions.report.web.viewer.taglib.ServerControlTag.doEndTag(Unknown Source) at com.crystaldecisions.report.web.viewer.taglib.ReportServerControlTag.doEndTag(Unknown Source) at com.ibm._jsp._sample._jspx_meth_crviewer_viewer_0(_sample.java:135) at com.ibm._jsp._sample._jspService(_sample.java:77) at com.ibm.ws.jsp.runtime.HttpJspBase.service(HttpJspBase.java:88) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1212) at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:629) at com.ibm.wsspi.webcontainer.servlet.GenericServletWrapper.handleRequest(GenericServletWrapper.java:117) at com.ibm.ws.jsp.webcontainerext.JSPExtensionServletWrapper.handleRequest(JSPExtensionServletWrapper.java:171) at com.ibm.ws.jsp.webcontainerext.JSPExtensionProcessor.handleRequest(JSPExtensionProcessor.java:230) at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:2837) at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:220) at com.ibm.ws.webcontainer.VirtualHost.handleRequest(VirtualHost.java:204) at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1681) at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:77) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:421) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:367) at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:276) at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminaters(NewConnectionInitialReadCallback.java:201) at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:103) at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:548) at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java:601) at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:934) at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1021) at

    For those who would have the same problem, here is how I could eventually fix it.
    Since the Flex Test Drive is sometimes out of sync with flash builder 4, I recreated a project using other help pages on Adobe site :
    Entry point :
    http://help.adobe.com/en_US/Flex/4.0/AccessingData/WSbde04e3d3e6474c4-668f02f4120d422cf08- 7ffd.html
    As suggested, I used the New Project wizard to create a new project, with :
    Application server type : J2EE
    Check the radio button "Use remote object access service : BlazeDS"
    Then, as indicated in following pages (section "Accessing BlazeDS")... :
    file:///C:/Mes%20documents%20C/Commun/Developpement/Documentation/HT-Tracks/AccessingData/ help.adobe.com/en_US/Flex/4.0/AccessingData/WSbde04e3d3e6474c4-668f02f4120d422cf08-7ffe.ht ml#WSbde04e3d3e6474c4-19a3f0e0122be55e1b7-8000
    ...I selected the "Data / Connect to Data/Services..." menu option, which started the Data/service connection wizard.
    There, I selected a BlazeDS (and not Web Services) service type, and everything went fine.
    Suggestion to adobe staff : maybe it would be useful to update the Flex Test Drive to reflect Flash Builder 4 ?
    Very nice product anyway, so far, congratulations...
    Rgds
    Marc.

  • How to use user defined exception class

    Hi all
    I just need som help with creating a user defined exception class.
    Im writing a small/simple text editor.
    My exception class looks like this:
    public class myExcp extends Throwable
         private String message;
         public myExcep(String message)
              this.message = message;
         public void display()
              System.out.println(message);
    I would like to use it when a user tries to open a exe-file instead of a txt file.
    Here is some code from the editor:
    if (e.getSource() == open)
    saveOld();
    if (fc.showOpenDialog(null)== JFileChooser.APPROVE_OPTION)
    readFile(fc.getSelectedFile().getAbsolutePath());           
    saveas.setEnabled(true);                
    So, should I use exception here or at the readFile method?
    readfile:
    private void readFile(String fileName)
    try
    String tmp = fileName.substring(fileName.length() -4, fileName.length());
    if (!tmp.equals(".exe"))
    FileReader r = new FileReader(fileName);
    textarea.read(r, null);
    r.close();
    currentFile = fileName;
    label.setText(currentFile);
    changed = false;
    catch (IOException e)
    JOptionPane.showMessageDialog (this, "Cannot find the file " + fileName);
    Where and how do I use my exception class.
    Do I need to create an instance? Where?
    Should the exception class extend Exception instead?
    Thank you in advance /

    Extend Exception, not Throwable. It's a checked exception that way.
    Follow the Sun coding standards and make that exception class name start with a capital letter.
    When you extend Exception, override all four ctors.
    What's that display method you added? Isn't getMessage() good enough?
    You need to create a new instance just before you throw the exception, of course.
    Sounds like a terrible design, by the way. Exceptions shouldn't be used like "go to" for app logic. They should signal unrecoverable conditions. You can easily recover from the situation you've described simply by displaying a pop-up that tells the user to open only text-readable file types. I think that's a better solution.
    %

  • Instatiating a C++ class through JNI

    I am trying to instantiate a C++ class from within my Java program using JNI. I want to instatiate the class once, and then call a function within the class a number of times, in which the results obtained from the previous time the function was run would be used the next time the function was run. By instantiating tha class, my hope is that the variable values would stay within the class, and therefore would not need to be passed.
    It is not an option to pass the variable between the C++ and Java code, since I am working with matrices and JNI does not support passing matrices.
    Thanks!

    Here are some things to try:
    1) Just keep a static reference to the class in your DLL. It shouldn't be considered a local reference as Java classes would be, but if it is, maybe you can keep it as a global reference, which is used to keep a reference to a Java class between JNI calls.
    http://java.sun.com/docs/books/tutorial/native1.1/implementing/refs.html
    2) You could also pass the entire class back and forth as a byte array and then cast it when necessary, but that's potentially a lot of data to pass around.

  • To define a class inside a method

    Hi,
    Iam new to OOPS ABAP.
    I had one doubt,
    Can we define and implement a new class inside a method... end method (like below)
    Method M1
    Class C1 Defination.
    Class C1 Implementation
    Method
    Endmethod
    Endmethod
    Please suggest me on this how to proceed.
    Regards
    Srinivas

    Hi Rich Heilman/Naimesh
    The requirement is
    In XI Proxy(XI proxy is related to creation of materials in SAP),there are macros defined, and my client told us to find out wheather is it possible to replace the macros with the classes and methods.
    Can i define a global class and call that method inside the class.
    Method M1
    Define a global class oref
    create object.
    Call method oref->m2.
    Endmethod
    Can i do it in the above way.Please suggest.
    Regards
    Srinivas

  • Can not locate Java class using JNI within C++ DLL

    I am using trying to use JNI to call a Java class from C++. The Java class uses JMS to send messages to a JMS message queue. At first I coded the C++ in a console application that created the JavaVM and used JNI to access the Java class. All worked fine. Then I called the Java class using JNI from threads and ran into the problem of the Java class not able to locate the JMS related classes. This was solved by placing the following line in the constructor of the Java class.
    Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
    Then I moved the JNI code from a console application to a DLL in specific an extension DLL that is called by SQL Server or Oracle server. The DLL will use JNI to call the Java class and send messages to a JMS message queue.
    The problem I am having now when the DLL code is called by SQL Server the call to
    JNI_CreateJavaVM
    appears to work correctly but the call to find the Java class using
    jvmEnv->FindClass(pName)
    fails. It appears the is a class loading problem which occurs due to the fact JNI is called from a DLL. When the VM is created I pass the class path information using the statement
    -Djava.class.path=
    And as I stated before it all works when running from a console application. I am new to JNI and really need help in the form of some sample code that will solve this problem. I believe I need to somehow load the classpath information from the DLL but I can not find examples on how to do this using JNI. I have tried several ways using URLClassLoader and getSystemClassLoader from JNI and either it does not work or it crashes very badly.
    I used the following code to determine what the existing class path is and the string returns empty.
    jcls = jvmEnv->FindClass("java/lang/System");
    jmid = jvmEnv->GetStaticMethodID(jcls, "getProperty", "(Ljava/lang/String;)Ljava/lang/String;");
    jstrClassPath = jvmEnv->NewStringUTF("java.class.path");
    jstr = (jstring)jvmEnv->CallStaticObjectMethod(jcls, jmid, jstrClassPath);
    m_jstr = (jstring)jvmEnv->NewGlobalRef(jstr);
    pstr = jvmEnv->GetStringUTFChars(m_jstr, 0);
    Can anyone please help with example code that will solve this problem. Thanks in advance for any help.
    Charles�

    I have determined the problem occurs when the application/component is compiled using VC 6.0. The test application was compiled using VC 7.1 and works correctly by locating the class path information. If the test application is compiled using VC 6.0 it has the same problem.
    The jvm.dll I am using is version 1.4.2.80. Currently this is not an option to compile all the applications that use JNI using VC 7.1 so can someone please tell me how to solve this problem.

  • Why class defination and class implementaion separated in abap?

    hai experts,
                           i hav doubt why  class defination and class implementaion separated in abap. In know in  C++  its  possible
            but in JAVA its not possible . what is the main reson behind this concept in ABAP.
    thanks in adv.

    Hi Sree,
    As far as I feel, it's been done with a view of readability. As you know that ABAP  is very well modularized and organized programing language. When you define a local ABAP  Class, you define two seperate sections of it. You define the Class Definition and then you define the Implementations. This way you can really have a look at all the class definitions which are organized in the same section. Then you can have a look at the selected implementation.
    But if this hasn't been the scenario, then as developer looking at the complex classes would have made life hell for you. You can very well figure it out how good to keep things organized for later class maintainance and readability.
    Hope this would shed some light on your question.
    Thanks,
    Samantak.

  • Inheritance class not working

    Alright, so I'm supposed to write an inheritance class called MusicStore, which is inherited from the Store ( already written), and then the MusicStore method tests out the MusicStore. The MusicStore has the additional attributes of the number of titles it offers and the its address...The store already offers the name of the store where the titles are located...I believe I'm writing it the MusicStore correctly, but I get this really odd error when I compile...I am not quite sure how it happens????? Helllpppp!!! I would appreciate it
    I will post the error and the error is located a bit lower in the MusicStore that I posted-
    "File: E:\comp 150\H10\MusicStore.java [line: 13]
    Error: E:\comp 150\H10\MusicStore.java:13: cannot find symbol
    symbol : constructor Store()
    location: class Store"
    Here is the Store:
    /* Store Class
       Anderson, Franceschi
    public class Store
      public final double SALES_TAX_RATE = 0.06;
      private String name;
      public Store( String newName )
        setName( newName );
      public String getName( )
        return this.name;
      public void setName( String newName )
        this.name = newName;
      public String toString( )
        return( "name: " + this.name );
      public boolean equals( Store otherStore )
        return ( this.name.equalsIgnoreCase( otherStore.name ) );
    }Here is the MusicStore:
    /* MusicStore class
    Smith, Tahnee
    public class MusicStore extends Store
      public final int DEFAULT_NUMBER = 0;
      private int numberOfTitles;
      public final String DEFAULT_ADDRESS = " ";
      private String address;
      public MusicStore()
      {                                         // LINE 13 : Here is where the error is...I don't understand what is going on here.
        address = DEFAULT_ADDRESS;
        numberOfTitles = DEFAULT_NUMBER;
      public MusicStore(String startNameStore, int startNumber, String startAddress)
        super( startNameStore );
        setNumberOfTitles( startNumber );
        setAddress( startAddress);
      public void setAddress( String newAddress)
        address = newAddress;
      public void setNumberOfTitles(int newNumber)
        if ( numberOfTitles > 0 )
          numberOfTitles = newNumber;
        else
          System.out.println(" Number of titles cannot be negative");
      public String toString()
        return super.toString()
          + " The number of titles are " + numberOfTitles
          + " The address is " + address;
    }Here is the MusicStoreClient:
    /* MusicStoreClient class
       Anderson, Franceschi
    public class MusicStoreClient
      public static void main( String [] args )
        MusicStore ms1 = new MusicStore( "Records, Inc.", 1000, "123 Elm Street" );
        MusicStore ms2 = new MusicStore( "All Records Unlimited", 1200, "999 Green Street" );
        System.out.println( ms1 );
        System.out.println( ms2 );
        ms2.setNumberOfTitles( 1000 );
        ms2.setAddress( "123 Elm Street" );
        if ( ms1.equals( ms2 ) )
          System.out.println( "ms1 and ms2 are equal" );
        else
          System.out.println( "ms1 and ms2 are not equal" );
        ms2.setName( "Records, Inc." );
        if ( ms1.equals( ms2 ) )
          System.out.println( "ms1 and ms2 are now equal" );
        else
          System.out.println( "ms1 and ms2 are still not equal" );
    }Edited by: guitarlady3000 on Nov 5, 2008 4:22 PM
    Edited by: guitarlady3000 on Nov 5, 2008 4:37 PM

    You don't explicitly call the super(...) constructor in your parameterless MusicStore constructor code and so Java will automatically and behind the scenes place a call to super() there. Problem is, Store doesn't have a parameterless constructor. Solution: either give Store a parameterless constructor or explicitly call super with a proper parameter.

  • Customer Defined Data Classes on Cluster Tables?

    Hi all,
    I noticed that there is no option within db13 to change the storage option to a customer defined data class, for cluster tables. I am sure this is by design but wanted to check to see if anyone has had any luck defining a data class on a cluster table.
    We could move a cluster table to a DB2 tablespace and define the new Data Class through dbacockpit/db02, but there is no option to change the data class definition in the data dictionary (se13) to use the new Data Class for the table itself.
    Mainly what we are aiming for is to be able to move 2 tables into their own tablespaces on the target server, during a migration. Sapinst is looking at the Data Classes to create DDLDB6.XML, which defines the tablespace assignments to the target server, so perhaps there is a preferred method of making this change, if it does exist.
    Thanks for any insights,
    Derek

    Hi guys,
    Thanks for the helpful answers. I should add some more detail.
    Our tablespaces have already been moved to new tablespaces on the source system, with DB6CONV, and we have updated our data classes through db02, with no problems. So sapinst uses the data class definitions to create the custom tablespaces, and then uses the data class assignments to assign the table to a tablespace.
    However, the cluster tables do not seem to support the data class assignment in se13, the option is not available as it is for normal tables. Let me see if I can post a screenshot somewhere with a cluster table versus a normal table. For example, there is no option to change the data class for table CDCLS in se13.
    I am wondering if this is a limitation of the version of R/3 we are using, or if the limitation for cluster tables is something that is intended on all versions of R/3.
    If we can't use db13 to make the assignment, we may try the custom definition in the STR file as Kiran mentioned.

  • Define local classes in function groups

    Hi,
    I have seen in few code examples that programmers defined their classes as follows:
    1. Interfaces are defined globally i.e. under package->class library->interfaces.
    2. implementing classes are defined locally under: package->function group (as public local class in the function group).
    My question is What is the advantage/disadvantage of it?
    (beside encapsulation).
    I heard that the class loader is working better in that way, is that right?
    thanks,
    Yaron

    Hi
    excuse me I miserunderstood.
    Perhaps it's true I don't know.
    I think the different is the SE24 is a library, so it's the tool arranged to analyze all class components you can need.
    I don't think it's easier to analyze an include (function group) where the class is defined and implemented.
    You shuold measure the time in order to load the class for both case, but probably the different isn't meaningful.
    You should consider that ABAP wasn't OO language, but it was adapted for OO, and so the most ABAP developer weren't used to use OO.
    I think you should define a class as local class if it's your own class.
    Max
    Message was edited by: max bianchi

  • Trouble with  instantiating inherited classes in a switch statement

    Hi
    I have few inherited classes which I need to instantiate in a switch statement based on command line argument supplied by user. I am ble to do that but I cannot access any methods once I come out of the switch scope. Please suggest a way to resolve this problem. The error I am getting is in the end of code in comments // //. Would really appreciate your help.
    Thanks
    Here is the code.
    package assignment2;
    import java.util.*;
    import java.io.*;
    abstract class Parent
    abstract void childclassDescription();
    void generalDescriptionToAllChilds()
    System.out.println("general to all child classes");
    childclassDescription();
    class Child1 extends Parent
    public void childclassDescription()
    System.out.println("i'm child1");
    class Child2 extends Parent
    public void childclassDescription()
    System.out.println("i'm child2");
    class Child3 extends Parent
    public void childclassDescription()
    System.out.println("i'm child3");
    public class Demo
    public static void main(String[] args)
    int option;
    Parent p;
    System.out.println("Pick from one of the following:");
    option=1; // supplying
    switch(option)
    case 1:
    p=new Child1();
    break;
    case 2:
    p=new Child2();
    break;
    case 3:
    p=new Child3();
    default:
    break;
    p.generalDescriptionToAllChilds();
    //error variable p might not have been initialized at line //
    }

    Well I also think that in Java, it is possible for a reference type variable to refer to nothing at all. A reference that refers to nothing at all is called a null reference . By default, an uninitialized reference is null.
    We can explicitly assign the null reference to a variable like this:
    f = null;
    But still i am not quety sure why you needed to do it.

  • Recon and provisioning of user-defined object class ICF Active Directory

    I have followed the documentation instructions for reconciliation of a user-defined object class in the ICF Active Directory connector. I am using OIM 11gR2 with the ICF Active Directory 11.1.1.5 connector patched to 11.1.1.5.0A. The procedure states to create the new object class in AD and then change the objectClass value in the Lookup.Configuration.ActiveDirectory lookup. In my case I am using the existing ObjectClass of contact, rather than a new object class. Just for completeness I am using a clone of the AD User Resource Object which I call AD User Contact and so my lookup name is Lookup.Configuration.ActiveDirCon.
    When I changed the ObjectClass from User to Contact, and ran the Active DirCon User Target Recon scheduled job, with Object Type also = contact. The first issue I noticed was that the connector wanted a different set of lookups, which is not in the documentation. It is looking for a lookup in my Configuration lookup where code key=contact Configuration Lookup (which I should have expected since there are code keys for User, Group, and organizationalUnit). I added a line to the lookup where code key=contact Configuration Lookup and the Decode=Lookup.ActiveDirCon.CM.Configuration and then I created a new lookup by that name, assigning the 5 values to be the Lookup.ActiveDirCon.UM.xxx lookups. I did not see any need to create a new set of Lookup.ActiveDirCon.CM.xxx lookups with the exact same values.
    I re-ran the scheduled job and it ran successfully, but did not generate any Recon Events, even though I had objects in the OU and I have that same OU in the Lookup.ActiveDirCon.OrganizationalUnits lookup (from the Org Lookup Recon). Everything looks good but getting no results. Looked at the log file from the ConnectorServer and it is building the query properly and executing it properly with the correct syntax, getting no errors, but the SearchAndReturnObjects method is returning zero results.
    Looking to see if anyone has successfully reconciled in user-defined or other non-User objectClass objects from Active Directory, and if so, can you provide Lookup configuration and Connector Server information so I can troubleshoot.
    I resolved this issue by changing the recon lookups to a blank lookup called Lookup.ActiveDirCon.CM.ReconAttrMap and only added in the parameters that are used by a Contact object. Only populate the ReconAttrMap with parameters that exist for the custom object.
    Edited by: Keith Smith AptecLLC on Mar 27, 2013 6:31 AM

    Oracle Support answered this question via SR

Maybe you are looking for

  • Mac Mail issues after latest Security Update

    After installing the latest update my Mail is acting very strange. If I open my Mail app it spins like it is retrieving mail but never gets anything and eventually acts like I am disconnected from the internet, which I am definitely not. In addition

  • Firewire power stays on

    Im having an issues with an external drive I have connected to my Mini via Firewire. When I power off the Mini the drive is supposed to power off as well, automatically. It is not doing this, and Ive read here that this is because the Firewire port s

  • Lost iChat somehow how do i get it back in the system

    I am a newbe for mac. I had a msn messenger update and i downloaded it for the im, and when it finished it showed a ? in the middle of the iChat icon. I clicked on it and nothing happened. I got out of MSN and came onto mac said and the iChat icon wa

  • Error ORA-00955:

    Hi, Why would I get this error message when I run the script below. SQL> START test.sql; Table dropped. Table created. create TABLE student * ERROR at line 1: ORA-00955: name is already used by an existing object script: drop TABLE student create TAB

  • Will this hard drive work with my iBook G4?

    My iBook's hard drive is in disrepair and I was wondering if this had drive will work. I am pretty sure it will, but I don't want to spend any money until I know for sure. http://www.compusa.com/products/productinfo.asp?productcode=316211&pfp=srch1&t