Reference.clear method

I think that I do not understand the Reference.clear method. I am trying to use SoftReferences to store objects (actually Sets) that can be retrieved from filesystem files. And I am trying to use (override) the Reference.clear method to handle writing said file when one of them is about to go "byebye"...
But what is happening is that my clear method never gets called AND the SoftReference.get method returns null. (Which means that the referent is gone without clear having been called...which means I don't understand the clear method!)
SOOOOOO, can someone please either explain how I can be alerted to handle something just before something gets gc-ed, or else enlighten me to a better way to implement this?
Here's the longer story:
I have many "records", far too many to even consider keeping them all in memory at once. So I started storing them in "minisets" which I can serialize to files and retrieve as needed. The "minisets" are values in a HashMap with string keys.
When one of these Sets gets "big enough", I start storing a SoftReference to it instead of "it". Then when I need a particular set, I do a hashmap.get(key), then either (a) I get the Set, or (b) I get the the softref from which I can get the Set, or (c) I get the softref from which I cannot get the Set, in which case I go reconstruct the Set by reading a file.
The problem is writing the file... if I write a file every time I edit a (potentially large) Set then this program will take 5 days to run. So I think I want to write the file only when absolutely necessary....right before the gc eats it.
Thank you for help,
/Mel

Okay, here it is.
MyRef: My extension of PhRef. Also holds referent data that we need for cleanup, since we can't get to referent once Ref is enQ'ed.
Dummy: thie is the class that you're storing in the Sets or whatever, and that gets put in a reference.
Dummy's id_ member: This holds the place of whatever data you need for pre-bye-bye cleanup, e.g. a filename and the internal data of Dummy. MyRef grabs this when it's created.
(Note: what you may want to create a new class, say DummyWrapper that holds a Dummy and provides the only strongly reachable path to it, pass DummyWrapper to the Ref's constructor, and then have the Ref store the wrapped Dummy (e.g. wrapper.getDummy()) as its member var in place of the id_ that I'm storing--that is, in place of storing a bunch of internal data individually. Like I said, this approach seems overly complex, but I've not found a simpler way that works. I originally tried having the Ref store the Dummy directly as a member var, but then the Dummy was always strongly reachable.)
Poller: Thread that removes Refs from queue. You can probably just do this at the point in your code where you decide the set is "big enough", rather than in a separate thread.
dummies_: List that holds Dummies and keeps them strongly reachable until cleanup time. I think you said your stuff was in a Set or Sets. This is the parallel to your Set(s).
refs_: List of PhRefs to keep them reachable until they get enqueued.
When I don't use Refs properly to clean things up, I get OutOfMemoryError after about 60 or 120 iterations. (I tried a couple different sizes for Dummy, so I forget where I am now.) With the Refs in place, I'm well over 100,000 iterations and still going.
import java.lang.ref.*;
import java.util.*;
public class Ref {
    public static ReferenceQueue rq_ = new ReferenceQueue();
    // one of these lists was giving ConcurrentModificationException
    // so I sync'ed both cuz I'm lazy
    public static List dummies_ = Collections.synchronizedList(new ArrayList());
    public static List refs_ = Collections.synchronizedList(new ArrayList());
    public static Poller po_ = new Poller();
    public static void main(String[] args) {
        new Thread(po_).start();
        new Thread(new Creator()).start();
    public static class Poller implements Runnable {
        public void run() {
            // block until something can be removed, then remove
            // until nothing left, at which point we block again
            while (true) {
                try {
                    MyRef ref = ((MyRef)rq_.remove());
                    // This println is your file write.
                    // id_ is your wrapped Dummy or the data you need to write.
                    // You probably want a getter instead of a public field.
                    System.err.println("==================== removed "
                            + ref.id_  + "             ======  ===  ==");
                    ref.clear();  // PhRefs aren't cleared automatically
                    refs_.remove(ref); // need to make Ref unreachable, or referent won't get gc'ed
                catch (InterruptedException exc) {
                    exc.printStackTrace();
    public static class Creator implements Runnable {
        public void run() {
            int count = 0;
            while (true) {
                // every so often, clear list, making Dummies reachable only thru Ref
                if (count++ % 50 == 0) {
                    System.err.println("                 :::: CLEAR");
                    dummies_.clear();
                // give Poller enough chances to run  
                if (count % 16 == 0) {
                    System.gc();
                    Thread.yield();
                // Create a Dummy, add to the List
                Dummy dd = new Dummy();
                System.err.println("++ created " + dd.id_);
                dummies_.add(dd);
                // Create Ref, add it to List of Refs so it stays
                // reachable and gets enqueued
                Reference ref = new MyRef(dd, rq_);
                refs_.add(ref);
    public static class MyRef extends PhantomReference {
        private long id_;  // data you need to write to file
        public MyRef(Dummy referent, ReferenceQueue queue) {
            super(referent, queue);
            id_ = referent.id_;
        public void clear() {
            System.err.println("-------CLEARED " + get());
        public String toString() {
            return "" + id_;
    public static class Dummy {
        // just a dummy byte array that takes up a bunch of mem,
        // so I can see OutOfMemoryError quickly when not using
        // Refs properly
        private final byte[] bb = new byte[1024 * 512];
        private static long nextId_;
        public final long id_ = nextId_++;
        public String toString() {
            return String.valueOf(id_);
}

Similar Messages

  • Reporting Against Level Reference Build Method

    All,
    I created a hierarchy in Essbase using the Level Reference build method since the data is in a bottom-up. The data is laid out like so:
    Statement
    --Assets
    ----Calc 1
    ------Calc 2
    --------Major Category 1
    --------Major Category 2
    --------Major Category 3
    ------Major Category 4
    ----Major Category 5
    --Liabilities
    ----Major Category 6
    Originally I had this in a generation reference, but that didn't work since we don't have a consistent number of layers for each item. Next I was thinking a parent-child relationship, but this doesnt work because major categories fall at different levels. Finally, I'm thinking level reference is the way to go since we can have different layers of parents for each lowest level member and the data can be laid out the way we need. (Let me know if you disagree with this approach).
    This works fine in the cube...however, when I import this into the BI Administration tool it only sees generations, not levels. How can I get it to pull in the levels so that I can add individual levels to a report?
    I'm planning on following this method to create the report: http://oraclebizint.wordpress.com/2008/01/10/oracle-bi-ee-101332-achieving-financial-template-layouts-using-pivot-tables/. However, when I do that with generations it has blanks because not all of the major categories are at the same generation. I'm hoping levels will clear this up, but if anyone has a suggestion of a different way to achieve this layout let me know.
    Thanks!

    Hi Corel,
    I am stucking on how and where to call the recursive function for performing Tree-level hierarchy for my above code.!
    in my hierarchy level, one parent has multiple children which in turn so many children and so on... if i am in the least level node , then i need to get the details of its related nodes which has been linked by that node.
    For ex: i have the structure somthing like below:
    Parent
    / | \
    child1 child2 child3
    |
    c5
    |
    c6
    In the above structure, Parent and its children sharing the same address id(56122). Suppose, If i am in c6, then i could get the references for C6->C5->child2->Parent as the hierarchy from ResultSet. child1 and child3 has been ignored ,since there is no implementation for saving their references.
    I am stucking here that i dont know how to save these ref. and get them too in the company hierarchy structure. Remember , i need to refer only the company which is sharing the same address id. there could be other address id assosiated with other children (not included here)
    any suggestion how to save the references by implementing recursive procedure from the resultset.
    thanks in advance

  • Can't make static reference to method while it is static

    Hello, can somebody please help me with my problem. I created a jsp page wich includes a .java file I wrote. In this JSP I called a method in the class I created. It worked but when I made the method static and adjusted the calling of the method it started to complain while i didnt make an instance of the class. the error is:Can't make static reference to method
    here is the code for the class and jsp:
    public class PhoneCheckHelper {
    public static String checkPhoneNumber(String phoneNumber) {
    String newPhoneNumber ="";
    for(int i=0; i<phoneNumber.length(); i++) {
    char ch = phoneNumber.charAt(i);
    if(Character.isDigit(ch)) {
    newPhoneNumber += String.valueOf(ch);
    return newPhoneNumber;
    <html>
    <head>
    <title>phonecheck_handler jsp pagina</title>
    <%@page import="java.util.*,com.twofoldmedia.text.*, java.lang.*" %>
    </head>
    <body>
    <input type="text" value="<%= PhoneCheckHelper.checkPhoneNumber(request.getParameter("phonenumberfield")) %>">
    </body>
    </html>

    Go over to the "New to Java" forum where that message is frequently explained. Do a search if you don't see it in the first page of posts.

  • Can't make static reference to method

    hi all,
    pls help me in the code i'm getting
    " can't make static reference to method....."
    kindly help me
    the following code gives the error:
    import java.rmi.*;
    import java.rmi.Naming;
    import java.rmi.RemoteException;
    import java.io.*;
    import java.io.IOException;
    import java.io.LineNumberReader;
    public class client
    static String vcno;
    static String vpin;
    static String vamt;
    static String vordid;
    static String vptype;
    //static String vreq;
    static String vreq = "1";
    static String vorgid;
    static String vm1;
    static String vs1;
    static String vqty1;
    static String vm2;
    static String vs2;
    static String vqty2;
    static String vm3;
    static String vs3;
    static String vqty3;
    static String vm4;
    static String vs4;
    static String vqty4;
    public static void main(String args[])
    try
    ServerIntf serverintf=(ServerIntf)Naming.lookup("rmi://shafeeq/server");
    int c;
    StringBuffer sb;
    FileReader f1=new FileReader("c:/testin.txt");
    sb=new StringBuffer();
    int line=0;
    while ((c=f1.read())!=-1) {
    sb.append((char)c);
    LineNumberReader inLines = new LineNumberReader(f1);
    String inputline;
    String test;
    while((inputline=inLines.readLine())!=null)
    line=inLines.getLineNumber();
    switch(line)
    case 1: {
    vcno = inLines.readLine();
    System.out.println(vcno);
    case 2: {
    vpin = inLines.readLine();
    System.out.println(vpin);
    case 3: {
    vptype = inLines.readLine();
    System.out.println(vptype);
    case 4: {
    vamt = inLines.readLine();
    System.out.println(vamt);
    case 5: {
    vordid = inLines.readLine();
    System.out.println(vordid);
    case 6: {
    vorgid = inLines.readLine();
    System.out.println(vorgid);
         case 7: {
    vm1 = inLines.readLine();
    System.out.println(vm1);
         case 8: {
    vs1 = inLines.readLine();
    System.out.println(vs1);
         case 9: {
    vqty1 = inLines.readLine();
    System.out.println(vqty1);
         case 10: {
    vm2 = inLines.readLine();
    System.out.println(vm2);
         case 11: {
    vs2 = inLines.readLine();
    System.out.println(vs2);
    case 12: {
    vqty2 = inLines.readLine();
    System.out.println(vqty2);
    case 13: {
    vm3 = inLines.readLine();
    System.out.println(vm3);
         case 14: {
    vs3 = inLines.readLine();
    System.out.println(vs3);
    case 15: {
    vqty3 = inLines.readLine();
    System.out.println(vqty3);
    case 16: {
    vm4 = inLines.readLine();
    System.out.println(vm4);
    case 17: {
    vs4 = inLines.readLine();
    System.out.println(vs4);
    case 18: {
    vqty4 = inLines.readLine();
    System.out.println(vqty4);
    f1.close();
    FileWriter f2=new FileWriter("c:/testout.txt");
    String t;
    t=ServerIntf.add(vcno,vpin,vamt,vordid,vptype,vreq,vorgid,vm1,vs1,vqty1,vm2,vs2, vqty2,vm3,vs3,vqty3,vm4,vs4,vqty4);
    String str1 = " >>";
    str1 = t + str1;
    f2.write(str1);
    System.out.println('\n'+"c:/testout.txt File updated");
    f2.close();
    catch(Exception e)
    System.out.println("Error " +e);

    Yes, ServerIntf is the interface type. The instance serverIntf. You declared it somewhere at the top of the routine.
    So what you must do is call t=serverIntf.add(...)This is probably just a mistype.

  • Clear method and Garbage Collector

    Hi Gurus,
    Does the Clear method (hashtable, vector etc..) is a good option for garbage collection ?
    In other words, if I have a vector V with 100 elements and I perform a V.clear(), am I sure that the 100 elements are now candidates for the Garbage Collection ?
    Or is it better to write a loop performing a NULL assignment for each element of the vector ?

    Hi schapel,
    I know it's not a good idea to force the garbage collector, but let me explain what I am confronted with.
    (FYI, I didn't write the source code. Comes from a 3rd party)
    The aim is to build a jsp page which is the list of the files contained in a web server directory.
    I have a "Directory" class, and a "File" class. To build the jsp, each directory of the webserver is represented by a directory class, and each file, ...by a file class.
    To simplify, when the tree structure of the web server is build in memory, I create a jsp page to list the files, and then, I do not need the vector anymore. But the vector can be quite huge and each client will build his own vector at the begening of his session (and will never use it again during the session).
    Don't you think it's usefull in that situation to free some memory ?

  • Azure Dedicated Role Cache does not fire notification to client when call DataCache.Clear method

    Hi,
    I'm using Azure Dedicated Role cache and  Enabled the local cache and notification.
    <localCache isEnabled="true" sync="NotificationBased" objectCount="20000" ttlValue="3600" />
    <clientNotification pollInterval="1" maxQueueLength="10000" />
    but when I call DataCache.Clear method in one client, the notification does not send to all clients, the client's local cached content still been used.
    is this a bug of Azure SDK 2.5?

    I assume that you have correctly configured and enabled Cache notifications, instead of using the DataCache's clear method - have you tried clearing all regions in your cache because I am not sure if DataCache.Clear triggers the cache notification or not.
    so your code should look something like this
    foreach (string regionName in cache.GetSystemRegions())
    cache.ClearRegion(regionName)
    You can refer the link which explains about Triggering Cache Notifications  https://msdn.microsoft.com/en-us/library/ee808091(v=azure.10).aspx
    Bhushan | Blog |
    LinkedIn | Twitter

  • Will JDeveloper support INTERVAL and REFERENCES partitioning methods soon?

    JDeveloper is a fantastic tool, and I'm very impressed with its data modeling capabilities as they are quite robust. However, currently its support for Table Partitioning is limited to the feature level of Oracle 10g, as it does not support 11g INTERVAL or REFERENCES partitioning methods, nor the Composite List partitioning methods List-Range, List-Hash, and List-List.
    Any idea when JDeveloper will support these Partitioning enhancements available in Oracle Database 11g? If it's in the works, I'd be happy to help beta test it!
    Best regards,
    Terry

    Hi Terry
    I love it that you are working with the data modeling and would love to hear how you are using it. Please email me direct with more info
    We are working to get composite partitions (11g) into a future release but I don't have any timeframe for you at the moment.
    rgds
    Susan Duncan
    Product Manager
    susan.duncan@oracle

  • Alsett clearing method in dreamweaver

    Hi everyone, has anyone used this in DW? My page looks wrong
    in Dreamweaver design view, but displays fine in the
    browser.

    Yep. Like much of the stuff I find on ALA, it's academically
    interesting,
    but practically useless.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "T.Pastrana - 4Level" <[email protected]> wrote in message
    news:[email protected]...
    >I agree.
    >
    > In that article he states...
    >
    > "
    > First and foremost, this clearing method is not at all
    intuitive,
    > requiring an extra element be added to the markup. One
    of the major
    > premises of CSS is that it helps reduce the bloated HTML
    markup found it
    > the average site these days. So having to re-bloat the
    markup just so
    > floats can be kept within their containers is not an
    ideal arrangement.
    > "
    >
    > Adding this... <div
    style="clear:both;"></div> ... doesn't seem like HTML
    > bloat to me, but with the method in the article you need
    to add this to
    > the CSS...
    >
    > .clearfix:after {
    > content: ".";
    > display: block;
    > height: 0;
    > clear: both;
    > visibility: hidden;
    > }
    >
    > .clearfix {display: inline-table;}
    >
    > /* Hides from IE-mac \*/
    > * html .clearfix {height: 1%;}
    > .clearfix {display: block;}
    > /* End hide from IE-mac */
    > What a mess! and it is bloating the CSS file so it
    doesn't make much sense
    > to me :-)
    >
    >
    > --
    > Regards,
    > ..Trent Pastrana
    > www.fourlevel.com
    >
    >
    >
    >
    >
    > "Murray *ACE*" <[email protected]>
    wrote in message
    > news:[email protected]...
    >> Thanks. I don't like it. Sorry. It forces me to
    remember to hack/zoom
    >> for IE.
    >>
    >> My <br class="clearer" /> works fine.
    >>
    >> --
    >> Murray --- ICQ 71997575
    >> Adobe Community Expert
    >> (If you *MUST* email me, don't LAUGH when you do
    so!)
    >> ==================
    >>
    http://www.dreamweavermx-templates.com
    - Template Triage!
    >>
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    >>
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    >>
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    >> ==================
    >>
    >>
    >> ".: Nadia :. **AdobeCommunityExpert**"
    >> <[email protected]>
    wrote in message
    >> news:[email protected]...
    >>>
    >>> "Murray *ACE*"
    <[email protected]> wrote in message
    >>> news:[email protected]...
    >>>> Used what? Which DW?
    >>>
    >>>
    http://www.positioniseverything.net/easyclearing.html
    >>>
    >>> A way of clearing divs....
    >>>
    >>>
    >>> --
    >>> Nadia
    >>> Adobe� Community Expert : Dreamweaver
    >>>
    >>>
    http://www.DreamweaverResources.com
    - CSS Templates|Tutorials
    >>>
    http://www.csstemplates.com.au
    >>>
    >>>
    http://www.perrelink.com.au
    - Web Dev
    >>>
    >>>
    http://www.adobe.com/devnet/dreamweaver/css.html
    >>> CSS Tutorials for Dreamweaver
    >>>
    >>>
    >>>
    >>>
    >>
    >>
    >
    >

  • Clear() method

    gridPane.getChildren().clear()
    I just would like to know if above method call is recursive to wipe out everything?
    The reason is I don't want anything to stay on stack.

    This is not a recursive call:
        grid.add(category, 1, 0);
        Label  chartTitle = new Label("Current Year");
        grid.add(chartTitle, 2, 0);
        Label  chartSubtitle = new Label("Goods and Services");
        grid.add(chartSubtitle, 1, 1, 2, 1);
        grid.getChildren().addListener(new ListChangeListener<Node>() {
                public void onChanged(ListChangeListener.Change<? extends Node> c) {
                    while (c.next()) {
                       System.out.println(c); 
            grid.getChildren().clear();The clear method fired only one change notification.

  • Error: reference to method is ambiguous

    Hi guys,
    Here is the line that won't compile:
    ((p)(o1)).g.a.(this);
    Here is the error:
    reference to a is ambiguous, both method a(av) in au and method a(bu)in at match ((p)(o1)).g.a.(this);
    So I want to try calling either au.a or at.a explicitly but I can't figure out how to do that.
    Any help is greatly appreciated. This is for an online game where (bad)people can boot others so I am trying to write a patch. Thanks alot.

    The explanation isn't totally clear - but you can use as much of "package.classname.method()" reference as needed to disambiguate the code. I.E. "package.classname.method()" or "classname.method()".
    Post some applicable code that clearly shows the relationships if more help is needed.

  • Regarding remove() and clear () method

    when we call clear() and remove(index) method for vector or hashtable, the element will be removed and the size decreases by one . The question is wheteher the memory will get freed when these methods are called?

    Hi,
    Vectors hold only references to other objects. Hence, when you "add or remove" elements to vectors, you are only adding or removing references to other objects in the heap.
    Memory taken by objects in the heap is freed as per the whims of the garbage collector. Unless your program does some memory-intensive computation, the garbage collector might not even run during your program's execution phase.
    If you have declared Vector v = new Vector();, the JRE will create a vector object in the heap, capable of storing 10 references. If you try to add an 11th reference to the vector, the Vector object will grow automatically by a default increment. Since in your code you are adding and removing references continuously, the Vector size will remain the same as long as the number of references never exceeds 10.
    Regards,
    Kumar.

  • Are weak references cleared with soft ones?

    Suppose a program holds both weak and soft references to an object X. Suppose the virtual machine clears all the soft references at once, making X weakly reachable. Is the virtual machine guaranteed to clear all the weak references next before normal execution resumes?
    I ask because I am setting up an automatic interning system for immutable objects of a certain class that will guarantee that at most one object of a given value is reachable by the rest of the program at one time but will allow objects to be garbage collected if necessary. I need to decide what reference object(s) to keep to each interned object. If I keep only a weak reference, objects will be discarded at the whim of the virtual machine; I would prefer to keep them around longer so they don't have to be recreated so many times. If I keep only a soft reference, I am concerned that another part of the program might keep a weak reference. If the answer to my question above is "no", the soft reference could be cleared and the interning system could create a second object with the same value while the first is still accessible via the weak reference. It seems safest to keep both a soft reference and a weak reference and only recreate the object if the weak reference has been cleared.

    Softs hang around until memory needs dictate theygo.
    In my experience (Apple's 1.4 VM) this appears to be
    as soon as GC is run, making them effectively
    useless. Maybe VMs have improved.Not in my experience (Sun 1.4 VM). Soft references hang around forever. I had to stuff my class with bloat to make the instance larger, then change the VM heap size to get it to start collecting my soft references. Whereas the weak references are dumped ASAP. Inside scoop has it that finalizers will delay object collection a bit so be careful of that.
    Also the only guarantee is that soft is cleared before weak when they refer to the same object. in my experience weak references go quickly. Like at the first GC when they are weak. You can not depend on any timing with respect to when the weak will be cleared. I don't think the spec even guarantees that soft will be enqueued before weak. Im not sure on that point.

  • Passing object references to methods

    i got the Foo class a few minutes ago from the other forum, despite passing the object reference to the baz method, it prints "2" and not "3" at the end.
    but the Passer3 code seems to be different, "p" is passed to test() , and the changes to "pass" in the test method prints "silver 7".
    so i'm totally confused about the whole call by reference thing, can anyone explain?
    class Foo {
        public int bar = 0;
        public static void main(String[] args) {
                Foo foo = new Foo();
                foo.bar = 1;
                System.out.println(foo.bar);
                baz(foo);
                // if this was pass by reference the following line would print 3
                // but it doesn't, it prints 2
                System.out.println(foo.bar);
        private static void baz(Foo foo) {
            foo.bar = 2;
            foo = new Foo();
            foo.bar = 3;
    class Passer2 {
         String str;
         int i;
         Passer2(String str, int i) {
         this.str = str;
         this.i = i;
         void test(Passer2 pass) {
         pass.str = "silver";
         pass.i = 7;
    class Passer3 {
         public static void main(String[] args) {
         Passer2 p = new Passer2("gold", 5);
         System.out.println(p.str+" "+p.i);  //prints gold 5
         p.test(p);
         System.out.println(p.str+" "+p.i);   //prints silver 7
    }

    private static void baz(Foo foo) {
    foo.bar = 2;
    foo = new Foo();
    foo.bar = 3;This sets the bar variable in the object reference by
    foo to 2.
    It then creates a new Foo and references it by foo
    (foo is a copy of the passed reference and cannot be
    seen outside the method).
    It sets the bar variable of the newly created Foo to
    3 and then exits the method.
    The method's foo variable now no longer exists and
    now there is no longer any reference to the Foo
    created in the method.thanks, i think i followed what you said.
    so when i pass the object reference to the method, the parameter is a copy of that reference, and it can be pointed to a different object.
    is that correct?

  • Finding references to methods

    Is there a way of finding where methods are used / referenced? e.g. in Websphere you can right-clight on a method & select the option "references to" and you get a list of all the places in your code where that method is used. Is there anything like this in JDeveloper?
    Similarly, is there a search facility to find all the classes that implement an interface?
    If the answers no, how do I suggext that these features are added in future versions? I've found them invaluable in the past when trying to understand the structure of code.

    I suggest you evaluate one of our partner's products, Aqris Software's RefactorIT:
    http://otn.oracle.com/products/jdev/htdocs/partners/content.html#aqris
    This is a downloadable extension that plugs directly into JDeveloper. It offers the searching capabilities you've asked for in addition to sophisticated refactoring capabilities.
    In future releases, we will add a subset of these features directly in JDeveloper. This forum is the best place to make those suggestions!
    -- Brian (JDev Team)

  • Passing object references via methods

    Why is the JFrame object not being created in the following code:
    public class Main {
      public static void main(String[] args) {
        Main main = new Main();
        JFrame frame = null;
        main.createFrame(frame);  // <-- does not create the "frame" object
        frame.pack();
        frame.setVisible(true);
      private void createFrame(JFrame frame) {
        frame = new JFrame("createFrame");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }Thanks.

    These explanations are great; real eye openers.
    OK. This could be a "way out in left field" question. I am just starting out with Java. But I want to ask:
    Objects are stored in the heap?
    Object references and primitives are stored on the stack?
    Adjusting heap size is straight-forward. A larger heap can store more/larger objects. What about stack sizes?
    C:\Dev\java -Xss1024k Main
    I assume this refers to method's stacks. But, what about object scoped, and class scoped, object references?
    public class Main {
      private static List list = new ArrayList(); // class scoped
      private JFrame frame = new JFrame();  // object scoped
      public static void main(String[] args) { ...... }
      private void createFrame() { .... }
    }How is the reference to list and frame stored, with regard to memory management?
    Do objects have stacks?
    Do classes have stacks?
    If not, how are the list and frame references stored (which helps me understand reference scoping).
    Would the overflow of a method stack (ex. via recurssion) also overflow the method's object and the method's class stacks?
    If these questions are stupid, "out of left field", don't matter, etc. Just ignore them.
    But the knowledge could help me avoid future memory related mistakes, and maybe pass a "Java Certified Developer" exam?
    My original question is already answered, so thanks to all.

Maybe you are looking for