How can I trace creation of objects?

I am wondering how I can trace creation of objects with new. For example:
interface CreationListener {
    void objectCreated(Object o);
class CreationNotifier {
    static void registerCreationListener(Class cls, CreationListener listener) {
        // registers `listener' to be notified after creating any object of class `cls'
class Test {
    public static void main(String[] args) {
        CreationNotifier.registerCreationListener(Integer.class, new CreationListener() {
            public void objectCreated(Object o) {
                System.out.println("Created Integer " + ((Integer)o).intValue());
        new Integer(2);  // Now I would expect to see `Created Integer 2' on my console...
}In other ways I want to get informed about every object of the specified class that gets created
throughout the application.
Does anyone have an idea about it? I was trying to find something appropriate in SecurityManager
but I failed :(
Please help!

I think you did not understand exactly what I meant. Your solution is only good for classes written by
me and I wanted to catch all object constructions in any class, e.g. one that I have only in a binary form.
Maybe Hashtable is
not the right data structure but I got to go back to
work :-) Let me know if you come up with a better
implementation.
-- Niladri.I created a WeakHashSet class on top of WeakHashMap which uses one static object as a value and really cares only about the keys. In the registrating class I have a HashMap with keys of type Class and values of WeakHashSet. The register method is simple:
public void register(Object o) {
    if (o == null) return;
    if (!map.containsKey(o.getClass()))    // this is the first object of this class being registered
        map.put(o.getClass(), new WeakHashSet());
    ((WeakHashSet)map.get(o.getClass())).add(o);    // WeakHashSet implements Set interface
}This design ensures (because of using WeakHashMap) that I only have live objects in my structure after running GC (in fact, I call System.gc() in methods to find the live objects of a specific class).
As you can see, my only problem is to have the object registration automate for classes that I have not written (and do not have sources).
And using the profiler is not portable (as I guess) - in examples for JProbe they used DLL's and UNIX shared objects. And that requires unusual switches when starting JVM. I would like to have an all-Java language solution as the code fragments which I have described come from a library which I am writing now and I should not make the users of it depend on switches or dynamic libraries...
Anyway, thanks for your good will. :-)

Similar Messages

  • How can we assign sproxy generated objects to a different package?

    Hello Expert,
    We need to change the package assigment of sproxy generated DDIC objects. How can we assign sproxy generated objects to a different package?
    Regards,
    Thulasi

    Any idea?

  • How can i access all the objects of one schema from another schema

    Dear All,
    How can i access all the objects(Tables,Views,Triggers,Procedures,Functions,Packages etc..) and do the modifications of one schema from another schema (Without using synonyms concept).
    Thanks in advance,
    Mahi

    First of all, synonyms only help you easy reference the object. It doesn't have any implication of object privilege.
    As long as you have proper privilege on target object. You can access it with or without synonyms.
    Assuming you have proper privilege of objects, you can use following command to assume schema owner.
    ALTER SESSION SET CURRENT_SCHEMA = Schema_owner

  • How can i reference a MIME object within a correspondence format through...

    how can i reference a MIME object within a correspondence format through TX oofo or se71?
    Hi, I need to put a MIME object within a correspondence's format that i've already done through Tx oofo. My problem is, that i don't know exactly how can i make the reference of that MIME object in the format? and What structure type do i have to use in order to make appear the MIME object in my correspondence's format? Does anybody can help me with this?   
    Regards    Hector

    Frank,
    I tried to find some examples/samples on how to create CollectionModel for a table component but not successful.
    Can you clarify the following ?
    1. "CollectionModel" is referenced only by af:table attributes "value", "selectedRowKeys" and "selectionListener".
    The rest of af:table attributes such as "rows", "fetchSize" used to reference the iterator binding in the binding container via the EL expression "#{bindings.VOIteratorBinding.xxx} .
    What should I replace that EL expression with?
    2. I heck out the bean method to create the CollectionModel as following, is it close to what you mean?
    public void initBusinessDataDashboardView() {
    OperationBinding operation = BeanUtils.getOperationBinding("getPanelBusinessData");
    Map params = operation.getParamsMap();
    Key panelKey = getPanelInfoView().getKey();
    params.put("panelKey", panelKey);
    params.put("maximizedView", false);
    panelView = (ViewObject)operation.execute();
    // Heck code to create CollectionModel
    RowSet rowSet = panelView.getRowSet();
    ArrayList rowList = new ArrayList();
    while (rowSet.hasNext()) {
    rowList.add(rowSet.next());
    model = new ChildPropertyTreeModel(rowList, null);
    // To be used to set up af:table value, selectRowKeys, selectionListener via EL expr #{backingBeanScope.MyBean.model.xxx}
    public CollectionModel getModel() {
    return model;
    Am I on the right track?
    Edited by: Pricilla on May 4, 2010 2:20 PM

  • How can i create a custom object 0REQUID

    Hello all,
    I have a question. How can i create a custom object 0REQUID? Is it possible to create it without actvating BI content?
    Thanks in advance..

    Hi,
    If you want to create a new info object which is a copy of 0REQUID. then
    Go to > info object key figure / Chara catalogue> create new key figure / Chara --> enter 0REQUID in front of TEMPLATE and you will get all details of 0REQUID in your new key figure / chara.
    Hope this helps.
    Assgn pts if helpful.
    Regards
    Edited by: chintamani deshmukh on Apr 14, 2008 11:09 AM

  • I lost my iphone in the woods and it is not connected to the internet. how can i trace it? and if i cant, can i take all the data, such as pictures from my old phone onto a new one?

    so i was walkin in the woods and somehow i droped it. its not conected to the internet. i know because i checked icloud. when i walked around to look for it i used a friends phone to call it so it would ring, but it went straight to voice mail.
    So, how can i trace it? and if i cant, can i take all the data, such as pictures from my old phone onto a new one?

    if you installed find my iphone app on it you can do these things from icloud if it's online
    if not you can't do anything

  • How can i copy,paste an Object ?

    How can i copy,paste an Object which i define by myself?

    implements Cloneable and define a clone method, for example
    public class ObjectA  implements Cloneable {
       // Data member
       String data;
       public ObjectA() {
       public void setData(String data) {
          this.data = data;
       public Object clone() {
           ObjectA tempObject = new ObjectA();
           tempObject.setData(this.data);
           return tempObject;
    }

  • How can I find services for object for PM Notification

    Hi all
    How can I find services for object(attached files ) for PM Notification  ?
    I can see then,for examle ,using transaction Iw22 :System---->Services for object
      My requirement are : 1. open attached file of selected notification for display ( if exists one)
                                     2. If user wants to attach file as service of object
                                           what function exists for it ?
    Please your help

    Hi SD,
    I have checked in SUIM and SU24 also. But I didn't find.  Could you please tell me any other way to finding out the authorization objects.
    Thanks,
    bsv.

  • How can I find out what objects are in a datafile???

    My database is 8.1.7...
    I have a tablespace with multiple datafiles. How can I find out what objects are in a specific datafile???
    Thanks in advance...

    DBA_SEGMENTS
    DBA_SEGMENTS describes the storage allocated for all segments in the database.
    Related View
    USER_SEGMENTS describes the storage allocated for the segments owned by the current user's objects. This view does not display the OWNER, HEADER_FILE, HEADER_BLOCK, or RELATIVE_FNO columns.
    Column Datatype NULL Description
    OWNER
    VARCHAR2(30)
    Username of the segment owner
    SEGMENT_NAME
    VARCHAR2(81)
    Name, if any, of the segment
    PARTITION_NAME
    VARCHAR2(30)
    Object Partition Name (Set to NULL for non-partitioned objects)
    SEGMENT_TYPE
    VARCHAR2(17)
    Type of segment: INDEX PARTITION, TABLE PARTITION, TABLE, CLUSTER, INDEX, ROLLBACK, DEFERRED ROLLBACK, TEMPORARY, CACHE, LOBSEGMENT and LOBINDEX
    TABLESPACE_NAME
    VARCHAR2(30)
    Name of the tablespace containing the segment
    HEADER_FILE
    NUMBER
    ID of the file containing the segment header
    HEADER_BLOCK
    NUMBER
    ID of the block containing the segment header
    BYTES
    NUMBER
    Size in bytes, of the segment
    BLOCKS
    NUMBER
    Size, in Oracle blocks, of the segment
    EXTENTS
    NUMBER
    Number of extents allocated to the segment
    INITIAL_EXTENT
    NUMBER
    Size in bytes requested for the initial extent of the segment at create time. (Oracle rounds the extent size to multiples of 5 blocks if the requested size is greater than 5 blocks.)
    NEXT_EXTENT
    NUMBER
    Size in bytes of the next extent to be allocated to the segment
    MIN_EXTENTS
    NUMBER
    Minimum number of extents allowed in the segment
    MAX_EXTENTS
    NUMBER
    Maximum number of extents allowed in the segment
    PCT_INCREASE
    NUMBER
    Percent by which to increase the size of the next extent to be allocated
    FREELISTS
    NUMBER
    Number of process freelists allocated to this segment
    FREELIST_GROUPS
    NUMBER
    Number of freelist groups allocated to this segment
    RELATIVE_FNO
    NUMBER
    Relative file number of the segment header
    BUFFER_POOL
    VARCHAR2(7)
    Default buffer pool for the object
    This view with this another viwe can help you to identify where the object is:
    DBA_DATA_FILES
    DBA_DATA_FILES describes database files.
    Column Datatype NULL Description
    FILE_NAME
    VARCHAR2(513)
    Name of the database file
    FILE_ID
    NUMBER
    NOT NULL
    File identifier number of the database file
    TABLESPACE_NAME
    VARCHAR2(30)
    NOT NULL
    Name of the tablespace to which the file belongs
    BYTES
    NUMBER
    Size of the file in bytes
    BLOCKS
    NUMBER
    NOT NULL
    Size of the file in Oracle blocks
    STATUS
    VARCHAR2(9)
    File status: AVAILABLE or INVALID (INVALID means that the file number is not in use, for example, a file in a tablespace that was dropped)
    RELATIVE_FNO
    NUMBER
    Relative file number
    AUTOEXTENSIBLE
    VARCHAR2(3)
    Autoextensible indicator
    MAXBYTES
    NUMBER
    Maximum file size in bytes
    MAXBLOCKS
    NUMBER
    Maximum file size in blocks
    INCREMENT_BY
    NUMBER
    Autoextension increment
    USER_BYTES
    NUMBER
    Corresponding number of bytes
    USER_BLOCKS
    NUMBER
    Number of blocks which can be used by the data
    Joel Pérez
    http://otn.oracle.com/experts

  • How can I drop the java objects from a schema

    hi..good afternoon all...
    How can I drop the java objects from a database schema???
    suppose the credentials are scott/tiger@db1
    Another thing is that...I have to do this from cmd(command prompt) as there is no plsql developer or sqldeveloper installed in the machine.
    plss help...thanks in advance...

    hi...i have already tried all the options..but it is showing the error..
    ora:01435 - user does not exist
    but when i have given the command...
    select object type, object_name, status from user_objects where object_type like'%JAVA%';
    then it is showing that the java_object is present....
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL>
    SQL>
    SQL>
    SQL> set linesize 200
    SQL>
    SQL>
    SQL>
    SQL> select object_type, object_name, status from user_objects where object_type
    like '%JAVA%';
    OBJECT_TYPE OBJECT_NAME
    STATUS
    JAVA CLASS javaclass1
    VALID
    JAVA SOURCE javaclass1
    VALID
    SQL> drop java source javaclass1.java;
    drop java source javaclass1.java
    ERROR at line 1:
    ORA-01435: user does not exist
    SQL>

  • How can i trace my stolen iphone

    dear team i purchsed iphone 3gs 16 gb from your uae distributor DU but while travling local railway train in india some one stolen my iphone. please can you suggest me how can i trace my iphone. any detail you need to trace iphone.
    regards

    You are not addressing Apple here, we are users just like yourself.
    Apple will not assist in any way in tracing/tracking your lost/stolen device.
    Your carrier may have some way of tracking your device.

  • How can i trace my lost iphone 4

    how can i trace my iphone since the lost phone is offline?

    The only way to find a lost iOS device is to use the Find my iPhone app or www.icloud.com.  For this to work, you have to enable this feature on the lost device prior to loss.  If you didn't do this, there is no way to find it.  Also, if the device is turned off or "Offline", there's no way to find it.  Neither Apple nor your carrier will find it for you.
    Setup Find my iPhone:
    http://support.apple.com/kb/PH2697
    Here's a good tip from Kappy on what to do if you device is lost or stolen:
    https://discussions.apple.com/docs/DOC-3362
    Good luck.

  • Hihaving a query like that who has done the Transport? How can i trace who

    having a query like that who has done the Transport? How can i trace who has done the transport (Import).
    I have tried with following steps but unable to find the right person.
    1. Go to TMS and disply the appropriate queue.
    2. Select menu path: Goto>Import History.
    3. Select menu path: Edit> Dipaly More.
    4. This will give the the "User" column.
    But my problem is the transport has happened long back. is there any other way to find out old import request who has done the transport.
    Please someone help me out on this.

    Do this may it can help you.
    At the last step where you had given "diaplay more"
    do this inspite of that:
    Extras --> Personal Settings
    Check the option "Query Interval Time" and try again.
    Best of luck !!!

  • How can u trace process of workflow throug workflow base table.

    Hi,
    My previous question might be confusing
    Just want to ask
    How can u trace process of workflow throug Which workflow base table.
    Please It's urgent
    Thanks
    Bachan

    Bachan,
    Why do you need to enable trace from the backend? You can run "bde_wf_item.sql" script, this script gives similar information as wfstatus.sql and wfstat.sql give but with more debugging information
    Note: 187071.1 - bde_wf_item.sql - Runtime Data of a Single Workflow Item
    https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=187071.1

  • How can we avoid cloning an object?

    how can we avoid cloning an object?

    maddy123 wrote:
    writing a singleton class but i want avoid the client to implement the cloneable for creating objectsHuh? What makes you think that's going to happen? Sounds like you have trust issues amongst developers, which would be better fixed by non-technical means

Maybe you are looking for

  • Fazer devolução de nota fiscal

    Prezados,           Qual o  procedimento a ser feito no SAP, uma vez que no sistema a nota foi cancelada, mas na SEFAZ não. Como vamos fazer a devolução da nota se a mesma está cancelada? O prazo de cancelamento do SEFAZ já passou. Garato, Fernando M

  • Whenever i try to open a video it starts quicktime but can't open the actual window

    It's only started happening recently but If i try to open a video, .mp4 for example, it opens quicktime and its shown on the dock and on the top bar but it doesn't actually open the window to play the thing. It just opens the app, nothing else. Does

  • Is it possible to continue downloading OS X Lion after shutting down the computer?

    I am downloading the OS X Lion app on my MacBook Pro and is only at 180mb after an hour. I am downloading this app for free because I recently purchased a MacBook Pro. Is there a way I can continue the download even after shutting down the computer?

  • Simple (stupid) question...

    Hello everyone! I have what I hope is a really dumb question... I'm trying to use JDBC through an applet and keep getting the following SQLException after trying to use the DriverManager.getConnection call: SQLState: 08001 Message : No suitable drive

  • ITunes mixing up song names and the album artworks.

    This is hard to explain but I'll do my best. For the record, I have 2 iPods that sync with the same playlist (iPod Touch 2nd Gen 4.2.1 for main music and iPod Nano 5th Gen for excercise). I decided to rip a recently purchased CD today and sync it to