Serializable inner classes

How does one deal with the serialVersionUID issue with non-static member classes? Is this the best we can do?
class A implements java.io.Serializable {
  static final long serialVersionUID = 42;
  @SuppressWarnings("serial") class B implements java.io.Serializable {...}
}MC

How interesting. I never even tried! The language specs say: "inner classes cannot have static members, <em>except for static final fields that are initialized to constants</em>". This means that the declaration of m is valid but the declaration of n is rejected at compile-time:
class A implements java.io.Serializable {
  static final long serialVersionUID = 42;
  class B implements java.io.Serializable {
    static final long serialVersionUID = 42;
    static final String m = "42";
    static final String n = String.valueOf(42);
}MC

Similar Messages

  • Trying to serialize inner class and getting various errors.

    Hi, I'm working on a program that contains the inner class User. user implements serializable, and writes just fine. For some strange reason, though, after I read it, I keep getting NullPointerExceptions in my code.
    I also tried it using externalization. The User class is essentially built around a HashMap. I have the following methods:
    public void writeExternal(ObjectOutput out) throws IOException {
    out.writeObject(mainMap);
    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
    mainMap = (Map) in.readObject();
    String test = (String) in.readObject();
    Whenever inputstream.readObject() is called, though, I get an InvalidClassException; "no valid constructor." The sad part is that I have the method:
    public User () {
    main = new HashMap();
    Does anyone know what the problem is??? Thanks a lot!

    Does anyone know what the problem is???The inner class is not a static inner class. Therefore your constructor User, is actually User(OuterClass). Solution - make the class static OR use read and/or write resolution to reconstruct the relationship.

  • Serialization of inner class

    I have a class MyClass with a certain number of inner class, i.e. 2.
    public MyClass implements Serializable
         private int number = 0;    
         public MyClass (int a)
            number = a;
        public void doSomething()
           MyInnerClass1 clazz1 = new MyInnerClass1();
           clazz1.doSomethingElse(1);
           MyInnerClass2 clazz2 = new MyInnerClass2();
           clazz2.doSomethingElse(4);
        class MyInnerClass1
             public void doSomethingElse(int b)
                 a += b;
        class MyInnerClass1
            public void doSomethingElse(int b)
                 a -= b;
    }and I need to serialize it over a stream. But as you can see the inner classes work in a stateless way so in a strict sense I don't need to serialize those classes.
    How can I achieve it?

    I have a class MyClass with a certain
    number of inner class, i.e. 2.
    public MyClass implements Serializable
    private int number = 0;    
    public MyClass (int a)
    number = a;
    public void doSomething()
    MyInnerClass1 clazz1 = new MyInnerClass1();
    clazz1.doSomethingElse(1);
    MyInnerClass2 clazz2 = new MyInnerClass2();
    clazz2.doSomethingElse(4);
    class MyInnerClass1
    public void doSomethingElse(int b)
    a += b;
    class MyInnerClass1
    public void doSomethingElse(int b)
    a -= b;
    }and I need to serialize it over a stream. But as you
    can see the inner classes work in a stateless way so
    in a strict sense I don't need to serialize those
    classes.
    How can I achieve it?The classes are not Serialized. It is an Object which is Serialized.
    All the 3 classes are independent from the point of Serialization.
    Object of which class is desired to be Serialized?

  • SerialVersionUID and inner classes

    Hello All
    A quick question about serialVersionUID in inner classes.
    If an inner class can't have any static members, how come it's legal to define
    static final long serialVersionUID = 123L;
    in an inner class ? Is there something special about serialization that allows this ?

