object in my package or the java library?

Hi i'm using JDI to capture MethodeEntry events, i then use the following code to get the object reference of the caller object:

ObjectReference caller =event.thread().frame(1).thisObject();

I was wondering how I can check whether the object reference returned above is from an object in my package or one which belongs to the java library:

Thanks in advance.

[385 byte] By [Ali_Erdogana] at [2007-10-2 16:53:27]
# 1
obj.getClass().getPackage().getName().startsWith("java") --> Java standard class
CeciNEstPasUnProgrammeura at 2007-7-13 18:05:32 > top of Java-index,Java Essentials,Java Programming...
# 2
Wait. getReferenceType().name().srtartsWith("java")
CeciNEstPasUnProgrammeura at 2007-7-13 18:05:32 > top of Java-index,Java Essentials,Java Programming...
# 3
thank you I will give that a tryif it works you don't know how much of a help it will be for me Cheers
Ali_Erdogana at 2007-7-13 18:05:32 > top of Java-index,Java Essentials,Java Programming...
# 4

Can I also ask how can i get the name which has been assigned to this object within the code :

For example

Test b2 = new Test();

how can i get the name of the instance ( b2 ), i can get the fact that it's an instance of Test but not the actual name.

Ali_Erdogana at 2007-7-13 18:05:32 > top of Java-index,Java Essentials,Java Programming...
# 5

> Can I also ask how can i get the name which has been

> assigned to this object within the code :

> For example

>

> Test b2 = new Test();

>

> how can i get the name of the instance ( b2 ), i can

> get the fact that it's an instance of Test but not

> the actual name.

I do not believe this is possible.

MrPicklesa at 2007-7-13 18:05:32 > top of Java-index,Java Essentials,Java Programming...
# 6

> Can I also ask how can i get the name which has been

> assigned to this object within the code :

You're not assigning a name to an object. You're assigning an object reference to a variable. Big difference; case in point:

Test b1 = new Test();

Test b2 = b1;

Test b3 = b1;

// and so on...

What "name" would expect the Test object to have?

(Note, there is no one "name", but a bunch of references that each point to the same object)

Hope this helps!

~

yawmarka at 2007-7-13 18:05:32 > top of Java-index,Java Essentials,Java Programming...