Instantiating a Class

I need to Instantiate a Class from a String.
For example, i have the String "MyClass", i need to Instantiate the class MyClass.
Is it possible ?
Help, me.
Thanks.

Read the API for java.lang.Class. Especially the methods forName() and newInstance().

Similar Messages

  • Reg: help on instantiation of class in workflow task

    Hi Geeks,
               I am trying to use class for Purchase order though standard workflow is available with BO. As per the requirement the triggering event is same as in the standard workflow with BO. Once the workfow is triggered ,The data is pulled to class from BO and custom release step is defined for release in class .
                  I face problem with the instantiation of class in workflow task while passed the po value and defined binding for the same after  reading  the document posted by jocelyn dart regarding this as follows :[www. wiki.sdn.sap.com/.../UsingABAPOOmethodsinWorkflowTasks |www. wiki.sdn.sap.com/.../UsingABAPOOmethodsinWorkflowTasks ]
    I am getting error as " Formal parameter " po number  " not defined.Please Advice.
    Regards,
    Kumar.

    Hi,
    I checked the same still no luck. I checked approx all combination.
    First I created a SOA-SAR file(jar file) , I extracted it and checked all jar files were there. orabpel.jar and bpm-services.jar and log4j jar. when i deployed that jar file. but it was not working
    then I put this in weblogic sever lib. it not worked.
    please tell me some points

  • Errors with CF 8.0.1 hotfix 3 and hotfix 4, "Object Instantiation Exception.Class not found"

    We need to get our servers up to date with the latest ColdFusion hotfixes in order to pass our security scans and policies. We have been following the Adobe instructions for installing the hotfixes, but we’re getting the same errors each time. The CF 8 hotfix 2 works fine, but once we install hotfix 3 and/or hotfix 4, we get the following errors:
    "Object Instantiation Exception.Class not found: coldfusion.security.ESAPIUtils The specific sequence of files included or processed is: C:\ColdFusion\wwwroot\WEB-INF\exception\java\lang\Exception.cfm, line: 12 "
    coldfusion.runtime.java.JavaObjectClassNotFoundException:
    We have dozens of servers running Windows XP, Netscape Enterprise Server 6.1 (I  know, don’t laugh), ColdFusion 8,0,1,195765, and Java Version 1.6.0_04. Just about  the only good thing about running XP on our servers is that it matches  our development boxes, so we have almost mirrored environments for dev,  test, and production. We do NOT have the CF install with the J2EE configuration.
    The crazy thing is, on tech note 51180 (http://kb2.adobe.com/cps/511/cpsid_51180.html), it says that the fix for bug # 71787 (Fix for "Object Instantiation Exception" thrown when calling a Java object constructor or method with a null argument under JDK 1.6.) was added in cumulative hotfix 2. However we don’t see this problem until we go to hotfix 3 (or 4).
    I’ve also been reading that other people had this same problem, and that the CF 8 hotfix 3 was not compatible with certain versions of JDK, then when you read the Adobe site for CF 8.0.1 hotfix 3, it says “Added the updated cumulative hotfix to make it compatible with jdk 1.4.x, 1.5.x and 1.6.x.”, so that makes me think that Adobe was supposed to have fixed this CF 8.0.1 hotfix 3 JDK incompatability issue - but unfortunately it's still not working for us. We have followed the instructions for removing the jar files and starting/restarting the CF server as directed, we’ve tried this 5-6 times, and still no luck.
    Recommendations? Seems like this is a ColdFusion bug to me – one that says is fixed on the Adobe site, but is not fixed in our environment. Please advise, thanks.

    For what it's worth, we had an MXUnit user describe a similar, though not identical, problem after installing the latest hotfixes. In his case, he's getting "NoSuchMethodExceptions".

  • Instantiating a class within itself ?!

    Hi guys,I just started playing around with Java, trying to understand the core base of this language.
    I have created a simple class and just-for-try I instantiated this class from inside itself.
    public class PrivAndPublic{
    PrivAndPublic o = new PrivAndPublic();
    }//end of class
    It doesn't give me any compiling error!
    Doesn't it sound strange?!
    I cannot understand how is it possible and it really seems a bug to me.
    Thanks for any help!

    What Darcia wrote make me suppose that a class is totally created with the first line of a java file (i.e. public class PrivAndPublic{ )and initialized by the constructor (which, if omitted, comes by default with no arguments)...after all this, the class can be instantiated many times I want from inside the class itself.
    (I was thinking the class needed to reach the matching close curly brace to be possible to instantiate it)
    But as phyzome said I have to be careful to do not make the object call the method which I put the object in, otherwise I will cause an infinite loop...as I did try ;)
    Thanx guys, see you.

  • Why we can't instantiated System class.

    Hi All,
    I can't undersatnd what type of class is "System". We can't instantiated system class but we can use it like a Static class.

    There are number of classes like that. You don't
    instantiate them because you don't need to.Objects
    have state and behavior. State is captured inmember
    variables. None of the functionality the Systemclass
    provides requires an object to be instantiated and
    maintain state in member variables. It's pure
    behavior.I beg to differ. Given he fact that it has attributes
    (e.g. in, out and err), it does have a state...They're static attributes, so no instance (if one existed) would have its own state that would potentially distinguish it from other instances. That's what I was talking about.
    I, personally, think that static classes are rather
    bad OO (it's objects doing the work, not classes),
    but singletons are too burdensome to create.You mean uninstantiable classes with only static methods? (System is not a static class. Only nested classes can be static.)
    If your goal is to write pure OO, then, yeah, they might be bad. But then I don't think "perfect OO" is a particularly important or useful goal. Tool for the job and all that.

  • Instantiating member classes using reflection

    I have checked through this forum but if the answer to this question is here I missed it.
    I am trying to find out how to invoke the appropriate instantiation / constructor call to create an instance of a member class.
    The following works finepublic class Succeeds {
      public abstract static class AbstractMember {
      Succeeds(final AbstractMember am) {
      public static void main(final String[] args) {
        Succeeds a = new Succeeds (new Succeeds.AbstractMember () {
    }However I want to make the AbstractMember a real member class not a nested inner class and I want to instantiate the concrete subclass of AbstractMember in the constructor of Succeeds rather than outside the class. I tried the following:public class Fails {
      public abstract class AbstractMember {
        public class ConcreteMember extends AbstractMember {
      Fails(final Class<? extends AbstractMember> c)
        throws InstantiationException, IllegalAccessException {
        AbstractMember am = c.newInstance() ;
      public static void main(final String[] args)
        throws InstantiationException, IllegalAccessException {
        Fails a = new Fails (Fails.AbstractMember.ConcreteMember.class) ;
    }(Please forgive the appling treatment of exceptions, I wanted to make a small example). This compiles fine but fails at runtime with an InstantiationException I assume because the nullary constructor doesn't exist for a member class because of the need to make the connection to the containing object.
    So the question is is there a bit of reflection that allows me to achieve what I want?
    I cannot be the first person to try doing this. I am hoping it is doable otherwise I am going to have to make the design a bit yukky.
    Thanks.

    import java.lang.reflect.*;
    public class Fixed
        public abstract class AbstractMember
        public class ConcreteMember extends AbstractMember
        <T extends AbstractMember> Fixed(final Class<T> c) throws Exception
            Constructor<T> ctor = c.getConstructor(new Class[]{getClass()});
            AbstractMember am = ctor.newInstance(new Object[]{this});
        public static void main(final String[] args) throws Exception
            new Fixed(ConcreteMember.class);
    }My exception handling is even more lax than yours. Why isn't there a class ReflectionException? I moved ConcreteMember out of AbstractMember to keep things simple. It's not entirely necessary, but I didn't want to construct an AbstractMember first.

  • Instantiating Java class while WAS is starting

    Is there a possibility to register Java classes within the SAP WAS which will be instantiated while the server starts up?

    Hi,
    to be honest, I have only a rough idea - may be you can emulate this behaviour  by  a web application, where in the deployment descriptor the load-on-startup flag is set ?
    Barbara

  • Instantiating a class by file - possible?

    Hi all!
    Is it possible to instantiate a class similar to Class.forName() when I only have the .class file?
    Any ideas?

    take a look at the newInstance() method in Class:
    "Creates a new instance of the class represented by this Class object. The class is instantiated as if by a new expression with an empty argument list. The class is initialized if it has not already been initialized."
    http://java.sun.com/j2se/1.4/docs/api/java/lang/Class.html#newInstance()

  • Instantiating a class within a class

    I've got a package with 2 classes. The first, we'll call it
    C1, is being instantiated within the main body of code. In turn, it
    instantiates another class, C2.
    Problem is, the C2 instantiation is not happening. However,
    if I instantiate the class within the main code body, the
    instantiations within C1 work ok. A chopped down version of my
    code:
    // main.swf
    import stuff.*;
    var myC1:C1 = new C1();
    var myC2:C2 = new C2(); // remove this line and the line
    below stops functioning
    // C1.as
    class stuff.C1 {
    public function C1() {
    trace('C1 instantiated');
    var anotherC2 = new C2(); // this line doesn't work unless
    the line above is included
    // C2.as
    class stuff.C2 {
    public function C2() {
    trace('C2 instantiated');
    So if I take the classes out of the package it works also, so
    I'm guessing it has something to do with the way I'm importing the
    files maybe? I dunno. Any thoughts?

    What Darcia wrote make me suppose that a class is totally created with the first line of a java file (i.e. public class PrivAndPublic{ )and initialized by the constructor (which, if omitted, comes by default with no arguments)...after all this, the class can be instantiated many times I want from inside the class itself.
    (I was thinking the class needed to reach the matching close curly brace to be possible to instantiate it)
    But as phyzome said I have to be careful to do not make the object call the method which I put the object in, otherwise I will cause an infinite loop...as I did try ;)
    Thanx guys, see you.

  • Instantiating iner classes

    I wanted to know why an inner or local class cannot be instantiated with the newInstance() call? When I try to do this, it gives an InstantiationException both when the class is local (commented code below) and when it is inner (uncommented code below).
    class A {
        public void method1() throws Exception {
            System.out.println(getClass().getName());
            A a = (A) getClass().newInstance();
    public class TestInner {
        final class B extends A {
        void method2() throws Exception {
            final class B extends A {
            B b = new B();
            b.method1();
        public static void main(String[] args) throws Exception  {
            TestInner test = new TestInner();
            test.method2();
    }

    I wanted to know why an inner or local class cannot be
    instantiated with the newInstance() call? When I tryHere's a tested and working example:
    import java.lang.reflect.*;
    public
    class ClassReflection
      public
      static
      void main(String[] args)
      throws Exception
        Class enclosingClass, innerClass;
        Object enclosingObject, innerObject;
        Constructor constructor;
        // first create the enclosing class, otherwise it's not possible
        // to invoke the constructor of the inner class.
        enclosingClass = Class.forName("ClassReflection");
        constructor = enclosingClass.getDeclaredConstructor(new Class[]{});
        enclosingObject = constructor.newInstance(new Object[]{});
        innerClass = enclosingClass.getDeclaredClasses()[1];
        constructor = innerClass.getDeclaredConstructor(new Class[] {ClassReflection.class,Object.class});
        constructor.setAccessible(true);
        innerObject = constructor.newInstance(new Object[]{enclosingObject,null});
        System.out.println(innerObject);
      private
      ClassReflection()
      class InnerClassReflection
      extends ClassReflection
        private
        InnerClassReflection(Object object)
          System.out.println("I am an inner class");
    }

  • Error ( while instantiating a class)

    I encountered the following errors ...plz help..Click and Clicka are two public classes which i have written ..Both of them have actionPerformed function defined ..
    gui.java:14: cannot resolve symbol
    symbol  : class Click
    location: class gui
    ActionListener listner = new Click();
    *^*
    gui.java:18: cannot resolve symbol
    symbol  : class Clicka
    location: class gui
    ActionListener listnera = new Clicka();
    *^*
    *2 errors*
    import java.awt.event.ActionListener;
    import javax.swing.*;
    import java.awt.*;
    import java.applet.*;
    public class gui
           public static void main(String[] args)
            JFrame frame = new JFrame();
            JPanel panel = new JPanel();
          frame.getContentPane().add(panel);
            JButton button = new JButton("Click to Start IWRMS");
            panel.add(button);
            ActionListener listner = new Click();<----------------------------------------------------ERROR1
            button.addActionListener(listner);
          JButton buttona = new JButton("Stop Irrigation");
          panel.add(buttona);
          ActionListener listnera = new Clicka();<----------------------------------------------------ERROR2
          buttona.addActionListener(listnera);
            frame.setTitle("Intelligent Water Resource Management System");
            frame.setSize(500,500);
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setVisible(true);
    }now here is the class click that is have written ...
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    public class Clicks implements ActionListener
      {    String input;
           public void actionPerformed(ActionEvent event)
              input = JOptionPane.showInputDialog("Enter the location of hex file (example C://new.txt");
              JOptionPane.showMessageDialog(null, "You have selected " + input );
            Edited by: maneesh2706 on Jun 4, 2008 7:17 PM
    Edited by: maneesh2706 on Jun 4, 2008 7:17 PM

    ok..iam sorry it was a typing error...
    This is class click
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    public class Click implements ActionListener
      {    String input;
           public void actionPerformed(ActionEvent event)
              input = JOptionPane.showInputDialog("Enter the location of hex file (example C://new.txt");
               JOptionPane.showMessageDialog(null, "You have selected " + input );
    This is the class clicka
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    import java.io.FileReader;
    import java.io.IOException;
    import java.io.BufferedReader;
    import java.lang.*;
              public class Clicka implements ActionListener
            public void actionPerformed(ActionEvent event)
                JOptionPane.showMessageDialog(null,"Duration is sent via serial port!");
                fill_buffer();
       public void fill_buffer( )
    //code...this function is fine //
    }

  • Problems with static member variables WAS: Why is the static initializer instantiating my class?!

    Hi,
    I have been hunting down a NullPointerException for half a day to come to
    the following conclusion.
    My constructor calls a method which uses static variables. Since an intance
    of my class is created in the static block when the class is loaded, those
    statics are probably not fully initialized yet and the constructor called
    from the static block has those null pointer problems.
    I've considered moving the initialization of the static variables from the
    declaration to the static block. But your code is inserted BEFORE any other
    code. Therefore not solving my problem.
    Two questions:
    1) what would be a solution to my problem? How can I make sure my static
    variables are initialized before the enhancer generated code in the static
    block calls my constructor? Short of decompiling, changing the code and
    recompiling.
    2) Why is the enhancing code inserted at the beginning of the static block
    and not at the end? The enhancements would be more transparent that way if
    the static variables are initialized in the static block.
    Thanks,
    Eric

    Hi Eric,
    JDO calls the no-args constructor. Your application should regard this constructor as belonging
    primarily to JDO. For example, you would not want to initialize persistent fields to nondefault
    values since that effort is wasted by JDO's later initilization to persistent values. Typically all
    you want to initialize in the no-args constructor are the transactional and unmanaged fields. This
    rule means that you need initialization after construction if your application uses the no-args
    constructor and wants persistent fields initialized. On the other hand, if your application really
    uses constructors with arguments, and you're initializing persistent fields in the no-args
    constructor either unintentionally through field initializers or intentionally as a matter of
    consistency, you will find treating the no-args constructor differently helpful.
    On the other hand, if Kodo puts its static initializer code first as you report, then it is a bug.
    Spec Section 20.16: "The generated static initialization code is placed after any user-defined
    static initialization code."
    David Ezzio
    Eric Borremans wrote:
    >
    Hi,
    I have been hunting down a NullPointerException for half a day to come to
    the following conclusion.
    My constructor calls a method which uses static variables. Since an intance
    of my class is created in the static block when the class is loaded, those
    statics are probably not fully initialized yet and the constructor called
    from the static block has those null pointer problems.
    I've considered moving the initialization of the static variables from the
    declaration to the static block. But your code is inserted BEFORE any other
    code. Therefore not solving my problem.
    Two questions:
    1) what would be a solution to my problem? How can I make sure my static
    variables are initialized before the enhancer generated code in the static
    block calls my constructor? Short of decompiling, changing the code and
    recompiling.
    2) Why is the enhancing code inserted at the beginning of the static block
    and not at the end? The enhancements would be more transparent that way if
    the static variables are initialized in the static block.
    Thanks,
    Eric

  • Instantiating MXML class in AS3

    I have a simple MXML component:
    -- code -- 'MyClass'
    <mx:Canvas ... creationPolicy="none" ... >
      <mx:HBox id="innerPanel" >
        <mx:Canvas ... />
      </mx:HBox>
    </mx:Canvas>
    -- /code --
    I'm trying to instantiate this in AS3 as so:
    -- code --
    var myClass:MyClass = new myClass();
    myClass.createComponentsFromDescriptors(true);
    -- /code --
    myClass is created, but no children.  myClass.childDescriptors is empty.
    What am I doing wrong?
    thanx,
    rickb

    Unfortunatelly nothing of the above works when you have a chain of MXML's and AS's that are instantiating eachother. Not even the combination of all of the techniques mentioned earlier.
    I tried all of the above on the entire chain, and even placed callLater in the main canvas container but still creationComplete in MyMXML happens after callLater.
    I tried to be creative with the bellow pseudo pseudo code, I hope you get the idea.
    <MyMainCanvas>
    <script>
    onCreationComplete
    var myClass = new MyClass();
    addChild(myClass)
    callLater(doSomething)
    doSomething()
    // does nothing as none of the properties are available from MyMXML
    </script>
    </MyMainCanvas>
    MyClass extends Canvas
    function MyClass()
      var myMXML = new MyMXML();
      addChild(myMXML);
    <MyMXML>
    <script>
    onCreationComplete
       // this gets called after callLater in MyMainCanvas
    </script>
    </MyMXML>

  • Instantiation of class in BPEL process

    I have a very Strange problem, in my BPEL process I have used java embed Activity. on that activity if I am using Task class. then I am not able to deploy my process. its giving me following message.
    when I remove that line then I am able to deploy that process.
    following error comes when deployment.
    [10:29:41 AM] ---- Deployment started. ---- [10:29:41 AM] Target platform is (Weblogic 10.3). [10:29:41 AM] Running dependency analysis... [10:29:41 AM] Building... [10:29:52 AM] Deploying profile... [10:30:19 AM] Wrote Archive Module to D:\RegistrationUpload\RegistrationUpload\RegistrationUpload\deploy\sca_RegistrationUpload_rev21.0.jar [10:30:19 AM] Deploying sca_RegistrationUpload_rev21.0.jar to partition "default" on server soa_server1 [WIN-73I7I7QL8Z3.uradevt.gov.sg:8002] [10:30:19 AM] Processing sar=/D:/RegistrationUpload/RegistrationUpload/RegistrationUpload/deploy/sca_RegistrationUpload_rev21.0.jar [10:30:19 AM] Adding sar file - D:\RegistrationUpload\RegistrationUpload\RegistrationUpload\deploy\sca_RegistrationUpload_rev21.0.jar [10:30:19 AM] Preparing to send HTTP request for deployment [10:30:19 AM] Creating HTTPS connection to host:WIN-73I7I7QL8Z3.uradevt.gov.sg, port:8002 [10:30:19 AM] Sending internal deployment descriptor [10:30:20 AM] Sending archive - sca_RegistrationUpload_rev21.0.jar [10:33:45 AM] Received HTTP response from the server, response code=500 [10:33:45 AM] Error deploying archive sca_RegistrationUpload_rev21.0.jar to partition "default" on server soa_server1 [WIN-73I7I7QL8Z3.uradevt.gov.sg:8002] [10:33:45 AM] HTTP error code returned [500] [10:33:45 AM] Error message from server: Error during deployment: Error occurred during deployment of component: OfficerList to service engine: implementation.bpel, for composite: RegistrationUpload: ORABPEL-01005
    Failed to compile bpel generated classes. failure to compile the generated BPEL classes for BPEL process "OfficerList" of composite "default/RegistrationUpload!21.0*soa_27af417b-20d6-48d0-821c-4f26b3c4ce94" The class path setting is incorrect. Ensure that the class path is set correctly. If this happens on the server side, verify that the custom classes or jars which this BPEL process is depending on are deployed correctly. Also verify that the run time is using the same release/version. . [10:33:45 AM] Check server log for more details. [10:33:45 AM] Error deploying archive sca_RegistrationUpload_rev21.0.jar to partition "default" on server soa_server1 [WIN-73I7I7QL8Z3.uradevt.gov.sg:8002] [10:33:45 AM] #### Deployment incomplete. #### [10:33:45 AM] Error deploying archive file:/D:/RegistrationUpload/RegistrationUpload/RegistrationUpload/deploy/sca_RegistrationUpload_rev21.0.jar (oracle.tip.tools.ide.fabric.deploy.common.SOARemoteDeployer)
    follwing code I have used in snippet.
    <bpelx:exec import="org.w3c.dom.Element"/>
    <bpelx:exec import="com.ura.dams.workflow.process.OfficerList"/>
    <bpelx:exec import="oracle.bpel.services.workflow.task.model.Task"/>
    <bpelx:exec name="getTaskInfoForPO" version="1.5" language="java">
    <![CDATA[try                       
          OfficerList officerlist= new OfficerList();              
          String JobAssignmentType1= (String)getVariableData("JobAssignmentType");                
          String officerLevel1= (String)getVariableData("officerLevel");                
          String applicationType1= (String)getVariableData("applicationType");                
          String functionId1= (String)getVariableData("functionId");                
          String dcConservationFlag1= (String)getVariableData("dcConservationFlag");                
          String app_id_key1= (String)getVariableData("app_id_key");                
          String app_id_value1= (String)getVariableData("app_id_value");                
          String taskID1= (String)getVariableData("taskID");      
          String officer="";      
          String DConservatiionFlag="";      
          java.util.Hashtable keyValues= new java.util.Hashtable();           
            keyValues.put(app_id_key1, app_id_value1);       
          Task taskinfo= null;  
    catch(Exception e)
    System.out.println("error occured" + e);
    }]]>
    </bpelx:exec>
    Will anyone please tell me do I need to refer jar file in terms of BPEL process also.
    even same class I can use in my java files in the same project. (for other class its working like OfficerList)
    Environment is : Oracle SOA 11g, Jdeveloper
    please suggest something.

    Hi,
    I checked the same still no luck. I checked approx all combination.
    First I created a SOA-SAR file(jar file) , I extracted it and checked all jar files were there. orabpel.jar and bpm-services.jar and log4j jar. when i deployed that jar file. but it was not working
    then I put this in weblogic sever lib. it not worked.
    please tell me some points

  • Instantiating a class from another package

    Hi,
    I have two packages, say "framework" and "impl" -
    framework package (framework.jar)
    - contains base classes
    - contains factories to instantiate concrete classes
    - bundled in <product>.ear
    impl package (impl.jar)
    - contains implementation(concrete) classes
    - compile time dependency on framework.jar
    - bundled in <product>.ear
    I could successfully compiled and build <product>.ear which contains both the jars. The ear gets deployed successfully.
    PROBLEM
    Now, whenever a factory class (part of framework package) tries to instantitate an impl class (part of impl package) using -
    Class.forName(impl.ConcreteClassName OR fully_qualified_concrete_class_name).newInstance();
    It throws "classNotFoundException". It is not able to locate the concrete class.
    So, my question is how can i instantiate a class using its fully qualified name(package.classname) from another package ?
    Thanks.

    909219 wrote:
    PROBLEM
    Now, whenever a factory class (part of framework package) tries to instantitate an impl class (part of impl package) using -
    Class.forName(impl.ConcreteClassName OR fully_qualified_concrete_class_name).newInstance();
    It throws "classNotFoundException". It is not able to locate the concrete class.This sound like a classpath problem. Check your ear's manifest.
    BTW:
    Shouldn't the framework better use ServiceRegistry to load implementations?
    bye
    TPD

  • Why is the static initializer instantiating my class?!

    It seems that the static { ... } blocks for my enhanced classes actually
    create instances of those classes. Gack! It seems, furthermore, that
    this is due to the JDO spec itself, whose JDOImplHelper.registerClass()
    requires an instance of the class being registered. Double gack!
    This is causing a problem for me, because I've put a sequence generator in
    my class's constructor. Now merely **loading** a PC class will cause my
    sequence to be incremented (not great), or will throw an exception if the
    environment isn't set up for the sequence generator (terrible). This
    latter problem happens if I enhance my classes, then try to enhance them
    again -- the enhancer tries to load my class, the static { ... } block
    tries to load the sequence generator, and the whole enhancer blows up.
    Questions:
    * Why is this necessary? Why does JDOImplHelper.registerClass() take an
    instance of the class being registered? Could the call to
    JDOImplHelper.registerClass() happen the first time the ctor is called,
    instead of inside a static { ... } block?
    * Given that the above questions probably have reasonable answers, how
    should I work around this problem?
    Thanks,
    Paul

    Hi Patrick,
    Do you understand why jdoNewInstance and jdoNewObjectIdInstance are not static? And if that could
    be done, would that void the need to register the class when loaded?
    David
    Patrick Linskey wrote:
    >
    On 5/28/02 12:39 PM, "Paul Cantrell" <[email protected]> wrote:
    Questions:
    * Why is this necessary? Why does JDOImplHelper.registerClass() take an
    instance of the class being registered? Could the call to
    JDOImplHelper.registerClass() happen the first time the ctor is called,
    instead of inside a static { ... } block?The JDO spec inserts some utility methods into PersistenceCapable classes
    for which it needs a method around.
    These utility methods are the jdoNewInstance() methods and the
    jdoNewObjectIdInstance() methods. These methods improve performance by
    allowing PersistenceCapable objects and application ID OID classes to be
    created without using reflection.
    This class registration must occur at class initialization time, because
    your first operation on the class might very well be to look up objects of
    that class from the data store, in which the no-args constructor might not
    be called.
    * Given that the above questions probably have reasonable answers, how
    should I work around this problem?Your best bet is probably to not do the sequence generation in your no-args
    constructor. One option would be to create a constructor with a marker
    boolean that designates if sequence generation should occur; another
    probably more elegant solution would be to create a factory method that uses
    the default constructor and then assigns an ID, or fetches an ID and then
    invokes a non-default constructor with that ID.
    -Patrick
    Patrick Linskey [email protected]
    SolarMetric Inc. http://www.solarmetric.com

Maybe you are looking for

  • No Audio - External Speakers - Running VISTA x64 Ultimate

    I have seen numerous references to this problem in the forum archives... but no solutions yet. I run Vista x64 Ultimate natively on the Mac Pro - no VMware or other emulation software. Everything works great EXCEPT audio: I have searched and searched

  • How to leave the current dialog box screen?

    Hi Experts, Now I met a problem when I use statement LEAVE SCREEN for closing current dialog box screen. The scenario is like this: There is a screen '0010' under function group A, on this screen, there are 4 tabs, i created a custom control element

  • Snapshots. Audio creation. X-Fi. DONT WORK?

    Hey all. How do I delete the 'snapshots' i've made in the audio creation mode's console. I have seen similar posts here but they were from at least a year ago. No answers? Also. I've noticed that if you change the master sampling rate in this same co

  • How to load path names into next path?

    Attached vi is a routine that is supposed to act as follows: 1) Open a file for manipulation and conversion. 2) Perform calculations to derive velocity and accel values from displacement (this part not shown for simplicity). 3) Open a new file path d

  • Sapscript printing only the last value

    Hello, Im currently coding subroutine for medruck.. My problem is sapscript is only printing the last value of the item for all items.. For example: Item # 1    10 pcs  10,000.00 Item # 2     5 pcs   10,000.00 Item # 3     5 Pad  10,000.00 where actu