    there is nothing special about the serialVersionUID defintion -
    you can define static datamember of inner class as long as it is final or the inner class is static :
    public class Out {
    public Out() {
    private class In {
    static final int i1 = 1; //legal
    static int i2 = 2; //** illegal
    private static class InStatic{
    static final int i1 = 1; //legal
    static int i2 = 2; //legal
    }

  • OJC error w/ assert & inner class

    The following code generates an error:
    public class Foo {
    public class Bar {}
    public Foo() {}
    public static void main(String[] args) {
    assert false == true:"Foo Bar";
    ojc Foo.java -source 1.4 -classpath c:\j2sdk1.4.1\jre\lib\rt.jar -verbose
    [jdk location retrieved from JAVA_HOME environment variable: c:\j2sdk1.4.1]
    [classpath: c:\j2sdk1.4.1\lib\rt.jar;c:\j2sdk1.4.1\lib\i18n.jar;c:\j2sdk1.4.1\li
    b\sunrsasign.jar;c:\j2sdk1.4.1\lib\jsse.jar;c:\j2sdk1.4.1\lib\jce.jar;c:\j2sdk1.
    4.1\lib\charsets.jar;c:\j2sdk1.4.1\classes;c:\j2sdk1.4.1\jre\lib\rt.jar]
    [sourcepath: c:\j2sdk1.4.1\jre\lib\rt.jar]
    [encoding: default]
    makeLevel = 1
    [parsing C:\temp\Foo.java [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\AssertionError.class 50ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\Error.class 0ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\Throwable.class 0ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\Object.class 0ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\io\Serializable.class 0ms]
    60ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\Class.class 0ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\String.class 0ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\Comparable.class 0ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\CharSequence.class 0ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\RuntimeException.class 0ms]
    [loading c:\j2sdk1.4.1\jre\lib\rt.jar\java\lang\Exception.class 0ms]
    [flattening class Foo]
    [flattening class Foo$Bar]
    C:\temp\Foo.java:8: error #300: constructor AssertionError(<anything>) not found
    in class java.lang.AssertionError
    assert false == true:"Foo Bar";
    ^
    Total build elapsed time = 70ms
    [10 lines compiled in 70ms from 1 files, generating 0 classes]
    1 error
    The same code compiles fine with Sun's JDK 1.4.1 compiler. Removing the inner class allows the code to compile fine with OJC.
    Is this a known OJC bug?
    TIA,
    David

    It is a known bug that has been fixed in 9.0.4. We don't plan to ship 9.0.4
    anytime soon. If you are using 9.0.3, send me an email to
    [email protected] and I will send you a workaround. In your email
    specify the JDev build number that you are using (please, see
    about box).
    Regards,
    Michel

  • How to config POF to handle inner class

    Hi, I have the following vo object:
    public class Obj implements java.io.Serializable, PortableObject
    public static class InnerObj implements java.io.Serializable, PortableObject
    1) If i put both classes in the pof config xml, it throws class not found exception for the inner class InnerObj (as expected since there is no separate class files for it). My question is what is the correct way to handle the inner class? Should i just leave it out of the pof config xml and coherence will be smart enough to handle it?
    <pof-config>
    <user-type-list>
    <user-type>
    <type-id>111</type-id>
    <class-name>some.package.Obj</class-name>
    </user-type>
    <user-type>
    <type-id>222</type-id>
    <class-name>some.package.InnerObj</class-name>
    </user-type>
    </user-type-list>
    </pof-config>
    2) Also want to confirm if implement both java.io.Serializable & PortableObject in the vo, coherence will ALWAYS take the portable object serialization if <pof-enabled>true</pof-enabled> is set in the config?
    thanks!

    Hi i got the inner class config to work but now struggling to get it to run from the java client that connects to the cache. Went through the documents, it only made me more confused, so many config files...
    The exception i am getting now is from the java application that connects to the cache, when it tried to do a cache.putAll() it's throwing the following exception:
    An exception occurred while encoding a PutAllRequest for Service=ExtendTcpCacheService:TcpInitiator: java.io.IOException: unknown user type: some.package.Obj
    So far I have done the below to enable POF:
    1) On cache server I made the below changes, and both the cacheserver and extendproxy are running fine now.
    - changed xml to: <pof-enabled>true</pof-enabled>
    - dropped the jar containing the pof objects in the classpath
    - added override pof config xml:
    <pof-config>
    <user-type-list>
    <user-type>
    <type-id>8888</type-id>
    <class-name>some.package.Obj</class-name>
    </user-type>
    <user-type>
    <type-id>8889</type-id>
    <class-name>some.package.Obj$InnerObj</class-name>
    </user-type>
    </user-type-list>
    </pof-config>
    2) On the java project that connects to the cache:
    - changed -Dtangosol.coherence.cacheconfig xml file and added:
    <defaults>
    <serializer>pof</serializer>
    </defaults>
    I am sure i am missing some config somewhere, thank you for your help.
    Edited by: 920558 on Mar 28, 2012 2:15 PM

  • Another exception... Serializing inner classes

    Basically, I am tesing class dynamic loading, which I am failing to do till now using codebase within the local system. This was my original question,,, you can see it here http://forum.java.sun.com/thread.jspa?threadID=581979&tstart=0
    which I did not solve as of yet.
    However, this is a new question:
    Does this error look nice? am I making a mistake when serializing and returning an object of an inner class by a remote call?? I have this code in the server class:
    public Message getMessage()throws RemoteException{
    return new MyMessage();
    private class MyMessage implements Message{
    //code
    }Clinet class:
    Message message=server.getMessage(); //generates ExceptionException :
    java.lang.ClassCastException: cannot assign instance of $Proxy0 to field Server$MyMessage.this$0 of type Server in instance of Server$MyMessage
         at java.io.ObjectStreamClass$FieldReflector.setObjFieldValues(ObjectStreamClass.java:1977)
         at java.io.ObjectStreamClass.setObjFieldValues(ObjectStreamClass.java:1157)
         at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1918)
         at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1836)
         at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1713)
         at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1299)
         at java.io.ObjectInputStream.readObject(ObjectInputStream.java:339)
         at sun.rmi.server.UnicastRef.unmarshalValue(UnicastRef.java:290)
         at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:139)
         at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:179)
         at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132)
         at $Proxy0.getMessage(Unknown Source)
         at Client.main(Client.java:30)
    thank you very much...

    I believe I need to have a better design as you are
    suggesting...
    I want to have a set of Remote interfaces that can be
    implemented by different ways. These interfaces are
    then distributed for other developpers. Assuming it
    is a chat program where clients send Messages to
    other clients through a server, I would like to have
    each client implement his own RemoteClient in a way
    that suits him using Callbacks. Serializing a class
    that implements Message can be used to have it as
    means to communicate. Dynamic class loading is then
    used to get the classes for different implementation
    of Message that circles the clients.
    Two pieces definitely. The message which is of the group that says "please do this" and the functional part which is "for a given message do this".
    There are probably other parts as well.
    In that form, I wanted to test serializing anonymous
    Messages, but it did not work because the enclosing
    class will also be serialized (if it implemented
    Serializable of course) or would throw an exception
    if it does not implement it like the one in the
    questions above as I have learned. Even if Inner
    classes are used it still will not work. Only normal
    classes, or static inner classes would work.
    If the "functionality" is truly general then there probably should be only one message. It would have attributes something like this...
    - Function request name
    - List of function parameters.
    - List of function results.
    After getting answers to my problems, as always, I
    end up meeting new problems, I have these questions:
    How to serialize Actions(AbstractActions,
    ActionListeners)??What is an "action" and why do you need to serialize it?
    If it is a message then make it a message.
    How can I serialize this:
    button.addActionListener(new ActionListiner(){
    public void actionPerformed(ActionEvent e){You don't. At least not in terms of your above problem description.
    This code is gui code. It is neither a message nor a "function". You don't send guis somewhere else.
    /// or this
    button.addActionListiner(new MyAction());
    static class MyActionExtends implements
    ActionListener{
    public void actionPerformed(ActionEvent e){
    //code
    }Again you don't. I suspect you are mixing functionality.
    Your gui should talk to your message layer. You might even have a gui layer, a message layer and a message-gui layer.
    How can I overcome this problem?? Sending a GUI
    through RMI looks very nice!!! with Buttons that
    perform Remote Actions!!
    Based on your system description above it is simply wrong.
    Maybe there is more to your system though.

  • Problem with Outer and Inner Classes....or better way?

    Right now I'm trying to create an Inner class.
    My .java file compiles ok, and I create my jar file too.
    But when I try to instantiate the Inner class, it fails:
    java.lang.NoClassDefFoundError: com/myco/vlXML/vlXML$vlDocument.
    Here's the class code:
    public class vlXML{
        private ArrayList myDocList=new ArrayList(); //holds documents
        public vlXML(){
        private class vlDocument{
            public vlDocument(){
            //stuff goes here
        public vlDocument vlDOC(){
            return new vlDocument();
        public void addDocument(){
            vlXML xxx=new vlXML();
            vlDocument myDoc=xxx.vlDOC();
            myDocList.add(myDoc);
        public int getNumDocs(){
            return myDocList.size();
    }Then, from a jsp page, I call:
    vlXML junk1=new vlXML();
    junk1.addDocument();...and get the error...
    Can someone help me figure out why it's failing?
    Thanks....

    You nailed it - thanks....(duh!)
    While I have your attention, if you don't mind, I have another question.
    I'm creating a Class (outer) that allows my users to write a specific XML file (according to my own schema).
    Within the XML file, they can have multiple instances of certain tags, like "Document". "Document"s can have multiple fields.
    Since I don't know how many "Documents" they may want, I was planning on using an Inner Class of "Document", and then simply letting them "add" as many as necessary (thus the original code posted here).
    Does that seem like an efficient (logical/reasonable) methodology,
    or is there there something better?
    Thanks Again...

  • Problem with final variables and inner classes

    variables accessed by inner classes need to be final. Else it gives compilation error. Such clases work finw from prompt. But when I try to run such classes through webstart it gives me error/exception for those final variables being accessed from inner class.
    Is there any solution to this?
    Exception is:
    java.lang.ClassFormatError: com/icorbroker/fx/client/screens/batchorder/BatchOrderFrame$2 (Illegal Variable name " val$l_table")
         at java.lang.ClassLoader.defineClass0(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
         at com.sun.jnlp.JNLPClassLoader.defineClass(Unknown Source)
         at com.sun.jnlp.JNLPClassLoader.access$1(Unknown Source)
         at com.sun.jnlp.JNLPClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
         at com.icorbroker.fx.client.screens.batchorder.BatchOrderFrame.<init>(BatchOrderFrame.java:217)
         at com.icorbroker.fx.client.screens.batchorder.BatchOrderViewController.createView(BatchOrderViewController.java:150)
         at com.icorbroker.fx.client.screens.RealTimeViewController.initialize(RealTimeViewController.java:23)
         at com.icorbroker.fx.client.screens.batchorder.BatchOrderViewController.<init>(BatchOrderViewController.java:62)
         at com.icorbroker.fx.client.screens.displayelements.DisplayPanel$3.mousePressed(DisplayPanel.java:267)
         at java.awt.Component.processMouseEvent(Component.java:5131)
         at java.awt.Component.processEvent(Component.java:4931)
         at java.awt.Container.processEvent(Container.java:1566)
         at java.awt.Component.dispatchEventImpl(Component.java:3639)
         at java.awt.Container.dispatchEventImpl(Container.java:1623)
         at java.awt.Component.dispatchEvent(Component.java:3480)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450)
         at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3162)
         at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)
         at java.awt.Container.dispatchEventImpl(Container.java:1609)
         at java.awt.Window.dispatchEventImpl(Window.java:1590)
         at java.awt.Component.dispatchEvent(Component.java:3480)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)

    I've also been having the same problem. The only work-around seems to be to slightly change the code, recompile & hope it works. See http://forum.java.sun.com/thread.jsp?forum=38&thread=372291

  • Problem with final variables and inner classes (JDK1.1.8)

    When using JDK1.1.8, I came up with following:
    public class Outer
        protected final int i;
        protected Inner inner = null;
        public Outer(int value)
            i = value;
            inner = new Inner();
            inner.foo();
        protected class Inner
            public void foo()
                System.out.println(i);
    }causing this:
    Outer.java:6: Blank final variable 'i' may not have been initialized. It must be assigned a value in an initializer, or in every constructor.
    public Outer(int value)
    ^
    1 error
    With JDK 1.3 this works just fine, as it does with 1.1.8 if
    1) I don't use inner class, or
    2) I assign the value in initializer, or
    3) I leave the keyword final away.
    and none of these is actually an option for me, neither using a newer JDK, if only there is another way to solve this.
    Reasons why I am trying to do this:
    1) I can't use a newer JDK
    2) I want to be able to assign the variables value in constructor
    3) I want to prevent anyone (including myself ;)) from changing the value in other parts of the class (yes, the code above is just to give you the idea, not the whole code)
    4) I must be able to use inner classes
    So, does anyone have a suggestion how to solve this problem of mine? Or can someone say that this is a JDK 1.1.8 feature, and that I just have to live with it? In that case, sticking to solution 3 is probably the best alternative here, at least for me (and hope that no-one will change the variables value). Or is it crappy planning..?

    You cannot use a final field if you do not
    initialize it at the time of declaration. So yes,
    your design is invalid.Sorry if I am being a bit too stubborn or something. :) I am just honestly a bit puzzled, since... If I cannot use a final field in an aforementioned situation, why does following work? (JDK 1.3.1 on Linux)
    public class Outer {
            protected final String str;
            public Outer(String paramStr) {
                    str = paramStr;
                    Inner in = new Inner();
                    in.foo();
            public void foo() {
                    System.out.println("Outer.foo(): " + str);
            public static void main( String args[] ) {
                    String param = new String("This is test.");
                    Outer outer = new Outer(param);
                    outer.foo();
            protected class Inner {
                    public void foo() {
                            System.out.println("Inner.foo(): " + str);
    } producing the following:
    [1:39] % javac Outer.java
    [1:39] % java Outer
    Inner.foo(): This is test.
    Outer.foo(): This is test.
    Is this then an "undocumented feature", working even though it shouldn't work?
    However, I assume you could
    get by with eliminating the final field and simply
    passing the value directly to the Inner class's
    constructor. if not, you'll have to rethink larger
    aspects of your design.I guess this is the way it must be done.
    Jussi

  • Problem with constructor of inner class.

    Hi everybody!
    I have an applet which loads images from a database.
    i want to draw the images in a textarea, so i wrote an inner class, which extends textarea and overrides the paint method.
    but everytime i try to disply the applet in the browser this happens:
    java.lang.NoClassDefFoundError: WohnungSuchenApplet$Malfl�che
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:1590)
    at java.lang.Class.getConstructor0(Class.java:1762)
    at java.lang.Class.newInstance0(Class.java:276)
    at java.lang.Class.newInstance(Class.java:259)
    at sun.applet.AppletPanel.createApplet(AppletPanel.java:567)
    at sun.plugin.AppletViewer.createApplet(AppletViewer.java:1778)
    at sun.applet.AppletPanel.runLoader(AppletPanel.java:496)
    at sun.applet.AppletPanel.run(AppletPanel.java:293)
    at java.lang.Thread.run(Thread.java:536)
    so my class has no own constructor, it just has the paint method overwritten.
    my class looks like this:
    public class Malfl�che extends javax.swing.JTextArea{
    public void paint(Graphics g){
    Color grey=new Color(220,220,220);
    g.drawImage(img,10,10,null);
    how should a constructor for this class look like?
    sorry i am quite new to this, so i really dont have a clue!
    my class does not have any attributes or requires any so it doesnt need a constructor, doesnt it?
    thanks a lot
    tim

    First off, unlike regular classes, inner classes can be declared public, private, protected, and default.
    Secondly, why are you using the JTextArea to display an image, why not use a JLabel, which takes an Image object as its constructor.
    Thirdly, when you drew your image you did not give it a width and height
    g.drawImage(img, 0,0, img.getWidth(null), img.getHeight(null), null);
    otherwise it will make your image 1 X 1 pixels. not big enough to see.

  • Help: Factory Class using Inner Class and Private Constructor?

    The situation is as follows:
    I want a GamesCollection class that instantiates Game objects by looking up the information needed from a database. I would like to use Game outside of GamesCollection, but only have it instantiated by GamesCollection to ensure the game actually exist. Each Game object is linked to a database record. If a Game object exist, it must also exist in the database. Game objects can never be removed from the database.
    I thought about making the Game object an inner class of GamesCollection, but this means that Game class constructor is still visible outside. So what if I made Game constructor private? Well, now I can't create Game objects without a static method inside Game class (static Object factory).
    Basically what I need is a constructor for the inner Game class accessible to GamesCollection, but not to the rest of the world (including packages). Is there a way to do this?

    leesiulung wrote:
    As a second look, I was initially confused about your first implementation, but it now makes more sense.
    Let me make sure I understand this:
    - the interface is needed to make the class accessible outside the outer classBetter: it is necessary to have a type that is accessible outside of GameCollection -- what else could be the return type of instance?
    - the instance() method is the object factory
    - the private modifier for the inner class is to prevent outside classes to instantiate this objectRight.
    However, is a private inner class accessible in the outer class? Try it and see.
    How does this affect private/public modifiers on inner classes?Take about five minutes and write a few tests. That should answer any questions you may have.
    How do instantiate a GameImpl object? This basically goes back to the first question.Filling out the initial solution:
    public interface Game {
        String method();
    public class GameCollection {
        private static  class GameImpl implements Game {
            public String method() {
                return "GameImpl";
        public Game instance() {
            return new GameImpl();
        public static void main(String[] args) {
            GameCollection app = new GameCollection();
            Game game = app.instance();
            System.out.println(game.method());
    }Even if you were not interested in controlling game creation, defining interfaces for key concepts like Game is always going to be a good idea. Consider how you will write testing code, for example. How will you mock Game?

  • Threaded inner classes & heap memory exhaustion

    (_) how can i maximize my threading without running out of
    heap memory?
    push it to the limit, but throttle back before an
    java.lang.OutOfMemoryError.
    (_) within 1 threaded class ThreadClass, i have two threaded inner classes. for each instance of ThreadClass i only
    start one instance of each inner class.
    and, i start hundreds of ThreadClass, but not until the previously running ThreadClass object exits, so only one should be running at any given time.
    so, what about threaded inner classes?
    are they good? bad? cause "OutOfMemoryErrors"?
    are those inner threads not dying?
    what are common causes of:
    java.lang.OutOfMemoryError: java heap space?
    my program runs for about 5-minutes, then
    bails with the memory error.
    how can i drill down and see what
    is eating-up all my memory?
    thanks.

    A Thread class is not the same as a thread of
    execution. Those inner class based threads of
    execution are not dying.maybe. but this is the way i test a thread's life:
    public void run() {
    System.out.println("thread start");
    System.out.println("thread dies and release memory");
    }for each inner thread, and the outer thread, this approach for
    testing thread life reveals that they die.
    Why don't you use a thread pool?ok. i will think about how to do this.
    >
    If not, you need to ensure those inner threads have
    exited and completed.what is a 100% sure check to guarantee a thread exits other than
    the one i use above?
    note:
    the outer thread is running on a remote host, and the inner threads
    are running locally. here are the details:
    public class BB implements Runnable, FinInterface {
      public void run() {
        // do some work on the remote machine
      private void startResultsHandler(OisXoos oisX) {
         ResultHandler rh = new ResultHandler(oisX);
         rh.start();
      public void startDataProxy(OisXoos oisX, String query) {
         DataProxy dp = new DataProxy(oisX, query);
         dp.start();
            public class ResultsHandler extends Thread {
               // runs locally; waits for results from servers
               public void run() {
                   ObjectInputStream ois = new ObjectInputStream(oisX.input);
                    Set result = (Set) ois.readObject();
            }  // ____ class :: _ ResultsHandler _ :: class ____
           public class DataProxy extends Thread {
               // runs locally; performs db queries on behalf of servers
               public void run() {
                   ObjectOutputStream oos = new ObjectOutputStream(oisX.output);
                    while(moreData) {
                        .... // sql queries
                        oos.writeObject(data);
                 StartResultsHandler(oisX);
            } // _____ class  :: _ DataProxy _ :: class _____
    }now, the BB class is not started locally.
    the inner threads are started locally to both service data requests
    by the BB thread as well as wait for its results.
    (_) so, maybe the inner threads cannot exit (but they sure look
    like they exit) until their parent BB thread exits.
    (_) yet, those inner threads have no knowledge that the BB
    thread is running.
    externalizing those inner thread classes will put 2-weeks of work
    in the dust bin. i want to keep them internal.
    thanks.
    here this piece of code that controls everything:
    while(moreData) {
      FinObjects finObj = new BB();
      String symb = (String) data_ois.readObject();
      OisXoos oisX = RSAdmin.getServer();
      oisX.xoos.writeObject(finObj);
      finObj.startDataProxy(finObj, oisX, symb);
    }

  • Compiler error when useing switch statements in an inner class

    I have defined several constants in a class and want to use this constans also in an inner class.
    All the constants are defined as private static final int.
    All works fine except when useing the switch statement in the inner class. I get the compiler error ""constant expression required". If I change the definition from private static final to protected static final it works, but why?
    What's the difference?
    Look at an example:
    public class Switchtest
       private static final int AA = 0;     
       protected static final int BB = 1;     
       private static int i = 0;
       public Switchtest()
          i = 0; // <- OK
          switch(i)
             case AA: break; //<- OK, funny no problem
             case BB: break; //<- OK
             default: break;
      private class InnerClass
          public InnerClass()
             i = 0; // <- OK: is accessible
             if (AA == i) // <- OK: AA is seen by the inner class; i  is also accessible
                i = AA + 1;
             switch(i)
                case AA: break; // <- STRANGE?! Fail: Constant expression required
                case BB: break; // <- OK
                default: break;
    }Thank's a lot for an explanation.

    Just a though:
    Maybe some subclass of Switchtest could decalare its own variable AA that is not final, but it can not declare its own BB because it is visible from the superclass. Therefore the compiler can not know for sure that AA is final.

  • Passing Inner class name as parameter

    Hi,
    How i can pass inner class name as parameter which is used to create object of inner class in the receiving method (class.formane(className))
    Hope somebody can help me.
    Thanks in advance.
    Prem

    No, because an inner class can never have a constructor that doesn't take any arguments.
    Without going through reflection, you always need an instance of the outer class to instantiate the inner class. Internally this instance is passed as a parameter to the inner class's constructor. So to create an instance of an inner class through reflection you need to get the appropriate constructor and call its newInstance method. Here's a complete example:import java.lang.reflect.Constructor;
    class Outer {
        class Inner {
        public static void main(String[] args) throws Exception{
            Class c = Class.forName("Outer$Inner");
            Constructor cnstrctr = c.getDeclaredConstructor(new Class[] {Outer.class});
            Outer o = new Outer();
            Inner i = (Inner) cnstrctr.newInstance(new Object[]{o});
            System.out.println(i);
    }

Maybe you are looking for

  • Is there a way to use Edge as Navigation and Have the rest of the page in HTML

    Hi, I want to create a three-column CSS layout.  I want the left column (navigation) to be in Edge and have the remainder (plus header & footer) in static HTML.  I'm new to Edge and am hoping this is possible.  I know it will take some hard work, but

  • Can I install Windows 7 Pro 64bit on my Machine?

    My MacPro 8 core with 6GB of RAM is running MAC OSX 10.5.8. How can I tell if I can run Windows 7 Pro via Boot camp? Is my Mac machine 32bit or 64bit? Thanks Chaz

  • Rollover buttons in Forms 9i

    I have read that forms 9i has a built in rollver button capability such as seen in all web menu buttons where there is a series of bitmaps that differ for a mouse rollover, mouseup, mouse down, and hit. Is this true and if so how do I utilize this ca

  • Calling a function in WHEN-BUTTON-PRESSED

    Hello, i have in when-button-pressed a line containing select pachet_salarizare.ani_vechime(data_min, to_number(to_char(sysdate,'YYYY')), to_number(to_char(sysdate,'MM'))) into ani_vechime from dual;so i call a function which is in pachet_salarizare

  • How do I get back to QT 6.5.2?

    I have a g4 dual 1-gig running Panther (a single app keeps me in Panther... I'd need to spend about 5k to upgrade to Tiger). I was running QT 6.5.2 and things were working just fine. I had some codecs installed (I forgot which and where) and was play